Browse Source

[update]0.7版本

xiahailong 2 years ago
parent
commit
9f9891a1b2

+ 3 - 2
.idea/workspace.xml

@@ -6,7 +6,6 @@
   <component name="ChangeListManager">
     <list default="true" id="3bf79822-fe13-41ea-bc8f-858fbea129e7" name="Changes" comment="[update]0.3版本">
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/fusion-analysis/src/main/java/cn/com/taiji/constants/EsIndexConstants.java" beforeDir="false" afterPath="$PROJECT_DIR$/fusion-analysis/src/main/java/cn/com/taiji/constants/EsIndexConstants.java" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/fusion-analysis/src/main/java/cn/com/taiji/service/impl/FusionAnalysisServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/fusion-analysis/src/main/java/cn/com/taiji/service/impl/FusionAnalysisServiceImpl.java" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
@@ -24,7 +23,7 @@
   <component name="Git.Settings">
     <option name="RECENT_BRANCH_BY_REPOSITORY">
       <map>
-        <entry key="$PROJECT_DIR$" value="xiahailong" />
+        <entry key="$PROJECT_DIR$" value="master" />
       </map>
     </option>
     <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
@@ -183,6 +182,8 @@
       <workItem from="1675926884397" duration="1000" />
       <workItem from="1675926990034" duration="2575000" />
       <workItem from="1675989856413" duration="1423000" />
+      <workItem from="1676011584046" duration="4880000" />
+      <workItem from="1676252216821" duration="1298000" />
     </task>
     <task id="LOCAL-00001" summary="[insert]新增prod环境配置,完善es连接配置">
       <created>1675652041715</created>

+ 114 - 70
fusion-analysis/src/main/java/cn/com/taiji/service/impl/FusionAnalysisServiceImpl.java

@@ -46,6 +46,9 @@ import java.lang.reflect.Field;
 import java.net.URLEncoder;
 import java.text.ParseException;
 import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.CopyOnWriteArraySet;
 
 import static cn.com.taiji.constants.EsIndexConstants.*;
 
@@ -77,7 +80,7 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
 
     @Override
     public void fusionAnalysisExcelOne(FusionQuery query, HttpServletResponse response) throws IOException, ParseException {
-        List<FusionData> list = new ArrayList<>();
+        List<FusionData> 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_REALTIMETRAJECTORY+time);
@@ -108,10 +111,11 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
         SearchResponse search = client.search(request, COMMON_OPTIONS);
         SearchHits searchHits = search.getHits();
         SearchHit[] hits = searchHits.getHits();
-        List<Map<String, Object>> inList = new ArrayList<Map<String, Object>>();
-        List<Map<String, Object>> outList = new ArrayList<Map<String, Object>>();
+        List<Map<String, Object>> inList = new CopyOnWriteArrayList<Map<String, Object>>();
+        List<Map<String, Object>> outList = new CopyOnWriteArrayList<Map<String, Object>>();
         for (SearchHit hit : hits) {
-            Map<String, Object> map = hit.getSourceAsMap();
+            Map<String, Object> map = new ConcurrentHashMap();
+            map = hit.getSourceAsMap();
             inList.add(map);
         }
         outList = change(inList, "mergeTarget", outList);
@@ -139,7 +143,7 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
                         } catch (ParseException e) {
                             e.printStackTrace();
                         }
-                        Long interval = date2.getTime()-date.getTime();
+                        Long interval = dateUtils(date2.getTime(),date.getTime());
                         if (interval>6500L){
                             num++;
                         }
@@ -150,8 +154,21 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
                     JSONObject sourceItem2 = jsonArray.getJSONObject(jsonArray.size()-1);
                     data.setMergeTarget(sourceItem.getString("mergeTarget"));
                     data.setTrackCount((long) jsonArray.size());
