Browse Source

提交海兰信原始数据解析代码

liangjianf 2 years ago
parent
commit
b7d123d9c9

+ 1 - 1
fusion-analysis/src/main/java/cn/com/taiji/constants/EsIndexConstants.java

@@ -47,5 +47,5 @@ public class EsIndexConstants {
     /**
      * 俯瞰融合
      */
-    public static final String INDEX_SEAT_FK_REALTIMETRAJECTORY_TEST = "index_seat_fk_realtimetrajectory_test";
+    public static final String INDEX_SEAT_FK_REALTIMETRAJECTORY = "index_seat_fk_realtimetrajectory_";
 }

+ 6 - 4
fusion-analysis/src/main/java/cn/com/taiji/controller/FusionAnalysisController.java

@@ -181,15 +181,17 @@ public class FusionAnalysisController {
     }
 
     /**
-     * 轨迹融合-导出天奥原始数据
+     * 轨迹融合-导出俯瞰原始数据
      * @param query
      * @param response
      * @throws IOException
      * @throws ParseException
      */
-    @PostMapping("excel/original/six")
-    public void fusionAnalysisExcelOriginalSix(@RequestBody FusionQuery query, HttpServletResponse response) throws IOException, ParseException {
-        fusionAnalysisService.fusionAnalysisExcelOriginalSix(query,response);
+    @PostMapping("excel/original/fk")
+    public void fusionAnalysisExcelOriginalFk(@RequestBody FusionQuery query, HttpServletResponse response) throws IOException, ParseException {
+        fusionAnalysisService.fusionAnalysisExcelOriginalFk(query,response);
     }
 
+
+
 }

+ 3 - 1
fusion-analysis/src/main/java/cn/com/taiji/service/FusionAnalysisService.java

@@ -68,7 +68,7 @@ public interface FusionAnalysisService {
 
     void fusionAnalysisExcelThree(FusionQuery query, HttpServletResponse response) throws IOException, ParseException;
 
-    abstract void fusionAnalysisExcelFour(FusionQuery query, HttpServletResponse response) throws IOException, ParseException;
+    void fusionAnalysisExcelFour(FusionQuery query, HttpServletResponse response) throws IOException, ParseException;
 
     void fusionAnalysisExcelOriginalOne(FusionQuery query, HttpServletResponse response) throws IOException, ParseException;
 
@@ -81,4 +81,6 @@ public interface FusionAnalysisService {
     void fusionAnalysisExcelOriginalFive(FusionQuery query, HttpServletResponse response) throws IOException, ParseException;
 
     void fusionAnalysisExcelOriginalSix(FusionQuery query, HttpServletResponse response) throws IOException, ParseException;
+
+    void fusionAnalysisExcelOriginalFk(FusionQuery query, HttpServletResponse response) throws IOException, ParseException;
 }

+ 46 - 0
fusion-analysis/src/main/java/cn/com/taiji/service/impl/FusionAnalysisServiceImpl.java

@@ -1403,6 +1403,52 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
         }
     }
 
