ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TFoundationPersonController.java
@@ -24,6 +24,8 @@ import java.time.LocalDateTime; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; /** * <p> @@ -59,7 +61,7 @@ @ApiOperation( value = "查询基础设置列表") @PostMapping(value = "/list") public AjaxResult<List<TFoundationPersonVO>> list(@RequestBody TFoundationPersonQuery query) { return AjaxResult.success(foundationPersonService.getSetList(query)); return AjaxResult.success(foundationPersonService.getSetList()); } /** @@ -87,18 +89,19 @@ */ @ApiOperation( value = "查看基础设置详情") @GetMapping(value = "/getDetailById") public AjaxResult<TFoundationPersonVO> getDetailById(@RequestParam("id") Long id) { public AjaxResult<List<TFoundationPersonVO>> getDetailByMealType(@RequestParam("mealType") Integer mealType) { // 查询基础设置 List<TFoundationConfig> list = foundationConfigService.list(Wrappers.lambdaQuery(TFoundationConfig.class) .eq(TFoundationConfig::getPersonId, id)); TFoundationPerson foundationPerson = foundationPersonService.getById(id); TFoundationPersonVO foundationPersonVO = new TFoundationPersonVO(); BeanUtils.copyProperties(foundationPerson, foundationPersonVO); foundationPersonVO.setFoundationConfigs(list); // 查询店铺 TShop shop = shopService.getById(foundationPersonVO.getShopId()); foundationPersonVO.setShop(shop); return AjaxResult.success(foundationPersonVO); List<TFoundationPersonVO> foundationPersonVOS = foundationPersonService.getSetList(); List<TFoundationPersonVO> collect = foundationPersonVOS.stream().filter(e -> Objects.equals(e.getMealType(), mealType)).collect(Collectors.toList()); for (TFoundationPersonVO foundationPersonVO : collect) { List<TFoundationConfig> list = foundationConfigService.list(Wrappers.lambdaQuery(TFoundationConfig.class) .eq(TFoundationConfig::getPersonId, foundationPersonVO.getId())); foundationPersonVO.setFoundationConfigs(list); // 查询店铺 TShop shop = shopService.getById(foundationPersonVO.getShopId()); foundationPersonVO.setShop(shop); } return AjaxResult.success(collect); } /** ruoyi-system/src/main/java/com/ruoyi/system/mapper/TFoundationPersonMapper.java
@@ -27,9 +27,8 @@ /** * 查询基础设置列表 * @param query * @return */ List<TFoundationPersonVO> getSetList(@Param("query")TFoundationPersonQuery query); List<TFoundationPersonVO> getSetList(); } ruoyi-system/src/main/java/com/ruoyi/system/service/TFoundationPersonService.java
@@ -47,6 +47,6 @@ */ boolean hasDuplicateId(List<TFoundationPersonDTO> list); List<TFoundationPersonVO> getSetList(TFoundationPersonQuery query); List<TFoundationPersonVO> getSetList(); } 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; } ruoyi-system/src/main/java/com/ruoyi/system/vo/TFoundationPersonVO.java
@@ -22,6 +22,12 @@ @ApiModelProperty(value = "最小菜品") private Integer minDish; @ApiModelProperty(value = "最大人数") private Integer maxPerson; @ApiModelProperty(value = "最小人数") private Integer minPerson; @ApiModelProperty(value = "店铺信息") private TShop shop;