From 20ca11322c7a11f8442c24fe9c521f614a54583e Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期二, 07 一月 2025 14:22:29 +0800 Subject: [PATCH] 氧气优化调度 --- shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleOnaOptTask.java | 135 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 135 insertions(+), 0 deletions(-) diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleOnaOptTask.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleOnaOptTask.java new file mode 100644 index 0000000..d5828bd --- /dev/null +++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleOnaOptTask.java @@ -0,0 +1,135 @@ +package com.iailab.module.shasteel.job.task; + +import com.iailab.module.model.api.mcs.McsApi; +import com.iailab.module.model.api.mcs.dto.AlarmMessageRespDTO; +import com.iailab.module.model.api.mcs.dto.ScheduleSuggestRespDTO; +import com.iailab.module.model.api.mcs.dto.StScheduleSchemeDTO; +import com.iailab.module.model.api.mdk.MdkApi; +import com.iailab.module.model.api.mdk.dto.MdkScheduleReqDTO; +import com.iailab.module.model.api.mdk.dto.MdkScheduleRespDTO; +import com.iailab.module.model.enums.CommonConstant; +import com.iailab.module.model.enums.ScheduleTriggerMethodEnum; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.util.*; + +/** + * 06 + * 氧气班平衡计划 + * 法夜空建议送出量 faAdvice + * 盈德低压建议送出量 yingDiAdvice + * 盈德中压建议送出量 yingZhongAdvice + * 宏昌建议送出量 hongAdvice + * 润忠建议送出量 RunAdvice + * 调整值 adviceValues + * <p> + * 05 + * 氧气系统优化调度决策 + * 盈德中压建议调整量 yingdiAdvice + * 法夜空建议调整量 faAdvice + * 宏昌建议调整量 hongAdvice + * 润忠建议调整量 RunAdvice + * + * @author PanZhibao + * @Description + * @createTime 2025年01月07日 + */ +@Component("runScheduleOnaOptTask") +public class RunScheduleOnaOptTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Autowired + private McsApi mcsApi; + + @Autowired + private MdkApi mdkApi; + + private Map<String, StScheduleSchemeDTO> schemeMap = new HashMap<>(); + + private static final String CODE06 = "06"; + + private static final String CODE05 = "05"; + + @Override + public void run(String params) { + logger.info("RunScheduleOnaOptTask,参数为:{}", params); + try { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + calendar.set(Calendar.SECOND, 0); + Date scheduleTime = calendar.getTime(); + if (StringUtils.isEmpty(params)) { + logger.info("参数为空"); + return; + } + + // 根据条件查找方案 + List<StScheduleSchemeDTO> schemeList = mcsApi.listScheduleScheme(ScheduleTriggerMethodEnum.JOB.getCode(), params); + if (CollectionUtils.isEmpty(schemeList)) { + logger.info("方案为空"); + return; + } + schemeMap.clear(); + Map<String, MdkScheduleRespDTO> resultMap = new HashMap<String, MdkScheduleRespDTO>(); + schemeList.forEach(item -> { + schemeMap.put(item.getCode(), item); + StScheduleSchemeDTO scheme = schemeList.get(0); + MdkScheduleReqDTO dto = new MdkScheduleReqDTO(); + dto.setScheduleTime(scheduleTime); + dto.setScheduleCode(scheme.getCode()); + MdkScheduleRespDTO mdkScheduleRespDTO = mdkApi.doSchedule(dto); + resultMap.put(item.getCode(), mdkScheduleRespDTO); + }); + if (CollectionUtils.isEmpty(resultMap)) { + logger.info("resultMap为空"); + return; + } + for (Map.Entry<String, MdkScheduleRespDTO> entry : resultMap.entrySet()) { + if (CommonConstant.MDK_STATUS_100.equals(entry.getValue().getStatusCode())) { + logger.info("调度结果异常,STATUS=" + entry.getValue().getStatusCode()); + continue; + } + + if (entry.getKey().equals(CODE06)) { + // 氧气班平衡计划,建议值写入测点 + mdkApi.scheduleModelOut(entry.getValue()); + } else if (entry.getKey().equals(CODE05)) { + String scheduleObj = schemeMap.get(CODE05).getScheduleObj(); + // double[] adviceValues = (double[]) entry.getValue().getResult().get("adviceValues"); + String yingdiAdvice = entry.getValue().getResult().get("yingdiAdvice").toString(); + saveScheduleSuggest("盈德中压建议调整量", yingdiAdvice, scheduleObj, scheduleTime); + String faAdvice = entry.getValue().getResult().get("faAdvice").toString(); + saveScheduleSuggest("法夜空建议调整量", faAdvice, scheduleObj, scheduleTime); + String hongAdvice = entry.getValue().getResult().get("hongAdvice").toString(); + saveScheduleSuggest("宏昌建议调整量", hongAdvice, scheduleObj, scheduleTime); + String runAdvice = entry.getValue().getResult().get("RunAdvice").toString(); + saveScheduleSuggest("宏昌建议调整量", runAdvice, scheduleObj, scheduleTime); + } + } + + logger.info(params + "调度方案执行完成"); + } catch (Exception ex) { + logger.error("RunScheduleOnaOptTask运行异常"); + ex.printStackTrace(); + } + logger.info("RunScheduleOnaOptTask运行完成"); + } + + private void saveScheduleSuggest(String title, String content, String scheduleObj, Date scheduleTime) { + if (StringUtils.isBlank(content)) { + return; + } + ScheduleSuggestRespDTO suggest = new ScheduleSuggestRespDTO(); + suggest.setTitle(title); + suggest.setContent(content); + suggest.setScheduleObj(scheduleObj); + suggest.setScheduleTime(scheduleTime); + suggest.setSort(0); + mcsApi.createScheduleSuggest(suggest); + } +} \ No newline at end of file -- Gitblit v1.9.3