|
|
@ -1015,9 +1015,19 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { |
|
|
|
monthlyCounts.merge(monthString, 0L, Long::sum); |
|
|
|
currentMonth = currentMonth.plusMonths(1); |
|
|
|
} |
|
|
|
// 将键值对放入TreeMap中,TreeMap会自动按键排序
|
|
|
|
Map<String, Long> monthlyCountsTreeMap = new TreeMap<>(monthlyCounts); |
|
|
|
return monthlyCountsTreeMap; |
|
|
|
//
|
|
|
|
|
|
|
|
Map<String, Long> sortedMonthlyCounts = new LinkedHashMap<>(); |
|
|
|
|
|
|
|
Map<Integer, Long> 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; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|