From fec8f858059d04692891ceee711980a93d489943 Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Wed, 28 May 2025 10:49:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=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 | 4 +-- .../core/cook/mapper/CookRecipeMapper.java | 4 +-- .../core/cook/service/ICookRecipeService.java | 4 +-- .../service/impl/CookRecipeServiceImpl.java | 31 +++++++++++++------ 4 files changed, 27 insertions(+), 16 deletions(-) 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 1c4cc14..4331ff1 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 @@ -99,9 +99,9 @@ public class CookRecipeController extends BaseController { //@RequiresPermissions("cook:recipe:edit") @SysLog(title = "菜品计划信息", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改菜品计划信息") @PostMapping("/edit") - public AjaxResult edit(@RequestBody CookRecipe cookRecipe) { + public AjaxResult edit(@RequestBody CookRecipeDTO cookRecipeDTO) { try { - return toAjax(cookRecipeService.updateCookRecipe(cookRecipe)); + return toAjax(cookRecipeService.updateCookRecipe(cookRecipeDTO)); } catch (Exception e) { return error(e.getMessage()); } 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 a172929..5b64dc3 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 @@ -40,10 +40,10 @@ public interface CookRecipeMapper { /** * 修改菜品计划信息 * - * @param cookRecipe 菜品计划信息 + * @param cookRecipeDTO 菜品计划信息 * @return 结果 */ - public int updateCookRecipe(CookRecipe cookRecipe); + public int updateCookRecipe(CookRecipeDTO cookRecipeDTO); /** * 删除菜品计划信息 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 35d8e3c..1181ed2 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 @@ -38,10 +38,10 @@ public interface ICookRecipeService { /** * 修改菜品计划信息 * - * @param cookRecipe 菜品计划信息 + * @param cookRecipeDTO 菜品计划信息 * @return 结果 */ - public int updateCookRecipe(CookRecipe cookRecipe); + public int updateCookRecipe(CookRecipeDTO cookRecipeDTO); /** * 批量删除菜品计划信息 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 f8289e9..68e796f 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 @@ -2,6 +2,7 @@ package com.bonus.canteen.core.cook.service.impl; import java.time.LocalDate; import java.util.*; +import java.util.stream.Collectors; import com.bonus.canteen.core.cook.domain.CookRecipeDetail; import com.bonus.canteen.core.cook.domain.CookRecipeDishes; @@ -91,6 +92,13 @@ public class CookRecipeServiceImpl implements ICookRecipeService { } private void createRecipeDetails(CookRecipeDTO cookRecipeDTO, boolean isCreate) { + // 更新菜谱时, + // 指定日期菜谱,删掉指定日期的菜谱 + // 循环菜谱,删掉模板数据 + 今日开始的详情数据 + if (!isCreate) { + + + } // 插入指定日期、日循环摸板、周循环模板 if (!CollectionUtils.isEmpty(cookRecipeDTO.getRecipeDateList())) { for (CookRecipeDateDTO recipeDateDTO : cookRecipeDTO.getRecipeDateList()) { @@ -186,20 +194,23 @@ public class CookRecipeServiceImpl implements ICookRecipeService { /** * 修改菜品计划信息 * - * @param cookRecipe 菜品计划信息 + * @param cookRecipeDTO 菜品计划信息 * @return 结果 */ @Override - public int updateCookRecipe(CookRecipe cookRecipe) { - cookRecipe.setUpdateTime(DateUtils.getNowDate()); + public int updateCookRecipe(CookRecipeDTO cookRecipeDTO) { + cookRecipeDTO.setUpdateTime(DateUtils.getNowDate()); + cookRecipeDTO.setUpdateBy(SecurityUtils.getUsername()); try { - //TODO 删除菜谱之菜品详情 - //TODO 删除菜谱之执行计划 - - //TODO 新增菜谱之执行计划 - //TODO 新增菜谱之菜品详情 - - return cookRecipeMapper.updateCookRecipe(cookRecipe); + List cookRecipes = cookRecipeMapper.selectCookRecipeList(new CookRecipe()); + List otherCookRecipes = cookRecipes.stream().filter(item -> !item.getRecipeId().equals(cookRecipeDTO.getRecipeId())) + .map(CookRecipe::getRecipeName).collect(Collectors.toList()); + if (otherCookRecipes.contains(cookRecipeDTO.getRecipeName())) { + throw new ServiceException("该菜谱名称已存在,请重新输入"); + } + int count = cookRecipeMapper.updateCookRecipe(cookRecipeDTO); + createRecipeDetails(cookRecipeDTO, false); + return count; } catch (Exception e) { throw new ServiceException(e.getMessage()); }