From 63b27f68e62bc1fc1366af265ca81e1e62c1f8b6 Mon Sep 17 00:00:00 2001 From: dengzedong <dengzedong@email> Date: 星期四, 13 二月 2025 17:02:19 +0800 Subject: [PATCH] runLDGTankFactorPredTask --- shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunLDGTankFactorPredTask.java | 60 ++++++++++++++++++++++++++++++ shasteel-biz/src/main/java/com/iailab/module/shasteel/framework/rpc/config/RpcConfiguration.java | 3 + shasteel-biz/pom.xml | 10 ++-- 3 files changed, 67 insertions(+), 6 deletions(-) diff --git a/shasteel-biz/pom.xml b/shasteel-biz/pom.xml index 4839e82..ad032ed 100644 --- a/shasteel-biz/pom.xml +++ b/shasteel-biz/pom.xml @@ -34,6 +34,11 @@ <artifactId>iailab-module-model-api</artifactId> <version>${revision}</version> </dependency> + <dependency> + <groupId>com.iailab</groupId> + <artifactId>iailab-module-data-api</artifactId> + <version>${revision}</version> + </dependency> <!-- 业务组件 --> <dependency> @@ -131,11 +136,6 @@ <dependency> <groupId>com.iailab</groupId> <artifactId>iailab-common-mq</artifactId> - </dependency> - - <dependency> - <groupId>com.iailab</groupId> - <artifactId>iailab-module-model-api</artifactId> </dependency> </dependencies> diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/framework/rpc/config/RpcConfiguration.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/framework/rpc/config/RpcConfiguration.java index bed8227..9a797c3 100644 --- a/shasteel-biz/src/main/java/com/iailab/module/shasteel/framework/rpc/config/RpcConfiguration.java +++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/framework/rpc/config/RpcConfiguration.java @@ -1,5 +1,6 @@ package com.iailab.module.shasteel.framework.rpc.config; +import com.iailab.module.data.api.point.DataPointApi; import com.iailab.module.infra.api.config.ConfigApi; import com.iailab.module.infra.api.db.DataSourceConfigServiceApi; import com.iailab.module.infra.api.file.FileApi; @@ -11,6 +12,6 @@ import org.springframework.context.annotation.Configuration; @Configuration(proxyBeanMethods = false) -@EnableFeignClients(clients = {FileApi.class, WebSocketSenderApi.class, DataSourceConfigServiceApi.class, ConfigApi.class, TenantApi.class, McsApi.class, MdkApi.class}) +@EnableFeignClients(clients = {FileApi.class, WebSocketSenderApi.class, DataSourceConfigServiceApi.class, ConfigApi.class, TenantApi.class, McsApi.class, MdkApi.class, DataPointApi.class}) public class RpcConfiguration { } 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 new file mode 100644 index 0000000..7685922 --- /dev/null +++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunLDGTankFactorPredTask.java @@ -0,0 +1,60 @@ +package com.iailab.module.shasteel.job.task; + +import com.iailab.module.data.api.point.DataPointApi; +import com.iailab.module.model.api.mdk.MdkApi; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.*; + +/** + * @description: LDG柜容预测 监听触发 + * points(当前时刻大于0,上一时刻为0)则触发 + * @author: dzd + * @date: 2025/2/13 16:22 + **/ +@Component("runLDGTankFactorPredTask") +public class RunLDGTankFactorPredTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + @Autowired + private DataPointApi dataPointApi; + @Autowired + private RunPredictModuleTask runPredictModuleTask; + + /** + * map<NetCode,[pointNos]> + **/ + private static final HashMap<String, List<String>> checkPoints = new HashMap<String, List<String>>(){{ + put("NET_LDG1", Arrays.asList("M0000100050","M0000100049","M0000100048")); + put("NET_LDG2", Arrays.asList("M0000100062","M0000100061","M0000100060")); + put("NET_LDG3", Arrays.asList("M0000100057","M0000100056","M0000100055")); + }}; + + private static HashMap<String,Double> pointsLastValue = new HashMap<>(); + + @Override + public void run(String params) { + logger.info("runLDGTankFactorPredTask定时任务正在执行,参数为:{}", params); + try { + 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 = (Double) pointRealValue.getValue(); + //如果有旧值,且旧值为0,且新值不为null,且新值>0 触发模型 + if (pointsLastValue.containsKey(pointNo) && pointsLastValue.get(pointNo).equals(0.0) && null != value && value.compareTo(0.0) > 0){ + runPredictModuleTask.run(entry.getKey()); + break; + } + } + + } + } catch (Exception ex) { + logger.error("runLDGTankFactorPredTask运行异常",ex); + } + logger.info("runLDGTankFactorPredTask运行完成"); + } +} -- Gitblit v1.9.3