459242451@qq.com 3 жил өмнө
parent
commit
022ac2f7aa

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

@@ -11,8 +11,10 @@ import cn.hutool.http.HttpUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.ruoyi.common.constant.CacheConstants;
 import com.ruoyi.common.constant.ElasticConstants;
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.utils.uuid.IdUtils;
 import com.ruoyi.framework.config.ElasticSearchClient;
 import com.ruoyi.system.domain.AisShip;
@@ -88,6 +90,8 @@ public class GasCommonController {
     private ISysConfigService configService;
     @Value("${black.snapImgUrl}")
     private String blackImgUrl;
+    @Autowired
+    private RedisCache redisCache;
 
     @PreAuthorize("@ss.hasPermi('system:gas:sync')")
     @PostMapping("/sync")
@@ -143,6 +147,9 @@ public class GasCommonController {
     @GetMapping("/queryDeviceList")
     @ApiOperation("获取所有设备数据")
     public AjaxResult queryDeviceList(@RequestParam(required = false) String monitor) {
+        if (redisCache.hasKey(CacheConstants.DEVICE_LIST_STATIC)) {
+            return AjaxResult.success(redisCache.getCacheMap(CacheConstants.DEVICE_LIST_STATIC));
+        }
         List<DeviceBo> njsanq = new ArrayList<>();
         List<DeviceBo> njsiq = new ArrayList<>();
         List<DeviceBo> ry = new ArrayList<>();
@@ -210,9 +217,30 @@ public class GasCommonController {
         data.put("江阴大桥", jy);
         data.put("苏通大桥", st);
 
+        redisCache.setCacheMap(CacheConstants.DEVICE_LIST_STATIC, data);
         return AjaxResult.success(data);
     }
 
+    @GetMapping("/queryShipByDeviceId")
+    @ApiOperation("根据设备id获取设备的嫌疑或违规船舶数据")
+    public AjaxResult queryShipByDeviceId(@RequestParam String deviceId, @RequestParam String illegalStatus, @RequestParam(required = false) Integer size, @RequestParam String... index) {
+        Map<String, Object> equalsCondition = new HashMap<>();
+        equalsCondition.put("illegalStatus", illegalStatus);
+        equalsCondition.put("deviceId", deviceId);
+        List<String> orderBy = new ArrayList<>();
+        orderBy.add("-createTime");
+        if (ObjectUtil.isEmpty(size)) {
+            size = 20;
+        }
+        Map<String, Object> stringObjectMap = client.searchDocument(equalsCondition,
+                null,
+                orderBy,
+                1,
+                size,
+                index);
+        return AjaxResult.success(Convert.toList(IllegalInfo.class, stringObjectMap.get("pageList")));
+    }
+
     @GetMapping("/queryShipList")
     @ApiOperation("获取所有船舶数据-用于地图展示船舶")
     public AjaxResult queryShipList(@RequestParam(required = false) String monitor, @RequestParam(required = false) String startTime) {
@@ -300,6 +328,12 @@ public class GasCommonController {
         put("江阴大桥", "江阴海事局");
         put("苏通大桥", "常熟海事局");
     }};
+    public final static Map<String, String> heiyanDeviceMap = new HashMap<String, String>() {{
+        put("南京三桥", "65");
+        put("润扬大桥", "66");
+        put("江阴大桥", "67");
+        put("苏通大桥", "68");
+    }};
 
     @GetMapping("/queryData")
     @ApiOperation("查询ES数据")
@@ -372,6 +406,7 @@ public class GasCommonController {
                         afterDataMap.put("berthName", eepReportRecInfo.getBerthName());
                     }
                 }
+                afterDataMap.put("deviceId", afterDataMap.get("semId"));
                 // 查询站点信息
                 Map<String, Object> sem = client.getDocById(ElasticConstants.AIS_SEM_INSTRUMENT, Convert.toStr(afterDataMap.get("semId")), "name,category");
                 if (sem != null && ObjectUtil.equal(sem.get("code"), 200)) {
@@ -496,6 +531,7 @@ public class GasCommonController {
             }
             if (ObjectUtil.isNotEmpty(afterDataMap.get("snapPos"))) {
                 afterDataMap.put("orgName", orgMap.get(Convert.toStr(afterDataMap.get("snapPos"))));
+                afterDataMap.put("deviceId", heiyanDeviceMap.get(Convert.toStr(afterDataMap.get("snapPos"))));
             }
             // 保存数据
             saveIllegalData(afterDataMap, ElasticConstants.HEIYAN_SHIP_RECOGNITION);

+ 0 - 97
ruoyi-admin/src/main/java/com/ruoyi/web/controller/gas/So2Controller.java

@@ -17,10 +17,8 @@ import com.ruoyi.common.core.page.TableSupport;
 import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.enums.AggsType;
 import com.ruoyi.framework.config.ElasticSearchClient;
-import com.ruoyi.system.domain.GuapAlert;
 import com.ruoyi.system.domain.GuapMonitorPoint;
 import com.ruoyi.system.domain.IllegalShip;
-import com.ruoyi.system.domain.XiuTanIllegalShip;
 import com.ruoyi.system.domain.XiuTanSemInstrument;
 import com.ruoyi.system.service.IAisDatabase;
 import com.ruoyi.system.service.IHeiYanService;
@@ -65,84 +63,6 @@ public class So2Controller extends BaseController {
     @Autowired
     private ISysDictTypeService dictTypeService;
 
-    @GetMapping("/guangpu/list")
-    @ApiOperation("光谱-硫嫌疑船舶列表数据")
-    public TableDataInfo GpList(GuapAlert guapAlert) {
-        // 传来的参数
-        Map<String, Object> params = guapAlert.getParams();
-        Map<String, Object> equalsCondition = new HashMap<>();
-        // 组装查询条件
-        equalsCondition.put("mmsi", ObjectUtil.isEmpty(guapAlert.getMmsi()) ? null : StrUtil.concat(true, "*", Convert.toStr(guapAlert.getMmsi()), "*"));
-        equalsCondition.put("shipName", StrUtil.isBlank(guapAlert.getShipName()) ? null : StrUtil.concat(true, "*", guapAlert.getShipName(), "*"));
-        equalsCondition.put("shipRegionType", guapAlert.getShipRegionType());
-        equalsCondition.put("destination", StrUtil.isBlank(guapAlert.getDestination()) ? null : StrUtil.concat(true, "*", guapAlert.getDestination(), "*"));
-        equalsCondition.put("orgName", guapAlert.getOrgName());
-        equalsCondition.put("illegalStatus", guapAlert.getIllegalStatus());
-        equalsCondition.put("dealResult", guapAlert.getDealResult());
-        equalsCondition.put("fastResult", guapAlert.getFastResult());
-        equalsCondition.put("uploadResult", guapAlert.getUploadResult());
-        equalsCondition.put("monitorPointName", guapAlert.getMonitorPointName());
-        // 组装范围查询条件
-        Map<String, Object> rangeCondition = new HashMap<>();
-        if (ObjectUtil.isNotEmpty(params.get("beginTime"))) {
-            params.put("beginTime", params.get("beginTime") + " 00:00:00");
-        }
-        if (ObjectUtil.isNotEmpty(params.get("endTime"))) {
-            params.put("endTime", params.get("endTime") + " 23:59:59");
-        }
-        rangeCondition.put("createTime", StrUtil.concat(true, "[", Convert.toStr(params.get("beginTime")), ",", Convert.toStr(params.get("endTime")), "]"));
-        List<String> orderBy = new ArrayList<>();
-        orderBy.add("-createTime");
-        PageDomain pageDomain = TableSupport.buildPageRequest();
-        Map<String, Object> maps = client.searchDocument(equalsCondition, rangeCondition, orderBy, pageDomain.getPageNum(), pageDomain.getPageSize(), ElasticConstants.SO2_ALERT);
-
-        TableDataInfo rspData = new TableDataInfo();
-        rspData.setCode(HttpStatus.SUCCESS);
-        rspData.setMsg("查询成功");
-        rspData.setRows(Convert.toList(GuapAlert.class, maps.get("pageList")));
-        rspData.setTotal(Convert.toLong(maps.get("totalNum")));
-        return rspData;
-    }
-
-    @GetMapping("/xiutan/list")
-    @ApiOperation("嗅探-硫嫌疑船舶列表数据")
-    public TableDataInfo XtList(XiuTanIllegalShip illegalShip) {
-        // 传来的参数
-        Map<String, Object> params = illegalShip.getParams();
-        Map<String, Object> equalsCondition = new HashMap<>();
-        // 组装查询条件
-        equalsCondition.put("mmsi", ObjectUtil.isEmpty(illegalShip.getMmsi()) ? null : StrUtil.concat(true, "*", Convert.toStr(illegalShip.getMmsi()), "*"));
-        equalsCondition.put("shipName", StrUtil.isBlank(illegalShip.getShipName()) ? null : StrUtil.concat(true, "*", illegalShip.getShipName(), "*"));
-        equalsCondition.put("shipRegionType", illegalShip.getShipRegionType());
-        equalsCondition.put("destination", StrUtil.isBlank(illegalShip.getDestination()) ? null : StrUtil.concat(true, "*", illegalShip.getDestination(), "*"));
-        equalsCondition.put("orgName", illegalShip.getOrgName());
-        equalsCondition.put("illegalStatus", illegalShip.getIllegalStatus());
-        equalsCondition.put("dealResult", illegalShip.getDealResult());
-        equalsCondition.put("fastResult", illegalShip.getFastResult());
-        equalsCondition.put("uploadResult", illegalShip.getUploadResult());
-        equalsCondition.put("monitorPointName", illegalShip.getMonitorPointName());
-        // 组装范围查询条件
-        Map<String, Object> rangeCondition = new HashMap<>();
-        if (ObjectUtil.isNotEmpty(params.get("beginTime"))) {
-            params.put("beginTime", params.get("beginTime") + " 00:00:00");
-        }
-        if (ObjectUtil.isNotEmpty(params.get("endTime"))) {
-            params.put("endTime", params.get("endTime") + " 23:59:59");
-        }
-        rangeCondition.put("peakTime", StrUtil.concat(true, "[", Convert.toStr(params.get("beginTime")), ",", Convert.toStr(params.get("endTime")), "]"));
-        List<String> orderBy = new ArrayList<>();
-        orderBy.add("-peakTime");
-        PageDomain pageDomain = TableSupport.buildPageRequest();
-        Map<String, Object> maps = client.searchDocument(equalsCondition, rangeCondition, orderBy, pageDomain.getPageNum(), pageDomain.getPageSize(), ElasticConstants.AIS_ILLEGAL_SHIP);
-
-        TableDataInfo rspData = new TableDataInfo();
-        rspData.setCode(HttpStatus.SUCCESS);
-        rspData.setMsg("查询成功");
-        rspData.setRows(Convert.toList(GuapAlert.class, maps.get("pageList")));
-        rspData.setTotal(Convert.toLong(maps.get("totalNum")));
-        return rspData;
-    }
-
     @GetMapping("/list")
     @ApiOperation("硫嫌疑船舶列表数据")
     public TableDataInfo list(IllegalShip illegalShip) {
@@ -304,21 +224,4 @@ public class So2Controller extends BaseController {
         return AjaxResult.success(result);
     }
 
-    /*@DeleteMapping("/del")
-    @ApiOperation("删除数据")
-    public AjaxResult del() {
-        if (StrUtil.isBlank(interval)) {
-            // 默认值为1个月
-            interval = "1M";
-        }
-        Map<Object, Object> aisAggs = client.dateHistogramAggs(ElasticConstants.AIS_ILLEGAL_SHIP, AggsType.count, "peakTime", "id", null, null, new DateHistogramInterval(interval));
-        Map<Object, Object> so2Aggs = client.dateHistogramAggs(ElasticConstants.SO2_ALERT, AggsType.count, "createTime", "id", null, null, new DateHistogramInterval(interval));
-        Map<Object, Object> heiyanAggs = client.dateHistogramAggs(ElasticConstants.HEIYAN_SHIP_RECOGNITION, AggsType.count, "snapTimeFmt", "id", null, null, new DateHistogramInterval(interval));
-        Map<String, Map<Object, Object>> result = new HashMap<>();
-        result.put("ais", aisAggs);
-        result.put("so2", so2Aggs);
-        result.put("black", heiyanAggs);
-        return AjaxResult.success(result);
-    }*/
-
 }

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

@@ -87,6 +87,12 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
         put("江阴大桥", "江阴海事局");
         put("苏通大桥", "常熟海事局");
     }};
+    public final static Map<String, String> heiyanDeviceMap = new HashMap<String, String>() {{
+        put("南京三桥", "65");
+        put("润扬大桥", "66");
+        put("江阴大桥", "67");
+        put("苏通大桥", "68");
+    }};
 
     @Override
     @Scheduled(fixedDelay = 100) //每隔100秒执行
@@ -249,6 +255,7 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                     }
                     if (ObjectUtil.isNotEmpty(afterDataMap.get("snapPos"))) {
                         afterDataMap.put("orgName", orgMap.get(Convert.toStr(afterDataMap.get("snapPos"))));
+                        afterDataMap.put("deviceId", heiyanDeviceMap.get(Convert.toStr(afterDataMap.get("snapPos"))));
                     }
                     afterDataMap.put("createTime", afterDataMap.get("snapTimeFmt"));
                     afterDataMap.put("monitorPointName", afterDataMap.get("snapPos"));
@@ -259,7 +266,8 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                     // 删除设备和类型的统计缓存
                     redisCache.deleteObject(CollUtil.set(false,
                             CacheConstants.DEVICE_STATIC,
-                            CacheConstants.DEVICE_TYPE_STATIC));
+                            CacheConstants.DEVICE_TYPE_STATIC,
+                            CacheConstants.DEVICE_LIST_STATIC));
                 } else if (StrUtil.equalsIgnoreCase(database, "ship") && StrUtil.equalsIgnoreCase(table, "monitor_point")) {
                     // 检测点信息
                     client.createDocument(ElasticConstants.SO2_MONITOR_POINT, Convert.toStr(afterDataMap.get("id")), afterDataMap);
@@ -268,7 +276,8 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                     // 设备信息
                     redisCache.deleteObject(CollUtil.set(false,
                             CacheConstants.DEVICE_STATIC,
-                            CacheConstants.DEVICE_TYPE_STATIC));
+                            CacheConstants.DEVICE_TYPE_STATIC,
+                            CacheConstants.DEVICE_LIST_STATIC));
                 } else if (StrUtil.equalsIgnoreCase(database, "ship") && StrUtil.equalsIgnoreCase(table, "alert")) {
                     // 船舶记录
                     if ("prod".equals(env)) {
@@ -318,7 +327,8 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                     client.createDocument(ElasticConstants.AIS_SEM_INSTRUMENT, Convert.toStr(afterDataMap.get("id")), afterDataMap);
                     redisCache.deleteObject(CollUtil.set(false,
                             CacheConstants.DEVICE_STATIC,
-                            CacheConstants.DEVICE_TYPE_STATIC));
+                            CacheConstants.DEVICE_TYPE_STATIC,
+                            CacheConstants.DEVICE_LIST_STATIC));
                 } else if (StrUtil.equalsIgnoreCase(database, "ais_database") && StrUtil.equalsIgnoreCase(table, "illegal_ship")) {
                     // 嗅探系统-违规船舶
                     if ("prod".equals(env)) {
@@ -343,6 +353,7 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                                 afterDataMap.put("berthName", eepReportRecInfo.getBerthName());
                             }
                         }
