|
@@ -173,7 +173,7 @@ public class AlarmHandleServiceImpl implements AlarmHandleService {
|
|
|
private void triggerOrEndAlarm(String dataTime, String meterId, String itemCode, HashMap<String, Object> paramMap)
|
|
|
throws Exception {
|
|
|
// 获取设备的报警条件
|
|
|
- ObjConditionInfo objConditionInfo = alarmInfoCache.getAlarmConditionsByObjId(meterId);
|
|
|
+ ObjConditionInfo objConditionInfo = alarmRedisCache.getAlarmConditionsByObjId(meterId);
|
|
|
if (objConditionInfo == null || CollectionUtils.isEmpty(objConditionInfo.getConditions())) {
|
|
|
log.warn("未获取到设备{}的报警条件", meterId);
|
|
|
return;
|
|
@@ -188,7 +188,7 @@ public class AlarmHandleServiceImpl implements AlarmHandleService {
|
|
|
for (ItemCodeCondition itemCodeCondition : itemCodeConditions) {
|
|
|
String conditionId = itemCodeCondition.getConditionId();
|
|
|
// AlarmCondition alarmCondition = alarmInfoCache.getAlarmCondition(conditionId);
|
|
|
- AlarmCondition alarmCondition = alarmRedisCache.getAlarmConditionRedis(conditionId);
|
|
|
+ AlarmCondition alarmCondition = alarmRedisCache.getAlarmCondition(conditionId);
|
|
|
|
|
|
// 解析触发和恢复条件
|
|
|
String trigger = alarmCondition.getTriggerBackend();
|
|
@@ -618,8 +618,8 @@ public class AlarmHandleServiceImpl implements AlarmHandleService {
|
|
|
objectNode.put("lastTime", lastTime);
|
|
|
objectNode.set("iotData", objectMapper.readTree(objectMapper.writeValueAsString(paramMap)));
|
|
|
objectNode.put("groupCode", groupCode);
|
|
|
- rabbitTemplate.convertAndSend(RabbitConfig.exchange, RabbitConfig.alarmMsgRoutingKey, JSON.toJSONString(objectNode));
|
|
|
- }
|
|
|
+ this.sendToMQ(JSONObject.parseObject(JSONObject.toJSONString(objectNode)),alarmId,alarmDefine);
|
|
|
+ }
|
|
|
}
|
|
|
//之前是是正常状态
|
|
|
if (AlarmConditionState.State.NORMAL.getType().equals(alarmConditionState.getState())) {
|
|
@@ -816,13 +816,17 @@ public class AlarmHandleServiceImpl implements AlarmHandleService {
|
|
|
.createUser(systemId)
|
|
|
.treatState(1)
|
|
|
.build();
|
|
|
- DmpMessage dmpMessage = new DmpMessage();
|
|
|
- dmpMessage.setDefaultValue();
|
|
|
- dmpMessage.setMid(alarmId);
|
|
|
- dmpMessage.setProjectId(alarmDefine.getProjectId());
|
|
|
- dmpMessage.setGroupCode(groupCode);
|
|
|
- dmpMessage.setExts(JSONObject.parseObject(JSONObject.toJSONString(alarmRecord)));
|
|
|
// TODO: 2021/11/16 消息发送至mq
|
|
|
- rabbitTemplate.convertAndSend(RabbitConfig.exchange, RabbitConfig.alarmMsgRoutingKey, JSON.toJSONString(dmpMessage));
|
|
|
+ this.sendToMQ(JSONObject.parseObject(JSONObject.toJSONString(alarmRecord)),alarmId,alarmDefine);
|
|
|
}
|
|
|
+
|
|
|
+ public void sendToMQ(JSONObject message,String alarmId,AlarmDefine alarmDefine){
|
|
|
+ DmpMessage dmpMessage = new DmpMessage();
|
|
|
+ dmpMessage.setDefaultValue();
|
|
|
+ dmpMessage.setMid(alarmId);
|
|
|
+ dmpMessage.setProjectId(alarmDefine.getProjectId());
|
|
|
+ dmpMessage.setGroupCode(groupCode);
|
|
|
+ dmpMessage.setExts(message);
|
|
|
+ rabbitTemplate.convertAndSend(RabbitConfig.exchange, RabbitConfig.alarmMsgRoutingKey, JSON.toJSONString(dmpMessage));
|
|
|
+ }
|
|
|
}
|