|
@@ -0,0 +1,82 @@
|
|
|
+package com.shanghaichengdi.downloadcenterserver.faced;
|
|
|
+
|
|
|
+import cn.hutool.http.HttpRequest;
|
|
|
+import cn.hutool.http.HttpUtil;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+public class AnalyseFaced {
|
|
|
+
|
|
|
+ private final static String SHIP_COVER = "http://172.16.58.199:5000/shipCover";
|
|
|
+ private final static String BOAT_FLAG = "http://172.16.58.199:3003/boat_flag";
|
|
|
+ private final static String DOWNLOAD_FILE_DIR = "/shipAnalysis/HDImages/";
|
|
|
+ private final static String SHIP_COVER_ANALYSE_DIR = "/disk/shipCover/";
|
|
|
+ private final static String BOAT_FLAG_ANALYSE_DIR = "/disk/shareFlag/";
|
|
|
+ private final static String GH_CLOUD_SERVER = "http://10.83.68.108:8090/ghjgBayonetDataShareApi/";
|
|
|
+
|
|
|
+
|
|
|
+ public static String shipCoverAnalyse(String id, String filePath) {
|
|
|
+ HttpRequest post = HttpUtil.createPost(SHIP_COVER);
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Content-Type", "application/json;charset=utf-8");
|
|
|
+ post.addHeaders(headers);
|
|
|
+ Map<String, String> param = new LinkedHashMap<>();
|
|
|
+ param.put("file", DOWNLOAD_FILE_DIR + filePath);
|
|
|
+ String responseBody = post.body(JSONObject.toJSONString(param))
|
|
|
+ .setReadTimeout(3600000)
|
|
|
+ .execute()
|
|
|
+ .body();
|
|
|
+ log.info("通用船舶货物识别完成,结果为:{}", responseBody);
|
|
|
+ return responseBody;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static String boatFlagAnalyse(String id, List<String> filePathList) {
|
|
|
+ String result = null;
|
|
|
+ for (String filePath : filePathList) {
|
|
|
+ HttpRequest post = HttpUtil.createPost(BOAT_FLAG);
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Content-Type", "application/json;charset=utf-8");
|
|
|
+ post.addHeaders(headers);
|
|
|
+ Map<String, String> param = new LinkedHashMap<>();
|
|
|
+ param.put("file", DOWNLOAD_FILE_DIR + filePath);
|
|
|
+ String responseBody = post.body(JSONObject.toJSONString(param))
|
|
|
+ .setReadTimeout(3600000)
|
|
|
+ .execute()
|
|
|
+ .body();
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(responseBody);
|
|
|
+ Boolean whetherHaveFlag = (Boolean) jsonObject.get("has_objects");
|
|
|
+ if (whetherHaveFlag) {
|
|
|
+// log.info("当前编号:{} 船舶有国旗, 返回结果为:{}", id, responseBody);
|
|
|
+ result = responseBody;
|
|
|
+ break;
|
|
|
+ } else {
|
|
|
+ // 没有国旗的只保留全景图的分析结果
|
|
|
+ String fullyImgResult = boatFlagAnalyse(id, filePathList.get(0));
|
|
|
+// log.warn("当前编号:{} 船舶没有国旗, 返回结果为:{}", id, responseBody);
|
|
|
+ result = fullyImgResult;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.info("国旗分析最终结果:{}", result);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static String boatFlagAnalyse(String id, String filePath) {
|
|
|
+ HttpRequest post = HttpUtil.createPost(BOAT_FLAG);
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Content-Type", "application/json;charset=utf-8");
|
|
|
+ post.addHeaders(headers);
|
|
|
+ Map<String, String> param = new LinkedHashMap<>();
|
|
|
+ param.put("file", DOWNLOAD_FILE_DIR + filePath);
|
|
|
+ return post.body(JSONObject.toJSONString(param))
|
|
|
+ .setReadTimeout(3600000)
|
|
|
+ .execute()
|
|
|
+ .body();
|
|
|
+ }
|
|
|
+}
|