+                        afterDataMap.put("deviceId", afterDataMap.get("semId"));
                         // 查询站点信息
                         Map<String, Object> sem = client.getDocById(ElasticConstants.AIS_SEM_INSTRUMENT, Convert.toStr(afterDataMap.get("semId")), "name,category");
                         if (sem != null && ObjectUtil.equal(sem.get("code"), 200)) {
@@ -374,7 +385,8 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                 if (StrUtil.equalsIgnoreCase(database, "smoke_api") && StrUtil.equalsIgnoreCase(table, "ship_snap_address")) {
                     redisCache.deleteObject(CollUtil.set(false,
                             CacheConstants.DEVICE_STATIC,
-                            CacheConstants.DEVICE_TYPE_STATIC));
+                            CacheConstants.DEVICE_TYPE_STATIC,
+                            CacheConstants.DEVICE_LIST_STATIC));
                 } else if (StrUtil.equalsIgnoreCase(database, "ship") && StrUtil.equalsIgnoreCase(table, "monitor_point")) {
                     // 检测点信息
                     client.updateDocument(ElasticConstants.SO2_MONITOR_POINT, Convert.toStr(afterDataMap.get("id")), afterDataMap);
@@ -383,20 +395,23 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                     // 设备信息
                     redisCache.deleteObject(CollUtil.set(false,
                             CacheConstants.DEVICE_STATIC,
-                            CacheConstants.DEVICE_TYPE_STATIC));
+                            CacheConstants.DEVICE_TYPE_STATIC,
+                            CacheConstants.DEVICE_LIST_STATIC));
                 } else if (StrUtil.equalsIgnoreCase(database, "ais_database") && (StrUtil.equalsIgnoreCase(table, "sem_instrument"))) {
                     // 嗅探系统-站点信息
                     client.updateDocument(ElasticConstants.AIS_SEM_INSTRUMENT, Convert.toStr(afterDataMap.get("id")), afterDataMap);
                     redisCache.deleteObject(CollUtil.set(false,
                             CacheConstants.DEVICE_STATIC,
-                            CacheConstants.DEVICE_TYPE_STATIC));
+                            CacheConstants.DEVICE_TYPE_STATIC,
+                            CacheConstants.DEVICE_LIST_STATIC));
                 }
                 break;
             case DELETE:
                 if (StrUtil.equalsIgnoreCase(database, "smoke_api") && StrUtil.equalsIgnoreCase(table, "ship_snap_address")) {
                     redisCache.deleteObject(CollUtil.set(false,
                             CacheConstants.DEVICE_STATIC,
-                            CacheConstants.DEVICE_TYPE_STATIC));
+                            CacheConstants.DEVICE_TYPE_STATIC,
+                            CacheConstants.DEVICE_LIST_STATIC));
                 } else if (StrUtil.equalsIgnoreCase(database, "ship") && StrUtil.equalsIgnoreCase(table, "monitor_point")) {
                     // 检测点信息
                     client.deleteDocument(ElasticConstants.SO2_MONITOR_POINT, Convert.toStr(afterDataMap.get("id")));
@@ -405,13 +420,15 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                     // 设备信息
                     redisCache.deleteObject(CollUtil.set(false,
                             CacheConstants.DEVICE_STATIC,
-                            CacheConstants.DEVICE_TYPE_STATIC));
+                            CacheConstants.DEVICE_TYPE_STATIC,
+                            CacheConstants.DEVICE_LIST_STATIC));
                 } else if (StrUtil.equalsIgnoreCase(database, "ais_database") && (StrUtil.equalsIgnoreCase(table, "sem_instrument"))) {
                     // 嗅探系统-站点信息
                     client.deleteDocument(ElasticConstants.AIS_SEM_INSTRUMENT, Convert.toStr(afterDataMap.get("id")));
                     redisCache.deleteObject(CollUtil.set(false,
                             CacheConstants.DEVICE_STATIC,
-                            CacheConstants.DEVICE_TYPE_STATIC));
+                            CacheConstants.DEVICE_TYPE_STATIC,
+                            CacheConstants.DEVICE_LIST_STATIC));
                 }
                 break;
             default:

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

