| | |
| | | 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); |
| | |
| | | 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(); |
| | |
| | | } |
| | | outerLoop: |
| | | for (AlarmConfigRespDTO configItem : configList) { |
| | | log.info("configItem: " + configItem); |
| | | List<Object[]> result = preData.get(configItem.getOutId()); |
| | | if (CollectionUtils.isEmpty(result)) { |
| | | continue; |
| | |
| | | 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; |
| | | } |
| | | // 预警记录 |
| | |
| | | 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; |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | 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(); |