From 097ee6692bea4d243d80756f2d4b21e431a7c724 Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期二, 18 三月 2025 19:39:19 +0800
Subject: [PATCH] 生产预警消息

---
 shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelPredictFinishConsumer.java |   21 +++++++++++----------
 1 files changed, 11 insertions(+), 10 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..422f03d 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
@@ -42,6 +42,8 @@
 
     private static String lastRunAlarm = "";
 
+    private static Map<String, Long> lastRunTime = new HashMap<>();
+
     /**
      * 监听预测完成,产生预警消息
      *
@@ -68,17 +70,13 @@
                     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 +84,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());
@@ -195,6 +197,5 @@
         } catch (Exception e) {
             e.printStackTrace();
         }
-
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3