Browse Source

光谱调整字段

459242451@qq.com 3 years ago
parent
commit
d994880c9c

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

@@ -2,6 +2,7 @@ package com.ruoyi.web.job;
 
 import cn.hutool.core.collection.CollUtil;
 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.alibaba.otter.canal.client.CanalConnector;
@@ -14,6 +15,7 @@ import com.ruoyi.common.constant.ElasticConstants;
 import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.utils.JdbcTypeUtil;
 import com.ruoyi.framework.config.ElasticSearchClient;
+import com.ruoyi.system.service.ISysConfigService;
 import com.ruoyi.web.core.config.CanalConfig;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
@@ -45,6 +47,8 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
     private ElasticSearchClient client;
     @Autowired
     private RedisCache redisCache;
+    @Autowired
+    private ISysConfigService configService;
 //    @Resource
 //    private CanalConnector canalConnector;
 
@@ -157,6 +161,9 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
             return;
         }
 
+        String so2ThresholdVal = configService.selectConfigByKey("so2.so2");
+        String blackThresholdVal = configService.selectConfigByKey("black.rcgSoot");
+
         // 根据不同类型处理相应的逻辑
         switch (eventType) {
             case INSERT:
@@ -176,13 +183,13 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                     redisCache.deleteObject(CollUtil.set(false,
                             CacheConstants.DEVICE_STATIC,
                             CacheConstants.DEVICE_TYPE_STATIC));
-                } else if (StrUtil.equalsIgnoreCase(database, "so2") && StrUtil.equalsIgnoreCase(table, "ship_static_info")) {
+                } /*else if (StrUtil.equalsIgnoreCase(database, "so2") && StrUtil.equalsIgnoreCase(table, "ship_static_info")) {
                     // 船舶信息
                     if (ObjectUtil.isNotEmpty(afterDataMap.get("mmsi"))) {
                         client.createDocument(ElasticConstants.SO2_SHIP_STATIC_INFO, Convert.toStr(afterDataMap.get("mmsi")), afterDataMap);
                     }
-                } else if (StrUtil.equalsIgnoreCase(database, "so2") && StrUtil.equalsIgnoreCase(table, "alert")) {
-                    // 违规船舶
+                }*/ else if (StrUtil.equalsIgnoreCase(database, "so2") && StrUtil.equalsIgnoreCase(table, "alert")) {
+                    // 船舶记录
                     // 查询检测点和船舶信息
                     if (ObjectUtil.isNotEmpty(afterDataMap.get("mmsi"))) {
                         Map<String, Object> mmsi = client.getDocById(ElasticConstants.SO2_SHIP_STATIC_INFO, Convert.toStr(afterDataMap.get("mmsi")), "name,destination");
@@ -197,6 +204,15 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                         Map<String, String> data = Convert.toMap(String.class, String.class, monitor.get("data"));
                         afterDataMap.put("monitorPointName", data.get("name"));
                     }
+                    // 判断是否大于阈值
+                    if (ObjectUtil.isNotEmpty(afterDataMap.get("so2Percent")) && NumberUtil.isGreaterOrEqual(Convert.toBigDecimal(afterDataMap.get("so2Percent")), Convert.toBigDecimal(so2ThresholdVal))) {
+                        // 嫌疑船舶
+                        afterDataMap.put("illegalStatus", 2);
+                        // TODO 上报行政检查系统
+
+                    } else {
+                        afterDataMap.put("illegalStatus", 1);
+                    }
                     client.createDocument(ElasticConstants.SO2_ALERT, Convert.toStr(afterDataMap.get("id")), afterDataMap);
                 } else if (StrUtil.equalsIgnoreCase(database, "ais_database") && (StrUtil.equalsIgnoreCase(table, "sem_instrument_test") || StrUtil.equalsIgnoreCase(table, "sem_instrument"))) {
                     // 嗅探系统-站点信息
@@ -234,12 +250,6 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                     redisCache.deleteObject(CollUtil.set(false,
                             CacheConstants.DEVICE_STATIC,
                             CacheConstants.DEVICE_TYPE_STATIC));
-                } else if (StrUtil.equalsIgnoreCase(database, "so2") && StrUtil.equalsIgnoreCase(table, "ship_static_info")) {
-                    // 船舶信息
-                    client.updateDocument(ElasticConstants.SO2_SHIP_STATIC_INFO, Convert.toStr(afterDataMap.get("mmsi")), afterDataMap);
-                } else if (StrUtil.equalsIgnoreCase(database, "so2") && StrUtil.equalsIgnoreCase(table, "alert")) {
-                    // 违规船舶
-                    client.updateDocument(ElasticConstants.SO2_ALERT, Convert.toStr(afterDataMap.get("id")), afterDataMap);
                 } else if (StrUtil.equalsIgnoreCase(database, "ais_database") && (StrUtil.equalsIgnoreCase(table, "sem_instrument_test") || StrUtil.equalsIgnoreCase(table, "sem_instrument"))) {
                     // 嗅探系统-站点信息
                     client.updateDocument(ElasticConstants.AIS_SEM_INSTRUMENT, Convert.toStr(afterDataMap.get("id")), afterDataMap);
@@ -259,9 +269,7 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                 }
                 break;
             case DELETE:
-                if (StrUtil.equalsIgnoreCase(database, "heiyan") && StrUtil.equalsIgnoreCase(table, "ship_recognition")) {
-                    client.deleteDocument(ElasticConstants.HEIYAN_SHIP_RECOGNITION, Convert.toStr(afterDataMap.get("id")));
-                } else if (StrUtil.equalsIgnoreCase(database, "heiyan") && StrUtil.equalsIgnoreCase(table, "ship_snap_address")) {
+                if (StrUtil.equalsIgnoreCase(database, "heiyan") && StrUtil.equalsIgnoreCase(table, "ship_snap_address")) {
                     redisCache.deleteObject(CollUtil.set(false,
                             CacheConstants.DEVICE_STATIC,
                             CacheConstants.DEVICE_TYPE_STATIC));
@@ -277,18 +285,12 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                 } else if (StrUtil.equalsIgnoreCase(database, "so2") && StrUtil.equalsIgnoreCase(table, "ship_static_info")) {
                     // 船舶信息
                     client.deleteDocument(ElasticConstants.SO2_SHIP_STATIC_INFO, Convert.toStr(afterDataMap.get("mmsi")));
-                } else if (StrUtil.equalsIgnoreCase(database, "so2") && StrUtil.equalsIgnoreCase(table, "alert")) {
-                    // 违规船舶
-                    client.deleteDocument(ElasticConstants.SO2_ALERT, Convert.toStr(afterDataMap.get("id")));
                 } else if (StrUtil.equalsIgnoreCase(database, "ais_database") && (StrUtil.equalsIgnoreCase(table, "sem_instrument_test") || 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));
-                } else if (StrUtil.equalsIgnoreCase(database, "ais_database") && StrUtil.equalsIgnoreCase(table, "illegal_ship")) {
-                    // 嗅探系统-违规船舶
-                    client.deleteDocument(ElasticConstants.AIS_ILLEGAL_SHIP, Convert.toStr(afterDataMap.get("id")));
                 }
                 break;
             default:

+ 8 - 5
ruoyi-system/src/main/java/com/ruoyi/system/domain/XiuTanIllegalShip.java

@@ -1,7 +1,6 @@
 package com.ruoyi.system.domain;
 
 import cn.afterturn.easypoi.excel.annotation.Excel;
-import com.fasterxml.jackson.annotation.JsonFormat;
 import com.ruoyi.common.core.domain.BaseEntity;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
@@ -11,17 +10,18 @@ import java.util.Date;
 
 /**
  * 嗅探-嫌疑船舶
- * 
+ *
  * @author ruoyi
  * @date 2021-08-24
  */
 @EqualsAndHashCode(callSuper = true)
 @Data
-public class XiuTanIllegalShip extends BaseEntity
-{
+public class XiuTanIllegalShip extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
-    /** 主键 */
+    /**
+     * 主键
+     */
     private Long id;
 
     private String semId;
@@ -64,6 +64,9 @@ public class XiuTanIllegalShip extends BaseEntity
     @Excel(name = "风向")
     private BigDecimal windAngle;
 
+    @Excel(name = "状态。1-正常;2-嫌疑;3-违规")
+    private Integer illegalStatus;
+
     private Integer confirmed;
 
 }

+ 58 - 67
ruoyi-system/src/main/resources/mapper/system/GasCommonMapper.xml

@@ -51,79 +51,76 @@
 
     <select id="queryShipRecognition" resultType="java.util.Map">
         select id,