-                    data.setStartTime(sourceItem.getString("mergeTime"));
-                    data.setEndTime(sourceItem2.getString("mergeTime"));
+                    Date date = null;
+                    Date date2 = null;
+                    try {
+                        date = DateUtils.parse(sourceItem.getString("mergeTime"),"yyyy-MM-dd HH:mm:ss.SSS");
+                        date2 = DateUtils.parse(sourceItem2.getString("mergeTime"),"yyyy-MM-dd HH:mm:ss.SSS");
+                    } catch (ParseException e) {
+                        e.printStackTrace();
+                    }
+                    if (date.getTime()>date2.getTime()){
+                        data.setStartTime(sourceItem2.getString("mergeTime"));
+                        data.setEndTime(sourceItem.getString("mergeTime"));
+                    }else {
+                        data.setStartTime(sourceItem.getString("mergeTime"));
+                        data.setEndTime(sourceItem2.getString("mergeTime"));
+                    }
                     data.setFluctuateNumber(num);
                     list.add(data);
                 }
@@ -190,6 +207,7 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
 //            }
 //        }
         try {
+            System.out.println("进入导出识别融合数据率波动问题");
             response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
             response.setCharacterEncoding("utf-8");
             String fileName = URLEncoder.encode("识别融合数据率波动问题", "UTF-8");
@@ -205,7 +223,7 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
     @Override
     public void fusionAnalysisExcelTwo(FusionQuery query, HttpServletResponse response) throws IOException, ParseException {
 
-        List<FusionData> list = new ArrayList<>();
+        List<FusionData> 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_REALTIMETRAJECTORY+time);
@@ -244,10 +262,11 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
         SearchResponse search = client.search(request, COMMON_OPTIONS);
         SearchHits searchHits = search.getHits();
         SearchHit[] hits = searchHits.getHits();
-        List<Map<String, Object>> inList = new ArrayList<Map<String, Object>>();
-        List<Map<String, Object>> outList = new ArrayList<Map<String, Object>>();
+        List<Map<String, Object>> inList = new CopyOnWriteArrayList<Map<String, Object>>();
+        List<Map<String, Object>> outList = new CopyOnWriteArrayList<Map<String, Object>>();
         for (SearchHit hit : hits) {
-            Map<String, Object> map = hit.getSourceAsMap();
+            Map<String, Object> map = new ConcurrentHashMap();
+            map = hit.getSourceAsMap();
             inList.add(map);
         }
         outList = change(inList, "mergeTarget", outList);
@@ -277,8 +296,23 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
                                     }
                                     data.setMergeTarget(maps.getString("text"));
                                     data.setTrackCount((long) jsonArray.size());
-                                    data.setStartTime(jsonArray.getJSONObject(0).getString("mergeTime"));
-                                    data.setEndTime(jsonArray.getJSONObject(jsonArray.size()-1).getString("mergeTime"));
+                                    String start=jsonArray.getJSONObject(0).getString("mergeTime");
+                                    String end=jsonArray.getJSONObject(jsonArray.size()-1).getString("mergeTime");
+                                    Date date = null;
+                                    Date date2 = null;
+                                    try {
+                                        date = DateUtils.parse(start,"yyyy-MM-dd HH:mm:ss.SSS");
+                                        date2 = DateUtils.parse(end,"yyyy-MM-dd HH:mm:ss.SSS");
+                                    } catch (ParseException e) {
+                                        e.printStackTrace();
+                                    }
+                                    if (date.getTime()>date2.getTime()){
+                                        data.setStartTime(end);
+                                        data.setEndTime(start);
+                                    }else {
+                                        data.setStartTime(start);
+                                        data.setEndTime(end);
+                                    }
                                     list.add(data);
                                     num =0;
                                 }
