沙钢智慧能源系统后端代码
潘志宝
2025-01-21 6fb7534adeaffd1caf325210a2353a85ab79a454
shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelPredictFinishConsumer.java
@@ -39,6 +39,8 @@
    @Resource
    private RabbitTemplate rabbitTemplate;
    private static String lastRunAlarm = "";
    /**
     * 监听预测完成,产生预警消息
     *
@@ -55,8 +57,10 @@
            if (CollectionUtils.isEmpty(messageJson)) {
                return;
            }
            // 预测时间
            Date predictTime = DateUtils.parse(messageJson.get("predictTime").toString(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND);
            // 预测模块/预测管网
            String moduleType = messageJson.get("moduleType").toString();
            // 查询相关预警配置
            List<AlarmConfigRespDTO> configList = mcsApi.listAlarmConfig(new HashMap<String, Object>());
            if (CollectionUtils.isEmpty(configList)) {
@@ -66,8 +70,16 @@
            List<String> outputIdList = configList.stream().map(item -> {
                return item.getOutId();
            }).collect(Collectors.toList());
            List<AlarmMessageRespDTO> alarmList = new ArrayList<>();
            if (moduleType.equals(CommonConstant.NET_BFG) || moduleType.equals(CommonConstant.NET_COG) ||
                    moduleType.equals(CommonConstant.NET_LDG)) {
                String runKey = "GasAlarm_" +  predictTime.getTime();
                log.info("runKey:" + runKey);
                log.info("lastRunAlarm:" + lastRunAlarm);
                if (lastRunAlarm.equals(runKey)) {
                    return;
                }
                lastRunAlarm = runKey;
            for (AlarmConfigRespDTO configItem : configList) {
                PreDataJsonReqVO reqVO = new PreDataJsonReqVO();
                reqVO.setPredictTime(predictTime);
@@ -83,7 +95,6 @@
                    }).collect(Collectors.toList()).stream().mapToDouble(Double::doubleValue).sum();
                    culData.put(key, new BigDecimal(nv));
                });
                List<Object[]> result = preData.get(configItem.getOutId());
                if (CollectionUtils.isEmpty(result)) {
@@ -149,6 +160,7 @@
                    alarmList.add(alarmMessage);
                }
            }
            }
            if (!CollectionUtils.isEmpty(alarmList)) {
                log.info("发送预警消息");
                Map<String, Object> msg = new HashMap<>(2);