Browse Source

告警处理各个型号,针对告警缺少传递的字段

yf_zn 9 months atrás
parent
commit
1fcdde63f5

+ 4 - 1
src/main/java/com/yunfeiyun/agmp/iots/device/serviceImp/BzyDeviceImpl.java

@@ -194,6 +194,7 @@ public class BzyDeviceImpl extends DeviceAbstractImpl implements IBzyDevice {
         newIotDevice.setDevtypeBid(devtypeBid);
         newIotDevice.setDevUpdateddate(devUpdateddate);
         newIotDevice.setDevStatus(IotDeviceStatusTypeEnum.ONLINE.getCode());
+        newIotDevice.setDevOriginalStatus(oldIotDevice.getDevOriginalStatus());
 
         HashMap<String, String> keyMaps = new HashMap<>();
         keyMaps.put("dver", "devVersion");
@@ -241,13 +242,15 @@ public class BzyDeviceImpl extends DeviceAbstractImpl implements IBzyDevice {
         newIotDevice.setDevBid(oldIotDevice.getDevBid());
         newIotDevice.setDevStatus("0");
         newIotDevice.setDevOfflinedate(DateUtils.dateTimeNow());
-        iIotDeviceService.updateIotDevice(newIotDevice);
         //这些参数预警需要用,携带过去
         newIotDevice.setTid(oldIotDevice.getTid());
         newIotDevice.setDevtypeBid(oldIotDevice.getDevtypeBid());
         newIotDevice.setDevCreateddate(oldIotDevice.getDevCreateddate());
         newIotDevice.setDevUpdateddate(oldIotDevice.getDevUpdateddate());
         newIotDevice.setDevCode(oldIotDevice.getDevCode());
+        newIotDevice.setDevOriginalStatus(oldIotDevice.getDevOriginalStatus());
+        iIotDeviceService.updateIotDevice(newIotDevice);
+
         //发送离线预警
         SpringUtils.getBean(WarnService.class).processWarningOfflineData(newIotDevice, ext);
     }

+ 3 - 2
src/main/java/com/yunfeiyun/agmp/iots/device/serviceImp/CqCbdDeviceImpl.java

@@ -298,11 +298,12 @@ public class CqCbdDeviceImpl extends DeviceAbstractImpl implements ICbdDevice {
         newIotDevice.setDevOfflinedate(DateUtils.dateTimeNow());
         newIotDevice.setTid(iotDevice.getTid());
         newIotDevice.setDevtypeBid(iotDevice.getDevtypeBid());
-
-        iIotDeviceService.updateIotDevice(newIotDevice);
+        newIotDevice.setDevOriginalStatus(iotDevice.getDevOriginalStatus());
         newIotDevice.setDevCreateddate(iotDevice.getDevCreateddate());
         newIotDevice.setDevUpdateddate(iotDevice.getDevUpdateddate());
         newIotDevice.setDevCode(iotDevice.getDevCode());
+        iIotDeviceService.updateIotDevice(newIotDevice);
+
 
         //发送离线预警
         SpringUtils.getBean(WarnService.class).processWarningOfflineData(newIotDevice, ext);

+ 4 - 1
src/main/java/com/yunfeiyun/agmp/iots/device/serviceImp/IYfXctDeviceImpl.java

@@ -155,6 +155,7 @@ public class IYfXctDeviceImpl extends DeviceAbstractImpl implements IYfXctDevice
         newIotDevice.setDevtypeBid(oldIotDevice.getDevtypeBid());
         newIotDevice.setDevUpdateddate(devUpdateddate);
         newIotDevice.setDevStatus(IotDeviceStatusTypeEnum.ONLINE.getCode());
+        newIotDevice.setDevOriginalStatus(oldIotDevice.getDevOriginalStatus());
 
         HashMap<String, String> keyMaps = new HashMap<>();
         keyMaps.put("dver", "devVersion");
@@ -242,10 +243,12 @@ public class IYfXctDeviceImpl extends DeviceAbstractImpl implements IYfXctDevice
         newIotDevice.setDevOfflinedate(DateUtils.dateTimeNow());
         newIotDevice.setTid(iotDevice.getTid());
         newIotDevice.setDevtypeBid(iotDevice.getDevtypeBid());
-        iIotDeviceService.updateIotDevice(newIotDevice);
         newIotDevice.setDevCreateddate(iotDevice.getDevCreateddate());
         newIotDevice.setDevUpdateddate(iotDevice.getDevUpdateddate());
         newIotDevice.setDevCode(iotDevice.getDevCode());
+        newIotDevice.setDevOriginalStatus(iotDevice.getDevOriginalStatus());
+        iIotDeviceService.updateIotDevice(newIotDevice);
+
 
         //发送离线预警
         SpringUtils.getBean(WarnService.class).processWarningOfflineData(newIotDevice, ext);

+ 4 - 1
src/main/java/com/yunfeiyun/agmp/iots/device/serviceImp/XphYfQxzDeviceImpl.java

@@ -249,6 +249,7 @@ public class XphYfQxzDeviceImpl extends DeviceAbstractImpl implements IXphYfQxzD
         iotDevice.setDevCode(devCode);
         iotDevice.setDevBid(iotDeviceOld.getDevBid());
         iotDevice.setDevVersion(jobjStatus.getString("Version"));
+        iotDevice.setDevOriginalStatus(iotDeviceOld.getDevOriginalStatus());
 
         String lng = jobjStatus.getString("longitude");
         String lat = jobjStatus.getString("latitude");
@@ -308,10 +309,12 @@ public class XphYfQxzDeviceImpl extends DeviceAbstractImpl implements IXphYfQxzD
         newIotDevice.setTid(iotDeviceOld.getTid());
         newIotDevice.setDevUpdateddate(devUpdateddate);
         newIotDevice.setDevtypeBid(iotDeviceOld.getDevtypeBid());
-        iIotDeviceService.updateIotDevice(newIotDevice);
         newIotDevice.setDevCreateddate(iotDeviceOld.getDevCreateddate());
         newIotDevice.setDevUpdateddate(iotDeviceOld.getDevUpdateddate());
         newIotDevice.setDevCode(iotDeviceOld.getDevCode());
+        newIotDevice.setDevOriginalStatus(iotDeviceOld.getDevOriginalStatus());
+        iIotDeviceService.updateIotDevice(newIotDevice);
+
 
         //发送离线预警
         SpringUtils.getBean(WarnService.class).processWarningOfflineData(newIotDevice, dataJson);

+ 4 - 1
src/main/java/com/yunfeiyun/agmp/iots/device/serviceImp/YfQxzDeviceImpl.java

@@ -396,6 +396,7 @@ public class YfQxzDeviceImpl extends DeviceAbstractImpl implements IYfQxzDevice
         iotDevice.setFirmBid(iotDeviceOld.getFirmBid());
         iotDevice.setDevUpdateddate(devUpdateddate);
         iotDevice.setDevStatus("1");
+        iotDevice.setDevOriginalStatus(iotDeviceOld.getDevOriginalStatus());
 
         iotDevice.setDevCode(devCode);
         iotDevice.setDevBid(iotDeviceOld.getDevBid());
@@ -458,10 +459,12 @@ public class YfQxzDeviceImpl extends DeviceAbstractImpl implements IYfQxzDevice
             newIotDevice.setDevStatus("1");
             newIotDevice.setDevUpdateddate(devUpdateddate);
         }
-        iIotDeviceService.updateIotDevice(newIotDevice);
+        newIotDevice.setDevOriginalStatus(iotDeviceOld.getDevOriginalStatus());
         newIotDevice.setDevCreateddate(iotDeviceOld.getDevCreateddate());
         newIotDevice.setDevUpdateddate(iotDeviceOld.getDevUpdateddate());
         newIotDevice.setDevCode(iotDeviceOld.getDevCode());
+        iIotDeviceService.updateIotDevice(newIotDevice);
+
 
         //发送离线预警
         SpringUtils.getBean(WarnService.class).processWarningOfflineData(newIotDevice, ext);

+ 4 - 2
src/main/java/com/yunfeiyun/agmp/iots/device/serviceImp/YfScdDeviceImpl.java

@@ -160,7 +160,7 @@ public class YfScdDeviceImpl extends DeviceAbstractImpl implements IYfScdDevice
         iotDevice.setDevBid(oldIotDevice.getDevBid());
         iotDevice.setDevUpdateddate(devUpdateddate);
         iotDevice.setDevStatus("1");//设备上线
-
+        iotDevice.setDevOriginalStatus(oldIotDevice.getDevOriginalStatus());
         HashMap<String, String> keyMaps = new HashMap<>();
         keyMaps.put("dver", "devVersion");
         keyMaps.put("imei", "devCode");
@@ -230,10 +230,12 @@ public class YfScdDeviceImpl extends DeviceAbstractImpl implements IYfScdDevice
         newIotDevice.setDevOfflinedate(DateUtils.dateTimeNow());
         newIotDevice.setTid(oldIotDevice.getTid());
         newIotDevice.setDevtypeBid(oldIotDevice.getDevtypeBid());
-        iIotDeviceService.updateIotDevice(newIotDevice);
         newIotDevice.setDevCreateddate(oldIotDevice.getDevCreateddate());
         newIotDevice.setDevUpdateddate(oldIotDevice.getDevUpdateddate());
         newIotDevice.setDevCode(oldIotDevice.getDevCode());
+        newIotDevice.setDevOriginalStatus(oldIotDevice.getDevOriginalStatus());
+        iIotDeviceService.updateIotDevice(newIotDevice);
+
 
         //发送离线预警
         SpringUtils.getBean(WarnService.class).processWarningOfflineData(newIotDevice, dataJson);

+ 1 - 0
src/main/java/com/yunfeiyun/agmp/iots/device/serviceImp/YfXycb2DeviceImpl.java

@@ -90,6 +90,7 @@ public class YfXycb2DeviceImpl extends DeviceAbstractImpl implements IYfXycb2Dev
         newIotDevice.setDevVersion("YF-XY-2.0");
         newIotDevice.setDevUpdateddate(devUpdateddate);
         newIotDevice.setDevStatus(IotDeviceStatusTypeEnum.ONLINE.getCode());
+        newIotDevice.setDevOriginalStatus(oldIotDevice.getDevOriginalStatus());
 
         // 更新设备基础信息数据库 mysql
         iIotDeviceService.updateIotDevice(newIotDevice);

+ 4 - 2
src/main/java/com/yunfeiyun/agmp/iots/device/serviceImp/YfXycbIIIDeviceImpl.java

@@ -208,11 +208,13 @@ public class YfXycbIIIDeviceImpl extends DeviceAbstractImpl implements IYfXycbII
         newIotDevice.setDevOfflinedate(devUpdateddate);
         newIotDevice.setTid(oldIotDevice.getTid());
         newIotDevice.setDevtypeBid(oldIotDevice.getDevtypeBid());
-
-        iIotDeviceService.updateIotDevice(newIotDevice);
         newIotDevice.setDevCreateddate(oldIotDevice.getDevCreateddate());
         newIotDevice.setDevUpdateddate(oldIotDevice.getDevUpdateddate());
         newIotDevice.setDevCode(oldIotDevice.getDevCode());
+        newIotDevice.setDevOriginalStatus(oldIotDevice.getDevOriginalStatus());
+        iIotDeviceService.updateIotDevice(newIotDevice);
+
+
         //发送离线预警
         SpringUtils.getBean(WarnService.class).processWarningOfflineData(newIotDevice, dataJson);
         /**

+ 1 - 0
src/main/java/com/yunfeiyun/agmp/iots/task/IotStatusService.java

@@ -150,6 +150,7 @@ public class IotStatusService {
         IotDevice iotDevice = new IotDevice();
         iotDevice.setDevCode(iotDeviceStatusResVo.getDevCode());
         iotDevice.setDevBid(iotDeviceStatusResVo.getDevBid());
+        iotDevice.setDevOriginalStatus(iotDeviceStatusResVo.getDevStatus());
         iotDevice.setDevStatus(IotDeviceStatusTypeEnum.OFFLINE.getCode());
         iotDevice.setDevOfflinedate(DateUtils.dateTimeNow());
         iotDevice.setDevModifieddate(DateUtils.dateTimeNow());

+ 5 - 2
src/main/java/com/yunfeiyun/agmp/iots/warn/service/WarnService.java

@@ -111,7 +111,7 @@ public class WarnService {
                             warnResult.setConfig(warnConfigInfo);
                             warnResult.setOffline(true);
                             warnResult.setTriggered(true);
-                            warnResult.setMessage(WarnMessageBuilderUtil.buildWarningOfflineMessage(iotDevice.getDevtypeBid(), iotDevice.getDevCode(),  StringUtils.isEmpty(iotDevice.getDevUpdateddate())?iotDevice.getDevCreateddate():iotDevice.getDevUpdateddate()));
+                            warnResult.setMessage(WarnMessageBuilderUtil.buildWarningOfflineMessage(iotDevice.getDevtypeBid(), iotDevice.getDevCode(), StringUtils.isEmpty(iotDevice.getDevUpdateddate()) ? iotDevice.getDevCreateddate() : iotDevice.getDevUpdateddate()));
                             // 处理警告记录前的日志
                             log.info("[设备告警] 正在为设备{}处理警告记录:{}", iotDevice.getDevBid(), warnResult);
                             handleWarnRecord(warnResult);
@@ -545,12 +545,15 @@ public class WarnService {
         CompletableFuture.runAsync(() -> {
             try {
                 for (IotDevice iotDevice : iotDeviceList) {
+
                     //离线转在线
                     if (IotDeviceStatusTypeEnum.OFFLINE.getCode().equals(iotDevice.getDevOriginalStatus())
                             && IotDeviceStatusTypeEnum.ONLINE.getCode().equals(iotDevice.getDevStatus()
                     )) {
-                        log.info("[离线告警]自动处理离线告警消息: {}", iotDevice.getDevBid());
+                        log.info("[离线告警]自动处理离线告警消息:设备号: {} ,bid:{}", iotDevice.getDevCode(), iotDevice.getDevBid());
                         autoDealWarnOfflineLog(iotDevice.getDevBid());
+                    } else {
+                        log.info("[离线告警]自动处理离线告警消息:设备号: {} ,bid:{} ,原始状态:", iotDevice.getDevCode(), iotDevice.getDevBid(), iotDevice.getDevOriginalStatus());
                     }
                 }
             } catch (Exception e) {