From 6cca4d5caa2f5c2e1d14c8a9908845f1b4999b8d Mon Sep 17 00:00:00 2001 From: dx <1242347652@qq.com> Date: Fri, 28 Feb 2025 15:04:11 +0800 Subject: [PATCH] =?UTF-8?q?bug=20=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/service/home/HomeServiceImpl.java | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/home/HomeServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/home/HomeServiceImpl.java index 6cc6d07..d0cbd5f 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/home/HomeServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/home/HomeServiceImpl.java @@ -20,6 +20,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.time.LocalDateTime; import java.util.ArrayList; +import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.stream.Collectors; @@ -132,11 +133,26 @@ public class HomeServiceImpl implements HomeService{ //排序 - final List sortCollect = homeGroupCountVOS1.stream(). - sorted(Comparator.comparing(HomeListVO::getValue).reversed()). - collect(Collectors.toList()); + final List sortedList = homeGroupCountVOS1.stream() + .filter(item -> item.getValue() != null && !item.getValue().isEmpty()) // 过滤掉 null 或空字符串 + .sorted(Comparator.comparing( + item -> { + try { + return Double.parseDouble(item.getValue()); // 将字符串转为 double + } catch (NumberFormatException e) { + return Double.MIN_VALUE; // 如果解析失败,视为最小值 + } + } + )) // 升序排序 + .collect(Collectors.toList()); - homeCountResVO.setCompletionRate(sortCollect); + if (sortedList != null && sortedList.size() > 0) { + List reversedList = new ArrayList<>(); + for (int i = sortedList.size() - 1; i >= 0; i--) { + reversedList.add(sortedList.get(i)); + } + homeCountResVO.setCompletionRate(reversedList); + } return homeCountResVO; }