package com.iailab.module.job.task; import com.iailab.module.mcs.dto.StModelDTO; import com.iailab.module.mcs.service.StModelService; import com.iailab.module.model.handler.ModelHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.annotation.Resource; import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.Calendar; import java.util.List; /** * 控制系统可靠性评价 * * @author PanZhibao * @Description * @createTime 2024年06月15日 */ @Component("modelControlReliabilityTask") public class ModelControlReliabilityTask implements ITask { private Logger logger = LoggerFactory.getLogger(getClass()); @Resource private StModelService stModelService; @Resource private ModelHandler modelHandler; private final List MODEL_CODE_LIST = new ArrayList<>(); ModelControlReliabilityTask() { MODEL_CODE_LIST.add("control_reliability_mm"); MODEL_CODE_LIST.add("control_reliability_km"); MODEL_CODE_LIST.add("control_reliability_blow1"); MODEL_CODE_LIST.add("control_reliability_blow2"); MODEL_CODE_LIST.add("control_reliability_dl401"); MODEL_CODE_LIST.add("control_reliability_dl402"); MODEL_CODE_LIST.add("control_reliability_dl501"); MODEL_CODE_LIST.add("control_reliability_hm"); } @Override public void run(String params) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.MILLISECOND, 0); calendar.set(Calendar.SECOND, 0); logger.info("ModelControlReliabilityTask定时任务正在执行,参数为:{}", params); try { for (int i = 0; i < MODEL_CODE_LIST.size(); i++) { StModelDTO stModel = stModelService.getByCode(MODEL_CODE_LIST.get(i)); if (stModel == null) { logger.info("model为空!"); return; } logger.info("运行模型:" + stModel.getModelCode()); modelHandler.run(stModel.getModelCode(), calendar.getTime()); } } catch (Exception ex) { logger.error("ModelControlReliabilityTask运行异常"); ex.printStackTrace(); } logger.info("ModelControlReliabilityTask运行完成"); } }