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 2932299..7088ba0 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 @@ -8,6 +8,7 @@ import com.bonus.canteen.core.cook.dto.CookRecipeBindDTO; import com.bonus.canteen.core.cook.dto.CookRecipeDTO; import com.bonus.canteen.core.cook.dto.CookRecipeDetailDTO; import com.bonus.canteen.core.cook.vo.CookRecipeDetailVO; +import com.bonus.canteen.core.cook.vo.CookRecipeVO; import com.bonus.common.log.enums.OperaType; //import com.bonus.canteen.core.cook.common.annotation.PreventRepeatSubmit; import io.swagger.annotations.Api; @@ -43,6 +44,15 @@ public class CookRecipeController extends BaseController { @Autowired private ICookRecipeService cookRecipeService; + @ApiOperation(value = "当前菜谱") + //@RequiresPermissions("menu:recipe:list") + @GetMapping("/currentList") + public TableDataInfo currentList(CookRecipeDTO content) { + startPage(); + List list = cookRecipeService.selectCookRecipeListV2(content); + return getDataTable(list); + } + /** * 查询菜品计划信息列表 */ 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 index 5fc653e..0399753 100644 --- 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 @@ -67,5 +67,15 @@ public class CookRecipeDTO extends BaseEntity { */ private String delFlag; + private Long areaId; + + private Integer key; + + @ApiModelProperty("菜谱绑定类型") + private Integer bindType; + + @ApiModelProperty("设备类型") + private List deviceTypeList; + private List recipeDateList; } 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 47cf687..521a650 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 @@ -6,6 +6,8 @@ import com.bonus.canteen.core.cook.domain.CookRecipe; import com.bonus.canteen.core.cook.dto.CookRecipeDTO; import com.bonus.canteen.core.cook.dto.CookRecipeDetailDTO; import com.bonus.canteen.core.cook.vo.CookRecipeDetailVO; +import com.bonus.canteen.core.cook.vo.CookRecipeVO; +import com.bonus.canteen.core.cook.vo.StallAndRecipeBindVO; import org.apache.ibatis.annotations.Param; /** @@ -72,4 +74,8 @@ public interface CookRecipeMapper { * @return 结果 */ public int deleteCookRecipeByRecipeIds(Long[] recipeIds); + + public List selectCookRecipeListV2(CookRecipeDTO content); + + List selectRecipeByStallIdsAndBindType(@Param("stallIds") List stallIds, @Param("bindType") Integer bindType); } 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 3a1ee9e..9250889 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 @@ -6,6 +6,7 @@ import com.bonus.canteen.core.cook.dto.CookRecipeBindDTO; import com.bonus.canteen.core.cook.dto.CookRecipeDTO; import com.bonus.canteen.core.cook.dto.CookRecipeDetailDTO; import com.bonus.canteen.core.cook.vo.CookRecipeDetailVO; +import com.bonus.canteen.core.cook.vo.CookRecipeVO; /** * 菜品计划信息Service接口 @@ -22,6 +23,8 @@ public interface ICookRecipeService { */ public CookRecipe selectCookRecipeByRecipeId(Long recipeId); + public List selectCookRecipeListV2(CookRecipeDTO dto); + /** * 查询菜品计划信息列表 * 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 60eac2e..8b721ae 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 @@ -3,9 +3,11 @@ package com.bonus.canteen.core.cook.service.impl; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.bonus.canteen.core.common.utils.MqUtil; import com.bonus.canteen.core.cook.domain.CookAppRecipe; import com.bonus.canteen.core.cook.domain.CookRecipeDetail; @@ -17,12 +19,13 @@ import com.bonus.canteen.core.cook.enums.RecipeDetailTypeEnum; 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.CookRecipeDetailVO; +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; import com.bonus.common.houqin.mq.constant.LeMqConstant; +import com.bonus.common.houqin.utils.LeBeanUtil; import com.bonus.common.security.utils.SecurityUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -65,6 +68,61 @@ public class CookRecipeServiceImpl implements ICookRecipeService { return cookRecipeMapper.selectCookRecipeByRecipeId(recipeId); } + public List selectCookRecipeListV2(CookRecipeDTO content) { + Map bindTypeMap = CookRecipeSortEnum.getKeyMap(); + CookRecipeSortEnum sortEnum = bindTypeMap.get(content.getKey()); + List records = new ArrayList<>(); + if (ObjectUtil.isEmpty(sortEnum)) { + throw new ServiceException("参数错误"); + }else{ + content.setDeviceTypeList(sortEnum.getDeviceType()); + content.setBindType(sortEnum.getBindType()); + content.setRecipeName(LeBeanUtil.fieldLikeHandle(content.getRecipeName())); + records = cookRecipeMapper.selectCookRecipeListV2(content); + if (ObjectUtil.isNotEmpty(records)) { + List recipeIds; + Map maping; + List menuRecipeDateVOS; + menuRecipeDateVOS = records.stream().map(CookRecipeVO::getStallId).collect(Collectors.toList()); + List stallAndRecipeBindDtos = this.cookRecipeMapper.selectRecipeByStallIdsAndBindType(menuRecipeDateVOS, content.getBindType()); + maping = stallAndRecipeBindDtos.stream().collect(Collectors.toMap(StallAndRecipeBindVO::getStallId, StallAndRecipeBindVO::getRecipeId)); + recipeIds = stallAndRecipeBindDtos.stream().map(StallAndRecipeBindVO::getRecipeId).distinct().collect(Collectors.toList()); + +// this.generateRecipe(recipeIds, content.getApplyDate()); +// List menuRecipeDateVOS1 = this.cookRecipeMapper.selectTmpBetweenDateDetailList(recipeIds, content.getApplyDate(), content.getApplyDate()); +// Map recipeMap = (recipeIds == null || recipeIds.isEmpty()) +// ? new HashMap<>() +// : this.list(Wrappers.lambdaQuery(CookRecipe.class) +// .in(CookRecipe::getRecipeId, recipeIds)) +// .stream() +// .collect(Collectors.toMap(CookRecipe::getRecipeId, Function.identity())); +// Map detailMap = menuRecipeDateVOS1.stream().collect(Collectors.toMap(CookRecipeDateVO::getRecipeId, Function.identity(), (t1, t2) -> { +// return t1; +// })); +// System.err.println("records = " + records.size()); +// CookRecipeVO item; +// long count; +// for(Iterator var12 = records.iterator(); var12.hasNext(); item.setDishesCount(count)) { +// item = var12.next(); +// Long recipeId; +// recipeId = maping.get(item.getStallId()); +// item.setRecipeId(recipeId); +// item.setDetail(detailMap.get(recipeId)); +// item.setRecipeName(Optional.ofNullable(recipeMap.get(recipeId)).map(CookRecipe::getRecipeName).orElse(null)); +// count = 0L; +// if (ObjectUtil.isNotEmpty(item.getDetail()) && ObjectUtil.isNotEmpty(item.getDetail().getDetails())) { +// count = item.getDetail().getDetails().stream().filter((x) -> { +// return ObjectUtil.isNotEmpty(x.getDishesList()); +// }).flatMap((x) -> { +// return x.getDishesList().stream(); +// }).map(CookRecipeDishesVO::getDishesId).distinct().count(); +// } +// } + } + } + return records; + } + /** * 查询菜品计划信息列表 * diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/vo/CookRecipeDateVO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/vo/CookRecipeDateVO.java new file mode 100644 index 0000000..665a532 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/vo/CookRecipeDateVO.java @@ -0,0 +1,50 @@ +package com.bonus.canteen.core.cook.vo; + +import com.bonus.canteen.core.cook.dto.CookRecipeDetailDTO; +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.time.LocalDate; +import java.util.List; + +/** + * 菜品计划详情信息对象 cook_recipe_detail + * + * @author xsheng + * @date 2025-05-25 + */ + + +@Data +@ToString +public class CookRecipeDateVO extends BaseEntity { + private static final long serialVersionUID = 1L; + + @ApiModelProperty("日期") + private LocalDate day; + + @ApiModelProperty("菜谱ID") + private Long recipeId; + + /** 启用时间(天) */ + @ApiModelProperty(value = "启用时间(天)") + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "启用时间(天)", width = 30, dateFormat = "yyyy-MM-dd") + private LocalDate 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/vo/CookRecipeVO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/vo/CookRecipeVO.java new file mode 100644 index 0000000..8a9c133 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/vo/CookRecipeVO.java @@ -0,0 +1,81 @@ +package com.bonus.canteen.core.cook.vo; + +import com.bonus.canteen.core.cook.dto.CookRecipeDateDTO; +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 CookRecipeVO 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; + + private String stallName; + + /** 食堂id */ + @Excel(name = "食堂id") + @ApiModelProperty(value = "食堂id") + private Long canteenId; + + private String canteenName; + + private Long areaId; + + private String areaName; + + /** 菜品计划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; + + /** + * 删除标志(0代表存在 2代表删除) + */ + private String delFlag; + + private List recipeDateList; +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/vo/StallAndRecipeBindVO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/vo/StallAndRecipeBindVO.java new file mode 100644 index 0000000..6ca7b3f --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/vo/StallAndRecipeBindVO.java @@ -0,0 +1,31 @@ +package com.bonus.canteen.core.cook.vo; + +public class StallAndRecipeBindVO { + private Long stallId; + private Long recipeId; + private Integer bindType; + + public Long getStallId() { + return this.stallId; + } + + public Long getRecipeId() { + return this.recipeId; + } + + public Integer getBindType() { + return this.bindType; + } + + public void setStallId(final Long stallId) { + this.stallId = stallId; + } + + public void setRecipeId(final Long recipeId) { + this.recipeId = recipeId; + } + + public void setBindType(final Integer bindType) { + this.bindType = bindType; + } +} 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 20f2d21..89e6945 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 @@ -198,4 +198,63 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{recipeId} + + + + \ No newline at end of file