From 05c03159aca6e029a323dea77c6d3a18b2be3609 Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Sat, 7 Jun 2025 10:16:06 +0800 Subject: [PATCH] =?UTF-8?q?h5=E5=91=A8=E8=8F=9C=E8=B0=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cook/controller/CookH5Controller.java | 212 ++--- .../core/cook/mapper/CookH5Mapper.java | 94 +-- .../core/cook/service/ICookH5Service.java | 54 +- .../cook/service/impl/CookH5ServiceImpl.java | 556 ++++++------- .../resources/mapper/cook/CookH5Mapper.xml | 768 +++++++++--------- 5 files changed, 842 insertions(+), 842 deletions(-) diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/controller/CookH5Controller.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/controller/CookH5Controller.java index 63da636..38527e1 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/controller/CookH5Controller.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/controller/CookH5Controller.java @@ -1,106 +1,106 @@ -package com.bonus.canteen.core.cook.controller; - -import com.bonus.canteen.core.cook.dto.AppletDishesDetailDTO; -import com.bonus.canteen.core.cook.dto.CookH5WeekDetailsDTO; -import com.bonus.canteen.core.cook.dto.UserInfoDTO; -import com.bonus.canteen.core.cook.service.ICookH5Service; -import com.bonus.canteen.core.cook.dto.CookH5ReserveRecipeDTO; -import com.bonus.canteen.core.cook.vo.AppletDishesDetailVO; -import com.bonus.common.core.web.controller.BaseController; -import com.bonus.common.core.web.domain.AjaxResult; -import com.bonus.common.core.web.page.TableDataInfo; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.time.LocalDate; -import java.util.ArrayList; - -/** - * @author xliu - * @date 2025/5/28 9:20 - */ -@Api(tags = "H5菜品计划信息") -@RestController -@RequestMapping("/cook/h5") -public class CookH5Controller extends BaseController { - private static final Logger log = LoggerFactory.getLogger(CookH5Controller.class); - - @Resource - private ICookH5Service cookH5Service; - - @GetMapping({"/list/week/canteen"}) - @ApiOperation("获取一周菜谱食堂列表") - public AjaxResult getWeekMealList( UserInfoDTO dto) { - startPage(); - try { - return AjaxResult.success(this.cookH5Service.getWeekCanteenList(dto)); - } catch (Exception e) { - log.error(e.toString(), e); - return AjaxResult.error("获取一周菜谱食堂列表失败"); - } - } - - @ApiOperation("获取一周菜谱详情") - @GetMapping({"/week/recipe/detail"}) - public TableDataInfo getWeekRecipeDetail(@Valid CookH5WeekDetailsDTO dto) { - try { - startPage(); - dto.setApplyDate(LocalDate.parse(dto.getDate())); - return getDataTable(this.cookH5Service.getWeekRecipeDetail(dto)); - } catch (Exception e) { - log.error(e.toString(), e); - return getDataTable(new ArrayList<>()); - } - - } - - @ApiOperation("获取预定餐食堂列表") - @GetMapping({"/list/reserve/canteen"}) - public TableDataInfo getReserveMealCanteenList(@Valid UserInfoDTO dto) { - try { - startPage(); - return getDataTable(this.cookH5Service.getReserveCanteenList(dto)); - } catch (Exception e) { - log.error(e.toString(), e); - return getDataTable(new ArrayList<>()); - } - } - - - @ApiOperation("获取预定餐菜谱详情") - @PostMapping({"/reserve/recipe/detail"}) - public TableDataInfo getReserveRecipeDetailList(@RequestBody CookH5ReserveRecipeDTO content) { - try { - return getDataTable(this.cookH5Service.getReserveRecipeDetailList(content)); - } catch (Exception e) { - log.error(e.toString(), e); - return getDataTable(new ArrayList<>()); - } - } - - @PostMapping({"/scheduledTasks"}) - @ApiOperation("定时任务") - @Transactional - public AjaxResult scheduledTasks() { - this.cookH5Service.scheduledTask(); - return AjaxResult.success(); - } - - @PostMapping({"/detail"}) - @ApiOperation("根据菜品id获取菜品详情") - public AjaxResult getRecipeDetail(@RequestBody AppletDishesDetailDTO dto) { - try { - AppletDishesDetailVO dishesDetailVO = this.cookH5Service.getDishesDetailByDishesId(dto); - return success(dishesDetailVO); - }catch (Exception e) { - return AjaxResult.error(e.getMessage()); - } - } - -} +//package com.bonus.canteen.core.cook.controller; +// +//import com.bonus.canteen.core.cook.dto.AppletDishesDetailDTO; +//import com.bonus.canteen.core.cook.dto.CookH5WeekDetailsDTO; +//import com.bonus.canteen.core.cook.dto.UserInfoDTO; +//import com.bonus.canteen.core.cook.service.ICookH5Service; +//import com.bonus.canteen.core.cook.dto.CookH5ReserveRecipeDTO; +//import com.bonus.canteen.core.cook.vo.AppletDishesDetailVO; +//import com.bonus.common.core.web.controller.BaseController; +//import com.bonus.common.core.web.domain.AjaxResult; +//import com.bonus.common.core.web.page.TableDataInfo; +//import io.swagger.annotations.Api; +//import io.swagger.annotations.ApiOperation; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +//import org.springframework.transaction.annotation.Transactional; +//import org.springframework.web.bind.annotation.*; +// +//import javax.annotation.Resource; +//import javax.validation.Valid; +//import java.time.LocalDate; +//import java.util.ArrayList; +// +///** +// * @author xliu +// * @date 2025/5/28 9:20 +// */ +//@Api(tags = "H5菜品计划信息") +//@RestController +//@RequestMapping("/cook/h5") +//public class CookH5Controller extends BaseController { +// private static final Logger log = LoggerFactory.getLogger(CookH5Controller.class); +// +// @Resource +// private ICookH5Service cookH5Service; +// +// @GetMapping({"/list/week/canteen"}) +// @ApiOperation("获取一周菜谱食堂列表") +// public AjaxResult getWeekMealList( UserInfoDTO dto) { +// startPage(); +// try { +// return AjaxResult.success(this.cookH5Service.getWeekCanteenList(dto)); +// } catch (Exception e) { +// log.error(e.toString(), e); +// return AjaxResult.error("获取一周菜谱食堂列表失败"); +// } +// } +// +// @ApiOperation("获取一周菜谱详情") +// @GetMapping({"/week/recipe/detail"}) +// public TableDataInfo getWeekRecipeDetail(@Valid CookH5WeekDetailsDTO dto) { +// try { +// startPage(); +// dto.setApplyDate(LocalDate.parse(dto.getDate())); +// return getDataTable(this.cookH5Service.getWeekRecipeDetail(dto)); +// } catch (Exception e) { +// log.error(e.toString(), e); +// return getDataTable(new ArrayList<>()); +// } +// +// } +// +// @ApiOperation("获取预定餐食堂列表") +// @GetMapping({"/list/reserve/canteen"}) +// public TableDataInfo getReserveMealCanteenList(@Valid UserInfoDTO dto) { +// try { +// startPage(); +// return getDataTable(this.cookH5Service.getReserveCanteenList(dto)); +// } catch (Exception e) { +// log.error(e.toString(), e); +// return getDataTable(new ArrayList<>()); +// } +// } +// +// +// @ApiOperation("获取预定餐菜谱详情") +// @PostMapping({"/reserve/recipe/detail"}) +// public TableDataInfo getReserveRecipeDetailList(@RequestBody CookH5ReserveRecipeDTO content) { +// try { +// return getDataTable(this.cookH5Service.getReserveRecipeDetailList(content)); +// } catch (Exception e) { +// log.error(e.toString(), e); +// return getDataTable(new ArrayList<>()); +// } +// } +// +// @PostMapping({"/scheduledTasks"}) +// @ApiOperation("定时任务") +// @Transactional +// public AjaxResult scheduledTasks() { +// this.cookH5Service.scheduledTask(); +// return AjaxResult.success(); +// } +// +// @PostMapping({"/detail"}) +// @ApiOperation("根据菜品id获取菜品详情") +// public AjaxResult getRecipeDetail(@RequestBody AppletDishesDetailDTO dto) { +// try { +// AppletDishesDetailVO dishesDetailVO = this.cookH5Service.getDishesDetailByDishesId(dto); +// return success(dishesDetailVO); +// }catch (Exception e) { +// return AjaxResult.error(e.getMessage()); +// } +// } +// +//} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/mapper/CookH5Mapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/mapper/CookH5Mapper.java index 8c1da69..53729ee 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/mapper/CookH5Mapper.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/mapper/CookH5Mapper.java @@ -1,47 +1,47 @@ -package com.bonus.canteen.core.cook.mapper; - -import com.bonus.canteen.core.cook.dto.AppletDishesDetailDTO; -import com.bonus.canteen.core.cook.dto.CookH5WeekDetailsDTO; -import com.bonus.canteen.core.cook.dto.UserInfoDTO; -import com.bonus.canteen.core.cook.vo.*; -import org.apache.ibatis.annotations.MapKey; -import org.apache.ibatis.annotations.Param; - -import java.time.LocalDate; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * @author xliu - * @date 2025/5/28 9:25 - */ -public interface CookH5Mapper { - - List getWeekCanteenList(UserInfoDTO userInfoDTO); - - List getWeekRecipeDetail(CookH5WeekDetailsDTO dto); - - - List selectReserveMealCanteenList(UserInfoDTO dto); - - List selectMonthSalesStall(@Param("stallIdList")List stallIdList); - - List selectTopDishesIdList(@Param("stallIdList")List longs); - - List selectAllRecipeDishesList(Long recipeId); - - List selectReserveRecipe(@Param("applyDate")LocalDate applyDate, @Param("recipeId")Long recipeId); - - List getCookMealtimeListByStallId(@Param("stallIdSet") Set recipeIdSet); - - List selectNutrition(@Param("dishesIdSet") Set dishesIdSet); - - List selectRecipeIdList(); - - List recipeIdMap(@Param("recipeIdList")List recipeIdList, @Param("applyDate")LocalDate applyDate); - - AppletDishesDetailVO selectDishesDetailByDishesId(AppletDishesDetailDTO dto); - - List getMenuMaterialById(Long dishesId); -} +//package com.bonus.canteen.core.cook.mapper; +// +//import com.bonus.canteen.core.cook.dto.AppletDishesDetailDTO; +//import com.bonus.canteen.core.cook.dto.CookH5WeekDetailsDTO; +//import com.bonus.canteen.core.cook.dto.UserInfoDTO; +//import com.bonus.canteen.core.cook.vo.*; +//import org.apache.ibatis.annotations.MapKey; +//import org.apache.ibatis.annotations.Param; +// +//import java.time.LocalDate; +//import java.util.List; +//import java.util.Map; +//import java.util.Set; +// +///** +// * @author xliu +// * @date 2025/5/28 9:25 +// */ +//public interface CookH5Mapper { +// +// List getWeekCanteenList(UserInfoDTO userInfoDTO); +// +// List getWeekRecipeDetail(CookH5WeekDetailsDTO dto); +// +// +// List selectReserveMealCanteenList(UserInfoDTO dto); +// +// List selectMonthSalesStall(@Param("stallIdList")List stallIdList); +// +// List selectTopDishesIdList(@Param("stallIdList")List longs); +// +// List selectAllRecipeDishesList(Long recipeId); +// +// List selectReserveRecipe(@Param("applyDate")LocalDate applyDate, @Param("recipeId")Long recipeId); +// +// List getCookMealtimeListByStallId(@Param("stallIdSet") Set recipeIdSet); +// +// List selectNutrition(@Param("dishesIdSet") Set dishesIdSet); +// +// List selectRecipeIdList(); +// +// List recipeIdMap(@Param("recipeIdList")List recipeIdList, @Param("applyDate")LocalDate applyDate); +// +// AppletDishesDetailVO selectDishesDetailByDishesId(AppletDishesDetailDTO dto); +// +// List getMenuMaterialById(Long dishesId); +//} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/ICookH5Service.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/ICookH5Service.java index b6f1101..b49e698 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/ICookH5Service.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/ICookH5Service.java @@ -1,27 +1,27 @@ -package com.bonus.canteen.core.cook.service; - -import com.bonus.canteen.core.cook.dto.AppletDishesDetailDTO; -import com.bonus.canteen.core.cook.dto.CookH5ReserveRecipeDTO; -import com.bonus.canteen.core.cook.dto.CookH5WeekDetailsDTO; -import com.bonus.canteen.core.cook.dto.UserInfoDTO; -import com.bonus.canteen.core.cook.vo.*; - -import java.util.List; - -/** - * @author xliu - * @date 2025/5/28 9:21 - */ -public interface ICookH5Service { - List getWeekCanteenList(UserInfoDTO userInfoDTO); - - List getWeekRecipeDetail(CookH5WeekDetailsDTO dto); - - List getReserveCanteenList(UserInfoDTO dto); - - List getReserveRecipeDetailList(CookH5ReserveRecipeDTO content); - - void scheduledTask(); - - AppletDishesDetailVO getDishesDetailByDishesId(AppletDishesDetailDTO dto); -} +//package com.bonus.canteen.core.cook.service; +// +//import com.bonus.canteen.core.cook.dto.AppletDishesDetailDTO; +//import com.bonus.canteen.core.cook.dto.CookH5ReserveRecipeDTO; +//import com.bonus.canteen.core.cook.dto.CookH5WeekDetailsDTO; +//import com.bonus.canteen.core.cook.dto.UserInfoDTO; +//import com.bonus.canteen.core.cook.vo.*; +// +//import java.util.List; +// +///** +// * @author xliu +// * @date 2025/5/28 9:21 +// */ +//public interface ICookH5Service { +// List getWeekCanteenList(UserInfoDTO userInfoDTO); +// +// List getWeekRecipeDetail(CookH5WeekDetailsDTO dto); +// +// List getReserveCanteenList(UserInfoDTO dto); +// +// List getReserveRecipeDetailList(CookH5ReserveRecipeDTO content); +// +// void scheduledTask(); +// +// AppletDishesDetailVO getDishesDetailByDishesId(AppletDishesDetailDTO dto); +//} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookH5ServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookH5ServiceImpl.java index 9e23dd3..3c211b2 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookH5ServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookH5ServiceImpl.java @@ -1,279 +1,279 @@ -package com.bonus.canteen.core.cook.service.impl; - -import cn.hutool.core.util.ObjectUtil; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.bonus.canteen.core.common.enums.YesOrNoEnum; -import com.bonus.canteen.core.cook.domain.CookRecipe; -import com.bonus.canteen.core.cook.domain.CookRecipeDetail; -import com.bonus.canteen.core.cook.domain.CookRecipeDishes; -import com.bonus.canteen.core.cook.dto.AppletDishesDetailDTO; -import com.bonus.canteen.core.cook.dto.CookH5ReserveRecipeDTO; -import com.bonus.canteen.core.cook.dto.CookH5WeekDetailsDTO; -import com.bonus.canteen.core.cook.dto.UserInfoDTO; -import com.bonus.canteen.core.cook.mapper.CookH5Mapper; -import com.bonus.canteen.core.cook.mapper.CookRecipeDetailMapper; -import com.bonus.canteen.core.cook.mapper.CookRecipeDishesMapper; -import com.bonus.canteen.core.cook.mapper.CookRecipeMapper; -import com.bonus.canteen.core.cook.service.ICookH5Service; -import com.bonus.canteen.core.cook.service.ICookRecipeService; -import com.bonus.canteen.core.cook.vo.*; -import com.bonus.common.houqin.constant.DelFlagEnum; -import com.bonus.common.security.utils.SecurityUtils; -import com.google.common.collect.Lists; -import org.hibernate.validator.internal.util.StringHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.time.LocalDate; -import java.time.LocalTime; -import java.util.*; -import java.util.function.Function; -import java.util.stream.Collectors; - -/** - * @author xliu - * @date 2025/5/28 9:22 - */ -@Service -public class CookH5ServiceImpl implements ICookH5Service { - - private static final Logger log = LoggerFactory.getLogger(CookH5ServiceImpl.class); - - @Resource - private CookH5Mapper cookH5Mapper; - @Resource - private CookRecipeDetailMapper cookRecipeDetailMapper; - @Resource - private CookRecipeDishesMapper cookRecipeDishesMapper; - - @Resource - private CookRecipeMapper cookRecipeMapper; - - @Override - public List getWeekCanteenList(UserInfoDTO userInfoDTO) { - return cookH5Mapper.getWeekCanteenList(userInfoDTO); - } - - @Override - public List getWeekRecipeDetail(CookH5WeekDetailsDTO dto) { - List resutlList = cookH5Mapper.getWeekRecipeDetail(dto); - resutlList.sort(Comparator.comparingInt(CookH5WeekDetailsVO::getMealtimeType)); - return resutlList; - } - - @Override - public List getReserveCanteenList(UserInfoDTO dto) { - List resultList = this.cookH5Mapper.selectReserveMealCanteenList(dto); - if (ObjectUtil.isEmpty(resultList)) { - return resultList; - }else{ - //获取集合中档口id - List stallIdList = resultList.stream().flatMap((canteen) -> { - return canteen.getStallList().stream().map(CookH5ReserveStallVO::getStallId); - }).collect(Collectors.toList()); - if (ObjectUtil.isNotEmpty(stallIdList)) { - //获取每个档口月销量 - List stallMonthSalesList = this.cookH5Mapper.selectMonthSalesStall(stallIdList); - //将档口月销量转换为Map - Map stallSaleMap = stallMonthSalesList.stream().collect(Collectors.toMap(StallMonthSalesVO::getStallId, StallMonthSalesVO::getMonthlySales)); - // 遍历食堂列表,将每个档口的月销量设置到对应的档口中 - resultList.forEach((canteen) -> { - List stallList = canteen.getStallList(); - if (ObjectUtil.isNotEmpty(stallList)) { - stallList.forEach((stall) -> { - stall.setMonthlySales((stallSaleMap.get(stall.getStallId()) == null) ? 0 : stallSaleMap.get(stall.getStallId())); - }); - } - - }); - //获取每个档口推荐菜品 - resultList.forEach((c) -> { - List stallList = c.getStallList(); - if (ObjectUtil.isNotEmpty(stallList)) { - stallList.forEach((s) -> { - List topDishesIdList = this.cookH5Mapper.selectTopDishesIdList(Collections.singletonList(s.getStallId())); - List recommendList = Lists.newArrayList(); - List allRecipeDishesList = cookH5Mapper.selectAllRecipeDishesList(s.getRecipeId()); - if (ObjectUtil.isNotEmpty(allRecipeDishesList) && ObjectUtil.isNotEmpty(topDishesIdList)) { - Iterator var5 = topDishesIdList.iterator(); - - while(var5.hasNext()) { - Long dishesId = (Long)var5.next(); - if (allRecipeDishesList.stream().map(CookH5ReserveDishesVO::getDishesId).collect(Collectors.toList()).contains(dishesId)) { - CookH5ReserveDishesVO recommendDishes = (CookH5ReserveDishesVO)allRecipeDishesList.stream().filter((a) -> { - return a.getDishesId().equals(dishesId); - }).collect(Collectors.toList()).get(0); - if (!recommendList.contains(recommendDishes)) { - recommendList.add(recommendDishes); - } - - if (recommendList.size() >= 3) { - s.setRecommendList(recommendList); - return; - } - } - } - } - s.setRecommendList(recommendList); - }); - } - }); - } - - } - return resultList; - } - - - @Override - public List getReserveRecipeDetailList(CookH5ReserveRecipeDTO content) { - List resultList = cookH5Mapper.selectReserveRecipe(content.getApplyDate(), content.getRecipeId()); - if (ObjectUtil.isEmpty(resultList)) { - return resultList; - } else { - Set stallSet = new HashSet<>(); - resultList.forEach((typeList)-> { - if (ObjectUtil.isNotEmpty(typeList.getTypeList())) { - typeList.getTypeList().forEach((type) -> { - if(ObjectUtil.isNotEmpty(type)){ - type.getDishesList().forEach((dishes) -> { - stallSet.add(dishes.getStallId()); - }); - } - }); - } - }); - resultList.sort(Comparator.comparingInt(CookH5ReserveRecipeDetailsVO::getMealtimeType)); - //设置默认配送方式 - List deliveryCostList = new ArrayList<>(); - CookH5AllocDeliveryCostVO deliveryCost = new CookH5AllocDeliveryCostVO(); - deliveryCost.setDeliveryType(1); - deliveryCost.setDeliveryName("自取"); - deliveryCost.setDeliveryAmount(BigDecimal.valueOf(0)); - deliveryCost.setPackingFee(BigDecimal.valueOf(0)); - deliveryCostList.add(deliveryCost); - - List mealTimeList = cookH5Mapper.getCookMealtimeListByStallId(stallSet); - if (ObjectUtil.isEmpty(mealTimeList)) { - log.info("未获取到开启餐次"); - return Lists.newArrayList(); - } else { - if (LocalDate.now().isEqual(content.getApplyDate())) { - mealTimeList = mealTimeList.stream().filter((time) -> { - return LocalTime.now().isBefore(time.getStartTime()); - }).collect(Collectors.toList()); - } - if (ObjectUtil.isEmpty(mealTimeList)) { - log.info("未获取到餐次信息"); - return Lists.newArrayList(); - }else{ - List finalMealTimeList = mealTimeList; - resultList = resultList.stream().filter((time) -> { - return finalMealTimeList.stream().map(CookH5ReserveMealtimeStateVO::getMealtimeType).collect(Collectors.toList()).contains(time.getMealtimeType()); - }).collect(Collectors.toList()); - resultList.forEach((time) -> { - List typeList = time.getTypeList(); - if (ObjectUtil.isNotEmpty(typeList)) { - typeList.forEach((type) -> { - List dishesList = type.getDishesList(); - if (ObjectUtil.isNotEmpty(dishesList)) { - dishesList.forEach((dishes) -> { - //添加配送方式 默认全是自取 - dishes.setCostModelList(deliveryCostList); - }); - } - - }); - } - }); - // 计算菜品分值 暂未开发 - - } - } - - } - return resultList; - } - - - @Override - public void scheduledTask() { - List recipeIdList = cookH5Mapper.selectRecipeIdList(); - //查询所有每周菜谱、指定日期菜谱id - for(int i = 0; i < 7; ++i) { - this.scheduledTaskRun(recipeIdList, LocalDate.now().plusDays(i)); - } - } - - public void scheduledTaskRun(List recipeIdList, LocalDate applyDate) { - if (ObjectUtil.isEmpty(recipeIdList) && recipeIdList.size()==0) { - log.info("未获取到菜谱id"); - }else{ - List recipeIdMap = cookH5Mapper.recipeIdMap(recipeIdList,applyDate); - //去除当日已有菜品的菜谱id - recipeIdList = new ArrayList<>(recipeIdList); - recipeIdList.removeAll(recipeIdMap); - if(recipeIdList.isEmpty()){ - log.info("当日无需要生成菜品"); - return; - } - List cookRecipeList = cookRecipeMapper.getCookRecipeByRecipeIds(recipeIdList); - if(!cookRecipeList.isEmpty()){ - // Map recipeMap = cookRecipeList.stream().collect(Collectors.toMap(CookRecipe::getRecipeId, Function.identity())); - //获取菜谱id对应detailsId信息 - recipeIdList.forEach( recipeId -> { - //获取具体的餐次信息 - List cookRecipeDetailList = cookRecipeDetailMapper.getCookRecipeDetailLTemplate(recipeId, "1"); - if(!cookRecipeDetailList.isEmpty()){ - cookRecipeDetailList.forEach(detail -> { - //设置菜谱id - //detail.setRecipeId(recipeId); - detail.setApplyDate(applyDate); - detail.setDetailType(2L); - detail.setApplyWeek(Long.valueOf(applyDate.getDayOfWeek().getValue())); - List cookRecipeDishesList = cookRecipeDishesMapper.getCookRecipeDishesByDetailId(detail.getRecipeDetailId()); - cookRecipeDetailMapper.insertCookRecipeDetail(detail); - if(!cookRecipeDishesList.isEmpty()){ - cookRecipeDishesList.forEach(dishes -> { - //设置菜品id - dishes.setRecipeDetailId(detail.getRecipeDetailId()); - cookRecipeDishesMapper.insertCookRecipeDishes(dishes); - }); - } - }); - } - //获取details对应的菜品信息 - }); - - }else{ - log.info("未获取到菜谱信息"); - } - } - } - - - @Override - public AppletDishesDetailVO getDishesDetailByDishesId(AppletDishesDetailDTO dto) { - dto.setDelFlag(DelFlagEnum.DEL_FALSE.key()); - AppletDishesDetailVO appletDishesDetailVO = cookH5Mapper.selectDishesDetailByDishesId(dto); - Long dishesId = ((AppletDishesSizeV2VO) appletDishesDetailVO.getDishesDetailList().get(0)).getDishesId(); - List materialList; - if (appletDishesDetailVO.getMealType() == 1) { - materialList = this.cookH5Mapper.getMenuMaterialById(dishesId); - appletDishesDetailVO.setMaterialList(materialList); - } - -// int countDishes = this.cookH5Mapper.getCollectionCountByUserIdAndDishesId(SecurityUtils.getUserId(), dishesId); -// if (countDishes > 0) { -// appletDishesDetailVO.setIsFavorites(YesOrNoEnum.YES.key()); -// } else { -// appletDishesDetailVO.setIsFavorites(YesOrNoEnum.NO.key()); +//package com.bonus.canteen.core.cook.service.impl; +// +//import cn.hutool.core.util.ObjectUtil; +//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +//import com.bonus.canteen.core.common.enums.YesOrNoEnum; +//import com.bonus.canteen.core.cook.domain.CookRecipe; +//import com.bonus.canteen.core.cook.domain.CookRecipeDetail; +//import com.bonus.canteen.core.cook.domain.CookRecipeDishes; +//import com.bonus.canteen.core.cook.dto.AppletDishesDetailDTO; +//import com.bonus.canteen.core.cook.dto.CookH5ReserveRecipeDTO; +//import com.bonus.canteen.core.cook.dto.CookH5WeekDetailsDTO; +//import com.bonus.canteen.core.cook.dto.UserInfoDTO; +//import com.bonus.canteen.core.cook.mapper.CookH5Mapper; +//import com.bonus.canteen.core.cook.mapper.CookRecipeDetailMapper; +//import com.bonus.canteen.core.cook.mapper.CookRecipeDishesMapper; +//import com.bonus.canteen.core.cook.mapper.CookRecipeMapper; +//import com.bonus.canteen.core.cook.service.ICookH5Service; +//import com.bonus.canteen.core.cook.service.ICookRecipeService; +//import com.bonus.canteen.core.cook.vo.*; +//import com.bonus.common.houqin.constant.DelFlagEnum; +//import com.bonus.common.security.utils.SecurityUtils; +//import com.google.common.collect.Lists; +//import org.hibernate.validator.internal.util.StringHelper; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.stereotype.Service; +// +//import javax.annotation.Resource; +//import java.math.BigDecimal; +//import java.time.LocalDate; +//import java.time.LocalTime; +//import java.util.*; +//import java.util.function.Function; +//import java.util.stream.Collectors; +// +///** +// * @author xliu +// * @date 2025/5/28 9:22 +// */ +//@Service +//public class CookH5ServiceImpl implements ICookH5Service { +// +// private static final Logger log = LoggerFactory.getLogger(CookH5ServiceImpl.class); +// +// @Resource +// private CookH5Mapper cookH5Mapper; +// @Resource +// private CookRecipeDetailMapper cookRecipeDetailMapper; +// @Resource +// private CookRecipeDishesMapper cookRecipeDishesMapper; +// +// @Resource +// private CookRecipeMapper cookRecipeMapper; +// +// @Override +// public List getWeekCanteenList(UserInfoDTO userInfoDTO) { +// return cookH5Mapper.getWeekCanteenList(userInfoDTO); +// } +// +// @Override +// public List getWeekRecipeDetail(CookH5WeekDetailsDTO dto) { +// List resutlList = cookH5Mapper.getWeekRecipeDetail(dto); +// resutlList.sort(Comparator.comparingInt(CookH5WeekDetailsVO::getMealtimeType)); +// return resutlList; +// } +// +// @Override +// public List getReserveCanteenList(UserInfoDTO dto) { +// List resultList = this.cookH5Mapper.selectReserveMealCanteenList(dto); +// if (ObjectUtil.isEmpty(resultList)) { +// return resultList; +// }else{ +// //获取集合中档口id +// List stallIdList = resultList.stream().flatMap((canteen) -> { +// return canteen.getStallList().stream().map(CookH5ReserveStallVO::getStallId); +// }).collect(Collectors.toList()); +// if (ObjectUtil.isNotEmpty(stallIdList)) { +// //获取每个档口月销量 +// List stallMonthSalesList = this.cookH5Mapper.selectMonthSalesStall(stallIdList); +// //将档口月销量转换为Map +// Map stallSaleMap = stallMonthSalesList.stream().collect(Collectors.toMap(StallMonthSalesVO::getStallId, StallMonthSalesVO::getMonthlySales)); +// // 遍历食堂列表,将每个档口的月销量设置到对应的档口中 +// resultList.forEach((canteen) -> { +// List stallList = canteen.getStallList(); +// if (ObjectUtil.isNotEmpty(stallList)) { +// stallList.forEach((stall) -> { +// stall.setMonthlySales((stallSaleMap.get(stall.getStallId()) == null) ? 0 : stallSaleMap.get(stall.getStallId())); +// }); +// } +// +// }); +// //获取每个档口推荐菜品 +// resultList.forEach((c) -> { +// List stallList = c.getStallList(); +// if (ObjectUtil.isNotEmpty(stallList)) { +// stallList.forEach((s) -> { +// List topDishesIdList = this.cookH5Mapper.selectTopDishesIdList(Collections.singletonList(s.getStallId())); +// List recommendList = Lists.newArrayList(); +// List allRecipeDishesList = cookH5Mapper.selectAllRecipeDishesList(s.getRecipeId()); +// if (ObjectUtil.isNotEmpty(allRecipeDishesList) && ObjectUtil.isNotEmpty(topDishesIdList)) { +// Iterator var5 = topDishesIdList.iterator(); +// +// while(var5.hasNext()) { +// Long dishesId = (Long)var5.next(); +// if (allRecipeDishesList.stream().map(CookH5ReserveDishesVO::getDishesId).collect(Collectors.toList()).contains(dishesId)) { +// CookH5ReserveDishesVO recommendDishes = (CookH5ReserveDishesVO)allRecipeDishesList.stream().filter((a) -> { +// return a.getDishesId().equals(dishesId); +// }).collect(Collectors.toList()).get(0); +// if (!recommendList.contains(recommendDishes)) { +// recommendList.add(recommendDishes); +// } +// +// if (recommendList.size() >= 3) { +// s.setRecommendList(recommendList); +// return; +// } +// } +// } +// } +// s.setRecommendList(recommendList); +// }); +// } +// }); +// } +// // } - - return appletDishesDetailVO; - } -} +// return resultList; +// } +// +// +// @Override +// public List getReserveRecipeDetailList(CookH5ReserveRecipeDTO content) { +// List resultList = cookH5Mapper.selectReserveRecipe(content.getApplyDate(), content.getRecipeId()); +// if (ObjectUtil.isEmpty(resultList)) { +// return resultList; +// } else { +// Set stallSet = new HashSet<>(); +// resultList.forEach((typeList)-> { +// if (ObjectUtil.isNotEmpty(typeList.getTypeList())) { +// typeList.getTypeList().forEach((type) -> { +// if(ObjectUtil.isNotEmpty(type)){ +// type.getDishesList().forEach((dishes) -> { +// stallSet.add(dishes.getStallId()); +// }); +// } +// }); +// } +// }); +// resultList.sort(Comparator.comparingInt(CookH5ReserveRecipeDetailsVO::getMealtimeType)); +// //设置默认配送方式 +// List deliveryCostList = new ArrayList<>(); +// CookH5AllocDeliveryCostVO deliveryCost = new CookH5AllocDeliveryCostVO(); +// deliveryCost.setDeliveryType(1); +// deliveryCost.setDeliveryName("自取"); +// deliveryCost.setDeliveryAmount(BigDecimal.valueOf(0)); +// deliveryCost.setPackingFee(BigDecimal.valueOf(0)); +// deliveryCostList.add(deliveryCost); +// +// List mealTimeList = cookH5Mapper.getCookMealtimeListByStallId(stallSet); +// if (ObjectUtil.isEmpty(mealTimeList)) { +// log.info("未获取到开启餐次"); +// return Lists.newArrayList(); +// } else { +// if (LocalDate.now().isEqual(content.getApplyDate())) { +// mealTimeList = mealTimeList.stream().filter((time) -> { +// return LocalTime.now().isBefore(time.getStartTime()); +// }).collect(Collectors.toList()); +// } +// if (ObjectUtil.isEmpty(mealTimeList)) { +// log.info("未获取到餐次信息"); +// return Lists.newArrayList(); +// }else{ +// List finalMealTimeList = mealTimeList; +// resultList = resultList.stream().filter((time) -> { +// return finalMealTimeList.stream().map(CookH5ReserveMealtimeStateVO::getMealtimeType).collect(Collectors.toList()).contains(time.getMealtimeType()); +// }).collect(Collectors.toList()); +// resultList.forEach((time) -> { +// List typeList = time.getTypeList(); +// if (ObjectUtil.isNotEmpty(typeList)) { +// typeList.forEach((type) -> { +// List dishesList = type.getDishesList(); +// if (ObjectUtil.isNotEmpty(dishesList)) { +// dishesList.forEach((dishes) -> { +// //添加配送方式 默认全是自取 +// dishes.setCostModelList(deliveryCostList); +// }); +// } +// +// }); +// } +// }); +// // 计算菜品分值 暂未开发 +// +// } +// } +// +// } +// return resultList; +// } +// +// +// @Override +// public void scheduledTask() { +// List recipeIdList = cookH5Mapper.selectRecipeIdList(); +// //查询所有每周菜谱、指定日期菜谱id +// for(int i = 0; i < 7; ++i) { +// this.scheduledTaskRun(recipeIdList, LocalDate.now().plusDays(i)); +// } +// } +// +// public void scheduledTaskRun(List recipeIdList, LocalDate applyDate) { +// if (ObjectUtil.isEmpty(recipeIdList) && recipeIdList.size()==0) { +// log.info("未获取到菜谱id"); +// }else{ +// List recipeIdMap = cookH5Mapper.recipeIdMap(recipeIdList,applyDate); +// //去除当日已有菜品的菜谱id +// recipeIdList = new ArrayList<>(recipeIdList); +// recipeIdList.removeAll(recipeIdMap); +// if(recipeIdList.isEmpty()){ +// log.info("当日无需要生成菜品"); +// return; +// } +// List cookRecipeList = cookRecipeMapper.getCookRecipeByRecipeIds(recipeIdList); +// if(!cookRecipeList.isEmpty()){ +// // Map recipeMap = cookRecipeList.stream().collect(Collectors.toMap(CookRecipe::getRecipeId, Function.identity())); +// //获取菜谱id对应detailsId信息 +// recipeIdList.forEach( recipeId -> { +// //获取具体的餐次信息 +// List cookRecipeDetailList = cookRecipeDetailMapper.getCookRecipeDetailLTemplate(recipeId, "1"); +// if(!cookRecipeDetailList.isEmpty()){ +// cookRecipeDetailList.forEach(detail -> { +// //设置菜谱id +// //detail.setRecipeId(recipeId); +// detail.setApplyDate(applyDate); +// detail.setDetailType(2L); +// detail.setApplyWeek(Long.valueOf(applyDate.getDayOfWeek().getValue())); +// List cookRecipeDishesList = cookRecipeDishesMapper.getCookRecipeDishesByDetailId(detail.getRecipeDetailId()); +// cookRecipeDetailMapper.insertCookRecipeDetail(detail); +// if(!cookRecipeDishesList.isEmpty()){ +// cookRecipeDishesList.forEach(dishes -> { +// //设置菜品id +// dishes.setRecipeDetailId(detail.getRecipeDetailId()); +// cookRecipeDishesMapper.insertCookRecipeDishes(dishes); +// }); +// } +// }); +// } +// //获取details对应的菜品信息 +// }); +// +// }else{ +// log.info("未获取到菜谱信息"); +// } +// } +// } +// +// +// @Override +// public AppletDishesDetailVO getDishesDetailByDishesId(AppletDishesDetailDTO dto) { +// dto.setDelFlag(DelFlagEnum.DEL_FALSE.key()); +// AppletDishesDetailVO appletDishesDetailVO = cookH5Mapper.selectDishesDetailByDishesId(dto); +// Long dishesId = ((AppletDishesSizeV2VO) appletDishesDetailVO.getDishesDetailList().get(0)).getDishesId(); +// List materialList; +// if (appletDishesDetailVO.getMealType() == 1) { +// materialList = this.cookH5Mapper.getMenuMaterialById(dishesId); +// appletDishesDetailVO.setMaterialList(materialList); +// } +// +//// int countDishes = this.cookH5Mapper.getCollectionCountByUserIdAndDishesId(SecurityUtils.getUserId(), dishesId); +//// if (countDishes > 0) { +//// appletDishesDetailVO.setIsFavorites(YesOrNoEnum.YES.key()); +//// } else { +//// appletDishesDetailVO.setIsFavorites(YesOrNoEnum.NO.key()); +//// } +// +// return appletDishesDetailVO; +// } +//} diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookH5Mapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookH5Mapper.xml index 180679f..0d738c4 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookH5Mapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookH5Mapper.xml @@ -1,413 +1,413 @@ - - + + + + - + - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + - + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + - + - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + - + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + +