Browse Source

事件时间分析排序

develop
王兴琳 3 months ago
parent
commit
5b3e47de82
  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); monthlyCounts.merge(monthString, 0L, Long::sum);
currentMonth = currentMonth.plusMonths(1); 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