459242451@qq.com 3 سال پیش
والد
کامیت
4e3cccd6cb

+ 57 - 22
ruoyi-admin/src/main/java/com/ruoyi/web/controller/gas/GasCommonController.java

@@ -8,6 +8,7 @@ import cn.hutool.core.util.NumberUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.http.HttpUtil;
 import cn.hutool.http.HttpUtil;
+import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
@@ -17,8 +18,8 @@ import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.utils.uuid.IdUtils;
 import com.ruoyi.common.utils.uuid.IdUtils;
 import com.ruoyi.framework.config.ElasticSearchClient;
 import com.ruoyi.framework.config.ElasticSearchClient;
-import com.ruoyi.system.domain.AisShip;
 import com.ruoyi.system.domain.DeviceBo;
 import com.ruoyi.system.domain.DeviceBo;
+import com.ruoyi.system.domain.HuiHAisInfo;
 import com.ruoyi.system.domain.IllegalInfo;
 import com.ruoyi.system.domain.IllegalInfo;
 import com.ruoyi.system.domain.IllegalShipData;
 import com.ruoyi.system.domain.IllegalShipData;
 import com.ruoyi.system.domain.MonitorInfo;
 import com.ruoyi.system.domain.MonitorInfo;
@@ -27,7 +28,6 @@ import com.ruoyi.system.domain.vo.AisShipInfo;
 import com.ruoyi.system.domain.vo.ShipEepReportRecInfo;
 import com.ruoyi.system.domain.vo.ShipEepReportRecInfo;
 import com.ruoyi.system.service.IAisDatabase;
 import com.ruoyi.system.service.IAisDatabase;
 import com.ruoyi.system.service.IAisInfoService;
 import com.ruoyi.system.service.IAisInfoService;
-import com.ruoyi.system.service.IAisShipService;
 import com.ruoyi.system.service.IHeiYanService;
 import com.ruoyi.system.service.IHeiYanService;
 import com.ruoyi.system.service.IIllegalShipDataService;
 import com.ruoyi.system.service.IIllegalShipDataService;
 import com.ruoyi.system.service.ISo2Service;
 import com.ruoyi.system.service.ISo2Service;
@@ -78,8 +78,6 @@ public class GasCommonController {
     private IAisDatabase aisDatabase;
     private IAisDatabase aisDatabase;
     @Autowired
     @Autowired
     private IHeiYanService heiYanService;
     private IHeiYanService heiYanService;
-    @Autowired
-    private IAisShipService aisShipService;
     @Value("${spring.profiles.active}")
     @Value("${spring.profiles.active}")
     private String env;
     private String env;
     @Autowired
     @Autowired
@@ -285,17 +283,19 @@ public class GasCommonController {
                 ElasticConstants.HEIYAN_SHIP_RECOGNITION);
                 ElasticConstants.HEIYAN_SHIP_RECOGNITION);
         List<IllegalInfo> pageList = Convert.toList(IllegalInfo.class, stringObjectMap.get("pageList"));
         List<IllegalInfo> pageList = Convert.toList(IllegalInfo.class, stringObjectMap.get("pageList"));
         // 查询船舶的实时经纬度
         // 查询船舶的实时经纬度
-        Map<String, AisShip> aisShipMap = aisShipService.queryDynamicShip(1);
         for (IllegalInfo illegalInfo : pageList) {
         for (IllegalInfo illegalInfo : pageList) {
             if (StrUtil.isNotBlank(illegalInfo.getMmsi())) {
             if (StrUtil.isNotBlank(illegalInfo.getMmsi())) {
-                AisShip aisShip = aisShipMap.get(illegalInfo.getMmsi());
-                if (aisShip != null) {
-                    illegalInfo.setLat(aisShip.getLat());
-                    illegalInfo.setLng(aisShip.getLng());
-                    illegalInfo.setReceive(aisShip.getReceive());
-                    illegalInfo.setHead(ObjectUtil.isEmpty(aisShip.getHead()) ? "-" : aisShip.getHead() + "");
-                    illegalInfo.setSpeed(ObjectUtil.isEmpty(aisShip.getSpeed()) ? "-" : aisShip.getSpeed() + "节");
-                    illegalInfo.setCourse(ObjectUtil.isEmpty(aisShip.getCourse()) ? "-" : aisShip.getCourse() + "");
+                String aisShip = redisCache.getCacheMapValue("ais:ship", illegalInfo.getMmsi());
+                if (StrUtil.isNotBlank(aisShip)) {
+                    cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(aisShip);
+                    illegalInfo.setLat(jsonObject.getBigDecimal("lat"));
+                    illegalInfo.setLng(jsonObject.getBigDecimal("lng"));
+                    if (StrUtil.isNotBlank(jsonObject.getStr("receive"))) {
+                        illegalInfo.setReceive(DateUtil.parseDateTime(jsonObject.getStr("receive").replace("T", " ").substring(0, jsonObject.getStr("receive").lastIndexOf("."))));
+                    }
+                    illegalInfo.setHead(jsonObject.getStr("head", "-"));
+                    illegalInfo.setSpeed(jsonObject.getStr("speed", "-") + "节");
+                    illegalInfo.setCourse(jsonObject.getStr("course", "-"));
                 }
                 }
             }
             }
         }
         }
@@ -305,6 +305,33 @@ public class GasCommonController {
         return AjaxResult.success(pageList);
         return AjaxResult.success(pageList);
     }
     }
 
 
