Browse Source

高速云事件排序

develop
lau572 3 months ago
parent
commit
d9914f2c76
  1. 32
      zc-business/src/main/java/com/zc/business/service/impl/DcSdhsEventServiceImpl.java

32
zc-business/src/main/java/com/zc/business/service/impl/DcSdhsEventServiceImpl.java

@ -1305,15 +1305,34 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService {
Map<String, Long> region = eventList.stream()
.collect(Collectors.groupingBy(item -> getRange(item.getStakeMark()), Collectors.counting()));
List<Map<String, Object>> list = new ArrayList<>();
region.forEach((key, count) -> {
for (String key : region.keySet()) {
Map<String, Object> map = new HashMap<>();
map.put("regionName", key);
map.put("num", count);
map.put("num", region.get(key));
list.add(map);
});
}
list = list.stream().sorted(Comparator.comparing(item -> getCitySorted(item.get("regionName").toString()))).collect(Collectors.toList());
return AjaxResult.success(list);
}
private int getCitySorted(String city){
if (StringUtils.isEmpty(city)){
return 5;
}
if ("济南".equals(city)){
return 1;
} else if ("泰安".equals(city)){
return 2;
} else if ("济宁".equals(city)){
return 3;
} else if ("菏泽".equals(city)){
return 4;
} else {
return 5;
}
}
private static String getRange(String stakeMark) {
Long stakeMarkMetre = StakeMarkUtils.formatMetreLong(stakeMark);
@ -1640,12 +1659,13 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService {
if (eventList.size() > 0) {
//根据详细类型 分组计数
Map<String, Long> subclass = eventList.stream().collect(Collectors.groupingBy(DcSdhsEvent::getEventSubclass, Collectors.counting()));
subclass.forEach((key, count) -> {
for (String key : subclass.keySet()) {
Map<String, Object> map = new HashMap<>();
map.put("subclassName", key);
map.put("num", count);
map.put("num", subclass.get(key));
list.add(map);
});
}
list = list.stream().sorted(Comparator.comparing(item -> Long.valueOf(item.get("num").toString()))).collect(Collectors.toList());
}
return AjaxResult.success(list);

Loading…
Cancel
Save