From c0d47f557b4d202ea95a52434730a235ffb118a0 Mon Sep 17 00:00:00 2001 From: Jay <csj123456> Date: 星期一, 31 三月 2025 15:27:50 +0800 Subject: [PATCH] 压缩空气和蒸汽页面增加调整频率 --- shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleAirDispatchTask.java | 57 +++++++++++++++++++++++++++++++++++---------------------- 1 files changed, 35 insertions(+), 22 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 0e25f5d..5a027de 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 @@ -43,12 +43,12 @@ /** * 调度建议内容 */ - 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) { @@ -82,27 +82,13 @@ // 保存预警信息 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()); } // 保存调度建议 @@ -128,13 +114,13 @@ 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); @@ -144,4 +130,31 @@ 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); + } } \ No newline at end of file -- Gitblit v1.9.3