From 71910079e61b3030a96bd4561e58493bfca7de82 Mon Sep 17 00:00:00 2001 From: xd <844539747@qq.com> Date: Tue, 30 Apr 2024 08:26:27 +0800 Subject: [PATCH] '1111' --- .../web/controller/system/SysNoticeController.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java index 3c73c51..45ae961 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java @@ -138,7 +138,18 @@ public class SysNoticeController extends BaseController Map> groupedByNoticeType = list.stream() .collect(Collectors.groupingBy(SysNoticeUser::getSendTimeFormat)); - for(String key:groupedByNoticeType.keySet()){ + + // 使用TreeMap并提供一个Comparator用于排序key + Map> sortedMap = new TreeMap<>(new Comparator() { + @Override + public int compare(String k1, String k2) { + // 降序排序 + return k2.compareTo(k1); + } + }); + sortedMap.putAll(groupedByNoticeType); + + for(String key:sortedMap.keySet()){ List lt = groupedByNoticeType.get(key); lt.sort((t1, t2) -> t2.getSendTime().compareTo(t1.getSendTime())); map = new HashMap<>();