|
|
|
@ -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<HomeListVO> sortCollect = homeGroupCountVOS1.stream(). |
|
|
|
|
sorted(Comparator.comparing(HomeListVO::getValue).reversed()). |
|
|
|
|
collect(Collectors.toList()); |
|
|
|
|
final List<HomeListVO> 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<HomeListVO> reversedList = new ArrayList<>(); |
|
|
|
|
for (int i = sortedList.size() - 1; i >= 0; i--) { |
|
|
|
|
reversedList.add(sortedList.get(i)); |
|
|
|
|
} |
|
|
|
|
homeCountResVO.setCompletionRate(reversedList); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return homeCountResVO; |
|
|
|
|
} |
|
|
|
|