From d62a462c9a52eb0c2929bb79f01cde965438ffc8 Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Thu, 29 May 2025 13:23:00 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=BD=93=E5=89=8D=E8=8F=9C=E8=B0=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cook/controller/CookRecipeController.java | 10 +++ .../canteen/core/cook/dto/CookRecipeDTO.java | 10 +++ .../core/cook/mapper/CookRecipeMapper.java | 6 ++ .../core/cook/service/ICookRecipeService.java | 3 + .../service/impl/CookRecipeServiceImpl.java | 60 +++++++++++++- .../core/cook/vo/CookRecipeDateVO.java | 50 ++++++++++++ .../canteen/core/cook/vo/CookRecipeVO.java | 81 +++++++++++++++++++ .../core/cook/vo/StallAndRecipeBindVO.java | 31 +++++++ .../mapper/cook/CookRecipeMapper.xml | 59 ++++++++++++++ 9 files changed, 309 insertions(+), 1 deletion(-) create mode 100644 bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/vo/CookRecipeDateVO.java create mode 100644 bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/vo/CookRecipeVO.java create mode 100644 bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/vo/StallAndRecipeBindVO.java diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/controller/CookRecipeController.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/controller/CookRecipeController.java index 2932299..7088ba0 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/controller/CookRecipeController.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/controller/CookRecipeController.java @@ -8,6 +8,7 @@ import com.bonus.canteen.core.cook.dto.CookRecipeBindDTO; import com.bonus.canteen.core.cook.dto.CookRecipeDTO; import com.bonus.canteen.core.cook.dto.CookRecipeDetailDTO; import com.bonus.canteen.core.cook.vo.CookRecipeDetailVO; +import com.bonus.canteen.core.cook.vo.CookRecipeVO; import com.bonus.common.log.enums.OperaType; //import com.bonus.canteen.core.cook.common.annotation.PreventRepeatSubmit; import io.swagger.annotations.Api; @@ -43,6 +44,15 @@ public class CookRecipeController extends BaseController { @Autowired private ICookRecipeService cookRecipeService; + @ApiOperation(value = "当前菜谱") + //@RequiresPermissions("menu:recipe:list") + @GetMapping("/currentList") + public TableDataInfo currentList(CookRecipeDTO content) { + startPage(); + List list = cookRecipeService.selectCookRecipeListV2(content); + return getDataTable(list); + } + /** * 查询菜品计划信息列表 */ diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/dto/CookRecipeDTO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/dto/CookRecipeDTO.java index 5fc653e..0399753 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/dto/CookRecipeDTO.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/dto/CookRecipeDTO.java @@ -67,5 +67,15 @@ public class CookRecipeDTO extends BaseEntity { */ private String delFlag; + private Long areaId; + + private Integer key; + + @ApiModelProperty("菜谱绑定类型") + private Integer bindType; + + @ApiModelProperty("设备类型") + private List deviceTypeList; + private List recipeDateList; } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/mapper/CookRecipeMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/mapper/CookRecipeMapper.java index 47cf687..521a650 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/mapper/CookRecipeMapper.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/mapper/CookRecipeMapper.java @@ -6,6 +6,8 @@ import com.bonus.canteen.core.cook.domain.CookRecipe; import com.bonus.canteen.core.cook.dto.CookRecipeDTO; import com.bonus.canteen.core.cook.dto.CookRecipeDetailDTO; import com.bonus.canteen.core.cook.vo.CookRecipeDetailVO; +import com.bonus.canteen.core.cook.vo.CookRecipeVO; +import com.bonus.canteen.core.cook.vo.StallAndRecipeBindVO; import org.apache.ibatis.annotations.Param; /** @@ -72,4 +74,8 @@ public interface CookRecipeMapper { * @return 结果 */ public int deleteCookRecipeByRecipeIds(Long[] recipeIds); + + public List selectCookRecipeListV2(CookRecipeDTO content); + + List selectRecipeByStallIdsAndBindType(@Param("stallIds") List stallIds, @Param("bindType") Integer bindType); } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/ICookRecipeService.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/ICookRecipeService.java index 3a1ee9e..9250889 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/ICookRecipeService.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/ICookRecipeService.java @@ -6,6 +6,7 @@ import com.bonus.canteen.core.cook.dto.CookRecipeBindDTO; import com.bonus.canteen.core.cook.dto.CookRecipeDTO; import com.bonus.canteen.core.cook.dto.CookRecipeDetailDTO; import com.bonus.canteen.core.cook.vo.CookRecipeDetailVO; +import com.bonus.canteen.core.cook.vo.CookRecipeVO; /** * 菜品计划信息Service接口 @@ -22,6 +23,8 @@ public interface ICookRecipeService { */ public CookRecipe selectCookRecipeByRecipeId(Long recipeId); + public List selectCookRecipeListV2(CookRecipeDTO dto); + /** * 查询菜品计划信息列表 * diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookRecipeServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookRecipeServiceImpl.java index 60eac2e..8b721ae 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookRecipeServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookRecipeServiceImpl.java @@ -3,9 +3,11 @@ package com.bonus.canteen.core.cook.service.impl; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.bonus.canteen.core.common.utils.MqUtil; import com.bonus.canteen.core.cook.domain.CookAppRecipe; import com.bonus.canteen.core.cook.domain.CookRecipeDetail; @@ -17,12 +19,13 @@ import com.bonus.canteen.core.cook.enums.RecipeDetailTypeEnum; import com.bonus.canteen.core.cook.enums.RecipeTypeEnum; import com.bonus.canteen.core.cook.mapper.CookRecipeDetailMapper; import com.bonus.canteen.core.cook.mapper.CookRecipeDishesMapper; -import com.bonus.canteen.core.cook.vo.CookRecipeDetailVO; +import com.bonus.canteen.core.cook.vo.*; import com.bonus.canteen.core.user.domain.DeviceMqPersonalUpdateMessageDTO; import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.utils.DateUtils; import com.bonus.common.houqin.constant.GlobalConstants; import com.bonus.common.houqin.mq.constant.LeMqConstant; +import com.bonus.common.houqin.utils.LeBeanUtil; import com.bonus.common.security.utils.SecurityUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -65,6 +68,61 @@ public class CookRecipeServiceImpl implements ICookRecipeService { return cookRecipeMapper.selectCookRecipeByRecipeId(recipeId); } + public List selectCookRecipeListV2(CookRecipeDTO content) { + Map bindTypeMap = CookRecipeSortEnum.getKeyMap(); + CookRecipeSortEnum sortEnum = bindTypeMap.get(content.getKey()); + List records = new ArrayList<>(); + if (ObjectUtil.isEmpty(sortEnum)) { + throw new ServiceException("参数错误"); + }else{ + content.setDeviceTypeList(sortEnum.getDeviceType()); + content.setBindType(sortEnum.getBindType()); + content.setRecipeName(LeBeanUtil.fieldLikeHandle(content.getRecipeName())); + records = cookRecipeMapper.selectCookRecipeListV2(content); + if (ObjectUtil.isNotEmpty(records)) { + List recipeIds; + Map maping; + List menuRecipeDateVOS; + menuRecipeDateVOS = records.stream().map(CookRecipeVO::getStallId).collect(Collectors.toList()); + List stallAndRecipeBindDtos = this.cookRecipeMapper.selectRecipeByStallIdsAndBindType(menuRecipeDateVOS, content.getBindType()); + maping = stallAndRecipeBindDtos.stream().collect(Collectors.toMap(StallAndRecipeBindVO::getStallId, StallAndRecipeBindVO::getRecipeId)); + recipeIds = stallAndRecipeBindDtos.stream().map(StallAndRecipeBindVO::getRecipeId).distinct().collect(Collectors.toList()); + +// this.generateRecipe(recipeIds, content.getApplyDate()); +// List menuRecipeDateVOS1 = this.cookRecipeMapper.selectTmpBetweenDateDetailList(recipeIds, content.getApplyDate(), content.getApplyDate()); +// Map recipeMap = (recipeIds == null || recipeIds.isEmpty()) +// ? new HashMap<>() +// : this.list(Wrappers.lambdaQuery(CookRecipe.class) +// .in(CookRecipe::getRecipeId, recipeIds)) +// .stream() +// .collect(Collectors.toMap(CookRecipe::getRecipeId, Function.identity())); +// Map detailMap = menuRecipeDateVOS1.stream().collect(Collectors.toMap(CookRecipeDateVO::getRecipeId, Function.identity(), (t1, t2) -> { +// return t1; +// })); +// System.err.println("records = " + records.size()); +// CookRecipeVO item; +// long count; +// for(Iterator var12 = records.iterator(); var12.hasNext(); item.setDishesCount(count)) { +// item = var12.next(); +// Long recipeId; +// recipeId = maping.get(item.getStallId()); +// item.setRecipeId(recipeId); +// item.setDetail(detailMap.get(recipeId)); +// item.setRecipeName(Optional.ofNullable(recipeMap.get(recipeId)).map(CookRecipe::getRecipeName).orElse(null)); +// count = 0L; +// if (ObjectUtil.isNotEmpty(item.getDetail()) && ObjectUtil.isNotEmpty(item.getDetail().getDetails())) { +// count = item.getDetail().getDetails().stream().filter((x) -> { +// return ObjectUtil.isNotEmpty(x.getDishesList()); +// }).flatMap((x) -> { +// return x.getDishesList().stream(); +// }).map(CookRecipeDishesVO::getDishesId).distinct().count(); +// } +// } + } + } + return records; + } + /** * 查询菜品计划信息列表 * diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/vo/CookRecipeDateVO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/vo/CookRecipeDateVO.java new file mode 100644 index 0000000..665a532 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/vo/CookRecipeDateVO.java @@ -0,0 +1,50 @@ +package com.bonus.canteen.core.cook.vo; + +import com.bonus.canteen.core.cook.dto.CookRecipeDetailDTO; +import com.bonus.common.core.annotation.Excel; +import com.bonus.common.core.web.domain.BaseEntity; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.ToString; + +import java.time.LocalDate; +import java.util.List; + +/** + * 菜品计划详情信息对象 cook_recipe_detail + * + * @author xsheng + * @date 2025-05-25 + */ + + +@Data +@ToString +public class CookRecipeDateVO extends BaseEntity { + private static final long serialVersionUID = 1L; + + @ApiModelProperty("日期") + private LocalDate day; + + @ApiModelProperty("菜谱ID") + private Long recipeId; + + /** 启用时间(天) */ + @ApiModelProperty(value = "启用时间(天)") + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "启用时间(天)", width = 30, dateFormat = "yyyy-MM-dd") + private LocalDate applyDate; + + /** 启用时间(周) */ + @Excel(name = "启用时间(周)") + @ApiModelProperty(value = "启用时间(周)") + private Long applyWeek; + + /** 启用时间(月) */ + @Excel(name = "启用时间(月)") + @ApiModelProperty(value = "启用时间(月)") + private Long applyMonth; + + List detailList; +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/vo/CookRecipeVO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/vo/CookRecipeVO.java new file mode 100644 index 0000000..8a9c133 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/vo/CookRecipeVO.java @@ -0,0 +1,81 @@ +package com.bonus.canteen.core.cook.vo; + +import com.bonus.canteen.core.cook.dto.CookRecipeDateDTO; +import com.bonus.common.core.annotation.Excel; +import com.bonus.common.core.web.domain.BaseEntity; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.ToString; + +import java.util.Date; +import java.util.List; + +/** + * 菜品计划信息对象 cook_recipe + * + * @author xsheng + * @date 2025-05-25 + */ + + +@Data +@ToString +public class CookRecipeVO extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** 菜谱id */ + private Long recipeId; + + /** 菜谱名称 */ + @Excel(name = "菜谱名称") + @ApiModelProperty(value = "菜谱名称") + private String recipeName; + + /** 菜谱类型(1默认,2按天,3按周,4按月) */ + @Excel(name = "菜谱类型(1默认,2按天,3按周,4按月)") + @ApiModelProperty(value = "菜谱类型(1默认,2按天,3按周,4按月)") + private Long recipeType; + + /** 档口id */ + @Excel(name = "档口id") + @ApiModelProperty(value = "档口id") + private Long stallId; + + private String stallName; + + /** 食堂id */ + @Excel(name = "食堂id") + @ApiModelProperty(value = "食堂id") + private Long canteenId; + + private String canteenName; + + private Long areaId; + + private String areaName; + + /** 菜品计划id(数据同步) */ + @Excel(name = "菜品计划id(数据同步)") + @ApiModelProperty(value = "菜品计划id(数据同步)") + private String planId; + + /** 生效时间 */ + @ApiModelProperty(value = "生效时间") + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "生效时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date effectDate; + + /** 到期时间 */ + @ApiModelProperty(value = "到期时间") + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "到期时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date expireDate; + + /** + * 删除标志(0代表存在 2代表删除) + */ + private String delFlag; + + private List recipeDateList; +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/vo/StallAndRecipeBindVO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/vo/StallAndRecipeBindVO.java new file mode 100644 index 0000000..6ca7b3f --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/vo/StallAndRecipeBindVO.java @@ -0,0 +1,31 @@ +package com.bonus.canteen.core.cook.vo; + +public class StallAndRecipeBindVO { + private Long stallId; + private Long recipeId; + private Integer bindType; + + public Long getStallId() { + return this.stallId; + } + + public Long getRecipeId() { + return this.recipeId; + } + + public Integer getBindType() { + return this.bindType; + } + + public void setStallId(final Long stallId) { + this.stallId = stallId; + } + + public void setRecipeId(final Long recipeId) { + this.recipeId = recipeId; + } + + public void setBindType(final Integer bindType) { + this.bindType = bindType; + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookRecipeMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookRecipeMapper.xml index 20f2d21..89e6945 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookRecipeMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookRecipeMapper.xml @@ -198,4 +198,63 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{recipeId} + + + + \ No newline at end of file From d9bfcc0c307b79c8592ab4e572daf9bedca5eb12 Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Thu, 29 May 2025 13:51:22 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E5=BD=93=E5=89=8D=E8=8F=9C=E8=B0=B1bind?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/cook/mapper/CookRecipeMapper.java | 16 +++ .../service/impl/CookRecipeServiceImpl.java | 106 +++++++++--------- .../mapper/cook/CookRecipeMapper.xml | 61 ++++++++++ 3 files changed, 130 insertions(+), 53 deletions(-) diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/mapper/CookRecipeMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/mapper/CookRecipeMapper.java index 521a650..785e532 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/mapper/CookRecipeMapper.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/mapper/CookRecipeMapper.java @@ -2,6 +2,8 @@ package com.bonus.canteen.core.cook.mapper; import java.time.LocalDate; import java.util.List; + +import com.bonus.canteen.core.cook.domain.CookAppRecipe; import com.bonus.canteen.core.cook.domain.CookRecipe; import com.bonus.canteen.core.cook.dto.CookRecipeDTO; import com.bonus.canteen.core.cook.dto.CookRecipeDetailDTO; @@ -59,6 +61,20 @@ public interface CookRecipeMapper { */ public int updateCookRecipe(CookRecipeDTO cookRecipeDTO); + List getDeviceIdByDevivce(@Param("canteenId")String canteenId, @Param("stallId")String stallId); + + List getDeviceSnByIds(@Param("list") List deviceInfoList); + + boolean checkIfAlreadyBind(CookAppRecipe appRecipe); + + List selectRecipeInSameShop(@Param("stallId") Long stallId, @Param("bindType") Integer bindType, @Param("mealLineId") Long mealLineId); + + void deleteBind(CookAppRecipe appRecipe); + + int insertBind(CookAppRecipe appRecipe); + + void updateRecipeByCanteenStallMeal(@Param("recipeId")String recipeId, @Param("canteenId")String canteenId, @Param("stallId")String stallId, @Param("deviceIds")List deviceIds); + /** * 删除菜品计划信息 * diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookRecipeServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookRecipeServiceImpl.java index 8b721ae..734ea84 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookRecipeServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookRecipeServiceImpl.java @@ -308,65 +308,65 @@ public class CookRecipeServiceImpl implements ICookRecipeService { } public void bindCookRecipe(CookRecipeBindDTO cookRecipeDTO) { -// CookRecipe menuRecipe = this.cookRecipeMapper.selectCookRecipeByRecipeId(cookRecipeDTO.getRecipeId()); -// List deviceInfoList = new ArrayList<>(); -// if(cookRecipeDTO.getStallId() !=null){ -// deviceInfoList = this.cookRecipeMapper.getDeviceIdByDevivce(null, String.valueOf(cookRecipeDTO.getStallId())); -// if(deviceInfoList == null || deviceInfoList.isEmpty() || deviceInfoList.size() == 0){ -// throw new ServiceException("该食堂档口下没有设备信息"); -// } -// } -// List deviceSnList = this.cookRecipeMapper.getDeviceSnByIds(deviceInfoList); -// CookRecipeSortEnum sortEnum = CookRecipeSortEnum.getBindTypeMap().get(cookRecipeDTO.getBindType()); -// CookAppRecipe mar = new CookAppRecipe(); -// mar.setRecipeId(cookRecipeDTO.getRecipeId()); -// mar.setMealLineId(cookRecipeDTO.getMealLineId()); -// mar.setBindType(cookRecipeDTO.getBindType()); -// List deviceTypeList = cookRecipeMapper.getDeviceIdByDevivce(null, String.valueOf(menuRecipe.getStallId())); -// if (ObjectUtil.isEmpty(sortEnum)) { -// throw new ServiceException("bingType值异常"); -// } else { -// List deviceTypes = sortEnum.getDeviceType(); -// if (cookRecipeDTO.getHandleType().equals(1)) { -// boolean exists; + CookRecipe menuRecipe = this.cookRecipeMapper.selectCookRecipeByRecipeId(cookRecipeDTO.getRecipeId()); + List deviceInfoList = new ArrayList<>(); + if(cookRecipeDTO.getStallId() !=null){ + deviceInfoList = this.cookRecipeMapper.getDeviceIdByDevivce(null, String.valueOf(cookRecipeDTO.getStallId())); + if(deviceInfoList == null || deviceInfoList.isEmpty() || deviceInfoList.size() == 0){ + throw new ServiceException("该食堂档口下没有设备信息"); + } + } + List deviceSnList = this.cookRecipeMapper.getDeviceSnByIds(deviceInfoList); + CookRecipeSortEnum sortEnum = CookRecipeSortEnum.getBindTypeMap().get(cookRecipeDTO.getBindType()); + CookAppRecipe mar = new CookAppRecipe(); + mar.setRecipeId(cookRecipeDTO.getRecipeId()); + mar.setMealLineId(cookRecipeDTO.getMealLineId()); + mar.setBindType(cookRecipeDTO.getBindType()); + List deviceTypeList = cookRecipeMapper.getDeviceIdByDevivce(null, String.valueOf(menuRecipe.getStallId())); + if (ObjectUtil.isEmpty(sortEnum)) { + throw new ServiceException("bingType值异常"); + } else { + List deviceTypes = sortEnum.getDeviceType(); + if (cookRecipeDTO.getHandleType().equals(1)) { + boolean exists; // if (CookBindTypeEnum.RESERVE.key().equals(cookRecipeDTO.getBindType())) { // exists = this.checkCanteenIfReserve(menuRecipe.getCanteenId(), menuRecipe.getStallId()); // if (!exists) { // throw new ServiceException("不支持预订餐"); // } // } -// exists = this.cookRecipeMapper.exists(mar); -// if (exists) { -// throw new ServiceException("菜谱已被使用,请勿重复绑定"); -// } -// List sourceRecipeList = this.cookRecipeMapper.selectRecipeInSameShop(menuRecipe.getStallId(), null, cookRecipeDTO.getBindType(), content.getMealLineId()); -// if (ObjectUtil.isNotEmpty(sourceRecipeList)) { -// mar.setRecipeIds(sourceRecipeList); -// this.cookRecipeMapper.delete(mar); -// } -// CookAppRecipe appRecipe = new CookAppRecipe(); -// appRecipe.setRecipeId(cookRecipeDTO.getRecipeId()); -// appRecipe.setBindType(cookRecipeDTO.getBindType()); -// appRecipe.setMealLineId(cookRecipeDTO.getMealLineId()); -// appRecipe.setBindTime(LocalDateTime.now()); -// this.cookRecipeMapper.insert(appRecipe); -// if (ObjectUtil.isNotEmpty(deviceTypes) && deviceTypeList!= null && !deviceTypeList.isEmpty()) { -// this.cookRecipeMapper.updateRecipeByCanteeStallMeal(String.valueOf(cookRecipeDTO.getRecipeId()), String.valueOf(menuRecipe.getCanteenId()), String.valueOf(menuRecipe.getStallId()),deviceTypeList); -// } -// MqUtil.sendDataChange(menuRecipe, LeMqConstant.DataChangeType.ADD, LeMqConstant.Topic.DATA_CHANGE_RECIPE_RELEASE); -// } else { -// mar.setRecipeIds(Collections.singletonList(mar.getRecipeId())); -// this.cookRecipeMapper.delete(mar); -// if (ObjectUtil.isNotEmpty(deviceTypes) && deviceTypeList!= null && !deviceTypeList.isEmpty()) { -// this.cookRecipeMapper.updateRecipeByCanteeStallMeal("-1", String.valueOf(menuRecipe.getCanteenId()), String.valueOf(menuRecipe.getStallId()), deviceTypeList); -// } -// } -// //发送mq -// for (String deviceSn : deviceSnList){ -// DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePerson(0,cookRecipeDTO.getHandleType().equals(1) ? "update" : "del"); -// MqUtil.pushToSingleDevice(bean, LeMqConstant.Topic.DEVICE_UPDATE_MENU_CONFIG_V4, deviceSn); -// } -// } + exists = this.cookRecipeMapper.checkIfAlreadyBind(mar); + if (exists) { + throw new ServiceException("菜谱已被使用,请勿重复绑定"); + } + List sourceRecipeList = this.cookRecipeMapper.selectRecipeInSameShop(menuRecipe.getStallId(), cookRecipeDTO.getBindType(), cookRecipeDTO.getMealLineId()); + if (ObjectUtil.isNotEmpty(sourceRecipeList)) { + mar.setRecipeIds(sourceRecipeList); + this.cookRecipeMapper.deleteBind(mar); + } + CookAppRecipe appRecipe = new CookAppRecipe(); + appRecipe.setRecipeId(cookRecipeDTO.getRecipeId()); + appRecipe.setBindType(cookRecipeDTO.getBindType()); + appRecipe.setMealLineId(cookRecipeDTO.getMealLineId()); + appRecipe.setBindTime(LocalDateTime.now()); + this.cookRecipeMapper.insertBind(appRecipe); + if (ObjectUtil.isNotEmpty(deviceTypes) && deviceTypeList!= null && !deviceTypeList.isEmpty()) { + this.cookRecipeMapper.updateRecipeByCanteenStallMeal(String.valueOf(cookRecipeDTO.getRecipeId()), String.valueOf(menuRecipe.getCanteenId()), String.valueOf(menuRecipe.getStallId()),deviceTypeList); + } + MqUtil.sendDataChange(menuRecipe, LeMqConstant.DataChangeType.ADD, LeMqConstant.Topic.DATA_CHANGE_RECIPE_RELEASE); + } else { + mar.setRecipeIds(Collections.singletonList(mar.getRecipeId())); + this.cookRecipeMapper.deleteBind(mar); + if (ObjectUtil.isNotEmpty(deviceTypes) && deviceTypeList!= null && !deviceTypeList.isEmpty()) { + this.cookRecipeMapper.updateRecipeByCanteenStallMeal("-1", String.valueOf(menuRecipe.getCanteenId()), String.valueOf(menuRecipe.getStallId()), deviceTypeList); + } + } + //发送mq + for (String deviceSn : deviceSnList){ + DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePerson(0,cookRecipeDTO.getHandleType().equals(1) ? "update" : "del"); + MqUtil.pushToSingleDevice(bean, LeMqConstant.Topic.DEVICE_UPDATE_MENU_CONFIG_V4, deviceSn); + } + } } /** diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookRecipeMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookRecipeMapper.xml index 89e6945..7044b08 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookRecipeMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookRecipeMapper.xml @@ -188,6 +188,67 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where recipe_id = #{recipeId} + + + + + + + + + + delete from cook_recipe_bind_app where recipe_id in + + #{recipeId} + + + and meal_line_id = #{mealLineId} + + and bind_type = #{bindType} + + + + insert into cook_recipe_bind_app (recipe_id,bind_type,bind_time,meal_line_id) + values (#{recipeId},#{bindType},now(),#{mealLineId}) + + + + update cook_recipe_bind_device set recipe_id = #{ recipeId} + where canteen_id = #{canteenId} and stall_id = #{stallId} + and device_id in + + #{item} + + + update cook_recipe set del_flag = '2' where recipe_id = #{recipeId} From a3693858feb822e03114bde465b1e0490c4bfcd3 Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Thu, 29 May 2025 14:09:30 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=BD=93=E5=89=8D=E8=8F=9C=E8=B0=B1bind?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/cook/service/impl/CookRecipeServiceImpl.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookRecipeServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookRecipeServiceImpl.java index 734ea84..de39b5e 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookRecipeServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookRecipeServiceImpl.java @@ -310,13 +310,14 @@ public class CookRecipeServiceImpl implements ICookRecipeService { public void bindCookRecipe(CookRecipeBindDTO cookRecipeDTO) { CookRecipe menuRecipe = this.cookRecipeMapper.selectCookRecipeByRecipeId(cookRecipeDTO.getRecipeId()); List deviceInfoList = new ArrayList<>(); + List deviceSnList = new ArrayList<>(); if(cookRecipeDTO.getStallId() !=null){ deviceInfoList = this.cookRecipeMapper.getDeviceIdByDevivce(null, String.valueOf(cookRecipeDTO.getStallId())); if(deviceInfoList == null || deviceInfoList.isEmpty() || deviceInfoList.size() == 0){ throw new ServiceException("该食堂档口下没有设备信息"); } + deviceSnList = this.cookRecipeMapper.getDeviceSnByIds(deviceInfoList); } - List deviceSnList = this.cookRecipeMapper.getDeviceSnByIds(deviceInfoList); CookRecipeSortEnum sortEnum = CookRecipeSortEnum.getBindTypeMap().get(cookRecipeDTO.getBindType()); CookAppRecipe mar = new CookAppRecipe(); mar.setRecipeId(cookRecipeDTO.getRecipeId()); @@ -362,9 +363,11 @@ public class CookRecipeServiceImpl implements ICookRecipeService { } } //发送mq - for (String deviceSn : deviceSnList){ - DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePerson(0,cookRecipeDTO.getHandleType().equals(1) ? "update" : "del"); - MqUtil.pushToSingleDevice(bean, LeMqConstant.Topic.DEVICE_UPDATE_MENU_CONFIG_V4, deviceSn); + if (!CollectionUtils.isEmpty(deviceSnList)) { + for (String deviceSn : deviceSnList) { + DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePerson(0, cookRecipeDTO.getHandleType().equals(1) ? "update" : "del"); + MqUtil.pushToSingleDevice(bean, LeMqConstant.Topic.DEVICE_UPDATE_MENU_CONFIG_V4, deviceSn); + } } } } From 6337c37f2ee203e072b816846e80463505400f1f Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Thu, 29 May 2025 14:13:29 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E5=BD=93=E5=89=8D=E8=8F=9C=E8=B0=B1bind?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../canteen/core/cook/domain/CookRecipeBindApp.java | 1 + .../resources/mapper/cook/CookRecipeBindAppMapper.xml | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/domain/CookRecipeBindApp.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/domain/CookRecipeBindApp.java index 762658b..da21629 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/domain/CookRecipeBindApp.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/domain/CookRecipeBindApp.java @@ -40,5 +40,6 @@ public class CookRecipeBindApp extends BaseEntity { @Excel(name = "绑定时间", width = 30, dateFormat = "yyyy-MM-dd") private Date bindTime; + private Long mealLineId; } diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookRecipeBindAppMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookRecipeBindAppMapper.xml index 947d362..f3afcbc 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookRecipeBindAppMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookRecipeBindAppMapper.xml @@ -8,6 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -15,7 +16,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select id, recipe_id, bind_type, bind_time, create_by, create_time, update_by, update_time from cook_recipe_bind_app + select id, recipe_id, bind_type, bind_time, meal_line_id, + create_by, create_time, update_by, update_time + from cook_recipe_bind_app @@ -38,6 +42,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" recipe_id, bind_type, bind_time, + meal_line_id, create_by, create_time, update_by, @@ -47,6 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{recipeId}, #{bindType}, #{bindTime}, + #{mealLineId}, #{createBy}, #{createTime}, #{updateBy}, @@ -60,6 +66,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" recipe_id = #{recipeId}, bind_type = #{bindType}, bind_time = #{bindTime}, + meal_line_id = #{mealLineId}, create_by = #{createBy}, create_time = #{createTime}, update_by = #{updateBy}, From 4dc5be1f29a346d74b79d6fc0049ac0ef92e1648 Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Thu, 29 May 2025 14:57:32 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E5=BE=AA=E7=8E=AF=E8=8F=9C=E8=B0=B1?= =?UTF-8?q?=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cook/controller/CookRecipeController.java | 7 ++++ .../core/cook/mapper/CookRecipeMapper.java | 2 ++ .../core/cook/service/ICookRecipeService.java | 2 ++ .../service/impl/CookRecipeServiceImpl.java | 5 +++ .../mapper/cook/CookRecipeMapper.xml | 35 +++++++++++++++++++ 5 files changed, 51 insertions(+) diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/controller/CookRecipeController.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/controller/CookRecipeController.java index 7088ba0..2810f9b 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/controller/CookRecipeController.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/controller/CookRecipeController.java @@ -104,6 +104,13 @@ public class CookRecipeController extends BaseController { return success(list); } + @PostMapping({"/template/detail"}) + @ApiOperation("获取循环菜谱计划-菜谱详情") + public AjaxResult getTemplateRecipeDetail(@RequestBody CookRecipeDetailDTO dto) { + List list = cookRecipeService.selectTemplateDetailList(dto); + return success(list); + } + /** * 新增菜品计划信息 */ diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/mapper/CookRecipeMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/mapper/CookRecipeMapper.java index 785e532..84a6ff5 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/mapper/CookRecipeMapper.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/mapper/CookRecipeMapper.java @@ -45,6 +45,8 @@ public interface CookRecipeMapper { List getRecipeDetail(@Param("params") CookRecipeDetailDTO dto); + List selectTemplateDetailList(@Param("params") CookRecipeDetailDTO dto); + /** * 新增菜品计划信息 * diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/ICookRecipeService.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/ICookRecipeService.java index 9250889..68c4860 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/ICookRecipeService.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/ICookRecipeService.java @@ -37,6 +37,8 @@ public interface ICookRecipeService { public List getRecipeDetail(CookRecipeDetailDTO dto); + public List selectTemplateDetailList(CookRecipeDetailDTO dto); + /** * 新增菜品计划信息 * diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookRecipeServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookRecipeServiceImpl.java index de39b5e..b0bd4d6 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookRecipeServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookRecipeServiceImpl.java @@ -153,6 +153,11 @@ public class CookRecipeServiceImpl implements ICookRecipeService { return cookRecipeMapper.getRecipeDetail(dto); } + @Override + public List selectTemplateDetailList(CookRecipeDetailDTO dto) { + return cookRecipeMapper.selectTemplateDetailList(dto); + } + /** * 新增菜品计划信息 * diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookRecipeMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookRecipeMapper.xml index 7044b08..3348f54 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookRecipeMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookRecipeMapper.xml @@ -128,6 +128,41 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and mrd.detail_type = 1 order by mrdd.dishes_id + +