@@ -337,6 +371,7 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
 //            }
 //        }
         try {
+            System.out.println("进入导出虚假推送问题");
             response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
             response.setCharacterEncoding("utf-8");
             String fileName = URLEncoder.encode("虚假推送问题", "UTF-8");
@@ -351,8 +386,8 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
 
     @Override
     public void tianAoLeaveOutExcel(FusionQuery query, HttpServletResponse response) throws IOException, ParseException {
-        List<LeaveOutData> list = new ArrayList<>();
-        List<LeaceOutDto> dtos = new ArrayList<>();
+        List<LeaveOutData> list = new CopyOnWriteArrayList<>();
+        List<LeaceOutDto> dtos = 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_TRACK_RADAR+time);
@@ -376,10 +411,11 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
         SearchResponse search = client.search(request, COMMON_OPTIONS);
         SearchHits searchHits = search.getHits();
         SearchHit[] hits = searchHits.getHits();
-        List<Map<String, Object>> inList = new ArrayList<Map<String, Object>>();
-        List<Map<String, Object>> outList = new ArrayList<Map<String, Object>>();
+        List<Map<String, Object>> inList = new CopyOnWriteArrayList<Map<String, Object>>();
+        List<Map<String, Object>> outList = new CopyOnWriteArrayList<Map<String, Object>>();
         for (SearchHit hit : hits) {
-            Map<String, Object> map = hit.getSourceAsMap();
+            Map<String, Object> map = new ConcurrentHashMap();
+            map = hit.getSourceAsMap();
             inList.add(map);
         }
         outList = change(inList, "fusionBatchNum", outList);
@@ -434,26 +470,27 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
                         Map<String, Object> map = hits2[0].getSourceAsMap();
                         Map<String, Object> map2 = hits2[hits2.length-1].getSourceAsMap();
                         data.setMergeTarget(map.get("mergeTarget").toString());
-                        data.setStartTime(map.get("mergeTime").toString());
-                        data.setEndTime(map2.get("mergeTime").toString());
+                        Date date = DateUtils.parse(map.get("mergeTime").toString(),"yyyy-MM-dd HH:mm:ss.SSS");
+                        Date date2 = DateUtils.parse(map2.get("mergeTime").toString(),"yyyy-MM-dd HH:mm:ss.SSS");
+                        if (date.getTime()>date2.getTime()){
+                            data.setStartTime(map2.get("mergeTime").toString());
+                            data.setEndTime(map.get("mergeTime").toString());
+                        }else {
+                            data.setStartTime(map.get("mergeTime").toString());
+                            data.setEndTime(map2.get("mergeTime").toString());
+                        }
                         data.setBatchNumber(item.getBatchNumber());
                         data.setOriginalCount(item.getCount());
                         data.setTrackCount(totalHits);
                         list.add(data);
-                    }else {
-                        data.setMergeTarget("未查出匹配融合数据");
-                        data.setStartTime("未查出匹配融合数据");
-                        data.setEndTime("未查出匹配融合数据");
-                        data.setBatchNumber(item.getBatchNumber());
-                        data.setOriginalCount(item.getCount());
-                        data.setTrackCount(totalHits);
                     }
                 }
-            } catch (IOException e) {
+            } catch (IOException | ParseException e) {
                 e.printStackTrace();
             }
         });
         try {
+            System.out.println("进入导出天奥轨迹数据遗漏");
             response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
             response.setCharacterEncoding("utf-8");
             String fileName = URLEncoder.encode("天奥轨迹数据遗漏", "UTF-8");
@@ -468,8 +505,8 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
 
     @Override
     public void beiDouLeaveOutExcel(FusionQuery query, HttpServletResponse response) throws IOException, ParseException {
-        List<LeaveOutData> list = new ArrayList<>();
-        List<LeaceOutDto> dtos = new ArrayList<>();
+        List<LeaveOutData> list = new CopyOnWriteArrayList<>();
+        List<LeaceOutDto> dtos = 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_TRACK_BEIDOU+time);
@@ -493,10 +530,11 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
         SearchResponse search = client.search(request, COMMON_OPTIONS);
         SearchHits searchHits = search.getHits();
         SearchHit[] hits = searchHits.getHits();
-        List<Map<String, Object>> inList = new ArrayList<Map<String, Object>>();
-        List<Map<String, Object>> outList = new ArrayList<Map<String, Object>>();
+        List<Map<String, Object>> inList = new CopyOnWriteArrayList<Map<String, Object>>();
+        List<Map<String, Object>> outList = new CopyOnWriteArrayList<Map<String, Object>>();
         for (SearchHit hit : hits) {
-            Map<String, Object> map = hit.getSourceAsMap();
+            Map<String, Object> map = new ConcurrentHashMap();
+            map = hit.getSourceAsMap();
             inList.add(map);
         }
         outList = change(inList, "devideNo", outList);
@@ -551,26 +589,27 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
                         Map<String, Object> map = hits2[0].getSourceAsMap();
                         Map<String, Object> map2 = hits2[hits2.length-1].getSourceAsMap();
                         data.setMergeTarget(map.get("mergeTarget").toString());
-                        data.setStartTime(map.get("mergeTime").toString());
-                        data.setEndTime(map2.get("mergeTime").toString());
+                        Date date = DateUtils.parse(map.get("mergeTime").toString(),"yyyy-MM-dd HH:mm:ss.SSS");
+                        Date date2 = DateUtils.parse(map2.get("mergeTime").toString(),"yyyy-MM-dd HH:mm:ss.SSS");
+                        if (date.getTime()>date2.getTime()){
+                            data.setStartTime(map2.get("mergeTime").toString());
+                            data.setEndTime(map.get("mergeTime").toString());
+                        }else {
+                            data.setStartTime(map.get("mergeTime").toString());
+                            data.setEndTime(map2.get("mergeTime").toString());
+                        }
                         data.setBatchNumber(item.getBatchNumber());
                         data.setOriginalCount(item.getCount());
                         data.setTrackCount(totalHits);
                         list.add(data);
-                    }else {
-                        data.setMergeTarget("未查出匹配融合数据");
-                        data.setStartTime("未查出匹配融合数据");
-                        data.setEndTime("未查出匹配融合数据");
-                        data.setBatchNumber(item.getBatchNumber());
-                        data.setOriginalCount(item.getCount());
-                        data.setTrackCount(totalHits);
                     }
                 }
