Merge branch 'master' into report
This commit is contained in:
commit
03bedbb3c3
|
|
@ -1,5 +1,6 @@
|
||||||
package com.bonus.canteen.core.cook.mapper;
|
package com.bonus.canteen.core.cook.mapper;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.bonus.canteen.core.cook.domain.CookRecipeDetail;
|
import com.bonus.canteen.core.cook.domain.CookRecipeDetail;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
@ -61,7 +62,13 @@ public interface CookRecipeDetailMapper {
|
||||||
|
|
||||||
public List<Long> getAllCookRecipeDetailIds(Long[] recipeIds);
|
public List<Long> getAllCookRecipeDetailIds(Long[] recipeIds);
|
||||||
|
|
||||||
public List<Long> getToDeleteCookRecipeDetailIds(Long recipeId);
|
|
||||||
|
public List<Long> getToDeleteCookRecipeDetailIds4PointDays(@Param("recipeId") Long recipeId, @Param("dateList") List<LocalDate> dateList);
|
||||||
|
|
||||||
|
public List<Long> getToDeleteCookRecipeDetailIds4Daily(Long recipeId);
|
||||||
|
|
||||||
|
public List<Long> getToDeleteCookRecipeDetailIds4Weekly(Long recipeId);
|
||||||
|
|
||||||
List<CookRecipeDetail> getCookRecipeDetailLTemplate(@Param("recipeId") Long recipeId, @Param("detailType") String detailType);
|
List<CookRecipeDetail> getCookRecipeDetailLTemplate(@Param("recipeId") Long recipeId, @Param("detailType") String detailType);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -201,25 +201,14 @@ public class CookRecipeServiceImpl implements ICookRecipeService {
|
||||||
throw new ServiceException("该菜谱名称已存在,请重新输入");
|
throw new ServiceException("该菜谱名称已存在,请重新输入");
|
||||||
}
|
}
|
||||||
int count = cookRecipeMapper.insertCookRecipe(cookRecipeDTO); //插入菜谱
|
int count = cookRecipeMapper.insertCookRecipe(cookRecipeDTO); //插入菜谱
|
||||||
createRecipeDetails(cookRecipeDTO, true);
|
createRecipeDetails(cookRecipeDTO);
|
||||||
return count;
|
return count;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ServiceException(e.getMessage());
|
throw new ServiceException(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createRecipeDetails(CookRecipeDTO cookRecipeDTO, boolean isCreate) {
|
private void createRecipeDetails(CookRecipeDTO cookRecipeDTO) {
|
||||||
// 更新菜谱时,
|
|
||||||
// 指定日期菜谱,删掉指定日期的菜谱
|
|
||||||
// 循环菜谱,删掉模板数据 + 今日开始的详情数据
|
|
||||||
if (!isCreate) {
|
|
||||||
List<Long> cookRecipeDetailIds = cookRecipeDetailMapper.getToDeleteCookRecipeDetailIds(cookRecipeDTO.getRecipeId());
|
|
||||||
if (!CollectionUtils.isEmpty(cookRecipeDetailIds)) {
|
|
||||||
Long[] cookRecipeDetailArray = cookRecipeDetailIds.stream().toArray(Long[]::new);
|
|
||||||
cookRecipeDishesMapper.deleteCookRecipeDishesByCookRecipeDetailIds(cookRecipeDetailArray);
|
|
||||||
cookRecipeDetailMapper.deleteCookRecipeDetailByRecipeDetailIds(cookRecipeDetailArray);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 插入指定日期、日循环摸板、周循环模板
|
// 插入指定日期、日循环摸板、周循环模板
|
||||||
if (!CollectionUtils.isEmpty(cookRecipeDTO.getRecipeDateList())) {
|
if (!CollectionUtils.isEmpty(cookRecipeDTO.getRecipeDateList())) {
|
||||||
for (CookRecipeDateDTO recipeDateDTO : cookRecipeDTO.getRecipeDateList()) {
|
for (CookRecipeDateDTO recipeDateDTO : cookRecipeDTO.getRecipeDateList()) {
|
||||||
|
|
@ -334,7 +323,28 @@ public class CookRecipeServiceImpl implements ICookRecipeService {
|
||||||
throw new ServiceException("该菜谱名称已存在,请重新输入");
|
throw new ServiceException("该菜谱名称已存在,请重新输入");
|
||||||
}
|
}
|
||||||
int count = cookRecipeMapper.updateCookRecipe(cookRecipeDTO);
|
int count = cookRecipeMapper.updateCookRecipe(cookRecipeDTO);
|
||||||
createRecipeDetails(cookRecipeDTO, false);
|
List<Long> cookRecipeDetailIds = new ArrayList<>();
|
||||||
|
// 更新菜谱时,指定日期菜谱,删掉指定日期的菜谱
|
||||||
|
if (RecipeTypeEnum.POINT_DATE.key().equals(cookRecipeDTO.getRecipeType())) {
|
||||||
|
List<LocalDate> dateList = cookRecipeDTO.getRecipeDateList().stream().map(CookRecipeDateDTO::getApplyDate).collect(Collectors.toList());
|
||||||
|
cookRecipeDetailIds = cookRecipeDetailMapper.getToDeleteCookRecipeDetailIds4PointDays(cookRecipeDTO.getRecipeId(), dateList);
|
||||||
|
}
|
||||||
|
// 循环日菜谱,删掉模板数据 + 今日开始的详情数据
|
||||||
|
if (RecipeTypeEnum.DAILY.key().equals(cookRecipeDTO.getRecipeType())) {
|
||||||
|
cookRecipeDetailIds = cookRecipeDetailMapper.getToDeleteCookRecipeDetailIds4Daily(cookRecipeDTO.getRecipeId());
|
||||||
|
}
|
||||||
|
// 循环周菜谱,删掉指定周x模板数据 + 今日开始的周x的详情数据
|
||||||
|
if (RecipeTypeEnum.WEEKLY.key().equals(cookRecipeDTO.getRecipeType())) {
|
||||||
|
List<Long> weekDayList = cookRecipeDTO.getRecipeDateList().stream().map(CookRecipeDateDTO::getApplyWeek).collect(Collectors.toList());
|
||||||
|
cookRecipeDetailIds = cookRecipeDetailMapper.getToDeleteCookRecipeDetailIds4Weekly(cookRecipeDTO.getRecipeId());
|
||||||
|
}
|
||||||
|
if (!CollectionUtils.isEmpty(cookRecipeDetailIds)) {
|
||||||
|
Long[] cookRecipeDetailArray = cookRecipeDetailIds.stream().toArray(Long[]::new);
|
||||||
|
cookRecipeDishesMapper.deleteCookRecipeDishesByCookRecipeDetailIds(cookRecipeDetailArray);
|
||||||
|
cookRecipeDetailMapper.deleteCookRecipeDetailByRecipeDetailIds(cookRecipeDetailArray);
|
||||||
|
}
|
||||||
|
// 重新创建菜谱
|
||||||
|
createRecipeDetails(cookRecipeDTO);
|
||||||
return count;
|
return count;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ServiceException(e.getMessage());
|
throw new ServiceException(e.getMessage());
|
||||||
|
|
|
||||||
|
|
@ -107,14 +107,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</foreach>
|
</foreach>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getToDeleteCookRecipeDetailIds" parameterType="Long" resultType="Long">
|
<select id="getToDeleteCookRecipeDetailIds4PointDays" resultType="Long">
|
||||||
SELECT distinct(crd.recipe_detail_id)
|
SELECT distinct(crd.recipe_detail_id)
|
||||||
FROM cook_recipe_detail crd
|
FROM cook_recipe_detail crd
|
||||||
left join cook_recipe cr ON cr.recipe_id = crd.recipe_id
|
left join cook_recipe cr ON cr.recipe_id = crd.recipe_id
|
||||||
where cr.recipe_id = #{recipeId} and cr.recipe_type = 1 and crd.apply_date >= NOW()-1
|
where cr.recipe_id = #{recipeId} and cr.recipe_type = 1 and crd.apply_date in
|
||||||
|
<foreach item="applyDate" collection="dateList" open="(" separator="," close=")">
|
||||||
UNION
|
#{applyDate}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getToDeleteCookRecipeDetailIds4Daily" resultType="Long">
|
||||||
SELECT distinct(crd.recipe_detail_id)
|
SELECT distinct(crd.recipe_detail_id)
|
||||||
FROM cook_recipe_detail crd
|
FROM cook_recipe_detail crd
|
||||||
left join cook_recipe cr ON cr.recipe_id = crd.recipe_id
|
left join cook_recipe cr ON cr.recipe_id = crd.recipe_id
|
||||||
|
|
@ -126,9 +129,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
FROM cook_recipe_detail crd
|
FROM cook_recipe_detail crd
|
||||||
left join cook_recipe cr ON cr.recipe_id = crd.recipe_id
|
left join cook_recipe cr ON cr.recipe_id = crd.recipe_id
|
||||||
where cr.recipe_id = #{recipeId} and cr.recipe_type = 2 and crd.detail_type = 2 and crd.apply_date >= NOW()-1
|
where cr.recipe_id = #{recipeId} and cr.recipe_type = 2 and crd.detail_type = 2 and crd.apply_date >= NOW()-1
|
||||||
|
</select>
|
||||||
|
|
||||||
UNION
|
<select id="getToDeleteCookRecipeDetailIds4Weekly" parameterType="Long" resultType="Long">
|
||||||
|
|
||||||
SELECT distinct(crd.recipe_detail_id)
|
SELECT distinct(crd.recipe_detail_id)
|
||||||
FROM cook_recipe_detail crd
|
FROM cook_recipe_detail crd
|
||||||
left join cook_recipe cr ON cr.recipe_id = crd.recipe_id
|
left join cook_recipe cr ON cr.recipe_id = crd.recipe_id
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="salePrice != null">sale_price,</if>
|
<if test="salePrice != null">sale_price,</if>
|
||||||
<if test="sizeType != null">size_type,</if>
|
<if test="sizeType != null">size_type,</if>
|
||||||
<if test="supplyNum != null">supply_num,</if>
|
<if test="supplyNum != null">supply_num,</if>
|
||||||
<if test="saleNum != null">sale_num,</if>
|
<!--<if test="saleNum != null">sale_num,</if>-->
|
||||||
<if test="remanentNum != null">remanent_num,</if>
|
<if test="remanentNum != null">remanent_num,</if>
|
||||||
<if test="limitNum != null">limit_num,</if>
|
<if test="limitNum != null">limit_num,</if>
|
||||||
<if test="chefId != null">chef_id,</if>
|
<if test="chefId != null">chef_id,</if>
|
||||||
|
|
@ -74,7 +74,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="salePrice != null">#{salePrice},</if>
|
<if test="salePrice != null">#{salePrice},</if>
|
||||||
<if test="sizeType != null">#{sizeType},</if>
|
<if test="sizeType != null">#{sizeType},</if>
|
||||||
<if test="supplyNum != null">#{supplyNum},</if>
|
<if test="supplyNum != null">#{supplyNum},</if>
|
||||||
<if test="saleNum != null">#{saleNum},</if>
|
<!--<if test="saleNum != null">#{saleNum},</if>-->
|
||||||
<if test="remanentNum != null">#{remanentNum},</if>
|
<if test="remanentNum != null">#{remanentNum},</if>
|
||||||
<if test="limitNum != null">#{limitNum},</if>
|
<if test="limitNum != null">#{limitNum},</if>
|
||||||
<if test="chefId != null">#{chefId},</if>
|
<if test="chefId != null">#{chefId},</if>
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<select id="selectCookRecipeList" parameterType="com.bonus.canteen.core.cook.domain.CookRecipe" resultMap="CookRecipeResult">
|
<select id="selectCookRecipeList" parameterType="com.bonus.canteen.core.cook.domain.CookRecipe" resultMap="CookRecipeResult">
|
||||||
<include refid="selectCookRecipeVo"/>
|
<include refid="selectCookRecipeVo"/>
|
||||||
<where>
|
<where>
|
||||||
|
cr.del_flag = 0
|
||||||
<if test="recipeName != null and recipeName != ''"> and cr.recipe_name like concat('%', #{recipeName}, '%')</if>
|
<if test="recipeName != null and recipeName != ''"> and cr.recipe_name like concat('%', #{recipeName}, '%')</if>
|
||||||
<if test="recipeType != null "> and cr.recipe_type = #{recipeType}</if>
|
<if test="recipeType != null "> and cr.recipe_type = #{recipeType}</if>
|
||||||
<if test="stallId != null "> and cr.stall_id = #{stallId}</if>
|
<if test="stallId != null "> and cr.stall_id = #{stallId}</if>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue