package com.iailab.module.shasteel.job.task; import com.iailab.module.model.api.mcs.McsApi; 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 * * 05 * æ°§æ°”ç³»ç»Ÿä¼˜åŒ–è°ƒåº¦å†³ç– * 盈德ä¸åŽ‹å»ºè®®è°ƒæ•´é‡ yingdiAdvice * æ³•å¤œç©ºå»ºè®®è°ƒæ•´é‡ faAdvice * å®æ˜Œå»ºè®®è°ƒæ•´é‡ hongAdvice * æ¶¦å¿ å»ºè®®è°ƒæ•´é‡ RunAdvice * * 01 * 氮气预è¦æ¨¡åž‹ * 预è¦ä¿¡å· advice * * @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"; private static final String CODE01 = "01"; @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(scheme -> { schemeMap.put(scheme.getCode(), scheme); MdkScheduleReqDTO dto = new MdkScheduleReqDTO(); dto.setScheduleTime(scheduleTime); dto.setScheduleCode(scheme.getCode()); MdkScheduleRespDTO mdkScheduleRespDTO = mdkApi.doSchedule(dto); resultMap.put(scheme.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()); logger.info("氧气ç平衡计划下å‘å‚æ•°: {}", entry.getValue()); } else if (entry.getKey().equals(CODE05)) { String scheduleObj = schemeMap.get(CODE05).getScheduleObj(); String faAdvice = entry.getValue().getResult().get("faAdvice").toString(); String hongAdvice = entry.getValue().getResult().get("hongAdvice").toString(); String runAdvice = entry.getValue().getResult().get("runAdvice").toString(); String yingdiAdvice = entry.getValue().getResult().get("yingdiAdvice").toString(); if(!yingdiAdvice.equals("压力æ£å¸¸")){ saveScheduleSuggest("盈德ä¸åŽ‹è°ƒæ•´å»ºè®®", yingdiAdvice, scheduleObj, scheduleTime); } if(!faAdvice.equals("压力æ£å¸¸")){ saveScheduleSuggest("法夜空调整建议", faAdvice, scheduleObj, scheduleTime); } if(!hongAdvice.equals("压力æ£å¸¸")){ saveScheduleSuggest("å®æ˜Œè°ƒæ•´å»ºè®®", hongAdvice, scheduleObj, scheduleTime); } if(!runAdvice.equals("压力æ£å¸¸")){ saveScheduleSuggest("æ¶¦å¿ è°ƒæ•´å»ºè®®", runAdvice, scheduleObj, scheduleTime); } } else if (entry.getKey().equals(CODE01)) { String scheduleObj = schemeMap.get(CODE01).getScheduleObj(); String advice = entry.getValue().getResult().get("advice").toString(); if(!"压力æ£å¸¸".equals(advice)){ saveScheduleSuggest("氮气预è¦", advice, 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); } }