From c6b6d7723a2ca2d6fb9d940e5ff10a6a2d111c70 Mon Sep 17 00:00:00 2001 From: Jay <csj123456> Date: 星期四, 27 三月 2025 10:50:31 +0800 Subject: [PATCH] 压缩空气班次指标累积评价修改参数长度 --- shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelPredictFinishConsumer.java | 48 ++++++++++++++++++++++++++++++------------------ 1 files changed, 30 insertions(+), 18 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 cd34c1d..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,7 +41,9 @@ @Resource private RabbitTemplate rabbitTemplate; - private static String lastRunAlarm = ""; + private static Map<String, Long> lastRunTime = new ConcurrentHashMap<>(); + + public static Map<Long, List<String>> finishModuleMap = new ConcurrentHashMap<>(); /** * 监听预测完成,产生预警消息 @@ -60,25 +63,28 @@ } // 预测时间 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) || moduleType.equals(CommonConstant.NET_LDG2) || moduleType.equals(CommonConstant.NET_LDG3)) { log.info("moduleType:" + moduleType); - String runKey = "GasAlarm_" + predictTime.getTime(); - log.info("runKey:" + runKey); - log.info("lastRunAlarm:" + lastRunAlarm); - if (lastRunAlarm.equals(runKey)) { + if (lastRunTime.containsKey(moduleType) && lastRunTime.get(moduleType) == predictTime.getTime()) { + log.info("moduleType return"); return; } - lastRunAlarm = runKey; - - // 预警信息列表 - List<AlarmMessageRespDTO> alarmList = new ArrayList<>(); - // 根据管网查询相关预警配置 + lastRunTime.put(moduleType, predictTime.getTime()); + log.info("lastRunTime=" + JSONObject.toJSONString(lastRunTime)); + log.info("开始处理预警"); Map<String, Object> params = new HashMap<>(); params.put("alarmObj", moduleType); List<AlarmConfigRespDTO> configList = mcsApi.listAlarmConfig(params); @@ -86,6 +92,10 @@ log.info("AlarmConfigList is empty"); return; } + log.info("configList=" + JSONArray.toJSONString(configList)); + + // 预警信息列表 + List<AlarmMessageRespDTO> alarmList = new ArrayList<>(); List<String> outputIdList = configList.stream().map(item -> { return item.getOutId(); }).collect(Collectors.toList()); @@ -184,17 +194,19 @@ } } - 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(); } - } } \ No newline at end of file -- Gitblit v1.9.3