From 26c638697968b97d5bf007da7e8427a534aa6e17 Mon Sep 17 00:00:00 2001 From: dengzedong <dengzedong@email> Date: 星期五, 14 二月 2025 09:09:43 +0800 Subject: [PATCH] runLDGTankFactorPredTask queryPointsRealValue 优化 --- shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunLDGTankFactorPredTask.java | 19 ++++++++++++------- 1 files changed, 12 insertions(+), 7 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..8390d55 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,8 +42,11 @@ 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()); @@ -50,12 +56,11 @@ 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