终端异常统计定时任务优化

This commit is contained in:
zhuxinyu
2023-05-05 16:36:23 +08:00
parent d654b49ff9
commit 017f9205d2

View File

@@ -47,9 +47,16 @@ public class DeviceAbnormaStatisticsServiceImpl implements DeviceAbnormalStatist
// 根据装置id分组
Map<String, List<AlarmPO>> devMap = lines.stream().collect(Collectors.groupingBy(AlarmPO::getDeviceId));
// 监测点集合
List<String> monotorIds = lines.stream().map(AlarmPO::getId).collect(Collectors.toList());
// List<String> monotorIds = lines.stream().map(AlarmPO::getId).collect(Collectors.toList());
// 装置id集合
List<String> devIds = new ArrayList<>(devMap.keySet());
// List<String> devIds = new ArrayList<>(devMap.keySet());
List<AlarmPO> monitors = devMap.get("f82ab14fd5950ac5f7deaf75af360333");
List<String> monotorIds = monitors.stream().map(AlarmPO::getId).collect(Collectors.toList());
List<String> devIds = new ArrayList(Collections.singleton("f82ab14fd5950ac5f7deaf75af360333"));
Map<String, List<AlarmPO>> map = new HashMap<>();
map.put("f82ab14fd5950ac5f7deaf75af360333",monitors);
// 获取异常告警策略
List<AlarmStrategyVO> alarmStrategyVOS = deviceAbnormaStatisticsMapper.selectAlarmStrategy();
Map<Integer, List<AlarmStrategyVO>> levMap = alarmStrategyVOS.stream().collect(Collectors.groupingBy(AlarmStrategyVO::getAlgoDesc));
@@ -84,7 +91,7 @@ public class DeviceAbnormaStatisticsServiceImpl implements DeviceAbnormalStatist
}
// 整合装置信息
List<TopMsgPO> topMsgPOS = new ArrayList<>();
for (Map.Entry<String, List<AlarmPO>> devEntry : devMap.entrySet()) {
for (Map.Entry<String, List<AlarmPO>> devEntry : map.entrySet()) {
TopMsgPO topMsg = new TopMsgPO();
topMsg.setDevId(devEntry.getKey());
int deviceLevel = devEntry.getValue().stream().mapToInt(AlarmPO::getLevel).min().orElse(-1);
@@ -145,10 +152,7 @@ public class DeviceAbnormaStatisticsServiceImpl implements DeviceAbnormalStatist
}
}
for (TopMsgPO topMsgPO : topMsgPOS) {
System.out.println(topMsgPO);
}
return deviceAbnormaStatisticsMapper.insertTopMsg(topMsgPOS);
return topMsgPOS.size()>0 ? deviceAbnormaStatisticsMapper.insertTopMsg(topMsgPOS) : true;
}
public List<TopMsgPO> getCommunicate(List<String> devs, String time) {