From 0ea54edfb4d2ad45b50529247fd1d8caef053c07 Mon Sep 17 00:00:00 2001 From: xuhy <3313886187@qq.com> Date: 星期四, 31 十月 2024 14:24:39 +0800 Subject: [PATCH] 修改 --- ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TFoundationPersonServiceImpl.java | 43 +++++++++++++++++++++++++++++-------------- 1 files changed, 29 insertions(+), 14 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TFoundationPersonServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TFoundationPersonServiceImpl.java index 52a9bcd..06e65f3 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TFoundationPersonServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TFoundationPersonServiceImpl.java @@ -19,6 +19,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; +import java.util.ArrayList; import java.util.Comparator; import java.util.HashSet; import java.util.List; @@ -122,20 +123,34 @@ } @Override - public List<TFoundationPersonVO> getSetList(TFoundationPersonQuery query) { - List<TFoundationPersonVO> list = this.baseMapper.getSetList(query); - List<Long> ids = list.stream().map(TFoundationPersonVO::getId).collect(Collectors.toList()); - if(!CollectionUtils.isEmpty(ids)){ - List<TFoundationConfig> list1 = foundationConfigService.list(Wrappers.lambdaQuery(TFoundationConfig.class) - .in(TFoundationConfig::getPersonId, ids)); - list.forEach(item -> { - List<TFoundationConfig> collect = list1.stream().filter(item1 -> item1.getPersonId().equals(item.getId())).collect(Collectors.toList()); - if(!CollectionUtils.isEmpty(collect)){ - item.setMinDish(collect.stream().sorted(Comparator.comparingInt(TFoundationConfig::getMinCount)).findFirst().get().getMinCount()); - item.setMaxDish(collect.stream().sorted(Comparator.comparingInt(TFoundationConfig::getMaxCount).reversed()).findFirst().get().getMaxCount()); - item.setFoundationConfigs(collect); - } - }); + public List<TFoundationPersonVO> getSetList() { + List<TFoundationPersonVO> list = new ArrayList<>(); + List<TFoundationPersonVO> setList = this.baseMapper.getSetList(); + for (int i = 1; i <= 2; i++) { + TFoundationPersonVO foundationPersonVO = new TFoundationPersonVO(); + foundationPersonVO.setMealType(i); + int finalI = i; + List<TFoundationPersonVO> collect = setList.stream().filter(e -> e.getMealType() == finalI).collect(Collectors.toList()); + if(!CollectionUtils.isEmpty(collect)){ + Integer minPerson = collect.stream().sorted(Comparator.comparingInt(TFoundationPerson::getMealCount)).findFirst().get().getMealCount(); + foundationPersonVO.setMinPerson(minPerson); + Integer maxPerson = collect.stream().sorted(Comparator.comparingInt(TFoundationPerson::getMealCount).reversed()).findFirst().get().getMealCount(); + foundationPersonVO.setMaxPerson(maxPerson); + } + List<Long> ids = collect.stream().map(TFoundationPersonVO::getId).collect(Collectors.toList()); + if(!CollectionUtils.isEmpty(ids)){ + List<TFoundationConfig> list1 = foundationConfigService.list(Wrappers.lambdaQuery(TFoundationConfig.class) + .in(TFoundationConfig::getPersonId, ids)); + list.forEach(item -> { + List<TFoundationConfig> collect1 = list1.stream().filter(item1 -> item1.getPersonId().equals(item.getId())).collect(Collectors.toList()); + if(!CollectionUtils.isEmpty(collect1)){ + item.setMinDish(collect1.stream().sorted(Comparator.comparingInt(TFoundationConfig::getMinCount)).findFirst().get().getMinCount()); + item.setMaxDish(collect1.stream().sorted(Comparator.comparingInt(TFoundationConfig::getMaxCount).reversed()).findFirst().get().getMaxCount()); + item.setFoundationConfigs(collect1); + } + }); + } + list.add(foundationPersonVO); } return list; } -- Gitblit v1.7.1