From a813d5d4ce66b1cdb28ca703481e5e549502b062 Mon Sep 17 00:00:00 2001 From: dengzedong <dengzedong@email> Date: 星期二, 18 二月 2025 15:32:32 +0800 Subject: [PATCH] 预警逻辑调整 --- shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelPredictFinishConsumer.java | 45 ++++++++++++++++++++++++--------------------- shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/common/constant/CommonConstant.java | 3 +++ 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/common/constant/CommonConstant.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/common/constant/CommonConstant.java index ee3e176..48d5367 100644 --- a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/common/constant/CommonConstant.java +++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/common/constant/CommonConstant.java @@ -38,6 +38,9 @@ String NET_O2 = "NET_O2"; String NET_LDG = "NET_LDG"; + String NET_LDG1 = "NET_LDG1"; + String NET_LDG2 = "NET_LDG2"; + String NET_LDG3 = "NET_LDG3"; String NET_STEAM = "NET_STEAM"; diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelPredictFinishConsumer.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelPredictFinishConsumer.java index 8e890a1..4f41447 100644 --- a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelPredictFinishConsumer.java +++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelPredictFinishConsumer.java @@ -61,18 +61,7 @@ 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)) { - log.info("AlarmConfigList is empty"); - return; - } - 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)) { + if (moduleType.equals(CommonConstant.NET_BFG) || moduleType.equals(CommonConstant.NET_COG) || moduleType.equals(CommonConstant.NET_LDG1) || moduleType.equals(CommonConstant.NET_LDG2) || moduleType.equals(CommonConstant.NET_LDG3)) { String runKey = "GasAlarm_" + predictTime.getTime(); log.info("runKey:" + runKey); log.info("lastRunAlarm:" + lastRunAlarm); @@ -80,6 +69,20 @@ return; } lastRunAlarm = runKey; + + // 预警信息列表 + List<AlarmMessageRespDTO> alarmList = new ArrayList<>(); + // 根据管网查询相关预警配置 + Map<String,Object> params = new HashMap<>(); + params.put("alarmObj",moduleType); + List<AlarmConfigRespDTO> configList = mcsApi.listAlarmConfig(params); + if (CollectionUtils.isEmpty(configList)) { + log.info("AlarmConfigList is empty"); + return; + } + List<String> outputIdList = configList.stream().map(item -> { + return item.getOutId(); + }).collect(Collectors.toList()); // 查询预测结果 PreDataJsonReqVO reqVO = new PreDataJsonReqVO(); @@ -91,6 +94,7 @@ } outerLoop: for (AlarmConfigRespDTO configItem : configList) { + log.info("configItem: " + configItem); List<Object[]> result = preData.get(configItem.getOutId()); if (CollectionUtils.isEmpty(result)) { continue; @@ -103,7 +107,6 @@ for (Object[] data : predictList) { BigDecimal dataValue = new BigDecimal(Double.parseDouble(data[1].toString())).setScale(2, BigDecimal.ROUND_HALF_UP); if (dataValue.compareTo(configItem.getLowerLimit()) >= 0 && dataValue.compareTo(configItem.getUpperLimit()) <= 0) { - log.info("预测值不超限"); continue; } // 预警记录 @@ -140,7 +143,6 @@ for (Object[] data : result) { culValue += Double.parseDouble(data[1].toString()); if (culValue.compareTo(configItem.getCulLower().doubleValue()) >= 0 && culValue.compareTo(configItem.getCulUpper().doubleValue()) <= 0) { - log.info("累计值不超限"); continue; } @@ -173,13 +175,14 @@ } } } - } - if (!CollectionUtils.isEmpty(alarmList)) { - log.info("发送预警消息"); - Map<String, Object> msg = new HashMap<>(2); - msg.put("predictTime", DateUtils.format(predictTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); - msg.put("alarmList", alarmList); - rabbitTemplate.convertAndSend(RoutingConstant.EXCHANGE, RoutingConstant.Iailab_Model_Alarm, msg); + + if (!CollectionUtils.isEmpty(alarmList)) { + log.info("发送预警消息"); + Map<String, Object> msg = new HashMap<>(2); + msg.put("predictTime", DateUtils.format(predictTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); + msg.put("alarmList", alarmList); + rabbitTemplate.convertAndSend(RoutingConstant.EXCHANGE, RoutingConstant.Iailab_Model_Alarm, msg); + } } } catch (Exception e) { e.printStackTrace(); -- Gitblit v1.9.3