|
|
@ -253,9 +253,23 @@ public class StatusController extends BaseController { |
|
|
|
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<>(); |
|
|
|
|
|
|
|
for (Map.Entry<String, List<Status>> entrys : typeMap.entrySet()) { |
|
|
|
itemTypeMap.forEach((key, value) -> { |
|
|
|
|
|
|
|
Map<String, String> maps = new HashMap<>(); |
|
|
|
List<Status> groupItems = entrys.getValue(); |
|
|
|
List<Status> groupItems = typeMap.get(key); |
|
|
|
if (groupItems == null) { |
|
|
|
//丢包率
|
|
|
|
maps.put("lostRate", "0%"); |
|
|
|
//在线率
|
|
|
|
maps.put("sucessRate", "0%"); |
|
|
|
//离线率
|
|
|
|
maps.put("failRate", "0%"); |
|
|
|
//已使用数量
|
|
|
|
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(); |
|
|
@ -272,11 +286,37 @@ public class StatusController extends BaseController { |
|
|
|
//已使用数量
|
|
|
|
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); |
|
|
|
} |
|
|
|
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
|
|
|
|