From 72c8e506e13f3b35476bfd65bfe07c22bf23c755 Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期二, 25 三月 2025 07:15:48 +0800 Subject: [PATCH] 氧气调度 调整速率 --- shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleAirDispatchTask.java | 72 +++++++++++++++++++++-------------- 1 files changed, 43 insertions(+), 29 deletions(-) diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleAirDispatchTask.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleAirDispatchTask.java index 74a9c66..0e25f5d 100644 --- a/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleAirDispatchTask.java +++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleAirDispatchTask.java @@ -16,9 +16,7 @@ import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; -import java.util.Calendar; -import java.util.Date; -import java.util.List; +import java.util.*; /** * 压缩空气优化调度 @@ -41,6 +39,16 @@ @Autowired private MdkApi mdkApi; + + /** + * 调度建议内容 + */ + private static Map<String, String> gasAdjustMode = new HashMap<>(); + + /** + * 调度建议时间 + */ + private static Map<String, Date> gasLastSugTime = new HashMap<>(); @Override public void run(String params) { @@ -71,7 +79,6 @@ logger.info("调度结果异常,STATUS=" + mdkScheduleRespDTO.getStatusCode()); return; } - // 保存预警信息 if (mdkScheduleRespDTO.getResult().get("pressureLWarning") != null && StringUtils.isNotEmpty(mdkScheduleRespDTO.getResult().get("pressureLWarning").toString())) { @@ -90,7 +97,7 @@ StringUtils.isNotEmpty(mdkScheduleRespDTO.getResult().get("pressureHWarning").toString())) { String pressureHWarning = mdkScheduleRespDTO.getResult().get("pressureHWarning").toString(); AlarmMessageRespDTO alarm = new AlarmMessageRespDTO(); - alarm.setTitle("压力高于上限预警"); + alarm.setTitle("空压机预警"); alarm.setContent(pressureHWarning); alarm.setAlarmObj(scheme.getScheduleObj()); alarm.setAlarmType("高于上限"); @@ -99,30 +106,10 @@ } // 保存调度建议 - if (mdkScheduleRespDTO.getResult().get("dispatchStart") != null && - StringUtils.isNotEmpty(mdkScheduleRespDTO.getResult().get("dispatchStart").toString())) { - String dispatchStart = mdkScheduleRespDTO.getResult().get("dispatchStart").toString(); - ScheduleSuggestRespDTO suggest = new ScheduleSuggestRespDTO(); - suggest.setTitle("空压机启动调度建议"); - suggest.setContent(dispatchStart); - suggest.setScheduleObj(scheme.getScheduleObj()); - suggest.setScheduleTime(scheduleTime); - suggest.setSort(0); - mcsApi.createScheduleSuggest(suggest); - } - - if (mdkScheduleRespDTO.getResult().get("dispatchClose") != null && - StringUtils.isNotEmpty(mdkScheduleRespDTO.getResult().get("dispatchClose").toString())) { - String dispatchClose = mdkScheduleRespDTO.getResult().get("dispatchClose").toString(); - ScheduleSuggestRespDTO suggest = new ScheduleSuggestRespDTO(); - suggest.setTitle("空压机关停调度建议"); - suggest.setContent(dispatchClose); - suggest.setScheduleObj(scheme.getScheduleObj()); - suggest.setScheduleTime(scheduleTime); - suggest.setSort(0); - mcsApi.createScheduleSuggest(suggest); - } - + this.saveScheduleSuggest("空压机启动调度建议", mdkScheduleRespDTO.getResult().get("dispatchStart"), scheme.getScheduleObj(), + scheduleTime, scheme.getAdjustRate()); + this.saveScheduleSuggest("空压机关停调度建议", mdkScheduleRespDTO.getResult().get("dispatchClose"), scheme.getScheduleObj(), + scheduleTime, scheme.getAdjustRate()); logger.info(params + "调度方案执行完成"); } catch (Exception ex) { logger.error("RunScheduleAirDispatchTask运行异常"); @@ -130,4 +117,31 @@ } logger.info("RunScheduleAirDispatchTask运行完成"); } + + private void saveScheduleSuggest(String title, Object content, String scheduleObj, Date scheduleTime, int adjustRate) { + if (content == null) { + logger.info(title + "调整值为空,不产生建议"); + return; + } + String contentStr = content.toString(); + if (StringUtils.isBlank(contentStr)) { + 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)) { + logger.info("调整建议在有效期内"); + return; + } + gasAdjustMode.put(title, contentStr); + gasLastSugTime.put(title, scheduleTime); + + ScheduleSuggestRespDTO suggest = new ScheduleSuggestRespDTO(); + suggest.setTitle(title); + suggest.setContent(content.toString()); + suggest.setScheduleObj(scheduleObj); + suggest.setScheduleTime(scheduleTime); + suggest.setSort(0); + mcsApi.createScheduleSuggest(suggest); + } } \ No newline at end of file -- Gitblit v1.9.3