Эх сурвалжийг харах

根据设计图调整接口
增加首页船舶信息的信息接口

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

+ 1 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/gas/BlackGasController.java

@@ -65,6 +65,7 @@ public class BlackGasController extends BaseController {
         equalsCondition.put("shipRegionType", shipRecognition.getShipRegionType());
         equalsCondition.put("rcgSoot", shipRecognition.getRcgSoot());
         equalsCondition.put("illegalStatus", shipRecognition.getIllegalStatus());
+        equalsCondition.put("orgName", shipRecognition.getOrgName());
         // 组装范围查询条件
         Map<String, Object> rangeCondition = new HashMap<>();
         if (ObjectUtil.isNotEmpty(params.get("beginTime"))) {

+ 23 - 3
ruoyi-admin/src/main/java/com/ruoyi/web/controller/gas/GasCommonController.java

@@ -1,12 +1,10 @@
 package com.ruoyi.web.controller.gas;
 
 import cn.hutool.core.convert.Convert;
-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.common.core.domain.BaseEntity;
 import com.ruoyi.framework.config.ElasticSearchClient;
+import com.ruoyi.system.domain.IllegalInfo;
 import com.ruoyi.system.domain.SyncPost;
 import com.ruoyi.web.service.IGasCommonService;
 import io.swagger.annotations.Api;
@@ -17,9 +15,12 @@ import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -67,4 +68,23 @@ public class GasCommonController {
         return AjaxResult.success(result);
     }
 
+    @GetMapping("/queryIllegalInfoList")
+    @ApiOperation("获取嫌疑或违规船舶信息")
+    public AjaxResult queryIllegalInfoList(@RequestParam String illegalStatus, @RequestParam(required = false, defaultValue = "20") Integer size) {
+        Map<String, Object> equalsCondition = new HashMap<>();
+        equalsCondition.put("illegalStatus", illegalStatus);
+        List<String> orderBy = new ArrayList<>();
+        orderBy.add("-createTime");
+        Map<String, Object> stringObjectMap = client.searchDocument(equalsCondition,
+                null,
+                orderBy,
+                1,
+                size,
+                ElasticConstants.AIS_ILLEGAL_SHIP,
+                ElasticConstants.SO2_ALERT,
+                ElasticConstants.HEIYAN_SHIP_RECOGNITION);
+
+        return AjaxResult.success(Convert.toList(IllegalInfo.class, stringObjectMap.get("pageList")));
+    }
+
 }

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

@@ -277,14 +277,26 @@ public class So2Controller extends BaseController {
 
     @GetMapping("/timeStatic")
     @ApiOperation("超标船舶统计-按时间")
-    public AjaxResult monthStatic(@RequestParam(required = false) String interval) {
+    public AjaxResult monthStatic(@RequestParam(required = false) String interval, @RequestParam(required = false) String startMonth, @RequestParam(required = false) String endMonth) {
         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, Object> so2RangeCondition = new HashMap<>();
+        Map<String, Object> heiyanRangeCondition = new HashMap<>();
+        if (!StrUtil.isAllBlank(startMonth, endMonth)) {
+            if (StrUtil.isNotBlank(startMonth)) {
+                startMonth = startMonth + "-01 00:00:00";
+            }
+            if (StrUtil.isNotBlank(endMonth)) {
+                endMonth = DateUtil.formatDate(DateUtil.endOfMonth(DateUtil.parseDate(endMonth + "-01 00:00:00"))) + " 23:59:59";
+            }
+            so2RangeCondition.put("createTime", StrUtil.concat(true, "[", startMonth, ",", endMonth, "]"));
+            heiyanRangeCondition.put("snapTimeFmt", StrUtil.concat(true, "[", startMonth, ",", endMonth, "]"));
+        }
+        Map<Object, Object> aisAggs = client.dateHistogramAggs(ElasticConstants.AIS_ILLEGAL_SHIP, AggsType.count, "peakTime", "id", null, so2RangeCondition, new DateHistogramInterval(interval));
+        Map<Object, Object> so2Aggs = client.dateHistogramAggs(ElasticConstants.SO2_ALERT, AggsType.count, "createTime", "id", null, so2RangeCondition, new DateHistogramInterval(interval));
+        Map<Object, Object> heiyanAggs = client.dateHistogramAggs(ElasticConstants.HEIYAN_SHIP_RECOGNITION, AggsType.count, "snapTimeFmt", "id", null, heiyanRangeCondition, new DateHistogramInterval(interval));
         Map<String, Map<Object, Object>> result = new HashMap<>();
         result.put("ais", aisAggs);
         result.put("so2", so2Aggs);

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

@@ -173,8 +173,7 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                 "monitor_point",
                 "device",
                 "illegal_ship",
-                "sem_instrument",
-                "sem_instrument_test")) {
+                "sem_instrument")) {
             return;
         }
 
@@ -215,8 +214,8 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                         if (ObjectUtil.isNotEmpty(afterDataMap.get("snapPos"))) {
                             afterDataMap.put("orgName", orgMap.get(Convert.toStr(afterDataMap.get("snapPos"))));
                         }
-                        // 嫌疑船舶
-                        afterDataMap.put("illegalStatus", 2);
+                        // 超过阈值后直接判定为违规船舶
+                        afterDataMap.put("illegalStatus", 3);
                         afterDataMap.put("uploadFlag", 1);
                         // TODO 上报行政检查系统
 
@@ -274,7 +273,7 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                     }
                     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_test") || StrUtil.equalsIgnoreCase(table, "sem_instrument"))) {
