459242451@qq.com há 3 anos atrás
pai
commit
ac453cb1de

+ 31 - 3
ruoyi-admin/src/main/java/com/ruoyi/web/controller/gas/GasCommonController.java

@@ -360,9 +360,37 @@ public class GasCommonController {
         if (cacheMapValue == null) {
             return AjaxResult.error("目前无法定位到该船舶位置!");
         }
-        cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(cacheMapValue);
-        Object result = jsonObject.getBigDecimal("lng") + "," + jsonObject.getBigDecimal("lat");
-        return AjaxResult.success(result);
+        Map<String, Object> equalsCondition = new HashMap<>();
+        equalsCondition.put("mmsi", mmsi);
+        List<String> orderBy = new ArrayList<>();
+        orderBy.add("-createTime");
+        Map<String, Object> stringObjectMap = client.searchDocument(equalsCondition,
+                null,
+                orderBy,
+                1,
+                1,
+                ElasticConstants.AIS_ILLEGAL_SHIP,
+                ElasticConstants.SO2_ALERT,
+                ElasticConstants.HEIYAN_SHIP_RECOGNITION);
+        List<IllegalInfo> pageList = Convert.toList(IllegalInfo.class, stringObjectMap.get("pageList"));
+        if (pageList != null && pageList.size() > 0) {
+            IllegalInfo illegalInfo = pageList.get(0);
+            cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(cacheMapValue);
+            illegalInfo.setLat(jsonObject.getBigDecimal("lat"));
+            illegalInfo.setLng(jsonObject.getBigDecimal("lng"));
+            if (StrUtil.isNotBlank(jsonObject.getStr("receive"))) {
+                try {
+                    illegalInfo.setReceive(DateUtil.parseDateTime(jsonObject.getStr("receive").replace("T", " ").substring(0, 19)));
+                } catch (Exception e) {
+                    log.error("error:value={}", jsonObject.getStr("receive"));
+                }
+            }
+            illegalInfo.setHead(jsonObject.getStr("head", "-"));
+            illegalInfo.setSpeed(jsonObject.getStr("speed", "-") + "节");
+            illegalInfo.setCourse(jsonObject.getStr("course", "-"));
+            return AjaxResult.success(illegalInfo);
+        }
+        return AjaxResult.error("目前无法查询到该船!");
     }
 
     @GetMapping("/queryShipMonitorInfo")