|
|
@ -89,30 +89,19 @@ public class StatusController extends BaseController { |
|
|
|
status.setStartTime(todayStart); |
|
|
|
status.setTime(currentTime); |
|
|
|
String[] types = status.getType().split(","); |
|
|
|
status.setTypes(types); |
|
|
|
|
|
|
|
Map<String, Map<String, String>> maps = new HashMap<>(); |
|
|
|
List<Status> statuses = statusService.getStatusList(status); |
|
|
|
|
|
|
|
for (String type : types) { |
|
|
|
status.setType(type); |
|
|
|
List<Status> listStatus = statusService.list(status); |
|
|
|
// List<Status> listStatu=listStatus.stream().filter(iteam ->iteam.getType()!=null && iteam.getType().equals(type)).collect(Collectors.toList());
|
|
|
|
//根据时间分组
|
|
|
|
Map<String, List<Status>> map = listStatus.stream() |
|
|
|
.collect(Collectors.groupingBy(Status -> (Status.getTime().getYear() + "-" + Status.getTime().getMonthValue() + "-" + Status.getTime().getDayOfMonth()))); |
|
|
|
//根据类型分组
|
|
|
|
// Map<String, List<Status>> maps = listStatu.stream().filter(iteam->iteam.getType()!=null).collect(Collectors.groupingBy(Status::getType));
|
|
|
|
//生成有序map
|
|
|
|
Map<String, List<Status>> mapTime = new TreeMap<>(map); |
|
|
|
Map<String, String> mapSort = new TreeMap<>(); |
|
|
|
for (Map.Entry<String, List<Status>> entry : mapTime.entrySet()) { |
|
|
|
List<Status> groupItems = entry.getValue(); |
|
|
|
long count = groupItems.stream().filter(iteam -> Objects.equals(iteam.getDeviceStatus(), "1")).count(); |
|
|
|
String onlineRate = String.format("%.2f%%", (double) count / groupItems.size() * 100); |
|
|
|
mapSort.put(entry.getKey(), onlineRate); |
|
|
|
} |
|
|
|
maps.put(type, mapSort); |
|
|
|
Map<String, String> collect = statuses.stream().filter(item -> Objects.equals(item.getType(), type)) |
|
|
|
.collect(Collectors.toMap( |
|
|
|
item -> item.getTime().getYear() + "-" + item.getTime().getMonthValue() + "-" + item.getTime().getDayOfMonth(), |
|
|
|
Status::getSuccessRate |
|
|
|
)); |
|
|
|
maps.put(type, collect); |
|
|
|
} |
|
|
|
// Map<String, List<Status>> mapStatus = new TreeMap<>(maps);
|
|
|
|
return AjaxResult.success(maps); |
|
|
|
} |
|
|
|
|
|
|
|