瀏覽代碼

增加新的接口

459242451@qq.com 3 年之前
父節點
當前提交
f74b15e17e

+ 14 - 3
README.md

@@ -73,10 +73,21 @@ Column
 ```
 1.黑烟数据库:
 198.17.23.20:3306/smoke_api   root_shipface   @P5zQQMbax8xx
-设备页面:http://198.17.188.6:8091/              http://119.45.121.229:8090/?opt=1
+设备页面:http://198.17.188.6:8091/(正式)              http://119.45.121.229:8090/?opt=1(测试)
 2.嗅探数据库
 198.17.23.18:3306/ais_database  js_test     Js@123456
-设备页面:http://198.17.188.2:81/index.html?opt=1    http://47.92.161.189:81/index.html?opt=1
+设备页面:http://198.17.188.2:81/index.html?opt=1(生产)    http://47.92.161.189:81/index.html?opt=1(测试)    http://198.17.25.32:9011/index.html?opt=1(前置机)
 3.光谱数据库
+设备页面:http://198.17.25.32:9001/device.html?opt=1(前置机)
+```
+
+> 注意:数据库需设置
+
+```
+#配置不包含ONLY_FULL_GROUP_BY
+sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
+```
+
+> 记录
 
-```
+- 共同的字段:mmsi、shipName

+ 91 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/gas/GasCommonController.java

@@ -1,13 +1,19 @@
 package com.ruoyi.web.controller.gas;
 
 import cn.hutool.core.convert.Convert;
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
 import com.ruoyi.common.constant.ElasticConstants;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.framework.config.ElasticSearchClient;
+import com.ruoyi.system.domain.AisShip;
 import com.ruoyi.system.domain.DeviceBo;
 import com.ruoyi.system.domain.IllegalInfo;
+import com.ruoyi.system.domain.MonitorInfo;
 import com.ruoyi.system.domain.SyncPost;
 import com.ruoyi.system.service.IAisDatabase;
+import com.ruoyi.system.service.IAisShipService;
 import com.ruoyi.system.service.IHeiYanService;
 import com.ruoyi.system.service.ISo2Service;
 import com.ruoyi.web.service.IGasCommonService;
@@ -23,9 +29,13 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.TreeSet;
+import java.util.stream.Collectors;
 
 /**
  * @Description: 公共提出接口
@@ -48,6 +58,8 @@ public class GasCommonController {
     private IAisDatabase aisDatabase;
     @Autowired
     private IHeiYanService heiYanService;
+    @Autowired
+    private IAisShipService aisShipService;
 
     @PreAuthorize("@ss.hasPermi('system:gas:sync')")
     @PostMapping("/sync")
@@ -170,6 +182,85 @@ public class GasCommonController {
         return AjaxResult.success(data);
     }
 
+    @GetMapping("/queryShipList")
+    @ApiOperation("获取所有船舶数据-用于地图展示船舶")
+    public AjaxResult queryShipList(@RequestParam(required = false) String monitor, @RequestParam(required = false) String startTime) {
+        Map<String, Object> equalsCondition = new HashMap<>();
+        if (StrUtil.isNotBlank(monitor)) {
+            equalsCondition.put("monitorPointName", monitor);
+            equalsCondition.put("snapPos", monitor);
+        }
+        Map<String, Object> rangeCondition = new HashMap<>();
+        if (StrUtil.isBlank(startTime)) {
+            startTime = DateUtil.formatDateTime(DateUtil.offsetDay(new Date(), -3));
+        }
+        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"));
+        // 查询船舶的实时经纬度
+        Map<String, AisShip> aisShipMap = aisShipService.queryDynamicShip(3);
+        for (IllegalInfo illegalInfo : pageList) {
+            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(aisShip.getHead());
+                    illegalInfo.setSpeed(aisShip.getSpeed());
+                    illegalInfo.setCourse(aisShip.getCourse());
+                }
+            }
+        }
+        pageList =
+                pageList.stream().filter(ship -> ObjectUtil.isNotEmpty(ship.getLat())).collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getMmsi() + ";" + o.getIllegalType()))),
+                        ArrayList::new));
+        return AjaxResult.success(pageList);
+    }
+
+    @GetMapping("/queryShipMonitorInfo")
+    @ApiOperation("获取船舶监测数据")
+    public AjaxResult queryShipMonitorInfo(@RequestParam String mmsi) {
+        Map<String, Object> map = new HashMap<>(4);
+        List<MonitorInfo> minor = new ArrayList<>();
+        // 硫的监测数据(监测点、硫含量、监测时间、so2浓度、no2浓度、co2浓度、硫碳比)
+        // 查询so2系统
+        Map<String, Object> equalsCondition = new HashMap<>();
+        equalsCondition.put("mmsi", mmsi);
+        List<String> orderBy = new ArrayList<>();
+        orderBy.add("-createTime");
+        Map<String, Object> monitorMap = client.searchDocument(equalsCondition,
+                null,
+                orderBy,
+                1,
+                100,
+                ElasticConstants.AIS_ILLEGAL_SHIP,
+                ElasticConstants.SO2_ALERT,
+                ElasticConstants.HEIYAN_SHIP_RECOGNITION);
+        List<MonitorInfo> pageList = Convert.toList(MonitorInfo.class, monitorMap.get("pageList"));
+        // 处理数据
+        for (MonitorInfo monitorInfo : pageList) {
+            if (StrUtil.isBlank(monitorInfo.getMonitorPointName()) && StrUtil.isNotBlank(monitorInfo.getSnapPos())) {
+                monitorInfo.setMonitorPointName(monitorInfo.getSnapPos());
+            }
+            if (ObjectUtil.isNotEmpty(monitorInfo.getCo2Concentration())) {
+                minor.add(monitorInfo);
+            }
+        }
+        map.put("main", pageList);
+        map.put("minor", minor);
+        return AjaxResult.success(map);
+    }
+
     public final static Map<String, String> orgMap = new HashMap<String, String>() {{
         put("南京三桥", "南京海事局");
         put("南京四桥", "南京海事局");

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

@@ -6,6 +6,10 @@ import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.NumberUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
+import cn.hutool.http.HttpUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.alibaba.otter.canal.client.CanalConnector;
 import com.alibaba.otter.canal.client.CanalConnectors;
 import com.alibaba.otter.canal.protocol.CanalEntry;
@@ -33,6 +37,7 @@ import org.springframework.stereotype.Component;
 import org.springframework.util.LinkedCaseInsensitiveMap;
 
 import java.net.InetSocketAddress;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -64,6 +69,9 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
     @Autowired
     private CanalConfig canalConfig;
 
+    @Value("${spring.profiles.active}")
+    private String env;
+
     public final static Map<String, String> orgMap = new HashMap<String, String>() {{
         put("南京三桥", "南京海事局");
         put("南京四桥", "南京海事局");
@@ -161,7 +169,7 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
     @SneakyThrows
     private void indexES(Map<String, Object> beforeDataMap, Map<String, Object> afterDataMap, CanalEntry.EventType eventType, String database, String table) {
         log.info("eventType:{},database:{},table:{}\nbeforeMap:{},\n afterMap:{}", eventType, database, table, beforeDataMap, afterDataMap);
-        if (!StrUtil.equalsAnyIgnoreCase(database, "heiyan", "so2", "ais_database")) {
+        if (!StrUtil.equalsAnyIgnoreCase(database, "smoke_api", "ship", "ais_database")) {
             return;
         }
 
@@ -184,35 +192,27 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
         switch (eventType) {
             case INSERT:
                 // 黑烟船舶数据入库
-                if (StrUtil.equalsIgnoreCase(database, "heiyan") && StrUtil.equalsIgnoreCase(table, "ship_recognition")) {
+                if (StrUtil.equalsIgnoreCase(database, "smoke_api") && StrUtil.equalsIgnoreCase(table, "ship_recognition")) {
                     // 判断数据状态
                     if (ObjectUtil.isNotEmpty(afterDataMap.get("rcgSoot")) && NumberUtil.isGreaterOrEqual(Convert.toBigDecimal(afterDataMap.get("rcgSoot")), Convert.toBigDecimal(blackThresholdVal))) {
-
                         // 查询黑烟图片
-                        /*String imgUrl = HttpUtil.get(blackImgUrl + Convert.toStr(afterDataMap.get("id")));
-                        JSONObject response = JSON.parseObject(imgUrl);
-                        if (200 == response.getInteger("code")) {
-                            List<String> newImgList = new ArrayList<>();
-                            JSONArray imgUrlList = response.getJSONObject("data").getJSONArray("imgUrlList");
-                            for (Object o : imgUrlList) {
-                                // 只保存细节、全貌开头的图片
-                                String s = Convert.toStr(o);
-                                if (StrUtil.containsAny(s, "全貌", "细节")) {
-                                    newImgList.add(s);
+                        if ("prod".equals(env)) {
+                            String imgUrl = HttpUtil.get(blackImgUrl + Convert.toStr(afterDataMap.get("id")));
+                            JSONObject response = JSON.parseObject(imgUrl);
+                            if (200 == response.getInteger("code")) {
+                                List<String> newImgList = new ArrayList<>();
+                                JSONArray imgUrlList = response.getJSONObject("data").getJSONArray("imgUrlList");
+                                String sootImgUrl = response.getJSONObject("data").getString("sootImgUrl");
+                                for (Object o : imgUrlList) {
+                                    // 只保存细节、全貌开头的图片
+                                    String s = Convert.toStr(o);
+                                    if (StrUtil.containsAny(s, "全貌", "细节")) {
+                                        newImgList.add("http://" + s);
+                                    }
                                 }
+                                afterDataMap.put("sootImgUrl", StrUtil.isNotBlank(sootImgUrl) ? "http://" + sootImgUrl : "");
+                                afterDataMap.put("allImgUrl", newImgList);
                             }
-                            afterDataMap.put("allImgUrl", newImgList);
-                        }*/
-                        // 查询检测点和船舶信息、船舶进出港记录
-                        if (ObjectUtil.isNotEmpty(afterDataMap.get("aisMmsi"))) {
-                            AisShipInfo shipInfo = aisInfoService.getShipInfo("", Convert.toStr(afterDataMap.get("aisMmsi")), "", "");
-                            if (shipInfo != null) {
-                                afterDataMap.put("aisShipName", shipInfo.getShipName());
-                                afterDataMap.put("shipRegionType", shipInfo.getShipRegionType());
-                            }
-                        }
-                        if (ObjectUtil.isNotEmpty(afterDataMap.get("snapPos"))) {
-                            afterDataMap.put("orgName", orgMap.get(Convert.toStr(afterDataMap.get("snapPos"))));
                         }
                         // 超过阈值后直接判定为违规船舶
                         afterDataMap.put("illegalStatus", 3);
@@ -223,32 +223,55 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                         afterDataMap.put("uploadFlag", 0);
                         afterDataMap.put("illegalStatus", 1);
                     }
+                    if (ObjectUtil.isNotEmpty(afterDataMap.get("aisMmsi"))) {
+                        aisInfoService.getDynamicShipInfo(Convert.toStr(afterDataMap.get("aisMmsi")));
+                    }
+                    afterDataMap.put("mmsi", afterDataMap.get("aisMmsi"));
+                    afterDataMap.put("illegalType", "heiyan");
+                    // 查询检测点和船舶信息
+                    if ("prod".equals(env)) {
+                        if (ObjectUtil.isNotEmpty(afterDataMap.get("aisMmsi")) && !"0".equals(Convert.toStr(afterDataMap.get("aisMmsi")))) {
+                            AisShipInfo shipInfo = aisInfoService.getShipInfo("", Convert.toStr(afterDataMap.get("aisMmsi")), "", "");
+                            if (shipInfo != null) {
+                                afterDataMap.put("aisShipName", shipInfo.getShipName());
+                                afterDataMap.put("shipRegionType", shipInfo.getShipRegionType());
+                            }
+                        }
+                    }
+                    if (ObjectUtil.isNotEmpty(afterDataMap.get("snapPos"))) {
+                        afterDataMap.put("orgName", orgMap.get(Convert.toStr(afterDataMap.get("snapPos"))));
+                    }
+                    afterDataMap.put("createTime", afterDataMap.get("snapTimeFmt"));
                     client.createDocument(ElasticConstants.HEIYAN_SHIP_RECOGNITION, Convert.toStr(afterDataMap.get("id")), afterDataMap);
-                } else if (StrUtil.equalsIgnoreCase(database, "heiyan") && StrUtil.equalsIgnoreCase(table, "ship_snap_address")) {
+                } else if (StrUtil.equalsIgnoreCase(database, "smoke_api") && StrUtil.equalsIgnoreCase(table, "ship_snap_address")) {
                     // 删除设备和类型的统计缓存
                     redisCache.deleteObject(CollUtil.set(false,
                             CacheConstants.DEVICE_STATIC,
                             CacheConstants.DEVICE_TYPE_STATIC));
-                } else if (StrUtil.equalsIgnoreCase(database, "so2") && StrUtil.equalsIgnoreCase(table, "monitor_point")) {
+                } else if (StrUtil.equalsIgnoreCase(database, "ship") && StrUtil.equalsIgnoreCase(table, "monitor_point")) {
                     // 检测点信息
                     client.createDocument(ElasticConstants.SO2_MONITOR_POINT, Convert.toStr(afterDataMap.get("id")), afterDataMap);
                     redisCache.deleteObject(CacheConstants.DEVICE_STATIC);
-                } else if (StrUtil.equalsIgnoreCase(database, "so2") && StrUtil.equalsIgnoreCase(table, "device")) {
+                } else if (StrUtil.equalsIgnoreCase(database, "ship") && StrUtil.equalsIgnoreCase(table, "device")) {
                     // 设备信息
                     redisCache.deleteObject(CollUtil.set(false,
                             CacheConstants.DEVICE_STATIC,
                             CacheConstants.DEVICE_TYPE_STATIC));
-                } else if (StrUtil.equalsIgnoreCase(database, "so2") && StrUtil.equalsIgnoreCase(table, "alert")) {
+                } else if (StrUtil.equalsIgnoreCase(database, "ship") && StrUtil.equalsIgnoreCase(table, "alert")) {
                     // 船舶记录
-                    // 判断是否大于阈值
-                    if (ObjectUtil.isNotEmpty(afterDataMap.get("so2Percent")) && NumberUtil.isGreaterOrEqual(Convert.toBigDecimal(afterDataMap.get("so2Percent")), Convert.toBigDecimal(so2ThresholdVal))) {
-                        // 查询检测点和船舶信息、船舶进出港记录
+                    if ("prod".equals(env)) {
                         if (ObjectUtil.isNotEmpty(afterDataMap.get("mmsi"))) {
                             AisShipInfo shipInfo = aisInfoService.getShipInfo("", Convert.toStr(afterDataMap.get("mmsi")), "", "");
                             if (shipInfo != null) {
                                 afterDataMap.put("shipName", shipInfo.getShipName());
                                 afterDataMap.put("shipRegionType", shipInfo.getShipRegionType());
                             }
+                        }
+                    }
+                    // 判断是否大于阈值
+                    if (ObjectUtil.isNotEmpty(afterDataMap.get("so2Percent")) && NumberUtil.isGreaterOrEqual(Convert.toBigDecimal(afterDataMap.get("so2Percent")), Convert.toBigDecimal(so2ThresholdVal))) {
+                        // 查询检测点和船舶信息、船舶进出港记录
+                        if (ObjectUtil.isNotEmpty(afterDataMap.get("mmsi"))) {
                             ShipEepReportRecInfo eepReportRecInfo = aisInfoService.getShipEepReportRecInfo(DateUtil.formatDate(DateUtil.lastWeek()), DateUtil.formatDate(DateUtil.tomorrow()), Convert.toStr(afterDataMap.get("mmsi")), "", "");
                             if (eepReportRecInfo != null) {
                                 afterDataMap.put("destination", eepReportRecInfo.getNextPortName());
@@ -271,6 +294,9 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                         afterDataMap.put("uploadFlag", 0);
                         afterDataMap.put("illegalStatus", 1);
                     }
+                    if (ObjectUtil.isNotEmpty(afterDataMap.get("mmsi"))) {
+                        aisInfoService.getDynamicShipInfo(Convert.toStr(afterDataMap.get("mmsi")));
+                    }
                     afterDataMap.put("illegalType", "guangpu");
                     client.createDocument(ElasticConstants.SO2_ALERT, Convert.toStr(afterDataMap.get("id")), afterDataMap);
                 } else if (StrUtil.equalsIgnoreCase(database, "ais_database") && (StrUtil.equalsIgnoreCase(table, "sem_instrument"))) {
@@ -281,10 +307,7 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                             CacheConstants.DEVICE_TYPE_STATIC));
                 } else if (StrUtil.equalsIgnoreCase(database, "ais_database") && StrUtil.equalsIgnoreCase(table, "illegal_ship")) {
                     // 嗅探系统-违规船舶
-                    afterDataMap.put("mmsi", afterDataMap.get("shipMmsi"));
-                    afterDataMap.put("createTime", afterDataMap.get("peakTime"));
-                    afterDataMap.put("so2Percent", afterDataMap.get("sPercent"));
-                    if (ObjectUtil.isNotEmpty(afterDataMap.get("sPercent")) && NumberUtil.isGreaterOrEqual(Convert.toBigDecimal(afterDataMap.get("sPercent")), Convert.toBigDecimal(so2ThresholdVal))) {
+                    if ("prod".equals(env)) {
                         // 查询检测点和船舶信息、船舶进出港记录
                         if (ObjectUtil.isNotEmpty(afterDataMap.get("mmsi"))) {
                             AisShipInfo shipInfo = aisInfoService.getShipInfo("", Convert.toStr(afterDataMap.get("mmsi")), "", "");
@@ -292,6 +315,14 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                                 afterDataMap.put("shipName", shipInfo.getShipName());
                                 afterDataMap.put("shipRegionType", shipInfo.getShipRegionType());
                             }
+                        }
+                    }
+                    afterDataMap.put("mmsi", afterDataMap.get("shipMmsi"));
+                    afterDataMap.put("createTime", afterDataMap.get("peakTime"));
+                    afterDataMap.put("so2Percent", afterDataMap.get("sPercent"));
+                    if (ObjectUtil.isNotEmpty(afterDataMap.get("sPercent")) && NumberUtil.isGreaterOrEqual(Convert.toBigDecimal(afterDataMap.get("sPercent")), Convert.toBigDecimal(so2ThresholdVal))) {
+                        // 查询检测点和船舶信息、船舶进出港记录
+                        if (ObjectUtil.isNotEmpty(afterDataMap.get("mmsi"))) {
                             ShipEepReportRecInfo eepReportRecInfo = aisInfoService.getShipEepReportRecInfo(DateUtil.formatDate(DateUtil.lastWeek()), DateUtil.formatDate(DateUtil.tomorrow()), Convert.toStr(afterDataMap.get("mmsi")), "", "");
                             if (eepReportRecInfo != null) {
                                 afterDataMap.put("destination", eepReportRecInfo.getNextPortName());
@@ -316,20 +347,23 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                         afterDataMap.put("uploadFlag", 0);
                         afterDataMap.put("illegalStatus", 1);
                     }
+                    if (ObjectUtil.isNotEmpty(afterDataMap.get("mmsi"))) {
+                        aisInfoService.getDynamicShipInfo(Convert.toStr(afterDataMap.get("mmsi")));
+                    }
                     afterDataMap.put("illegalType", "xiutan");
                     client.createDocument(ElasticConstants.AIS_ILLEGAL_SHIP, Convert.toStr(afterDataMap.get("id")), afterDataMap);
                 }
                 break;
             case UPDATE:
-                if (StrUtil.equalsIgnoreCase(database, "heiyan") && StrUtil.equalsIgnoreCase(table, "ship_snap_address")) {
+                if (StrUtil.equalsIgnoreCase(database, "smoke_api") && StrUtil.equalsIgnoreCase(table, "ship_snap_address")) {
                     redisCache.deleteObject(CollUtil.set(false,
                             CacheConstants.DEVICE_STATIC,
                             CacheConstants.DEVICE_TYPE_STATIC));
-                } else if (StrUtil.equalsIgnoreCase(database, "so2") && StrUtil.equalsIgnoreCase(table, "monitor_point")) {
+                } else if (StrUtil.equalsIgnoreCase(database, "ship") && StrUtil.equalsIgnoreCase(table, "monitor_point")) {
                     // 检测点信息
                     client.updateDocument(ElasticConstants.SO2_MONITOR_POINT, Convert.toStr(afterDataMap.get("id")), afterDataMap);
                     redisCache.deleteObject(CacheConstants.DEVICE_STATIC);
-                } else if (StrUtil.equalsIgnoreCase(database, "so2") && StrUtil.equalsIgnoreCase(table, "device")) {
+                } else if (StrUtil.equalsIgnoreCase(database, "ship") && StrUtil.equalsIgnoreCase(table, "device")) {
                     // 设备信息
                     redisCache.deleteObject(CollUtil.set(false,
                             CacheConstants.DEVICE_STATIC,
@@ -343,15 +377,15 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                 }
                 break;
             case DELETE:
-                if (StrUtil.equalsIgnoreCase(database, "heiyan") && StrUtil.equalsIgnoreCase(table, "ship_snap_address")) {
+                if (StrUtil.equalsIgnoreCase(database, "smoke_api") && StrUtil.equalsIgnoreCase(table, "ship_snap_address")) {
                     redisCache.deleteObject(CollUtil.set(false,
                             CacheConstants.DEVICE_STATIC,
                             CacheConstants.DEVICE_TYPE_STATIC));
-                } else if (StrUtil.equalsIgnoreCase(database, "so2") && StrUtil.equalsIgnoreCase(table, "monitor_point")) {
+                } else if (StrUtil.equalsIgnoreCase(database, "ship") && StrUtil.equalsIgnoreCase(table, "monitor_point")) {
                     // 检测点信息
                     client.deleteDocument(ElasticConstants.SO2_MONITOR_POINT, Convert.toStr(afterDataMap.get("id")));
                     redisCache.deleteObject(CacheConstants.DEVICE_STATIC);
-                } else if (StrUtil.equalsIgnoreCase(database, "so2") && StrUtil.equalsIgnoreCase(table, "device")) {
+                } else if (StrUtil.equalsIgnoreCase(database, "ship") && StrUtil.equalsIgnoreCase(table, "device")) {
                     // 设备信息
                     redisCache.deleteObject(CollUtil.set(false,
                             CacheConstants.DEVICE_STATIC,

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

@@ -0,0 +1,108 @@
+package com.ruoyi.web.job;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.convert.Convert;
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.StrUtil;
+import com.ruoyi.common.constant.ElasticConstants;
+import com.ruoyi.framework.config.ElasticSearchClient;
+import com.ruoyi.system.domain.IllegalInfo;
+import com.ruoyi.system.service.IAisInfoService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @Description: TODO
+ * @Author: huangcheng
+ * @Date: 2021/11/1
+ * @Version V1.0
+ */
+@Component("getDynamicShip")
+@Slf4j
+public class GetDynamicShip {
+
+    @Autowired
+    private IAisInfoService aisInfoService;
+    @Autowired
+    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) {
+            shipMmsi.add(StrUtil.isBlank(illegalInfo.getMmsi()) ? illegalInfo.getAisMmsi() : 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, xianyiMap.get("pageList"));
+        for (IllegalInfo illegalInfo : weiguiList) {
+            shipMmsi.add(StrUtil.isBlank(illegalInfo.getMmsi()) ? illegalInfo.getAisMmsi() : 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, xianyiMap.get("pageList"));
+        for (IllegalInfo illegalInfo : zhengchangList) {
+            shipMmsi.add(StrUtil.isBlank(illegalInfo.getMmsi()) ? illegalInfo.getAisMmsi() : 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("获取船舶实时位置任务结束!");
+    }
+
+}

+ 33 - 13
ruoyi-admin/src/main/java/com/ruoyi/web/service/Impl/GasCommonServiceImpl.java

@@ -1,6 +1,8 @@
 package com.ruoyi.web.service.Impl;
 
 import cn.hutool.core.convert.Convert;
+import cn.hutool.core.util.NumberUtil;
+import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import com.ruoyi.common.constant.ElasticConstants;
 import com.ruoyi.framework.config.ElasticSearchClient;
@@ -65,45 +67,63 @@ public class GasCommonServiceImpl implements IGasCommonService {
             for (Map<String, Object> stringObjectMap : map) {
                 stringObjectMap.put("mmsi", stringObjectMap.get("shipMmsi"));
                 stringObjectMap.put("createTime", stringObjectMap.get("peakTime"));
-                stringObjectMap.put("illegalStatus", 1);
+                if (NumberUtil.isGreaterOrEqual(Convert.toBigDecimal(stringObjectMap.get("sPercent")), Convert.toBigDecimal("0.1"))) {
+                    stringObjectMap.put("illegalStatus", 2);
+                } else {
+                    stringObjectMap.put("illegalStatus", 1);
+                }
+                stringObjectMap.put("shipRegionType", 0);
                 stringObjectMap.put("illegalType", "xiutan");
                 stringObjectMap.put("uploadFlag", 0);
+                Map<String, Object> sem = client.getDocById(ElasticConstants.AIS_SEM_INSTRUMENT, Convert.toStr(stringObjectMap.get("semId")), "name,category");
+                if (sem != null && ObjectUtil.equal(sem.get("code"), 200)) {
+                    Map<String, String> data = Convert.toMap(String.class, String.class, sem.get("data"));
+                    stringObjectMap.put("semName", data.get("name"));
+                    stringObjectMap.put("monitorPointName", data.get("category"));
+                }
                 stringObjectMap.put("orgName", orgMap.get(Convert.toStr(stringObjectMap.get("monitorPointName"))));
                 stringObjectMap.put("so2Percent", stringObjectMap.get("sPercent"));
                 saveOrUpdate(ElasticConstants.AIS_ILLEGAL_SHIP, Convert.toStr(stringObjectMap.get("id")), stringObjectMap);
             }
-        } else if (StrUtil.equalsIgnoreCase(schema, "heiyan") && StrUtil.equalsIgnoreCase(table, "ship_recognition")) {
+        } else if (StrUtil.equalsIgnoreCase(schema, "smoke_api") && StrUtil.equalsIgnoreCase(table, "ship_recognition")) {
             // 黑烟嫌疑船舶
             List<Map<String, Object>> map = gasCommonMapper.queryShipRecognition(syncPost);
             for (Map<String, Object> stringObjectMap : map) {
-                stringObjectMap.put("illegalStatus", 1);
+                if (NumberUtil.isGreaterOrEqual(Convert.toBigDecimal(stringObjectMap.get("rcgSoot")), Convert.toBigDecimal("1"))) {
+                    stringObjectMap.put("illegalStatus", 3);
+                } else {
+                    stringObjectMap.put("illegalStatus", 1);
+                }
                 stringObjectMap.put("uploadFlag", 0);
+                stringObjectMap.put("illegalType", "heiyan");
+                stringObjectMap.put("shipRegionType", 0);
+                stringObjectMap.put("createTime", stringObjectMap.get("snapTimeFmt"));
+                stringObjectMap.put("mmsi", stringObjectMap.get("aisMmsi"));
                 stringObjectMap.put("orgName", orgMap.get(Convert.toStr(stringObjectMap.get("snapPos"))));
                 saveOrUpdate(ElasticConstants.HEIYAN_SHIP_RECOGNITION, Convert.toStr(stringObjectMap.get("id")), stringObjectMap);
             }
-        } else if (StrUtil.equalsIgnoreCase(schema, "so2") && StrUtil.equalsIgnoreCase(table, "alert")) {
+        } else if (StrUtil.equalsIgnoreCase(schema, "ship") && StrUtil.equalsIgnoreCase(table, "alert")) {
             // 光谱嫌疑船舶
             List<Map<String, Object>> map = gasCommonMapper.queryAlert(syncPost);
             for (Map<String, Object> stringObjectMap : map) {
-                stringObjectMap.put("illegalStatus", 1);
+                if (NumberUtil.isGreaterOrEqual(Convert.toBigDecimal(stringObjectMap.get("so2Percent")), Convert.toBigDecimal("0.1"))) {
+                    stringObjectMap.put("illegalStatus", 2);
+                } else {
+                    stringObjectMap.put("illegalStatus", 1);
+                }
                 stringObjectMap.put("illegalType", "guangpu");
+                stringObjectMap.put("shipRegionType", 0);
                 stringObjectMap.put("uploadFlag", 0);
                 stringObjectMap.put("orgName", orgMap.get(Convert.toStr(stringObjectMap.get("monitorPointName"))));
                 saveOrUpdate(ElasticConstants.SO2_ALERT, Convert.toStr(stringObjectMap.get("id")), stringObjectMap);
             }
-        } else if (StrUtil.equalsIgnoreCase(schema, "so2") && StrUtil.equalsIgnoreCase(table, "monitor_point")) {
+        } else if (StrUtil.equalsIgnoreCase(schema, "ship") && StrUtil.equalsIgnoreCase(table, "monitor_point")) {
             // 光谱监测点
             List<Map<String, Object>> map = gasCommonMapper.queryMonitorPoint(syncPost);
             for (Map<String, Object> stringObjectMap : map) {
                 saveOrUpdate(ElasticConstants.SO2_MONITOR_POINT, Convert.toStr(stringObjectMap.get("id")), stringObjectMap);
             }
-        }/* else if (StrUtil.equalsIgnoreCase(schema, "so2") && StrUtil.equalsIgnoreCase(table, "ship_static_info")) {
-            // 光谱船舶信息
-            List<Map<String, Object>> map = gasCommonMapper.queryShipStaticInfo(syncPost);
-            for (Map<String, Object> stringObjectMap : map) {
-                saveOrUpdate(ElasticConstants.SO2_SHIP_STATIC_INFO, Convert.toStr(stringObjectMap.get("id")), stringObjectMap);
-            }
-        }*/
+        }
     }
 
     @SneakyThrows

+ 11 - 7
ruoyi-admin/src/main/resources/application-prod.yml

@@ -13,16 +13,19 @@ spring:
       slaveais:
         # 从数据源开关/默认关闭
         enabled: true
-        url: jdbc:mysql://198.17.23.18:3306/ais_database?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
-        username: js_test
-        password: Js@123456
+        #        url: jdbc:mysql://198.17.23.18:3306/ais_database?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+        #        username: js_test
+        #        password: Js@123456
+        url: jdbc:mysql://198.17.25.31:3306/ais_database?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+        username: root
+        password: 1qaz!QAZ
       # 从库数据源(光谱)
       slaveso2:
         # 从数据源开关/默认关闭
         enabled: true
-        url: jdbc:mysql://198.17.188.51:3306/so2?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+        url: jdbc:mysql://198.17.25.31:3306/ship?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
         username: root
-        password: cbwq!xintong
+        password: 1qaz!QAZ
       # 从库数据源(黑烟)
       slaveblack:
         # 从数据源开关/默认关闭
@@ -124,9 +127,10 @@ swagger:
 
 # 子平台
 black:
-  snapImgUrl: http://127.0.0.1:8090/api/shipface/snap/imgUrl?id=
+  snapImgUrl: http://198.17.188.6:8091/api/shipface/snap/imgurl?id=
 
 # 第三方接口
 third:
   shipEepReportRecInfo: http://198.17.188.111:6201/huiyan/getShipEepReportRec # 船舶进出港记录
-  shipBaseInfo: http://198.17.239.239:7999/getInfosByCondition # 船舶基本信息
+  shipBaseInfo: http://198.17.239.239:7001/getInfosByCondition # 船舶基本信息
+  shipDynamicInfo: http://198.17.239.239:9004/getInfosByMmsi?mmsi #船舶动态数据信息

+ 4 - 3
ruoyi-admin/src/main/resources/application-test.yml

@@ -20,14 +20,14 @@ spring:
       slaveso2:
         # 从数据源开关/默认关闭
         enabled: true
-        url: jdbc:mysql://212.129.138.23:3306/so2?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+        url: jdbc:mysql://212.129.138.23:3306/ship?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
         username: root
         password: YbNL5_h]6a4kk
       # 从库数据源(黑烟)
       slaveblack:
         # 从数据源开关/默认关闭
         enabled: true
-        url: jdbc:mysql://212.129.138.23:3306/heiyan?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+        url: jdbc:mysql://212.129.138.23:3306/smoke_api?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
         username: root
         password: YbNL5_h]6a4kk
       # 初始连接数
@@ -128,4 +128,5 @@ black:
 # 第三方接口
 third:
   shipEepReportRecInfo: http://198.17.188.111:6201/huiyan/getShipEepReportRec # 船舶进出港记录
-  shipBaseInfo: http://198.17.239.239:7999/getInfosByCondition # 船舶基本信息
+  shipBaseInfo: http://198.17.239.239:7001/getInfosByCondition # 船舶基本信息
+  shipDynamicInfo: http://198.17.239.239:9004/getInfosByMmsi?mmsi #船舶动态数据信息

+ 1 - 1
ruoyi-admin/src/main/resources/application.yml

@@ -21,7 +21,7 @@ server:
   port: 8080
   servlet:
     # 应用的访问路径
-    context-path: /
+    context-path: /api
   tomcat:
     # tomcat的URI编码
     uri-encoding: UTF-8

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

@@ -0,0 +1,37 @@
+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;
+}

+ 20 - 1
ruoyi-system/src/main/java/com/ruoyi/system/domain/IllegalInfo.java

@@ -25,7 +25,7 @@ public class IllegalInfo {
 
     private String shipName;
 
-    private BigDecimal sPercent;
+    private BigDecimal so2Percent;
 
     private String snapTimeFmt;
 
@@ -36,4 +36,23 @@ public class IllegalInfo {
     private String aisShipName;
 
     private Integer rcgSoot;
+
+    // 船舶实时经纬度
+    private BigDecimal lng;
+
+    // 船舶实时经纬度
+    private BigDecimal lat;
+
+    // 船舶实时经纬度上传时间
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date receive;
+
+    // 实际航向
+    private BigDecimal head;
+    // 地面航速
+    private BigDecimal speed;
+    // 地面航线
+    private BigDecimal course;
+
+    private Integer illegalStatus;
 }

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

@@ -0,0 +1,37 @@
+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 MonitorInfo {
+    private String monitorPointName;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+
+    private String illegalType;
+
+    private String mmsi;
+
+    private BigDecimal so2Percent;
+
+    private BigDecimal no2Concentration;
+    private BigDecimal so2Concentration;
+    private BigDecimal co2Concentration;
+
+    private String snapPos;
+
+    private Integer rcgSoot;
+
+    private Integer illegalStatus;
+}

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

@@ -0,0 +1,19 @@
+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.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);
+}

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

@@ -14,4 +14,6 @@ public interface IAisInfoService {
     ShipEepReportRecInfo getShipEepReportRecInfo(String startTime, String endTime, String mmsi, String shipId, String shipNameCn);
 
     AisShipInfo getShipInfo(String shipnameCn, String mmsi, String shipId, String shipNo);
+
+    void getDynamicShipInfo(String mmsis);
 }

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

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

+ 42 - 14
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/AisInfoServiceImpl.java

@@ -8,6 +8,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.ruoyi.system.domain.vo.AisShipInfo;
 import com.ruoyi.system.domain.vo.ShipEepReportRecInfo;
 import com.ruoyi.system.service.IAisInfoService;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
@@ -21,6 +22,7 @@ import java.util.Map;
  * @Version V1.0
  */
 @Service
+@Slf4j
 public class AisInfoServiceImpl implements IAisInfoService {
 
     @Value("${spring.profiles.active}")
@@ -29,6 +31,8 @@ public class AisInfoServiceImpl implements IAisInfoService {
     private String shipEepReportRecInfoUrl;
     @Value("${third.shipBaseInfo}")
     private String shipBaseInfo;
+    @Value("${third.shipDynamicInfo}")
+    private String shipDynamicInfo;
 
     /**
      * 获取船舶进出港记录
@@ -49,15 +53,20 @@ public class AisInfoServiceImpl implements IAisInfoService {
             params.put("mmsi", mmsi);
             params.put("shipId", shipId);
             params.put("shipNameCn", shipNameCn);
-            String getResult = HttpUtil.get(shipEepReportRecInfoUrl, params);
-            JSONObject jsonObject = JSON.parseObject(getResult);
-            if (jsonObject != null && 200 == jsonObject.getInteger("code")) {
-                JSONArray result = jsonObject.getJSONArray("result");
-                if (result != null && !result.isEmpty()) {
-                    Map<String, String> stringStringMap = Convert.toMap(String.class, String.class, result.get(0));
-                    return ShipEepReportRecInfo.builder().berthName(stringStringMap.get("BERTH_NAME")).nextPortName(stringStringMap.get("NEXT_PORT_NAME")).build();
+            try {
+                String getResult = HttpUtil.get(shipEepReportRecInfoUrl, params);
+                JSONObject jsonObject = JSON.parseObject(getResult);
+                if (jsonObject != null && 200 == jsonObject.getInteger("code")) {
+                    JSONArray result = jsonObject.getJSONArray("result");
+                    if (result != null && !result.isEmpty()) {
+                        Map<String, String> stringStringMap = Convert.toMap(String.class, String.class, result.get(0));
+                        return ShipEepReportRecInfo.builder().berthName(stringStringMap.get("BERTH_NAME")).nextPortName(stringStringMap.get("NEXT_PORT_NAME")).build();
+                    }
                 }
+            } catch (Exception e) {
+                log.error("获取船舶停靠信息异常");
             }
+
         }
         return null;
     }
@@ -70,16 +79,35 @@ public class AisInfoServiceImpl implements IAisInfoService {
             params.put("mmsi", mmsi);
             params.put("shipId", shipId);
             params.put("shipNo", shipNo);
-            String getResult = HttpUtil.get(shipBaseInfo, params);
-            JSONObject jsonObject = JSON.parseObject(getResult);
-            if (jsonObject != null && 200 == jsonObject.getInteger("code")) {
-                JSONArray result = jsonObject.getJSONArray("data");
-                if (result != null && !result.isEmpty()) {
-                    Map<String, String> stringStringMap = Convert.toMap(String.class, String.class, result.get(0));
-                    return AisShipInfo.builder().shipName(stringStringMap.get("shipnameCn")).shipRegionType(stringStringMap.get("shipRegionType")).build();
+            try {
+                String getResult = HttpUtil.get(shipBaseInfo, params);
+                JSONObject jsonObject = JSON.parseObject(getResult);
+                if (jsonObject != null && 200 == jsonObject.getInteger("code")) {
+                    JSONArray result = jsonObject.getJSONArray("data");
+                    if (result != null && !result.isEmpty()) {
+                        Map<String, String> stringStringMap = Convert.toMap(String.class, String.class, result.get(0));
+                        return AisShipInfo.builder().shipName(stringStringMap.get("shipnameCn")).shipRegionType(stringStringMap.get("shipRegionType")).build();
+                    }
                 }
+            } catch (Exception e) {
+                log.error("获取船舶基本信息异常");
             }
         }
         return null;
     }
+
+    /**
+     * 推送需要获取的船舶实时数据
+     *
+     * @param mmsis
+     */
+    @Override
+    public void getDynamicShipInfo(String mmsis) {
+        try {
+            String s = HttpUtil.get(shipDynamicInfo + mmsis);
+            log.info("推送船舶动态信息,返回结果:{}", s);
+        } catch (Exception e) {
+            log.error("推送船舶动态信息异常");
+        }
+    }
 }

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

@@ -0,0 +1,27 @@
+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.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);
+    }
+}

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

@@ -0,0 +1,24 @@
+<?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">
+
+
+    <select id="queryDynamicShip" resultType="com.ruoyi.system.domain.AisShip">
+        SELECT mmsi,
+               lng,
+               lat,
+               date_format(receive, '%Y-%m-%d %H:%i:%s') as receive
+        FROM (
+                 SELECT mmsi,
+                        lng,
+                        lat,
+                        receive
+                 FROM ais_ship
+                 WHERE DATE_SUB(CURDATE(), INTERVAL #{day} DAY) &lt;= date (receive)
+        ORDER BY receive DESC ) t
+        GROUP BY t.mmsi
+    </select>
+
+</mapper>