From ec56230a2904cab5660200ce1cdd956f660f7c45 Mon Sep 17 00:00:00 2001
From: zhangnaisong <2434969829@qq.com>
Date: 星期四, 20 七月 2023 17:15:12 +0800
Subject: [PATCH] 上传车辆图片提交
---
ard-work/src/main/java/com/ruoyi/alarm/globalAlarm/service/impl/GlobalAlarmServiceImpl.java | 389 ++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 314 insertions(+), 75 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/alarm/globalAlarm/service/impl/GlobalAlarmServiceImpl.java b/ard-work/src/main/java/com/ruoyi/alarm/globalAlarm/service/impl/GlobalAlarmServiceImpl.java
index 63a106c..0cb90b3 100644
--- a/ard-work/src/main/java/com/ruoyi/alarm/globalAlarm/service/impl/GlobalAlarmServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/alarm/globalAlarm/service/impl/GlobalAlarmServiceImpl.java
@@ -1,8 +1,12 @@
package com.ruoyi.alarm.globalAlarm.service.impl;
import com.alibaba.fastjson2.JSONObject;
+import com.ruoyi.alarm.accessAlarm.domain.ArdAlarmAccess;
+import com.ruoyi.alarm.accessAlarm.mapper.ArdAlarmAccessMapper;
import com.ruoyi.alarm.cameraAlarm.domain.ArdAlarmCamera;
import com.ruoyi.alarm.cameraAlarm.mapper.ArdAlarmCameraMapper;
+import com.ruoyi.alarm.externalAlarm.domain.ArdAlarmExternal;
+import com.ruoyi.alarm.externalAlarm.mapper.ArdAlarmExternalMapper;
import com.ruoyi.alarm.globalAlarm.domain.GlobalAlarmCondition;
import com.ruoyi.alarm.globalAlarm.domain.GlobalAlarmData;
import com.ruoyi.alarm.globalAlarm.domain.GuidePriorityQueue;
@@ -21,21 +25,23 @@
import com.ruoyi.alarmpoints.tube.mapper.ArdTubesMapper;
import com.ruoyi.alarmpoints.well.domain.ArdAlarmpointsWell;
import com.ruoyi.alarmpoints.well.mapper.ArdAlarmpointsWellMapper;
+import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.constant.CamPriority;
+import com.ruoyi.device.external.domain.ArdEquipExternal;
+import com.ruoyi.device.external.mapper.ArdEquipExternalMapper;
import com.ruoyi.utils.tools.ArdTool;
import com.ruoyi.utils.tools.GisTool;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.device.camera.domain.ArdCameras;
-import com.ruoyi.device.camera.domain.CameraCmd;
import com.ruoyi.device.camera.mapper.ArdCamerasMapper;
-import com.ruoyi.device.hiksdk.common.GlobalVariable;
-import com.ruoyi.device.hiksdk.service.IHikClientService;
import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.utils.tube.GeoPoint;
import com.ruoyi.utils.tube.TubeTools;
+import lombok.AllArgsConstructor;
+import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
@@ -45,7 +51,6 @@
import java.util.*;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.stream.Collectors;
-
/**
* @Description: 鍏ㄥ眬鎶ヨ涓氬姟
@@ -58,6 +63,12 @@
@Slf4j(topic = "mqtt")
public class GlobalAlarmServiceImpl implements IGlobalAlarmService {
//region 渚濊禆娉ㄥ叆
+ @Resource
+ private ArdEquipExternalMapper ardEquipExternalMapper;
+ @Resource
+ private ArdAlarmAccessMapper ardAlarmAccessMapper;
+ @Resource
+ private ArdAlarmExternalMapper ardAlarmExternalMapper;
@Resource
private ArdAlarmRadarMapper ardAlarmRadarMapper;
@Resource
@@ -76,8 +87,6 @@
private ISysConfigService configService;
@Resource
private ArdCamerasMapper ardCamerasMapper;
- @Resource
- private IHikClientService hikClientService;
@Resource
private RedisCache redisCache;
@Resource
@@ -105,6 +114,12 @@
countMap.put("1003", count1003);
int count1004 = ardAlarmRadarMapper.selectCountByAlarmTime(refreshTime, "鐑簮妫�娴�");
countMap.put("1004", count1004);
+ int count1007 = ardAlarmRadarMapper.selectCountByAlarmTime(refreshTime, "闆疯揪鎶芥补鏈哄仠鏈�");
+ countMap.put("1007", count1007);
+ int count1005 = ardAlarmExternalMapper.selectCountByAlarmTime(refreshTime, "闃插尯鎶ヨ");
+ countMap.put("1005", count1005);
+ int count1006 = ardAlarmAccessMapper.selectCountByAlarmTime(refreshTime);
+ countMap.put("1006", count1006);
int count1014 = ardAlarmTubeMapper.selectCountByAlarmTime(refreshTime);
countMap.put("1014", count1014);
map.put("20000", countMap);
@@ -137,8 +152,7 @@
.setCount(ardAlarmStealelec.getCount())
.setTotal(ardAlarmStealelec.getTotal());
return globalAlarmData;
- })
- .collect(Collectors.toList());
+ }).collect(Collectors.toList());
case 1002:
List<ArdAlarmCamera> ardAlarmCameras = ardAlarmCameraMapper.selectListAllByCommand(refreshTime);
return ardAlarmCameras.stream()
@@ -152,8 +166,7 @@
.setCount(ardAlarmCamera.getCount())
.setTotal(ardAlarmCamera.getTotal());
return globalAlarmData;
- })
- .collect(Collectors.toList());
+ }).collect(Collectors.toList());
case 1003:
List<ArdAlarmRadar> ardAlarmRadars = ardAlarmRadarMapper.selectListAllByCommand(refreshTime, "杩愬姩鐩爣妫�娴�");
return ardAlarmRadars.stream()
@@ -167,8 +180,7 @@
.setCount(ardAlarmRadar.getCount())
.setTotal(ardAlarmRadar.getTotal());
return globalAlarmData;
- })
- .collect(Collectors.toList());
+ }).collect(Collectors.toList());
case 1004:
ardAlarmRadars = ardAlarmRadarMapper.selectListAllByCommand(refreshTime, "鐑簮妫�娴�");
return ardAlarmRadars.stream()
@@ -182,8 +194,49 @@
.setCount(ardAlarmRadar.getCount())
.setTotal(ardAlarmRadar.getTotal());
return globalAlarmData;
- })
- .collect(Collectors.toList());
+ }).collect(Collectors.toList());
+ case 1005:
+ List<ArdAlarmExternal> ardAlarmExternals = ardAlarmExternalMapper.selectListAllByCommand(refreshTime, "闃插尯鎶ヨ");
+ return ardAlarmExternals.stream()
+ .map(ardAlarmExternal -> {
+ GlobalAlarmData globalAlarmData = new GlobalAlarmData()
+ .setId(ardAlarmExternal.getId())
+ .setName(ardAlarmExternal.getAlarmName())
+ .setAlarmTime(ardAlarmExternal.getAlarmTime())
+ .setLongitude(ardAlarmExternal.getLongitude())
+ .setLatitude(ardAlarmExternal.getLatitude())
+ .setCount(ardAlarmExternal.getCount())
+ .setTotal(ardAlarmExternal.getTotal());
+ return globalAlarmData;
+ }).collect(Collectors.toList());
+ case 1006:
+ List<ArdAlarmAccess> ardAlarmAccesses = ardAlarmAccessMapper.selectListAllByCommand(refreshTime);
+ return ardAlarmAccesses.stream()
+ .map(ardAlarmAccess -> {
+ GlobalAlarmData globalAlarmData = new GlobalAlarmData()
+ .setId(ardAlarmAccess.getId())
+ .setName(ardAlarmAccess.getAcsName())
+ .setAlarmTime(ardAlarmAccess.getAlarmTime())
+ .setLongitude(ardAlarmAccess.getLongitude())
+ .setLatitude(ardAlarmAccess.getLatitude())
+ .setCount(ardAlarmAccess.getCount())
+ .setTotal(ardAlarmAccess.getTotal());
+ return globalAlarmData;
+ }).collect(Collectors.toList());
+ case 1007:
+ ardAlarmRadars = ardAlarmRadarMapper.selectListAllByCommand(refreshTime, "闆疯揪鎶芥补鏈哄仠鏈�");
+ return ardAlarmRadars.stream()
+ .map(ardAlarmRadar -> {
+ GlobalAlarmData globalAlarmData = new GlobalAlarmData()
+ .setId(ardAlarmRadar.getId())
+ .setName(ardAlarmRadar.getName())
+ .setAlarmTime(ardAlarmRadar.getAlarmTime())
+ .setLongitude(ardAlarmRadar.getLongitude())
+ .setLatitude(ardAlarmRadar.getLatitude())
+ .setCount(ardAlarmRadar.getCount())
+ .setTotal(ardAlarmRadar.getTotal());
+ return globalAlarmData;
+ }).collect(Collectors.toList());
case 1014:
List<ArdAlarmTube> ardAlarmTubes = ardAlarmTubeMapper.selectListAllByCommand(refreshTime);
return ardAlarmTubes.stream()
@@ -198,8 +251,7 @@
.setCount(ardAlarmTube.getCount())
.setTotal(ardAlarmTube.getTotal());
return globalAlarmData;
- })
- .collect(Collectors.toList());
+ }).collect(Collectors.toList());
default:
return null;
}
@@ -224,38 +276,54 @@
aas.setParams(params);
aas.setPageNum(pageNum);
aas.setPageSize(pageSize);
- List<ArdAlarmStealelec> ardAlarmStealelecs = ardAlarmStealelecMapper.selectArdAlarmStealelecList(aas);
- return ardAlarmStealelecs;
+ return ardAlarmStealelecMapper.selectArdAlarmStealelecList(aas);
case 1002:
ArdAlarmCamera aac = new ArdAlarmCamera();
aac.setParams(params);
aac.setPageNum(pageNum);
aac.setPageSize(pageSize);
- List<ArdAlarmCamera> ardAlarmCameras = ardAlarmCameraMapper.selectArdAlarmCameraList(aac);
- return ardAlarmCameras;
+ return ardAlarmCameraMapper.selectArdAlarmCameraList(aac);
case 1003:
ArdAlarmRadar aar = new ArdAlarmRadar();
aar.setParams(params);
aar.setPageNum(pageNum);
aar.setPageSize(pageSize);
aar.setAlarmType("杩愬姩鐩爣妫�娴�");
- List<ArdAlarmRadar> ardAlarmRadar = ardAlarmRadarMapper.selectArdAlarmRadarList(aar);
- return ardAlarmRadar;
+ return ardAlarmRadarMapper.selectArdAlarmRadarList(aar);
case 1004:
ArdAlarmRadar aarr = new ArdAlarmRadar();
aarr.setParams(params);
aarr.setPageNum(pageNum);
aarr.setPageSize(pageSize);
aarr.setAlarmType("鐑簮妫�娴�");
- List<ArdAlarmRadar> ardAlarmRadarr = ardAlarmRadarMapper.selectArdAlarmRadarList(aarr);
- return ardAlarmRadarr;
+ return ardAlarmRadarMapper.selectArdAlarmRadarList(aarr);
+ case 1007:
+ ArdAlarmRadar aarrr = new ArdAlarmRadar();
+ aarrr.setParams(params);
+ aarrr.setPageNum(pageNum);
+ aarrr.setPageSize(pageSize);
+ aarrr.setAlarmType("闆疯揪鎶芥补鏈哄仠鏈�");
+ return ardAlarmRadarMapper.selectArdAlarmRadarList(aarrr);
+ case 1005:
+ ArdAlarmExternal aae = new ArdAlarmExternal();
+ aae.setParams(params);
+ aae.setPageNum(pageNum);
+ aae.setPageSize(pageSize);
+ aae.setAlarmType("闃插尯鎶ヨ");
+ return ardAlarmExternalMapper.selectArdAlarmExternalList(aae);
+ case 1006:
+ ArdAlarmAccess aaa = new ArdAlarmAccess();
+ aaa.setParams(params);
+ aaa.setPageNum(pageNum);
+ aaa.setPageSize(pageSize);
+ aaa.setAlarmType("闃插尯鎶ヨ");
+ return ardAlarmAccessMapper.selectArdAlarmAccessList(aaa);
case 1014:
ArdAlarmTube aat = new ArdAlarmTube();
aat.setParams(params);
aat.setPageNum(pageNum);
aat.setPageSize(pageSize);
- List<ArdAlarmTube> ardAlarmTubes = ardAlarmTubeMapper.selectArdAlarmTubeList(aat);
- return ardAlarmTubes;
+ return ardAlarmTubeMapper.selectArdAlarmTubeList(aat);
}
return null;
}
@@ -277,15 +345,51 @@
if (StringUtils.isNotNull(ardAlarmStealelec)) {
String describe = ardAlarmStealelec.getDescribe();
String startTime = fmt.format(ardAlarmStealelec.getStartTime());
- int i = ardAlarmStealelecMapper.updateViewTimeByDescribe(describe, startTime, DateUtils.getTime());
+ ardAlarmStealelecMapper.updateViewTimeByDescribe(describe, startTime, DateUtils.getTime());
return ardAlarmStealelec;
+ }
+ case 1002:
+ ArdAlarmCamera ardAlarmCamera = ardAlarmCameraMapper.selectArdAlarmCameraById(condition.getId());
+ if (StringUtils.isNotNull(ardAlarmCamera)) {
+ String cameraName = ardAlarmCamera.getCameraName();
+ String alarmTime = fmt.format(ardAlarmCamera.getAlarmTime());
+ ardAlarmCameraMapper.updateViewTimeByCameraName(cameraName, alarmTime, DateUtils.getTime());
+ return ardAlarmCamera;
+ }
+ case 1003:
+ case 1004:
+ case 1007:
+ ArdAlarmRadar ardAlarmRadar = ardAlarmRadarMapper.selectArdAlarmRadarById(condition.getId());
+ if (StringUtils.isNotNull(ardAlarmRadar)) {
+ String name = ardAlarmRadar.getName();
+ String alarmType = ardAlarmRadar.getAlarmType();
+ String alarmTime = fmt.format(ardAlarmRadar.getAlarmTime());
+ ardAlarmRadarMapper.updateViewTimeByCondition(name, alarmType, alarmTime, DateUtils.getTime());
+ return ardAlarmRadar;
+ }
+ case 1005:
+ ArdAlarmExternal ardAlarmExternal = ardAlarmExternalMapper.selectArdAlarmExternalById(condition.getId());
+ if (StringUtils.isNotNull(ardAlarmExternal)) {
+ String defenseName = ardAlarmExternal.getDefenseName();
+ String alarmType = ardAlarmExternal.getAlarmType();
+ String alarmTime = fmt.format(ardAlarmExternal.getAlarmTime());
+ ardAlarmExternalMapper.updateViewTimeByCondition(defenseName, alarmType, alarmTime, DateUtils.getTime());
+ return ardAlarmExternal;
+ }
+ case 1006:
+ ArdAlarmAccess ardAlarmAccess = ardAlarmAccessMapper.selectArdAlarmAccessById(condition.getId());
+ if (StringUtils.isNotNull(ardAlarmAccess)) {
+ String acsId = ardAlarmAccess.getAcsId();
+ String alarmTime = fmt.format(ardAlarmAccess.getAlarmTime());
+ ardAlarmAccessMapper.updateViewTimeByAcsId(acsId, alarmTime, DateUtils.getTime());
+ return ardAlarmAccess;
}
case 1014:
ArdAlarmTube ardAlarmTube = ardAlarmTubeMapper.selectArdAlarmTubeById(condition.getId());
if (StringUtils.isNotNull(ardAlarmTube)) {
String tubeId = ardAlarmTube.getTubeId();
String alarmTime = fmt.format(ardAlarmTube.getAlarmTime());
- int i = ardAlarmTubeMapper.updateViewTimeByTubeId(tubeId, alarmTime, DateUtils.getTime());
+ ardAlarmTubeMapper.updateViewTimeByTubeId(tubeId, alarmTime, DateUtils.getTime());
return ardAlarmTube;
}
default:
@@ -343,11 +447,18 @@
int aat = ardAlarmTubeMapper.insertArdAlarmTube(ardAlarmTube);
if (aat > 0) {
log.debug("tube鍏ュ簱鎴愬姛锛�" + ardAlarmTube);
- double[] coordinate=new double[]{ardAlarmTube.getLongitude(),ardAlarmTube.getLatitude()};
+ //region 寮曞褰曞儚
+ Double longitude = ardAlarmTube.getLongitude();
+ Double latitude = ardAlarmTube.getLatitude();
+ if (StringUtils.isNull(longitude) || StringUtils.isNull(latitude)) {
+ return;
+ }
+ double[] coordinate = new double[]{longitude, latitude};
String nearbyCameraId = getNearbyCamera(new double[]{ardAlarmTube.getLongitude(), ardAlarmTube.getLatitude()});
if (StringUtils.isNotEmpty(nearbyCameraId)) {
- messagesEnqueued(nearbyCameraId, ardAlarmTube.getId(), "sys_tube_leak",ardAlarmTube.getCreateTime(), 1,1,coordinate);
+ messagesEnqueued(nearbyCameraId, ardAlarmTube.getId(), "sys_tube_leak", ardAlarmTube.getCreateTime(), 1, 1, coordinate);
}
+ //endregion
}
//endregion
break;
@@ -355,7 +466,6 @@
//region 澶勭悊閫氱敤鍏夌數鎶ヨ
ArdAlarmCamera ardAlarmCamera = JSONObject.parseObject(message, ArdAlarmCamera.class);
ardAlarmCamera.setId(IdUtils.simpleUUID());
-
int aac = ardAlarmCameraMapper.insertArdAlarmCamera(ardAlarmCamera);
if (aac > 0) {
log.debug("camera鍏ュ簱鎴愬姛锛�" + ardAlarmCamera);
@@ -373,7 +483,7 @@
String alarmpointName = ardAlarmRadar.getName();//鍏磋叮鐐瑰悕绉�
ardAlarmRadar.setName(ardAlarmRadar.getName() + "(" + radarAlarmData.getRadarName() + ")");//鎶ヨ鐐瑰悕绉�
ardAlarmRadar.setCreateTime(new Date());//鎺ユ敹鏃堕棿
- double[] coordinate=new double[]{ardAlarmRadar.getLongitude(),ardAlarmRadar.getLatitude()};//鎶ヨ鍧愭爣
+
String alarmType = "";
switch (ardAlarmRadar.getAlarmType()) {
case "杩愬姩鐩爣妫�娴�":
@@ -382,7 +492,19 @@
case "鐑簮妫�娴�":
alarmType = "sys_radar_fire";
break;
+ case "闆疯揪鎶芥补鏈哄仠鏈�":
+ alarmType = "sys_radar_pumpshutdown";
+ ArdAlarmpointsWell ardAlarmpointsWell = ardAlarmpointsWellMapper.selectArdAlarmpointsWellByWellId(alarmpointName);
+ if (StringUtils.isNotNull(ardAlarmpointsWell)) {
+ ardAlarmRadar.setLongitude(ardAlarmpointsWell.getLongitude());
+ ardAlarmRadar.setLatitude(ardAlarmpointsWell.getLatitude());
+ }
+ break;
}
+ if (StringUtils.isNull(ardAlarmRadar.getLongitude()) || StringUtils.isNull(ardAlarmRadar.getLatitude())) {
+ continue;
+ }
+ double[] coordinate = new double[]{ardAlarmRadar.getLongitude(), ardAlarmRadar.getLatitude()};//鎶ヨ鍧愭爣
//鍒ゆ柇褰撳墠鎶ヨ鐐�5鍒嗛挓鍐呮槸鍚﹀凡寮曞
ardAlarmRadar.setGuideFlag(1);
ArdAlarmRadar AlarmRadar = ardAlarmRadarMapper.getArdAlarmRadarWithGuide(ardAlarmRadar);
@@ -392,19 +514,20 @@
//鑾峰彇闆疯揪鎵�鍦ㄥ涓婄殑澶у厜鐢�
String cameraIdWithTower = ardAlarmRadarMapper.getCameraByRadar(radarAlarmData.getRadarId());
if (StringUtils.isNotNull(cameraIdWithTower) && StringUtils.isNotEmpty(cameraIdWithTower)) {
- log.info("鑾峰彇鍒伴浄杈惧涓婄殑鍏夌數:"+cameraIdWithTower);
+ log.info("鑾峰彇鍒伴浄杈惧涓婄殑鍏夌數:" + cameraIdWithTower);
//濡傛灉闆疯揪濉斾笂鏈夊厜鐢�
- messagesEnqueued(cameraIdWithTower, uuid, alarmType, ardAlarmRadar.getCreateTime(),1,1,coordinate);
+ messagesEnqueued(cameraIdWithTower, uuid, alarmType, ardAlarmRadar.getCreateTime(), 1, 1, coordinate);
}
//鑾峰彇鎶ヨ鐐瑰叧鑱旂殑澶у厜鐢�
ArdAlarmpointsWell ardAlarmpointsWell = ardAlarmpointsWellMapper.selectArdAlarmpointsWellByWellId(alarmpointName);
- if(StringUtils.isNotNull(ardAlarmpointsWell) && StringUtils.isNotEmpty(ardAlarmpointsWell.getCameraId()))
- {
-
+ if (StringUtils.isNotNull(ardAlarmpointsWell) && StringUtils.isNotEmpty(ardAlarmpointsWell.getCameraId())) {
String cameraId = ardAlarmpointsWell.getCameraId();
- log.info("鑾峰彇鍒版姤璀︾偣鍏宠仈鐨勫厜鐢�:"+cameraId);
+ if (cameraIdWithTower.equals(cameraId)) {
+ return;
+ }
+ log.info("鑾峰彇鍒版姤璀︾偣鍏宠仈鐨勫厜鐢�:" + cameraId);
//濡傛灉鎶ヨ鐐瑰叧鑱斾簡鍏夌數
- messagesEnqueued(cameraId, uuid, alarmType,ardAlarmRadar.getCreateTime(), 1,2,coordinate);
+ messagesEnqueued(cameraId, uuid, alarmType, ardAlarmRadar.getCreateTime(), 1, 2, coordinate);
}
} else {
//5鍒嗛挓鍐呮湁寮曞
@@ -414,28 +537,88 @@
if (count >= 3) {
ardAlarmRadar.setGuideFlag(1);
ardAlarmRadarMapper.insertArdAlarmRadar(ardAlarmRadar);
-
//鑾峰彇闆疯揪鎵�鍦ㄥ涓婄殑澶у厜鐢�
String cameraIdWithTower = ardAlarmRadarMapper.getCameraByRadar(radarAlarmData.getRadarId());
if (StringUtils.isNotNull(cameraIdWithTower) && StringUtils.isNotEmpty(cameraIdWithTower)) {
- log.info("鑾峰彇鍒伴浄杈惧涓婄殑鍏夌數:"+cameraIdWithTower);
+ log.info("鑾峰彇鍒伴浄杈惧涓婄殑鍏夌數:" + cameraIdWithTower);
//濡傛灉闆疯揪濉斾笂鏈夊厜鐢�
- messagesEnqueued(cameraIdWithTower, uuid, alarmType,ardAlarmRadar.getCreateTime(), count,1,coordinate);
+ messagesEnqueued(cameraIdWithTower, uuid, alarmType, ardAlarmRadar.getCreateTime(), count, 1, coordinate);
}
//鑾峰彇鎶ヨ鐐瑰叧鑱旂殑澶у厜鐢�
ArdAlarmpointsWell ardAlarmpointsWell = ardAlarmpointsWellMapper.selectArdAlarmpointsWellByWellId(alarmpointName);
- if(StringUtils.isNotNull(ardAlarmpointsWell) && StringUtils.isNotEmpty(ardAlarmpointsWell.getCameraId()))
- {
+ if (StringUtils.isNotNull(ardAlarmpointsWell) && StringUtils.isNotEmpty(ardAlarmpointsWell.getCameraId())) {
String cameraId = ardAlarmpointsWell.getCameraId();
- log.info("鑾峰彇鍒版姤璀︾偣鍏宠仈鐨勫厜鐢�:"+cameraId);
+ if (cameraIdWithTower.equals(cameraId)) {
+ return;
+ }
+ log.info("鑾峰彇鍒版姤璀︾偣鍏宠仈鐨勫厜鐢�:" + cameraId);
//濡傛灉鎶ヨ鐐瑰叧鑱斾簡鍏夌數
- messagesEnqueued(cameraId, uuid, alarmType,ardAlarmRadar.getCreateTime(), count,2,coordinate);
+ messagesEnqueued(cameraId, uuid, alarmType, ardAlarmRadar.getCreateTime(), count, 2, coordinate);
}
} else {
//鏈紩瀵兼湭瓒呰繃3娆★紝鐩存帴鍏ュ簱
ardAlarmRadarMapper.insertArdAlarmRadar(ardAlarmRadar);
}
}
+ }
+ //endregion
+ break;
+ case "external":
+ //region 澶勭悊澶栬仈鎶ヨ
+ ArdAlarmExternal ardAlarmExternal = JSONObject.parseObject(message, ArdAlarmExternal.class);
+ ardAlarmExternal.setId(IdUtils.simpleUUID());
+ ardAlarmExternal.setCreateTime(new Date());//鎺ユ敹鏃堕棿
+ //澶栬仈闃插尯鍚嶇О灏辨槸鍏磋叮鐐癸紝鏌ュ叴瓒g偣鍧愭爣
+ String defenseName = ardAlarmExternal.getDefenseName();
+ ArdAlarmpointsWell ardAlarmpointsWell = ardAlarmpointsWellMapper.selectArdAlarmpointsWellByWellId(defenseName);
+ if (StringUtils.isNotNull(ardAlarmpointsWell)) {
+ ardAlarmExternal.setLongitude(ardAlarmpointsWell.getLongitude());
+ ardAlarmExternal.setLatitude(ardAlarmpointsWell.getLatitude());
+ }
+ int aae = ardAlarmExternalMapper.insertArdAlarmExternal(ardAlarmExternal);
+ if (aae > 0) {
+ log.debug("external鍏ュ簱鎴愬姛锛�" + ardAlarmExternal);
+ //region 寮曞褰曞儚
+ if (StringUtils.isNull(ardAlarmExternal.getLongitude()) || StringUtils.isNull(ardAlarmExternal.getLatitude())) {
+ return;
+ }
+ double[] guideCoordinate = new double[]{ardAlarmExternal.getLongitude(), ardAlarmExternal.getLatitude()};//寮曞鍧愭爣
+ String nearbyCameraId = getNearbyCamera(guideCoordinate);//鏈�杩戠浉鏈篒D
+ if (StringUtils.isNotEmpty(nearbyCameraId)) {
+ messagesEnqueued(nearbyCameraId, ardAlarmExternal.getId(), "sys_external", ardAlarmExternal.getCreateTime(), 1, 1, guideCoordinate);
+ }
+ //endregion
+ }
+ //endregion
+ break;
+ case "accessControl":
+ //region 澶勭悊闂ㄧ鎶ヨ
+ ArdAlarmAccess ardAlarmAccess = JSONObject.parseObject(message, ArdAlarmAccess.class);
+ ardAlarmAccess.setId(IdUtils.simpleUUID());
+ ardAlarmAccess.setCreateTime(new Date());//鎺ユ敹鏃堕棿
+ //鏌ョ鐞嗙殑闂ㄧ涓绘満淇℃伅
+ String acsId = ardAlarmAccess.getAcsId();
+ ArdEquipExternal ardEquipExternal = ardEquipExternalMapper.selectArdEquipExternalById(acsId);
+ if (StringUtils.isNotNull(ardEquipExternal)) {
+ ardAlarmAccess.setLongitude(ardEquipExternal.getLongitude());
+ ardAlarmAccess.setLatitude(ardEquipExternal.getLatitude());
+ ardAlarmAccess.setAltitude(ardEquipExternal.getAltitude());
+ ardAlarmAccess.setAcsId(ardEquipExternal.getId());
+ ardAlarmAccess.setAcsName(ardEquipExternal.getName());
+ }
+ int aaa = ardAlarmAccessMapper.insertArdAlarmAccess(ardAlarmAccess);
+ if (aaa > 0) {
+ log.debug("external鍏ュ簱鎴愬姛锛�" + ardAlarmAccess);
+ //region 寮曞褰曞儚
+ if (StringUtils.isNull(ardAlarmAccess.getLongitude()) || StringUtils.isNull(ardAlarmAccess.getLatitude())) {
+ return;
+ }
+ double[] guideCoordinate = new double[]{ardAlarmAccess.getLongitude(), ardAlarmAccess.getLatitude()};//寮曞鍧愭爣
+ String nearbyCameraId = getNearbyCamera(guideCoordinate);//鏈�杩戠浉鏈篒D
+ if (StringUtils.isNotEmpty(nearbyCameraId)) {
+ messagesEnqueued(nearbyCameraId, ardAlarmAccess.getId(), "sys_access_control", ardAlarmAccess.getCreateTime(), 1, 1, guideCoordinate);
+ }
+ //endregion
}
//endregion
break;
@@ -447,7 +630,7 @@
/**
* 娑堟伅鍏ラ槦
- *
+ * <p>
* cameraId 鐩告満ID
* alarmId 鎶ヨID
* alarmType 鎶ヨ绫诲瀷
@@ -455,34 +638,57 @@
* recordSn 褰曞儚瀛樺偍浣嶇疆 1-recordUrl1 2-recordUrl2
* targetPosition 鎶ヨ鐐逛綅缃潗鏍�
*/
- private void messagesEnqueued(String cameraId, String alarmId, String alarmType,Date receiveTime, Integer num, Integer recordSn,double[] targetPosition) {
- SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
- GuideTask guideTask = new GuideTask();
- //鐩告満ID
- guideTask.setCameraId(cameraId);
- //鎶ヨ绫诲瀷
- guideTask.setAlarmType(alarmType);
- //閫氶亾(閫氳繃鏃ュ鏃堕棿鐮斿垽)
- String dayNightTime = redisCache.getCacheObject("sys_config:dayNightTime");
- Integer channel = ArdTool.getChannelBydayNightTime(dayNightTime);
- guideTask.setChanNum(channel);
- //鎶ヨID
- guideTask.setAlarmId(alarmId);
- //鎺ユ敹鏃堕棿
- guideTask.setReceiveTime(fmt.format(receiveTime));
- //鎶ヨ浼樺厛绾�(閫氳繃浼樺厛绾у瓧鍏�)
- Integer priority = CamPriority.priorityMap.get(alarmType);
- guideTask.setPriority(priority);
- //鎶ヨ娆℃暟
- guideTask.setNum(num);
- //褰曞儚瀛樺偍浣嶇疆
- guideTask.setRecordSn(recordSn);
- //鐩爣缁忕含搴�
- guideTask.setTargetPosition(targetPosition);
- //娑堟伅鍏ラ槦
- queueManager.addTaskToQueue(cameraId, guideTask);
- //鎵撳嵃闃熷垪
- GuidePriorityQueue.printPriorityQueue();
+ private void messagesEnqueued(String cameraId, String alarmId, String alarmType, Date receiveTime, Integer num, Integer recordSn, double[] targetPosition) {
+ try {
+ if (!IsEnableGuide(cameraId)) {
+ log.info("鐩告満:" + cameraId + "鏈紑鍚姤璀﹀紩瀵煎姛鑳�");
+ return;
+ }
+
+ SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
+ GuideTask guideTask = new GuideTask();
+ //鐩告満ID
+ guideTask.setCameraId(cameraId);
+ //鎶ヨ绫诲瀷
+ guideTask.setAlarmType(alarmType);
+ //閫氶亾(閫氳繃鏃ュ鏃堕棿鐮斿垽)
+ String dayNightTime = redisCache.getCacheObject("sys_config:dayNightTime");
+ Integer channel = ArdTool.getChannelBydayNightTime(dayNightTime);
+ guideTask.setChanNum(channel);
+ //鎶ヨID
+ guideTask.setAlarmId(alarmId);
+ //鎺ユ敹鏃堕棿
+ guideTask.setReceiveTime(fmt.format(receiveTime));
+ //鎶ヨ浼樺厛绾�(閫氳繃浼樺厛绾у瓧鍏�)
+ Integer priority = CamPriority.priorityMap.get(alarmType);
+ guideTask.setPriority(priority);
+ //鎶ヨ娆℃暟
+ guideTask.setNum(num);
+ //褰曞儚瀛樺偍浣嶇疆
+ guideTask.setRecordSn(recordSn);
+ //鐩爣缁忕含搴�
+ guideTask.setTargetPosition(targetPosition);
+ //娑堟伅鍏ラ槦
+ queueManager.addTaskToQueue(cameraId, guideTask);
+ //鎵撳嵃闃熷垪
+ GuidePriorityQueue.printPriorityQueue();
+ } catch (Exception ex) {
+ log.error("鎶ヨ鍏ラ槦寮傚父:" + ex.getMessage());
+ }
+ }
+
+ /**
+ * 鍏夌數鏄惁寮�鍚姤璀﹀紩瀵煎姛鑳�
+ * 鍒樿嫃涔�
+ * 2023/7/7 14:03
+ */
+ private Boolean IsEnableGuide(String cameraId) {
+ boolean enabled = false;
+ ArdCameras ardCameras = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCameras.getCamAlarmGuideEnable().equals(1)) {
+ enabled = true;
+ }
+ return enabled;
}
/**
@@ -519,4 +725,37 @@
return minDistanceCameraId;
}
+ public static void main(String[] args) {
+ Comparator<Obj> PriorityDescCom = Comparator.comparingInt(Obj::getPriority).reversed();
+ Comparator<Obj> NumDescCom = Comparator.comparingInt(Obj::getNum).reversed();
+ Comparator<Obj> receiveTimeAscCom = Comparator.comparing(Obj::getAlarmTime);
+ Comparator<Obj> comparator = PriorityDescCom.thenComparing(NumDescCom).thenComparing(receiveTimeAscCom);
+
+ PriorityBlockingQueue<Obj> priorityQueue = new PriorityBlockingQueue<>(1000, comparator);
+
+ priorityQueue.add(new Obj(999, 1, "2023-07-01 16:00:01"));
+ priorityQueue.add(new Obj(999, 2, "2023-07-01 16:00:01"));
+ priorityQueue.add(new Obj(999, 3, "2023-07-01 16:00:01"));
+
+ List<Obj> elements = new ArrayList<>(priorityQueue);
+ elements.sort(priorityQueue.comparator()); // 浣跨敤闃熷垪鐨勬瘮杈冨櫒杩涜鎺掑簭
+ for (Obj task : elements) {
+ log.info("姝e湪鎺掗槦銆恜riority銆�" + task.getPriority() + "銆恘um銆�" + task.getNum() + "銆恆larmTime銆�" + task.getAlarmTime());
+ }
+ log.info("===================================================================");
+ priorityQueue.add(new Obj(999, 5, "2023-07-01 16:00:01"));
+ PriorityBlockingQueue queue = new PriorityBlockingQueue<>(priorityQueue);
+ while (queue.size() > 0) {
+ Obj task = (Obj) queue.poll();
+ log.info("姝e湪鎺掗槦銆恜riority銆�" + task.getPriority() + "銆恘um銆�" + task.getNum() + "銆恆larmTime銆�" + task.getAlarmTime());
+ }
+ }
+
+ @Data
+ @AllArgsConstructor
+ static class Obj {
+ Integer priority;
+ Integer num;
+ String alarmTime;
+ }
}
--
Gitblit v1.9.3