From 03bdf8738729b6055b0c5594628b261a3ebaaced Mon Sep 17 00:00:00 2001
From: aijinhui <aijinhui>
Date: 星期四, 21 九月 2023 16:50:20 +0800
Subject: [PATCH] 设备健康
---
ard-work/src/main/java/com/ruoyi/alarm/global/service/impl/GlobalAlarmServiceImpl.java | 172 ++++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 133 insertions(+), 39 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 d984130..87540fa 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
@@ -33,7 +33,9 @@
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.domain.entity.SysConfig;
import com.ruoyi.common.core.redis.RedisCache;
+import com.ruoyi.common.utils.ConfigUtils;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.DictUtils;
import com.ruoyi.common.utils.StringUtils;
@@ -113,10 +115,6 @@
@Resource
private ArdEquipRadarMapper ardEquipRadarMapper;
//endregion
- //姣忎釜鐐逛綅鏈紩瀵兼鏁�
- private Map<String, Integer> unGuideCountMapMove = new HashMap<>();
- private Map<String, Integer> unGuideCountMapFire = new HashMap<>();
- private Map<String, Integer> unGuideCountMapPump = new HashMap<>();
/**
* @鎻忚堪 鏌ヨ鎵�鏈夋姤璀︾殑褰撳墠鏁伴噺
@@ -389,20 +387,20 @@
// globalAlarmDataList.add(globalAlarmData);
//}
//return globalAlarmDataList;
- //浠庢暟鎹簱鑾峰彇
- List<ArdAlarmRadarMove> ardAlarmRadarMoves = ardAlarmRadarMoveMapper.selectListAllByCommand(refreshTime);
- return ardAlarmRadarMoves.stream()
- .map(ardAlarmRadarMove -> {
- GlobalAlarmData globalAlarmData = new GlobalAlarmData()
- .setId(ardAlarmRadarMove.getId())
- .setName(ardAlarmRadarMove.getName())
- .setAlarmTime(ardAlarmRadarMove.getAlarmTime())
- .setLongitude(ardAlarmRadarMove.getLongitude())
- .setLatitude(ardAlarmRadarMove.getLatitude())
- .setCount(ardAlarmRadarMove.getCount())
- .setTotal(ardAlarmRadarMove.getTotal());
- return globalAlarmData;
- }).collect(Collectors.toList());
+ //浠庢暟鎹簱鑾峰彇
+ List<ArdAlarmRadarMove> ardAlarmRadarMoves = ardAlarmRadarMoveMapper.selectListAllByCommand(refreshTime);
+ return ardAlarmRadarMoves.stream()
+ .map(ardAlarmRadarMove -> {
+ GlobalAlarmData globalAlarmData = new GlobalAlarmData()
+ .setId(ardAlarmRadarMove.getId())
+ .setName(ardAlarmRadarMove.getName())
+ .setAlarmTime(ardAlarmRadarMove.getAlarmTime())
+ .setLongitude(ardAlarmRadarMove.getLongitude())
+ .setLatitude(ardAlarmRadarMove.getLatitude())
+ .setCount(ardAlarmRadarMove.getCount())
+ .setTotal(ardAlarmRadarMove.getTotal());
+ return globalAlarmData;
+ }).collect(Collectors.toList());
case 1004:
List<ArdAlarmRadarFire> ardAlarmRadarFires = ardAlarmRadarFireMapper.selectListAllByCommand(refreshTime);
return ardAlarmRadarFires.stream()
@@ -987,13 +985,13 @@
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();
- List<ArdAlarmRadarMove> ardAlarmRadarMoves = new ArrayList<>();
- List<ArdAlarmRadarFire> ardAlarmRadarFires = new ArrayList<>();
- List<ArdAlarmRadarPump> ardAlarmRadarPumps = new ArrayList<>();
for (ArdAlarmRadar ardAlarmRadar : ardAlarmRadars) {
String uuid = IdUtils.simpleUUID();
+ String radarId = radarAlarmData.getRadarId();
String alarmpointName = ardAlarmRadar.getName();//鍏磋叮鐐瑰悕绉�
Double longitude = ardAlarmRadar.getLongitude();
Double latitude = ardAlarmRadar.getLatitude();
@@ -1009,9 +1007,31 @@
ardAlarmRadarMove.setAlarmType("杩愬姩鐩爣妫�娴�");
ardAlarmRadarMove.setLongitude(longitude);
ardAlarmRadarMove.setLatitude(latitude);
- //鍏ュ簱
- ardAlarmRadarMoveMapper.insertArdAlarmRadarMove(ardAlarmRadarMove);
- ardAlarmRadarMoves.add(ardAlarmRadarMove);
+ ardAlarmRadarMove.setUpdateTime(radarAlarmData.getAlarmTime());
+ ardAlarmRadarMove.setRadarId(radarId);
+ //鑾峰彇褰撳墠鍏磋叮鐐瑰綋鍓嶉浄杈剧殑涓婁竴鏉℃暟鎹�
+ ArdAlarmRadarMove lastMoveData = ardAlarmRadarMoveMapper.selectArdAlarmRadarLastData(ardAlarmRadarMove.getName());
+ if (lastMoveData == null) {
+ //鍏ュ簱
+ ardAlarmRadarMoveMapper.insertArdAlarmRadarMove(ardAlarmRadarMove);
+ radarMoveGuide(ardAlarmRadarMove);//寮曞
+ } else {
+ //鍚﹀垯姣斿鏇存柊鏃堕棿
+ Date lastUpdateTime = lastMoveData.getUpdateTime();
+ Date alarmTime = ardAlarmRadarMove.getAlarmTime();
+ long secDatePoor = DateUtils.getSecDatePoor(alarmTime,lastUpdateTime);
+ if (secDatePoor <= radarMergeTime) {
+ //灏忎簬10绉掔殑鏂版暟鎹紝鏇存柊涓婁竴鏉�
+ ArdAlarmRadarMove updateData = new ArdAlarmRadarMove();
+ updateData.setId(lastMoveData.getId());
+ updateData.setUpdateTime(alarmTime);
+ ardAlarmRadarMoveMapper.updateArdAlarmRadarMove(updateData);
+ } else {
+ //瓒呰繃10绉掔殑鏁版嵁,鍏ュ簱
+ ardAlarmRadarMoveMapper.insertArdAlarmRadarMove(ardAlarmRadarMove);
+ radarMoveGuide(ardAlarmRadarMove);//寮曞
+ }
+ }
//鍏ョ紦瀛�
//String key = "radar_alarm:" + DateUtils.getDate();
//if (redisCache.hasKey(key)) {
@@ -1031,34 +1051,74 @@
ardAlarmRadarFire.setAlarmType("鐑簮妫�娴�");
ardAlarmRadarFire.setLongitude(longitude);
ardAlarmRadarFire.setLatitude(latitude);
- //鍏ュ簱
- ardAlarmRadarFireMapper.insertArdAlarmRadarFire(ardAlarmRadarFire);
- ardAlarmRadarFires.add(ardAlarmRadarFire);
+ ardAlarmRadarFire.setRadarId(radarId);
+ ardAlarmRadarFire.setUpdateTime(radarAlarmData.getAlarmTime());
+ //
+ ArdAlarmRadarFire lastFireData = ardAlarmRadarFireMapper.selectArdAlarmRadarLastData(ardAlarmRadarFire.getName());
+ if (lastFireData == null) {
+ //鍏ュ簱
+ ardAlarmRadarFireMapper.insertArdAlarmRadarFire(ardAlarmRadarFire);
+ radarFireGuide(ardAlarmRadarFire);//寮曞
+ } else {
+ //鍚﹀垯姣斿鏇存柊鏃堕棿
+ Date lastUpdateTime = lastFireData.getUpdateTime();
+ Date alarmTime = ardAlarmRadarFire.getAlarmTime();
+ long secDatePoor = DateUtils.getSecDatePoor(alarmTime,lastUpdateTime);
+ if (secDatePoor <= radarMergeTime) {
+ //灏忎簬10绉掔殑鏂版暟鎹紝鏇存柊涓婁竴鏉�
+ ArdAlarmRadarFire updateData = new ArdAlarmRadarFire();
+ updateData.setId(lastFireData.getId());
+ updateData.setUpdateTime(alarmTime);
+ ardAlarmRadarFireMapper.updateArdAlarmRadarFire(updateData);
+ } else {
+ //瓒呰繃10绉掔殑鏁版嵁,鍏ュ簱
+ ardAlarmRadarFireMapper.insertArdAlarmRadarFire(ardAlarmRadarFire);
+ radarFireGuide(ardAlarmRadarFire);//寮曞
+ }
+ }
break;
case "闆疯揪鎶芥补鏈哄仠鏈�":
ArdAlarmRadarPump ardAlarmRadarPump = new ArdAlarmRadarPump();
+ ardAlarmRadarPump.setRadarId(radarId);
ardAlarmRadarPump.setId(uuid);
ardAlarmRadarPump.setTargetId(targetId);
ardAlarmRadarPump.setAlarmTime(radarAlarmData.getAlarmTime());
ardAlarmRadarPump.setCreateTime(new Date());
ardAlarmRadarPump.setName(ardAlarmRadar.getName() + "(" + radarAlarmData.getRadarName() + ")");
ardAlarmRadarPump.setAlarmType("闆疯揪鎶芥补鏈哄仠鏈�");
+ ardAlarmRadarPump.setUpdateTime(radarAlarmData.getAlarmTime());
ArdAlarmpointsWell ardAlarmpointsWell = ardAlarmpointsWellMapper.selectArdAlarmpointsWellByWellId(alarmpointName);
if (StringUtils.isNotNull(ardAlarmpointsWell)) {
ardAlarmRadarPump.setLongitude(ardAlarmpointsWell.getLongitude());
ardAlarmRadarPump.setLatitude(ardAlarmpointsWell.getLatitude());
}
- //鍏ュ簱
- ardAlarmRadarPumpMapper.insertArdAlarmRadarPump(ardAlarmRadarPump);
- ardAlarmRadarPumps.add(ardAlarmRadarPump);
-
+ //
+ ArdAlarmRadarPump lastPumpData = ardAlarmRadarPumpMapper.selectArdAlarmRadarLastData(ardAlarmRadarPump.getName());
+ if (lastPumpData == null) {
+ //鍏ュ簱
+ ardAlarmRadarPumpMapper.insertArdAlarmRadarPump(ardAlarmRadarPump);
+ radarPumpGuide(ardAlarmRadarPump);//寮曞
+ } else {
+ //鍚﹀垯姣斿鏇存柊鏃堕棿
+ Date lastUpdateTime = lastPumpData.getUpdateTime();
+ Date alarmTime = ardAlarmRadarPump.getAlarmTime();
+ long secDatePoor = DateUtils.getSecDatePoor(alarmTime,lastUpdateTime);
+ if (secDatePoor <= radarMergeTime) {
+ //灏忎簬10绉掔殑鏂版暟鎹紝鏇存柊涓婁竴鏉�
+ ArdAlarmRadarPump updateData = new ArdAlarmRadarPump();
+ updateData.setId(lastPumpData.getId());
+ updateData.setUpdateTime(alarmTime);
+ ardAlarmRadarPumpMapper.updateArdAlarmRadarPump(updateData);
+ } else {
+ //瓒呰繃10绉掔殑鏁版嵁,鍏ュ簱
+ ardAlarmRadarPumpMapper.insertArdAlarmRadarPump(ardAlarmRadarPump);
+ radarPumpGuide(ardAlarmRadarPump);//寮曞
+ }
+ }
break;
}
}
- radarMoveGuide(ardAlarmRadarMoves, radarAlarmData);
- radarFireGuide(ardAlarmRadarFires, radarAlarmData);
- radarPumpGuide(ardAlarmRadarPumps, radarAlarmData);
//endregion
break;
case "external":
@@ -1134,7 +1194,7 @@
ArdAlarmDigitization3 ardAlarmDigitization3 = JSONObject.parseObject(message, ArdAlarmDigitization3.class);
//鑾峰彇缁忕含搴�
ArdAlarmpointsWell Well = ardAlarmpointsWellMapper.selectArdAlarmpointsWellByWellId(ardAlarmDigitization3.getWellNo());
- if(Well!=null) {
+ if (Well != null) {
ardAlarmDigitization3.setLongitude(Well.getLongitude());
ardAlarmDigitization3.setLatitude(Well.getLatitude());
ardAlarmDigitization3.setAltitude(Well.getAltitude());
@@ -1276,8 +1336,7 @@
return minDistanceCameraId;
}
-
- //闆疯揪寮曞鍏ラ槦(鑾峰彇鐩告満)
+ //闆疯揪鑾峰彇鐩告満寮曞鍏ラ槦
private void radarGuideToQueue(String alarmId, String radarId, String name, String alarmType, Date createTime, double[] coordinate) {
int index = name.indexOf("(");
String alarmpointName = name.substring(0, index);
@@ -1305,6 +1364,42 @@
}
}
//闆疯揪绉诲姩寮曞
+ private void radarMoveGuide(ArdAlarmRadarMove ardAlarmRadarMove) {
+ if (StringUtils.isNull(ardAlarmRadarMove.getLongitude()) || StringUtils.isNull(ardAlarmRadarMove.getLatitude())) {
+ log.debug("鍧愭爣涓虹┖涓嶅紩瀵�");
+ return;
+ }
+ double[] coordinate = new double[]{ardAlarmRadarMove.getLongitude(), ardAlarmRadarMove.getLatitude()};//鎶ヨ鍧愭爣
+ //寮曞鍏ラ槦
+ radarGuideToQueue(ardAlarmRadarMove.getId(), ardAlarmRadarMove.getRadarId(), ardAlarmRadarMove.getName(), ardAlarmRadarMove.getAlarmType(), ardAlarmRadarMove.getCreateTime(), coordinate);//鏇存柊
+ }
+ //闆疯揪闃茬伀寮曞
+ private void radarFireGuide(ArdAlarmRadarFire ardAlarmRadarFire) {
+ if (StringUtils.isNull(ardAlarmRadarFire.getLongitude()) || StringUtils.isNull(ardAlarmRadarFire.getLatitude())) {
+ log.debug("鍧愭爣涓虹┖涓嶅紩瀵�");
+ return;
+ }
+ double[] coordinate = new double[]{ardAlarmRadarFire.getLongitude(), ardAlarmRadarFire.getLatitude()};//鎶ヨ鍧愭爣
+ //寮曞鍏ラ槦
+ radarGuideToQueue(ardAlarmRadarFire.getId(), ardAlarmRadarFire.getRadarId(), ardAlarmRadarFire.getName(), ardAlarmRadarFire.getAlarmType(), ardAlarmRadarFire.getCreateTime(), coordinate);//鏇存柊
+ }
+ //闆疯揪鎶芥补鏈哄仠鏈哄紩瀵�
+ private void radarPumpGuide(ArdAlarmRadarPump ardAlarmRadarPump) {
+ if (StringUtils.isNull(ardAlarmRadarPump.getLongitude()) || StringUtils.isNull(ardAlarmRadarPump.getLatitude())) {
+ //鍧愭爣涓虹┖涓嶅紩瀵�
+ log.debug("鍧愭爣涓虹┖涓嶅紩瀵�");
+ return;
+ }
+ double[] coordinate = new double[]{ardAlarmRadarPump.getLongitude(), ardAlarmRadarPump.getLatitude()};//鎶ヨ鍧愭爣
+ //寮曞鍏ラ槦
+ radarGuideToQueue(ardAlarmRadarPump.getId(), ardAlarmRadarPump.getRadarId(), ardAlarmRadarPump.getName(), ardAlarmRadarPump.getAlarmType(), ardAlarmRadarPump.getCreateTime(), coordinate);//鏇存柊
+ }
+
+
+ //姣忎釜鐐逛綅鏈紩瀵兼鏁�
+ private Map<String, Integer> unGuideCountMapMove = new HashMap<>();
+ private Map<String, Integer> unGuideCountMapFire = new HashMap<>();
+ private Map<String, Integer> unGuideCountMapPump = new HashMap<>();
private void radarMoveGuide(List<ArdAlarmRadarMove> ardAlarmRadarMoves, RadarAlarmData radarAlarmData) {
//鎸夊叴瓒g偣鍘婚噸,鐒跺悗鎸夊紩瀵奸�昏緫杩涜寮曞鍏ラ槦
ardAlarmRadarMoves = ardAlarmRadarMoves.stream()
@@ -1357,7 +1452,6 @@
}
//endregion
}
- //闆疯揪闃茬伀寮曞
private void radarFireGuide(List<ArdAlarmRadarFire> ardAlarmRadarFires, RadarAlarmData radarAlarmData) {
//鎸夊叴瓒g偣鍘婚噸,鐒跺悗鎸夊紩瀵奸�昏緫杩涜寮曞鍏ラ槦
ardAlarmRadarFires = ardAlarmRadarFires.stream()
@@ -1409,7 +1503,6 @@
}
//endregion
}
- //闆疯揪鎶芥补鏈哄仠鏈哄紩瀵�
private void radarPumpGuide(List<ArdAlarmRadarPump> ardAlarmRadarPumps, RadarAlarmData radarAlarmData) {
//鎸夊叴瓒g偣鍘婚噸,鐒跺悗鎸夊紩瀵奸�昏緫杩涜寮曞鍏ラ槦
ardAlarmRadarPumps = ardAlarmRadarPumps.stream()
@@ -1461,4 +1554,5 @@
}
//endregion
}
+
}
--
Gitblit v1.9.3