Bonus-Cloud-JYY-Smart-Canteen/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookRecipeMapper.xml

197 lines
9.4 KiB
XML
Raw Normal View History

2025-05-25 19:57:10 +08:00
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.canteen.core.cook.mapper.CookRecipeMapper">
<resultMap type="com.bonus.canteen.core.cook.domain.CookRecipe" id="CookRecipeResult">
<result property="recipeId" column="recipe_id" />
<result property="recipeName" column="recipe_name" />
<result property="recipeType" column="recipe_type" />
<result property="stallId" column="stall_id" />
2025-05-28 12:52:05 +08:00
<result property="stallName" column="stall_name" />
2025-05-25 19:57:10 +08:00
<result property="canteenId" column="canteen_id" />
2025-05-28 12:52:05 +08:00
<result property="canteenName" column="canteen_name" />
<result property="areaName" column="area_name" />
2025-05-25 19:57:10 +08:00
<result property="planId" column="plan_id" />
<result property="effectDate" column="effect_date" />
<result property="expireDate" column="expire_date" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectCookRecipeVo">
2025-05-28 12:52:05 +08:00
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,
bs.stall_name, bc.canteen_name, ba.area_name
from cook_recipe cr
left join basic_stall bs on bs.stall_id = cr.stall_id
left join basic_canteen bc on bc.canteen_id = bs.canteen_id
left join basic_area ba on ba.area_id = bc.area_id
2025-05-25 19:57:10 +08:00
</sql>
<select id="selectCookRecipeList" parameterType="com.bonus.canteen.core.cook.domain.CookRecipe" resultMap="CookRecipeResult">
<include refid="selectCookRecipeVo"/>
<where>
2025-05-28 12:52:05 +08:00
<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="stallId != null "> and cr.stall_id = #{stallId}</if>
<if test="canteenId != null "> and cr.canteen_id = #{canteenId}</if>
<if test="planId != null and planId != ''"> and cr.plan_id = #{planId}</if>
<if test="effectDate != null "> and cr.effect_date = #{effectDate}</if>
<if test="expireDate != null "> and cr.expire_date = #{expireDate}</if>
2025-05-25 19:57:10 +08:00
</where>
</select>
2025-05-28 13:06:21 +08:00
<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="selectRecipeDetailList" resultType="com.bonus.canteen.core.cook.vo.CookRecipeDetailVO">
select crd.mealtime_type,
crd.recipe_detail_id,
cd.dishes_id,
cdb.base_dishes_id,
cdb.dishes_name,
crdd.id,
crdd.price,
crdd.size_type,
crdd.supply_num,
crdd.sale_num,
crdd.remanent_num,
crdd.limit_num,
crdd.sale_price,
crdd.recommend_flag,
bc.canteen_name,
cd.sales_mode,
cd.unit_price,
cd.meal_type,
cd.type_id,
cdt.dishes_type_name,
cd.material_cost
from cook_recipe_detail crd
left join cook_recipe_dishes crdd on crd.recipe_detail_id = crdd.recipe_detail_id
left join cook_dishes cd on crdd.dishes_id = cd.dishes_id
left join basic_canteen bc on cd.canteen_id = bc.canteen_id
left join cook_dishes_base cdb on cd.base_dishes_id = cdb.base_dishes_id
left join cook_dishes_type cdt on cd.type_id = cdt.dishes_type_id
where crd.recipe_id = #{recipeId}
and crd.apply_date = #{applyDate}
order by crdd.dishes_id
</select>
2025-05-28 15:52:44 +08:00
<select id="getRecipeDetail" resultType="com.bonus.canteen.core.cook.vo.CookRecipeDetailVO">
select DISTINCT
mrd.mealtime_type,
mrd.recipe_detail_id,
mdb.base_dishes_id ,
md.dishes_id,
mdb.dishes_name,
mrdd.id,
mrdd.price,
mrdd.size_type,
mrdd.supply_num,
mrdd.sale_num,
mrdd.remanent_num,
mrdd.limit_num,
mrdd.sale_price,
mrdd.recommend_flag,
ac.canteen_name,
md.sales_mode,
md.unit_price,
md.meal_type,
md.type_id,
mdt.dishes_type_name,
md.material_cost
from cook_recipe_detail mrd
left join cook_recipe_dishes mrdd on mrd.recipe_detail_id = mrdd.recipe_detail_id
left join cook_dishes md on mrdd.dishes_id = md.dishes_id
left join basic_canteen ac on md.canteen_id = ac.canteen_id
left join cook_dishes_base mdb on md.base_dishes_id = mdb.base_dishes_id
left join cook_dishes_type mdt on md.type_id = mdt.dishes_type_id
where mrd.recipe_id = #{params.recipeId}
<if test="params.applyWeek !=null and params.applyWeek != ''">
and mrd.apply_week = #{params.applyWeek}
</if>
and mrd.detail_type = 1
order by mrdd.dishes_id
</select>
2025-05-25 19:57:10 +08:00
<select id="selectCookRecipeByRecipeId" parameterType="Long" resultMap="CookRecipeResult">
<include refid="selectCookRecipeVo"/>
2025-05-28 12:52:05 +08:00
where cr.recipe_id = #{recipeId}
2025-05-25 19:57:10 +08:00
</select>
2025-05-28 10:20:08 +08:00
<select id="selectCookRecipeByRecipeName" parameterType="String" resultMap="CookRecipeResult">
<include refid="selectCookRecipeVo"/>
2025-05-28 12:52:05 +08:00
where cr.recipe_name = #{recipeName}
2025-05-28 10:20:08 +08:00
</select>
2025-05-25 19:57:10 +08:00
<insert id="insertCookRecipe" parameterType="com.bonus.canteen.core.cook.domain.CookRecipe" useGeneratedKeys="true" keyProperty="recipeId">
insert into cook_recipe
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="recipeName != null and recipeName != ''">recipe_name,</if>
<if test="recipeType != null">recipe_type,</if>
<if test="stallId != null">stall_id,</if>
<if test="canteenId != null">canteen_id,</if>
<if test="planId != null">plan_id,</if>
<if test="effectDate != null">effect_date,</if>
<if test="expireDate != null">expire_date,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="recipeName != null and recipeName != ''">#{recipeName},</if>
<if test="recipeType != null">#{recipeType},</if>
<if test="stallId != null">#{stallId},</if>
<if test="canteenId != null">#{canteenId},</if>
<if test="planId != null">#{planId},</if>
<if test="effectDate != null">#{effectDate},</if>
<if test="expireDate != null">#{expireDate},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateCookRecipe" parameterType="com.bonus.canteen.core.cook.domain.CookRecipe">
update cook_recipe
<trim prefix="SET" suffixOverrides=",">
<if test="recipeName != null and recipeName != ''">recipe_name = #{recipeName},</if>
<if test="recipeType != null">recipe_type = #{recipeType},</if>
<if test="stallId != null">stall_id = #{stallId},</if>
<if test="canteenId != null">canteen_id = #{canteenId},</if>
<if test="planId != null">plan_id = #{planId},</if>
<if test="effectDate != null">effect_date = #{effectDate},</if>
<if test="expireDate != null">expire_date = #{expireDate},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where recipe_id = #{recipeId}
</update>
<delete id="deleteCookRecipeByRecipeId" parameterType="Long">
delete from cook_recipe where recipe_id = #{recipeId}
</delete>
<delete id="deleteCookRecipeByRecipeIds" parameterType="String">
delete from cook_recipe where recipe_id in
<foreach item="recipeId" collection="array" open="(" separator="," close=")">
#{recipeId}
</foreach>
</delete>
</mapper>