-            } catch (IOException e) {
+            } catch (IOException | ParseException e) {
                 e.printStackTrace();
             }
         });
         try {
+            System.out.println("进入导出北斗轨迹数据遗漏");
             response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
             response.setCharacterEncoding("utf-8");
             String fileName = URLEncoder.encode("北斗轨迹数据遗漏", "UTF-8");
@@ -585,8 +624,8 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
 
     @Override
     public void hlxyjrhLeaveOutExcel(FusionQuery query, HttpServletResponse response) throws IOException, ParseException {
-        List<LeaveOutData> list = new ArrayList<>();
-        List<LeaceOutDto> dtos = new ArrayList<>();
+        List<LeaveOutData> list = new CopyOnWriteArrayList<>();
+        List<LeaceOutDto> dtos = 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_HLX_FUSION_SHIP+time);
@@ -610,10 +649,11 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
         SearchResponse search = client.search(request, COMMON_OPTIONS);
         SearchHits searchHits = search.getHits();
         SearchHit[] hits = searchHits.getHits();
-        List<Map<String, Object>> inList = new ArrayList<Map<String, Object>>();
-        List<Map<String, Object>> outList = new ArrayList<Map<String, Object>>();
+        List<Map<String, Object>> inList = new CopyOnWriteArrayList<Map<String, Object>>();
+        List<Map<String, Object>> outList = new CopyOnWriteArrayList<Map<String, Object>>();
         for (SearchHit hit : hits) {
-            Map<String, Object> map = hit.getSourceAsMap();
+            Map<String, Object> map = new ConcurrentHashMap();
+            map = hit.getSourceAsMap();
             inList.add(map);
         }
         outList = change(inList, "targetID", outList);
@@ -668,26 +708,27 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
                         Map<String, Object> map = hits2[0].getSourceAsMap();
                         Map<String, Object> map2 = hits2[hits2.length-1].getSourceAsMap();
                         data.setMergeTarget(map.get("mergeTarget").toString());
-                        data.setStartTime(map.get("mergeTime").toString());
-                        data.setEndTime(map2.get("mergeTime").toString());
+                        Date date = DateUtils.parse(map.get("mergeTime").toString(),"yyyy-MM-dd HH:mm:ss.SSS");
+                        Date date2 = DateUtils.parse(map2.get("mergeTime").toString(),"yyyy-MM-dd HH:mm:ss.SSS");
+                        if (date.getTime()>date2.getTime()){
+                            data.setStartTime(map2.get("mergeTime").toString());
+                            data.setEndTime(map.get("mergeTime").toString());
+                        }else {
+                            data.setStartTime(map.get("mergeTime").toString());
+                            data.setEndTime(map2.get("mergeTime").toString());
+                        }
                         data.setBatchNumber(item.getBatchNumber());
                         data.setOriginalCount(item.getCount());
                         data.setTrackCount(totalHits);
                         list.add(data);
-                    }else {
-                        data.setMergeTarget("未查出匹配融合数据");
-                        data.setStartTime("未查出匹配融合数据");
-                        data.setEndTime("未查出匹配融合数据");
-                        data.setBatchNumber(item.getBatchNumber());
-                        data.setOriginalCount(item.getCount());
-                        data.setTrackCount(totalHits);
                     }
                 }
