|
@@ -1,6 +1,7 @@
|
|
|
package cn.com.taiji.service.impl;
|
|
|
|
|
|
import cn.com.taiji.constants.EsIndexConstants;
|
|
|
+import cn.com.taiji.entity.CountDTO;
|
|
|
import cn.com.taiji.entity.FusionNewShipJsonDTO;
|
|
|
import cn.com.taiji.entity.QueryVo;
|
|
|
import cn.com.taiji.entity.TianaoRadar;
|
|
@@ -35,14 +36,14 @@ public class TianaoServiceImpl implements TianaoService {
|
|
|
@Autowired
|
|
|
private RestHighLevelClient restHighLevelClient;
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
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("index_seat_tianao_radar_fusion_ship_track_2022-11-24");
|
|
|
+ ArrayList<String> result = new ArrayList<>();
|
|
|
+ List<String> tianaoRadarList = new ArrayList<>();
|
|
|
+ IdentityHashMap<String, CountDTO> idenNewStringMap = new IdentityHashMap<>();
|
|
|
+ String time = DateUtils.format(new Date(), "yyyy-MM-dd");
|
|
|
+ SearchRequest searchRequest = new SearchRequest(EsIndexConstants.INDEX_SEAT_TRACK_RADAR + time);
|
|
|
// 构建查询条件
|
|
|
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
|
|
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
|
@@ -54,17 +55,18 @@ public class TianaoServiceImpl implements TianaoService {
|
|
|
SearchHit[] hits = search.getHits().getHits();
|
|
|
for (SearchHit hit : hits) {
|
|
|
String sourceAsString = hit.getSourceAsString();
|
|
|
- TianaoRadar object= JSON.parseObject(sourceAsString,TianaoRadar.class);
|
|
|
+ TianaoRadar object = JSON.parseObject(sourceAsString, TianaoRadar.class);
|
|
|
//存储天奥
|
|
|
- tianaoRadarIdList.put(object.getFusionBatchNum(),null);
|
|
|
+ tianaoRadarList.add(object.getFusionBatchNum());
|
|
|
}
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
+
|
|
|
//融合
|
|
|
- SearchRequest fusionSearchRequest = new SearchRequest((EsIndexConstants.INDEX_SEAT_REALTIMETRAJECTORY + "2023-02-01"));
|
|
|
+ SearchRequest fusionSearchRequest = new SearchRequest((EsIndexConstants.INDEX_SEAT_REALTIMETRAJECTORY + time));
|
|
|
// 构建查询条件
|
|
|
- BoolQueryBuilder fusionBoolQueryBuilder = QueryBuilders.boolQuery();
|
|
|
+ BoolQueryBuilder fusionBoolQueryBuilder = QueryBuilders.boolQuery();
|
|
|
SearchSourceBuilder fusionSearchSourceBuilder = new SearchSourceBuilder();
|
|
|
boolQueryBuilder.filter(QueryBuilders.rangeQuery("mergeTime").gte(query.getStartTime()).lte(query.getEndTime()));
|
|
|
fusionSearchSourceBuilder.query(fusionBoolQueryBuilder);
|
|
@@ -72,42 +74,27 @@ public class TianaoServiceImpl implements TianaoService {
|
|
|
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
|
|
|
+ List<FusionNewShipJsonDTO> targetSourceList = JSON.parseArray(targetSource, FusionNewShipJsonDTO.class);
|
|
|
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);
|
|
|
- }
|
|
|
+ if (null != item) {
|
|
|
+ if (null != item.getType() && "TA_RADAR".equals(item.getType())) {
|
|
|
+ if(idenNewStringMap.get(item.getTrackId()) != null){
|
|
|
+ CountDTO countDTO = idenNewStringMap.get(item.getTrackId());
|
|
|
+ countDTO.setCount(countDTO.getCount()+1);
|
|
|
+ List<String> data = countDTO.getData();
|
|
|
+ if(!data.contains(mergeTarget)){
|
|
|
+ data.add(mergeTarget);
|
|
|
+ countDTO.setData(data);
|
|
|
}
|
|
|
+ idenNewStringMap.put(item.getTrackId(),countDTO);
|
|
|
+ }else {
|
|
|
+ ArrayList<String> list = new ArrayList<>();
|
|
|
+ list.add(mergeTarget);
|
|
|
+ idenNewStringMap.put(item.getTrackId(),new CountDTO(1,list));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -116,6 +103,36 @@ public class TianaoServiceImpl implements TianaoService {
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- return list;
|
|
|
+ //遍历天奥数据、找到在一条天奥数据在融合中有两个不同mergeTarget的融合数据
|
|
|
+ for (String key : tianaoRadarList) {
|
|
|
+ //计算key在map中的数量,大于1则拿出map中的mergeTarget
|
|
|
+ CountDTO countDTO = idenNewStringMap.get(key);
|
|
|
+ if(countDTO.getCount() > 1){
|
|
|
+ List<String> data = countDTO.getData();
|
|
|
+ result.addAll(data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //导出融合数据
|
|
|
+ SearchRequest exportFusionSearchRequest = new SearchRequest(EsIndexConstants.INDEX_SEAT_REALTIMETRAJECTORY + time);
|
|
|
+ SearchSourceBuilder exportSearchSourceBuilder = new SearchSourceBuilder();
|
|
|
+ exportSearchSourceBuilder.query(QueryBuilders.termsQuery("mergeTime",result));
|
|
|
+ exportFusionSearchRequest.source(exportSearchSourceBuilder);
|
|
|
+ List<TianaoVo> data = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ SearchResponse response = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
|
|
|
+ SearchHit[] hits = response.getHits().getHits();
|
|
|
+ for (SearchHit hit : hits) {
|
|
|
+ Map<String, Object> sourceAsMap = hit.getSourceAsMap();
|
|
|
+ String mergeTarget = (String) sourceAsMap.get("merge_target");
|
|
|
+ String targetSource = (String) sourceAsMap.get("targetSource");
|
|
|
+ TianaoVo tianaoVo = new TianaoVo();
|
|
|
+ tianaoVo.setMergeTarget(mergeTarget);
|
|
|
+ tianaoVo.setStartTime(targetSource);
|
|
|
+ data.add(tianaoVo);
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return data;
|
|
|
}
|
|
|
}
|