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 | 83 +++++++++++++++++++++++++---------------- 1 files changed, 51 insertions(+), 32 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 6d424e8..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) { @@ -67,14 +75,14 @@ dto.setScheduleTime(scheduleTime); dto.setScheduleCode(scheme.getCode()); MdkScheduleRespDTO mdkScheduleRespDTO = mdkApi.doSchedule(dto); - if (CommonConstant.MDK_STATUS_100.equals(mdkScheduleRespDTO.getStatusCode())) { + if (!CommonConstant.MDK_STATUS_100.equals(mdkScheduleRespDTO.getStatusCode())) { logger.info("调度结果异常,STATUS=" + mdkScheduleRespDTO.getStatusCode()); return; } - // 保存预警信息 - String pressureLWarning = mdkScheduleRespDTO.getResult().get("pressureLWarning").toString(); - if (StringUtils.isNotBlank(pressureLWarning)) { + 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); @@ -84,10 +92,12 @@ mcsApi.createAlarmMessage(alarm); } - String pressureHWarning = mdkScheduleRespDTO.getResult().get("pressureHWarning").toString(); - if (StringUtils.isNotBlank(pressureHWarning)) { + + 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.setTitle("空压机预警"); alarm.setContent(pressureHWarning); alarm.setAlarmObj(scheme.getScheduleObj()); alarm.setAlarmType("高于上限"); @@ -96,28 +106,10 @@ } // 保存调度建议 - String dispatchStart = mdkScheduleRespDTO.getResult().get("dispatchStart").toString(); - if (StringUtils.isNotBlank(pressureHWarning)) { - ScheduleSuggestRespDTO suggest = new ScheduleSuggestRespDTO(); - suggest.setTitle("空压机启动调度建议"); - suggest.setContent(dispatchStart); - suggest.setScheduleObj(scheme.getScheduleObj()); - suggest.setScheduleTime(scheduleTime); - suggest.setSort(0); - mcsApi.createScheduleSuggest(suggest); - } - - String dispatchClose = mdkScheduleRespDTO.getResult().get("dispatchClose").toString(); - if (StringUtils.isNotBlank(dispatchClose)) { - 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运行异常"); @@ -125,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