From 868b02929eb681f9567de949e1642042a67c5354 Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Sun, 1 Jun 2025 06:56:32 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8F=9C=E8=B0=B1=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/cook/mapper/CookRecipeMapper.java | 2 +- .../service/impl/CookRecipeServiceImpl.java | 53 +++++++++---------- .../mapper/cook/CookRecipeMapper.xml | 2 +- 3 files changed, 28 insertions(+), 29 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 8d3710d..b4aada5 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 @@ -70,7 +70,7 @@ public interface CookRecipeMapper { */ public int updateCookRecipe(CookRecipeDTO cookRecipeDTO); - List getDeviceIdByDevivce(@Param("canteenId")String canteenId, @Param("stallId")String stallId); + List getDeviceIdByDevice(@Param("canteenId")String canteenId, @Param("stallId")String stallId); List getDeviceSnByIds(@Param("list") List deviceInfoList); 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 b2cfcda..905eaa3 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 @@ -22,7 +22,6 @@ 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.*; -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; @@ -368,24 +367,31 @@ public class CookRecipeServiceImpl implements ICookRecipeService { public void bindCookRecipe(CookRecipeBindDTO content) { CookRecipe cookRecipe = this.cookRecipeMapper.selectCookRecipeByRecipeId(content.getRecipeId()); CookRecipeSortEnum sortEnum = CookRecipeSortEnum.getBindTypeMap().get(content.getBindType()); - CookAppRecipe appRecipe = new CookAppRecipe(); if (ObjectUtil.isEmpty(sortEnum)) { throw new ServiceException("菜谱绑定类型错误"); } else { - List deviceTypes = sortEnum.getDeviceType(); + List deviceIds = new ArrayList<>(); + if (CookBindTypeEnum.TABLE.key().equals(content.getBindType())) { //TABLE(7, "智慧餐台/消费机") + if (content.getStallId() != null) { + deviceIds = this.cookRecipeMapper.getDeviceIdByDevice(null, String.valueOf(content.getStallId())); + if (deviceIds == null || deviceIds.isEmpty() || deviceIds.size() == 0) { + throw new ServiceException("该食堂档口下没有设备信息"); + } + } + } + CookAppRecipe appRecipe = new CookAppRecipe(); + appRecipe.setRecipeId(content.getRecipeId()); + appRecipe.setMealLineId(content.getMealLineId()); + appRecipe.setBindType(content.getBindType()); + appRecipe.setBindTime(LocalDateTime.now()); if (content.getHandleType().equals(1)) { - boolean exists; // if (CookBindTypeEnum.RESERVE.key().equals(content.getBindType())) { // exists = this.allocCanteenApi.checkCanteenIfReserve(cookRecipe.getCanteenId(), cookRecipe.getStallId()); // if (!exists) { // throw new ServiceException("不支持预订餐"); // } // } - appRecipe.setRecipeId(content.getRecipeId()); - appRecipe.setMealLineId(content.getMealLineId()); - appRecipe.setBindType(content.getBindType()); - appRecipe.setBindTime(LocalDateTime.now()); - exists = this.cookRecipeMapper.checkIfAlreadyBind(appRecipe); + boolean exists = this.cookRecipeMapper.checkIfAlreadyBind(appRecipe); if (exists) { throw new ServiceException("菜谱已被使用,请勿重复绑定"); } @@ -395,32 +401,25 @@ public class CookRecipeServiceImpl implements ICookRecipeService { this.cookRecipeMapper.deleteBind(appRecipe); } this.cookRecipeMapper.insertBind(appRecipe); - if (ObjectUtil.isNotEmpty(deviceTypes)) { - this.cookRecipeMapper.updateRecipeByCanteenStallMeal(content.getRecipeId(), cookRecipe.getCanteenId(), cookRecipe.getStallId(), deviceTypes); + if (ObjectUtil.isNotEmpty(deviceIds)) { + this.cookRecipeMapper.updateRecipeByCanteenStallMeal(content.getRecipeId(), cookRecipe.getCanteenId(), cookRecipe.getStallId(), deviceIds); } MqUtil.sendDataChange(cookRecipe, LeMqConstant.DataChangeType.ADD, LeMqConstant.Topic.DATA_CHANGE_RECIPE_RELEASE); } else { appRecipe.setRecipeIds(Collections.singletonList(appRecipe.getRecipeId())); this.cookRecipeMapper.deleteBind(appRecipe); - if (ObjectUtil.isNotEmpty(deviceTypes)) { - this.cookRecipeMapper.updateRecipeByCanteenStallMeal(-1L, cookRecipe.getCanteenId(), cookRecipe.getStallId(), deviceTypes); + if (ObjectUtil.isNotEmpty(deviceIds)) { + this.cookRecipeMapper.updateRecipeByCanteenStallMeal(-1L, cookRecipe.getCanteenId(), cookRecipe.getStallId(), deviceIds); } } //发送mq - if (CookBindTypeEnum.TABLE.key().equals(content.getBindType())) { //TABLE(7, "智慧餐台/消费机") - List deviceInfoList = new ArrayList<>(); - if (content.getStallId() != null) { - deviceInfoList = this.cookRecipeMapper.getDeviceIdByDevivce(null, String.valueOf(content.getStallId())); - if (deviceInfoList == null || deviceInfoList.isEmpty() || deviceInfoList.size() == 0) { - throw new ServiceException("该食堂档口下没有设备信息"); - } - } - List deviceSnList = this.cookRecipeMapper.getDeviceSnByIds(deviceInfoList); - for (String deviceSn : deviceSnList) { - DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePerson(0, content.getHandleType().equals(1) ? "update" : "del"); - MqUtil.pushToSingleDevice(bean, LeMqConstant.Topic.DEVICE_UPDATE_MENU_CONFIG_V4, deviceSn); - } - } +// if (CookBindTypeEnum.TABLE.key().equals(content.getBindType())) { //TABLE(7, "智慧餐台/消费机") +// List deviceSnList = this.cookRecipeMapper.getDeviceSnByIds(deviceInfoList); +// for (String deviceSn : deviceSnList) { +// DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePerson(0, content.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 4f0950d..7af8991 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 @@ -294,7 +294,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where recipe_id = #{recipeId} - select a.device_id from device_info a LEFT JOIN cook_recipe_bind_device b on a.device_id = b.device_id