| | |
| | | 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.ScheduleSuggestRespDTO; |
| | | import com.iailab.module.model.api.mcs.dto.StScheduleSchemeDTO; |
| | |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | private MdkApi mdkApi; |
| | | |
| | | 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"; |
| | | |
| | |
| | | mdkApi.scheduleModelOut(entry.getValue()); |
| | | logger.info("氧气班平衡计划下发参数: {}", entry.getValue()); |
| | | } else if (entry.getKey().equals(CODE05)) { |
| | | String scheduleObj = schemeMap.get(CODE05).getScheduleObj(); |
| | | // 氧气系统优化调度决策 |
| | | 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(); |
| | | String hongAdvice = entry.getValue().getResult().get("hongAdvice").toString(); |
| | | String runAdvice = entry.getValue().getResult().get("runAdvice").toString(); |
| | | String yingdiAdvice = entry.getValue().getResult().get("yingdiAdvice").toString(); |
| | | JSONArray adviceValues = JSONArray.parseArray(entry.getValue().getResult().get("adviceValues").toString()); |
| | | List<BigDecimal> adviceValueList = new ArrayList<>(); |
| | | if (!CollectionUtils.isEmpty(adviceValues)) { |
| | | for (int i = 0; i < adviceValues.size(); i++) { |
| | | adviceValueList.add(new BigDecimal(adviceValues.get(i).toString())); |
| | | } |
| | | } |
| | | if(!yingdiAdvice.equals("压力正常")){ |
| | | saveScheduleSuggest("盈德中压调整建议", yingdiAdvice, scheduleObj, scheduleTime); |
| | | saveScheduleSuggest("盈德中压调整建议", yingdiAdvice, scheduleObj, scheduleTime, adviceValueList.get(0), scheduleScheme.getAdjustRate()); |
| | | } |
| | | if(!faAdvice.equals("压力正常")){ |
| | | saveScheduleSuggest("法夜空调整建议", faAdvice, scheduleObj, scheduleTime); |
| | | saveScheduleSuggest("法夜空调整建议", faAdvice, scheduleObj, scheduleTime, adviceValueList.get(1), scheduleScheme.getAdjustRate()); |
| | | } |
| | | if(!hongAdvice.equals("压力正常")){ |
| | | saveScheduleSuggest("宏昌调整建议", hongAdvice, scheduleObj, scheduleTime); |
| | | saveScheduleSuggest("宏昌调整建议", hongAdvice, scheduleObj, scheduleTime, adviceValueList.get(2), scheduleScheme.getAdjustRate()); |
| | | } |
| | | if(!runAdvice.equals("压力正常")){ |
| | | saveScheduleSuggest("润忠调整建议", runAdvice, scheduleObj, scheduleTime); |
| | | saveScheduleSuggest("润忠调整建议", runAdvice, scheduleObj, scheduleTime, adviceValueList.get(3), scheduleScheme.getAdjustRate()); |
| | | } |
| | | } else if (entry.getKey().equals(CODE01)) { |
| | | String scheduleObj = schemeMap.get(CODE01).getScheduleObj(); |
| | | StScheduleSchemeDTO scheduleScheme = schemeMap.get(CODE05); |
| | | String scheduleObj = scheduleScheme.getScheduleObj(); |
| | | String advice = entry.getValue().getResult().get("advice").toString(); |
| | | if(!"压力正常".equals(advice)){ |
| | | saveScheduleSuggest("氮气预警", advice, scheduleObj, 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); |
| | | } |
| | | |
| | | private void saveScheduleSuggest(String title, String content, String scheduleObj, Date scheduleTime, BigDecimal adjustValue, int adjustRate) { |
| | | if (StringUtils.isBlank(content)) { |
| | | return; |
| | | } |
| | | if (adjustValue == null || adjustValue.doubleValue() == 0) { |
| | | logger.info(title + "调整值为空,不产生建议"); |
| | | return; |
| | | } |
| | | if (gasAdjustMode.containsKey(scheduleObj) && gasAdjustMode.get(scheduleObj).equals(adjustValue.compareTo(BigDecimal.ZERO)) && |
| | | gasLastSugTime.containsKey(scheduleObj) && (scheduleTime.getTime() - gasLastSugTime.get(scheduleObj).getTime() <= Integer.valueOf(adjustRate).longValue() * 60 * 1000)) { |
| | | logger.info("调整建议在有效期内"); |
| | | return; |
| | | } |
| | | gasAdjustMode.put(scheduleObj, adjustValue.compareTo(BigDecimal.ZERO)); |
| | | gasLastSugTime.put(scheduleObj, scheduleTime); |
| | | |
| | | ScheduleSuggestRespDTO suggest = new ScheduleSuggestRespDTO(); |
| | | suggest.setTitle(title); |
| | | suggest.setContent(content); |