From 5b3e47de8286e9adf445345e6390553956d75f50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=85=B4=E7=90=B3?= <1911390090@qq.com> Date: Tue, 27 Aug 2024 14:23:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E6=97=B6=E9=97=B4=E5=88=86?= =?UTF-8?q?=E6=9E=90=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 | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 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 bad631f7..c93283f6 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 @@ -1015,9 +1015,19 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { monthlyCounts.merge(monthString, 0L, Long::sum); currentMonth = currentMonth.plusMonths(1); } - // 将键值对放入TreeMap中,TreeMap会自动按键排序 - Map monthlyCountsTreeMap = new TreeMap<>(monthlyCounts); - return monthlyCountsTreeMap; + // + + Map sortedMonthlyCounts = new LinkedHashMap<>(); + + Map tempMap = new TreeMap<>(); + monthlyCounts.forEach((key, value) -> tempMap.put(Integer.parseInt(key), value)); + // 将排序后的数据重新放入LinkedHashMap + tempMap.forEach((key, value) -> { + String formattedKey = String.format("%02d", key); + sortedMonthlyCounts.put(formattedKey, value); + }); + + return sortedMonthlyCounts; } }