Compare commits

...

2 Commits

Author SHA1 Message Date
xiaozzzi
aa4bfb0c7d
Merge pull request #103 from klaus-cicd/dev
perf: 优化待办导出排序规则(日期增序)
2024-03-29 13:03:57 +08:00
Klaus
aa6a8d36c3 perf: 优化待办导出排序规则(日期增序) 2024-03-29 10:36:12 +08:00

View File

@ -58,9 +58,16 @@ public class TodoUtil {
if (CollUtil.isEmpty(todos)) {
return "无内容";
}
Map<String, List<TodoEntity>> maps = todos.stream().collect(Collectors.groupingBy(TodoEntity::getTodoName));
List<Map.Entry<String, List<TodoEntity>>> entryList = todos.stream()
.collect(Collectors.groupingBy(TodoEntity::getTodoName))
// 增加根据Todo name的排序
.entrySet().stream().sorted(Map.Entry.comparingByKey()).collect(Collectors.toList());
StringBuilder sb = new StringBuilder();
maps.forEach((todoName, tasks) -> {
entryList.forEach(entry -> {
String todoName = entry.getKey();
List<TodoEntity> tasks = entry.getValue();
sb.append(String.format("# %s \n\n", todoName));
for (TodoEntity task : tasks) {