+    @Override
+    public void fusionAnalysisExcelOriginalFk(FusionQuery query, HttpServletResponse response) throws IOException, ParseException {
+        List<FuseOriginal> list = new CopyOnWriteArrayList<>();
+        Date startTime = DateUtils.parse(query.getStartTime(),"yyyy-MM-dd");
+        String time = DateUtils.format(startTime,"yyyy-MM-dd");
+        SearchRequest request = new SearchRequest(INDEX_SEAT_FK_REALTIMETRAJECTORY+time);
+        // 构建查询条件
+        BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
+        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
+        boolQueryBuilder.filter(QueryBuilders.rangeQuery("mergeTime").gte(query.getStartTime()).lte(query.getEndTime()));
+        double[] doubles = new double[]{109.05069874931793,19.75955316191097,109.20963772383247,19.811999020000147,109.35696654655628,19.782373115430687,109.33374624297481,19.66386949715284,109.09473725611036,19.617428889989903,109.05069874931793,19.75955316191097};
+        List<GeoPoint> points = new ArrayList<>();
+        for(int i = 0 ;i < doubles.length;i=i+2) {
+            points.add(new GeoPoint(doubles[i+1],doubles[i]));
+        }
+        boolQueryBuilder.filter(QueryBuilders.geoPolygonQuery("location", points));
+        searchSourceBuilder.query(boolQueryBuilder);
+        searchSourceBuilder
+                .trackTotalHits(true)
+                .sort(SortBuilders.fieldSort("mergeTime").order(SortOrder.ASC))
+                .size(query.getPageSize())
+                .timeout(TimeValue.timeValueHours(1L))
+                .timeout(TimeValue.timeValueMinutes(30L))
+                .timeout(TimeValue.timeValueSeconds(500L));
+        request.source(searchSourceBuilder);
+        SearchResponse search = client.search(request, COMMON_OPTIONS);
+        SearchHits searchHits = search.getHits();
+        SearchHit[] hits = searchHits.getHits();
+        for (SearchHit hit : hits) {
+            FuseOriginal fuseOriginal = JSONObject.parseObject(hit.getSourceAsString(), FuseOriginal.class);
+            list.add(fuseOriginal);
+        }
+        try {
+            System.out.println("导出俯瞰融合原始数据");
+            response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+            response.setCharacterEncoding("utf-8");
+            String fileName = URLEncoder.encode("俯瞰融合原始数据", "UTF-8");
+            response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xlsx");
+            EasyExcel.write(response.getOutputStream(), FuseOriginal.class).sheet("俯瞰融合原始数据")
+                    .doWrite(list);
+        } catch (Exception e) {
+            // 重置response
+            System.out.println("导出俯瞰融合原始数据excel失败:{}" + e.getMessage() + e);
+        }
+    }
+
 
     /**
      * 按照List<Map<String,Object>>里面map的某个value重新封装成多个不同的list, 原始数据类型List<Map<String,Object>>, 转换后数据类型Map<String,List<Map<String,Object>>>

+ 3 - 3
fusion-analysis/src/main/resources/application.yml

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

+ 2 - 3
protobuf_hlx/src/main/java/cn/com/taiji/consumer/HlxAisConsumer.java

@@ -28,7 +28,7 @@ public class HlxAisConsumer {
     @Autowired
     HlxAisService hlxAisService;
 
-    @KafkaListener(topics = "hlx_ax_original_ais", groupId = "20230303yougi")
+    @KafkaListener(topics = "hlx_ax_original_ais", groupId = "original_${random.uuid}")
     public void aisConsumer(List<ConsumerRecord<byte[],byte[]>> records, Acknowledgment ack) {
         for (ConsumerRecord<byte[],byte[]> record : records) {
             Optional<byte[]> kafkaMessage = Optional.ofNullable(record.value());
@@ -59,9 +59,8 @@ public class HlxAisConsumer {
 //                    e.printStackTrace();
                 }
             });
-
+            ack.acknowledge();
         }
-        ack.acknowledge();
     }
 
 }

+ 2 - 3
protobuf_hlx/src/main/java/cn/com/taiji/consumer/HlxRadarConsumer.java

@@ -28,7 +28,7 @@ public class HlxRadarConsumer {
     @Autowired
     HlxRadarService hlxRadarService;
 
-    @KafkaListener(topics = "hlx_ax_original_radar", groupId = "20230303yougi")
+    @KafkaListener(topics = "hlx_ax_original_radar", groupId = "original_${random.uuid}")
     public void radarConsumer(List<ConsumerRecord<byte[],byte[]>> records, Acknowledgment ack) {
         for (ConsumerRecord<byte[],byte[]> record : records) {
             Optional<byte[]> kafkaMessage = Optional.ofNullable(record.value());
@@ -58,8 +58,7 @@ public class HlxRadarConsumer {
 //                    e.printStackTrace();
                 }
             });
-
+            ack.acknowledge();
         }
-        ack.acknowledge();
     }
 }

+ 2 - 0
protobuf_hlx/src/main/java/cn/com/taiji/service/impl/HlxAisServiceImpl.java

@@ -7,6 +7,7 @@ import cn.com.taiji.service.HlxAisService;
 import cn.com.taiji.utils.ByteArrayUtils;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 
 import java.util.*;
@@ -20,6 +21,7 @@ public class HlxAisServiceImpl extends ServiceImpl<HlxAisMapper, HlxAis> impleme
     private Vector<HlxAisPackage> targetAis = new Vector<>();
 
     @Override
+    @Scheduled(initialDelay = 5 * 1000, fixedRate = 30 * 1000)
     public void saveRadarList() {
         List<HlxAisPackage> result = new ArrayList<> (targetAis);
         List<HlxAis> saveList = new ArrayList<> ();