Browse Source

[feat]#天奥船舶

chenfangchao 2 years ago
parent
commit
1c75df5af2

+ 27 - 0
beidou-analysis/pom.xml

@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>es-track-analysis</artifactId>
+        <groupId>cn.com.taiji</groupId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>beidou-analysis</artifactId>
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>cn.com.taiji</groupId>
+            <artifactId>es-track-common</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
+
+</project>

+ 18 - 0
beidou-analysis/src/main/java/cn/com/taiji/BeidouAnalySisApplication.java

@@ -0,0 +1,18 @@
+package cn.com.taiji;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * @author chenfangchao
+ * @title: BeidouAnalySisApplication
+ * @projectName es-track-analysis
+ * @description: TODO
+ * @date 2023/2/7 10:57 AM
+ */
+@SpringBootApplication
+public class BeidouAnalySisApplication {
+    public static void main(String[] args) {
+        SpringApplication.run(BeidouAnalySisApplication.class,args);
+    }
+}

+ 32 - 0
beidou-analysis/src/main/java/cn/com/taiji/controller/BeidouAnalySisController.java

@@ -0,0 +1,32 @@
+package cn.com.taiji.controller;
+
+import cn.com.taiji.entity.QueryVo;
+import cn.com.taiji.service.BeidouAnalySisService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @author chenfangchao
+ * @title: BeidouAnalySisController
+ * @projectName es-track-analysis
+ * @description: TODO
+ * @date 2023/2/7 10:59 AM
+ */
+@RequestMapping("/beidou/analysis")
+@RestController
+public class BeidouAnalySisController {
+
+    @Autowired
+    private BeidouAnalySisService beidouAnalySisService;
+
+    @PostMapping("/export")
+    public void beidouAnalySis(HttpServletResponse response, @RequestBody QueryVo query){
+        beidouAnalySisService.export(query);
+    }
+
+}

+ 15 - 0
beidou-analysis/src/main/java/cn/com/taiji/service/BeidouAnalySisService.java

@@ -0,0 +1,15 @@
+package cn.com.taiji.service;
+
+import cn.com.taiji.entity.QueryVo;
+
+/**
+ * @author chenfangchao
+ * @title: BeidouAnalySisService
+ * @projectName es-track-analysis
+ * @description: TODO
+ * @date 2023/2/7 10:59 AM
+ */
+public interface BeidouAnalySisService {
+
+    void export(QueryVo query);
+}

+ 26 - 0
beidou-analysis/src/main/java/cn/com/taiji/service/impl/BeidouAnalySisServiceImpl.java

@@ -0,0 +1,26 @@
+package cn.com.taiji.service.impl;
+
+import cn.com.taiji.entity.QueryVo;
+import cn.com.taiji.service.BeidouAnalySisService;
+import org.elasticsearch.client.RestHighLevelClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author chenfangchao
+ * @title: BeidouAnalySisServiceImpl
+ * @projectName es-track-analysis
+ * @description: TODO
+ * @date 2023/2/7 10:59 AM
+ */
+@Service
+public class BeidouAnalySisServiceImpl implements BeidouAnalySisService {
+
+    @Autowired
+    private RestHighLevelClient restHighLevelClient;
+
+    @Override
+    public void export(QueryVo query) {
+
+    }
+}

+ 7 - 0
beidou-analysis/src/main/resources/application-prod.yml

@@ -0,0 +1,7 @@
+taiji:
+  elasticsearch.rest:
+    uris: 74.10.28.65:9200,74.10.28.65:9201,74.10.28.65:9202,74.10.28.66:9200,74.10.28.66:9201,74.10.28.66:9202,74.10.28.67:9200,74.10.28.67:9201,74.10.28.67:9202,74.10.28.68:9200,74.10.28.68:9201,74.10.28.68:9202,74.10.28.69:9200,74.10.28.69:9201,74.10.28.69:9202
+    username: ax_seat       #如果你设置了基于x-pack的验证就要填写账号和密码
+    password: ax_seat       #没有则不用配置
+    connection-timeout: 100 #连接超时
+    max-connection: 100  #最大连接数

+ 10 - 0
beidou-analysis/src/main/resources/application.yml

@@ -0,0 +1,10 @@
+server:
+  port: 8081
+
+taiji:
+  elasticsearch.rest:
+    uris: 120.25.233.10:9200
+    username: elastic       #如果你设置了基于x-pack的验证就要填写账号和密码
+    password: root@2022!       #没有则不用配置
+    connection-timeout: 100 #连接超时
+    max-connection: 100  #最大连接数

+ 26 - 0
es-track-common/src/main/java/cn/com/taiji/entity/CountDTO.java

@@ -0,0 +1,26 @@
+package cn.com.taiji.entity;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @author chenfangchao
+ * @title: Count
+ * @projectName es-track-analysis
+ * @description: TODO
+ * @date 2023/2/7 3:42 PM
+ */
+@NoArgsConstructor
+@AllArgsConstructor
+@Data
+public class CountDTO implements Serializable {
+    private static final long serialVersionUID = 4984753519417414138L;
+
+    private Integer count;
+
+    private List<String> data;
+}

tianao-analysis/src/main/java/cn/com/taiji/entity/QueryVo.java → es-track-common/src/main/java/cn/com/taiji/entity/QueryVo.java


+ 19 - 0
hlx-one-fusion-analysis/pom.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>es-track-analysis</artifactId>
+        <groupId>cn.com.taiji</groupId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>hlx-one-fusion-analysis</artifactId>
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+    </properties>
+
+</project>

+ 2 - 0
pom.xml

@@ -12,6 +12,8 @@
         <module>es-track-common</module>
         <module>tianao-analysis</module>
         <module>fusion-analysis</module>
+        <module>beidou-analysis</module>
+        <module>hlx-one-fusion-analysis</module>
     </modules>
 
     <properties>

+ 13 - 0
tianao-analysis/pom.xml

@@ -22,6 +22,19 @@
             <artifactId>es-track-common</artifactId>
             <version>1.0-SNAPSHOT</version>
         </dependency>
+
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <version>5.1.46</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.mybatis</groupId>
+            <artifactId>mybatis</artifactId>
+            <version>3.5.9</version>
+        </dependency>
+
     </dependencies>
 
 </project>

+ 58 - 41
tianao-analysis/src/main/java/cn/com/taiji/service/impl/TianaoServiceImpl.java

@@ -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;
     }
 }