| | |
| | | @Resource |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | private static String lastRunAlarm = ""; |
| | | |
| | | /** |
| | | * 监听预测完成,产生预警消息 |
| | | * |
| | |
| | | if (CollectionUtils.isEmpty(messageJson)) { |
| | | return; |
| | | } |
| | | // 预测时间 |
| | | Date predictTime = DateUtils.parse(messageJson.get("predictTime").toString(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND); |
| | | |
| | | // 预测模块/预测管网 |
| | | String moduleType = messageJson.get("moduleType").toString(); |
| | | // 查询相关预警配置 |
| | | List<AlarmConfigRespDTO> configList = mcsApi.listAlarmConfig(new HashMap<String, Object>()); |
| | | if (CollectionUtils.isEmpty(configList)) { |
| | |
| | | List<String> outputIdList = configList.stream().map(item -> { |
| | | return item.getOutId(); |
| | | }).collect(Collectors.toList()); |
| | | |
| | | List<AlarmMessageRespDTO> alarmList = new ArrayList<>(); |
| | | if (moduleType.equals(CommonConstant.NET_BFG) || moduleType.equals(CommonConstant.NET_COG) || |
| | | moduleType.equals(CommonConstant.NET_LDG)) { |
| | | String runKey = "GasAlarm_" + predictTime.getTime(); |
| | | log.info("runKey:" + runKey); |
| | | log.info("lastRunAlarm:" + lastRunAlarm); |
| | | if (lastRunAlarm.equals(runKey)) { |
| | | return; |
| | | } |
| | | lastRunAlarm = runKey; |
| | | for (AlarmConfigRespDTO configItem : configList) { |
| | | PreDataJsonReqVO reqVO = new PreDataJsonReqVO(); |
| | | reqVO.setPredictTime(predictTime); |
| | |
| | | }).collect(Collectors.toList()).stream().mapToDouble(Double::doubleValue).sum(); |
| | | culData.put(key, new BigDecimal(nv)); |
| | | }); |
| | | |
| | | |
| | | List<Object[]> result = preData.get(configItem.getOutId()); |
| | | if (CollectionUtils.isEmpty(result)) { |
| | |
| | | alarmList.add(alarmMessage); |
| | | } |
| | | } |
| | | } |
| | | if (!CollectionUtils.isEmpty(alarmList)) { |
| | | log.info("发送预警消息"); |
| | | Map<String, Object> msg = new HashMap<>(2); |