+    @GetMapping("/queryRdsShipList")
+    @ApiOperation("获取redis中所有正常船舶数据-用于地图展示船舶")
+    public AjaxResult queryRedisShipList() {
+        Map<String, Object> cacheMap = redisCache.getCacheMap("ais:ship");
+
+        Map<String, Object> equalsCondition = new HashMap<>();
+        equalsCondition.put("mmsi", "!0");
+        Map<String, Object> rangeCondition = new HashMap<>();
+        String startTime = DateUtil.formatDateTime(DateUtil.offsetDay(new Date(), -1));
+        rangeCondition.put("createTime", StrUtil.concat(true, "[", startTime, ",", DateUtil.now(), "]"));
+        List<String> orderBy = new ArrayList<>();
+        orderBy.add("-createTime");
+        Map<String, Object> stringObjectMap = client.searchDocument(equalsCondition,
+                rangeCondition,
+                orderBy,
+                1,
+                10000,
+                ElasticConstants.AIS_ILLEGAL_SHIP,
+                ElasticConstants.SO2_ALERT,
+                ElasticConstants.HEIYAN_SHIP_RECOGNITION);
+        List<IllegalInfo> pageList = Convert.toList(IllegalInfo.class, stringObjectMap.get("pageList"));
+        for (IllegalInfo illegalInfo : pageList) {
+            cacheMap.remove(illegalInfo.getMmsi());
+        }
+        return AjaxResult.success(toMapList(cacheMap));
+    }
+
     @GetMapping("/queryShipMonitorInfo")
     @GetMapping("/queryShipMonitorInfo")
     @ApiOperation("获取船舶监测数据")
     @ApiOperation("获取船舶监测数据")
     public AjaxResult queryShipMonitorInfo(@RequestParam String mmsi) {
     public AjaxResult queryShipMonitorInfo(@RequestParam String mmsi) {
@@ -440,9 +467,9 @@ public class GasCommonController {
                 afterDataMap.put("uploadFlag", 0);
                 afterDataMap.put("uploadFlag", 0);
                 afterDataMap.put("illegalStatus", 1);
                 afterDataMap.put("illegalStatus", 1);
             }
             }
-            if (ObjectUtil.isNotEmpty(afterDataMap.get("mmsi"))) {
-                aisInfoService.getDynamicShipInfo(Convert.toStr(afterDataMap.get("mmsi")));
-            }
+//            if (ObjectUtil.isNotEmpty(afterDataMap.get("mmsi"))) {
+//                aisInfoService.getDynamicShipInfo(Convert.toStr(afterDataMap.get("mmsi")));
+//            }
             afterDataMap.put("illegalType", "xiutan");
             afterDataMap.put("illegalType", "xiutan");
             // 保存数据
             // 保存数据
             saveIllegalData(afterDataMap, ElasticConstants.AIS_ILLEGAL_SHIP);
             saveIllegalData(afterDataMap, ElasticConstants.AIS_ILLEGAL_SHIP);
@@ -483,9 +510,9 @@ public class GasCommonController {
                 afterDataMap.put("monitorPointName", data.get("name"));
                 afterDataMap.put("monitorPointName", data.get("name"));
                 afterDataMap.put("orgName", orgMap.get(data.get("name")));
                 afterDataMap.put("orgName", orgMap.get(data.get("name")));
             }
             }
-            if (ObjectUtil.isNotEmpty(afterDataMap.get("mmsi"))) {
-                aisInfoService.getDynamicShipInfo(Convert.toStr(afterDataMap.get("mmsi")));
-            }
+//            if (ObjectUtil.isNotEmpty(afterDataMap.get("mmsi"))) {
+//                aisInfoService.getDynamicShipInfo(Convert.toStr(afterDataMap.get("mmsi")));
+//            }
             afterDataMap.put("illegalType", "guangpu");
             afterDataMap.put("illegalType", "guangpu");
             // 保存数据
             // 保存数据
             saveIllegalData(afterDataMap, ElasticConstants.SO2_ALERT);
             saveIllegalData(afterDataMap, ElasticConstants.SO2_ALERT);
@@ -534,9 +561,9 @@ public class GasCommonController {
                 afterDataMap.put("uploadFlag", 0);
                 afterDataMap.put("uploadFlag", 0);
                 afterDataMap.put("illegalStatus", 1);
                 afterDataMap.put("illegalStatus", 1);
             }
             }
-            if (ObjectUtil.isNotEmpty(afterDataMap.get("mmsi")) && Convert.toStr(afterDataMap.get("mmsi")).length() == 9) {
-                aisInfoService.getDynamicShipInfo(Convert.toStr(afterDataMap.get("mmsi")));
-            }
+//            if (ObjectUtil.isNotEmpty(afterDataMap.get("mmsi")) && Convert.toStr(afterDataMap.get("mmsi")).length() == 9) {
+//                aisInfoService.getDynamicShipInfo(Convert.toStr(afterDataMap.get("mmsi")));
+//            }
             afterDataMap.put("illegalType", "heiyan");
             afterDataMap.put("illegalType", "heiyan");
             // 查询检测点和船舶信息
             // 查询检测点和船舶信息
             if (ObjectUtil.isNotEmpty(afterDataMap.get("mmsi")) && !"0".equals(Convert.toStr(afterDataMap.get("mmsi")))) {
             if (ObjectUtil.isNotEmpty(afterDataMap.get("mmsi")) && !"0".equals(Convert.toStr(afterDataMap.get("mmsi")))) {
@@ -576,4 +603,12 @@ public class GasCommonController {
         }
         }
     }
     }
 
 
+    private List<Object> toMapList(Map<String, Object> listMap) {
+        List<Object> resultList = new ArrayList<>();
+        for (Map.Entry<String, Object> entry : listMap.entrySet()) {
+            resultList.add(JSONUtil.toBean(entry.getValue().toString(), HuiHAisInfo.class));
+        }
+        return resultList;
+    }
+
 }
 }

+ 9 - 9
ruoyi-admin/src/main/java/com/ruoyi/web/job/CanalScheduling.java

