当前菜谱

This commit is contained in:
sxu 2025-05-29 13:23:00 +08:00
parent 60517d329e
commit d62a462c9a
9 changed files with 309 additions and 1 deletions

View File

@ -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<CookRecipeVO> list = cookRecipeService.selectCookRecipeListV2(content);
return getDataTable(list);
}
/**
* 查询菜品计划信息列表
*/

View File

@ -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<Integer> deviceTypeList;
private List<CookRecipeDateDTO> recipeDateList;
}

View File

@ -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<CookRecipeVO> selectCookRecipeListV2(CookRecipeDTO content);
List<StallAndRecipeBindVO> selectRecipeByStallIdsAndBindType(@Param("stallIds") List<Long> stallIds, @Param("bindType") Integer bindType);
}

View File

@ -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<CookRecipeVO> selectCookRecipeListV2(CookRecipeDTO dto);
/**
* 查询菜品计划信息列表
*

View File

@ -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<CookRecipeVO> selectCookRecipeListV2(CookRecipeDTO content) {
Map<Integer, CookRecipeSortEnum> bindTypeMap = CookRecipeSortEnum.getKeyMap();
CookRecipeSortEnum sortEnum = bindTypeMap.get(content.getKey());
List<CookRecipeVO> 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<Long> recipeIds;
Map<Long ,Long> maping;
List<Long> menuRecipeDateVOS;
menuRecipeDateVOS = records.stream().map(CookRecipeVO::getStallId).collect(Collectors.toList());
List<StallAndRecipeBindVO> 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<CookRecipeDateVO> menuRecipeDateVOS1 = this.cookRecipeMapper.selectTmpBetweenDateDetailList(recipeIds, content.getApplyDate(), content.getApplyDate());
// Map<Long, CookRecipe> 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<Long, CookRecipeDateVO> 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<CookRecipeVO> 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;
}
/**
* 查询菜品计划信息列表
*

View File

@ -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<CookRecipeDetailVO> detailList;
}

View File

@ -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<CookRecipeDateVO> recipeDateList;
}

View File

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

View File

@ -198,4 +198,63 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{recipeId}
</foreach>
</delete>
<select id="selectCookRecipeListV2" resultType="com.bonus.canteen.core.cook.vo.CookRecipeVO">
SELECT
t3.area_id, t3.area_name, t2.canteen_id, t2.canteen_name, t1.stall_id, t1.stall_name
FROM
basic_stall t1
LEFT JOIN basic_canteen t2 ON t1.canteen_id = t2.canteen_id
LEFT JOIN basic_area t3 ON t2.area_id = t3.area_id
where 1=1
<if test="recipeName !=null and recipeName !=''">
AND EXISTS (
select null
from cook_recipe_bind_app t4 INNER JOIN cook_recipe t5 on t4.recipe_id = t5.recipe_id
where t5.stall_id = t1.stall_id AND t4.bind_type = #{bindType}
and t5.recipe_name like #{recipeName}
)
</if>
<if test="deviceTypeList != null and deviceTypeList.size() > 0">
AND EXISTS (
SELECT NULL
FROM
cook_recipe_bind_device t6
LEFT JOIN device_info t7 ON t7.device_id = t6.device_id
WHERE
t6.canteen_id = t2.canteen_id
AND t6.stall_id = t1.stall_id
AND t7.device_type IN
<foreach collection="deviceTypeList" item="deviceType" separator="," open="(" close=")">
#{deviceType}
</foreach>
)
</if>
<if test="areaId !=null">
and t3.area_id = #{areaId}
</if>
<if test="canteenId !=null">
and t2.canteen_id = #{canteenId}
</if>
<if test="stallId !=null ">
and t1.stall_id = #{stallId}
</if>
</select>
<select id="selectRecipeByStallIdsAndBindType"
resultType="com.bonus.canteen.core.cook.vo.StallAndRecipeBindVO">
select
mar.recipe_id,
mr.stall_id,
mar.bind_type
from cook_recipe_bind_app mar
left join cook_recipe mr on mar.recipe_id = mr.recipe_id
where bind_type = #{bindType}
<if test="stallIds !=null and stallIds.size() > 0 ">
and mr.stall_id IN
<foreach collection="stallIds" item="stallId" separator="," open="(" close=")">
#{stallId}
</foreach>
</if>
</select>
</mapper>