菜谱列表
This commit is contained in:
parent
b67efb60e9
commit
cd5e7096bb
|
|
@ -45,4 +45,6 @@ public class DeviceDTO {
|
|||
private String createBy;
|
||||
@ApiModelProperty("更新人")
|
||||
private String updateBy;
|
||||
@ApiModelProperty("设备类型")
|
||||
private String deviceType;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@ import com.bonus.canteen.core.common.utils.RedisUtil;
|
|||
import com.bonus.canteen.core.common.utils.TenantContextHolder;
|
||||
import com.bonus.canteen.core.menu.dto.MenuRecipeAddDTO;
|
||||
import com.bonus.canteen.core.menu.dto.MenuRecipeParamDTO;
|
||||
import com.bonus.canteen.core.menu.dto.MenuTypeDishesDTO;
|
||||
import com.bonus.canteen.core.menu.service.IMenuRecipeService;
|
||||
import com.bonus.canteen.core.menu.vo.MenuDishesTypeAllVO;
|
||||
import com.bonus.canteen.core.menu.vo.MenuRecipeDetailDateVO;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.houqin.constant.GlobalConstants;
|
||||
|
|
@ -85,4 +87,23 @@ public class MenuRecipeController extends BaseController {
|
|||
this.menuRecipeService.deleteRecipeById(dto.getRecipeId());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PostMapping({"getDishesCategoryList"})
|
||||
@ApiOperation("获取类别分类菜品")
|
||||
public AjaxResult getDishesCategoryList(@RequestBody @Valid MenuTypeDishesDTO dto) {
|
||||
return AjaxResult.success(this.menuRecipeService.getDishesCategoryList(dto));
|
||||
}
|
||||
|
||||
@PostMapping({"getAllDishCategories"})
|
||||
@ApiOperation("获取所有菜品类别")
|
||||
public AjaxResult getAllDishCategories() {
|
||||
List<MenuDishesTypeAllVO> resultList = this.menuRecipeService.getAllDishCategories();
|
||||
return AjaxResult.success(resultList);
|
||||
}
|
||||
|
||||
@PostMapping({"/getDetailByDate"})
|
||||
@ApiOperation("获取指定日期菜谱计划菜品详情")
|
||||
public List<MenuRecipeDetailDateVO> getDetailByDate(@RequestBody MenuRecipeParamDTO dto) {
|
||||
return this.menuRecipeService.getDetailByDate(dto);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -26,10 +26,10 @@ public class MenuRecipe {
|
|||
private Long canteenId;
|
||||
@ApiModelProperty("档口id")
|
||||
private Long stallId;
|
||||
@ApiModelProperty("适用人员范围")
|
||||
private Long effId;
|
||||
@ApiModelProperty("删除标识")
|
||||
private Integer delFlag;
|
||||
// @ApiModelProperty("适用人员范围")
|
||||
// private Long effId;
|
||||
// @ApiModelProperty("删除标识")
|
||||
// private Integer delFlag;
|
||||
@ApiModelProperty("乐观锁")
|
||||
private Integer revision;
|
||||
@ApiModelProperty("创建人")
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import java.util.Date;
|
|||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.bonus.common.core.annotation.Excel;
|
||||
|
|
@ -25,6 +26,7 @@ import com.bonus.common.core.web.domain.BaseEntity;
|
|||
|
||||
@Data
|
||||
@ToString
|
||||
@TableName("menu_recipe_detail")
|
||||
public class MenuRecipeDetail{
|
||||
private static final long serialVersionUID = 1L;
|
||||
@TableId
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import lombok.Data;
|
|||
import lombok.ToString;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
@Data
|
||||
@ToString
|
||||
|
|
@ -26,5 +28,6 @@ public class MenuRecipeParamDTO {
|
|||
private Integer recipeType;
|
||||
@ApiModelProperty("发布日期")
|
||||
private Integer applyWeek;
|
||||
|
||||
@ApiModelProperty("发布日期")
|
||||
private LocalDate applyDate;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,110 @@
|
|||
package com.bonus.canteen.core.menu.dto;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
public class MenuTypeDishesDTO implements Serializable {
|
||||
@ApiModelProperty("菜品类型")
|
||||
private Long typeId;
|
||||
@ApiModelProperty("区域id")
|
||||
private List<Long> areaIds;
|
||||
@ApiModelProperty("食堂id")
|
||||
private List<Long> canteenIds;
|
||||
@ApiModelProperty("档口id")
|
||||
private List<Long> stallIds;
|
||||
@ApiModelProperty("区域id")
|
||||
private Long areaId;
|
||||
@ApiModelProperty("食堂id")
|
||||
private Long canteenId;
|
||||
@ApiModelProperty("档口id")
|
||||
private Long stallId;
|
||||
@ApiModelProperty("菜品名称")
|
||||
private String dishesName;
|
||||
private String pinyinInitials;
|
||||
private Integer salesMode;
|
||||
|
||||
public String getDishesName() {
|
||||
return CharSequenceUtil.isBlank(this.dishesName) ? this.dishesName : "%" + this.dishesName + "%";
|
||||
}
|
||||
|
||||
public String getPinyinInitials() {
|
||||
return CharSequenceUtil.isBlank(this.dishesName) ? this.dishesName : "%" + this.dishesName.toUpperCase() + "%";
|
||||
}
|
||||
|
||||
|
||||
public Long getTypeId() {
|
||||
return this.typeId;
|
||||
}
|
||||
|
||||
public List<Long> getAreaIds() {
|
||||
return this.areaIds;
|
||||
}
|
||||
|
||||
public List<Long> getCanteenIds() {
|
||||
return this.canteenIds;
|
||||
}
|
||||
|
||||
public List<Long> getStallIds() {
|
||||
return this.stallIds;
|
||||
}
|
||||
|
||||
public Long getAreaId() {
|
||||
return this.areaId;
|
||||
}
|
||||
|
||||
public Long getCanteenId() {
|
||||
return this.canteenId;
|
||||
}
|
||||
|
||||
public Long getStallId() {
|
||||
return this.stallId;
|
||||
}
|
||||
|
||||
public Integer getSalesMode() {
|
||||
return this.salesMode;
|
||||
}
|
||||
|
||||
public void setTypeId(final Long typeId) {
|
||||
this.typeId = typeId;
|
||||
}
|
||||
|
||||
public void setAreaIds(final List<Long> areaIds) {
|
||||
this.areaIds = areaIds;
|
||||
}
|
||||
|
||||
public void setCanteenIds(final List<Long> canteenIds) {
|
||||
this.canteenIds = canteenIds;
|
||||
}
|
||||
|
||||
public void setStallIds(final List<Long> stallIds) {
|
||||
this.stallIds = stallIds;
|
||||
}
|
||||
|
||||
public void setAreaId(final Long areaId) {
|
||||
this.areaId = areaId;
|
||||
}
|
||||
|
||||
public void setCanteenId(final Long canteenId) {
|
||||
this.canteenId = canteenId;
|
||||
}
|
||||
|
||||
public void setStallId(final Long stallId) {
|
||||
this.stallId = stallId;
|
||||
}
|
||||
|
||||
public void setDishesName(final String dishesName) {
|
||||
this.dishesName = dishesName;
|
||||
}
|
||||
|
||||
public void setPinyinInitials(final String pinyinInitials) {
|
||||
this.pinyinInitials = pinyinInitials;
|
||||
}
|
||||
|
||||
public void setSalesMode(final Integer salesMode) {
|
||||
this.salesMode = salesMode;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -4,17 +4,17 @@ import java.time.LocalDate;
|
|||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.bonus.canteen.core.menu.domain.MenuAppRecipe;
|
||||
import com.bonus.canteen.core.menu.domain.MenuRecipe;
|
||||
import com.bonus.canteen.core.menu.domain.MenuRecipeDetail;
|
||||
import com.bonus.canteen.core.menu.domain.MenuRecipeDishes;
|
||||
import com.bonus.canteen.core.menu.domain.*;
|
||||
import com.bonus.canteen.core.menu.dto.*;
|
||||
import com.bonus.canteen.core.menu.model.MenuBaseModel;
|
||||
import com.bonus.canteen.core.menu.vo.MenuRecipeDataVO;
|
||||
import com.bonus.canteen.core.menu.vo.MenuRecipeDetailDateVO;
|
||||
import com.bonus.canteen.core.menu.vo.MenuRecipeV2VO;
|
||||
import com.bonus.canteen.core.menu.model.MenuDishesCostModel;
|
||||
import com.bonus.canteen.core.menu.vo.*;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.springframework.beans.PropertyValues;
|
||||
|
||||
/**
|
||||
* 菜品计划信息Mapper接口
|
||||
|
|
@ -149,4 +149,18 @@ public interface MenuRecipeMapper extends BaseMapper<MenuRecipe> {
|
|||
List<Long> getDetailIdList(Long recipeId);
|
||||
|
||||
int selectMenuAppRecipeCount(Long recipeId);
|
||||
|
||||
List<MenuAllTypeDishesVO> selectTypeDishesList(MenuTypeDishesDTO dto);
|
||||
|
||||
@Select({"select base_dishes_id, material_cost from menu_dishes ${ew.customSqlSegment}"})
|
||||
List<MenuDishesCostModel> selectMaterialCostList(@Param("ew") Wrapper<MenuDishes> wrapper);
|
||||
@Select({"select type_id, type_name, area_id from menu_dishes_type ${ew.customSqlSegment}"})
|
||||
List<MenuDishesTypeAllVO> getAllDishCategories(@Param("ew") Wrapper<MenuDishesType> wrapper);
|
||||
|
||||
List<MenuRecipeDetailDateVO> selectDateDetailList(@Param("recipeId") Long recipeId, @Param("applyDate") LocalDate applyDate);
|
||||
@Select({"select * from menu_recipe_detail ${ew.customSqlSegment}"})
|
||||
List<MenuRecipeDetail> selectMenuRecipeDetailList(@Param("ew") Wrapper<MenuRecipeDetail> wrapper);
|
||||
@Select({"select * from menu_recipe_dishes ${ew.customSqlSegment}"})
|
||||
List<MenuRecipeDishes> selectMenuRecipeDishList(@Param("ew") Wrapper<MenuRecipeDishes> wrapper);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
package com.bonus.canteen.core.menu.model;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class MenuDishesCostModel {
|
||||
private Long baseDishesId;
|
||||
private Integer materialCost;
|
||||
|
||||
public Integer getMaterialCost() {
|
||||
return (Integer)Optional.ofNullable(this.materialCost).orElse(0);
|
||||
}
|
||||
|
||||
public Long getBaseDishesId() {
|
||||
return this.baseDishesId;
|
||||
}
|
||||
|
||||
public void setBaseDishesId(final Long baseDishesId) {
|
||||
this.baseDishesId = baseDishesId;
|
||||
}
|
||||
|
||||
public void setMaterialCost(final Integer materialCost) {
|
||||
this.materialCost = materialCost;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +1,14 @@
|
|||
package com.bonus.canteen.core.menu.service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bonus.canteen.core.menu.domain.MenuRecipe;
|
||||
import com.bonus.canteen.core.menu.dto.MenuRecipeAddDTO;
|
||||
import com.bonus.canteen.core.menu.dto.MenuRecipeParamDTO;
|
||||
import com.bonus.canteen.core.menu.dto.MenuTypeDishesDTO;
|
||||
import com.bonus.canteen.core.menu.vo.MenuDishesTypeAllVO;
|
||||
import com.bonus.canteen.core.menu.vo.MenuRecipeDetailDateVO;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
|
||||
|
|
@ -30,4 +33,12 @@ public interface IMenuRecipeService extends IService<MenuRecipe> {
|
|||
List<MenuRecipeDetailDateVO> getDetail(MenuRecipeParamDTO dto);
|
||||
|
||||
void deleteRecipeById(Long id);
|
||||
|
||||
AjaxResult getDishesCategoryList(@Valid MenuTypeDishesDTO dto);
|
||||
|
||||
List<MenuDishesTypeAllVO> getAllDishCategories();
|
||||
|
||||
List<MenuRecipeDetailDateVO> getDetailByDate(MenuRecipeParamDTO dto);
|
||||
|
||||
void generateRecipe(Long recipeId, LocalDate applyDate);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.bonus.canteen.core.menu.service.impl;
|
|||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -69,7 +70,7 @@ public class MenuDishesServiceImpl implements IMenuDishesService {
|
|||
*/
|
||||
@Override
|
||||
public int insertMenuDishes(MenuDishes menuDishes) {
|
||||
menuDishes.setCreateTime(DateUtils.getNowDate());
|
||||
menuDishes.setCreateTime(LocalDateTime.now());
|
||||
try {
|
||||
return menuDishesMapper.insertMenuDishes(menuDishes);
|
||||
} catch (Exception e) {
|
||||
|
|
@ -85,7 +86,7 @@ public class MenuDishesServiceImpl implements IMenuDishesService {
|
|||
*/
|
||||
@Override
|
||||
public int updateMenuDishes(MenuDishes menuDishes) {
|
||||
menuDishes.setUpdateTime(DateUtils.getNowDate());
|
||||
menuDishes.setUpdateTime(LocalDateTime.now());
|
||||
try {
|
||||
return menuDishesMapper.updateMenuDishes(menuDishes);
|
||||
} catch (Exception e) {
|
||||
|
|
|
|||
|
|
@ -12,30 +12,26 @@ import java.util.stream.Collectors;
|
|||
import java.util.stream.Stream;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bonus.canteen.core.common.utils.MqUtil;
|
||||
import com.bonus.canteen.core.common.utils.RedisUtil;
|
||||
import com.bonus.canteen.core.common.utils.TenantContextHolder;
|
||||
import com.bonus.canteen.core.menu.domain.MenuAppRecipe;
|
||||
import com.bonus.canteen.core.menu.domain.MenuRecipeDetail;
|
||||
import com.bonus.canteen.core.menu.domain.MenuRecipeDishes;
|
||||
import com.bonus.canteen.core.menu.domain.*;
|
||||
import com.bonus.canteen.core.menu.dto.*;
|
||||
import com.bonus.canteen.core.menu.enums.MenuRecipeSortEnum;
|
||||
import com.bonus.canteen.core.menu.mapper.MenuRecipeDishesMapper;
|
||||
import com.bonus.canteen.core.menu.model.MenuBaseDishesModel;
|
||||
import com.bonus.canteen.core.menu.model.MenuBaseModel;
|
||||
import com.bonus.canteen.core.menu.model.MenuDishesCostModel;
|
||||
import com.bonus.canteen.core.menu.service.IMenuRecipeService;
|
||||
import com.bonus.canteen.core.menu.vo.MenuRecipeDataVO;
|
||||
import com.bonus.canteen.core.menu.vo.MenuRecipeDetailDateVO;
|
||||
import com.bonus.canteen.core.menu.vo.MenuRecipeV2VO;
|
||||
import com.bonus.canteen.core.menu.vo.*;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.core.utils.DateUtils;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.houqin.constant.DelFlagEnum;
|
||||
import com.bonus.common.houqin.i18n.I18n;
|
||||
|
|
@ -46,7 +42,6 @@ import com.google.common.collect.Lists;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.bonus.canteen.core.menu.mapper.MenuRecipeMapper;
|
||||
import com.bonus.canteen.core.menu.domain.MenuRecipe;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
|
|
@ -177,7 +172,6 @@ public class MenuRecipeServiceImpl extends ServiceImpl<MenuRecipeMapper, MenuRec
|
|||
this.menuRecipeMapper.deleteMenuRecipeDetailByIds(detailIdList);
|
||||
this.menuRecipeMapper.deleteMenuRecipeDishesByIds(detailIdList);
|
||||
}
|
||||
//TODO 删除缓存 -- 发送mq
|
||||
String redisKey = String.format("yst:%s:recipe:%s:detail:%s", TenantContextHolder.getTenantId(), recipeId, "*");
|
||||
RedisUtil.deleteByPattern(redisKey);
|
||||
MqUtil.sendDataChange(recipeId, LeMqConstant.DataChangeType.REMOVE, LeMqConstant.Topic.DATA_CHANGE_RECIPE);
|
||||
|
|
@ -185,6 +179,140 @@ public class MenuRecipeServiceImpl extends ServiceImpl<MenuRecipeMapper, MenuRec
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult getDishesCategoryList(MenuTypeDishesDTO dto) {
|
||||
List<MenuAllTypeDishesVO> resultList = this.baseMapper.selectTypeDishesList(dto);
|
||||
if (CollUtil.isEmpty(resultList)) {
|
||||
return AjaxResult.success(new ArrayList<>());
|
||||
} else {
|
||||
List<MenuDishesCostModel> costList = this.baseMapper.selectMaterialCostList(new QueryWrapper<MenuDishes>()
|
||||
.in("base_dishes_id", resultList.stream()
|
||||
.map(MenuAllTypeDishesVO::getDishesId)
|
||||
.collect(Collectors.toList()))
|
||||
.eq("size_json", "{\"sizeType\":\"小份\"}"));
|
||||
if (CollUtil.isNotEmpty(costList)) {
|
||||
Map<Long, Integer> mostMap = costList.stream().collect(Collectors.toMap(MenuDishesCostModel::getBaseDishesId, MenuDishesCostModel::getMaterialCost));
|
||||
resultList.forEach((x) -> x.setLittleMaterialCost((Integer) mostMap.get(x.getDishesId())));
|
||||
}
|
||||
|
||||
return AjaxResult.success(resultList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MenuDishesTypeAllVO> getAllDishCategories() {
|
||||
return this.baseMapper.getAllDishCategories(Wrappers.lambdaQuery(MenuDishesType.class)
|
||||
.eq(MenuDishesType::getDelFlag, DelFlagEnum.DEL_FALSE.key())
|
||||
.orderByAsc(MenuDishesType::getDefaultFlag)
|
||||
.orderByDesc(MenuDishesType::getCrtime));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MenuRecipeDetailDateVO> getDetailByDate(MenuRecipeParamDTO dto) {
|
||||
this.generateRecipe(dto.getRecipeId(), dto.getApplyDate());
|
||||
List<MenuRecipeDetailDateVO> menuRecipeDetailDateVOS = this.menuRecipeMapper.selectDateDetailList(dto.getRecipeId(), dto.getApplyDate());
|
||||
return menuRecipeDetailDateVOS.stream().sorted(Comparator.comparing(MenuRecipeDetailDateVO::getMealtimeType)).collect(Collectors.toList());
|
||||
}
|
||||
@Override
|
||||
public void generateRecipe(Long recipeId, LocalDate applyDate) {
|
||||
if (!ObjectUtil.isEmpty(recipeId) && !ObjectUtil.isEmpty(applyDate)) {
|
||||
this.generateRecipe(Collections.singletonList(recipeId), applyDate);
|
||||
}
|
||||
}
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public synchronized void generateRecipe(List<Long> recipeIdList, LocalDate applyDate) {
|
||||
if (!ObjectUtil.isEmpty(recipeIdList) && !ObjectUtil.isEmpty(applyDate)) {
|
||||
recipeIdList = new ArrayList<>(recipeIdList);
|
||||
Map<Long, Long> recipeDetailContMap = this.menuRecipeMapper.selectMenuRecipeDetailList(new QueryWrapper<MenuRecipeDetail>()
|
||||
.eq("apply_date", applyDate)
|
||||
.in("recipe_id", recipeIdList))
|
||||
.stream().collect(Collectors.groupingBy(MenuRecipeDetail::getRecipeId, Collectors.counting()));
|
||||
recipeIdList.removeAll(recipeDetailContMap.keySet());
|
||||
if (!ObjectUtil.isEmpty(recipeIdList)) {
|
||||
List<MenuRecipe> menuRecipes = this.list(Wrappers.lambdaQuery(MenuRecipe.class).in(MenuRecipe::getRecipeType, new Object[]{2, 3})
|
||||
.apply(CollUtil.isNotEmpty(recipeIdList), "recipe_id IN (" + recipeIdList.stream().map(String::valueOf).collect(Collectors.joining(", ")) + ")"));
|
||||
if (!ObjectUtil.isEmpty(menuRecipes)) {
|
||||
Map<Long, MenuRecipe> recipeMap = menuRecipes.stream().collect(Collectors.toMap(MenuRecipe::getRecipeId, Function.identity()));
|
||||
List<MenuRecipeDetail> menuRecipeDetails = this.menuRecipeMapper.selectMenuRecipeDetailList(
|
||||
new QueryWrapper<MenuRecipeDetail>().eq("detail_type", 1)
|
||||
.apply(CollUtil.isNotEmpty(recipeIdList), "recipe_id IN (" + recipeIdList.stream().map(String::valueOf).collect(Collectors.joining(", ")) + ")"));
|
||||
Map<Long, Integer> recipeTypeMap = menuRecipes.stream().collect(Collectors.toMap(MenuRecipe::getRecipeId, MenuRecipe::getRecipeType));
|
||||
menuRecipeDetails = this.filterMenuRecipeDetails(recipeTypeMap, menuRecipeDetails, applyDate);
|
||||
if (!ObjectUtil.isEmpty(menuRecipeDetails)) {
|
||||
Map<Long, List<MenuRecipeDetail>> detailMap = menuRecipeDetails.stream().collect(Collectors.groupingBy(MenuRecipeDetail::getRecipeId));
|
||||
List<Long> detailIds = menuRecipeDetails.stream().map(MenuRecipeDetail::getDetailId).collect(Collectors.toList());
|
||||
Map<Long, List<MenuRecipeDishes>> recipeDishes = this.menuRecipeMapper.selectMenuRecipeDishList(new QueryWrapper<MenuRecipeDishes>()
|
||||
.in("detail_id", detailIds)).stream().collect(Collectors.groupingBy(MenuRecipeDishes::getDetailId));
|
||||
List<MenuRecipeDetail> recipeDetailV2List = Lists.newArrayList();
|
||||
List<MenuRecipeDishes> recipeDishesV2List = Lists.newArrayList();
|
||||
Iterator var13 = recipeMap.keySet().iterator();
|
||||
|
||||
label59:
|
||||
while (true) {
|
||||
Long recipeId;
|
||||
Integer type;
|
||||
List menuRecipeDetail;
|
||||
do {
|
||||
if (!var13.hasNext()) {
|
||||
this.menuRecipeMapper.insertMenuDetails(recipeDetailV2List);
|
||||
if (ObjectUtil.isNotEmpty(recipeDishesV2List)) {
|
||||
this.menuRecipeMapper.insertMenuDishes(recipeDishesV2List);
|
||||
}
|
||||
return;
|
||||
}
|
||||
recipeId = (Long) var13.next();
|
||||
type = (Integer) recipeTypeMap.get(recipeId);
|
||||
menuRecipeDetail = (List) detailMap.get(recipeId);
|
||||
} while (!ObjectUtil.isNotEmpty(menuRecipeDetail));
|
||||
Iterator var17 = menuRecipeDetail.iterator();
|
||||
while (true) {
|
||||
Long detailId;
|
||||
List dishes;
|
||||
do {
|
||||
if (!var17.hasNext()) {
|
||||
continue label59;
|
||||
}
|
||||
MenuRecipeDetail recipeDetail = (MenuRecipeDetail) var17.next();
|
||||
MenuRecipeDetail detailItem = new MenuRecipeDetail();
|
||||
detailId = Id.next();
|
||||
detailItem.setDetailId(detailId);
|
||||
detailItem.setRecipeId(recipeId);
|
||||
if (ObjectUtil.equal(type, 3)) {
|
||||
detailItem.setApplyWeek(applyDate.getDayOfWeek().getValue());
|
||||
}
|
||||
detailItem.setApplyDate(applyDate);
|
||||
detailItem.setMealtimeType(recipeDetail.getMealtimeType());
|
||||
detailItem.setCreateBy("");
|
||||
detailItem.setDetailType(2);
|
||||
recipeDetailV2List.add(detailItem);
|
||||
dishes = (List) recipeDishes.get(recipeDetail.getDetailId());
|
||||
} while (!ObjectUtil.isNotEmpty(dishes));
|
||||
Iterator var22 = dishes.iterator();
|
||||
while (var22.hasNext()) {
|
||||
MenuRecipeDishes dish = (MenuRecipeDishes) var22.next();
|
||||
MenuRecipeDishes dishesItem = (MenuRecipeDishes) BeanUtil.copyProperties(dish, MenuRecipeDishes.class, new String[0]);
|
||||
dishesItem.setDetailId(detailId);
|
||||
dishesItem.setId((Long) null);
|
||||
recipeDishesV2List.add(dishesItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public List<MenuRecipeDetail> filterMenuRecipeDetails(Map<Long, Integer> recipeTypeMap, List<MenuRecipeDetail> menuRecipeDetails, LocalDate applyDate) {
|
||||
return menuRecipeDetails.stream().filter((item) -> {
|
||||
Long recipeId = item.getRecipeId();
|
||||
Integer type = (Integer) recipeTypeMap.get(recipeId);
|
||||
if (type == 3) {
|
||||
return ObjectUtil.equal(item.getApplyWeek(), applyDate.getDayOfWeek().getValue());
|
||||
} else {
|
||||
return type == 2;
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
public void processResult(RecipeProcessResult result) {
|
||||
List<Long> detailIds = result.getTemplateDetailIds();
|
||||
MenuRecipe menuRecipe = result.getMenuRecipe();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,188 @@
|
|||
package com.bonus.canteen.core.menu.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
@ApiModel("菜品详情")
|
||||
public class MenuAllTypeDishesVO {
|
||||
@ApiModelProperty("菜品id")
|
||||
private Long dishesId;
|
||||
@ApiModelProperty("菜品名称")
|
||||
private String dishesName;
|
||||
@ApiModelProperty("菜品价格")
|
||||
private Integer price;
|
||||
@ApiModelProperty("食堂名称")
|
||||
private String canteenName;
|
||||
@ApiModelProperty("档口名称")
|
||||
private String stallName;
|
||||
@ApiModelProperty("区域名称")
|
||||
private String areaName;
|
||||
@ApiModelProperty("销售方式(1按份,2称重)")
|
||||
private Integer salesMode;
|
||||
@ApiModelProperty("规格类型(1-标准,2-大小份)")
|
||||
private Long sizeType;
|
||||
@ApiModelProperty("称重单位多少克(默认1kg)")
|
||||
private Integer unitPrice;
|
||||
@ApiModelProperty("大份单价")
|
||||
private Integer largePrice;
|
||||
@ApiModelProperty("小份单价")
|
||||
private Integer littlePrice;
|
||||
@ApiModelProperty("成本价")
|
||||
private Integer materialCost;
|
||||
@ApiModelProperty("成本价-小份")
|
||||
private Integer littleMaterialCost;
|
||||
@ApiModelProperty("菜品编号")
|
||||
private String dishesNum;
|
||||
@ApiModelProperty("菜品类型")
|
||||
private Integer mealType;
|
||||
@ApiModelProperty("类别名称")
|
||||
private String typeName;
|
||||
@ApiModelProperty("类别id")
|
||||
private Long typeId;
|
||||
@ApiModelProperty("是否是公共菜品(1-是,2-否,)")
|
||||
private Integer publicDishes;
|
||||
|
||||
public Long getDishesId() {
|
||||
return this.dishesId;
|
||||
}
|
||||
|
||||
public String getDishesName() {
|
||||
return this.dishesName;
|
||||
}
|
||||
|
||||
public Integer getPrice() {
|
||||
return this.price;
|
||||
}
|
||||
|
||||
public String getCanteenName() {
|
||||
return this.canteenName;
|
||||
}
|
||||
|
||||
public String getStallName() {
|
||||
return this.stallName;
|
||||
}
|
||||
|
||||
public String getAreaName() {
|
||||
return this.areaName;
|
||||
}
|
||||
|
||||
public Integer getSalesMode() {
|
||||
return this.salesMode;
|
||||
}
|
||||
|
||||
public Long getSizeType() {
|
||||
return this.sizeType;
|
||||
}
|
||||
|
||||
public Integer getUnitPrice() {
|
||||
return this.unitPrice;
|
||||
}
|
||||
|
||||
public Integer getLargePrice() {
|
||||
return this.largePrice;
|
||||
}
|
||||
|
||||
public Integer getLittlePrice() {
|
||||
return this.littlePrice;
|
||||
}
|
||||
|
||||
public Integer getMaterialCost() {
|
||||
return this.materialCost;
|
||||
}
|
||||
|
||||
public Integer getLittleMaterialCost() {
|
||||
return this.littleMaterialCost;
|
||||
}
|
||||
|
||||
public String getDishesNum() {
|
||||
return this.dishesNum;
|
||||
}
|
||||
|
||||
public Integer getMealType() {
|
||||
return this.mealType;
|
||||
}
|
||||
|
||||
public String getTypeName() {
|
||||
return this.typeName;
|
||||
}
|
||||
|
||||
public Long getTypeId() {
|
||||
return this.typeId;
|
||||
}
|
||||
|
||||
public Integer getPublicDishes() {
|
||||
return this.publicDishes;
|
||||
}
|
||||
|
||||
public void setDishesId(final Long dishesId) {
|
||||
this.dishesId = dishesId;
|
||||
}
|
||||
|
||||
public void setDishesName(final String dishesName) {
|
||||
this.dishesName = dishesName;
|
||||
}
|
||||
|
||||
public void setPrice(final Integer price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public void setCanteenName(final String canteenName) {
|
||||
this.canteenName = canteenName;
|
||||
}
|
||||
|
||||
public void setStallName(final String stallName) {
|
||||
this.stallName = stallName;
|
||||
}
|
||||
|
||||
public void setAreaName(final String areaName) {
|
||||
this.areaName = areaName;
|
||||
}
|
||||
|
||||
public void setSalesMode(final Integer salesMode) {
|
||||
this.salesMode = salesMode;
|
||||
}
|
||||
|
||||
public void setSizeType(final Long sizeType) {
|
||||
this.sizeType = sizeType;
|
||||
}
|
||||
|
||||
public void setUnitPrice(final Integer unitPrice) {
|
||||
this.unitPrice = unitPrice;
|
||||
}
|
||||
|
||||
public void setLargePrice(final Integer largePrice) {
|
||||
this.largePrice = largePrice;
|
||||
}
|
||||
|
||||
public void setLittlePrice(final Integer littlePrice) {
|
||||
this.littlePrice = littlePrice;
|
||||
}
|
||||
|
||||
public void setMaterialCost(final Integer materialCost) {
|
||||
this.materialCost = materialCost;
|
||||
}
|
||||
|
||||
public void setLittleMaterialCost(final Integer littleMaterialCost) {
|
||||
this.littleMaterialCost = littleMaterialCost;
|
||||
}
|
||||
|
||||
public void setDishesNum(final String dishesNum) {
|
||||
this.dishesNum = dishesNum;
|
||||
}
|
||||
|
||||
public void setMealType(final Integer mealType) {
|
||||
this.mealType = mealType;
|
||||
}
|
||||
|
||||
public void setTypeName(final String typeName) {
|
||||
this.typeName = typeName;
|
||||
}
|
||||
|
||||
public void setTypeId(final Long typeId) {
|
||||
this.typeId = typeId;
|
||||
}
|
||||
|
||||
public void setPublicDishes(final Integer publicDishes) {
|
||||
this.publicDishes = publicDishes;
|
||||
}
|
||||
}
|
||||
|
|
@ -5,9 +5,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<mapper namespace="com.bonus.canteen.core.device.mapper.DoubleScreenMachineMapper">
|
||||
<insert id="insertMachine" useGeneratedKeys="true" keyProperty="deviceId">
|
||||
insert into device_info(tenant_id,device_ip, device_mac, device_gateway, device_sn, device_name, device_num, device_pwd,
|
||||
device_addr, device_key)
|
||||
device_addr, device_key,device_type)
|
||||
values (#{tenantId},#{deviceIp}, #{deviceMac}, #{deviceGateway}, #{deviceSn}, #{deviceName}, #{deviceNum}, #{devicePwd},
|
||||
#{deviceAddr}, #{deviceKey})
|
||||
#{deviceAddr}, #{deviceKey},#{deviceType})
|
||||
</insert>
|
||||
<insert id="insertMachineBind">
|
||||
insert into device_bind(device_id,area_id,canteen_id,stall_id)
|
||||
|
|
|
|||
|
|
@ -389,6 +389,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
<select id="selectAppRecipeList" resultType="com.bonus.canteen.core.menu.domain.MenuAppRecipe">
|
||||
select
|
||||
DISTINCT
|
||||
recipe_id as recipeId,
|
||||
bind_type as bindType,
|
||||
meal_line_id as mealLineId,
|
||||
|
|
@ -396,8 +397,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
from menu_app_recipe
|
||||
where recipe_id = #{recipeId}
|
||||
</select>
|
||||
<select id="getDetail" resultType="com.bonus.canteen.core.menu.vo.MenuRecipeDetailDateVO">
|
||||
select mrd.mealtime_type,
|
||||
<select id="getDetail" resultMap="menuRecipeDetailDateVO">
|
||||
select DISTINCT
|
||||
mrd.mealtime_type,
|
||||
mrd.detail_id,
|
||||
mdb.base_dishes_id as dishes_id,
|
||||
mdb.dishes_name,
|
||||
|
|
@ -426,12 +428,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
left join menu_dishes_base mdb on md.base_dishes_id = mdb.base_dishes_id
|
||||
left join menu_dishes_type mdt on md.type_id = mdt.type_id
|
||||
where mrd.recipe_id = #{params.recipeId}
|
||||
<if test="params.applyWeek !=null ">
|
||||
<if test="params.applyWeek !=null and params.applyWeek != ''">
|
||||
and mrd.apply_week = #{params.applyWeek}
|
||||
</if>
|
||||
and mrd.detail_type = 1
|
||||
order by mrdd.sort_num
|
||||
</select>
|
||||
|
||||
<select id="getRecipeBindCount" resultType="java.lang.Integer">
|
||||
select DISTINCT
|
||||
count(device_id)
|
||||
|
|
@ -450,6 +453,133 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
from menu_app_recipe
|
||||
where recipe_id = #{recipeId}
|
||||
</select>
|
||||
<select id="selectTypeDishesList" resultType="com.bonus.canteen.core.menu.vo.MenuAllTypeDishesVO">
|
||||
select
|
||||
mdb.base_dishes_id as dishes_id,
|
||||
mdb.dishes_name,
|
||||
md.price,
|
||||
ac.canteen_name,
|
||||
ass.stall_name,
|
||||
aa.area_name,
|
||||
md.sales_mode,
|
||||
md.size_type,
|
||||
md.public_dishes,
|
||||
md.unit_price,
|
||||
md.little_price,
|
||||
md.large_price,
|
||||
md.material_cost,
|
||||
md.meal_type,
|
||||
md.type_id,
|
||||
mdt.type_name,
|
||||
md.dishes_num
|
||||
from
|
||||
menu_dishes_base mdb
|
||||
left join menu_dishes md on mdb.base_dishes_id = md.base_dishes_id
|
||||
and md.size_json != '{"sizeType":"小份"}'
|
||||
left join alloc_area aa on aa.area_id = md.area_id
|
||||
left join alloc_canteen ac on md.canteen_id = ac.canteen_id
|
||||
left join alloc_stall ass on ass.stall_id = md.shopstall_id
|
||||
left join menu_dishes_type mdt on md.type_id = mdt.type_id
|
||||
where
|
||||
1 =1
|
||||
<if test="typeId != null">
|
||||
and md.type_id = #{typeId}
|
||||
</if>
|
||||
<if test="canteenId != null and stallId != null and areaId != null">
|
||||
and(
|
||||
(md.canteen_id = #{canteenId} and md.shopstall_id = #{stallId})
|
||||
or (md.canteen_id = #{canteenId} and md.shopstall_id = -1)
|
||||
or (md.canteen_id = -1 and md.shopstall_id = -1 and md.area_id = #{areaId})
|
||||
or (md.canteen_id = -1 and md.shopstall_id = -1 and md.area_id = -1)
|
||||
)
|
||||
</if>
|
||||
<if test="areaIds != null and areaIds.size >0">
|
||||
and md.area_id in
|
||||
<foreach collection="areaIds" item="areaId" open="(" separator="," close=")">
|
||||
#{areaId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="canteenIds != null and canteenIds.size >0">
|
||||
and md.canteen_id in
|
||||
<foreach collection="canteenIds" item="canteenId" open="(" separator="," close=")">
|
||||
#{canteenId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="stallIds != null and stallIds.size >0">
|
||||
and md.shopstall_id in
|
||||
<foreach collection="stallIds" item="stallId" open="(" separator="," close=")">
|
||||
#{stallId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="dishesName != null and dishesName != ''">
|
||||
and (md.dishes_name like #{dishesName}
|
||||
or md.pinyin_full like #{dishesName}
|
||||
or md.pinyin_initials like #{dishesName})
|
||||
</if>
|
||||
<if test="salesMode != null">
|
||||
and md.sales_mode = #{salesMode}
|
||||
</if>
|
||||
</select>
|
||||
<resultMap id="menuRecipeDetailDateVO" type="com.bonus.canteen.core.menu.vo.MenuRecipeDetailDateVO">
|
||||
<result property="mealtimeType" column="mealtime_type"/>
|
||||
<result property="detailId" column="detail_id"/>
|
||||
<collection property="dishesList" ofType="com.bonus.canteen.core.menu.vo.MenuRecipeDetailDishesVO">
|
||||
<result property="id" column="id"/>
|
||||
<result property="dishesId" column="dishes_id"/>
|
||||
<result property="dishesName" column="dishes_name"/>
|
||||
<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="surplusNum" column="surplus_num"/>
|
||||
<result property="restrictNum" column="restrict_num"/>
|
||||
<result property="salePrice" column="sale_price"/>
|
||||
<result property="recommendFlag" column="recommend_flag"/>
|
||||
<result property="canteenName" column="canteen_name"/>
|
||||
<result property="salesMode" column="sales_mode"/>
|
||||
<result property="unitPrice" column="unit_price"/>
|
||||
<result property="mealType" column="meal_type"/>
|
||||
<result property="dishesNum" column="dishes_num"/>
|
||||
<result property="materialCost" column="material_cost"/>
|
||||
<result property="sortNum" column="sort_num"/>
|
||||
<result property="typeId" column="type_id"/>
|
||||
<result property="typeName" column="type_name"/>
|
||||
</collection>
|
||||
</resultMap>
|
||||
<!-- 获取指定日期菜谱详情 -->
|
||||
<select id="selectDateDetailList" resultMap="menuRecipeDetailDateVO">
|
||||
select mrd.mealtime_type,
|
||||
mrd.detail_id,
|
||||
mdb.base_dishes_id as dishes_id,
|
||||
mdb.dishes_name,
|
||||
mrdd.id,
|
||||
mrdd.price,
|
||||
mrdd.size_type,
|
||||
mrdd.supply_num,
|
||||
mrdd.sale_num,
|
||||
mrdd.surplus_num,
|
||||
mrdd.restrict_num,
|
||||
mrdd.sale_price,
|
||||
mrdd.recommend_flag,
|
||||
mrdd.sort_num,
|
||||
ac.canteen_name,
|
||||
md.sales_mode,
|
||||
md.unit_price,
|
||||
md.meal_type,
|
||||
md.dishes_num,
|
||||
md.type_id,
|
||||
mdt.type_name,
|
||||
md.material_cost
|
||||
from menu_recipe_detail mrd
|
||||
left join menu_recipe_dishes mrdd on mrd.detail_id = mrdd.detail_id
|
||||
left join menu_dishes md on mrdd.dishes_id = md.dishes_id
|
||||
left join alloc_canteen ac on md.canteen_id = ac.canteen_id
|
||||
left join menu_dishes_base mdb on md.base_dishes_id = mdb.base_dishes_id
|
||||
left join menu_dishes_type mdt on md.type_id = mdt.type_id
|
||||
where mrd.recipe_id = #{recipeId}
|
||||
and mrd.apply_date = #{applyDate}
|
||||
order by mrdd.sort_num
|
||||
</select>
|
||||
<insert id="insertMenuRecipe" parameterType="com.bonus.canteen.core.menu.domain.MenuRecipe" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into menu_recipe
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
|
|
@ -604,7 +734,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</trim>
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<update id="updateMenuRecipe" parameterType="com.bonus.canteen.core.menu.domain.MenuRecipe">
|
||||
update menu_recipe
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
|
|
|
|||
Loading…
Reference in New Issue