Explorar o código

调整嗅探系统的监测点数据

459242451@qq.com %!s(int64=3) %!d(string=hai) anos
pai
achega
f942eeb589

+ 4 - 2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/gas/BlackGasController.java

@@ -64,7 +64,8 @@ public class BlackGasController extends BaseController {
         equalsCondition.put("aisShipName", StrUtil.isBlank(shipRecognition.getAisShipName()) ? null : StrUtil.concat(true, "*", shipRecognition.getAisShipName(), "*"));
         equalsCondition.put("snapPos", StrUtil.isBlank(shipRecognition.getSnapPos()) ? null : StrUtil.concat(true, "*", shipRecognition.getSnapPos(), "*"));
         equalsCondition.put("aisDst", StrUtil.isBlank(shipRecognition.getAisDst()) ? null : StrUtil.concat(true, "*", shipRecognition.getAisDst(), "*"));
-        equalsCondition.put("aisShipType", shipRecognition.getAisShipType());
+        equalsCondition.put("aisShipType", StrUtil.isBlank(shipRecognition.getAisShipType()) ? null : StrUtil.concat(true, "*", shipRecognition.getAisShipType(), "*"));
+        equalsCondition.put("rcgSoot",shipRecognition.getRcgSoot());
         // 组装范围查询条件
         Map<String, Object> rangeCondition = new HashMap<>();
         if (ObjectUtil.isNotEmpty(params.get("beginTime"))) {
@@ -100,7 +101,8 @@ public class BlackGasController extends BaseController {
         equalsCondition.put("aisShipName", StrUtil.isBlank(shipRecognition.getAisShipName()) ? null : StrUtil.concat(true, "*", shipRecognition.getAisShipName(), "*"));
         equalsCondition.put("snapPos", StrUtil.isBlank(shipRecognition.getSnapPos()) ? null : StrUtil.concat(true, "*", shipRecognition.getSnapPos(), "*"));
         equalsCondition.put("aisDst", StrUtil.isBlank(shipRecognition.getAisDst()) ? null : StrUtil.concat(true, "*", shipRecognition.getAisDst(), "*"));
-        equalsCondition.put("aisShipType", shipRecognition.getAisShipType());
+        equalsCondition.put("aisShipType", StrUtil.isBlank(shipRecognition.getAisShipType()) ? null : StrUtil.concat(true, "*", shipRecognition.getAisShipType(), "*"));
+        equalsCondition.put("rcgSoot",shipRecognition.getRcgSoot());
         // 组装范围查询条件
         Map<String, Object> rangeCondition = new HashMap<>();
         if (ObjectUtil.isNotEmpty(params.get("beginTime"))) {

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

@@ -65,7 +65,7 @@ public class So2Controller extends BaseController {
         // 组装查询条件
         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("monitorPointId", guapAlert.getMonitorPointId());
+        equalsCondition.put("monitorPointName", guapAlert.getMonitorPointName());
         // 组装范围查询条件
         Map<String, Object> rangeCondition = new HashMap<>();
         if (ObjectUtil.isNotEmpty(params.get("beginTime"))) {
@@ -97,7 +97,7 @@ public class So2Controller extends BaseController {
         // 组装查询条件
         equalsCondition.put("shipMmsi", ObjectUtil.isEmpty(illegalShip.getShipMmsi()) ? null : StrUtil.concat(true, "*", Convert.toStr(illegalShip.getShipMmsi()), "*"));
         equalsCondition.put("shipName", StrUtil.isBlank(illegalShip.getShipName()) ? null : StrUtil.concat(true, "*", illegalShip.getShipName(), "*"));
-        equalsCondition.put("semId", illegalShip.getSemId());
+        equalsCondition.put("monitorPointName", illegalShip.getMonitorPointName());
         // 组装范围查询条件
         Map<String, Object> rangeCondition = new HashMap<>();
         if (ObjectUtil.isNotEmpty(params.get("beginTime"))) {

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

@@ -207,10 +207,11 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                 } else if (StrUtil.equalsIgnoreCase(database, "ais_database") && StrUtil.equalsIgnoreCase(table, "illegal_ship")) {
                     // 嗅探系统-违规船舶
                     // 查询站点信息
-                    Map<String, Object> sem = client.getDocById(ElasticConstants.AIS_SEM_INSTRUMENT, Convert.toStr(afterDataMap.get("semId")), "name");
+                    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)) {
                         Map<String, String> data = Convert.toMap(String.class, String.class, sem.get("data"));
                         afterDataMap.put("semName", data.get("name"));
+                        afterDataMap.put("monitorPointName", data.get("category"));
                     }
                     // 初始化设为未上传状态
                     afterDataMap.put("uploadFlag", 0);
@@ -248,10 +249,11 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                 } else if (StrUtil.equalsIgnoreCase(database, "ais_database") && StrUtil.equalsIgnoreCase(table, "illegal_ship")) {
                     // 嗅探系统-违规船舶
                     // 查询站点信息
-                    Map<String, Object> sem = client.getDocById(ElasticConstants.AIS_SEM_INSTRUMENT, Convert.toStr(afterDataMap.get("semId")), "name");
+                    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)) {
                         Map<String, String> data = Convert.toMap(String.class, String.class, sem.get("data"));
                         afterDataMap.put("semName", data.get("name"));
+                        afterDataMap.put("monitorPointName", data.get("category"));
                     }
                     client.updateDocument(ElasticConstants.AIS_ILLEGAL_SHIP, Convert.toStr(afterDataMap.get("id")), afterDataMap);
                 }

+ 30 - 3
ruoyi-admin/src/main/java/com/ruoyi/web/service/Impl/GasCommonServiceImpl.java

@@ -40,6 +40,12 @@ public class GasCommonServiceImpl implements IGasCommonService {
     public void sync(SyncPost syncPost) {
         String schema = syncPost.getSchema();
         String table = syncPost.getTable();
+        if (StrUtil.isNotBlank(syncPost.getStartTime())) {
+            syncPost.setStartTime(syncPost.getStartTime() + " 00:00:00");
+        }
+        if (StrUtil.isNotBlank(syncPost.getEndTime())) {
+            syncPost.setEndTime(syncPost.getEndTime() + " 23:59:59");
+        }
         if (StrUtil.equalsIgnoreCase(schema, "ais_database") && (StrUtil.equalsIgnoreCase(table, "sem_instrument_test") || StrUtil.equalsIgnoreCase(table, "sem_instrument"))) {
             // 嗅探站点信息
             List<Map<String,Object>> map = gasCommonMapper.querySemInstrument(table);
@@ -50,11 +56,32 @@ public class GasCommonServiceImpl implements IGasCommonService {
             // 嗅探违规船舶信息
             List<Map<String,Object>> map = gasCommonMapper.queryIllegalShip(syncPost);
             for (Map<String, Object> stringObjectMap : map) {
-                stringObjectMap.put("peakTime", DateUtil.formatDateTime(DateUtil.parse(Convert.toStr(stringObjectMap.get("peakTime")))));
-                stringObjectMap.put("startTime", DateUtil.formatDateTime(DateUtil.parse(Convert.toStr(stringObjectMap.get("startTime")))));
-                stringObjectMap.put("endTime", DateUtil.formatDateTime(DateUtil.parse(Convert.toStr(stringObjectMap.get("endTime")))));
                 saveOrUpdate(ElasticConstants.AIS_ILLEGAL_SHIP, Convert.toStr(stringObjectMap.get("id")), stringObjectMap);
             }
+        } else if (StrUtil.equalsIgnoreCase(schema, "heiyan") && StrUtil.equalsIgnoreCase(table, "ship_recognition")) {
+            // 黑烟嫌疑船舶
+            List<Map<String,Object>> map = gasCommonMapper.queryShipRecognition(syncPost);
+            for (Map<String, Object> stringObjectMap : map) {
+                saveOrUpdate(ElasticConstants.HEIYAN_SHIP_RECOGNITION, Convert.toStr(stringObjectMap.get("id")), stringObjectMap);
+            }
+        } else if (StrUtil.equalsIgnoreCase(schema, "so2") && StrUtil.equalsIgnoreCase(table, "alert")) {
+            // 光谱嫌疑船舶
+            List<Map<String,Object>> map = gasCommonMapper.queryAlert(syncPost);
+            for (Map<String, Object> stringObjectMap : map) {
+                saveOrUpdate(ElasticConstants.SO2_ALERT, Convert.toStr(stringObjectMap.get("id")), stringObjectMap);
+            }
+        } else if (StrUtil.equalsIgnoreCase(schema, "so2") && 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);
+            }
         }
     }
 

+ 15 - 13
ruoyi-framework/src/main/java/com/ruoyi/framework/config/ElasticSearchClient.java

@@ -5,7 +5,6 @@ import cn.hutool.core.util.StrUtil;
 import com.ruoyi.common.constant.DefineConstant;
 import com.ruoyi.framework.config.properties.ElasticSearchConfig;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
 import org.apache.http.HttpHost;
 import org.elasticsearch.action.ActionListener;
 import org.elasticsearch.action.DocWriteRequest;
@@ -31,13 +30,18 @@ import org.elasticsearch.client.indices.CreateIndexRequest;
 import org.elasticsearch.client.indices.CreateIndexResponse;
 import org.elasticsearch.client.indices.GetIndexRequest;
 import org.elasticsearch.common.Strings;
-import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.common.unit.DistanceUnit;
 import org.elasticsearch.common.xcontent.XContentBuilder;
 import org.elasticsearch.common.xcontent.XContentFactory;
-import org.elasticsearch.common.xcontent.XContentType;
 import org.elasticsearch.core.TimeValue;
-import org.elasticsearch.index.query.*;
+import org.elasticsearch.index.query.BoolQueryBuilder;
+import org.elasticsearch.index.query.GeoDistanceQueryBuilder;
+import org.elasticsearch.index.query.MatchQueryBuilder;
+import org.elasticsearch.index.query.PrefixQueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.elasticsearch.index.query.RangeQueryBuilder;
+import org.elasticsearch.index.query.TermQueryBuilder;
+import org.elasticsearch.index.query.WildcardQueryBuilder;
 import org.elasticsearch.search.SearchHit;
 import org.elasticsearch.search.SearchHits;
 import org.elasticsearch.search.builder.SearchSourceBuilder;
@@ -50,7 +54,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Bean;
 import org.springframework.stereotype.Component;
 import org.springframework.util.CollectionUtils;
-import org.springframework.util.MultiValueMap;
 
 import javax.annotation.PostConstruct;
 import java.io.IOException;
@@ -59,7 +62,6 @@ import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.TimeUnit;
 
 /**
  * ES客户端
@@ -105,7 +107,7 @@ public class ElasticSearchClient {
     /**
      * 创建索引
      *
-     * @param index
+     * @param index 索引名
      * @return
      */
     public boolean createIndex(String index) throws IOException {
@@ -190,7 +192,8 @@ public class ElasticSearchClient {
      * 更新文档内容
      *
      * @param indexName 索引名称
-     * @param id
+     * @param id id
+     * @param paramMap paramMap
      */
     public void updateDocument(String indexName, String id, Map<String, Object> paramMap) {
 
@@ -222,10 +225,9 @@ public class ElasticSearchClient {
      * 删除文档数据
      *
      * @param indexName 索引名称
-     * @param id
-     * @throws Exception
+     * @param id id
      */
-    public void deleteDocument(String indexName, String id) throws Exception {
+    public void deleteDocument(String indexName, String id) {
         DeleteRequest deleteRequest = new DeleteRequest(indexName, id);
         // 主分片执行删除的超时时长
         deleteRequest.timeout(TimeValue.timeValueMinutes(2));
@@ -448,7 +450,7 @@ public class ElasticSearchClient {
                     boolQueryBuilder.must(termQueryBuilder);
                 }
             } else if (value instanceof Collection) {
-                Collection<? extends Object> collectionValue = (Collection<? extends Object>) value;
+                Collection<?> collectionValue = (Collection<?>) value;
                 //此处使用了多值条件
                 boolQueryBuilder.must(QueryBuilders.termsQuery(key, collectionValue));
             } else {
@@ -579,7 +581,7 @@ public class ElasticSearchClient {
      * 索引创建前,判断索引是否存在
      */
     public static Boolean isIndexExist(String checkIndex) {
-        Boolean flag = false;
+        boolean flag = false;
         try {
             GetIndexRequest getIndexRequest = new GetIndexRequest(checkIndex);
             getIndexRequest.local(false);

+ 4 - 1
ruoyi-system/src/main/java/com/ruoyi/system/domain/XiuTanIllegalShip.java

@@ -26,9 +26,12 @@ public class XiuTanIllegalShip extends BaseEntity
 
     private String semId;
 
-    @Excel(name = "站点")
+    @Excel(name = "设备名")
     private String semName;
 
+    @Excel(name = "监测点")
+    private String monitorPointName;
+
     @Excel(name = "硫含量")
     private BigDecimal sPercent;
 

+ 12 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/GasCommonMapper.java

@@ -21,4 +21,16 @@ public interface GasCommonMapper {
 
     @DataSource(DataSourceType.SLAVE_AIS)
     List<Map<String, Object>> queryIllegalShip(@Param("syncPost") SyncPost syncPost);
+
+    @DataSource(DataSourceType.SLAVE_BLACK)
+    List<Map<String, Object>> queryShipRecognition(@Param("syncPost") SyncPost syncPost);
+
+    @DataSource(DataSourceType.SLAVE_SO2)
+    List<Map<String, Object>> queryAlert(@Param("syncPost") SyncPost syncPost);
+
+    @DataSource(DataSourceType.SLAVE_SO2)
+    List<Map<String, Object>> queryMonitorPoint(@Param("syncPost") SyncPost syncPost);
+
+    @DataSource(DataSourceType.SLAVE_SO2)
+    List<Map<String, Object>> queryShipStaticInfo(@Param("syncPost") SyncPost syncPost);
 }

+ 127 - 12
ruoyi-system/src/main/resources/mapper/system/GasCommonMapper.xml

@@ -23,28 +23,143 @@
                pMode,
                nFlag,
                sensitiveType,
-               autoType
+               autoType,
+               category
         from ${table}
     </select>
 
     <select id="queryIllegalShip" resultType="java.util.Map">
         select t1.id,
-               sem_id        semId,
-               t2.Name       semName,
-               s_percent     sPercent,
-               n_percent     nPercent,
-               peak_time     peakTime,
-               start_time    startTime,
-               end_time      endTime,
-               ship_mmsi     shipMmsi,
-               ship_name     shipName,
+               sem_id                                          semId,
+               t2.Name                                         semName,
+               t2.Category                                     monitorPointName,
+               s_percent                                       sPercent,
+               n_percent                                       nPercent,
+               date_format(peak_time, '%Y-%m-%d %H:%i:%S')  as peakTime,
+               date_format(start_time, '%Y-%m-%d %H:%i:%S') as startTime,
+               date_format(end_time, '%Y-%m-%d %H:%i:%S')   as endTime,
+               ship_mmsi                                       shipMmsi,
+               ship_name                                       shipName,
                error,
                distance,
-               t1.wind_speed windSpeed,
-               wind_angle    windAngle,
+               t1.wind_speed                                as windSpeed,
+               wind_angle                                      windAngle,
                confirmed
         from illegal_ship t1
                  left join sem_instrument_test t2 on t1.sem_id = t2.id
     </select>
 
+    <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
+        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}
+            </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
+        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
+        <where>
+            <if test="syncPost.startTime != null and syncPost.startTime != ''">
+                create_time &gt;= #{syncPost.startTime}
+            </if>
+            <if test="syncPost.endTime != null and syncPost.endTime != ''">
+                create_time &lt;= #{syncPost.endTime}
+            </if>
+        </where>
+    </select>
+
+    <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,
+               longitude,
+               latitude,
+               remark
+        from monitor_point
+    </select>
+
+    <select id="queryShipStaticInfo" resultType="java.util.Map">
+        select id,
+               MMSI,
+               name,
+               type,
+            size,
+            destination,
+            ETA,
+            IMO
+        from ship_static_info
+    </select>
+
 </mapper>