From 42f01638154bc2566a901fd62ce4653cd93a0cb0 Mon Sep 17 00:00:00 2001
From: ‘liusuyi’ <1951119284@qq.com>
Date: 星期二, 18 七月 2023 15:19:16 +0800
Subject: [PATCH] APP位置接口增加speed和bearing字段
---
ard-work/src/main/java/com/ruoyi/alarm/globalAlarm/service/impl/GlobalAlarmServiceImpl.java | 487 +++++++++++++++++++++++++++++++++++++----------------
1 files changed, 338 insertions(+), 149 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 1a0e990..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;
@@ -46,10 +52,9 @@
import java.util.concurrent.PriorityBlockingQueue;
import java.util.stream.Collectors;
-
/**
+ * @Description: 鍏ㄥ眬鎶ヨ涓氬姟
* @ClassName: globalAlarmServiceImpl
- * @Description:
* @Author: Administrator
* @Date: 2023骞�03鏈�10鏃� 11:03
* @Version: 1.0
@@ -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:
@@ -332,6 +436,7 @@
ardAlarmTube.setColor(ardTubes.getColor());
ardAlarmTube.setPipeDiameter(ardTubes.getPipeDiameter());
ardAlarmTube.setTubeType(ardTubes.getType());
+ ardAlarmTube.setCreateTime(new Date());
GeoPoint geoPoint = TubeTools.CalculateCoordinates(ardTubesDetails, ardAlarmTube.getPosition());
if (StringUtils.isNotNull(geoPoint)) {
ardAlarmTube.setLongitude(geoPoint.getLongitude());
@@ -342,10 +447,18 @@
int aat = ardAlarmTubeMapper.insertArdAlarmTube(ardAlarmTube);
if (aat > 0) {
log.debug("tube鍏ュ簱鎴愬姛锛�" + ardAlarmTube);
- String nearbyCamera = getNearbyCamera(new double[]{ardAlarmTube.getLongitude(), ardAlarmTube.getLatitude()});
- if (StringUtils.isNotEmpty(nearbyCamera)) {
- messagesEnqueued(nearbyCamera, ardAlarmTube.getId(), "sys_tube_leak", ardAlarmTube.getAlarmTime(), 1);
+ //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);
+ }
+ //endregion
}
//endregion
break;
@@ -353,30 +466,9 @@
//region 澶勭悊閫氱敤鍏夌數鎶ヨ
ArdAlarmCamera ardAlarmCamera = JSONObject.parseObject(message, ArdAlarmCamera.class);
ardAlarmCamera.setId(IdUtils.simpleUUID());
-
int aac = ardAlarmCameraMapper.insertArdAlarmCamera(ardAlarmCamera);
if (aac > 0) {
log.debug("camera鍏ュ簱鎴愬姛锛�" + ardAlarmCamera);
- String nearbyCamera = getNearbyCamera(new double[]{ardAlarmCamera.getLongitude(), ardAlarmCamera.getLatitude()});
- if (StringUtils.isNotEmpty(nearbyCamera)) {
- messagesEnqueued(nearbyCamera, ardAlarmCamera.getId(), "sys_camera", ardAlarmCamera.getAlarmTime(), 1);
- }
- //寮曞褰曞儚
-// CameraCmd cmd = new CameraCmd();
-// cmd.setRecordBucketName("record");
-// cmd.setRecordObjectName("camera");
-// cmd.setOperator("sys_camera");
-// cmd.setExpired(30);
-// cmd.setTargetPosition(new double[]{ardAlarmCamera.getLongitude(), ardAlarmCamera.getLatitude()});
-// boolean res = guideCamera(cmd);
-// if (res) {
-// String url = alarmToRecord(cmd);
-// if (StringUtils.isNotEmpty(url)) {
-// //鏇存柊褰曞儚
-// ardAlarmCamera.setRecordUrl(url);
-// ardAlarmCameraMapper.updateArdAlarmCamera(ardAlarmCamera);
-// }
-// }
}
//endregion
break;
@@ -386,11 +478,12 @@
List<ArdAlarmRadar> ardAlarmRadars = radarAlarmData.getArdAlarmRadars();
for (ArdAlarmRadar ardAlarmRadar : ardAlarmRadars) {
String uuid = IdUtils.simpleUUID();
- ardAlarmRadar.setId(uuid);
- ardAlarmRadar.setAlarmTime(radarAlarmData.getAlarmTime());
- String name = ardAlarmRadar.getName() + "(" + radarAlarmData.getRadarName() + ")";
- ardAlarmRadar.setName(name);
- ardAlarmRadar.setCreateTime(new Date());
+ ardAlarmRadar.setId(uuid);//鎶ヨID
+ ardAlarmRadar.setAlarmTime(radarAlarmData.getAlarmTime());//鎶ヨ鏃堕棿
+ String alarmpointName = ardAlarmRadar.getName();//鍏磋叮鐐瑰悕绉�
+ ardAlarmRadar.setName(ardAlarmRadar.getName() + "(" + radarAlarmData.getRadarName() + ")");//鎶ヨ鐐瑰悕绉�
+ ardAlarmRadar.setCreateTime(new Date());//鎺ユ敹鏃堕棿
+
String alarmType = "";
switch (ardAlarmRadar.getAlarmType()) {
case "杩愬姩鐩爣妫�娴�":
@@ -399,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);
@@ -409,72 +514,185 @@
//鑾峰彇闆疯揪鎵�鍦ㄥ涓婄殑澶у厜鐢�
String cameraIdWithTower = ardAlarmRadarMapper.getCameraByRadar(radarAlarmData.getRadarId());
if (StringUtils.isNotNull(cameraIdWithTower) && StringUtils.isNotEmpty(cameraIdWithTower)) {
- //鍏ラ槦鍒楀緟寮曞
- messagesEnqueued(cameraIdWithTower, uuid, alarmType, ardAlarmRadar.getAlarmTime(), 1);
+ log.info("鑾峰彇鍒伴浄杈惧涓婄殑鍏夌數:" + cameraIdWithTower);
+ //濡傛灉闆疯揪濉斾笂鏈夊厜鐢�
+ messagesEnqueued(cameraIdWithTower, uuid, alarmType, ardAlarmRadar.getCreateTime(), 1, 1, coordinate);
+ }
+ //鑾峰彇鎶ヨ鐐瑰叧鑱旂殑澶у厜鐢�
+ ArdAlarmpointsWell ardAlarmpointsWell = ardAlarmpointsWellMapper.selectArdAlarmpointsWellByWellId(alarmpointName);
+ if (StringUtils.isNotNull(ardAlarmpointsWell) && StringUtils.isNotEmpty(ardAlarmpointsWell.getCameraId())) {
+ String cameraId = ardAlarmpointsWell.getCameraId();
+ if (cameraIdWithTower.equals(cameraId)) {
+ return;
+ }
+ log.info("鑾峰彇鍒版姤璀︾偣鍏宠仈鐨勫厜鐢�:" + cameraId);
+ //濡傛灉鎶ヨ鐐瑰叧鑱斾簡鍏夌數
+ messagesEnqueued(cameraId, uuid, alarmType, ardAlarmRadar.getCreateTime(), 1, 2, coordinate);
}
} else {
//5鍒嗛挓鍐呮湁寮曞
ardAlarmRadar.setGuideFlag(0);
int count = ardAlarmRadarMapper.getArdAlarmRadarWithNotGuide(ardAlarmRadar, AlarmRadar.getCreateTime());
+ //鏈紩瀵艰秴杩�3娆★紝鐩存帴鍏ュ簱鍏ラ槦
if (count >= 3) {
- //鏈紩瀵艰秴杩�3娆★紝鐩存帴鍏ュ簱鍏ラ槦
- //5鍒嗛挓鍐呮湭寮曞鐩存帴鍏ュ簱
ardAlarmRadar.setGuideFlag(1);
ardAlarmRadarMapper.insertArdAlarmRadar(ardAlarmRadar);
- //鍏ラ槦鍒楀緟寮曞
//鑾峰彇闆疯揪鎵�鍦ㄥ涓婄殑澶у厜鐢�
String cameraIdWithTower = ardAlarmRadarMapper.getCameraByRadar(radarAlarmData.getRadarId());
if (StringUtils.isNotNull(cameraIdWithTower) && StringUtils.isNotEmpty(cameraIdWithTower)) {
+ log.info("鑾峰彇鍒伴浄杈惧涓婄殑鍏夌數:" + cameraIdWithTower);
//濡傛灉闆疯揪濉斾笂鏈夊厜鐢�
- messagesEnqueued(cameraIdWithTower, uuid, alarmType, ardAlarmRadar.getAlarmTime(), count);
+ messagesEnqueued(cameraIdWithTower, uuid, alarmType, ardAlarmRadar.getCreateTime(), count, 1, coordinate);
+ }
+ //鑾峰彇鎶ヨ鐐瑰叧鑱旂殑澶у厜鐢�
+ ArdAlarmpointsWell ardAlarmpointsWell = ardAlarmpointsWellMapper.selectArdAlarmpointsWellByWellId(alarmpointName);
+ if (StringUtils.isNotNull(ardAlarmpointsWell) && StringUtils.isNotEmpty(ardAlarmpointsWell.getCameraId())) {
+ String cameraId = ardAlarmpointsWell.getCameraId();
+ if (cameraIdWithTower.equals(cameraId)) {
+ return;
+ }
+ log.info("鑾峰彇鍒版姤璀︾偣鍏宠仈鐨勫厜鐢�:" + cameraId);
+ //濡傛灉鎶ヨ鐐瑰叧鑱斾簡鍏夌數
+ messagesEnqueued(cameraId, uuid, alarmType, ardAlarmRadar.getCreateTime(), count, 2, coordinate);
}
} else {
//鏈紩瀵兼湭瓒呰繃3娆★紝鐩存帴鍏ュ簱
ardAlarmRadarMapper.insertArdAlarmRadar(ardAlarmRadar);
}
-
}
-
-
- //鑾峰彇鍏磋叮鐐瑰叧鑱旂殑澶у厜鐢�
-// ArdAlarmpointsWell well=new ArdAlarmpointsWell();
-// well.setWellId(ardAlarmRadar.getName());
-// List<ArdAlarmpointsWell> ardAlarmpointsWells = ardAlarmpointsWellMapper.selectArdAlarmpointsWellList(well);
-// if(ardAlarmpointsWells!=null&&ardAlarmpointsWells.size()>0)
-// {
-// String cameraIdWithWell = ardAlarmpointsWells.get(0).getCameraId();
-// }
-
+ }
+ //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;
}
- GuidePriorityQueue.printPriorityQueue();//鎵撳嵃闃熷垪
} catch (Exception ex) {
log.error("鎺ユ敹鎶ヨ寮傚父:" + ex.getMessage());
}
}
-
/**
* 娑堟伅鍏ラ槦
+ * <p>
+ * cameraId 鐩告満ID
+ * alarmId 鎶ヨID
+ * alarmType 鎶ヨ绫诲瀷
+ * num 鎶ヨ娆℃暟
+ * recordSn 褰曞儚瀛樺偍浣嶇疆 1-recordUrl1 2-recordUrl2
+ * targetPosition 鎶ヨ鐐逛綅缃潗鏍�
*/
- private void messagesEnqueued (String cameraId, String alarmId, String alarmType, Date alarmTime, Integer num) {
- GuideTask guideTask = new GuideTask();
- guideTask.setCameraId(cameraId);
- guideTask.setAlarmId(alarmId);
- SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- guideTask.setAlarmTime(fmt.format(alarmTime));
- Integer priority = CamPriority.priorityMap.get(alarmType);
- guideTask.setPriority(priority);
- guideTask.setNum(num);
- queueManager.addTaskToQueue(cameraId,guideTask);
-// PriorityBlockingQueue<GuideTask> priorityBlockingQueue = GuidePriorityQueue.cameraQueueMap.get(guideTask.getCameraId());
-// priorityBlockingQueue.add(guideTask);
+ 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;
+ }
+
+ /**
+ * 鑾峰彇闄勮繎寮�鍚姤璀﹀紩瀵煎姛鑳藉厜鐢�
*/
private String getNearbyCamera(double[] targetPosition) {
String minDistanceCameraId = "";
@@ -507,66 +725,37 @@
return minDistanceCameraId;
}
- /**
- * @鎻忚堪 寮曞鏈�杩戠殑澶у厜鐢垫寚鍚戠洰鏍�
- * @鍙傛暟 [cmd]
- * @杩斿洖鍊� boolean
- * @鍒涘缓浜� 鍒樿嫃涔�
- * @鍒涘缓鏃堕棿 2023/6/28 16:34
- * @淇敼浜哄拰鍏跺畠淇℃伅
- */
- private boolean guideCamera(CameraCmd cmd) {
- try {
- String dayNightTime = redisCache.getCacheObject("sys_config:dayNightTime");
- String nearbyCamera = getNearbyCamera(cmd.getTargetPosition());
- if (StringUtils.isNotEmpty(nearbyCamera)) {
- //寮曞鍏夌數
- cmd.setCameraId(nearbyCamera);
- cmd.setChannelNum(ArdTool.getChannelBydayNightTime(dayNightTime));
- boolean guideRes = hikClientService.guideTargetPosition(cmd);
- return guideRes;
- } else {
- log.debug("鏈煡鎵惧埌鏈�杩戝厜鐢�");
- return false;
- }
- } catch (
- Exception ex) {
- log.error("寮曞寮傚父:" + ex.getMessage());
- return false;
- }
+ 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());
+ }
}
- /**
- * @鎻忚堪 鎶ヨ褰曞儚
- * @鍙傛暟 [cmd]
- * @杩斿洖鍊� java.lang.String
- * @鍒涘缓浜� 鍒樿嫃涔�
- * @鍒涘缓鏃堕棿 2023/6/28 16:33
- * @淇敼浜哄拰鍏跺畠淇℃伅
- */
- private String alarmToRecord(CameraCmd cmd) {
- String url = "";
- try {
- log.debug("寮曞鎴愬姛锛屽皾璇曞綍鍍�");
- String cameraId = cmd.getCameraId();
- hikClientService.controlLock(cmd);//涓婇攣
- cmd.setEnable(true);//寮�濮嬪綍鍍�
- hikClientService.recordToMinio(cmd);//寮�濮嬪綍鍍�
- GlobalVariable.threadMap.put(cameraId, Thread.currentThread().getName());//灏嗙浉鏈篿d涓庡綋鍓嶅鐞嗙嚎绋嬪悕绉扮粦瀹�
- Thread.sleep(cmd.getExpired() * 1000);//褰曞儚鏃堕暱
- String thread = GlobalVariable.threadMap.get(cameraId);
- String currentThread = Thread.currentThread().getName();
- //鍒ゆ柇鐩告満缁戝畾绾跨▼鏄惁鏄綋鍓嶇嚎绋嬶紝濡傛灉鏄紝鍋滄褰曞儚锛屽鏋滀笉鏄紝璇存槑鐩告満琚叾浠栫嚎绋嬫姠鍗狅紝涓嶅仠姝㈠綍鍍�
- if (thread.equals(currentThread)) {
- cmd.setEnable(false);//鍋滄褰曞儚
- cmd.setUploadMinio(true);//涓婁紶minio
- url = hikClientService.recordToMinio(cmd);//鍋滄褰曞儚杩斿洖url
- }
- } catch (Exception ex) {
- log.error("褰曞儚寮傚父:" + ex.getMessage());
- }
- return url;
+ @Data
+ @AllArgsConstructor
+ static class Obj {
+ Integer priority;
+ Integer num;
+ String alarmTime;
}
-
}
--
Gitblit v1.9.3