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 a608727..8a73905 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 @@ -2,6 +2,8 @@ package com.bonus.canteen.core.cook.controller; import java.util.List; import javax.servlet.http.HttpServletResponse; + +import com.bonus.canteen.core.cook.dto.CookRecipeDTO; import com.bonus.common.log.enums.OperaType; //import com.bonus.canteen.core.cook.common.annotation.PreventRepeatSubmit; import io.swagger.annotations.Api; @@ -70,6 +72,12 @@ public class CookRecipeController extends BaseController { //@RequiresPermissions("cook:recipe:query") @GetMapping(value = "/{recipeId}") public AjaxResult getInfo(@PathVariable("recipeId") Long recipeId) { + // 构造菜谱之菜品详情VO + + // 狗仔菜谱之执行计划VO + + // 狗仔菜谱VO + return success(cookRecipeService.selectCookRecipeByRecipeId(recipeId)); } @@ -81,9 +89,9 @@ public class CookRecipeController extends BaseController { //@RequiresPermissions("cook:recipe:add") @SysLog(title = "菜品计划信息", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增菜品计划信息") @PostMapping - public AjaxResult add(@RequestBody CookRecipe cookRecipe) { + public AjaxResult add(@RequestBody CookRecipeDTO cookRecipeDTO) { try { - return toAjax(cookRecipeService.insertCookRecipe(cookRecipe)); + return toAjax(cookRecipeService.insertCookRecipe(cookRecipeDTO)); } catch (Exception e) { return error(e.getMessage()); } @@ -99,6 +107,11 @@ public class CookRecipeController extends BaseController { @PostMapping("/edit") public AjaxResult edit(@RequestBody CookRecipe cookRecipe) { try { + //TODO 删除菜谱之菜品详情 + //TODO 删除菜谱之执行计划 + + //TODO 新增菜谱之执行计划 + //TODO 新增菜谱之菜品详情 return toAjax(cookRecipeService.updateCookRecipe(cookRecipe)); } catch (Exception e) { return error(e.getMessage()); @@ -114,6 +127,8 @@ public class CookRecipeController extends BaseController { @SysLog(title = "菜品计划信息", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除菜品计划信息") @PostMapping("/del/{recipeIds}") public AjaxResult remove(@PathVariable Long[] recipeIds) { + //TODO 删除菜谱之菜品详情 + //TODO 删除菜谱之执行计划 return toAjax(cookRecipeService.deleteCookRecipeByRecipeIds(recipeIds)); } } 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 new file mode 100644 index 0000000..db26f03 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/dto/CookRecipeDTO.java @@ -0,0 +1,66 @@ +package com.bonus.canteen.core.cook.dto; + +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 CookRecipeDTO 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; + + /** 食堂id */ + @Excel(name = "食堂id") + @ApiModelProperty(value = "食堂id") + private Long canteenId; + + /** 菜品计划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; + + private List recipeDateList; +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/dto/CookRecipeDateDTO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/dto/CookRecipeDateDTO.java new file mode 100644 index 0000000..aca02c1 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/dto/CookRecipeDateDTO.java @@ -0,0 +1,42 @@ +package com.bonus.canteen.core.cook.dto; + +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_detail + * + * @author xsheng + * @date 2025-05-25 + */ + + +@Data +@ToString +public class CookRecipeDateDTO extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** 启用时间(天) */ + @ApiModelProperty(value = "启用时间(天)") + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "启用时间(天)", width = 30, dateFormat = "yyyy-MM-dd") + private Date 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/dto/CookRecipeDetailDTO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/dto/CookRecipeDetailDTO.java new file mode 100644 index 0000000..0b1f62e --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/dto/CookRecipeDetailDTO.java @@ -0,0 +1,65 @@ +package com.bonus.canteen.core.cook.dto; + +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_detail + * + * @author xsheng + * @date 2025-05-25 + */ + + +@Data +@ToString +public class CookRecipeDetailDTO extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** 菜谱详情id */ + private Long recipeDetailId; + + /** 菜品计划销售类别id(数据同步) */ + @Excel(name = "菜品计划销售类别id(数据同步)") + @ApiModelProperty(value = "菜品计划销售类别id(数据同步)") + private String saleTypeId; + + /** 菜谱id */ + @Excel(name = "菜谱id") + @ApiModelProperty(value = "菜谱id") + private Long recipeId; + + /** 启用时间(天) */ + @ApiModelProperty(value = "启用时间(天)") + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "启用时间(天)", width = 30, dateFormat = "yyyy-MM-dd") + private Date applyDate; + + /** 启用时间(周) */ + @Excel(name = "启用时间(周)") + @ApiModelProperty(value = "启用时间(周)") + private Long applyWeek; + + /** 启用时间(月) */ + @Excel(name = "启用时间(月)") + @ApiModelProperty(value = "启用时间(月)") + private Long applyMonth; + + /** 餐次类型 */ + @Excel(name = "餐次类型") + @ApiModelProperty(value = "餐次类型") + private Long mealtimeType; + + /** 详情类型(1-模板,2-详情) */ + @Excel(name = "详情类型(1-模板,2-详情)") + @ApiModelProperty(value = "详情类型(1-模板,2-详情)") + private Long detailType; + + private List dishesList; +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/dto/CookRecipeDishesDTO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/dto/CookRecipeDishesDTO.java new file mode 100644 index 0000000..2090b9b --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/dto/CookRecipeDishesDTO.java @@ -0,0 +1,81 @@ +package com.bonus.canteen.core.cook.dto; + +import com.bonus.common.core.annotation.Excel; +import com.bonus.common.core.web.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.ToString; + +/** + * 菜品计划菜品关联对象 cook_recipe_dishes + * + * @author xsheng + * @date 2025-05-25 + */ + + +@Data +@ToString +public class CookRecipeDishesDTO extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** 主键id */ + private Long id; + + /** 菜谱详情id */ + @Excel(name = "菜谱详情id") + @ApiModelProperty(value = "菜谱详情id") + private Long recipeDetailId; + + /** 菜品id */ + @Excel(name = "菜品id") + @ApiModelProperty(value = "菜品id") + private Long dishesId; + + /** 菜品单价 */ + @Excel(name = "菜品单价") + @ApiModelProperty(value = "菜品单价") + private Long price; + + /** 菜品售价(优惠价) */ + @Excel(name = "菜品售价(优惠价)") + @ApiModelProperty(value = "菜品售价(优惠价)") + private Long salePrice; + + /** 规格类型(1-标准,2-大份,3-小份,4-50g,5-100g) */ + @Excel(name = "规格类型(1-标准,2-大份,3-小份,4-50g,5-100g)") + @ApiModelProperty(value = "规格类型(1-标准,2-大份,3-小份,4-50g,5-100g)") + private Long sizeType; + + /** 供应数量 */ + @Excel(name = "供应数量") + @ApiModelProperty(value = "供应数量") + private Long supplyNum; + + /** 销售数量 */ + @Excel(name = "销售数量") + @ApiModelProperty(value = "销售数量") + private Long saleNum; + + /** 剩余数量 */ + @Excel(name = "剩余数量") + @ApiModelProperty(value = "剩余数量") + private Integer remanentNum; + + /** 个人限购数量 */ + @Excel(name = "个人限购数量") + @ApiModelProperty(value = "个人限购数量") + private Long limitNum; + + /** 厨师id */ + @Excel(name = "厨师id") + @ApiModelProperty(value = "厨师id") + private Long chefId; + + /** 是否推荐(1-推荐,2-不推荐) */ + @Excel(name = "是否推荐(1-推荐,2-不推荐)") + @ApiModelProperty(value = "是否推荐(1-推荐,2-不推荐)") + private Long recommendFlag; + + +} 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 fbac632..6d8c4c5 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,7 @@ package com.bonus.canteen.core.cook.mapper; import java.util.List; import com.bonus.canteen.core.cook.domain.CookRecipe; +import com.bonus.canteen.core.cook.dto.CookRecipeDTO; /** * 菜品计划信息Mapper接口 @@ -29,10 +30,10 @@ public interface CookRecipeMapper { /** * 新增菜品计划信息 * - * @param cookRecipe 菜品计划信息 + * @param cookRecipeDTO 菜品计划信息 * @return 结果 */ - public int insertCookRecipe(CookRecipe cookRecipe); + public int insertCookRecipe(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 31a1cfd..35d8e3c 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 @@ -2,6 +2,7 @@ package com.bonus.canteen.core.cook.service; import java.util.List; import com.bonus.canteen.core.cook.domain.CookRecipe; +import com.bonus.canteen.core.cook.dto.CookRecipeDTO; /** * 菜品计划信息Service接口 @@ -29,10 +30,10 @@ public interface ICookRecipeService { /** * 新增菜品计划信息 * - * @param cookRecipe 菜品计划信息 + * @param cookRecipeDTO 菜品计划信息 * @return 结果 */ - public int insertCookRecipe(CookRecipe cookRecipe); + public int insertCookRecipe(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 f03be70..9e5ebd5 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 @@ -1,13 +1,25 @@ package com.bonus.canteen.core.cook.service.impl; import java.util.List; + +import com.bonus.canteen.core.cook.domain.CookRecipeDetail; +import com.bonus.canteen.core.cook.domain.CookRecipeDishes; +import com.bonus.canteen.core.cook.dto.CookRecipeDTO; +import com.bonus.canteen.core.cook.dto.CookRecipeDateDTO; +import com.bonus.canteen.core.cook.dto.CookRecipeDetailDTO; +import com.bonus.canteen.core.cook.dto.CookRecipeDishesDTO; +import com.bonus.canteen.core.cook.mapper.CookRecipeDetailMapper; +import com.bonus.canteen.core.cook.mapper.CookRecipeDishesMapper; import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.utils.DateUtils; +import com.bonus.common.security.utils.SecurityUtils; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.bonus.canteen.core.cook.mapper.CookRecipeMapper; import com.bonus.canteen.core.cook.domain.CookRecipe; import com.bonus.canteen.core.cook.service.ICookRecipeService; +import org.springframework.transaction.annotation.Transactional; /** * 菜品计划信息Service业务层处理 @@ -19,6 +31,10 @@ import com.bonus.canteen.core.cook.service.ICookRecipeService; public class CookRecipeServiceImpl implements ICookRecipeService { @Autowired private CookRecipeMapper cookRecipeMapper; + @Autowired + private CookRecipeDetailMapper cookRecipeDetailMapper; + @Autowired + private CookRecipeDishesMapper cookRecipeDishesMapper; /** * 查询菜品计划信息 @@ -45,14 +61,34 @@ public class CookRecipeServiceImpl implements ICookRecipeService { /** * 新增菜品计划信息 * - * @param cookRecipe 菜品计划信息 + * @param cookRecipeDTO 菜品计划信息 * @return 结果 */ @Override - public int insertCookRecipe(CookRecipe cookRecipe) { - cookRecipe.setCreateTime(DateUtils.getNowDate()); + @Transactional(rollbackFor = Exception.class) + public int insertCookRecipe(CookRecipeDTO cookRecipeDTO) { + cookRecipeDTO.setCreateTime(DateUtils.getNowDate()); + cookRecipeDTO.setCreateBy(SecurityUtils.getUsername()); try { - return cookRecipeMapper.insertCookRecipe(cookRecipe); + int count = cookRecipeMapper.insertCookRecipe(cookRecipeDTO); //插入菜谱 + List recipeDateList = cookRecipeDTO.getRecipeDateList(); + for (CookRecipeDateDTO recipeDateDTO : recipeDateList) { + List detailList = recipeDateDTO.getDetailList(); + for (CookRecipeDetailDTO detailDTO : detailList) { + CookRecipeDetail cookRecipeDetail = new CookRecipeDetail(); + BeanUtils.copyProperties(detailDTO, cookRecipeDetail); + cookRecipeDetail.setRecipeId(cookRecipeDTO.getRecipeId()); + cookRecipeDetailMapper.insertCookRecipeDetail(cookRecipeDetail); //插入菜谱之执行计划 + List dishesList = detailDTO.getDishesList(); + for (CookRecipeDishesDTO dishesDTO : dishesList) { + CookRecipeDishes cookRecipeDishes = new CookRecipeDishes(); + BeanUtils.copyProperties(dishesDTO, cookRecipeDishes); + cookRecipeDishes.setRecipeDetailId(detailDTO.getRecipeDetailId()); + cookRecipeDishesMapper.insertCookRecipeDishes(cookRecipeDishes); //插入菜谱之菜品详情 + } + } + } + return count; } catch (Exception e) { throw new ServiceException(e.getMessage()); }