|
@@ -1,10 +1,12 @@
|
|
|
package cn.com.taiji.service.impl;
|
|
|
|
|
|
import cn.com.taiji.constants.EsIndexConstants;
|
|
|
+import cn.com.taiji.entity.FusionNewShipJsonDTO;
|
|
|
import cn.com.taiji.entity.QueryVo;
|
|
|
import cn.com.taiji.entity.TianaoRadar;
|
|
|
import cn.com.taiji.service.TianaoService;
|
|
|
import cn.com.taiji.utils.DateUtils;
|
|
|
+import cn.com.taiji.vo.TianaoVo;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import org.elasticsearch.action.search.SearchRequest;
|
|
|
import org.elasticsearch.action.search.SearchResponse;
|
|
@@ -18,9 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @author chenfangchao
|
|
@@ -36,16 +36,18 @@ public class TianaoServiceImpl implements TianaoService {
|
|
|
private RestHighLevelClient restHighLevelClient;
|
|
|
|
|
|
@Override
|
|
|
- public List<TianaoService> tianaRader(QueryVo query) {
|
|
|
- List<String> tianaoRadarIdList = new ArrayList<>();
|
|
|
+ public List<TianaoVo> tianaRader(QueryVo query) {
|
|
|
+ List<TianaoVo> list = new ArrayList<>();
|
|
|
+ //天奥标识
|
|
|
+ Map<String, TianaoVo> tianaoRadarIdList = new HashMap<>();
|
|
|
String time = DateUtils.format(new Date(),"yyyy-MM-dd");
|
|
|
- SearchRequest searchRequest = new SearchRequest(EsIndexConstants.INDEX_SEAT_TRACK_RADAR + time);
|
|
|
+// SearchRequest searchRequest = new SearchRequest(EsIndexConstants.INDEX_SEAT_TRACK_RADAR + time);
|
|
|
+ SearchRequest searchRequest = new SearchRequest("index_seat_tianao_radar_fusion_ship_track_2022-11-24");
|
|
|
// 构建查询条件
|
|
|
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
|
|
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
|
|
- boolQueryBuilder.filter(QueryBuilders.rangeQuery("mergeTime").gte(query.getStartTime()).lte(query.getEndTime()));
|
|
|
+ boolQueryBuilder.filter(QueryBuilders.rangeQuery("fusionTime").gte(query.getStartTime()).lte(query.getEndTime()));
|
|
|
searchSourceBuilder.query(boolQueryBuilder);
|
|
|
-
|
|
|
searchRequest.source(searchSourceBuilder);
|
|
|
try {
|
|
|
SearchResponse search = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
|
|
@@ -53,13 +55,67 @@ public class TianaoServiceImpl implements TianaoService {
|
|
|
for (SearchHit hit : hits) {
|
|
|
String sourceAsString = hit.getSourceAsString();
|
|
|
TianaoRadar object= JSON.parseObject(sourceAsString,TianaoRadar.class);
|
|
|
- tianaoRadarIdList.add(object.getRadarCode());
|
|
|
+ //存储天奥
|
|
|
+ tianaoRadarIdList.put(object.getFusionBatchNum(),null);
|
|
|
}
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ //融合
|
|
|
+ SearchRequest fusionSearchRequest = new SearchRequest((EsIndexConstants.INDEX_SEAT_REALTIMETRAJECTORY + "2023-02-01"));
|
|
|
+ // 构建查询条件
|
|
|
+ BoolQueryBuilder fusionBoolQueryBuilder = QueryBuilders.boolQuery();
|
|
|
+ SearchSourceBuilder fusionSearchSourceBuilder = new SearchSourceBuilder();
|
|
|
+ boolQueryBuilder.filter(QueryBuilders.rangeQuery("mergeTime").gte(query.getStartTime()).lte(query.getEndTime()));
|
|
|
+ fusionSearchSourceBuilder.query(fusionBoolQueryBuilder);
|
|
|
+ fusionSearchRequest.source(fusionSearchSourceBuilder);
|
|
|
+ try {
|
|
|
+ SearchResponse fusionSearch = restHighLevelClient.search(fusionSearchRequest, RequestOptions.DEFAULT);
|
|
|
+ SearchHit[] hits = fusionSearch.getHits().getHits();
|
|
|
+ //通过融合数据匹配天奥数据
|
|
|
+ for (SearchHit hit : hits) {
|
|
|
+ Map<String, Object> sourceAsMap = hit.getSourceAsMap();
|
|
|
|
|
|
+ String mergeTarget = (String) sourceAsMap.get("merge_target");
|
|
|
+ String mergeTime = (String) sourceAsMap.get("merge_time");
|
|
|
|
|
|
+ String targetSource = (String) sourceAsMap.get("targetSource");
|
|
|
+
|
|
|
+ List<FusionNewShipJsonDTO> targetSourceList = JSON.parseArray(targetSource,FusionNewShipJsonDTO.class);
|
|
|
+ //融合子源信息匹配天奥、有两条相同的存储mergeTarget
|
|
|
+ for (FusionNewShipJsonDTO item : targetSourceList) {
|
|
|
+ if(null != item){
|
|
|
+ if(null != item.getType() && "TA_RADAR".equals(item.getType())){
|
|
|
+ //判断天奥数据里面是否包含融合数据
|
|
|
+ if(tianaoRadarIdList.containsKey(item.getTrackId())){
|
|
|
+ TianaoVo tianaoVo = tianaoRadarIdList.get(item.getTrackId());
|
|
|
+ //判断值是否为空
|
|
|
+ if(null != tianaoVo){
|
|
|
+ //判断值是否相等
|
|
|
+ if(!tianaoVo.getMergeTarget().equals(mergeTarget)){
|
|
|
+ TianaoVo obj = new TianaoVo();
|
|
|
+ obj.setStartTime(mergeTime);
|
|
|
+ obj.setMergeTarget(mergeTarget);
|
|
|
+ obj.setTargetSource(targetSource);
|
|
|
+ list.add(tianaoVo);
|
|
|
+ list.add(obj);
|
|
|
+ tianaoRadarIdList.remove(item.getTrackId());
|
|
|
+ }else {
|
|
|
+ TianaoVo obj = new TianaoVo();
|
|
|
+ obj.setStartTime(mergeTime);
|
|
|
+ obj.setMergeTarget(mergeTarget);
|
|
|
+ obj.setTargetSource(targetSource);
|
|
|
+ tianaoRadarIdList.put(item.getTrackId(),obj);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- return null;
|
|
|
+ return list;
|
|
|
}
|
|
|
}
|