| | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | @Resource |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | private static String lastRunAlarm = ""; |
| | | private static Map<String, Long> lastRunTime = new ConcurrentHashMap<>(); |
| | | |
| | | private static Map<String, Long> lastRunTime = new HashMap<>(); |
| | | public static Map<Long, List<String>> finishModuleMap = new ConcurrentHashMap<>(); |
| | | |
| | | /** |
| | | * 监听预测完成,产生预警消息 |
| | |
| | | } |
| | | // 预测时间 |
| | | Date predictTime = DateUtils.parse(messageJson.get("predictTime").toString(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND); |
| | | // 预测模块/预测管网 |
| | | // 预测管网 |
| | | String moduleType = messageJson.get("moduleType").toString(); |
| | | if (!finishModuleMap.containsKey(predictTime.getTime())) { |
| | | List<String> mList = new ArrayList<>(); |
| | | finishModuleMap.put(predictTime.getTime(), mList); |
| | | } |
| | | finishModuleMap.get(predictTime.getTime()).add(moduleType); |
| | | log.info("finishModuleMap:" + JSONObject.toJSONString(finishModuleMap)); |
| | | |
| | | if (moduleType.equals(CommonConstant.NET_BFG) || moduleType.equals(CommonConstant.NET_COG) || |
| | | moduleType.equals(CommonConstant.NET_LDG) || |
| | | moduleType.equals(CommonConstant.NET_LDG1) || |
| | |
| | | } |
| | | } |
| | | |
| | | if (!CollectionUtils.isEmpty(alarmList)) { |
| | | log.info("发送预警消息"); |
| | | Map<String, Object> msg = new HashMap<>(2); |
| | | msg.put("predictTime", DateUtils.format(predictTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); |
| | | msg.put("alarmList", alarmList); |
| | | rabbitTemplate.convertAndSend(RoutingConstant.EXCHANGE, RoutingConstant.Iailab_Model_Alarm, msg); |
| | | if (CollectionUtils.isEmpty(alarmList)) { |
| | | log.info("alarmList is empty"); |
| | | return; |
| | | } |
| | | log.info("发送预警消息"); |
| | | Map<String, Object> msg = new HashMap<>(2); |
| | | msg.put("predictTime", DateUtils.format(predictTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); |
| | | msg.put("alarmList", alarmList); |
| | | msg.put("moduleType", moduleType); |
| | | rabbitTemplate.convertAndSend(RoutingConstant.EXCHANGE, RoutingConstant.Iailab_Model_Alarm, msg); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |