Browse Source

:sparkles: 覆盖物/国旗预警生成

lag 7 months ago
parent
commit
ae1e345d72

+ 1 - 1
download-center-server/src/main/java/com/shanghaichengdi/downloadcenterserver/controller/PicDownloadController.java

@@ -35,7 +35,7 @@ public class PicDownloadController {
     PicDownload picDownload = JSONObject.parseObject(data, PicDownload.class);
 //    log.info("接收到的数据为:{}",JSONObject.toJSON(picDownload));
     PicDownloadFaced faced =
-        new PicDownloadFaced(picDownload.getImageUrls(), picDownload.getPassTime(),picDownload.getId());
+        new PicDownloadFaced(picDownload.getImageUrls(), picDownload.getPassTime(),picDownload.getId(),picDownload.getBayonetId());
     try {
       faced.start();
     } catch (Exception e) {

+ 1 - 0
download-center-server/src/main/java/com/shanghaichengdi/downloadcenterserver/domain/PicDownload.java

@@ -15,4 +15,5 @@ public class PicDownload {
   private List<String> imageUrls;
   private String passTime;
   private String id;
+  private String bayonetId;
 }

+ 29 - 4
download-center-server/src/main/java/com/shanghaichengdi/downloadcenterserver/faced/AnalyseFaced.java

@@ -2,11 +2,13 @@ package com.shanghaichengdi.downloadcenterserver.faced;
 
 import cn.hutool.http.HttpRequest;
 import cn.hutool.http.HttpUtil;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import lombok.extern.slf4j.Slf4j;
 
 @Slf4j
@@ -20,7 +22,7 @@ public class AnalyseFaced {
   private final static String GH_CLOUD_SERVER = "http://10.83.68.108:8090/ghjgBayonetDataShareApi/analyse/receive";
 
 
-  public static String shipCoverAnalyse(String id, String filePath) {
+  public static String shipCoverAnalyse(String id, String filePath, String bayonetId) {
     HttpRequest post = HttpUtil.createPost(SHIP_COVER);
     Map<String, String> headers = new HashMap<>();
     headers.put("Content-Type", "application/json;charset=utf-8");
@@ -31,12 +33,26 @@ public class AnalyseFaced {
         .setReadTimeout(3600000)
         .execute()
         .body();
-    log.info("通用船舶货物识别完成,结果为:{}", responseBody);
+//    log.info("通用船舶货物识别完成,结果为:{}", responseBody);
+    // 调用云上覆盖物/国旗接收接口
+    JSONObject coverAnalyseResultData = JSONObject.parseObject(responseBody);
+    JSONArray resultArray = (JSONArray) coverAnalyseResultData.get("result");
+    JSONObject resultJsonObject = (JSONObject) resultArray.get(0);
+    if (!Objects.isNull(resultJsonObject.get("class"))) {
+      Map<String, Object> yunParam = new LinkedHashMap<>();
+      yunParam.put("type", "覆盖物");
+      yunParam.put("dir", SHIP_COVER_ANALYSE_DIR);
+      yunParam.put("id", id);
+      yunParam.put("data", responseBody);
+      yunParam.put("bayonetId", bayonetId);
+      String coverJsonString = JSONObject.toJSONString(yunParam);
+      log.info("覆盖物调用云上传参为:{}", coverJsonString);
+    }
     return responseBody;
   }
 
 
-  public static String boatFlagAnalyse(String id, List<String> filePathList) {
+  public static String boatFlagAnalyse(String id, List<String> filePathList, String bayonetId) {
     String result = null;
     for (String filePath : filePathList) {
       HttpRequest post = HttpUtil.createPost(BOAT_FLAG);
@@ -62,7 +78,16 @@ public class AnalyseFaced {
         result = fullyImgResult;
       }
     }
-    log.info("国旗分析最终结果:{}", result);
+//    log.info("国旗分析最终结果:{}", result);
+    // 调用云上覆盖物/国旗接收接口
+    Map<String, Object> yunParam = new LinkedHashMap<>();
+    yunParam.put("type", "国旗");
+    yunParam.put("dir", BOAT_FLAG_ANALYSE_DIR);
+    yunParam.put("id", id);
+    yunParam.put("data", result);
+    yunParam.put("bayonetId", bayonetId);
+    String coverJsonString = JSONObject.toJSONString(yunParam);
+    log.info("国旗调用云上传参为:{}", coverJsonString);
     return null;
   }
 

+ 5 - 3
download-center-server/src/main/java/com/shanghaichengdi/downloadcenterserver/faced/PicDownloadFaced.java

@@ -24,11 +24,13 @@ public class PicDownloadFaced extends Thread {
   private List<String> imageUrls;
   private String passTime;
   private String id;
+  private String bayonetId;
 
-  public PicDownloadFaced(List<String> imageUrls, String passTime, String id) {
+  public PicDownloadFaced(List<String> imageUrls, String passTime, String id, String bayonetId) {
     this.imageUrls = imageUrls;
     this.passTime = passTime;
     this.id = id;
+    this.bayonetId = bayonetId;
   }
 
   @Override
@@ -81,8 +83,8 @@ public class PicDownloadFaced extends Thread {
 //    log.warn("======>   取出并移除首位元素:{}", JSONObject.toJSONString(UrlData.URL_IMG_TO_SAVE.poll()));
     Map<String, List<String>> polled = UrlData.URL_IMG_TO_SAVE.poll();
     String id = new ArrayList<>(polled.keySet()).get(0);
-    AnalyseFaced.shipCoverAnalyse(id, polled.get(id).get(0));
-    AnalyseFaced.boatFlagAnalyse(id, polled.get(id));
+    AnalyseFaced.shipCoverAnalyse(id, polled.get(id).get(0),bayonetId);
+    AnalyseFaced.boatFlagAnalyse(id, polled.get(id),bayonetId);
   }
 
   private synchronized static void addQueue(String id, List<String> imgUrlToSave) {