|
@@ -609,13 +609,14 @@ public class AlarmHandleServiceImpl implements AlarmHandleService {
|
|
|
// alarmLastTimeCache.put(alarmId, Integer.valueOf(String.valueOf(lastTime)));
|
|
|
// log.debug("开始拼装报警持续消息");
|
|
|
// initAlarmContinueMsg(alarmId, lastTime, paramMap, alarmDefine.getProjectId());
|
|
|
- ObjectMapper objectMapper = new ObjectMapper();
|
|
|
- ObjectNode objectNode = objectMapper.createObjectNode();
|
|
|
- objectNode.put("id", alarmId);
|
|
|
- objectNode.put("lastTime", lastTime);
|
|
|
- objectNode.set("iotData", objectMapper.readTree(objectMapper.writeValueAsString(paramMap)));
|
|
|
- objectNode.put("groupCode", groupCode);
|
|
|
- this.sendToMQ(JSONObject.parseObject(JSONObject.toJSONString(objectNode)), alarmId, alarmDefine);
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ ObjectNode objectNode = objectMapper.createObjectNode();
|
|
|
+ objectNode.put("id", alarmId);
|
|
|
+ objectNode.put("lastTime", lastTime);
|
|
|
+ objectNode.set("iotData", objectMapper.readTree(objectMapper.writeValueAsString(paramMap)));
|
|
|
+ objectNode.put("groupCode", groupCode);
|
|
|
+ //推送报警持续消息到MQ
|
|
|
+ this.sendToMQ(JSONObject.parseObject(JSONObject.toJSONString(objectNode)),alarmId,alarmDefine.getProjectId());
|
|
|
}
|
|
|
}
|
|
|
// 之前是是正常状态
|
|
@@ -662,7 +663,7 @@ public class AlarmHandleServiceImpl implements AlarmHandleService {
|
|
|
log.debug("生效时间为:[{}]", condition.getEffectTime());
|
|
|
alarmConditionState.reset();
|
|
|
}
|
|
|
- alarmInfoCache.setAlarmState(defineId, alarmConditionState);
|
|
|
+ alarmRedisCache.setAlarmState(defineId, alarmConditionState);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -774,39 +775,54 @@ public class AlarmHandleServiceImpl implements AlarmHandleService {
|
|
|
return zktAlarmRecordDO;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * @description: 发送创建报警记录消息
|
|
|
- * @param: alarmId 报警id
|
|
|
- * @param: alarmDefine 报警定义
|
|
|
- * @param: triggerTime 触发时间
|
|
|
- * @param: triggerInfo 触发值
|
|
|
- * @param: expireDate 过期时间
|
|
|
- * @return: void
|
|
|
- * @exception:
|
|
|
- * @author: lixing
|
|
|
- * @company: Persagy Technology Co.,Ltd
|
|
|
- * @since: 2021/1/8 下午5:38
|
|
|
- * @version: V1.0
|
|
|
- */
|
|
|
- private void sendCreateAlarmRecordMessage(String alarmId, AlarmDefine alarmDefine, String triggerTime,
|
|
|
- HashMap<String, Object> triggerInfo, Date expireDate) throws InterruptedException {
|
|
|
- Condition condition = alarmDefine.getCondition();
|
|
|
- AlarmRecord alarmRecord = AlarmRecord.builder().id(alarmId).category(alarmDefine.getCategory())
|
|
|
- .concern(alarmDefine.getConcern()).level(alarmDefine.getLevel()).projectId(alarmDefine.getProjectId())
|
|
|
- .state(1).triggerTime(DateUtils.parseDate(triggerTime)).remark(alarmDefine.getRemark())
|
|
|
- .triggerInfo(JSONObject.toJSONString(triggerInfo)).condition(condition.toString())
|
|
|
- .effectEndTime(expireDate).groupCode(groupCode).itemCode(alarmDefine.getItemCode())
|
|
|
- .objId(alarmDefine.getObjId()).classCode(alarmDefine.getClassCode()).createUser(systemId).treatState(1)
|
|
|
- .build();
|
|
|
- // TODO: 2021/11/16 消息发送至mq
|
|
|
- this.sendToMQ(JSONObject.parseObject(JSONObject.toJSONString(alarmRecord)), alarmId, alarmDefine);
|
|
|
- }
|
|
|
|
|
|
- public void sendToMQ(JSONObject message, String alarmId, AlarmDefine alarmDefine) {
|
|
|
+ /**
|
|
|
+ * @description: 发送创建报警记录消息
|
|
|
+ * @param: alarmId 报警id
|
|
|
+ * @param: alarmDefine 报警定义
|
|
|
+ * @param: triggerTime 触发时间
|
|
|
+ * @param: triggerInfo 触发值
|
|
|
+ * @param: expireDate 过期时间
|
|
|
+ * @return: void
|
|
|
+ * @exception:
|
|
|
+ * @author: lixing
|
|
|
+ * @company: Persagy Technology Co.,Ltd
|
|
|
+ * @since: 2021/1/8 下午5:38
|
|
|
+ * @version: V1.0
|
|
|
+ */
|
|
|
+ private void sendCreateAlarmRecordMessage(
|
|
|
+ String alarmId,
|
|
|
+ AlarmDefine alarmDefine, String triggerTime,
|
|
|
+ HashMap<String, Object> triggerInfo, Date expireDate) throws InterruptedException {
|
|
|
+ Condition condition = alarmDefine.getCondition();
|
|
|
+ AlarmRecord alarmRecord = AlarmRecord.builder()
|
|
|
+ .id(alarmId)
|
|
|
+ .category(alarmDefine.getCategory())
|
|
|
+ .concern(alarmDefine.getConcern())
|
|
|
+ .level(alarmDefine.getLevel())
|
|
|
+ .projectId(alarmDefine.getProjectId())
|
|
|
+ .state(1)
|
|
|
+ .triggerTime(DateUtils.parseDate(triggerTime))
|
|
|
+ .remark(alarmDefine.getRemark())
|
|
|
+ .triggerInfo(JSONObject.toJSONString(triggerInfo))
|
|
|
+ .condition(condition.toString())
|
|
|
+ .effectEndTime(expireDate)
|
|
|
+ .groupCode(groupCode)
|
|
|
+ .itemCode(alarmDefine.getItemCode())
|
|
|
+ .objId(alarmDefine.getObjId())
|
|
|
+ .classCode(alarmDefine.getClassCode())
|
|
|
+ .createUser(systemId)
|
|
|
+ .treatState(1)
|
|
|
+ .build();
|
|
|
+ // TODO: 2021/11/16 消息发送至mq
|
|
|
+ this.sendToMQ(JSONObject.parseObject(JSONObject.toJSONString(alarmRecord)),alarmId,alarmDefine.getProjectId());
|
|
|
+ }
|
|
|
+
|
|
|
+ public void sendToMQ(JSONObject message,String alarmId,String projectId){
|
|
|
DmpMessage dmpMessage = new DmpMessage();
|
|
|
dmpMessage.setDefaultValue();
|
|
|
dmpMessage.setMid(alarmId);
|
|
|
- dmpMessage.setProjectId(alarmDefine.getProjectId());
|
|
|
+ dmpMessage.setProjectId(projectId);
|
|
|
dmpMessage.setGroupCode(groupCode);
|
|
|
dmpMessage.setExts(message);
|
|
|
rabbitTemplate.convertAndSend(RabbitConfig.exchange, RabbitConfig.alarmMsgRoutingKey,
|