From a3bb1815c3eb6b0f0cfe9d9d2ba5ee48279e26ed Mon Sep 17 00:00:00 2001 From: dongyukun <1208714201@qq.com> Date: 星期五, 28 三月 2025 11:30:49 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleOnaOptTask.java | 72 ++++++++++++++++++++++++++--------- 1 files changed, 53 insertions(+), 19 deletions(-) diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleOnaOptTask.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleOnaOptTask.java index 18598ba..18734fe 100644 --- a/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleOnaOptTask.java +++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleOnaOptTask.java @@ -2,6 +2,7 @@ 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 com.iailab.module.model.api.mcs.dto.StScheduleSchemeDTO; import com.iailab.module.model.api.mdk.MdkApi; @@ -120,17 +121,10 @@ // 氧气系统优化调度决策 StScheduleSchemeDTO scheduleScheme = schemeMap.get(CODE05); String scheduleObj = scheduleScheme.getScheduleObj(); - String yingdiAdvice = entry.getValue().getResult().get("yingdiAdvice").toString(); + /*String yingdiAdvice = entry.getValue().getResult().get("yingdiAdvice").toString(); String faAdvice = entry.getValue().getResult().get("faAdvice").toString(); String hongAdvice = entry.getValue().getResult().get("hongAdvice").toString(); String runAdvice = entry.getValue().getResult().get("runAdvice").toString(); - /*JSONArray adviceValues = JSONArray.parseArray(entry.getValue().getResult().get("adviceValues").toString()); - List<BigDecimal> adviceValueList = new ArrayList<>(); - if (!CollectionUtils.isEmpty(adviceValues)) { - for (int i = 0; i < adviceValues.size(); i++) { - adviceValueList.add(new BigDecimal(adviceValues.get(i).toString())); - } - }*/ if(!yingdiAdvice.equals("压力正常")){ saveScheduleSuggest("盈德中压调整建议", yingdiAdvice, scheduleObj, scheduleTime); } @@ -142,19 +136,32 @@ } if(!runAdvice.equals("压力正常")){ saveScheduleSuggest("润忠调整建议", runAdvice, scheduleObj, scheduleTime); - } - } else if (entry.getKey().equals(CODE01)) { - StScheduleSchemeDTO scheduleScheme = schemeMap.get(CODE05); - String scheduleObj = scheduleScheme.getScheduleObj(); + }*/ + + BigDecimal adviceValues = new BigDecimal(entry.getValue().getResult().get("adviceValues").toString()); + logger.info("各制氧机组建议 adviceValues=" + adviceValues); + + String advice = entry.getValue().getResult().get("advice").toString(); - if(!"压力正常".equals(advice)){ - saveScheduleSuggest("氮气预警", advice, scheduleObj, scheduleTime); + if(adviceValues.compareTo(BigDecimal.ZERO) != 0){ + saveScheduleSuggest("各制氧机组建议", advice, scheduleObj, scheduleTime, adviceValues, scheduleScheme.getAdjustRate()); + } + + } else if (entry.getKey().equals(CODE01)) { + StScheduleSchemeDTO scheduleScheme = schemeMap.get(CODE01); + String scheduleObj = scheduleScheme.getScheduleObj(); + BigDecimal adviceValues = new BigDecimal(entry.getValue().getResult().get("advicevalues").toString()); + logger.info("氮气预警 adviceValues=" + adviceValues); + + String advice = entry.getValue().getResult().get("advice").toString(); + if(adviceValues.compareTo(BigDecimal.ZERO) != 0){ + saveAlarmMessage("氮气预警", advice, scheduleObj, scheduleTime,adviceValues,scheduleScheme.getAdjustRate()); } } } logger.info(params + "调度方案执行完成"); } catch (Exception ex) { - logger.error("RunScheduleOnaOptTask运行异常"); + logger.error("RunScheduleOnaOptTask运行异常",ex); ex.printStackTrace(); } logger.info("RunScheduleOnaOptTask运行完成"); @@ -162,6 +169,7 @@ private void saveScheduleSuggest(String title, String content, String scheduleObj, Date scheduleTime) { if (StringUtils.isBlank(content)) { + logger.info(title + "调整值为空,不产生建议"); return; } @@ -176,19 +184,20 @@ private void saveScheduleSuggest(String title, String content, String scheduleObj, Date scheduleTime, BigDecimal adjustValue, int adjustRate) { if (StringUtils.isBlank(content)) { + logger.info(title + "调整值为空,不产生建议"); return; } if (adjustValue == null || adjustValue.doubleValue() == 0) { logger.info(title + "调整值为空,不产生建议"); return; } - if (gasAdjustMode.containsKey(scheduleObj) && gasAdjustMode.get(scheduleObj).equals(adjustValue.compareTo(BigDecimal.ZERO)) && - gasLastSugTime.containsKey(scheduleObj) && (scheduleTime.getTime() - gasLastSugTime.get(scheduleObj).getTime() <= Integer.valueOf(adjustRate).longValue() * 60 * 1000)) { + 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(scheduleObj, adjustValue.compareTo(BigDecimal.ZERO)); - gasLastSugTime.put(scheduleObj, scheduleTime); + gasAdjustMode.put(title, adjustValue.compareTo(BigDecimal.ZERO)); + gasLastSugTime.put(title, scheduleTime); ScheduleSuggestRespDTO suggest = new ScheduleSuggestRespDTO(); suggest.setTitle(title); @@ -198,4 +207,29 @@ suggest.setSort(0); mcsApi.createScheduleSuggest(suggest); } + private void saveAlarmMessage(String title, String content, String scheduleObj, Date scheduleTime, BigDecimal adjustValue, int adjustRate) { + if (StringUtils.isBlank(content)) { + logger.info(title + "预警值为空,不产生预警"); + 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); + + AlarmMessageRespDTO alarm = new AlarmMessageRespDTO(); + alarm.setTitle(title); + alarm.setContent(content); + alarm.setAlarmObj(scheduleObj); + alarm.setAlarmType(adjustValue.compareTo(BigDecimal.ZERO) > 0 ? "超上限" : "超下限"); + alarm.setAlarmTime(scheduleTime); + mcsApi.createAlarmMessage(alarm); + } } \ No newline at end of file -- Gitblit v1.9.3