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è¿è¡Œå®Œæˆ"); } }