|
@@ -107,37 +107,42 @@ public class ShutdownEventService extends ServiceImpl<ShutdownEventMapper, Shut
|
|
|
List<ShutdownEvent> list = shutdownEventMapper.queryShutdownEventCurrentDate(stId,currentDate);
|
|
|
|
|
|
List<StopType> stopTypes = stopTypeMapper.queryStopTypeList("gz");
|
|
|
- List<String> oritypes = stopTypes.stream().map(StopType::getId).collect(Collectors.toList());
|
|
|
- Map<String, String> maps = stopTypes.stream().collect(Collectors.toMap(StopType::getId, StopType::getName, (key1, key2) -> key2));
|
|
|
- Map<String, List<ShutdownEvent>> groupbyTypes = list.stream().collect(Collectors.groupingBy(ShutdownEvent::getStoptypeId));
|
|
|
- double hours = 0;
|
|
|
Map<String, StopTypeCount> resultMap = new TreeMap<>();
|
|
|
- List <String> types = new ArrayList<>();
|
|
|
- StopTypeCount count = null;
|
|
|
- for (Map.Entry<String, List<ShutdownEvent>> groupbyType : groupbyTypes.entrySet()) {
|
|
|
- count = new StopTypeCount();
|
|
|
- hours = groupbyType.getValue().stream().mapToDouble(ShutdownEvent::getStopHours).sum();
|
|
|
- count.setTime(hours);
|
|
|
- count.setCount(groupbyType.getValue().size());
|
|
|
- count.setType(null == maps.get(groupbyType.getKey())? "": maps.get(groupbyType.getKey()));
|
|
|
- count.setTypeID(groupbyType.getKey());
|
|
|
- resultMap.put(groupbyType.getKey(),count);
|
|
|
- types.add(groupbyType.getKey());
|
|
|
- }
|
|
|
-
|
|
|
- List<String> subList = oritypes.stream().filter(item -> !types.contains(item)).collect(Collectors.toList());
|
|
|
+ if(!list.isEmpty())
|
|
|
+ {
|
|
|
+ List<String> oritypes = stopTypes.stream().map(StopType::getId).collect(Collectors.toList());
|
|
|
+ Map<String, String> maps = stopTypes.stream().collect(Collectors.toMap(StopType::getId, StopType::getName, (key1, key2) -> key2));
|
|
|
+ Map<String, List<ShutdownEvent>> groupbyTypes = list.stream().collect(Collectors.groupingBy(ShutdownEvent::getStoptypeId));
|
|
|
+ double hours = 0;
|
|
|
+
|
|
|
+ List <String> types = new ArrayList<>();
|
|
|
+ StopTypeCount count = null;
|
|
|
+ for (Map.Entry<String, List<ShutdownEvent>> groupbyType : groupbyTypes.entrySet()) {
|
|
|
+ count = new StopTypeCount();
|
|
|
+ hours = groupbyType.getValue().stream().mapToDouble(ShutdownEvent::getStopHours).sum();
|
|
|
+ count.setTime(hours);
|
|
|
+ count.setCount(groupbyType.getValue().size());
|
|
|
+ count.setType(null == maps.get(groupbyType.getKey())? "": maps.get(groupbyType.getKey()));
|
|
|
+ count.setTypeID(groupbyType.getKey());
|
|
|
+ resultMap.put(groupbyType.getKey(),count);
|
|
|
+ types.add(groupbyType.getKey());
|
|
|
+ }
|
|
|
|
|
|
- for (String s:subList) {
|
|
|
- if("gzbmq".equals(s)){
|
|
|
- continue;
|
|
|
+ List<String> subList = oritypes.stream().filter(item -> !types.contains(item)).collect(Collectors.toList());
|
|
|
+
|
|
|
+ for (String s:subList) {
|
|
|
+ if("gzbmq".equals(s)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ count = new StopTypeCount();
|
|
|
+ count.setTime(0);
|
|
|
+ count.setCount(0);
|
|
|
+ count.setType(null == maps.get(s)? "": maps.get(s));
|
|
|
+ count.setTypeID(s);
|
|
|
+ resultMap.put(s,count);
|
|
|
}
|
|
|
- count = new StopTypeCount();
|
|
|
- count.setTime(0);
|
|
|
- count.setCount(0);
|
|
|
- count.setType(null == maps.get(s)? "": maps.get(s));
|
|
|
- count.setTypeID(s);
|
|
|
- resultMap.put(s,count);
|
|
|
}
|
|
|
+
|
|
|
return resultMap;
|
|
|
}
|
|
|
|