From d9914f2c7693e72f24b09c4404db21317faf4938 Mon Sep 17 00:00:00 2001 From: lau572 <1010031226@qq.com> Date: Tue, 27 Aug 2024 17:04:53 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E9=AB=98=E9=80=9F=E4=BA=91=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/DcSdhsEventServiceImpl.java | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcSdhsEventServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcSdhsEventServiceImpl.java index c93283f6..5401fc43 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcSdhsEventServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcSdhsEventServiceImpl.java @@ -1305,15 +1305,34 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { Map region = eventList.stream() .collect(Collectors.groupingBy(item -> getRange(item.getStakeMark()), Collectors.counting())); List> list = new ArrayList<>(); - region.forEach((key, count) -> { + for (String key : region.keySet()) { Map 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 subclass = eventList.stream().collect(Collectors.groupingBy(DcSdhsEvent::getEventSubclass, Collectors.counting())); - subclass.forEach((key, count) -> { + for (String key : subclass.keySet()) { Map 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); From 1560b578866932f7a7200e16a08167f6b468c661 Mon Sep 17 00:00:00 2001 From: lau572 <1010031226@qq.com> Date: Tue, 27 Aug 2024 17:10:37 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E9=AB=98=E9=80=9F=E4=BA=91=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E5=80=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/zc/business/service/impl/DcSdhsEventServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcSdhsEventServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcSdhsEventServiceImpl.java index 5401fc43..9bbeb028 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcSdhsEventServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcSdhsEventServiceImpl.java @@ -1665,7 +1665,7 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { 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()); + list = list.stream().sorted(Comparator.comparing(item -> Long.valueOf(((Map) item).get("num").toString())).reversed()).collect(Collectors.toList()); } return AjaxResult.success(list);