|
|
@ -244,39 +244,79 @@ public class StatusController extends BaseController { |
|
|
|
//根据时间分组
|
|
|
|
Map<Integer, List<Status>> map = listStatus.stream() |
|
|
|
.collect(Collectors.groupingBy(Status -> Status.getTime().getHour())); |
|
|
|
if(StringUtils.isEmpty(map)){ |
|
|
|
if (StringUtils.isEmpty(map)) { |
|
|
|
return AjaxResult.success("暂无数据"); |
|
|
|
} |
|
|
|
Map<Integer, List<Status>> ipMap = new TreeMap<>(map); |
|
|
|
Integer lastKey = Collections.max(ipMap.keySet()); |
|
|
|
List<Status> lastEntry = ipMap.get(lastKey); |
|
|
|
Map<String, List<Status>> typeMap = lastEntry.stream().filter(iteam -> iteam.getType() != null).collect(Collectors.groupingBy(Status::getType)); |
|
|
|
Map<String,Map<String,String>> subMap=new HashMap<>(); |
|
|
|
Map<String, Map<String, String>> subMap = new HashMap<>(); |
|
|
|
|
|
|
|
for (Map.Entry<String, List<Status>> entrys : typeMap.entrySet()) { |
|
|
|
Map<String, String> maps=new HashMap<>(); |
|
|
|
List<Status> groupItems = entrys.getValue(); |
|
|
|
double lostRate = groupItems.stream() |
|
|
|
.mapToDouble(Status -> Double.parseDouble(Status.getLostRate().replace("%", ""))) // 去掉%,并转换为double
|
|
|
|
.average().getAsDouble(); |
|
|
|
double sucessRate = groupItems.stream() |
|
|
|
.mapToDouble(Status -> Double.parseDouble(Status.getSuccessRate().replace("%", ""))) // 去掉%,并转换为double
|
|
|
|
.average().getAsDouble(); |
|
|
|
String failRate=String.format("%.2f", (100-sucessRate))+"%"; |
|
|
|
//丢包率
|
|
|
|
maps.put("lostRate",String.format("%.2f", lostRate)+"%"); |
|
|
|
//在线率
|
|
|
|
maps.put("sucessRate",String.format("%.2f", sucessRate)+"%"); |
|
|
|
//离线率
|
|
|
|
maps.put("failRate",failRate); |
|
|
|
//已使用数量
|
|
|
|
maps.put("sumUseState",String.valueOf(groupItems.size())); |
|
|
|
//总数
|
|
|
|
maps.put("sum", String.valueOf(dcDeviceList.stream().filter(item -> Objects.equals(item.getDeviceType(), entrys.getKey())).map(DcDevice::getSumAll).collect(Collectors.toList()).get(0))); |
|
|
|
if(itemTypeMap.get(entrys.getKey())!=null) { |
|
|
|
subMap.put(itemTypeMap.get(entrys.getKey()), maps); |
|
|
|
itemTypeMap.forEach((key, value) -> { |
|
|
|
|
|
|
|
Map<String, String> maps = new HashMap<>(); |
|
|
|
List<Status> groupItems = typeMap.get(key); |
|
|
|
if (groupItems == null) { |
|
|
|
//丢包率
|
|
|
|
maps.put("lostRate", "0%"); |
|
|
|
//在线率
|
|
|
|
maps.put("sucessRate", "0%"); |
|
|
|
//离线率
|
|
|
|
maps.put("failRate", "100%"); |
|
|
|
//已使用数量
|
|
|
|
maps.put("sumUseState", "0"); |
|
|
|
//总数
|
|
|
|
maps.put("sum", String.valueOf(dcDeviceList.stream().filter(item -> Objects.equals(item.getDeviceType(), key)).map(DcDevice::getSumAll).collect(Collectors.toList()).get(0))); |
|
|
|
subMap.put(itemTypeMap.get(key), maps); |
|
|
|
} else { |
|
|
|
double lostRate = groupItems.stream() |
|
|
|
.mapToDouble(Status -> Double.parseDouble(Status.getLostRate().replace("%", ""))) // 去掉%,并转换为double
|
|
|
|
.average().getAsDouble(); |
|
|
|
double sucessRate = groupItems.stream() |
|
|
|
.mapToDouble(Status -> Double.parseDouble(Status.getSuccessRate().replace("%", ""))) // 去掉%,并转换为double
|
|
|
|
.average().getAsDouble(); |
|
|
|
String failRate = String.format("%.2f", (100 - sucessRate)) + "%"; |
|
|
|
//丢包率
|
|
|
|
maps.put("lostRate", String.format("%.2f", lostRate) + "%"); |
|
|
|
//在线率
|
|
|
|
maps.put("sucessRate", String.format("%.2f", sucessRate) + "%"); |
|
|
|
//离线率
|
|
|
|
maps.put("failRate", failRate); |
|
|
|
//已使用数量
|
|
|
|
maps.put("sumUseState", String.valueOf(groupItems.size())); |
|
|
|
//总数
|
|
|
|
maps.put("sum", String.valueOf(dcDeviceList.stream().filter(item -> Objects.equals(item.getDeviceType(), key)).map(DcDevice::getSumAll).collect(Collectors.toList()).get(0))); |
|
|
|
subMap.put(itemTypeMap.get(key), maps); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
//for (Map.Entry<String, List<Status>> entrys : typeMap.entrySet()) {
|
|
|
|
// Map<String, String> maps=new HashMap<>();
|
|
|
|
// List<Status> groupItems = entrys.getValue();
|
|
|
|
// double lostRate = groupItems.stream()
|
|
|
|
// .mapToDouble(Status -> Double.parseDouble(Status.getLostRate().replace("%", ""))) // 去掉%,并转换为double
|
|
|
|
// .average().getAsDouble();
|
|
|
|
// double sucessRate = groupItems.stream()
|
|
|
|
// .mapToDouble(Status -> Double.parseDouble(Status.getSuccessRate().replace("%", ""))) // 去掉%,并转换为double
|
|
|
|
// .average().getAsDouble();
|
|
|
|
// String failRate=String.format("%.2f", (100-sucessRate))+"%";
|
|
|
|
// //丢包率
|
|
|
|
// maps.put("lostRate",String.format("%.2f", lostRate)+"%");
|
|
|
|
// //在线率
|
|
|
|
// maps.put("sucessRate",String.format("%.2f", sucessRate)+"%");
|
|
|
|
// //离线率
|
|
|
|
// maps.put("failRate",failRate);
|
|
|
|
// //已使用数量
|
|
|
|
// maps.put("sumUseState",String.valueOf(groupItems.size()));
|
|
|
|
// //总数
|
|
|
|
// maps.put("sum", String.valueOf(dcDeviceList.stream().filter(item -> Objects.equals(item.getDeviceType(), entrys.getKey())).map(DcDevice::getSumAll).collect(Collectors.toList()).get(0)));
|
|
|
|
// if(itemTypeMap.get(entrys.getKey())!=null) {
|
|
|
|
// subMap.put(itemTypeMap.get(entrys.getKey()), maps);
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
Map<String, String> maps=new HashMap<>(); |
|
|
|
double lostRate = lastEntry.stream() |
|
|
|
.mapToDouble(Status -> Double.parseDouble(Status.getLostRate().replace("%", ""))) // 去掉%,并转换为double
|
|
|
|