From 72c8e506e13f3b35476bfd65bfe07c22bf23c755 Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期二, 25 三月 2025 07:15:48 +0800
Subject: [PATCH] 氧气调度 调整速率

---
 shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunLDGTankFactorPredTask.java |   25 +++++++++++++++----------
 1 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunLDGTankFactorPredTask.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunLDGTankFactorPredTask.java
index f7fec37..33bf2a0 100644
--- a/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunLDGTankFactorPredTask.java
+++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunLDGTankFactorPredTask.java
@@ -9,6 +9,9 @@
 import org.springframework.stereotype.Component;
 
 import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 /**
  * @description: LDG柜容预测 监听触发
@@ -39,23 +42,25 @@
     public void run(String params) {
         logger.info("runLDGTankFactorPredTask定时任务正在执行,参数为:{}", params);
         try {
+            //一次查询所有pointNo,减少请求
+            List<String> allPointNos = checkPoints.values().stream().flatMap(List::stream).collect(Collectors.toList());
+            Map<String, Object> pointsRealValue = dataPointApi.queryPointsRealValue(allPointNos);
+
             for (Map.Entry<String, List<String>> entry : checkPoints.entrySet()) {
-                Map<String, Object> pointsRealValue = dataPointApi.queryPointsRealValue(entry.getValue());
-                for (Map.Entry<String, Object> pointRealValue : pointsRealValue.entrySet()) {
-                    String pointNo = pointRealValue.getKey();
-                    Double value = null == pointRealValue.getValue() ? null : Double.valueOf(pointRealValue.getValue().toString());
+                for (String pointNo : entry.getValue()) {
+                    Double value = null == pointsRealValue.get(pointNo) ? null : Double.valueOf(pointsRealValue.get(pointNo).toString());
                     //如果有旧值,且旧值为0,且新值不为null,且新值>0  触发模型
                     if (null != pointsLastValue.get(pointNo) && pointsLastValue.get(pointNo).equals(0.0) && null != value && value.compareTo(0.0) > 0){
+                        logger.info("LDG柜容预测触发,NET:" + entry.getKey() + ",pointNo:" + pointNo + "-" + value);
                         runPredictModuleTask.run(entry.getKey());
                         break;
                     }
                 }
-
-                for (Map.Entry<String, Object> pointRealValue : pointsRealValue.entrySet()) {
-                    Double value = null == pointRealValue.getValue() ? null : Double.valueOf(pointRealValue.getValue().toString());
-                    pointsLastValue.put(pointRealValue.getKey(),value);
-                }
-
+            }
+            //记录pointsLastValue
+            for (Map.Entry<String, Object> pointRealValue : pointsRealValue.entrySet()) {
+                Double value = null == pointRealValue.getValue() ? null : Double.valueOf(pointRealValue.getValue().toString());
+                pointsLastValue.put(pointRealValue.getKey(),value);
             }
         } catch (Exception ex) {
             logger.error("runLDGTankFactorPredTask运行异常",ex);

--
Gitblit v1.9.3