统计菜谱菜品数量

This commit is contained in:
sxu 2025-05-28 13:06:21 +08:00
parent e706c925c9
commit 7edc50bf5b
4 changed files with 25 additions and 1 deletions

View File

@ -67,5 +67,6 @@ public class CookRecipe extends BaseEntity {
@Excel(name = "到期时间", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "到期时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date expireDate; private Date expireDate;
private int dishesCount;
} }

View File

@ -29,6 +29,10 @@ public interface CookRecipeMapper {
*/ */
public List<CookRecipe> selectCookRecipeList(CookRecipe cookRecipe); public List<CookRecipe> selectCookRecipeList(CookRecipe cookRecipe);
public int getDishesCount4PointDates(Long recipeId);
public int getDishesCount4Recycle(Long recipeId);
/** /**
* 新增菜品计划信息 * 新增菜品计划信息
* *

View File

@ -64,7 +64,15 @@ public class CookRecipeServiceImpl implements ICookRecipeService {
*/ */
@Override @Override
public List<CookRecipe> selectCookRecipeList(CookRecipe cookRecipe) { public List<CookRecipe> selectCookRecipeList(CookRecipe cookRecipe) {
return cookRecipeMapper.selectCookRecipeList(cookRecipe); List<CookRecipe> list = cookRecipeMapper.selectCookRecipeList(cookRecipe);
for (CookRecipe recipe : list) {
if (1 == recipe.getRecipeType()) {
recipe.setDishesCount(cookRecipeMapper.getDishesCount4PointDates(recipe.getRecipeId()));
} else {
recipe.setDishesCount(cookRecipeMapper.getDishesCount4Recycle(recipe.getRecipeId()));
}
}
return list;
} }
/** /**

View File

@ -43,6 +43,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="expireDate != null "> and cr.expire_date = #{expireDate}</if> <if test="expireDate != null "> and cr.expire_date = #{expireDate}</if>
</where> </where>
</select> </select>
<select id="getDishesCount4PointDates" resultType="Integer">
select count(1)
from cook_recipe_dishes where recipe_detail_id in
(select recipe_detail_id from cook_recipe_detail where recipe_id = #{recipeId} and apply_date >= NOW()-1)
</select>
<select id="getDishesCount4Recycle" resultType="Integer">
select count(1) from cook_recipe_dishes where recipe_detail_id in
(select recipe_detail_id from cook_recipe_detail where recipe_id = #{recipeId} and detail_type = 1)
</select>
<select id="selectCookRecipeByRecipeId" parameterType="Long" resultMap="CookRecipeResult"> <select id="selectCookRecipeByRecipeId" parameterType="Long" resultMap="CookRecipeResult">
<include refid="selectCookRecipeVo"/> <include refid="selectCookRecipeVo"/>