From 931ad9c18321121d0b64e9f6e49592f0472289fa Mon Sep 17 00:00:00 2001
From: Administrator <1144154118@qq.com>
Date: 星期四, 10 八月 2023 09:26:54 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
ard-work/src/main/java/com/ruoyi/alarm/global/service/impl/GlobalAlarmServiceImpl.java | 35 +++++++++--------
ard-work/src/main/resources/mapper/alarm/ArdAlarmRadarMapper.xml | 43 +++++++++++----------
2 files changed, 41 insertions(+), 37 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 a5935ee..c7d9fb5 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
@@ -45,11 +45,13 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
+
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
+
/**
* @Description: 鍏ㄥ眬鎶ヨ涓氬姟
@@ -507,8 +509,6 @@
break;
case "radar":
//region 澶勭悊闆疯揪鎶ヨ
- // 寮�濮嬫椂闂�
- long stime = System.currentTimeMillis();
RadarAlarmData radarAlarmData = JSONObject.parseObject(message, RadarAlarmData.class);
List<ArdAlarmRadar> ardAlarmRadars = radarAlarmData.getArdAlarmRadars();
for (ArdAlarmRadar ardAlarmRadar : ardAlarmRadars) {
@@ -519,10 +519,9 @@
ardAlarmRadar.setName(ardAlarmRadar.getName() + "(" + radarAlarmData.getRadarName() + ")");//鎶ヨ鐐瑰悕绉�
ardAlarmRadar.setCreateTime(new Date());//鎺ユ敹鏃堕棿
- String alarmType = "";
switch (ardAlarmRadar.getAlarmType()) {
case "杩愬姩鐩爣妫�娴�":
- alarmType = "sys_radar_move";
+ String alarmType = "sys_radar_move";
break;
case "鐑簮妫�娴�":
alarmType = "sys_radar_fire";
@@ -536,11 +535,21 @@
}
break;
}
+ //鍏ュ簱
+ ardAlarmRadarMapper.insertArdAlarmRadar(ardAlarmRadar);
+
+ }
+ //鎸夊叴瓒g偣鍘婚噸,鐒跺悗鎸夊紩瀵奸�昏緫杩涜寮曞鍏ラ槦
+ ardAlarmRadars = ardAlarmRadars.stream()
+ .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new java.util.TreeSet<>(java.util.Comparator.comparing(ArdAlarmRadar::getName))), ArrayList::new));
+ for(ArdAlarmRadar ardAlarmRadar : ardAlarmRadars)
+ {
+ //閬嶅巻鎶ヨ鏁版嵁杩涜寮曞
if (StringUtils.isNull(ardAlarmRadar.getLongitude()) || StringUtils.isNull(ardAlarmRadar.getLatitude())) {
+ //鍧愭爣涓虹┖涓嶅紩瀵�
continue;
}
double[] coordinate = new double[]{ardAlarmRadar.getLongitude(), ardAlarmRadar.getLatitude()};//鎶ヨ鍧愭爣
-
//浠巖edis涓彇鍑哄綋鍓嶆姤璀︾偣鐨�5鍒嗛挓鍐呮槸鍚︽湁寮曞
ArdAlarmRadar AlarmRadar = redisCache.getCacheObject("global_alarm:" + ardAlarmRadar.getName());//浠巖edis涓彇鍑烘渶鏂板紩瀵肩殑鎶ヨ鏁版嵁
if (AlarmRadar == null) {
@@ -550,7 +559,7 @@
redisCache.setCacheObject("global_alarm:" + ardAlarmRadar.getName(), ardAlarmRadar, 5, TimeUnit.MINUTES);//寮曞鏁版嵁鍐欏叆redis
unGuideCountMap.put(ardAlarmRadar.getName(), 0);
//寮曞鍏ラ槦
- radarGuide(radarAlarmData.getRadarId(), alarmpointName, alarmType, ardAlarmRadar.getCreateTime(), coordinate);
+ radarGuide(radarAlarmData.getRadarId(), ardAlarmRadar.getName(), ardAlarmRadar.getAlarmType(), ardAlarmRadar.getCreateTime(), coordinate);
} else {
//5鍒嗛挓鍐卹edis涓湁鏁版嵁锛岃鏄�5鍒嗛挓鍐呮湁寮曞鏁版嵁,鑾峰彇褰撳墠鎶ヨ鐐圭殑鏈紩瀵兼鏁�
@@ -563,7 +572,7 @@
redisCache.setCacheObject("global_alarm:" + ardAlarmRadar.getName(), ardAlarmRadar, 5, TimeUnit.MINUTES);
count = 0;
//寮曞鍏ラ槦
- radarGuide(radarAlarmData.getRadarId(), alarmpointName, alarmType, ardAlarmRadar.getCreateTime(), coordinate);
+ radarGuide(radarAlarmData.getRadarId(), ardAlarmRadar.getName(), ardAlarmRadar.getAlarmType(), ardAlarmRadar.getCreateTime(), coordinate);
} else {
ardAlarmRadar.setGuideFlag(0);
count++;
@@ -573,15 +582,10 @@
count = 0;
}
unGuideCountMap.put(ardAlarmRadar.getName(), count);
+ //鏇存柊
+ ardAlarmRadarMapper.updateArdAlarmRadar(ardAlarmRadar);
}
- //鍏ュ簱
- ardAlarmRadarMapper.insertArdAlarmRadar(ardAlarmRadar);
- // 缁撴潫鏃堕棿
- long etime = System.currentTimeMillis();
- // 璁$畻鎵ц鏃堕棿
- log.debug("闆疯揪鎶ヨ澶勭悊鏃堕暱锛�" + (etime - stime) + "姣");
}
-
//endregion
break;
case "external":
@@ -691,8 +695,7 @@
guideTask.setReceiveTime(fmt.format(receiveTime));
//鎶ヨ浼樺厛绾�(閫氳繃浼樺厛绾у瓧鍏�)
String priority = DictUtils.getDictValue("cameras_priority", alarmType);
- if(StringUtils.isEmpty(priority))
- {
+ if (StringUtils.isEmpty(priority)) {
log.debug("鏈尮閰嶅埌浼樺厛绾�,璇锋鏌ヤ紭鍏堢骇瀛楀吀閰嶇疆");
return;
}
diff --git a/ard-work/src/main/resources/mapper/alarm/ArdAlarmRadarMapper.xml b/ard-work/src/main/resources/mapper/alarm/ArdAlarmRadarMapper.xml
index ebe4f66..6819e98 100644
--- a/ard-work/src/main/resources/mapper/alarm/ArdAlarmRadarMapper.xml
+++ b/ard-work/src/main/resources/mapper/alarm/ArdAlarmRadarMapper.xml
@@ -128,27 +128,28 @@
</delete>
<select id="selectListAllByCommand" resultMap="ArdAlarmRadarResult">
- SELECT T
- .*
- FROM (
- SELECT aar.ID,
- aar.target_id,
- aar.NAME,
- aar.alarm_type,
- aar.alarm_time,
- aar.longitude,
- aar.latitude,
- ROW_NUMBER() OVER ( PARTITION BY aar.NAME ORDER BY aar.alarm_time DESC ) AS rn, COUNT(CASE WHEN aar.view_time IS NULL THEN 1 END) OVER ( PARTITION BY aar.NAME ) AS COUNT,
- COUNT ( aar.alarm_time ) OVER ( PARTITION BY aar.NAME ) AS total
- FROM
- ard_alarm_radar aar
- WHERE
- aar.alarm_time >= ( CURRENT_TIMESTAMP - INTERVAL '%${refreshTime}%' MINUTE )
- AND aar.alarm_type = #{alarmType}
- ORDER BY
- aar.alarm_time DESC
- ) T
- WHERE T.rn = 1
+ select aaar.ID,
+ aaar.target_id,
+ aaar.NAME,
+ aaar.alarm_type,
+ aaar.alarm_time,
+ aaar.longitude,
+ aaar.latitude,
+ r.COUNT,
+ r.total from
+ (SELECT
+ aar.NAME,
+ max(aar.create_time) as create_time1,
+ count(case when aar.view_time is null THEN 1 END) as count,
+ count(aar.id) as total
+ FROM
+ ard_alarm_radar aar
+ WHERE
+ aar.create_time >= ( CURRENT_TIMESTAMP - INTERVAL '%${refreshTime}%' MINUTE )
+ AND aar.alarm_type = #{alarmType}
+ GROUP BY aar.NAME
+ ) r
+ INNER JOIN ard_alarm_radar aaar ON r.create_time1 = aaar.create_time
</select>
<select id="selectCountByAlarmTime" resultType="Integer">
SELECT COUNT(DISTINCT aar.name)
--
Gitblit v1.9.3