Browse Source

修复报警恢复时间错误的bug

lixing 3 years ago
parent
commit
201929195e

+ 2 - 2
src/main/java/com/persagy/entity/AlarmConditionState.java

@@ -25,11 +25,11 @@ public class AlarmConditionState {
      */
     private String expire = "0";
     /**
-     * 报警开始时间
+     * 触发报警时间
      */
     private String alarmStartTime = "";
     /**
-     * 报警中止(恢复)开始时间
+     * 触发报警恢复的时间
      */
     private String alarmSuspendStartTime = "";
 

+ 5 - 3
src/main/java/com/persagy/service/impl/AlarmHandleServiceImpl.java

@@ -346,9 +346,9 @@ public class AlarmHandleServiceImpl {
             AlarmDefine alarmDefine, String dataTime, Boolean endResult,
             HashMap<String, Object> paramMap) throws InterruptedException {
         String defineId = AlarmInfoCache.getAlarmDefineId(alarmDefine);
-        //        AlarmConditionState alarmConditionState = getAlarmDefineStateFromCacheOrDb(defineId);
         AlarmConditionState alarmConditionState = alarmRedisCache.getAlarmDefineState(defineId);
-
+        // 恢复报警,报警触发时间统计中断,清空触发报警时间的记录
+        alarmConditionState.setAlarmStartTime(null);
         Condition condition = alarmDefine.getCondition();
         // 当前数据正常,报警状态为正常:清空之前的报警计时,重置回默认状态
         if (AlarmConditionState.State.NORMAL.getType().equals(alarmConditionState.getState())) {
@@ -378,7 +378,7 @@ public class AlarmHandleServiceImpl {
             String alarmId = alarmRecordDO.getAlarmId();
             alarmRedisCache.lock(RedisConstant.alarmRecordLockPrefix + alarmId, alarmId, 10);
             // 发送报警恢复消息
-            sendAlarmRecoverMessage(alarmDefine.getProjectId(), alarmSuspendStartTime, paramMap, alarmId, alarmDefine.getItemCode());
+            sendAlarmRecoverMessage(alarmDefine.getProjectId(), dataTime, paramMap, alarmId, alarmDefine.getItemCode());
             // 取消过期任务
             cancelRelatedExpireJob(alarmId);
             // 报警恢复,报警状态重置回默认
@@ -485,6 +485,8 @@ public class AlarmHandleServiceImpl {
         // 根据defineId获取报警定义状态
         String defineId = AlarmInfoCache.getAlarmDefineId(alarmDefine);
         AlarmConditionState alarmConditionState = alarmRedisCache.getAlarmDefineState(defineId);
+        // 触发报警,报警恢复时间统计中断,清空触发报警恢复时间的记录
+        alarmConditionState.setAlarmSuspendStartTime(null);
         Condition condition = alarmDefine.getCondition();
         // 判断报警是否在有效期内
         boolean inEffectTime = ConditionUtils.inEffectiveTime(condition, dataTime);