@@ -251,9 +251,6 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                         afterDataMap.put("uploadFlag", 0);
                         afterDataMap.put("uploadFlag", 0);
                         afterDataMap.put("illegalStatus", 1);
                         afterDataMap.put("illegalStatus", 1);
                     }
                     }
-                    if (ObjectUtil.isNotEmpty(afterDataMap.get("mmsi")) && Convert.toStr(afterDataMap.get("mmsi")).length() == 9) {
-                        aisInfoService.getDynamicShipInfo(Convert.toStr(afterDataMap.get("mmsi")));
-                    }
 
 
                     // 查询检测点和船舶信息
                     // 查询检测点和船舶信息
                     AisShipInfo shipInfo = aisInfoService.getShipInfo("", Convert.toStr(afterDataMap.get("mmsi")), "", "");
                     AisShipInfo shipInfo = aisInfoService.getShipInfo("", Convert.toStr(afterDataMap.get("mmsi")), "", "");
@@ -276,6 +273,7 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                     client.createDocument(ElasticConstants.HEIYAN_SHIP_RECOGNITION, Convert.toStr(afterDataMap.get("id")), afterDataMap);
                     client.createDocument(ElasticConstants.HEIYAN_SHIP_RECOGNITION, Convert.toStr(afterDataMap.get("id")), afterDataMap);
                 } else if (StrUtil.equalsIgnoreCase(database, "smoke_api") && StrUtil.equalsIgnoreCase(table, "ship_snap_address")) {
                 } else if (StrUtil.equalsIgnoreCase(database, "smoke_api") && StrUtil.equalsIgnoreCase(table, "ship_snap_address")) {
                     // 删除设备和类型的统计缓存
                     // 删除设备和类型的统计缓存
+                    log.info("删除redis设备缓存");
                     redisCache.deleteObject(CollUtil.set(false,
                     redisCache.deleteObject(CollUtil.set(false,
                             CacheConstants.DEVICE_STATIC,
                             CacheConstants.DEVICE_STATIC,
                             CacheConstants.DEVICE_TYPE_STATIC,
                             CacheConstants.DEVICE_TYPE_STATIC,
@@ -286,6 +284,7 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                     redisCache.deleteObject(CacheConstants.DEVICE_STATIC);
                     redisCache.deleteObject(CacheConstants.DEVICE_STATIC);
                 } else if (StrUtil.equalsIgnoreCase(database, "ship") && StrUtil.equalsIgnoreCase(table, "device")) {
                 } else if (StrUtil.equalsIgnoreCase(database, "ship") && StrUtil.equalsIgnoreCase(table, "device")) {
                     // 设备信息
                     // 设备信息
+                    log.info("删除redis设备缓存");
                     redisCache.deleteObject(CollUtil.set(false,
                     redisCache.deleteObject(CollUtil.set(false,
                             CacheConstants.DEVICE_STATIC,
                             CacheConstants.DEVICE_STATIC,
                             CacheConstants.DEVICE_TYPE_STATIC,
                             CacheConstants.DEVICE_TYPE_STATIC,
@@ -323,9 +322,6 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                         afterDataMap.put("monitorPointName", data.get("name"));
                         afterDataMap.put("monitorPointName", data.get("name"));
                         afterDataMap.put("orgName", orgMap.get(data.get("name")));
                         afterDataMap.put("orgName", orgMap.get(data.get("name")));
                     }
                     }
-                    if (ObjectUtil.isNotEmpty(afterDataMap.get("mmsi")) && Convert.toStr(afterDataMap.get("mmsi")).length() == 9) {
-                        aisInfoService.getDynamicShipInfo(Convert.toStr(afterDataMap.get("mmsi")));
-                    }
                     afterDataMap.put("illegalType", "guangpu");
                     afterDataMap.put("illegalType", "guangpu");
                     // 保存数据
                     // 保存数据
                     saveIllegalData(afterDataMap, ElasticConstants.SO2_ALERT);
                     saveIllegalData(afterDataMap, ElasticConstants.SO2_ALERT);
@@ -333,6 +329,7 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                 } else if (StrUtil.equalsIgnoreCase(database, "ais_database") && (StrUtil.equalsIgnoreCase(table, "sem_instrument"))) {
                 } else if (StrUtil.equalsIgnoreCase(database, "ais_database") && (StrUtil.equalsIgnoreCase(table, "sem_instrument"))) {
                     // 嗅探系统-站点信息
                     // 嗅探系统-站点信息
                     client.createDocument(ElasticConstants.AIS_SEM_INSTRUMENT, Convert.toStr(afterDataMap.get("id")), afterDataMap);
                     client.createDocument(ElasticConstants.AIS_SEM_INSTRUMENT, Convert.toStr(afterDataMap.get("id")), afterDataMap);
+                    log.info("删除redis设备缓存");
                     redisCache.deleteObject(CollUtil.set(false,
                     redisCache.deleteObject(CollUtil.set(false,
                             CacheConstants.DEVICE_STATIC,
                             CacheConstants.DEVICE_STATIC,
                             CacheConstants.DEVICE_TYPE_STATIC,
                             CacheConstants.DEVICE_TYPE_STATIC,
@@ -376,9 +373,6 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                         afterDataMap.put("monitorPointName", data.get("category"));
                         afterDataMap.put("monitorPointName", data.get("category"));
                         afterDataMap.put("orgName", orgMap.get(data.get("category")));
                         afterDataMap.put("orgName", orgMap.get(data.get("category")));
                     }
                     }
-                    if (ObjectUtil.isNotEmpty(afterDataMap.get("mmsi")) && Convert.toStr(afterDataMap.get("mmsi")).length() == 9) {
-                        aisInfoService.getDynamicShipInfo(Convert.toStr(afterDataMap.get("mmsi")));
-                    }
                     afterDataMap.put("illegalType", "xiutan");
                     afterDataMap.put("illegalType", "xiutan");
                     // 保存数据
                     // 保存数据
                     saveIllegalData(afterDataMap, ElasticConstants.AIS_ILLEGAL_SHIP);
                     saveIllegalData(afterDataMap, ElasticConstants.AIS_ILLEGAL_SHIP);
@@ -387,6 +381,7 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                 break;
                 break;
             case UPDATE:
             case UPDATE:
                 if (StrUtil.equalsIgnoreCase(database, "smoke_api") && StrUtil.equalsIgnoreCase(table, "ship_snap_address")) {
                 if (StrUtil.equalsIgnoreCase(database, "smoke_api") && StrUtil.equalsIgnoreCase(table, "ship_snap_address")) {
+                    log.info("删除redis设备缓存");
                     redisCache.deleteObject(CollUtil.set(false,
                     redisCache.deleteObject(CollUtil.set(false,
                             CacheConstants.DEVICE_STATIC,
                             CacheConstants.DEVICE_STATIC,
                             CacheConstants.DEVICE_TYPE_STATIC,
                             CacheConstants.DEVICE_TYPE_STATIC,
@@ -400,6 +395,7 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                     // 如果状态和经纬度变更才去删除redis
                     // 如果状态和经纬度变更才去删除redis
                     if (ObjectUtil.notEqual(beforeDataMap.get("online_status"), afterDataMap.get("online_status")) || ObjectUtil.notEqual(beforeDataMap.get("longitude"), afterDataMap.get("longitude")) || ObjectUtil.notEqual(beforeDataMap.get(
                     if (ObjectUtil.notEqual(beforeDataMap.get("online_status"), afterDataMap.get("online_status")) || ObjectUtil.notEqual(beforeDataMap.get("longitude"), afterDataMap.get("longitude")) || ObjectUtil.notEqual(beforeDataMap.get(
                             "latitude"), afterDataMap.get("latitude"))) {
                             "latitude"), afterDataMap.get("latitude"))) {
+                        log.info("删除redis设备缓存");
                         redisCache.deleteObject(CollUtil.set(false,
                         redisCache.deleteObject(CollUtil.set(false,
                                 CacheConstants.DEVICE_STATIC,
                                 CacheConstants.DEVICE_STATIC,
                                 CacheConstants.DEVICE_TYPE_STATIC,
                                 CacheConstants.DEVICE_TYPE_STATIC,
@@ -408,6 +404,7 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                 } else if (StrUtil.equalsIgnoreCase(database, "ais_database") && (StrUtil.equalsIgnoreCase(table, "sem_instrument"))) {
                 } else if (StrUtil.equalsIgnoreCase(database, "ais_database") && (StrUtil.equalsIgnoreCase(table, "sem_instrument"))) {
                     // 嗅探系统-站点信息
                     // 嗅探系统-站点信息
                     client.updateDocument(ElasticConstants.AIS_SEM_INSTRUMENT, Convert.toStr(afterDataMap.get("id")), afterDataMap);
                     client.updateDocument(ElasticConstants.AIS_SEM_INSTRUMENT, Convert.toStr(afterDataMap.get("id")), afterDataMap);
+                    log.info("删除redis设备缓存");
                     redisCache.deleteObject(CollUtil.set(false,
                     redisCache.deleteObject(CollUtil.set(false,
                             CacheConstants.DEVICE_STATIC,
                             CacheConstants.DEVICE_STATIC,
                             CacheConstants.DEVICE_TYPE_STATIC,
                             CacheConstants.DEVICE_TYPE_STATIC,
@@ -416,6 +413,7 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                 break;
                 break;
             case DELETE:
             case DELETE:
                 if (StrUtil.equalsIgnoreCase(database, "smoke_api") && StrUtil.equalsIgnoreCase(table, "ship_snap_address")) {
                 if (StrUtil.equalsIgnoreCase(database, "smoke_api") && StrUtil.equalsIgnoreCase(table, "ship_snap_address")) {
+                    log.info("删除redis设备缓存");
                     redisCache.deleteObject(CollUtil.set(false,
                     redisCache.deleteObject(CollUtil.set(false,
                             CacheConstants.DEVICE_STATIC,
                             CacheConstants.DEVICE_STATIC,
                             CacheConstants.DEVICE_TYPE_STATIC,
                             CacheConstants.DEVICE_TYPE_STATIC,
@@ -426,6 +424,7 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                     redisCache.deleteObject(CacheConstants.DEVICE_STATIC);
                     redisCache.deleteObject(CacheConstants.DEVICE_STATIC);
                 } else if (StrUtil.equalsIgnoreCase(database, "ship") && StrUtil.equalsIgnoreCase(table, "device")) {
                 } else if (StrUtil.equalsIgnoreCase(database, "ship") && StrUtil.equalsIgnoreCase(table, "device")) {
                     // 设备信息
                     // 设备信息
+                    log.info("删除redis设备缓存");
                     redisCache.deleteObject(CollUtil.set(false,
                     redisCache.deleteObject(CollUtil.set(false,
                             CacheConstants.DEVICE_STATIC,
                             CacheConstants.DEVICE_STATIC,
                             CacheConstants.DEVICE_TYPE_STATIC,
                             CacheConstants.DEVICE_TYPE_STATIC,
@@ -433,6 +432,7 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                 } else if (StrUtil.equalsIgnoreCase(database, "ais_database") && (StrUtil.equalsIgnoreCase(table, "sem_instrument"))) {
                 } else if (StrUtil.equalsIgnoreCase(database, "ais_database") && (StrUtil.equalsIgnoreCase(table, "sem_instrument"))) {
                     // 嗅探系统-站点信息
                     // 嗅探系统-站点信息
                     client.deleteDocument(ElasticConstants.AIS_SEM_INSTRUMENT, Convert.toStr(afterDataMap.get("id")));
                     client.deleteDocument(ElasticConstants.AIS_SEM_INSTRUMENT, Convert.toStr(afterDataMap.get("id")));
+                    log.info("删除redis设备缓存");
                     redisCache.deleteObject(CollUtil.set(false,
                     redisCache.deleteObject(CollUtil.set(false,
                             CacheConstants.DEVICE_STATIC,
                             CacheConstants.DEVICE_STATIC,
                             CacheConstants.DEVICE_TYPE_STATIC,
                             CacheConstants.DEVICE_TYPE_STATIC,

+ 0 - 97
ruoyi-admin/src/main/java/com/ruoyi/web/job/GetDynamicShip.java

@@ -1,25 +1,19 @@
 package com.ruoyi.web.job;
 package com.ruoyi.web.job;
 
 
-import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.convert.Convert;
 import cn.hutool.core.convert.Convert;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.StrUtil;
 import com.ruoyi.common.constant.ElasticConstants;
 import com.ruoyi.common.constant.ElasticConstants;
 import com.ruoyi.framework.config.ElasticSearchClient;
 import com.ruoyi.framework.config.ElasticSearchClient;
 import com.ruoyi.system.domain.IllegalInfo;
 import com.ruoyi.system.domain.IllegalInfo;
-import com.ruoyi.system.service.IAisInfoService;
-import com.ruoyi.system.service.IAisShipService;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
 
 
-import java.util.ArrayList;
 import java.util.Date;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
-import java.util.Set;
 
 
 /**
 /**
  * @Description: TODO
  * @Description: TODO
@@ -32,98 +26,7 @@ import java.util.Set;
 public class GetDynamicShip {
 public class GetDynamicShip {
 
 
     @Autowired
     @Autowired
-    private IAisInfoService aisInfoService;
-    @Autowired
-    private IAisShipService aisShipService;
-    @Autowired
     private ElasticSearchClient client;
     private ElasticSearchClient client;
-    private static final int SIZE = 50;
-
-    public void get() {
-        log.info("获取船舶实时位置任务开始!");
-        // 拉取一天内需要获取经纬度的船舶
-        Set<String> shipMmsi = new HashSet<>();
-        Map<String, Object> equalsCondition = new HashMap<>();
-        equalsCondition.put("illegalStatus", 2);
-        List<String> orderBy = new ArrayList<>();
-        orderBy.add("-createTime");
-        Map<String, Object> rangeCondition = new HashMap<>();
-        String startTime = DateUtil.formatDateTime(DateUtil.offsetDay(new Date(), -1));
-        rangeCondition.put("createTime", StrUtil.concat(true, "[", startTime, ",", DateUtil.now(), "]"));
-        Map<String, Object> xianyiMap = client.searchDocument(equalsCondition,
-                rangeCondition,
-                orderBy,
-                1,
-                500,
-                ElasticConstants.AIS_ILLEGAL_SHIP,
-                ElasticConstants.SO2_ALERT,
-                ElasticConstants.HEIYAN_SHIP_RECOGNITION);
-        List<IllegalInfo> xianyiList = Convert.toList(IllegalInfo.class, xianyiMap.get("pageList"));
-        for (IllegalInfo illegalInfo : xianyiList) {
-            if (StrUtil.isNotBlank(illegalInfo.getMmsi()) && !"0".equals(illegalInfo.getMmsi())) {
-                shipMmsi.add(illegalInfo.getMmsi());
-            }
-        }
-        equalsCondition.put("illegalStatus", 3);
-        Map<String, Object> weiguiMap = client.searchDocument(equalsCondition,
-                rangeCondition,
-                orderBy,
-                1,
-                100,
-                ElasticConstants.AIS_ILLEGAL_SHIP,
-                ElasticConstants.SO2_ALERT,
-                ElasticConstants.HEIYAN_SHIP_RECOGNITION);
-        List<IllegalInfo> weiguiList = Convert.toList(IllegalInfo.class, weiguiMap.get("pageList"));
-        for (IllegalInfo illegalInfo : weiguiList) {
-            if (StrUtil.isNotBlank(illegalInfo.getMmsi()) && !"0".equals(illegalInfo.getMmsi())) {
-                shipMmsi.add(illegalInfo.getMmsi());
-            }
-        }
-        equalsCondition.put("illegalStatus", 1);
-        rangeCondition.put("createTime", StrUtil.concat(true, "[", DateUtil.formatDateTime(DateUtil.offsetHour(new Date(), -2)), ",", DateUtil.now(), "]"));
-        Map<String, Object> zhengchangMap = client.searchDocument(equalsCondition,
-                rangeCondition,
-                orderBy,
-                1,
-                50,
-                ElasticConstants.AIS_ILLEGAL_SHIP,
-                ElasticConstants.SO2_ALERT,
-                ElasticConstants.HEIYAN_SHIP_RECOGNITION);
-        List<IllegalInfo> zhengchangList = Convert.toList(IllegalInfo.class, zhengchangMap.get("pageList"));
-        for (IllegalInfo illegalInfo : zhengchangList) {
-            if (StrUtil.isNotBlank(illegalInfo.getMmsi()) && !"0".equals(illegalInfo.getMmsi())) {
-                shipMmsi.add(illegalInfo.getMmsi());
-            }
-        }
-        int startIndex = 0;
-        int endIndex;
-        int size = shipMmsi.size();
-        while (startIndex < size) {
-            //尾部的位置
-            endIndex = startIndex + SIZE;
-
-            //尾部位置不能超出范围,否则就取集合的长度
-            endIndex = Math.min(endIndex, size);
-
-            //截取
-            List<String> subList = CollUtil.sub(shipMmsi, startIndex, endIndex);
-            aisInfoService.getDynamicShipInfo(String.join(",", subList));
-            //计算下次截取的开始位置
-            startIndex = endIndex;
-        }
-        log.info("获取船舶实时位置任务结束!");
-    }
-
-    /**
-     * 删除历史某些数据
-     *
-     * @param day 删除多少天前的数据
-     */
-    public void delete(Integer day) {
-        log.info("删除实时经纬度数据任务开始!");
-        aisShipService.deleteByDay(day);
-        log.info("删除实时经纬度数据任务开始!");
-    }
 
 
     /**
     /**
      * 删除ES中存在的历史数据--正常监测数据
      * 删除ES中存在的历史数据--正常监测数据

+ 0 - 7
ruoyi-admin/src/main/java/com/ruoyi/web/service/Impl/GasCommonServiceImpl.java

@@ -1,7 +1,6 @@
 package com.ruoyi.web.service.Impl;
 package com.ruoyi.web.service.Impl;
 
 
 import cn.hutool.core.convert.Convert;
 import cn.hutool.core.convert.Convert;
-import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.NumberUtil;
 import cn.hutool.core.util.NumberUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.StrUtil;
@@ -11,7 +10,6 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.ruoyi.common.constant.ElasticConstants;
 import com.ruoyi.common.constant.ElasticConstants;
-import com.ruoyi.common.utils.uuid.IdUtils;
 import com.ruoyi.framework.config.ElasticSearchClient;
 import com.ruoyi.framework.config.ElasticSearchClient;
 import com.ruoyi.system.domain.HuiHAisInfo;
 import com.ruoyi.system.domain.HuiHAisInfo;
 import com.ruoyi.system.domain.SyncPost;
 import com.ruoyi.system.domain.SyncPost;
@@ -155,9 +153,6 @@ public class GasCommonServiceImpl implements IGasCommonService {
                         afterDataMap.put("sootImgUrl", StrUtil.isNotBlank(sootImgUrl) ? "http://" + sootImgUrl : "");
                         afterDataMap.put("sootImgUrl", StrUtil.isNotBlank(sootImgUrl) ? "http://" + sootImgUrl : "");
                         afterDataMap.put("allImgUrl", newImgList);
                         afterDataMap.put("allImgUrl", newImgList);
                     }
                     }
-                    if (ObjectUtil.isNotEmpty(afterDataMap.get("mmsi")) && Convert.toStr(afterDataMap.get("mmsi")).length() == 9) {
-                        aisInfoService.getDynamicShipInfo(Convert.toStr(afterDataMap.get("mmsi")));
-                    }
                 }
                 }
                 saveOrUpdate(ElasticConstants.HEIYAN_SHIP_RECOGNITION, Convert.toStr(afterDataMap.get("id")), afterDataMap);
                 saveOrUpdate(ElasticConstants.HEIYAN_SHIP_RECOGNITION, Convert.toStr(afterDataMap.get("id")), afterDataMap);
             }
             }
@@ -202,8 +197,6 @@ public class GasCommonServiceImpl implements IGasCommonService {
     @Async
     @Async
     public void dealAis(String message) {
     public void dealAis(String message) {
         HuiHAisInfo aisBaseInfo = JSONUtil.toBean(message, HuiHAisInfo.class);
         HuiHAisInfo aisBaseInfo = JSONUtil.toBean(message, HuiHAisInfo.class);
-        aisBaseInfo.setId(IdUtils.fastSimpleUUID());
-        aisBaseInfo.setCreateTime(DateUtil.date());
         gasCommonMapper.saveHuiHAisInfo(aisBaseInfo);
         gasCommonMapper.saveHuiHAisInfo(aisBaseInfo);
     }
     }
 }
 }

+ 0 - 37
ruoyi-system/src/main/java/com/ruoyi/system/domain/AisShip.java

@@ -1,37 +0,0 @@
-package com.ruoyi.system.domain;
-
-import com.fasterxml.jackson.annotation.JsonFormat;
-import lombok.Data;
-
-import java.math.BigDecimal;
-import java.util.Date;
-
-/**
- * 嫌疑船舶
- *
- * @author ruoyi
- * @date 2021-08-24
- */
-@Data
-public class AisShip {
-    private String uuid;
-    private String mmsi;
-
-    private BigDecimal lng;
-    private BigDecimal lat;
-    // 实际航向
-    private BigDecimal head;
-    // 地面航速
-    private BigDecimal speed;
-    // 地面航线
-    private BigDecimal course;
-
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    private Date receive;
-
-    // 
-    private String destination;
-
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    private Date insertTime;
-}

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/DeviceBo.java

@@ -42,4 +42,6 @@ public class DeviceBo {
     // 子系统来源
     // 子系统来源
     private String source;
     private String source;
 
 
+    private String liveStreamUrl;
+
 }
 }

+ 10 - 16
ruoyi-system/src/main/java/com/ruoyi/system/domain/HuiHAisInfo.java

@@ -1,10 +1,7 @@
 package com.ruoyi.system.domain;
 package com.ruoyi.system.domain;
 
 
-import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 import lombok.Data;
 
 
-import java.util.Date;
-
 /**
 /**
  * @Description: TODO
  * @Description: TODO
  * @Author: huangcheng
  * @Author: huangcheng
@@ -13,28 +10,25 @@ import java.util.Date;
  */
  */
 @Data
 @Data
 public class HuiHAisInfo {
 public class HuiHAisInfo {
-    private String id;
     private String ship_no;
     private String ship_no;
     private String mmsi;
     private String mmsi;
     private String speed;
     private String speed;
     private String head;
     private String head;
     private String rate;
     private String rate;
     private String course;
     private String course;
-    private String tel;
-    private String power;
+    //    private String tel;
+//    private String power;
     private String lat;
     private String lat;
     private String ship_id;
     private String ship_id;
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    private Date receive;
+    private String receive;
     private String lng;
     private String lng;
-    private String length;
+    //    private String length;
     private String shipname_cn;
     private String shipname_cn;
-    private String ship_type;
-    private String ship_reg_no;
-    private String depth;
-    private String draught;
-    private String width;
-    private String ship_type_code;
+    //    private String ship_type;
+//    private String ship_reg_no;
+//    private String depth;
+//    private String draught;
+//    private String width;
+//    private String ship_type_code;
     private String shipname;
     private String shipname;
-    private Date createTime;
 }
 }

+ 0 - 24
ruoyi-system/src/main/java/com/ruoyi/system/mapper/AisShipMapper.java

@@ -1,24 +0,0 @@
-package com.ruoyi.system.mapper;
-
-import com.ruoyi.system.domain.AisShip;
-import org.apache.ibatis.annotations.MapKey;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * @Description: TODO
- * @Author: huangcheng
- * @Date: 2021/11/1
- * @Version V1.0
- */
-public interface AisShipMapper {
-
-    @MapKey("mmsi")
-    Map<String, AisShip> queryDynamicShip(@Param("day") int i);
-
-    void deleteByDay(@Param("day") int day);
-
-    List<AisShip> queryShipAddressList(@Param("day") int i);
-}

+ 0 - 2
ruoyi-system/src/main/java/com/ruoyi/system/service/IAisInfoService.java

@@ -15,6 +15,4 @@ public interface IAisInfoService {
 
 
     AisShipInfo getShipInfo(String shipnameCn, String mmsi, String shipId, String shipNo);
     AisShipInfo getShipInfo(String shipnameCn, String mmsi, String shipId, String shipNo);
 
 
-    void getDynamicShipInfo(String mmsis);
-
 }
 }

+ 0 - 20
ruoyi-system/src/main/java/com/ruoyi/system/service/IAisShipService.java

@@ -1,20 +0,0 @@
-package com.ruoyi.system.service;
-
-import com.ruoyi.system.domain.AisShip;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * @Description: TODO
- * @Author: huangcheng
- * @Date: 2021/11/1
- * @Version V1.0
- */
-public interface IAisShipService {
-    Map<String, AisShip> queryDynamicShip(int i);
-
-    void deleteByDay(int day);
-
-    List<AisShip> queryShipAddressList(int i);
-}

+ 0 - 19
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/AisInfoServiceImpl.java

@@ -102,23 +102,4 @@ public class AisInfoServiceImpl implements IAisInfoService {
         return null;
         return null;
     }
     }
 
 
-    /**
-     * 推送需要获取的船舶实时数据
-     *
-     * @param mmsis
-     */
-    @Override
-    public void getDynamicShipInfo(String mmsis) {
-        if ("prod".equals(profile)) {
-            try {
-                if (StrUtil.isNotBlank(mmsis)) {
-                    String s = HttpUtil.get(shipDynamicInfo + mmsis);
-                    log.info("推送船舶动态信息,返回结果:{}", s);
-                }
-            } catch (Exception e) {
-                log.error("推送船舶动态信息异常");
-            }
-        }
-    }
-
 }
 }

+ 0 - 38
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/AisShipServiceImpl.java

@@ -1,38 +0,0 @@
-package com.ruoyi.system.service.impl;
-
-import com.ruoyi.system.domain.AisShip;
-import com.ruoyi.system.mapper.AisShipMapper;
-import com.ruoyi.system.service.IAisShipService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * @Description: TODO
- * @Author: huangcheng
- * @Date: 2021/11/1
- * @Version V1.0
- */
-@Service
-public class AisShipServiceImpl implements IAisShipService {
-
-    @Autowired
-    private AisShipMapper aisShipMapper;
-
-    @Override
-    public Map<String, AisShip> queryDynamicShip(int i) {
-        return aisShipMapper.queryDynamicShip(i);
-    }
-
-    @Override
-    public List<AisShip> queryShipAddressList(int i) {
-        return aisShipMapper.queryShipAddressList(i);
-    }
-
-    @Override
-    public void deleteByDay(int day) {
-        aisShipMapper.deleteByDay(day);
-    }
-}

+ 0 - 45
ruoyi-system/src/main/resources/mapper/system/AisShipMapper.xml

@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.ruoyi.system.mapper.AisShipMapper">
-
-    <delete id="deleteByDay">
-        delete
-        from ais_ship
-        where DATE_SUB(CURDATE(), INTERVAL #{day} DAY) > receive
-    </delete>
-
-    <select id="queryDynamicShip" resultType="com.ruoyi.system.domain.AisShip">
-        SELECT mmsi,
-               lng,
-               lat,
-               head,
-               speed,
-               course,
-               date_format(receive, '%Y-%m-%d %H:%i:%s') as receive
-        FROM (
-                 SELECT mmsi,
-                        lng,
-                        lat,
-                        head,
-                        speed,
-                        course,
-                        receive
-                 FROM ais_ship
-                 WHERE DATE_SUB(CURDATE(), INTERVAL #{day} DAY) &lt;= date (receive)
-        ORDER BY receive DESC ) t
-        GROUP BY t.mmsi
-    </select>
-
-    <select id="queryShipAddressList" resultType="com.ruoyi.system.domain.AisShip">
-        SELECT mmsi,
-               lng,
-               lat,
-               head
-        FROM ais_ship
-        WHERE DATE_SUB(CURDATE(), INTERVAL #{day} DAY) &lt;= date (receive)
-        order BY receive
-    </select>
-
-</mapper>

+ 1 - 0
ruoyi-system/src/main/resources/mapper/system/HeiYanMapper.xml

@@ -23,6 +23,7 @@
                type                             as                                deviceType,
                type                             as                                deviceType,
                case status when 'ENABLED' then '在线' when 'DISABLED' then '离线' end status,
                case status when 'ENABLED' then '在线' when 'DISABLED' then '离线' end status,
                orgName,
                orgName,
+               liveStreamUrl,
                'heiyan_ship_recognition'        as                                source
                'heiyan_ship_recognition'        as                                source
         from ship_snap_address
         from ship_snap_address
     </select>
     </select>

+ 16 - 16
ruoyi-ui/src/views/components/table/homeTable.vue

@@ -146,7 +146,7 @@ export default {
       beginTime: '',
       beginTime: '',
       so2TimeData: {},
       so2TimeData: {},
       endTime: '',
       endTime: '',
-      deviceList:[],
+      deviceList: [],
       deviceTotal: 0,
       deviceTotal: 0,
       queryParams: {
       queryParams: {
         pageNum: 1,
         pageNum: 1,
@@ -202,10 +202,10 @@ export default {
         {"name": "润扬大桥光谱2", "locations": [[119.369724, 32.204459]]},
         {"name": "润扬大桥光谱2", "locations": [[119.369724, 32.204459]]},
       ],
       ],
       ship: [
       ship: [
-        {"name": "一号船","mmsi":"s", "locations": [[118.639711, 31.98602]], 'type': 1,"head":0,"lnglats":[[118.649711, 31.98602],[118.639711, 31.98602],[118.629711, 31.98602],[118.619711, 31.98602]]},
+        {"name": "一号船", "mmsi": "s", "locations": [[118.639711, 31.98602]], 'type': 1, "head": 0, "lnglats": [[118.649711, 31.98602], [118.639711, 31.98602], [118.629711, 31.98602], [118.619711, 31.98602]]},
         // {"name": "二号船", "locations": [[118.639711, 31.96602]], 'type': 2,"head":60},
         // {"name": "二号船", "locations": [[118.639711, 31.96602]], 'type': 2,"head":60},
-        {"name": "三号船","mmsi":"s1", "locations": [[118.639711, 31.96622]], 'type': 1,"head":90},
-        {"name": "三号船","mmsi":"s2", "locations": [[118.639711, 31.93662]], 'type': 1,"head":180},
+        {"name": "三号船", "mmsi": "s1", "locations": [[118.639711, 31.96622]], 'type': 1, "head": 90},
+        {"name": "三号船", "mmsi": "s2", "locations": [[118.639711, 31.93662]], 'type': 1, "head": 180},
         // {"name": "四号船", "locations": [[118.639711, 31.96602]], 'type': 3,"head":180},
         // {"name": "四号船", "locations": [[118.639711, 31.96602]], 'type': 3,"head":180},
         // {"name": "五号船", "locations": [[118.639711, 31.96602]], 'type': 2,"head":270},
         // {"name": "五号船", "locations": [[118.639711, 31.96602]], 'type': 2,"head":270},
         // {"name": "五号船", "locations": [[118.639711, 31.96602]], 'type': 2,"head":360},
         // {"name": "五号船", "locations": [[118.639711, 31.96602]], 'type': 2,"head":360},
@@ -216,10 +216,11 @@ export default {
     this.getdeviceList();
     this.getdeviceList();
     this.getStaticDevice();
     this.getStaticDevice();
     this.getIllegalShipStatic();
     this.getIllegalShipStatic();
+    this.getshipData();
     var that = this;
     var that = this;
     setInterval(() => {
     setInterval(() => {
       that.getshipData();
       that.getshipData();
-    }, 1000);
+    }, 120000);
 
 
     this.getThresholdList();
     this.getThresholdList();
     // this.addDevicePoint();
     // this.addDevicePoint();
@@ -230,15 +231,15 @@ export default {
     //  this.getChart();
     //  this.getChart();
   },
   },
   methods: {
   methods: {
-    getThresholdList(){
-           getThresholdList({type: 'bridge'}).then(response => {
-           console.log(response);
-           for(var index in response.rows){
-                var obj = response.rows[index];
-                var points ='['+obj.configValue+']';
-                console.log(JSON.parse(points));
-                this.$refs.mapv.addline(JSON.parse(points));
-           }
+    getThresholdList() {
+      getThresholdList({type: 'bridge'}).then(response => {
+        console.log(response);
+        for (var index in response.rows) {
+          var obj = response.rows[index];
+          var points = '[' + obj.configValue + ']';
+          console.log(JSON.parse(points));
+          this.$refs.mapv.addline(JSON.parse(points));
+        }
       });
       });
     },
     },
     getdeviceList() {
     getdeviceList() {
@@ -277,7 +278,6 @@ export default {
     getshipData() {
     getshipData() {
 
 
 
 
-
       queryShipData().then(data => {
       queryShipData().then(data => {
         var shipdatalist = [];
         var shipdatalist = [];
         for (var key in data.data) {
         for (var key in data.data) {
@@ -321,7 +321,7 @@ export default {
         } else if (obj.type == 3) {
         } else if (obj.type == 3) {
           img = 'wg.png'
           img = 'wg.png'
         }
         }
-        this.$refs.mapv.addpoint(obj.locations, obj, img, 'ship', ((obj.head==null?0:parseFloat(obj.head))-90)*Math.PI/180);
+        this.$refs.mapv.addpoint(obj.locations, obj, img, 'ship', ((obj.head == null ? 0 : parseFloat(obj.head)) - 90) * Math.PI / 180);
       }
       }
     },
     },
     getSo2Time() {
     getSo2Time() {