| | |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.concurrent.CopyOnWriteArrayList; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | private static Map<String, Long> lastRunTime = new ConcurrentHashMap<>(); |
| | | |
| | | public static Map<Long, List<String>> finishModuleMap = new ConcurrentHashMap<>(); |
| | | |
| | | public static List<Long> finishAlarmMap = new CopyOnWriteArrayList<>(); |
| | | |
| | | /** |
| | | * 监听预测完成,产生预警消息 |
| | |
| | | log.info("AlarmPreData: " + JSONArray.toJSONString(result)); |
| | | |
| | | // 对比预测值是否超限 |
| | | int fromIndex = 0; |
| | | int toIndex = result.size(); |
| | | int fromIndex = result.size() - configItem.getCompLength(); |
| | | if (!configItem.getCompLength().contains(",")) { |
| | | fromIndex = result.size() - Integer.parseInt(configItem.getCompLength().trim()); |
| | | } else { |
| | | String[] cpArr = configItem.getCompLength().split(","); |
| | | fromIndex = Integer.parseInt(cpArr[0]); |
| | | toIndex = Integer.parseInt(cpArr[1]); |
| | | } |
| | | log.info("fromIndex:" + fromIndex); |
| | | log.info("toIndex:" + toIndex); |
| | | List<Object[]> predictList = result.subList(fromIndex, toIndex); |
| | | for (Object[] data : predictList) { |
| | | BigDecimal dataValue = new BigDecimal(Double.parseDouble(data[1].toString())).setScale(2, BigDecimal.ROUND_HALF_UP); |
| | |
| | | |
| | | if (CollectionUtils.isEmpty(alarmList)) { |
| | | log.info("alarmList is empty"); |
| | | return; |
| | | // return; |
| | | } else { |
| | | finishAlarmMap.add(predictTime.getTime()); |
| | | } |
| | | |
| | | log.info("发送预警消息"); |
| | | Map<String, Object> msg = new HashMap<>(2); |
| | | msg.put("predictTime", DateUtils.format(predictTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); |