沙钢智慧能源系统后端代码
Jay
4 天以前 c0d47f557b4d202ea95a52434730a235ffb118a0
shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleSteamTask.java
@@ -58,6 +58,17 @@
     */
    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);
@@ -87,26 +98,32 @@
                return;
            }
            // 用户调整量
            double[][] adviceValues = (double[][])mdkScheduleRespDTO.getResult().get("user_adjust");
            logger.info("adviceValues=" + Arrays.toString(adviceValues));
            Object jinfengAdvice = mdkScheduleRespDTO.getResult().get("jinfengAdvice");
            saveScheduleSuggest("锦丰调度建议", jinfengAdvice, scheme.getScheduleObj(), scheduleTime, new BigDecimal(adviceValues[0][0]), scheme.getAdjustRate());
            logger.info("user_adjust=" + mdkScheduleRespDTO.getResult().get("user_adjust"));
            List<BigDecimal> adviceValues = new ArrayList<>();
            JSONArray ja0 = JSONArray.parseArray(mdkScheduleRespDTO.getResult().get("user_adjust").toString());
            JSONArray ja1 = ja0.getJSONArray(0);
            for(int i = 0; i < ja1.size(); i++) {
                adviceValues.add(new BigDecimal(ja1.get(i).toString()));
            }
            logger.info("adviceValues=" + JSONArray.toJSONString(adviceValues));
            Object daxinAdvice = mdkScheduleRespDTO.getResult().get("daxinAdvice");
            saveScheduleSuggest("大新调度建议", daxinAdvice, scheme.getScheduleObj(), scheduleTime, new BigDecimal(adviceValues[0][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) {
@@ -144,14 +161,22 @@
        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);