当前菜谱

This commit is contained in:
sxu 2025-06-03 16:39:09 +08:00
parent 5aa087c457
commit affb765dcf
8 changed files with 323 additions and 32 deletions

View File

@ -5,9 +5,11 @@ import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import cn.hutool.core.util.ObjectUtil;
import com.bonus.canteen.core.cook.dto.AllocRecipeStallDTO;
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.AllocRecipeStallVO;
import com.bonus.canteen.core.cook.vo.CookRecipeDetailVO;
import com.bonus.canteen.core.cook.vo.CookRecipeVO;
import com.bonus.common.log.enums.OperaType;
@ -54,9 +56,9 @@ public class CookRecipeController extends BaseController {
@ApiOperation(value = "当前菜谱")
//@RequiresPermissions("menu:recipe:list")
@PostMapping("/currentList")
public TableDataInfo currentList(@RequestBody CookRecipeDTO content) {
public TableDataInfo currentList(@RequestBody AllocRecipeStallDTO content) {
startPage();
List<CookRecipeVO> list = cookRecipeService.selectCookRecipeList4Current(content);
List<AllocRecipeStallVO> list = cookRecipeService.selectCookRecipeList4Current(content);
return getDataTable(list);
}

View File

@ -0,0 +1,148 @@
package com.bonus.canteen.core.cook.dto;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDate;
import java.util.List;
public class AllocRecipeStallDTO {
@ApiModelProperty("区域id")
private Long areaId;
private List<Long> areaIds;
@ApiModelProperty("食堂id")
private Long canteenId;
private List<Long> canteenIds;
@ApiModelProperty("档口id")
private Long stallId;
private List<Long> stallIds;
@ApiModelProperty("餐线类型")
private Integer mealLineType;
@ApiModelProperty("餐线id")
private Long mealLineId;
@ApiModelProperty("菜谱名称")
private String recipeName;
@ApiModelProperty("菜谱绑定类型")
private Integer bindType;
@ApiModelProperty("设备类型")
private List<Integer> deviceTypeList;
@ApiModelProperty("是否查询餐线")
private Integer ifQueryMealLine;
private Integer key;
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE) // for "yyyy-MM-dd" format
private LocalDate applyDate;
public Long getAreaId() {
return this.areaId;
}
public List<Long> getAreaIds() {
return this.areaIds;
}
public Long getCanteenId() {
return this.canteenId;
}
public List<Long> getCanteenIds() {
return this.canteenIds;
}
public Long getStallId() {
return this.stallId;
}
public List<Long> getStallIds() {
return this.stallIds;
}
public Integer getMealLineType() {
return this.mealLineType;
}
public Long getMealLineId() {
return this.mealLineId;
}
public String getRecipeName() {
return this.recipeName;
}
public Integer getBindType() {
return this.bindType;
}
public List<Integer> getDeviceTypeList() {
return this.deviceTypeList;
}
public Integer getIfQueryMealLine() {
return this.ifQueryMealLine;
}
public Integer getKey() {
return this.key;
}
public LocalDate getApplyDate() {
return this.applyDate;
}
public void setAreaId(final Long areaId) {
this.areaId = areaId;
}
public void setAreaIds(final List<Long> areaIds) {
this.areaIds = areaIds;
}
public void setCanteenId(final Long canteenId) {
this.canteenId = canteenId;
}
public void setCanteenIds(final List<Long> canteenIds) {
this.canteenIds = canteenIds;
}
public void setStallId(final Long stallId) {
this.stallId = stallId;
}
public void setStallIds(final List<Long> stallIds) {
this.stallIds = stallIds;
}
public void setMealLineType(final Integer mealLineType) {
this.mealLineType = mealLineType;
}
public void setMealLineId(final Long mealLineId) {
this.mealLineId = mealLineId;
}
public void setRecipeName(final String recipeName) {
this.recipeName = recipeName;
}
public void setBindType(final Integer bindType) {
this.bindType = bindType;
}
public void setDeviceTypeList(final List<Integer> deviceTypeList) {
this.deviceTypeList = deviceTypeList;
}
public void setIfQueryMealLine(final Integer ifQueryMealLine) {
this.ifQueryMealLine = ifQueryMealLine;
}
public void setKey(final Integer key) {
this.key = key;
}
public void setApplyDate(final LocalDate applyDate) {
this.applyDate = applyDate;
}
}

View File

@ -0,0 +1,10 @@
package com.bonus.canteen.core.cook.dto;
import lombok.Data;
@Data
public class StallAndRecipeBindDto {
private Long stallId;
private Long recipeId;
private Integer bindType;
}

View File

@ -5,12 +5,11 @@ import java.util.List;
import com.bonus.canteen.core.cook.domain.CookAppRecipe;
import com.bonus.canteen.core.cook.domain.CookRecipe;
import com.bonus.canteen.core.cook.dto.AllocRecipeStallDTO;
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.CookRecipeDishesCountVO;
import com.bonus.canteen.core.cook.vo.CookRecipeVO;
import com.bonus.canteen.core.cook.vo.StallAndRecipeBindVO;
import com.bonus.canteen.core.cook.dto.StallAndRecipeBindDto;
import com.bonus.canteen.core.cook.vo.*;
import org.apache.ibatis.annotations.Param;
/**
@ -103,10 +102,15 @@ public interface CookRecipeMapper {
List<CookRecipe> getCookRecipeByRecipeIds(@Param("recipeIds") List<Long> recipeIds);
public List<CookRecipeVO> selectCookRecipeListV2(CookRecipeDTO content);
public List<AllocRecipeStallVO> selectCookRecipeListV2(AllocRecipeStallDTO content);
List<StallAndRecipeBindVO> selectRecipeByStallIdsAndBindType(@Param("stallIds") List<Long> stallIds, @Param("bindType") Integer bindType);
//List<StallAndRecipeBindVO> selectRecipeByStallIdsAndBindType(@Param("stallIds") List<Long> stallIds, @Param("bindType") Integer bindType);
List<CookRecipeDetailVO> selectTmpBetweenDateDetailList(@Param("recipeIds") List<Long> recipeIds, @Param("applyStartDate") LocalDate applyStartDate, @Param("applyEndDate") LocalDate applyEndDate);
List<StallAndRecipeBindDto> selectRecipeByStallIdsAndBindType(@Param("stallIds") List<Long> stallIds, @Param("bindType") Integer bindType);
List<CookRecipeDateVO> selectTmpBetweenDateDetailList(@Param("recipeIds") List<Long> recipeIds, @Param("applyStartDate") LocalDate applyStartDate, @Param("applyEndDate") LocalDate applyEndDate);
//List<CookRecipeDetailVO> selectTmpBetweenDateDetailList(@Param("recipeIds") List<Long> recipeIds, @Param("applyStartDate") LocalDate applyStartDate, @Param("applyEndDate") LocalDate applyEndDate);
}

View File

@ -4,9 +4,11 @@ import java.util.List;
import java.util.Set;
import com.bonus.canteen.core.cook.domain.CookRecipe;
import com.bonus.canteen.core.cook.dto.AllocRecipeStallDTO;
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.AllocRecipeStallVO;
import com.bonus.canteen.core.cook.vo.CookRecipeDetailVO;
import com.bonus.canteen.core.cook.vo.CookRecipeVO;
import org.springframework.web.multipart.MultipartFile;
@ -34,7 +36,9 @@ public interface ICookRecipeService {
*/
public List<CookRecipe> selectCookRecipeList(CookRecipe cookRecipe);
public List<CookRecipeVO> selectCookRecipeList4Current(CookRecipeDTO dto);
//public List<CookRecipeVO> selectCookRecipeList4Current(CookRecipeDTO dto);
public List<AllocRecipeStallVO> selectCookRecipeList4Current(AllocRecipeStallDTO content);
public List<CookRecipeDetailVO> getRecipeDetailByDate(CookRecipeDetailDTO dto);

View File

@ -12,6 +12,7 @@ import cn.hutool.core.util.ObjectUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelReader;
import com.alibaba.excel.read.metadata.ReadSheet;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.bonus.canteen.core.android.vo.CookMealtimeTypeEnum;
import com.bonus.canteen.core.common.utils.DateUtil;
import com.bonus.canteen.core.common.utils.MqUtil;
@ -120,50 +121,107 @@ public class CookRecipeServiceImpl implements ICookRecipeService {
return list;
}
public List<CookRecipeVO> selectCookRecipeList4Current(CookRecipeDTO content) {
// public List<CookRecipeVO> selectCookRecipeList4Current(CookRecipeDTO content) {
// Map<Integer, CookRecipeSortEnum> bindTypeMap = CookRecipeSortEnum.getKeyMap();
// CookRecipeSortEnum sortEnum = bindTypeMap.get(content.getKey());
// List<CookRecipeVO> records = new ArrayList<>();
// if (Objects.isNull(sortEnum)) {
// throw new ServiceException("参数错误");
// }else{
// content.setDeviceTypeList(sortEnum.getDeviceType());
// content.setBindType(sortEnum.getBindType());
// content.setRecipeName(LeBeanUtil.fieldLikeHandle(content.getRecipeName()));
// records = cookRecipeMapper.selectCookRecipeListV2(content);
// if (!CollectionUtils.isEmpty(records)) {
// List<Long> recipeIds;
// Map<Long ,Long> maping;
// List<Long> stallIds = records.stream().map(CookRecipeVO::getStallId).collect(Collectors.toList());
// List<StallAndRecipeBindVO> stallAndRecipeBindDtos = this.cookRecipeMapper.selectRecipeByStallIdsAndBindType(stallIds, 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<CookRecipeDetailVO> cookRecipeDetailVOs = this.cookRecipeMapper.selectTmpBetweenDateDetailList(recipeIds, content.getApplyDate(), content.getApplyDate());
// Map<Long, CookRecipe> recipeMap = (recipeIds == null || recipeIds.isEmpty())
// ? new HashMap<>()
// : this.cookRecipeMapper.selectRecipeListByRecipeIds(recipeIds)
// .stream()
// .collect(Collectors.toMap(CookRecipe::getRecipeId, Function.identity()));
// Map<Long, CookRecipeDetailVO> detailMap = cookRecipeDetailVOs.stream().collect(Collectors.toMap(CookRecipeDetailVO::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);
// CookRecipeDateVO cookRecipeDateVO = new CookRecipeDateVO();
// cookRecipeDateVO.setDetailList(Arrays.asList(detailMap.get(recipeId)));
// item.setRecipeDateList(Arrays.asList(cookRecipeDateVO));
// item.setRecipeName(Optional.ofNullable(recipeMap.get(recipeId)).map(CookRecipe::getRecipeName).orElse(null));
// count = 0L;
// if (Objects.nonNull(item.getRecipeDateDetail()) && !CollectionUtils.isEmpty(item.getRecipeDateList().get(0).getDetailList())) {
// count = item.getRecipeDateList().get(0).getDetailList().stream().filter((x) -> {
// return !CollectionUtils.isEmpty(x.getDishesList());
// }).flatMap((x) -> {
// return x.getDishesList().stream();
// }).map(CookRecipeDishesVO::getDishesId).distinct().count();
// }
// }
// }
// }
// return records;
// }
@Override
public List<AllocRecipeStallVO> selectCookRecipeList4Current(AllocRecipeStallDTO content) {
Map<Integer, CookRecipeSortEnum> bindTypeMap = CookRecipeSortEnum.getKeyMap();
CookRecipeSortEnum sortEnum = bindTypeMap.get(content.getKey());
List<CookRecipeVO> records = new ArrayList<>();
if (Objects.isNull(sortEnum)) {
List<AllocRecipeStallVO> 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 (!CollectionUtils.isEmpty(records)) {
if (ObjectUtil.isNotEmpty(records)) {
List<Long> recipeIds;
Map<Long ,Long> maping;
List<Long> stallIds = records.stream().map(CookRecipeVO::getStallId).collect(Collectors.toList());
List<StallAndRecipeBindVO> stallAndRecipeBindDtos = this.cookRecipeMapper.selectRecipeByStallIdsAndBindType(stallIds, 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<CookRecipeDetailVO> cookRecipeDetailVOs = this.cookRecipeMapper.selectTmpBetweenDateDetailList(recipeIds, content.getApplyDate(), content.getApplyDate());
List<Long> menuRecipeDateVOS;
menuRecipeDateVOS = records.stream().map(AllocRecipeStallVO::getStallId).collect(Collectors.toList());
List<StallAndRecipeBindDto> stallAndRecipeBindDtos = this.cookRecipeMapper.selectRecipeByStallIdsAndBindType(menuRecipeDateVOS, content.getBindType());
maping = stallAndRecipeBindDtos.stream().collect(Collectors.toMap(StallAndRecipeBindDto::getStallId, StallAndRecipeBindDto::getRecipeId));
recipeIds = stallAndRecipeBindDtos.stream().map(StallAndRecipeBindDto::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.cookRecipeMapper.selectRecipeListByRecipeIds(recipeIds)
.stream()
.collect(Collectors.toMap(CookRecipe::getRecipeId, Function.identity()));
Map<Long, CookRecipeDetailVO> detailMap = cookRecipeDetailVOs.stream().collect(Collectors.toMap(CookRecipeDetailVO::getRecipeId, Function.identity(), (t1, t2) -> {
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;
AllocRecipeStallVO item;
long count;
for(Iterator<CookRecipeVO> var12 = records.iterator(); var12.hasNext(); item.setDishesCount(count)) {
for(Iterator<AllocRecipeStallVO> var12 = records.iterator(); var12.hasNext(); item.setDishesCount(count)) {
item = var12.next();
Long recipeId;
recipeId = maping.get(item.getStallId());
item.setRecipeId(recipeId);
CookRecipeDateVO cookRecipeDateVO = new CookRecipeDateVO();
cookRecipeDateVO.setDetailList(Arrays.asList(detailMap.get(recipeId)));
item.setRecipeDateList(Arrays.asList(cookRecipeDateVO));
item.setDetail(detailMap.get(recipeId));
item.setRecipeName(Optional.ofNullable(recipeMap.get(recipeId)).map(CookRecipe::getRecipeName).orElse(null));
// item.setUptime(Optional.ofNullable(recipeMap.get(recipeId)).map(MenuRecipe::getUptime).orElse(null));
count = 0L;
if (Objects.nonNull(item.getRecipeDateDetail()) && !CollectionUtils.isEmpty(item.getRecipeDateList().get(0).getDetailList())) {
count = item.getRecipeDateList().get(0).getDetailList().stream().filter((x) -> {
return !CollectionUtils.isEmpty(x.getDishesList());
if (ObjectUtil.isNotEmpty(item.getDetail()) && ObjectUtil.isNotEmpty(item.getDetail().getDetailList())) {
count = item.getDetail().getDetailList().stream().filter((x) -> {
return ObjectUtil.isNotEmpty(x.getDishesList());
}).flatMap((x) -> {
return x.getDishesList().stream();
}).map(CookRecipeDishesVO::getDishesId).distinct().count();

View File

@ -0,0 +1,35 @@
package com.bonus.canteen.core.cook.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDateTime;
@Data
public class AllocRecipeStallVO {
@ApiModelProperty("区域id")
private Long areaId;
@ApiModelProperty("当前区域名称")
private String areaName;
@ApiModelProperty("食堂id")
private Long canteenId;
@ApiModelProperty("食堂名称")
private String canteenName;
@ApiModelProperty("档口id")
private Long stallId;
@ApiModelProperty("档口名称")
private String stallName;
@ApiModelProperty("餐线类型")
private Integer mealLineType;
@ApiModelProperty("餐线id")
private Long mealLineId;
@ApiModelProperty("餐线名称")
private String mealLineName;
@ApiModelProperty("菜谱id")
private Long recipeId;
@ApiModelProperty("菜谱名称")
private String recipeName;
private Long DishesCount;
private CookRecipeDateVO detail;
private LocalDateTime uptime;
}

View File

@ -49,6 +49,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</collection>
</resultMap>
<!-- 获取指定日期菜谱详情 -->
<resultMap id="cookRecipeDateVO" type="com.bonus.canteen.core.cook.vo.CookRecipeDateVO">
<result property="day" column="apply_date"/>
<result property="recipeId" column="recipe_id"/>
<collection property="detailList" ofType="com.bonus.canteen.core.cook.vo.CookRecipeDetailVO">
<result property="mealtimeType" column="mealtime_type"/>
<result property="recipeDetailId" column="recipe_detail_id"/>
<collection property="dishesList" ofType="com.bonus.canteen.core.cook.vo.CookRecipeDishesVO">
<result property="dishesId" column="dishes_id"/>
<result property="dishesName" column="dishes_name"/>
<result property="dishesId" column="dishesId"/>
<result property="price" column="price"/>
<result property="sizeType" column="size_type"/>
<result property="supplyNum" column="supply_num"/>
<result property="saleNum" column="sale_num"/>
<result property="remanentNum" column="remanent_num"/>
<result property="limitNum" column="limit_num"/>
<result property="salePrice" column="sale_price"/>
<result property="recommendFlag" column="recommend_flag"/>
<result property="typeId" column="type_id"/>
<result property="dishesTypeName" column="dishes_type_name"/>
<result property="salesMode" column="sales_mode"/>
<result property="canteenName" column="canteen_name"/>
<result property="unitPrice" column="unit_price"/>
<result property="mealType" column="meal_type"/>
<result property="materialCost" column="material_cost"/>
</collection>
</collection>
</resultMap>
<sql id="selectCookRecipeVo">
select cr.recipe_id, cr.recipe_name, cr.recipe_type, cr.stall_id, cr.canteen_id, cr.plan_id, cr.effect_date,
cr.expire_date, cr.create_by, cr.create_time, cr.update_by, cr.update_time, cr.del_flag,
@ -375,7 +405,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and del_flag = 0
</select>
<select id="selectCookRecipeListV2" resultType="com.bonus.canteen.core.cook.vo.CookRecipeVO">
<select id="selectCookRecipeListV2" resultType="com.bonus.canteen.core.cook.vo.AllocRecipeStallVO">
SELECT
t3.area_id, t3.area_name, t2.canteen_id, t2.canteen_name, t1.stall_id, t1.stall_name
FROM
@ -418,7 +448,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectRecipeByStallIdsAndBindType"
resultType="com.bonus.canteen.core.cook.vo.StallAndRecipeBindVO">
resultType="com.bonus.canteen.core.cook.dto.StallAndRecipeBindDto">
select
crba.recipe_id,
cr.stall_id,
@ -434,7 +464,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
</select>
<select id="selectTmpBetweenDateDetailList" resultMap="cookRecipeDetailVO">
<select id="selectTmpBetweenDateDetailList" resultMap="cookRecipeDateVO">
select mrd.mealtime_type,
mrd.recipe_id,
mrd.recipe_detail_id,