| | |
| | | import com.ruoyi.system.vo.TFoundationPersonVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | public List<TFoundationPersonVO> getList() { |
| | | List<TFoundationPersonVO> list = this.baseMapper.getList(); |
| | | List<Long> ids = list.stream().map(TFoundationPersonVO::getId).collect(Collectors.toList()); |
| | | List<TFoundationConfig> list1 = foundationConfigService.list(Wrappers.lambdaQuery(TFoundationConfig.class) |
| | | .in(TFoundationConfig::getPersonId, ids)); |
| | | list.forEach(item -> { |
| | | item.setFoundationConfigs(list1.stream().filter(item1 -> item1.getPersonId().equals(item.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); |
| | | } |
| | | }); |
| | | } |
| | | return list; |
| | | } |
| | | } |