更新菜谱
This commit is contained in:
parent
fec8f85805
commit
f791312df4
|
|
@ -1,119 +0,0 @@
|
|||
package com.bonus.canteen.core.cook.controller;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import com.bonus.common.log.enums.OperaType;
|
||||
//import com.bonus.canteen.core.cook.common.annotation.PreventRepeatSubmit;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.bonus.common.log.annotation.SysLog;
|
||||
import com.bonus.common.security.annotation.RequiresPermissions;
|
||||
import com.bonus.canteen.core.cook.domain.CookRecipeDetail;
|
||||
import com.bonus.canteen.core.cook.service.ICookRecipeDetailService;
|
||||
import com.bonus.common.core.web.controller.BaseController;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.core.utils.poi.ExcelUtil;
|
||||
import com.bonus.common.core.web.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 菜品计划详情信息Controller
|
||||
*
|
||||
* @author xsheng
|
||||
* @date 2025-05-25
|
||||
*/
|
||||
@Api(tags = "菜品计划详情信息接口")
|
||||
@RestController
|
||||
@RequestMapping("/cook_recipe_detail")
|
||||
public class CookRecipeDetailController extends BaseController {
|
||||
@Autowired
|
||||
private ICookRecipeDetailService cookRecipeDetailService;
|
||||
|
||||
/**
|
||||
* 查询菜品计划详情信息列表
|
||||
*/
|
||||
@ApiOperation(value = "查询菜品计划详情信息列表")
|
||||
//@RequiresPermissions("cook:detail:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(CookRecipeDetail cookRecipeDetail) {
|
||||
startPage();
|
||||
List<CookRecipeDetail> list = cookRecipeDetailService.selectCookRecipeDetailList(cookRecipeDetail);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出菜品计划详情信息列表
|
||||
*/
|
||||
@ApiOperation(value = "导出菜品计划详情信息列表")
|
||||
//@PreventRepeatSubmit
|
||||
//@RequiresPermissions("cook:detail:export")
|
||||
@SysLog(title = "菜品计划详情信息", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出菜品计划详情信息")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, CookRecipeDetail cookRecipeDetail) {
|
||||
List<CookRecipeDetail> list = cookRecipeDetailService.selectCookRecipeDetailList(cookRecipeDetail);
|
||||
ExcelUtil<CookRecipeDetail> util = new ExcelUtil<CookRecipeDetail>(CookRecipeDetail.class);
|
||||
util.exportExcel(response, list, "菜品计划详情信息数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜品计划详情信息详细信息
|
||||
*/
|
||||
@ApiOperation(value = "获取菜品计划详情信息详细信息")
|
||||
//@RequiresPermissions("cook:detail:query")
|
||||
@GetMapping(value = "/{recipeDetailId}")
|
||||
public AjaxResult getInfo(@PathVariable("recipeDetailId") Long recipeDetailId) {
|
||||
return success(cookRecipeDetailService.selectCookRecipeDetailByRecipeDetailId(recipeDetailId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增菜品计划详情信息
|
||||
*/
|
||||
@ApiOperation(value = "新增菜品计划详情信息")
|
||||
//@PreventRepeatSubmit
|
||||
//@RequiresPermissions("cook:detail:add")
|
||||
@SysLog(title = "菜品计划详情信息", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增菜品计划详情信息")
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody CookRecipeDetail cookRecipeDetail) {
|
||||
try {
|
||||
return toAjax(cookRecipeDetailService.insertCookRecipeDetail(cookRecipeDetail));
|
||||
} catch (Exception e) {
|
||||
return error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改菜品计划详情信息
|
||||
*/
|
||||
@ApiOperation(value = "修改菜品计划详情信息")
|
||||
//@PreventRepeatSubmit
|
||||
//@RequiresPermissions("cook:detail:edit")
|
||||
@SysLog(title = "菜品计划详情信息", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改菜品计划详情信息")
|
||||
@PostMapping("/edit")
|
||||
public AjaxResult edit(@RequestBody CookRecipeDetail cookRecipeDetail) {
|
||||
try {
|
||||
return toAjax(cookRecipeDetailService.updateCookRecipeDetail(cookRecipeDetail));
|
||||
} catch (Exception e) {
|
||||
return error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除菜品计划详情信息
|
||||
*/
|
||||
@ApiOperation(value = "删除菜品计划详情信息")
|
||||
//@PreventRepeatSubmit
|
||||
//@RequiresPermissions("cook:detail:remove")
|
||||
@SysLog(title = "菜品计划详情信息", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除菜品计划详情信息")
|
||||
@PostMapping("/del/{recipeDetailIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] recipeDetailIds) {
|
||||
return toAjax(cookRecipeDetailService.deleteCookRecipeDetailByRecipeDetailIds(recipeDetailIds));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,119 +0,0 @@
|
|||
package com.bonus.canteen.core.cook.controller;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import com.bonus.common.log.enums.OperaType;
|
||||
//import com.bonus.canteen.core.cook.common.annotation.PreventRepeatSubmit;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.bonus.common.log.annotation.SysLog;
|
||||
import com.bonus.common.security.annotation.RequiresPermissions;
|
||||
import com.bonus.canteen.core.cook.domain.CookRecipeDishes;
|
||||
import com.bonus.canteen.core.cook.service.ICookRecipeDishesService;
|
||||
import com.bonus.common.core.web.controller.BaseController;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.core.utils.poi.ExcelUtil;
|
||||
import com.bonus.common.core.web.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 菜品计划菜品关联Controller
|
||||
*
|
||||
* @author xsheng
|
||||
* @date 2025-05-25
|
||||
*/
|
||||
@Api(tags = "菜品计划菜品关联接口")
|
||||
@RestController
|
||||
@RequestMapping("/cook_recipe_dishes")
|
||||
public class CookRecipeDishesController extends BaseController {
|
||||
@Autowired
|
||||
private ICookRecipeDishesService cookRecipeDishesService;
|
||||
|
||||
/**
|
||||
* 查询菜品计划菜品关联列表
|
||||
*/
|
||||
@ApiOperation(value = "查询菜品计划菜品关联列表")
|
||||
//@RequiresPermissions("cook:dishes:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(CookRecipeDishes cookRecipeDishes) {
|
||||
startPage();
|
||||
List<CookRecipeDishes> list = cookRecipeDishesService.selectCookRecipeDishesList(cookRecipeDishes);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出菜品计划菜品关联列表
|
||||
*/
|
||||
@ApiOperation(value = "导出菜品计划菜品关联列表")
|
||||
//@PreventRepeatSubmit
|
||||
//@RequiresPermissions("cook:dishes:export")
|
||||
@SysLog(title = "菜品计划菜品关联", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出菜品计划菜品关联")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, CookRecipeDishes cookRecipeDishes) {
|
||||
List<CookRecipeDishes> list = cookRecipeDishesService.selectCookRecipeDishesList(cookRecipeDishes);
|
||||
ExcelUtil<CookRecipeDishes> util = new ExcelUtil<CookRecipeDishes>(CookRecipeDishes.class);
|
||||
util.exportExcel(response, list, "菜品计划菜品关联数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜品计划菜品关联详细信息
|
||||
*/
|
||||
@ApiOperation(value = "获取菜品计划菜品关联详细信息")
|
||||
//@RequiresPermissions("cook:dishes:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
return success(cookRecipeDishesService.selectCookRecipeDishesById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增菜品计划菜品关联
|
||||
*/
|
||||
@ApiOperation(value = "新增菜品计划菜品关联")
|
||||
//@PreventRepeatSubmit
|
||||
//@RequiresPermissions("cook:dishes:add")
|
||||
@SysLog(title = "菜品计划菜品关联", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增菜品计划菜品关联")
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody CookRecipeDishes cookRecipeDishes) {
|
||||
try {
|
||||
return toAjax(cookRecipeDishesService.insertCookRecipeDishes(cookRecipeDishes));
|
||||
} catch (Exception e) {
|
||||
return error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改菜品计划菜品关联
|
||||
*/
|
||||
@ApiOperation(value = "修改菜品计划菜品关联")
|
||||
//@PreventRepeatSubmit
|
||||
//@RequiresPermissions("cook:dishes:edit")
|
||||
@SysLog(title = "菜品计划菜品关联", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改菜品计划菜品关联")
|
||||
@PostMapping("/edit")
|
||||
public AjaxResult edit(@RequestBody CookRecipeDishes cookRecipeDishes) {
|
||||
try {
|
||||
return toAjax(cookRecipeDishesService.updateCookRecipeDishes(cookRecipeDishes));
|
||||
} catch (Exception e) {
|
||||
return error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除菜品计划菜品关联
|
||||
*/
|
||||
@ApiOperation(value = "删除菜品计划菜品关联")
|
||||
//@PreventRepeatSubmit
|
||||
//@RequiresPermissions("cook:dishes:remove")
|
||||
@SysLog(title = "菜品计划菜品关联", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除菜品计划菜品关联")
|
||||
@PostMapping("/del/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
return toAjax(cookRecipeDishesService.deleteCookRecipeDishesByIds(ids));
|
||||
}
|
||||
}
|
||||
|
|
@ -57,4 +57,6 @@ public interface CookRecipeDetailMapper {
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteCookRecipeDetailByRecipeDetailIds(Long[] recipeDetailIds);
|
||||
|
||||
public List<Long> getToDeleteCookRecipeDetailIds(Long recipeId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,4 +57,6 @@ public interface CookRecipeDishesMapper {
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteCookRecipeDishesByIds(Long[] ids);
|
||||
|
||||
public int deleteCookRecipeDishesByCookRecipeDetailIds(Long[] recipeDetailIds);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,8 +96,10 @@ public class CookRecipeServiceImpl implements ICookRecipeService {
|
|||
// 指定日期菜谱,删掉指定日期的菜谱
|
||||
// 循环菜谱,删掉模板数据 + 今日开始的详情数据
|
||||
if (!isCreate) {
|
||||
|
||||
|
||||
List<Long> cookRecipeDetailIds = cookRecipeDetailMapper.getToDeleteCookRecipeDetailIds(cookRecipeDTO.getRecipeId());
|
||||
Long[] cookRecipeDetailArray = cookRecipeDetailIds.stream().toArray(Long[]::new);
|
||||
cookRecipeDishesMapper.deleteCookRecipeDishesByCookRecipeDetailIds(cookRecipeDetailArray);
|
||||
cookRecipeDetailMapper.deleteCookRecipeDetailByRecipeDetailIds(cookRecipeDetailArray);
|
||||
}
|
||||
// 插入指定日期、日循环摸板、周循环模板
|
||||
if (!CollectionUtils.isEmpty(cookRecipeDTO.getRecipeDateList())) {
|
||||
|
|
|
|||
|
|
@ -98,4 +98,39 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
#{recipeDetailId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="getToDeleteCookRecipeDetailIds" parameterType="Long" resultType="Long">
|
||||
SELECT distinct(crd.recipe_detail_id)
|
||||
FROM cook_recipe_detail crd
|
||||
left join cook_recipe cr ON cr.recipe_id = crd.recipe_id
|
||||
where cr.recipe_id = #{recipeId} and cr.recipe_type = 1
|
||||
|
||||
UNION
|
||||
|
||||
SELECT distinct(crd.recipe_detail_id)
|
||||
FROM cook_recipe_detail crd
|
||||
left join cook_recipe cr ON cr.recipe_id = crd.recipe_id
|
||||
where cr.recipe_id = #{recipeId} and cr.recipe_type = 2 and crd.detail_type = 1
|
||||
|
||||
UNION
|
||||
|
||||
SELECT distinct(crd.recipe_detail_id)
|
||||
FROM cook_recipe_detail crd
|
||||
left join cook_recipe cr ON cr.recipe_id = crd.recipe_id
|
||||
where cr.recipe_id = #{recipeId} and cr.recipe_type = 2 and crd.detail_type = 2 and crd.apply_date >= NOW()-1
|
||||
|
||||
UNION
|
||||
|
||||
SELECT distinct(crd.recipe_detail_id)
|
||||
FROM cook_recipe_detail crd
|
||||
left join cook_recipe cr ON cr.recipe_id = crd.recipe_id
|
||||
where cr.recipe_id = #{recipeId} and cr.recipe_type = 3 and crd.detail_type = 1
|
||||
|
||||
UNION
|
||||
|
||||
SELECT distinct(crd.recipe_detail_id)
|
||||
FROM cook_recipe_detail crd
|
||||
left join cook_recipe cr ON cr.recipe_id = crd.recipe_id
|
||||
where cr.recipe_id = #{recipeId} and cr.recipe_type = 3 and crd.detail_type = 2 and crd.apply_date >= NOW()-1
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -118,4 +118,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteCookRecipeDishesByCookRecipeDetailIds" parameterType="String">
|
||||
delete from cook_recipe_dishes where recipe_detail_id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue