| | |
| | | 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 org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 蒸汽调度 |
| | |
| | | |
| | | @Autowired |
| | | private MdkApi mdkApi; |
| | | |
| | | /** |
| | | * 调度调整方向 |
| | | * 1:调整值为正数;-1:调整值为负数 |
| | | */ |
| | | private static Map<String, Integer> gasAdjustMode = new HashMap<>(); |
| | | |
| | | /** |
| | | * 调度建议时间 |
| | | */ |
| | | private static Map<String, Date> gasLastSugTime = new HashMap<>(); |
| | | |
| | | @Override |
| | | public void run(String params) { |
| | |
| | | logger.info("调度结果异常,STATUS=" + mdkScheduleRespDTO.getStatusCode()); |
| | | return; |
| | | } |
| | | // 用户调整量 |
| | | logger.info("user_adjust=" + mdkScheduleRespDTO.getResult().get("user_adjust")); |
| | | List<BigDecimal> adviceValues = new ArrayList<>(); |
| | | JSONArray ja0 = JSONArray.parseArray(mdkScheduleRespDTO.getResult().get("user_adjust").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)); |
| | | |
| | | Object jinfengAdvice = mdkScheduleRespDTO.getResult().get("jinfengAdvice"); |
| | | saveScheduleSuggest("锦丰调度建议", jinfengAdvice, scheme.getScheduleObj(), scheduleTime); |
| | | saveScheduleSuggest("锦丰调度建议", jinfengAdvice, scheme.getScheduleObj(), scheduleTime, adviceValues.get(0), scheme.getAdjustRate()); |
| | | |
| | | Object daxinAdvice = mdkScheduleRespDTO.getResult().get("daxinAdvice"); |
| | | saveScheduleSuggest("大新调度建议", daxinAdvice, scheme.getScheduleObj(), scheduleTime); |
| | | saveScheduleSuggest("大新调度建议", daxinAdvice, scheme.getScheduleObj(), scheduleTime, adviceValues.get(1), scheme.getAdjustRate()); |
| | | |
| | | Object daxinWarning = mdkScheduleRespDTO.getResult().get("daxinWarning"); |
| | | saveAlarmMessage("大新预警", daxinWarning, scheme.getScheduleObj(), scheduleTime); |
| | |
| | | logger.info("RunScheduleSteamTask运行完成"); |
| | | } |
| | | |
| | | private void saveScheduleSuggest(String title, Object content, String scheduleObj, Date scheduleTime) { |
| | | if (content == null || StringUtils.isBlank(content.toString()) || "0".equals(content.toString())) { |
| | | logger.info(title + "content为空"); |
| | | private void saveScheduleSuggest(String title, Object content, String scheduleObj, Date scheduleTime, BigDecimal adjustValue, int adjustRate) { |
| | | if (content == null) { |
| | | return; |
| | | } |
| | | if (StringUtils.isBlank(content.toString())) { |
| | | 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.toString()); |