|
@@ -18,6 +18,7 @@ import io.micrometer.core.instrument.util.JsonUtils;
|
|
|
import io.netty.channel.ChannelHandler;
|
|
|
import lombok.SneakyThrows;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
@@ -106,7 +107,7 @@ public class AlarmEngineMsgHandler {
|
|
|
*/
|
|
|
public void syncNewCondition(DmpMessage msg) {
|
|
|
AlarmCondition alarmCondition = JSONObject.parseObject(msg.getStr1(), AlarmCondition.class);
|
|
|
- redisUtil.put(RedisConstants.ALARM_CONDITIONS, alarmCondition.getId(), JSON.toJSONString(alarmCondition));
|
|
|
+ redisUtil.put(RedisConstants.ALARM_CONDITIONS, alarmCondition.getId(), alarmCondition);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -118,8 +119,7 @@ public class AlarmEngineMsgHandler {
|
|
|
*/
|
|
|
public void syncUpdatedCondition(DmpMessage msg) {
|
|
|
AlarmCondition alarmCondition = JSONObject.parseObject(msg.getStr1(), AlarmCondition.class);
|
|
|
- // TODO: 2021/11/16 更新redis
|
|
|
- redisUtil.put("ALARM_CONDITION", alarmCondition.getId(), JSON.toJSONString(alarmCondition));
|
|
|
+ redisUtil.put(RedisConstants.ALARM_CONDITIONS, alarmCondition.getId(), alarmCondition);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -170,7 +170,7 @@ public class AlarmEngineMsgHandler {
|
|
|
condition.setItemCode(objConditionRel.getItemCode());
|
|
|
// 对象内部自己做去重操作
|
|
|
objConditionInfo.addCondition(condition);
|
|
|
- redisUtil.put(RedisConstants.OBJ_CONDITION_REL, objId, JSON.toJSONString(objConditionInfo));
|
|
|
+ redisUtil.put(RedisConstants.OBJ_CONDITION_REL, objId, objConditionInfo);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -196,7 +196,7 @@ public class AlarmEngineMsgHandler {
|
|
|
if (CollectionUtils.isEmpty(objConditionInfo.getConditions())) {
|
|
|
redisUtil.delete(RedisConstants.OBJ_CONDITION_REL, objId);
|
|
|
} else {
|
|
|
- redisUtil.put(RedisConstants.OBJ_CONDITION_REL, objId, JSON.toJSONString(objConditionInfo));
|
|
|
+ redisUtil.put(RedisConstants.OBJ_CONDITION_REL, objId, objConditionInfo);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -255,7 +255,7 @@ public class AlarmEngineMsgHandler {
|
|
|
if (CollectionUtil.isEmpty(conditionsRemain)) {
|
|
|
redisUtil.delete(RedisConstants.OBJ_CONDITION_REL, alarmConfigItem.getObjId());
|
|
|
} else {
|
|
|
- redisUtil.put(RedisConstants.OBJ_CONDITION_REL, alarmConfigItem.getObjId(), JSON.toJSONString(conditionsRemain));
|
|
|
+ redisUtil.put(RedisConstants.OBJ_CONDITION_REL, alarmConfigItem.getObjId(), conditionsRemain);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -265,8 +265,11 @@ public class AlarmEngineMsgHandler {
|
|
|
for (AlarmConfigItem alarmConfigItem : alarmConfigItems) {
|
|
|
// 数据中台报警条件转化为业务中台报警条件和设备与条件的关联关系
|
|
|
AlarmCondition alarmCondition = avgAlarmDmpCondition(alarmConfigItem);
|
|
|
+ if (alarmCondition == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
// 存储报警条件
|
|
|
- redisUtil.put(RedisConstants.ALARM_CONDITIONS, alarmCondition.getId(), JSON.toJSONString(alarmCondition));
|
|
|
+ redisUtil.put(RedisConstants.ALARM_CONDITIONS, alarmCondition.getId(), alarmCondition);
|
|
|
// 存储设备与条件的关联关系
|
|
|
ObjConditionRel objConditionRel = new ObjConditionRel();
|
|
|
objConditionRel.setConditionId(alarmCondition.getId());
|
|
@@ -283,6 +286,9 @@ public class AlarmEngineMsgHandler {
|
|
|
AlarmCondition alarmCondition = new AlarmCondition();
|
|
|
alarmCondition.setId(alarmConfigItem.getId());
|
|
|
List<String> infoCodes = new ArrayList<>();
|
|
|
+ if (alarmConfigItem.getCondition() == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
for (String infoCode : alarmConfigItem.getCondition().getInfoCode()) {
|
|
|
infoCodes.add(infoCode.replaceAll(alarmConfigItem.getObjId()+"_",""));
|
|
|
}
|
|
@@ -295,8 +301,12 @@ public class AlarmEngineMsgHandler {
|
|
|
//alarmCondition.setTriggerRules(alarmDmpCondition.getRules());
|
|
|
alarmCondition.setEndBackend(alarmConfigItem.getCondition().getEnd().replaceAll(alarmConfigItem.getObjId()+"_",""));
|
|
|
// alarmCondition.setEndRules(null);
|
|
|
- alarmCondition.setEffectTimeType(alarmConfigItem.getCondition().getEffectTime().getType());
|
|
|
- alarmCondition.setEffectTimeDetail(JSONObject.toJSONString(alarmConfigItem.getCondition().getEffectTime()));
|
|
|
+ String effectTime = alarmConfigItem.getCondition().getEffectTime();
|
|
|
+ if (StringUtils.isNotBlank(effectTime)) {
|
|
|
+ JSONObject effectTimeObj = JSONObject.parseObject(effectTime);
|
|
|
+ alarmCondition.setEffectTimeType(effectTimeObj.getString("type"));
|
|
|
+ alarmCondition.setEffectTimeDetail(effectTime);
|
|
|
+ }
|
|
|
return alarmCondition;
|
|
|
}
|
|
|
}
|