@@ -42,6 +42,12 @@ public class GasCommonServiceImpl implements IGasCommonService {
         put("江阴大桥", "江阴海事局");
         put("苏通大桥", "常熟海事局");
     }};
+    public final static Map<String, String> heiyanDeviceMap = new HashMap<String, String>() {{
+        put("南京三桥", "65");
+        put("润扬大桥", "66");
+        put("江阴大桥", "67");
+        put("苏通大桥", "68");
+    }};
 
     @SneakyThrows
     @Override
@@ -81,6 +87,7 @@ public class GasCommonServiceImpl implements IGasCommonService {
                     stringObjectMap.put("semName", data.get("name"));
                     stringObjectMap.put("monitorPointName", data.get("category"));
                 }
+                stringObjectMap.put("deviceId", stringObjectMap.get("semId"));
                 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);
@@ -102,6 +109,7 @@ public class GasCommonServiceImpl implements IGasCommonService {
                 stringObjectMap.put("createTime", stringObjectMap.get("snapTimeFmt"));
                 stringObjectMap.put("mmsi", stringObjectMap.get("aisMmsi"));
                 stringObjectMap.put("orgName", orgMap.get(Convert.toStr(stringObjectMap.get("snapPos"))));
+                stringObjectMap.put("deviceId", heiyanDeviceMap.get(Convert.toStr(stringObjectMap.get("snapPos"))));
                 saveOrUpdate(ElasticConstants.HEIYAN_SHIP_RECOGNITION, Convert.toStr(stringObjectMap.get("id")), stringObjectMap);
             }
         } else if (StrUtil.equalsIgnoreCase(schema, "ship") && StrUtil.equalsIgnoreCase(table, "alert")) {

+ 2 - 0
ruoyi-common/src/main/java/com/ruoyi/common/constant/CacheConstants.java

@@ -11,5 +11,7 @@ public class CacheConstants {
     public static final String DEVICE_STATIC = "device:static";
     // 设备类型统计
     public static final String DEVICE_TYPE_STATIC = "devicetype:static";
+    // 设备所有数据统计
+    public static final String DEVICE_LIST_STATIC = "devicelist:static";
 
 }

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

@@ -27,7 +27,7 @@
                    end                             status,
                'ais'                            as deviceType,
                now()                            as updateTime,
-               'ais'                            as source
+               'ais_illegal_ship'               as source
         from sem_instrument
         where Category is not null
     </select>

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

@@ -114,6 +114,7 @@
         monitor_point_id monitorPointId,
         t2.name monitorPointName,
         t1.mmsi,
+        t1.device_id as deviceId,
         t3.name shipName,
         t3.destination,
         t1.no2_concentration no2Concentration,

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

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

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

@@ -31,7 +31,7 @@
                    end                                 status,
                CONCAT(d.longitude, ',', d.latitude) as latilongti,
                update_time                          as updateTime,
-               'so2'                                as source
+               'so2_alert'                          as source
         from device d
                  left join monitor_point t1
                            on t1.id = d.monitor_point_id