更新菜谱

This commit is contained in:
sxu 2025-05-28 10:49:46 +08:00
parent e786f8d53a
commit fec8f85805
4 changed files with 27 additions and 16 deletions

View File

@ -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());
}

View File

@ -40,10 +40,10 @@ public interface CookRecipeMapper {
/**
* 修改菜品计划信息
*
* @param cookRecipe 菜品计划信息
* @param cookRecipeDTO 菜品计划信息
* @return 结果
*/
public int updateCookRecipe(CookRecipe cookRecipe);
public int updateCookRecipe(CookRecipeDTO cookRecipeDTO);
/**
* 删除菜品计划信息

View File

@ -38,10 +38,10 @@ public interface ICookRecipeService {
/**
* 修改菜品计划信息
*
* @param cookRecipe 菜品计划信息
* @param cookRecipeDTO 菜品计划信息
* @return 结果
*/
public int updateCookRecipe(CookRecipe cookRecipe);
public int updateCookRecipe(CookRecipeDTO cookRecipeDTO);
/**
* 批量删除菜品计划信息

View File

@ -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<CookRecipe> cookRecipes = cookRecipeMapper.selectCookRecipeList(new CookRecipe());
List<String> 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());
}