|
@@ -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.date.DateUtil;
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
@@ -15,6 +16,9 @@ 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.domain.vo.AisShipInfo;
|
|
|
+import com.ruoyi.system.domain.vo.ShipEepReportRecInfo;
|
|
|
+import com.ruoyi.system.service.IAisInfoService;
|
|
|
import com.ruoyi.system.service.ISysConfigService;
|
|
|
import com.ruoyi.web.core.config.CanalConfig;
|
|
|
import lombok.SneakyThrows;
|
|
@@ -50,6 +54,8 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
|
|
|
private RedisCache redisCache;
|
|
|
@Autowired
|
|
|
private ISysConfigService configService;
|
|
|
+ @Autowired
|
|
|
+ private IAisInfoService aisInfoService;
|
|
|
// @Resource
|
|
|
// private CanalConnector canalConnector;
|
|
|
@Value("${black.snapImgUrl}")
|
|
@@ -58,6 +64,15 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
|
|
|
@Autowired
|
|
|
private CanalConfig canalConfig;
|
|
|
|
|
|
+ public final static Map<String, String> orgMap = new HashMap<String, String>() {{
|
|
|
+ put("南京三桥", "南京海事局");
|
|
|
+ put("南京四桥", "南京海事局");
|
|
|
+ put("润扬大桥", "扬州海事局");
|
|
|
+ put("泰州大桥", "泰州海事局");
|
|
|
+ put("江阴大桥", "江阴海事局");
|
|
|
+ put("苏通大桥", "常熟海事局");
|
|
|
+ }};
|
|
|
+
|
|
|
@Override
|
|
|
@Scheduled(fixedDelay = 100) //每隔100秒执行
|
|
|
public void run() {
|
|
@@ -157,7 +172,6 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
|
|
|
"alert",
|
|
|
"monitor_point",
|
|
|
"device",
|
|
|
- "ship_static_info",
|
|
|
"illegal_ship",
|
|
|
"sem_instrument",
|
|
|
"sem_instrument_test")) {
|
|
@@ -174,8 +188,7 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
|
|
|
if (StrUtil.equalsIgnoreCase(database, "heiyan") && StrUtil.equalsIgnoreCase(table, "ship_recognition")) {
|
|
|
// 判断数据状态
|
|
|
if (ObjectUtil.isNotEmpty(afterDataMap.get("rcgSoot")) && NumberUtil.isGreaterOrEqual(Convert.toBigDecimal(afterDataMap.get("rcgSoot")), Convert.toBigDecimal(blackThresholdVal))) {
|
|
|
- // 嫌疑船舶
|
|
|
- afterDataMap.put("illegalStatus", 2);
|
|
|
+
|
|
|
// 查询黑烟图片
|
|
|
/*String imgUrl = HttpUtil.get(blackImgUrl + Convert.toStr(afterDataMap.get("id")));
|
|
|
JSONObject response = JSON.parseObject(imgUrl);
|
|
@@ -191,9 +204,24 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
|
|
|
}
|
|
|
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", 2);
|
|
|
+ afterDataMap.put("uploadFlag", 1);
|
|
|
// TODO 上报行政检查系统
|
|
|
|
|
|
} else {
|
|
|
+ afterDataMap.put("uploadFlag", 0);
|
|
|
afterDataMap.put("illegalStatus", 1);
|
|
|
}
|
|
|
client.createDocument(ElasticConstants.HEIYAN_SHIP_RECOGNITION, Convert.toStr(afterDataMap.get("id")), afterDataMap);
|
|
@@ -211,36 +239,40 @@ 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")) {
|
|
|
- // 船舶信息
|
|
|
- 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");
|
|
|
- if (mmsi != null && ObjectUtil.equal(mmsi.get("code"), 200)) {
|
|
|
- Map<String, String> data = Convert.toMap(String.class, String.class, mmsi.get("data"));
|
|
|
- afterDataMap.put("shipName", data.get("name"));
|
|
|
- afterDataMap.put("destination", data.get("destination"));
|
|
|
- }
|
|
|
- }
|
|
|
- Map<String, Object> monitor = client.getDocById(ElasticConstants.SO2_MONITOR_POINT, Convert.toStr(afterDataMap.get("monitorPointId")), "name");
|
|
|
- if (monitor != null && ObjectUtil.equal(monitor.get("code"), 200)) {
|
|
|
- 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))) {
|
|
|
+ // 查询检测点和船舶信息、船舶进出港记录
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+ 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());
|
|
|
+ afterDataMap.put("berthName", eepReportRecInfo.getBerthName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Map<String, Object> monitor = client.getDocById(ElasticConstants.SO2_MONITOR_POINT, Convert.toStr(afterDataMap.get("monitorPointId")), "name");
|
|
|
+ if (monitor != null && ObjectUtil.equal(monitor.get("code"), 200)) {
|
|
|
+ Map<String, String> data = Convert.toMap(String.class, String.class, monitor.get("data"));
|
|
|
+ afterDataMap.put("monitorPointName", data.get("name"));
|
|
|
+ afterDataMap.put("orgName", orgMap.get(data.get("name")));
|
|
|
+ }
|
|
|
+
|
|
|
// 嫌疑船舶
|
|
|
afterDataMap.put("illegalStatus", 2);
|
|
|
+ afterDataMap.put("uploadFlag", 1);
|
|
|
// TODO 上报行政检查系统
|
|
|
|
|
|
} else {
|
|
|
+ afterDataMap.put("uploadFlag", 0);
|
|
|
afterDataMap.put("illegalStatus", 1);
|
|
|
}
|
|
|
+ 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"))) {
|
|
|
// 嗅探系统-站点信息
|
|
@@ -250,22 +282,46 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
|
|
|
CacheConstants.DEVICE_TYPE_STATIC));
|
|
|
} 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,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("mmsi", afterDataMap.get("shipMmsi"));
|
|
|
+ afterDataMap.put("createTime", afterDataMap.get("peakTime"));
|
|
|
+ if (ObjectUtil.isNotEmpty(afterDataMap.get("sPercent")) && NumberUtil.isGreaterOrEqual(Convert.toBigDecimal(afterDataMap.get("sPercent")), Convert.toBigDecimal(so2ThresholdVal))) {
|
|
|
+ // 查询检测点和船舶信息、船舶进出港记录
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+ 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());
|
|
|
+ afterDataMap.put("berthName", eepReportRecInfo.getBerthName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 查询站点信息
|
|
|
+ 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("orgName", orgMap.get(data.get("name")));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 嫌疑船舶
|
|
|
+ afterDataMap.put("illegalStatus", 2);
|
|
|
+ afterDataMap.put("uploadFlag", 1);
|
|
|
+ // TODO 上报行政检查系统
|
|
|
+
|
|
|
+ } else {
|
|
|
+ afterDataMap.put("uploadFlag", 0);
|
|
|
+ afterDataMap.put("illegalStatus", 1);
|
|
|
}
|
|
|
- // 初始化设为未上传状态
|
|
|
- afterDataMap.put("uploadFlag", 0);
|
|
|
+ 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_recognition")) {
|
|
|
- client.updateDocument(ElasticConstants.HEIYAN_SHIP_RECOGNITION, Convert.toStr(afterDataMap.get("id")), afterDataMap);
|
|
|
- } 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));
|
|
@@ -284,16 +340,6 @@ 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, "illegal_ship")) {
|
|
|
- // 嗅探系统-违规船舶
|
|
|
- // 查询站点信息
|
|
|
- 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);
|
|
|
}
|
|
|
break;
|
|
|
case DELETE:
|
|
@@ -310,9 +356,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.deleteDocument(ElasticConstants.SO2_SHIP_STATIC_INFO, Convert.toStr(afterDataMap.get("mmsi")));
|
|
|
} 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")));
|