-               createBy,
-               date_format(createTime,'%Y-%m-%d %H:%i:%S') as createTime,
-               updateBy,
-               date_format(updateTime,'%Y-%m-%d %H:%i:%S') as updateTime,
-               aisDist,
-               aisDrt,
-               aisDst,
-               aisMmsi,
-               aisShipLen,
-               aisShipName,
-               aisShipSpd,
-               aisShipType,
-               aisShipWidth,
-               isAbnormalSize,
-               latitude,
-               rcgSoot,
-               lockSeq,
-               longitude,
-               rcgCargoType,
-               rcgDeadweightTon,
-               rcgDist,
-               rcgDrt,
-               rcgIsFleet,
-               rcgLoadSts,
-               rcgShipHeightAboveWater,
-               rcgShipLen,
-               rcgShipName,
-               rcgShipSpd,
-               rcgShipType,
-               rcgShipWidth,
-               regportName,
-               remark,
-               snapImPath,
-               snapPos,
-               snapTime,
-               snapTimeFmt,
-               status,
-               textFeatureLabel,
-               textImgUrl,
-               rcgShipTypeDetail,
-               useWarn,
-               warnLabelList,
-               qrcode,
-               shipNameDirection
+        createBy,
+        date_format(createTime,'%Y-%m-%d %H:%i:%S') as createTime,
+        updateBy,
+        date_format(updateTime,'%Y-%m-%d %H:%i:%S') as updateTime,
+        aisDist,
+        aisDrt,
+        aisDst,
+        aisMmsi,
+        aisShipLen,
+        aisShipName,
+        aisShipSpd,
+        aisShipType,
+        aisShipWidth,
+        isAbnormalSize,
+        latitude,
+        rcgSoot,
+        lockSeq,
+        longitude,
+        rcgCargoType,
+        rcgDeadweightTon,
+        rcgDist,
+        rcgDrt,
+        rcgIsFleet,
+        rcgLoadSts,
+        rcgShipHeightAboveWater,
+        rcgShipLen,
+        rcgShipName,
+        rcgShipSpd,
+        rcgShipType,
+        rcgShipWidth,
+        regportName,
+        remark,
+        snapImPath,
+        snapPos,
+        snapTime,
+        snapTimeFmt,
+        status,
+        textFeatureLabel,
+        textImgUrl,
+        rcgShipTypeDetail,
+        useWarn,
+        warnLabelList,
+        qrcode,
+        shipNameDirection
         from ship_recognition
         <where>
             <if test="syncPost.startTime != null and syncPost.startTime != ''">
                 createTime &gt;= #{syncPost.startTime}
             </if>
             <if test="syncPost.endTime != null and syncPost.endTime != ''">
-               createTime &lt;= #{syncPost.endTime}
+                createTime &lt;= #{syncPost.endTime}
             </if>
         </where>
     </select>
 
     <select id="queryAlert" resultType="java.util.Map">
         select t1.id,
-               monitor_point_id                                 monitorPointId,
-               t2.name                                          monitorPointName,
-               t1.mmsi,
-               t3.name                                          shipName,
-               t3.destination,
-               alert_type                                       alertType,
-               t1.no2_concentration                             no2Concentration,
-               t1.so2_concentration                             so2Concentration,
-               t1.co2_concentration                             co2Concentration,
-               so2_percent                                      so2Percent,
-               date_format(create_time, '%Y-%m-%d %H:%i:%S') as createTime,
-               audit_status                                     auditStatus,
-               capture_url                                      captureUrl
+        monitor_point_id monitorPointId,
+        t2.name monitorPointName,
+        t1.mmsi,
+        t3.name shipName,
+        t3.destination,
+        t1.no2_concentration no2Concentration,
+        t1.so2_concentration so2Concentration,
+        t1.co2_concentration co2Concentration,
+        so2_percent so2Percent,
+        date_format(create_time, '%Y-%m-%d %H:%i:%S') as createTime
         from alert t1
-                 left join monitor_point t2 on t1.monitor_point_id = t2.id
-                 left join ship_static_info t3 on t1.mmsi = t3.mmsi
+        left join monitor_point t2 on t1.monitor_point_id = t2.id
+        left join ship_static_info t3 on t1.mmsi = t3.mmsi
         <where>
             <if test="syncPost.startTime != null and syncPost.startTime != ''">
                 create_time &gt;= #{syncPost.startTime}
@@ -137,13 +134,7 @@
     <select id="queryMonitorPoint" resultType="java.util.Map">
         select id,
                name,
-               city_id             cityId,
-               no2_concentration   no2Concentration,
-               no2_alert_threshold no2AlertThreshold,
-               so2_concentration   so2Concentration,
-               co2_concentration   co2Concentration,
-               so2_alert_threshold so2AlertThreshold,
-               co2_alert_threshold co2AlertThreshold,
+               organization,
                longitude,
                latitude,
                remark