+                } else if (StrUtil.equalsIgnoreCase(database, "ais_database") && (StrUtil.equalsIgnoreCase(table, "sem_instrument"))) {
                     // 嗅探系统-站点信息
                     client.createDocument(ElasticConstants.AIS_SEM_INSTRUMENT, Convert.toStr(afterDataMap.get("id")), afterDataMap);
                     redisCache.deleteObject(CollUtil.set(false,
@@ -284,6 +283,7 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                     // 嗅探系统-违规船舶
                     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"))) {
@@ -334,7 +334,7 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                     redisCache.deleteObject(CollUtil.set(false,
                             CacheConstants.DEVICE_STATIC,
                             CacheConstants.DEVICE_TYPE_STATIC));
-                } else if (StrUtil.equalsIgnoreCase(database, "ais_database") && (StrUtil.equalsIgnoreCase(table, "sem_instrument_test") || StrUtil.equalsIgnoreCase(table, "sem_instrument"))) {
+                } else if (StrUtil.equalsIgnoreCase(database, "ais_database") && (StrUtil.equalsIgnoreCase(table, "sem_instrument"))) {
                     // 嗅探系统-站点信息
                     client.updateDocument(ElasticConstants.AIS_SEM_INSTRUMENT, Convert.toStr(afterDataMap.get("id")), afterDataMap);
                     redisCache.deleteObject(CollUtil.set(false,
@@ -356,7 +356,7 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                     redisCache.deleteObject(CollUtil.set(false,
                             CacheConstants.DEVICE_STATIC,
                             CacheConstants.DEVICE_TYPE_STATIC));
-                } else if (StrUtil.equalsIgnoreCase(database, "ais_database") && (StrUtil.equalsIgnoreCase(table, "sem_instrument_test") || StrUtil.equalsIgnoreCase(table, "sem_instrument"))) {
+                } else if (StrUtil.equalsIgnoreCase(database, "ais_database") && (StrUtil.equalsIgnoreCase(table, "sem_instrument"))) {
                     // 嗅探系统-站点信息
                     client.deleteDocument(ElasticConstants.AIS_SEM_INSTRUMENT, Convert.toStr(afterDataMap.get("id")));
                     redisCache.deleteObject(CollUtil.set(false,

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

@@ -53,7 +53,7 @@ public class GasCommonServiceImpl implements IGasCommonService {
         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"))) {
+        if (StrUtil.equalsIgnoreCase(schema, "ais_database") && (StrUtil.equalsIgnoreCase(table, "sem_instrument"))) {
             // 嗅探站点信息
             List<Map<String, Object>> map = gasCommonMapper.querySemInstrument(table);
             for (Map<String, Object> stringObjectMap : map) {
@@ -69,6 +69,7 @@ public class GasCommonServiceImpl implements IGasCommonService {
                 stringObjectMap.put("illegalType", "xiutan");
                 stringObjectMap.put("uploadFlag", 0);
                 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")) {
@@ -77,6 +78,7 @@ public class GasCommonServiceImpl implements IGasCommonService {
             for (Map<String, Object> stringObjectMap : map) {
                 stringObjectMap.put("illegalStatus", 1);
                 stringObjectMap.put("uploadFlag", 0);
+                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")) {

+ 39 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/IllegalInfo.java

@@ -0,0 +1,39 @@
+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 IllegalInfo {
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+
+    private String illegalType;
+
+    private String monitorPointName;
+
+    private String mmsi;
+
+    private String shipName;
+
+    private BigDecimal sPercent;
+
+    private String snapTimeFmt;
+
+    private String snapPos;
+
+    private String aisMmsi;
+
+    private String aisShipName;
+
+    private Integer rcgSoot;
+}

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

@@ -43,6 +43,8 @@ public class IllegalShip extends BaseEntity {
     private String berthName;
 
     private BigDecimal sPercent;
+    
+    private BigDecimal so2Percent;
 
     private BigDecimal so2Concentration;
 

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

@@ -6,12 +6,14 @@
 
     <select id="queryDeviceStatic" resultType="java.util.Map">
         select Category point, count(1) count
-        from sem_instrument_test
+        from sem_instrument
+        where Category is not null
         group by Category;
     </select>
 
     <select id="queryDeviceCount" resultType="java.lang.Integer">
         select count(1)
-        from sem_instrument_test
+        from sem_instrument
+        where Category is not null
     </select>
 </mapper>

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

@@ -46,7 +46,7 @@
                wind_angle                                      windAngle,
                confirmed
         from illegal_ship t1
-                 left join sem_instrument_test t2 on t1.sem_id = t2.id
+                 left join sem_instrument t2 on t1.sem_id = t2.id
     </select>
 
     <select id="queryShipRecognition" resultType="java.util.Map">