|
@@ -1,26 +1,46 @@
|
|
|
package com.ruoyi.web.controller.gas;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.bean.copier.CopyOptions;
|
|
|
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;
|
|
|
+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;
|
|
|
import com.ruoyi.system.domain.DeviceBo;
|
|
|
import com.ruoyi.system.domain.IllegalInfo;
|
|
|
+import com.ruoyi.system.domain.IllegalShipData;
|
|
|
import com.ruoyi.system.domain.MonitorInfo;
|
|
|
import com.ruoyi.system.domain.SyncPost;
|
|
|
+import com.ruoyi.system.domain.vo.AisShipInfo;
|
|
|
+import com.ruoyi.system.domain.vo.ShipEepReportRecInfo;
|
|
|
import com.ruoyi.system.service.IAisDatabase;
|
|
|
+import com.ruoyi.system.service.IAisInfoService;
|
|
|
import com.ruoyi.system.service.IAisShipService;
|
|
|
import com.ruoyi.system.service.IHeiYanService;
|
|
|
+import com.ruoyi.system.service.IIllegalShipDataService;
|
|
|
import com.ruoyi.system.service.ISo2Service;
|
|
|
+import com.ruoyi.system.service.ISysConfigService;
|
|
|
+import com.ruoyi.web.controller.tool.SMSUtil;
|
|
|
import com.ruoyi.web.service.IGasCommonService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.SneakyThrows;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
@@ -60,6 +80,18 @@ public class GasCommonController {
|
|
|
private IHeiYanService heiYanService;
|
|
|
@Autowired
|
|
|
private IAisShipService aisShipService;
|
|
|
+ @Value("${spring.profiles.active}")
|
|
|
+ private String env;
|
|
|
+ @Autowired
|
|
|
+ private IAisInfoService aisInfoService;
|
|
|
+ @Autowired
|
|
|
+ private IIllegalShipDataService illegalShipDataService;
|
|
|
+ @Autowired
|
|
|
+ private ISysConfigService configService;
|
|
|
+ @Value("${black.snapImgUrl}")
|
|
|
+ private String blackImgUrl;
|
|
|
+ @Autowired
|
|
|
+ private RedisCache redisCache;
|
|
|
|
|
|
@PreAuthorize("@ss.hasPermi('system:gas:sync')")
|
|
|
@PostMapping("/sync")
|
|
@@ -115,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<>();
|
|
@@ -182,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) {
|
|
@@ -272,10 +328,16 @@ 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数据")
|
|
|
- public Object queryData(@RequestParam(required = false) String id, @RequestParam(required = false) Integer size, @RequestParam String... index) {
|
|
|
+ public Object queryData(@RequestParam(required = false) String id, @RequestParam(required = false) Integer size, @RequestParam(required = false) String orderKey, @RequestParam String... index) {
|
|
|
if (size == null) {
|
|
|
size = 200;
|
|
|
}
|
|
@@ -284,7 +346,9 @@ public class GasCommonController {
|
|
|
equalsCondition.put("id", id);
|
|
|
}
|
|
|
List<String> orderBy = new ArrayList<>();
|
|
|
- orderBy.add("-createTime");
|
|
|
+ if (StrUtil.isNotBlank(orderKey)) {
|
|
|
+ orderBy.add("-" + orderKey);
|
|
|
+ }
|
|
|
Map<String, Object> map = client.searchDocument(equalsCondition,
|
|
|
null,
|
|
|
orderBy,
|
|
@@ -294,4 +358,201 @@ public class GasCommonController {
|
|
|
return map.get("pageList");
|
|
|
}
|
|
|
|
|
|
+ @DeleteMapping("/deleteIndexOneData")
|
|
|
+ @ApiOperation("删除ES中某个数据")
|
|
|
+ public void deleteIndexData(@RequestParam String index, @RequestParam String id) {
|
|
|
+ client.deleteDocument(index, id);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/sendSms")
|
|
|
+ @ApiOperation("发送短信")
|
|
|
+ public AjaxResult sendSms(@RequestBody JSONObject jsonObject) {
|
|
|
+ String content = jsonObject.getString("content");
|
|
|
+ String phone = jsonObject.getString("phone");
|
|
|
+ if (StrUtil.hasBlank(content, phone)) {
|
|
|
+ return AjaxResult.error("存在参数为空");
|
|
|
+ }
|
|
|
+ SMSUtil smsUtil = new SMSUtil();
|
|
|
+ smsUtil.sendMessage(content, phone);
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @SneakyThrows
|
|
|
+ @PostMapping("/reSyncOneData")
|
|
|
+ @ApiOperation("重新同步某一个数据")
|
|
|
+ public void reSyncOneData(@RequestParam String index, @RequestParam String id) {
|
|
|
+ client.deleteDocument(index, id);
|
|
|
+ String so2ThresholdVal = configService.selectConfigByKey("so2.so2");
|
|
|
+ String blackThresholdVal = configService.selectConfigByKey("black.rcgSoot");
|
|
|
+ if (ElasticConstants.AIS_ILLEGAL_SHIP.equals(index)) {
|
|
|
+ Map<String, Object> afterDataMap = aisDatabase.queryById(id);
|
|
|
+ // 嗅探系统-违规船舶
|
|
|
+ if ("prod".equals(env)) {
|
|
|
+ // 查询检测点和船舶信息、船舶进出港记录
|
|
|
+ if (ObjectUtil.isNotEmpty(afterDataMap.get("shipMmsi"))) {
|
|
|
+ AisShipInfo shipInfo = aisInfoService.getShipInfo("", Convert.toStr(afterDataMap.get("shipMmsi")), "", "");
|
|
|
+ if (shipInfo != null) {
|
|
|
+ afterDataMap.put("shipName", shipInfo.getShipName());
|
|
|
+ afterDataMap.put("shipRegionType", shipInfo.getShipRegionType());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(afterDataMap.get("sPercent")) && NumberUtil.isGreaterOrEqual(Convert.toBigDecimal(afterDataMap.get("sPercent")), Convert.toBigDecimal(so2ThresholdVal))) {
|
|
|
+ // 查询检测点和船舶信息、船舶进出港记录
|
|
|
+ if (ObjectUtil.isNotEmpty(afterDataMap.get("mmsi"))) {
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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)) {
|
|
|
+ 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("category")));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 嫌疑船舶
|
|
|
+ afterDataMap.put("illegalStatus", 2);
|
|
|
+ afterDataMap.put("uploadFlag", 0);
|
|
|
+ // TODO 上报行政检查系统
|
|
|
+
|
|
|
+ } else {
|
|
|
+ afterDataMap.put("uploadFlag", 0);
|
|
|
+ afterDataMap.put("illegalStatus", 1);
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(afterDataMap.get("mmsi"))) {
|
|
|
+ aisInfoService.getDynamicShipInfo(Convert.toStr(afterDataMap.get("mmsi")));
|
|
|
+ }
|
|
|
+ afterDataMap.put("illegalType", "xiutan");
|
|
|
+ // 保存数据
|
|
|
+ saveIllegalData(afterDataMap, ElasticConstants.AIS_ILLEGAL_SHIP);
|
|
|
+ client.createDocument(ElasticConstants.AIS_ILLEGAL_SHIP, Convert.toStr(afterDataMap.get("id")), afterDataMap);
|
|
|
+
|
|
|
+ } else if (ElasticConstants.SO2_ALERT.equals(index)) {
|
|
|
+ Map<String, Object> afterDataMap = so2Service.queryById(id);
|
|
|
+
|
|
|
+ // 船舶记录
|
|
|
+ if ("prod".equals(env)) {
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 判断是否大于阈值
|
|
|
+ if (ObjectUtil.isNotEmpty(afterDataMap.get("so2Percent")) && NumberUtil.isGreaterOrEqual(Convert.toBigDecimal(afterDataMap.get("so2Percent")), Convert.toBigDecimal(so2ThresholdVal))) {
|
|
|
+ // 查询检测点和船舶信息、船舶进出港记录
|
|
|
+ if (ObjectUtil.isNotEmpty(afterDataMap.get("mmsi"))) {
|
|
|
+ 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", 0);
|
|
|
+ // TODO 上报行政检查系统
|
|
|
+
|
|
|
+ } else {
|
|
|
+ afterDataMap.put("uploadFlag", 0);
|
|
|
+ afterDataMap.put("illegalStatus", 1);
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(afterDataMap.get("mmsi"))) {
|
|
|
+ aisInfoService.getDynamicShipInfo(Convert.toStr(afterDataMap.get("mmsi")));
|
|
|
+ }
|
|
|
+ afterDataMap.put("illegalType", "guangpu");
|
|
|
+ // 保存数据
|
|
|
+ saveIllegalData(afterDataMap, ElasticConstants.SO2_ALERT);
|
|
|
+ client.createDocument(ElasticConstants.SO2_ALERT, Convert.toStr(afterDataMap.get("id")), afterDataMap);
|
|
|
+
|
|
|
+ } else if (ElasticConstants.HEIYAN_SHIP_RECOGNITION.equals(index)) {
|
|
|
+ Map<String, Object> afterDataMap = heiYanService.queryById(id);
|
|
|
+
|
|
|
+ if (ObjectUtil.isEmpty(afterDataMap.get("aisMmsi")) /*|| Convert.toStr(afterDataMap.get("aisMmsi")).length() != 9*/) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 判断数据状态
|
|
|
+ if (ObjectUtil.isNotEmpty(afterDataMap.get("rcgSoot")) && NumberUtil.isGreaterOrEqual(Convert.toBigDecimal(afterDataMap.get("rcgSoot")),
|
|
|
+ Convert.toBigDecimal(blackThresholdVal))) {
|
|
|
+ // 查询黑烟图片
|
|
|
+ if ("prod".equals(env)) {
|
|
|
+ String imgUrl = HttpUtil.get(blackImgUrl + Convert.toStr(afterDataMap.get("id")));
|
|
|
+ JSONObject response = JSON.parseObject(imgUrl);
|
|
|
+ if (200 == response.getInteger("code")) {
|
|
|
+ List<String> newImgList = new ArrayList<>();
|
|
|
+ JSONArray imgUrlList = response.getJSONObject("data").getJSONArray("imgUrlList");
|
|
|
+ String sootImgUrl = response.getJSONObject("data").getString("sootImgUrl");
|
|
|
+ for (Object o : imgUrlList) {
|
|
|
+ // 只保存细节、全貌开头的图片
|
|
|
+ String s = Convert.toStr(o);
|
|
|
+ if (StrUtil.containsAny(s, "全貌", "细节")) {
|
|
|
+ newImgList.add("http://" + s);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ afterDataMap.put("sootImgUrl", StrUtil.isNotBlank(sootImgUrl) ? "http://" + sootImgUrl : "");
|
|
|
+ afterDataMap.put("allImgUrl", newImgList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 超过阈值后直接判定为违规船舶
|
|
|
+ afterDataMap.put("illegalStatus", 3);
|
|
|
+ afterDataMap.put("uploadFlag", 0);
|
|
|
+ // TODO 上报行政检查系统
|
|
|
+
|
|
|
+ } else {
|
|
|
+ afterDataMap.put("uploadFlag", 0);
|
|
|
+ afterDataMap.put("illegalStatus", 1);
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(afterDataMap.get("aisMmsi")) && Convert.toStr(afterDataMap.get("aisMmsi")).length() == 9) {
|
|
|
+ aisInfoService.getDynamicShipInfo(Convert.toStr(afterDataMap.get("aisMmsi")));
|
|
|
+ }
|
|
|
+ afterDataMap.put("illegalType", "heiyan");
|
|
|
+ // 查询检测点和船舶信息
|
|
|
+ if (ObjectUtil.isNotEmpty(afterDataMap.get("aisMmsi")) && !"0".equals(Convert.toStr(afterDataMap.get("aisMmsi")))) {
|
|
|
+ AisShipInfo shipInfo = aisInfoService.getShipInfo("", Convert.toStr(afterDataMap.get("aisMmsi")), "", "");
|
|
|
+ if (shipInfo != null) {
|
|
|
+ afterDataMap.put("shipName", 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("deviceId", heiyanDeviceMap.get(Convert.toStr(afterDataMap.get("snapPos"))));
|
|
|
+ }
|
|
|
+ // 保存数据
|
|
|
+ saveIllegalData(afterDataMap, ElasticConstants.HEIYAN_SHIP_RECOGNITION);
|
|
|
+ client.createDocument(ElasticConstants.HEIYAN_SHIP_RECOGNITION, Convert.toStr(afterDataMap.get("id")), afterDataMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void saveIllegalData(Map<String, Object> afterDataMap, String indexName) {
|
|
|
+ if (Convert.toInt(afterDataMap.get("illegalStatus")) != 1) {
|
|
|
+ IllegalShipData illegalShipData = new IllegalShipData();
|
|
|
+ BeanUtil.fillBeanWithMap(afterDataMap, illegalShipData, CopyOptions.create().setIgnoreProperties("id"));
|
|
|
+ illegalShipData.setId(IdUtils.fastSimpleUUID());
|
|
|
+ illegalShipData.setSystemId(Convert.toStr(afterDataMap.get("id")));
|
|
|
+ illegalShipData.setSystemEsIndex(indexName);
|
|
|
+ try {
|
|
|
+ illegalShipDataService.insertIllegalShipData(illegalShipData);
|
|
|
+ } catch (Exception ignored) {
|
|
|
+ ignored.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|