From 720f98e15ae809092f9686b710d038cbe503b3ca Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期二, 25 三月 2025 13:16:11 +0800 Subject: [PATCH] 蒸汽调度 --- shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleOnaOptTask.java | 102 ++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 85 insertions(+), 17 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 index d53b1b9..4e94f46 100644 --- 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 @@ -1,7 +1,7 @@ package com.iailab.module.shasteel.job.task; +import com.alibaba.fastjson.JSONArray; 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; @@ -16,6 +16,7 @@ import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; +import java.math.BigDecimal; import java.util.*; /** @@ -55,6 +56,17 @@ private Map<String, StScheduleSchemeDTO> schemeMap = new HashMap<>(); + /** + * 调度调整方向 + * 1:调整值为正数;-1:调整值为负数 + */ + private static Map<String, Integer> gasAdjustMode = new HashMap<>(); + + /** + * 调度建议时间 + */ + private static Map<String, Date> gasLastSugTime = new HashMap<>(); + private static final String CODE06 = "06"; private static final String CODE05 = "05"; @@ -82,21 +94,20 @@ } schemeMap.clear(); Map<String, MdkScheduleRespDTO> resultMap = new HashMap<String, MdkScheduleRespDTO>(); - schemeList.forEach(item -> { - schemeMap.put(item.getCode(), item); - StScheduleSchemeDTO scheme = schemeList.get(0); + 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(item.getCode(), mdkScheduleRespDTO); + 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())) { + if (!CommonConstant.MDK_STATUS_100.equals(entry.getValue().getStatusCode())) { logger.info("调度结果异常,STATUS=" + entry.getValue().getStatusCode()); continue; } @@ -104,21 +115,50 @@ 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(); - // double[] adviceValues = (double[]) entry.getValue().getResult().get("adviceValues"); - String yingdiAdvice = entry.getValue().getResult().get("yingdiAdvice").toString(); - saveScheduleSuggest("盈德中压建议调整量", yingdiAdvice, scheduleObj, scheduleTime); + // 氧气系统优化调度决策 + StScheduleSchemeDTO scheduleScheme = schemeMap.get(CODE05); + String scheduleObj = scheduleScheme.getScheduleObj(); + /*String yingdiAdvice = entry.getValue().getResult().get("yingdiAdvice").toString(); 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); - } else if (entry.getKey().equals(CODE01)) { - String scheduleObj = schemeMap.get(CODE05).getScheduleObj(); + String runAdvice = entry.getValue().getResult().get("runAdvice").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); + }*/ + + logger.info("adviceValues=" + entry.getValue().getResult().get("adviceValues")); + List<BigDecimal> adviceValues = new ArrayList<>(); + JSONArray ja0 = JSONArray.parseArray(entry.getValue().getResult().get("adviceValues").toString()); + JSONArray ja1 = ja0.getJSONArray(0); + for(int i = 0; i < ja1.size(); i++) { + adviceValues.add(new BigDecimal(ja1.get(i).toString())); + } + logger.info("adviceValues=" + JSONArray.toJSONString(adviceValues)); + + String advice = entry.getValue().getResult().get("advice").toString(); - saveScheduleSuggest("氮气预警", advice, scheduleObj, scheduleTime); + if(!advice.contains("压力正常")){ + saveScheduleSuggest("各制氧机组建议", advice, scheduleObj, scheduleTime, adviceValues.get(0), scheduleScheme.getAdjustRate()); + } + + } else if (entry.getKey().equals(CODE01)) { + StScheduleSchemeDTO scheduleScheme = schemeMap.get(CODE05); + String scheduleObj = scheduleScheme.getScheduleObj(); + String advice = entry.getValue().getResult().get("advice").toString(); + if(!"压力正常".equals(advice)){ + saveScheduleSuggest("氮气预警", advice, scheduleObj, scheduleTime); + } } } logger.info(params + "调度方案执行完成"); @@ -131,8 +171,36 @@ private void saveScheduleSuggest(String title, String content, String scheduleObj, Date scheduleTime) { if (StringUtils.isBlank(content)) { + logger.info(title + "调整值为空,不产生建议"); return; } + + ScheduleSuggestRespDTO suggest = new ScheduleSuggestRespDTO(); + suggest.setTitle(title); + suggest.setContent(content); + suggest.setScheduleObj(scheduleObj); + suggest.setScheduleTime(scheduleTime); + suggest.setSort(0); + mcsApi.createScheduleSuggest(suggest); + } + + private void saveScheduleSuggest(String title, String content, String scheduleObj, Date scheduleTime, BigDecimal adjustValue, int adjustRate) { + if (StringUtils.isBlank(content)) { + logger.info(title + "调整值为空,不产生建议"); + return; + } + if (adjustValue == null || adjustValue.doubleValue() == 0) { + logger.info(title + "调整值为空,不产生建议"); + return; + } + if (gasAdjustMode.containsKey(title) && gasAdjustMode.get(title).equals(adjustValue.compareTo(BigDecimal.ZERO)) && + gasLastSugTime.containsKey(title) && (scheduleTime.getTime() - gasLastSugTime.get(title).getTime() <= Integer.valueOf(adjustRate).longValue() * 60 * 1000)) { + logger.info("调整建议在有效期内"); + return; + } + gasAdjustMode.put(title, adjustValue.compareTo(BigDecimal.ZERO)); + gasLastSugTime.put(title, scheduleTime); + ScheduleSuggestRespDTO suggest = new ScheduleSuggestRespDTO(); suggest.setTitle(title); suggest.setContent(content); -- Gitblit v1.9.3