This commit is contained in:
sxu 2025-04-17 11:05:46 +08:00
parent 9c9935b57e
commit e2b43a52d7
1 changed files with 16 additions and 28 deletions

View File

@ -3,17 +3,15 @@ package com.bonus.canteen.core.menu.service.impl;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.bonus.canteen.core.alloc.domain.AllocStall;
import com.bonus.canteen.core.alloc.domain.AllocStallMealtime;
import com.bonus.canteen.core.alloc.mapper.AllocStallMapper;
import com.bonus.canteen.core.menu.domain.MenuRecipe;
import com.bonus.canteen.core.menu.dto.AppletReserveRecipeDTO;
import com.bonus.canteen.core.menu.service.IMenuAppRecipeService;
@ -41,6 +39,8 @@ import com.bonus.canteen.core.menu.domain.MenuAppRecipe;
public class MenuAppRecipeServiceImpl implements IMenuAppRecipeService {
@Autowired
private MenuAppRecipeMapper menuAppRecipeMapper;
@Autowired
AllocStallMapper allocStallMapper;
/**
* 查询移动端菜谱绑定关系
@ -120,7 +120,7 @@ public class MenuAppRecipeServiceImpl implements IMenuAppRecipeService {
@Override
public List<AppletReserveRecipeVO> getReserveRecipeDetailList(AppletReserveRecipeDTO content) {
this.generateRecipe(content.getRecipeId(), content.getApplyDate());
//this.generateRecipe(content.getRecipeId(), content.getApplyDate());
List<AppletReserveRecipeVO> resultList = menuAppRecipeMapper.selectReserveRecipe(content.getApplyDate(), content.getRecipeId());
if (ObjectUtil.isEmpty(resultList)) {
return resultList;
@ -129,8 +129,7 @@ public class MenuAppRecipeServiceImpl implements IMenuAppRecipeService {
return s2.getMealtimeType() - s1.getMealtimeType();
}));
Long stallId = menuAppRecipeMapper.selectStallIdByWrappers(Wrappers.lambdaQuery(MenuRecipe.class).eq(MenuRecipe::getRecipeId, content.getRecipeId()).eq(MenuRecipe::getDelFlag, DelFlagEnum.DEL_FALSE.key()));
AllocStall allocStall = new AllocStall(); //TODO 查询档口
AllocStall allocStall = allocStallMapper.selectAllocStallByStallId(stallId);
List<AllocStallMealtime> mealTimeList = allocStall.getAllocStallMealtimeList();
log.info("配置api查询的档口餐次,档口id: {}, 配置: {}", stallId, JSON.toJSONString(mealTimeList));
if (ObjectUtil.isEmpty(mealTimeList)) {
@ -151,21 +150,14 @@ public class MenuAppRecipeServiceImpl implements IMenuAppRecipeService {
resultList = resultList.stream().filter((time) -> {
return finalMealTimeList.stream().map(AllocStallMealtime::getMealtimeType).collect(Collectors.toList()).contains(time.getMealtimeType());
}).collect(Collectors.toList());
resultList.forEach((time) -> {
List<AppletReserveRecipeTypeVO> typeList = time.getTypeList();
if (ObjectUtil.isNotEmpty(typeList)) {
typeList.forEach((type) -> {
List<AppletReserveRecipeDishesVO> dishesList = type.getDishesList();
if (ObjectUtil.isNotEmpty(dishesList)) {
dishesList.forEach((dishes) -> {
dishes.setCostModelList(costModelList);
});
}
});
}
});
// resultList.forEach((time) -> {
// List<AppletReserveRecipeTypeVO> typeList = time.getTypeList();
// if (ObjectUtil.isNotEmpty(typeList)) {
// typeList.forEach((type) -> {
// List<AppletReserveRecipeDishesVO> dishesList = type.getDishesList();
// });
// }
// });
Set<Long> dishesIdSet = resultList.stream().flatMap((time) -> {
return time.getTypeList().stream().flatMap((type) -> {
return type.getDishesList().stream().map((item) -> {
@ -217,9 +209,5 @@ public class MenuAppRecipeServiceImpl implements IMenuAppRecipeService {
}
}
public void generateRecipe(Long recipeId, LocalDate applyDate) {
if (!ObjectUtil.isEmpty(recipeId) && !ObjectUtil.isEmpty(applyDate)) {
this.generateRecipe(Collections.singletonList(recipeId), applyDate);
}
}
}