Browse Source

修复报警条件不包含恢复时间导致的空指针问题

lixing 3 years ago
parent
commit
3460f1e657

+ 13 - 8
AlarmEngineStarter/src/main/java/com/persagy/apm/energyalarmstarter/alarmengine/jms/AlarmEngineMsgHandler.java

@@ -290,22 +290,27 @@ public class AlarmEngineMsgHandler {
         AlarmCondition alarmCondition = new AlarmCondition();
         alarmCondition.setId(alarmConfigItem.getId());
         List<String> infoCodes = new ArrayList<>();
-        if (alarmConfigItem.getCondition() == null) {
+        com.persagy.apm.energyalarmstarter.alarmdata.model.dto.AlarmCondition condition = alarmConfigItem.getCondition();
+        if (condition == null) {
             return null;
         }
-        for (String infoCode : alarmConfigItem.getCondition().getInfoCode()) {
+        for (String infoCode : condition.getInfoCode()) {
             infoCodes.add(infoCode.replaceAll(alarmConfigItem.getObjId()+"_",""));
         }
         alarmCondition.setInfoCodes(infoCodes);
-        alarmCondition.setConfigs(alarmConfigItem.getCondition().getConfigs());
-        alarmCondition.setTriggerBackend(alarmConfigItem.getCondition().getTrigger().replaceAll(alarmConfigItem.getObjId()+"_",""));
-        alarmCondition.setTriggerUphold(alarmConfigItem.getCondition().getTriggerUphold()/60);
+        alarmCondition.setConfigs(condition.getConfigs());
+        alarmCondition.setTriggerBackend(condition.getTrigger().replaceAll(alarmConfigItem.getObjId()+"_",""));
+        if (condition.getTriggerUphold() != null) {
+            alarmCondition.setTriggerUphold(condition.getTriggerUphold()/60);
+        }
         alarmCondition.setAlarmLevel(alarmConfigItem.getLevel());
-        alarmCondition.setEndUphold(alarmConfigItem.getCondition().getEndUphold()/60);
+        if (condition.getEndUphold() != null) {
+            alarmCondition.setEndUphold(condition.getEndUphold()/60);
+        }
         //alarmCondition.setTriggerRules(alarmDmpCondition.getRules());
-        alarmCondition.setEndBackend(alarmConfigItem.getCondition().getEnd().replaceAll(alarmConfigItem.getObjId()+"_",""));
+        alarmCondition.setEndBackend(condition.getEnd().replaceAll(alarmConfigItem.getObjId()+"_",""));
         //  alarmCondition.setEndRules(null);
-        String effectTime = alarmConfigItem.getCondition().getEffectTime();
+        String effectTime = condition.getEffectTime();
         if (StringUtils.isNotBlank(effectTime)) {
             JSONObject effectTimeObj = JSONObject.parseObject(effectTime);
             alarmCondition.setEffectTimeType(effectTimeObj.getString("type"));