-            } catch (IOException e) {
+            } catch (IOException | ParseException e) {
                 e.printStackTrace();
             }
         });
         try {
+            System.out.println("进入导出海兰信1级融合轨迹数据遗漏");
             response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
             response.setCharacterEncoding("utf-8");
             String fileName = URLEncoder.encode("海兰信1级融合轨迹数据遗漏", "UTF-8");
@@ -702,8 +743,8 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
 
     @Override
     public void tianaoStaticOrDynamicLeaveOutExcel(FusionQuery query, HttpServletResponse response) throws IOException, ParseException {
-        List<StaticOrDynamicData> list = new ArrayList<>();
-        List<LeaceOutDto> dtos = new ArrayList<>();
+        List<StaticOrDynamicData> list = new CopyOnWriteArrayList<>();
+        List<LeaceOutDto> dtos = 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_TRACK_RADAR+time);
@@ -727,10 +768,11 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
         SearchResponse search = client.search(request, COMMON_OPTIONS);
         SearchHits searchHits = search.getHits();
         SearchHit[] hits = searchHits.getHits();
-        List<Map<String, Object>> inList = new ArrayList<Map<String, Object>>();
-        List<Map<String, Object>> outList = new ArrayList<Map<String, Object>>();
+        List<Map<String, Object>> inList = new CopyOnWriteArrayList<Map<String, Object>>();
+        List<Map<String, Object>> outList = new CopyOnWriteArrayList<Map<String, Object>>();
         for (SearchHit hit : hits) {
-            Map<String, Object> map = hit.getSourceAsMap();
+            Map<String, Object> map = new ConcurrentHashMap();
+            map = hit.getSourceAsMap();
             inList.add(map);
         }
         outList = change(inList, "fusionBatchNum", outList);
@@ -777,16 +819,18 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
                     data.setMergeTarget(sourceItem.getString("mergeTarget"));
                     data.setBatchNumber(item.getBatchNumber());
                     list.add(data);
-                }else {
-                    data.setMergeTarget("未查出匹配融合数据");
-                    data.setBatchNumber(item.getBatchNumber());
-                    list.add(data);
                 }
+//                else {
+//                    data.setMergeTarget("未查出匹配融合数据");
+//                    data.setBatchNumber(item.getBatchNumber());
+//                    list.add(data);
+//                }
             } catch (IOException e) {
                 e.printStackTrace();
             }
         });
         try {
+            System.out.println("进入导出天奥静态数据与动态轨迹融合");
             response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
             response.setCharacterEncoding("utf-8");
             String fileName = URLEncoder.encode("天奥静态数据与动态轨迹融合", "UTF-8");
@@ -809,7 +853,7 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
     private static List<Map<String, Object>> change(List<Map<String, Object>> inList, String oneMapKey,
                                                     List<Map<String, Object>> outList) {
         // 1.将某个key的值存在set中
-        Set<Object> setTmp = new HashSet<Object>();
+        Set<Object> setTmp = new CopyOnWriteArraySet<Object>();
         for (Map<String, Object> tmp : inList) {
             setTmp.add(tmp.get(oneMapKey));
         }
@@ -818,8 +862,8 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
         while (it.hasNext()) {
             String oneMapValueStr = "";
             String oneSetTmpStr = (String) it.next();
-            Map<String, Object> oneSetTmpMap = new HashMap<String, Object>();
-            List<Map<String, Object>> oneSetTmpList = new ArrayList<Map<String, Object>>();
+            Map<String, Object> oneSetTmpMap = new ConcurrentHashMap<String, Object>();
+            List<Map<String, Object>> oneSetTmpList = new CopyOnWriteArrayList<Map<String, Object>>();
 
             for (Map<String, Object> tmp : inList) {
                 oneMapValueStr = (String) tmp.get(oneMapKey);