From 9d5493abf19d379382bbe4a45e006b974c137018 Mon Sep 17 00:00:00 2001
From: ‘liusuyi’ <1951119284@qq.com>
Date: 星期四, 14 十二月 2023 15:27:23 +0800
Subject: [PATCH] 优化
---
ard-work/src/main/java/com/ruoyi/alarm/global/service/impl/GlobalAlarmServiceImpl.java | 259 +++++++++++++++++++++++++++++----------------------
1 files changed, 146 insertions(+), 113 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/alarm/global/service/impl/GlobalAlarmServiceImpl.java b/ard-work/src/main/java/com/ruoyi/alarm/global/service/impl/GlobalAlarmServiceImpl.java
index db7b2d9..a17c4b9 100644
--- a/ard-work/src/main/java/com/ruoyi/alarm/global/service/impl/GlobalAlarmServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/alarm/global/service/impl/GlobalAlarmServiceImpl.java
@@ -1059,8 +1059,6 @@
break;
case "radar":
//region 澶勭悊闆疯揪鎶ヨ
- String mergeTime = ConfigUtils.getConfigValue("radarMergeTime");
- Integer radarMergeTime = mergeTime == null || "".equals(mergeTime) ? 10 : Integer.valueOf(mergeTime);
RadarAlarmData radarAlarmData = JSONObject.parseObject(message, RadarAlarmData.class);
List<ArdAlarmRadar> ardAlarmRadars = radarAlarmData.getArdAlarmRadars();
for (ArdAlarmRadar ardAlarmRadar : ardAlarmRadars) {
@@ -1096,47 +1094,8 @@
ardAlarmRadarMove.setUpdateTime(radarAlarmData.getAlarmTime());
ardAlarmRadarMove.setRadarId(radarId);
ardAlarmRadarMove.setGuidePTZ(guidePTZ);
- Date alarmTime = ardAlarmRadarMove.getAlarmTime();
- //鑾峰彇褰撳墠鍏磋叮鐐瑰綋鍓嶉浄杈剧殑涓婁竴鏉℃暟鎹�
- ArdAlarmRadarMove lastMoveData = ardAlarmRadarMoveMapper.selectArdAlarmRadarLastData(ardAlarmRadarMove.getName());
- if (lastMoveData == null) {
- //鍏ュ簱
- ardAlarmRadarMove.setGuideTime(alarmTime);
- ardAlarmRadarMoveMapper.insertArdAlarmRadarMove(ardAlarmRadarMove);
- radarMoveGuide(ardAlarmRadarMove);//寮曞
- } else {
- //鍚﹀垯姣斿鏇存柊鏃堕棿
- Date lastUpdateTime = lastMoveData.getUpdateTime();
- Date lastGuideTime = lastMoveData.getGuideTime();
- long secDatePoor = DateUtils.getSecDatePoor(alarmTime, lastUpdateTime);
- if (secDatePoor <= radarMergeTime) {
- //灏忎簬10绉掔殑鏂版暟鎹紝鏇存柊涓婁竴鏉�
- ArdAlarmRadarMove updateData = new ArdAlarmRadarMove();
- updateData.setId(lastMoveData.getId());
- updateData.setUpdateTime(alarmTime);
-
- //鍒ゆ柇寮曞鏃堕棿瓒呰繃5鍒嗛挓鍐嶆寮曞
- long secDatePoorGuide = DateUtils.getSecDatePoor(alarmTime, lastGuideTime);
- if (secDatePoorGuide >= 300) {
- updateData.setGuideTime(alarmTime);
- radarMoveGuide(ardAlarmRadarMove);//寮曞
- }
- ardAlarmRadarMoveMapper.updateArdAlarmRadarMove(updateData);
- } else {
- //瓒呰繃10绉掔殑鏁版嵁,鍏ュ簱
- ardAlarmRadarMove.setGuideTime(alarmTime);
- ardAlarmRadarMoveMapper.insertArdAlarmRadarMove(ardAlarmRadarMove);
- radarMoveGuide(ardAlarmRadarMove);//寮曞
- }
- }
- //鍏ョ紦瀛�
- //String key = "radar_alarm:" + DateUtils.getDate();
- //if (redisCache.hasKey(key)) {
- // redisCache.setCacheList(key, ardAlarmRadarMove, -1, TimeUnit.HOURS);
- //} else {
- // Integer expiryTimeInSeconds = DateUtils.getDayRemainingTime(ardAlarmRadarMove.getCreateTime());
- // redisCache.setCacheList(key, ardAlarmRadarMove, expiryTimeInSeconds, TimeUnit.SECONDS);
- //}
+ //
+ ardAlarmRadarMoveHandler(ardAlarmRadarMove);
break;
case "鐑簮妫�娴�":
ArdAlarmRadarFire ardAlarmRadarFire = new ArdAlarmRadarFire();
@@ -1152,38 +1111,7 @@
ardAlarmRadarFire.setRadarId(radarId);
ardAlarmRadarFire.setUpdateTime(radarAlarmData.getAlarmTime());
//
- ArdAlarmRadarFire lastFireData = ardAlarmRadarFireMapper.selectArdAlarmRadarLastData(ardAlarmRadarFire.getName());
- alarmTime = ardAlarmRadarFire.getAlarmTime();
- if (lastFireData == null) {
- //鍏ュ簱
- ardAlarmRadarFire.setGuideTime(alarmTime);
- ardAlarmRadarFireMapper.insertArdAlarmRadarFire(ardAlarmRadarFire);
- radarFireGuide(ardAlarmRadarFire);//寮曞
- } else {
- //鍚﹀垯姣斿鏇存柊鏃堕棿
- Date lastUpdateTime = lastFireData.getUpdateTime();
- Date lastGuideTime = lastFireData.getGuideTime();
- long secDatePoor = DateUtils.getSecDatePoor(alarmTime, lastUpdateTime);
- if (secDatePoor <= radarMergeTime) {
- //灏忎簬10绉掔殑鏂版暟鎹紝鏇存柊涓婁竴鏉�
- ArdAlarmRadarFire updateData = new ArdAlarmRadarFire();
- updateData.setId(lastFireData.getId());
- updateData.setUpdateTime(alarmTime);
-
- //鍒ゆ柇寮曞鏃堕棿瓒呰繃5鍒嗛挓鍐嶆寮曞
- long secDatePoorGuide = DateUtils.getSecDatePoor(alarmTime, lastGuideTime);
- if (secDatePoorGuide >= 300) {
- updateData.setGuideTime(alarmTime);
- radarFireGuide(ardAlarmRadarFire);//寮曞
- }
- ardAlarmRadarFireMapper.updateArdAlarmRadarFire(updateData);
- } else {
- //瓒呰繃10绉掔殑鏁版嵁,鍏ュ簱
- ardAlarmRadarFire.setGuideTime(alarmTime);
- ardAlarmRadarFireMapper.insertArdAlarmRadarFire(ardAlarmRadarFire);
- radarFireGuide(ardAlarmRadarFire);//寮曞
- }
- }
+ ardAlarmRadarFireHandler(ardAlarmRadarFire);
break;
case "闆疯揪鎶芥补鏈哄仠鏈�":
ArdAlarmRadarPump ardAlarmRadarPump = new ArdAlarmRadarPump();
@@ -1195,41 +1123,11 @@
ardAlarmRadarPump.setName(ardAlarmRadar.getName() + "(" + radarAlarmData.getRadarName() + ")");
ardAlarmRadarPump.setAlarmType("闆疯揪鎶芥补鏈哄仠鏈�");
ardAlarmRadarPump.setUpdateTime(radarAlarmData.getAlarmTime());
- alarmTime = ardAlarmRadarPump.getAlarmTime();
ardAlarmRadarPump.setLongitude(well.getLongitude());
ardAlarmRadarPump.setLatitude(well.getLatitude());
ardAlarmRadarPump.setGuidePTZ(guidePTZ);
//
- ArdAlarmRadarPump lastPumpData = ardAlarmRadarPumpMapper.selectArdAlarmRadarLastData(ardAlarmRadarPump.getName());
- if (lastPumpData == null) {
- //鍏ュ簱
- ardAlarmRadarPump.setGuideTime(alarmTime);
- ardAlarmRadarPumpMapper.insertArdAlarmRadarPump(ardAlarmRadarPump);
- radarPumpGuide(ardAlarmRadarPump);//寮曞
- } else {
- //鍚﹀垯姣斿鏇存柊鏃堕棿
- Date lastUpdateTime = lastPumpData.getUpdateTime();
- Date lastGuideTime = lastPumpData.getGuideTime();
- long secDatePoor = DateUtils.getSecDatePoor(alarmTime, lastUpdateTime);
- if (secDatePoor <= radarMergeTime) {
- //灏忎簬10绉掔殑鏂版暟鎹紝鏇存柊涓婁竴鏉�
- ArdAlarmRadarPump updateData = new ArdAlarmRadarPump();
- updateData.setId(lastPumpData.getId());
- updateData.setUpdateTime(alarmTime);
- //鍒ゆ柇寮曞鏃堕棿瓒呰繃5鍒嗛挓鍐嶆寮曞
- long secDatePoorGuide = DateUtils.getSecDatePoor(alarmTime, lastGuideTime);
- if (secDatePoorGuide >= 300) {
- radarPumpGuide(ardAlarmRadarPump);//寮曞
- updateData.setGuideTime(alarmTime);
- }
- ardAlarmRadarPumpMapper.updateArdAlarmRadarPump(updateData);
- } else {
- //瓒呰繃10绉掔殑鏁版嵁,鍏ュ簱
- ardAlarmRadarPump.setGuideTime(alarmTime);
- ardAlarmRadarPumpMapper.insertArdAlarmRadarPump(ardAlarmRadarPump);
- radarPumpGuide(ardAlarmRadarPump);//寮曞
- }
- }
+ ardAlarmRadarPumpHandler(ardAlarmRadarPump);
break;
}
}
@@ -1392,7 +1290,7 @@
Integer chanNo = ArdTool.getChannelBydayNightTime(redisCache.getCacheObject("sys_config:dayNightTime"));
guideTask.setChanNo(chanNo);//閫氶亾(閫氳繃鏃ュ鏃堕棿鐮斿垽)
guideTask.setAlarmId(guideDataDto.getAlarmId()); //鎶ヨID
- guideTask.setReceiveTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS_MS,guideDataDto.getReceiveTime()));//鎺ユ敹鏃堕棿
+ guideTask.setReceiveTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS_MS, guideDataDto.getReceiveTime()));//鎺ユ敹鏃堕棿
//鎶ヨ浼樺厛绾�(閫氳繃浼樺厛绾у瓧鍏�)
String priority = DictUtils.getDictValue("cameras_priority", alarmType);
if (StringUtils.isEmpty(priority)) {
@@ -1485,7 +1383,11 @@
}
}
- //闆疯揪绉诲姩寮曞
+ /**
+ * 闆疯揪绉诲姩寮曞
+ * 鍒樿嫃涔�
+ * 2023/12/14 15:04:24
+ */
private void radarMoveGuide(ArdAlarmRadarMove ardAlarmRadarMove) {
log.debug("闆疯揪绉诲姩寮�濮嬪紩瀵�");
if (StringUtils.isNull(ardAlarmRadarMove.getLongitude()) || StringUtils.isNull(ardAlarmRadarMove.getLatitude())) {
@@ -1495,7 +1397,7 @@
double[] coordinate = new double[]{ardAlarmRadarMove.getLongitude(), ardAlarmRadarMove.getLatitude()};//鎶ヨ鍧愭爣
//寮曞鍏ラ槦
GuideDataDto guideDataDto = new GuideDataDto()
- .setRadarId( ardAlarmRadarMove.getRadarId())
+ .setRadarId(ardAlarmRadarMove.getRadarId())
.setName(ardAlarmRadarMove.getName())
.setAlarmId(ardAlarmRadarMove.getId())
.setAlarmType(ardAlarmRadarMove.getAlarmType())
@@ -1505,7 +1407,11 @@
getCameraGuideToQueue(guideDataDto);//鑾峰彇鐩告満鍏ラ槦
}
- //闆疯揪闃茬伀寮曞
+ /**
+ * 闆疯揪闃茬伀寮曞
+ * 鍒樿嫃涔�
+ * 2023/12/14 15:04:32
+ */
private void radarFireGuide(ArdAlarmRadarFire ardAlarmRadarFire) {
log.debug("闆疯揪闃茬伀寮�濮嬪紩瀵�");
if (StringUtils.isNull(ardAlarmRadarFire.getLongitude()) || StringUtils.isNull(ardAlarmRadarFire.getLatitude())) {
@@ -1515,7 +1421,7 @@
double[] coordinate = new double[]{ardAlarmRadarFire.getLongitude(), ardAlarmRadarFire.getLatitude()};//鎶ヨ鍧愭爣
//寮曞鍏ラ槦
GuideDataDto guideDataDto = new GuideDataDto()
- .setRadarId( ardAlarmRadarFire.getRadarId())
+ .setRadarId(ardAlarmRadarFire.getRadarId())
.setName(ardAlarmRadarFire.getName())
.setAlarmId(ardAlarmRadarFire.getId())
.setAlarmType(ardAlarmRadarFire.getAlarmType())
@@ -1525,7 +1431,11 @@
getCameraGuideToQueue(guideDataDto);//鑾峰彇鐩告満鍏ラ槦
}
- //闆疯揪鎶芥补鏈哄仠鏈哄紩瀵�
+ /**
+ * 闆疯揪鎶芥补鏈哄仠鏈哄紩瀵�
+ * 鍒樿嫃涔�
+ * 2023/12/14 15:04:40
+ */
private void radarPumpGuide(ArdAlarmRadarPump ardAlarmRadarPump) {
log.debug("闆疯揪鎶芥补鏈哄仠鏈哄紑濮嬪紩瀵�");
if (StringUtils.isNull(ardAlarmRadarPump.getLongitude()) || StringUtils.isNull(ardAlarmRadarPump.getLatitude())) {
@@ -1536,7 +1446,7 @@
double[] coordinate = new double[]{ardAlarmRadarPump.getLongitude(), ardAlarmRadarPump.getLatitude()};//鎶ヨ鍧愭爣
//寮曞鍏ラ槦
GuideDataDto guideDataDto = new GuideDataDto()
- .setRadarId( ardAlarmRadarPump.getRadarId())
+ .setRadarId(ardAlarmRadarPump.getRadarId())
.setName(ardAlarmRadarPump.getName())
.setAlarmId(ardAlarmRadarPump.getId())
.setAlarmType(ardAlarmRadarPump.getAlarmType())
@@ -1545,4 +1455,127 @@
.setGuidePTZ(ardAlarmRadarPump.getGuidePTZ());
getCameraGuideToQueue(guideDataDto);//鑾峰彇鐩告満鍏ラ槦
}
+
+
+ /**
+ * 闆疯揪鐩爣绉诲姩鎶ヨ澶勭悊
+ * 鍒樿嫃涔�
+ * 2023/12/14 15:03:32
+ */
+ private void ardAlarmRadarMoveHandler(ArdAlarmRadarMove ardAlarmRadarMove) {
+ String mergeTime = ConfigUtils.getConfigValue("radarMergeTime");
+ Integer radarMergeTime = mergeTime == null || "".equals(mergeTime) ? 10 : Integer.valueOf(mergeTime);
+ ArdAlarmRadarMove lastMoveData = ardAlarmRadarMoveMapper.selectArdAlarmRadarLastData(ardAlarmRadarMove.getName());
+ if (lastMoveData == null) {
+ //鍏ュ簱
+ ardAlarmRadarMove.setGuideTime(ardAlarmRadarMove.getAlarmTime());
+ ardAlarmRadarMoveMapper.insertArdAlarmRadarMove(ardAlarmRadarMove);
+ radarMoveGuide(ardAlarmRadarMove);//寮曞
+ } else {
+ //鍚﹀垯姣斿鏇存柊鏃堕棿
+ Date lastUpdateTime = lastMoveData.getUpdateTime();
+ Date lastGuideTime = lastMoveData.getGuideTime();
+ long secDatePoor = DateUtils.getSecDatePoor(ardAlarmRadarMove.getAlarmTime(), lastUpdateTime);
+ if (secDatePoor <= radarMergeTime) {
+ //灏忎簬10绉掔殑鏂版暟鎹紝鏇存柊涓婁竴鏉�
+ ArdAlarmRadarMove updateData = new ArdAlarmRadarMove();
+ updateData.setId(lastMoveData.getId());
+ updateData.setUpdateTime(ardAlarmRadarMove.getAlarmTime());
+
+ //鍒ゆ柇寮曞鏃堕棿瓒呰繃5鍒嗛挓鍐嶆寮曞
+ long secDatePoorGuide = DateUtils.getSecDatePoor(ardAlarmRadarMove.getAlarmTime(), lastGuideTime);
+ if (secDatePoorGuide >= 300) {
+ updateData.setGuideTime(ardAlarmRadarMove.getAlarmTime());
+ radarMoveGuide(ardAlarmRadarMove);//寮曞
+ }
+ ardAlarmRadarMoveMapper.updateArdAlarmRadarMove(updateData);
+ } else {
+ //瓒呰繃10绉掔殑鏁版嵁,鍏ュ簱
+ ardAlarmRadarMove.setGuideTime(ardAlarmRadarMove.getAlarmTime());
+ ardAlarmRadarMoveMapper.insertArdAlarmRadarMove(ardAlarmRadarMove);
+ radarMoveGuide(ardAlarmRadarMove);//寮曞
+ }
+ }
+ }
+
+ /**
+ * 闆疯揪绾㈠闃茬伀鎶ヨ澶勭悊
+ * 鍒樿嫃涔�
+ * 2023/12/14 15:03:23
+ */
+ private void ardAlarmRadarFireHandler(ArdAlarmRadarFire ardAlarmRadarFire) {
+ String mergeTime = ConfigUtils.getConfigValue("radarMergeTime");
+ Integer radarMergeTime = mergeTime == null || "".equals(mergeTime) ? 10 : Integer.valueOf(mergeTime);
+ ArdAlarmRadarFire lastFireData = ardAlarmRadarFireMapper.selectArdAlarmRadarLastData(ardAlarmRadarFire.getName());
+ if (lastFireData == null) {
+ //鍏ュ簱
+ ardAlarmRadarFire.setGuideTime(ardAlarmRadarFire.getAlarmTime());
+ ardAlarmRadarFireMapper.insertArdAlarmRadarFire(ardAlarmRadarFire);
+ radarFireGuide(ardAlarmRadarFire);//寮曞
+ } else {
+ //鍚﹀垯姣斿鏇存柊鏃堕棿
+ Date lastUpdateTime = lastFireData.getUpdateTime();
+ Date lastGuideTime = lastFireData.getGuideTime();
+ long secDatePoor = DateUtils.getSecDatePoor(ardAlarmRadarFire.getAlarmTime(), lastUpdateTime);
+ if (secDatePoor <= radarMergeTime) {
+ //灏忎簬10绉掔殑鏂版暟鎹紝鏇存柊涓婁竴鏉�
+ ArdAlarmRadarFire updateData = new ArdAlarmRadarFire();
+ updateData.setId(lastFireData.getId());
+ updateData.setUpdateTime(ardAlarmRadarFire.getAlarmTime());
+
+ //鍒ゆ柇寮曞鏃堕棿瓒呰繃5鍒嗛挓鍐嶆寮曞
+ long secDatePoorGuide = DateUtils.getSecDatePoor(ardAlarmRadarFire.getAlarmTime(), lastGuideTime);
+ if (secDatePoorGuide >= 300) {
+ updateData.setGuideTime(ardAlarmRadarFire.getAlarmTime());
+ radarFireGuide(ardAlarmRadarFire);//寮曞
+ }
+ ardAlarmRadarFireMapper.updateArdAlarmRadarFire(updateData);
+ } else {
+ //瓒呰繃10绉掔殑鏁版嵁,鍏ュ簱
+ ardAlarmRadarFire.setGuideTime(ardAlarmRadarFire.getAlarmTime());
+ ardAlarmRadarFireMapper.insertArdAlarmRadarFire(ardAlarmRadarFire);
+ radarFireGuide(ardAlarmRadarFire);//寮曞
+ }
+ }
+ }
+
+ /**
+ * 闆疯揪鎶芥补鏈哄仠鏈烘姤璀﹀鐞�
+ * 鍒樿嫃涔�
+ * 2023/12/14 15:03:06
+ */
+ private void ardAlarmRadarPumpHandler(ArdAlarmRadarPump ardAlarmRadarPump) {
+ String mergeTime = ConfigUtils.getConfigValue("radarMergeTime");
+ Integer radarMergeTime = mergeTime == null || "".equals(mergeTime) ? 10 : Integer.valueOf(mergeTime);
+ ArdAlarmRadarPump lastPumpData = ardAlarmRadarPumpMapper.selectArdAlarmRadarLastData(ardAlarmRadarPump.getName());
+ if (lastPumpData == null) {
+ //鍏ュ簱
+ ardAlarmRadarPump.setGuideTime(ardAlarmRadarPump.getAlarmTime());
+ ardAlarmRadarPumpMapper.insertArdAlarmRadarPump(ardAlarmRadarPump);
+ radarPumpGuide(ardAlarmRadarPump);//寮曞
+ } else {
+ //鍚﹀垯姣斿鏇存柊鏃堕棿
+ Date lastUpdateTime = lastPumpData.getUpdateTime();
+ Date lastGuideTime = lastPumpData.getGuideTime();
+ long secDatePoor = DateUtils.getSecDatePoor(ardAlarmRadarPump.getAlarmTime(), lastUpdateTime);
+ if (secDatePoor <= radarMergeTime) {
+ //灏忎簬10绉掔殑鏂版暟鎹紝鏇存柊涓婁竴鏉�
+ ArdAlarmRadarPump updateData = new ArdAlarmRadarPump();
+ updateData.setId(lastPumpData.getId());
+ updateData.setUpdateTime(ardAlarmRadarPump.getAlarmTime());
+ //鍒ゆ柇寮曞鏃堕棿瓒呰繃5鍒嗛挓鍐嶆寮曞
+ long secDatePoorGuide = DateUtils.getSecDatePoor(ardAlarmRadarPump.getAlarmTime(), lastGuideTime);
+ if (secDatePoorGuide >= 300) {
+ radarPumpGuide(ardAlarmRadarPump);//寮曞
+ updateData.setGuideTime(ardAlarmRadarPump.getAlarmTime());
+ }
+ ardAlarmRadarPumpMapper.updateArdAlarmRadarPump(updateData);
+ } else {
+ //瓒呰繃10绉掔殑鏁版嵁,鍏ュ簱
+ ardAlarmRadarPump.setGuideTime(ardAlarmRadarPump.getAlarmTime());
+ ardAlarmRadarPumpMapper.insertArdAlarmRadarPump(ardAlarmRadarPump);
+ radarPumpGuide(ardAlarmRadarPump);//寮曞
+ }
+ }
+ }
}
--
Gitblit v1.9.3