h5周菜谱
This commit is contained in:
parent
c2dea1ccb2
commit
0005d5861f
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
import com.bonus.canteen.core.cook.domain.CookRecipeDetail;
|
||||
import com.bonus.canteen.core.cook.vo.CookRecipeDetailIDVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
|
|
@ -77,4 +78,7 @@ public interface CookRecipeDetailMapper {
|
|||
|
||||
List<CookRecipeDetail> getByRecipeIdAndDatesAndIntervalId(@Param("recipeId") Long recipeId, @Param("dateList") Set<LocalDate> dateList, @Param("mealtimeType") Long mealtimeType);
|
||||
|
||||
List<CookRecipeDetail> getCookRecipeDetailsByApplyDateAndRecipeIds(@Param("recipeIdList") List<Long> recipeIdList);
|
||||
|
||||
List<CookRecipeDetail> getCookRecipeDetailsByDetailTypeAndRecipeIds(@Param("recipeIdList") List<Long> recipeIdList);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ public interface CookRecipeDishesMapper {
|
|||
*/
|
||||
public CookRecipeDishes selectCookRecipeDishesById(Long id);
|
||||
|
||||
public List<CookRecipeDishes> selectCookRecipeDishesByDetailIds(@Param("recipeDetailIds") List<Long> recipeDetailIds);
|
||||
|
||||
/**
|
||||
* 查询菜品计划菜品关联列表
|
||||
*
|
||||
|
|
|
|||
|
|
@ -39,6 +39,10 @@ public interface CookRecipeMapper {
|
|||
|
||||
public List<CookRecipe> selectRecipeListByRecipeIds(@Param("recipeIds") List<Long> recipeIds);
|
||||
|
||||
public List<CookRecipe> selectRecipeListByRecipeTypes();
|
||||
|
||||
public List<CookRecipe> selectRecipeListByRecipeTypesAndRecipeIds(@Param("recipeIds") List<Long> recipeIds);
|
||||
|
||||
public int getDishesCount4PointDates(Long recipeId);
|
||||
|
||||
public int getDishesCount4Recycle(Long recipeId);
|
||||
|
|
|
|||
|
|
@ -81,4 +81,6 @@ public interface ICookRecipeService {
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteCookRecipeByRecipeId(Long recipeId);
|
||||
|
||||
public void generateRecipe();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ 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;
|
||||
|
|
@ -123,60 +122,6 @@ public class CookRecipeServiceImpl implements ICookRecipeService {
|
|||
return list;
|
||||
}
|
||||
|
||||
// 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();
|
||||
|
|
@ -565,4 +510,106 @@ public class CookRecipeServiceImpl implements ICookRecipeService {
|
|||
public int deleteCookRecipeByRecipeId(Long recipeId) {
|
||||
return cookRecipeMapper.deleteCookRecipeByRecipeId(recipeId);
|
||||
}
|
||||
|
||||
@Transactional(
|
||||
rollbackFor = {Exception.class}
|
||||
)
|
||||
public void generateRecipe() {
|
||||
List<Long> recipeIds = cookRecipeMapper.selectRecipeListByRecipeTypes().stream().map(CookRecipe::getRecipeId).collect(Collectors.toList());
|
||||
for(int i = 0; i < 7; ++i) {
|
||||
this.generateRecipe(recipeIds, LocalDate.now().plusDays((long)i));
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(
|
||||
rollbackFor = {Exception.class}
|
||||
)
|
||||
public synchronized void generateRecipe(List<Long> inputRecipeIdList, LocalDate applyDate) {
|
||||
if (!ObjectUtil.isEmpty(inputRecipeIdList) && !ObjectUtil.isEmpty(applyDate)) {
|
||||
List<Long> recipeIdList = new ArrayList(inputRecipeIdList);
|
||||
List<CookRecipeDetail> cookRecipeDetails = cookRecipeDetailMapper.getCookRecipeDetailsByApplyDateAndRecipeIds(recipeIdList);
|
||||
Map<Long, Long> recipeDetailContMap = cookRecipeDetails.stream().collect(Collectors.groupingBy(CookRecipeDetail::getRecipeId, Collectors.counting()));
|
||||
recipeIdList.removeAll(recipeDetailContMap.keySet());
|
||||
if (!ObjectUtil.isEmpty(recipeIdList)) {
|
||||
List<CookRecipe> menuRecipes = cookRecipeMapper.selectRecipeListByRecipeTypesAndRecipeIds(recipeIdList);
|
||||
if (!ObjectUtil.isEmpty(menuRecipes)) {
|
||||
Map<Long, CookRecipe> recipeMap = (Map)menuRecipes.stream().collect(Collectors.toMap(CookRecipe::getRecipeId, Function.identity()));
|
||||
List<CookRecipeDetail> menuRecipeDetails = cookRecipeDetailMapper.getCookRecipeDetailsByDetailTypeAndRecipeIds(recipeIdList);
|
||||
Map<Long, Integer> recipeTypeMap = (Map)menuRecipes.stream().collect(Collectors.toMap(CookRecipe::getRecipeId, CookRecipe::getRecipeType));
|
||||
menuRecipeDetails = this.filterCookRecipeDetails(recipeTypeMap, menuRecipeDetails, applyDate);
|
||||
if (!ObjectUtil.isEmpty(menuRecipeDetails)) {
|
||||
Map<Long, List<CookRecipeDetail>> detailMap = (Map)menuRecipeDetails.stream().collect(Collectors.groupingBy(CookRecipeDetail::getRecipeId));
|
||||
List<Long> detailIds = (List)menuRecipeDetails.stream().map(CookRecipeDetail::getRecipeDetailId).collect(Collectors.toList());
|
||||
List<CookRecipeDishes> foundDishes = cookRecipeDishesMapper.selectCookRecipeDishesByDetailIds(detailIds);
|
||||
Map<Long, List<CookRecipeDishes>> recipeDishes = (Map)foundDishes.stream().collect(Collectors.groupingBy(CookRecipeDishes::getRecipeDetailId));
|
||||
List<CookRecipeDetail> recipeDetailV2List = Lists.newArrayList();
|
||||
List<CookRecipeDishes> recipeDishesV2List = Lists.newArrayList();
|
||||
Iterator var13 = recipeMap.keySet().iterator();
|
||||
// label59:
|
||||
// while(true) {
|
||||
// Long recipeId;
|
||||
// Integer type;
|
||||
// List menuRecipeDetail;
|
||||
// do {
|
||||
// if (!var13.hasNext()) {
|
||||
// this.cookRecipeDetailMapper.insert(recipeDetailV2List);
|
||||
// if (ObjectUtil.isNotEmpty(recipeDishesV2List)) {
|
||||
// this.cookRecipeDishesService.saveBatch(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;
|
||||
// }
|
||||
// CookRecipeDetail recipeDetail = (CookRecipeDetail)var17.next();
|
||||
// CookRecipeDetail detailItem = new CookRecipeDetail();
|
||||
// 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()) {
|
||||
// CookRecipeDishes dish = (CookRecipeDishes)var22.next();
|
||||
// CookRecipeDishes dishesItem = (CookRecipeDishes) BeanUtil.copyProperties(dish, CookRecipeDishes.class, new String[0]);
|
||||
// dishesItem.setDetailId(detailId);
|
||||
// dishesItem.setId((Long)null);
|
||||
// recipeDishesV2List.add(dishesItem);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<CookRecipeDetail> filterCookRecipeDetails(Map<Long, Integer> recipeTypeMap, List<CookRecipeDetail> cookRecipeDetails, LocalDate applyDate) {
|
||||
return (List)cookRecipeDetails.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());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
package com.bonus.canteen.core.cook.vo;
|
||||
|
||||
public class CookRecipeDetailIDVO {
|
||||
/** 菜谱id */
|
||||
private Long recipeId;
|
||||
|
||||
/** 菜谱计划详情id */
|
||||
private Long recipeDetailId;
|
||||
}
|
||||
|
|
@ -19,7 +19,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</resultMap>
|
||||
|
||||
<sql id="selectCookRecipeDetailVo">
|
||||
select recipe_detail_id, sale_type_id, recipe_id, apply_date, apply_week, apply_month, mealtime_type, detail_type, create_by, create_time, update_by, update_time from cook_recipe_detail
|
||||
select recipe_detail_id, sale_type_id, recipe_id, apply_date, apply_week, apply_month, mealtime_type,
|
||||
detail_type, create_by, create_time, update_by, update_time
|
||||
from cook_recipe_detail
|
||||
</sql>
|
||||
|
||||
<select id="selectCookRecipeDetailList" parameterType="com.bonus.canteen.core.cook.domain.CookRecipeDetail" resultMap="CookRecipeDetailResult">
|
||||
|
|
@ -167,4 +169,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
#{applyDate}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="getCookRecipeDetailsByApplyDateAndRecipeIds" resultMap="CookRecipeDetailResult">
|
||||
<include refid="selectCookRecipeDetailVo"/>
|
||||
where apply_date = ${applyDate} and recipe_id in
|
||||
<foreach item="recipeId" collection="recipeIdList" open="(" separator="," close=")">
|
||||
#{recipeId}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="getCookRecipeDetailsByDetailTypeAndRecipeIds" resultMap="CookRecipeDetailResult">
|
||||
<include refid="selectCookRecipeDetailVo"/>
|
||||
where detail_type = 1 and recipe_id in
|
||||
<foreach item="recipeId" collection="recipeIdList" open="(" separator="," close=")">
|
||||
#{recipeId}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -23,7 +23,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</resultMap>
|
||||
|
||||
<sql id="selectCookRecipeDishesVo">
|
||||
select id, recipe_detail_id, dishes_id, price, sale_price, size_type, supply_num, sale_num, remanent_num, limit_num, chef_id, recommend_flag, create_by, create_time, update_by, update_time from cook_recipe_dishes
|
||||
select id, recipe_detail_id, dishes_id, price, sale_price, size_type, supply_num, sale_num,
|
||||
remanent_num, limit_num, chef_id, recommend_flag, create_by, create_time, update_by, update_time
|
||||
from cook_recipe_dishes
|
||||
</sql>
|
||||
|
||||
<select id="selectCookRecipeDishesList" parameterType="com.bonus.canteen.core.cook.domain.CookRecipeDishes" resultMap="CookRecipeDishesResult">
|
||||
|
|
@ -48,6 +50,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectCookRecipeDishesByDetailIds" parameterType="String" resultMap="CookRecipeDishesResult">
|
||||
<include refid="selectCookRecipeDishesVo"/>
|
||||
where recipe_detail_id in
|
||||
<foreach item="detailId" collection="recipeDetailIds" open="(" separator="," close=")">
|
||||
#{detailId}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<insert id="insertCookRecipeDishes" parameterType="com.bonus.canteen.core.cook.domain.CookRecipeDishes" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into cook_recipe_dishes
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<select id="selectRecipeListByRecipeIds" resultType="com.bonus.canteen.core.cook.domain.CookRecipe">
|
||||
<include refid="selectCookRecipeVo"/>
|
||||
<where>
|
||||
cr.del_flag = '0'
|
||||
<if test="recipeIds !=null and recipeIds.size()>0">
|
||||
AND cr.recipe_id in
|
||||
<foreach collection="recipeIds" open="(" close=")" item="item" separator=",">
|
||||
|
|
@ -117,6 +118,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectRecipeListByRecipeTypes" resultType="com.bonus.canteen.core.cook.domain.CookRecipe">
|
||||
<include refid="selectCookRecipeVo"/>
|
||||
where cr.recipe_type in (2,3) and cr.del_flag = '0'
|
||||
</select>
|
||||
|
||||
<select id="selectRecipeListByRecipeTypesAndRecipeIds" resultType="com.bonus.canteen.core.cook.domain.CookRecipe">
|
||||
<include refid="selectCookRecipeVo"/>
|
||||
where cr.recipe_type in (2,3) and cr.del_flag = '0' and cr.recipe_id in
|
||||
<foreach collection="recipeIds" open="(" close=")" item="item" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="getDishesCount4PointDates" resultType="Integer">
|
||||
select count(1)
|
||||
from cook_recipe_dishes where recipe_detail_id in
|
||||
|
|
|
|||
Loading…
Reference in New Issue