对比新文件 |
| | |
| | | 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运行完成"); |
| | | } |
| | | } |