From 9028d0694549df46adf4cca71de823b5b35fc4c8 Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期三, 19 三月 2025 11:47:20 +0800 Subject: [PATCH] 调整速率有效期内,跳过执行 --- shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelPredictFinishConsumer.java | 29 ++++++++++++++++++++--------- 1 files changed, 20 insertions(+), 9 deletions(-) diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelPredictFinishConsumer.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelPredictFinishConsumer.java index 422f03d..c6c647b 100644 --- a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelPredictFinishConsumer.java +++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelPredictFinishConsumer.java @@ -20,6 +20,7 @@ import javax.annotation.Resource; import java.math.BigDecimal; import java.util.*; +import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; /** @@ -40,9 +41,9 @@ @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<>(); /** * 监听预测完成,产生预警消息 @@ -62,8 +63,15 @@ } // 预测时间 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) || @@ -186,13 +194,16 @@ } } - 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(); -- Gitblit v1.9.3