Browse Source

Merge remote-tracking branch 'origin/develop' into develop

develop
wangsixiang 3 months ago
parent
commit
95e84dfea4
  1. 16
      zc-business/src/main/java/com/zc/business/service/impl/DcSdhsEventServiceImpl.java

16
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<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;
}
}

Loading…
Cancel
Save