| | |
| | | /** |
| | | * 调度建议内容 |
| | | */ |
| | | private static Map<String, String> gasAdjustMode = new HashMap<>(); |
| | | private static Map<String, String> airAdjustMode = new HashMap<>(); |
| | | |
| | | /** |
| | | * 调度建议时间 |
| | | */ |
| | | private static Map<String, Date> gasLastSugTime = new HashMap<>(); |
| | | private static Map<String, Date> airLastSugTime = new HashMap<>(); |
| | | |
| | | @Override |
| | | public void run(String params) { |
| | |
| | | // 保存预警信息 |
| | | if (mdkScheduleRespDTO.getResult().get("pressureLWarning") != null && |
| | | StringUtils.isNotEmpty(mdkScheduleRespDTO.getResult().get("pressureLWarning").toString())) { |
| | | String pressureLWarning = mdkScheduleRespDTO.getResult().get("pressureLWarning").toString(); |
| | | AlarmMessageRespDTO alarm = new AlarmMessageRespDTO(); |
| | | alarm.setTitle("压力低于下限预警"); |
| | | alarm.setContent(pressureLWarning); |
| | | alarm.setAlarmObj(scheme.getScheduleObj()); |
| | | alarm.setAlarmType("低于下限"); |
| | | alarm.setAlarmTime(scheduleTime); |
| | | mcsApi.createAlarmMessage(alarm); |
| | | this.saveAlarmMessage("空压机预警", mdkScheduleRespDTO.getResult().get("pressureLWarning"), scheme.getScheduleObj(), "低于下限",scheduleTime, scheme.getWarningAdjustRate()); |
| | | } |
| | | |
| | | |
| | | if (mdkScheduleRespDTO.getResult().get("pressureHWarning") != null && |
| | | StringUtils.isNotEmpty(mdkScheduleRespDTO.getResult().get("pressureHWarning").toString())) { |
| | | String pressureHWarning = mdkScheduleRespDTO.getResult().get("pressureHWarning").toString(); |
| | | AlarmMessageRespDTO alarm = new AlarmMessageRespDTO(); |
| | | alarm.setTitle("空压机预警"); |
| | | alarm.setContent(pressureHWarning); |
| | | alarm.setAlarmObj(scheme.getScheduleObj()); |
| | | alarm.setAlarmType("高于上限"); |
| | | alarm.setAlarmTime(scheduleTime); |
| | | mcsApi.createAlarmMessage(alarm); |
| | | this.saveAlarmMessage("空压机预警", mdkScheduleRespDTO.getResult().get("pressureHWarning"), scheme.getScheduleObj(), "高于上限",scheduleTime, scheme.getWarningAdjustRate()); |
| | | } |
| | | |
| | | // 保存调度建议 |
| | |
| | | logger.info(title + "调整值为空,不产生建议"); |
| | | return; |
| | | } |
| | | if (gasAdjustMode.containsKey(title) && gasAdjustMode.get(title).equals(contentStr) && |
| | | gasLastSugTime.containsKey(title) && (scheduleTime.getTime() - gasLastSugTime.get(title).getTime() <= Integer.valueOf(adjustRate).longValue() * 60 * 1000)) { |
| | | if (airAdjustMode.containsKey(title) && airAdjustMode.get(title).equals(contentStr) && |
| | | airLastSugTime.containsKey(title) && (scheduleTime.getTime() - airLastSugTime.get(title).getTime() <= Integer.valueOf(adjustRate).longValue() * 60 * 1000)) { |
| | | logger.info("调整建议在有效期内"); |
| | | return; |
| | | } |
| | | gasAdjustMode.put(title, contentStr); |
| | | gasLastSugTime.put(title, scheduleTime); |
| | | airAdjustMode.put(title, contentStr); |
| | | airLastSugTime.put(title, scheduleTime); |
| | | |
| | | ScheduleSuggestRespDTO suggest = new ScheduleSuggestRespDTO(); |
| | | suggest.setTitle(title); |
| | |
| | | suggest.setSort(0); |
| | | mcsApi.createScheduleSuggest(suggest); |
| | | } |
| | | |
| | | private void saveAlarmMessage(String title, Object content, String scheduleObj,String alarmType, Date scheduleTime, int warningAdjustRate) { |
| | | if (content == null) { |
| | | logger.info(title + "预警信息为空,不产生预警"); |
| | | return; |
| | | } |
| | | String contentStr = content.toString(); |
| | | if (StringUtils.isBlank(contentStr)) { |
| | | logger.info(title + "预警信息为空,不产生预警"); |
| | | return; |
| | | } |
| | | if (airAdjustMode.containsKey(title) && airAdjustMode.get(title).equals(contentStr) && |
| | | airLastSugTime.containsKey(title) && (scheduleTime.getTime() - airLastSugTime.get(title).getTime() <= Integer.valueOf(warningAdjustRate).longValue() * 60 * 1000)) { |
| | | logger.info("预警信息在有效期内"); |
| | | return; |
| | | } |
| | | airAdjustMode.put(title, contentStr); |
| | | airLastSugTime.put(title, scheduleTime); |
| | | |
| | | AlarmMessageRespDTO alarm = new AlarmMessageRespDTO(); |
| | | alarm.setTitle(title); |
| | | alarm.setContent(contentStr); |
| | | alarm.setAlarmObj(scheduleObj); |
| | | alarm.setAlarmType(alarmType); |
| | | alarm.setAlarmTime(scheduleTime); |
| | | mcsApi.createAlarmMessage(alarm); |
| | | } |
| | | } |
| | |
| | | */ |
| | | private static Map<String, Date> gasLastSugTime = new HashMap<>(); |
| | | |
| | | |
| | | /** |
| | | * 预警调整内容 |
| | | */ |
| | | private static Map<String, String> warningAdjustContent = new HashMap<>(); |
| | | |
| | | /** |
| | | * 预警建议时间 |
| | | */ |
| | | private static Map<String, Date> warningLastSugTime = new HashMap<>(); |
| | | |
| | | @Override |
| | | public void run(String params) { |
| | | logger.info("RunScheduleSteamTask,参数为:{}", params); |
| | |
| | | } |
| | | logger.info("adviceValues=" + JSONArray.toJSONString(adviceValues)); |
| | | |
| | | Object jinfengAdvice = mdkScheduleRespDTO.getResult().get("jinfengAdvice"); |
| | | saveScheduleSuggest("锦丰调度建议", jinfengAdvice, scheme.getScheduleObj(), scheduleTime, adviceValues.get(0), scheme.getAdjustRate()); |
| | | |
| | | Object daxinAdvice = mdkScheduleRespDTO.getResult().get("daxinAdvice"); |
| | | saveScheduleSuggest("大新调度建议", daxinAdvice, scheme.getScheduleObj(), scheduleTime, adviceValues.get(1), scheme.getAdjustRate()); |
| | | saveScheduleSuggest("大新调度建议", daxinAdvice, scheme.getScheduleObj(), scheduleTime, adviceValues.get(0), scheme.getAdjustRate()); |
| | | |
| | | Object jinfengAdvice = mdkScheduleRespDTO.getResult().get("jinfengAdvice"); |
| | | saveScheduleSuggest("锦丰调度建议", jinfengAdvice, scheme.getScheduleObj(), scheduleTime, adviceValues.get(1), scheme.getAdjustRate()); |
| | | |
| | | Object daxinWarning = mdkScheduleRespDTO.getResult().get("daxinWarning"); |
| | | saveAlarmMessage("大新预警", daxinWarning, scheme.getScheduleObj(), scheduleTime); |
| | | saveAlarmMessage("大新预警", daxinWarning, scheme.getScheduleObj(), scheduleTime, scheme.getWarningAdjustRate()); |
| | | |
| | | Object jinfengWarning = mdkScheduleRespDTO.getResult().get("jinfengWarning"); |
| | | saveAlarmMessage("锦丰预警", jinfengWarning, scheme.getScheduleObj(), scheduleTime); |
| | | saveAlarmMessage("锦丰预警", jinfengWarning, scheme.getScheduleObj(), scheduleTime, scheme.getWarningAdjustRate()); |
| | | |
| | | Object zhuanlu1Warning = mdkScheduleRespDTO.getResult().get("zhuanlu1Warning"); |
| | | saveAlarmMessage("转炉一预警", zhuanlu1Warning, scheme.getScheduleObj(), scheduleTime); |
| | | saveAlarmMessage("转炉一预警", zhuanlu1Warning, scheme.getScheduleObj(), scheduleTime, scheme.getWarningAdjustRate()); |
| | | |
| | | Object zhuanlu2Warning = mdkScheduleRespDTO.getResult().get("zhuanlu2Warning"); |
| | | saveAlarmMessage("转炉二预警", zhuanlu2Warning, scheme.getScheduleObj(), scheduleTime); |
| | | saveAlarmMessage("转炉二预警", zhuanlu2Warning, scheme.getScheduleObj(), scheduleTime, scheme.getWarningAdjustRate()); |
| | | |
| | | logger.info(params + "调度方案执行完成"); |
| | | } catch (Exception ex) { |
| | |
| | | mcsApi.createScheduleSuggest(suggest); |
| | | } |
| | | |
| | | private void saveAlarmMessage(String title, Object content, String alarmObj, Date scheduleTime) { |
| | | private void saveAlarmMessage(String title, Object content, String alarmObj, Date scheduleTime, int warningAdjustRate) { |
| | | if (content == null || StringUtils.isBlank(content.toString()) || "0".equals(content.toString())) { |
| | | logger.info(title + "content为空"); |
| | | return; |
| | | } |
| | | String contentStr = content.toString(); |
| | | if (warningAdjustContent.containsKey(title) && warningAdjustContent.get(title).equals(contentStr) && |
| | | warningLastSugTime.containsKey(title) && (scheduleTime.getTime() - warningLastSugTime.get(title).getTime() <= Integer.valueOf(warningAdjustRate).longValue() * 60 * 1000)) { |
| | | logger.info("预警信息在有效期内"); |
| | | return; |
| | | } |
| | | warningAdjustContent.put(title, contentStr); |
| | | warningLastSugTime.put(title, scheduleTime); |
| | | AlarmMessageRespDTO alarm = new AlarmMessageRespDTO(); |
| | | alarm.setTitle(title); |
| | | alarm.setContent(content.toString()); |
| | | alarm.setContent(contentStr); |
| | | alarm.setAlarmObj(alarmObj); |
| | | alarm.setAlarmType(""); |
| | | alarm.setAlarmTime(scheduleTime); |