189 lines
11 KiB
XML
189 lines
11 KiB
XML
<?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.ims.mapper.PurchasePlanDetailMapper">
|
|
<resultMap type="com.bonus.canteen.core.ims.domain.vo.PurchasePlanDetailVO" id="PurchasePlanDetailResult">
|
|
<result property="detailId" column="detail_id" />
|
|
<result property="planId" column="plan_id" />
|
|
<result property="planCode" column="plan_code" />
|
|
<result property="materialId" column="material_id" />
|
|
<result property="unitId" column="unit_id" />
|
|
<result property="unitPrice" column="unit_price" />
|
|
<result property="size" column="size" />
|
|
<result property="purchaseNum" column="purchase_num" />
|
|
<result property="productionPlanNum" column="production_plan_num" />
|
|
<result property="inventoryNum" column="inventory_num" />
|
|
<result property="purchaseBudgetPrice" column="purchase_budget_price" />
|
|
<result property="stallId" column="stall_id" />
|
|
<result property="originalQuantity" column="original_quantity" />
|
|
<result property="remark" column="remark" />
|
|
<!-- <result property="delFlag" column="del_flag" />-->
|
|
<result property="createBy" column="create_by" />
|
|
<result property="createTime" column="create_time" />
|
|
<result property="updateBy" column="update_by" />
|
|
<result property="updateTime" column="update_time" />
|
|
<result property="materialName" column="material_name" />
|
|
<result property="unitName" column="unit_name" />
|
|
<result property="stallName" column="stall_name" />
|
|
<result property="materialCode" column="material_code" />
|
|
<result property="materialTypeName" column="material_type_name" />
|
|
<result property="materialTypeId" column="material_type_id" />
|
|
</resultMap>
|
|
|
|
<sql id="selectPurchasePlanDetailVo">
|
|
select detail_id, plan_id, plan_code, ippd.material_id, ippd.unit_id, ippd.unit_price, ippd.size,
|
|
purchase_num, production_plan_num, inventory_num, purchase_budget_price,
|
|
ippd.stall_id, original_quantity, remark, ippd.del_flag, ippd.create_by, ippd.create_time,
|
|
ippd.update_by, ippd.update_time, cm.material_name, iu.unit_name, bs.stall_name,
|
|
cm.material_code, cmt.material_type_name
|
|
from ims_purchase_plan_detail ippd
|
|
left join cook_material cm on cm.material_id = ippd.material_id
|
|
left join cook_material_type cmt on cm.material_type_id = cmt.material_type_id
|
|
left join ims_unit iu on iu.unit_id = ippd.unit_id
|
|
left join basic_stall bs on bs.stall_id = ippd.stall_id
|
|
</sql>
|
|
|
|
<select id="selectPurchasePlanDetailList" parameterType="com.bonus.canteen.core.ims.domain.PurchasePlanDetail" resultMap="PurchasePlanDetailResult">
|
|
<include refid="selectPurchasePlanDetailVo"/>
|
|
<where>
|
|
ippd.del_flag = '0'
|
|
<if test="planId != null "> and ippd.plan_id = #{planId}</if>
|
|
<if test="planCode != null and planCode != ''"> and ippd.plan_code = #{planCode}</if>
|
|
<if test="materialId != null "> and ippd.material_id = #{materialId}</if>
|
|
<if test="unitId != null "> and ippd.unit_id = #{unitId}</if>
|
|
<if test="unitPrice != null "> and ippd.unit_price = #{unitPrice}</if>
|
|
<if test="size != null and size != ''"> and ippd.size = #{size}</if>
|
|
<if test="purchaseNum != null "> and ippd.purchase_num = #{purchaseNum}</if>
|
|
<if test="productionPlanNum != null "> and ippd.production_plan_num = #{productionPlanNum}</if>
|
|
<if test="inventoryNum != null "> and ippd.inventory_num = #{inventoryNum}</if>
|
|
<if test="purchaseBudgetPrice != null "> and ippd.purchase_budget_price = #{purchaseBudgetPrice}</if>
|
|
<if test="stallId != null "> and ippd.stall_id = #{stallId}</if>
|
|
<if test="originalQuantity != null "> and ippd.original_quantity = #{originalQuantity}</if>
|
|
</where>
|
|
order by ippd.detail_id
|
|
</select>
|
|
|
|
<select id="selectPurchasePlanDetailByDetailId" parameterType="Long" resultMap="PurchasePlanDetailResult">
|
|
<include refid="selectPurchasePlanDetailVo"/>
|
|
where ippd.del_flag = '0' and ippd.detail_id = #{detailId}
|
|
</select>
|
|
|
|
<insert id="insertPurchasePlanDetail" parameterType="com.bonus.canteen.core.ims.domain.PurchasePlanDetail" useGeneratedKeys="true" keyProperty="detailId">
|
|
insert into ims_purchase_plan_detail
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="planId != null">plan_id,</if>
|
|
<if test="planCode != null and planCode != ''">plan_code,</if>
|
|
<if test="materialId != null">material_id,</if>
|
|
<if test="unitId != null">unit_id,</if>
|
|
<if test="unitPrice != null">unit_price,</if>
|
|
<if test="size != null">size,</if>
|
|
<if test="purchaseNum != null">purchase_num,</if>
|
|
<if test="productionPlanNum != null">production_plan_num,</if>
|
|
<if test="inventoryNum != null">inventory_num,</if>
|
|
<if test="purchaseBudgetPrice != null">purchase_budget_price,</if>
|
|
<if test="stallId != null">stall_id,</if>
|
|
<if test="originalQuantity != null">original_quantity,</if>
|
|
<if test="remark != null">remark,</if>
|
|
<if test="delFlag != null">del_flag,</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="planId != null">#{planId},</if>
|
|
<if test="planCode != null and planCode != ''">#{planCode},</if>
|
|
<if test="materialId != null">#{materialId},</if>
|
|
<if test="unitId != null">#{unitId},</if>
|
|
<if test="unitPrice != null">#{unitPrice},</if>
|
|
<if test="size != null">#{size},</if>
|
|
<if test="purchaseNum != null">#{purchaseNum},</if>
|
|
<if test="productionPlanNum != null">#{productionPlanNum},</if>
|
|
<if test="inventoryNum != null">#{inventoryNum},</if>
|
|
<if test="purchaseBudgetPrice != null">#{purchaseBudgetPrice},</if>
|
|
<if test="stallId != null">#{stallId},</if>
|
|
<if test="originalQuantity != null">#{originalQuantity},</if>
|
|
<if test="remark != null">#{remark},</if>
|
|
<if test="delFlag != null">#{delFlag},</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="updatePurchasePlanDetail" parameterType="com.bonus.canteen.core.ims.domain.PurchasePlanDetail">
|
|
update ims_purchase_plan_detail
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="planId != null">plan_id = #{planId},</if>
|
|
<if test="planCode != null and planCode != ''">plan_code = #{planCode},</if>
|
|
<if test="materialId != null">material_id = #{materialId},</if>
|
|
<if test="unitId != null">unit_id = #{unitId},</if>
|
|
<if test="unitPrice != null">unit_price = #{unitPrice},</if>
|
|
<if test="size != null">size = #{size},</if>
|
|
<if test="purchaseNum != null">purchase_num = #{purchaseNum},</if>
|
|
<if test="productionPlanNum != null">production_plan_num = #{productionPlanNum},</if>
|
|
<if test="inventoryNum != null">inventory_num = #{inventoryNum},</if>
|
|
<if test="purchaseBudgetPrice != null">purchase_budget_price = #{purchaseBudgetPrice},</if>
|
|
<if test="stallId != null">stall_id = #{stallId},</if>
|
|
<if test="originalQuantity != null">original_quantity = #{originalQuantity},</if>
|
|
<if test="remark != null">remark = #{remark},</if>
|
|
<!-- <if test="delFlag != null">del_flag = #{delFlag},</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 detail_id = #{detailId}
|
|
</update>
|
|
|
|
<delete id="deletePurchasePlanDetailByDetailId" parameterType="Long">
|
|
update ims_purchase_plan_detail set del_flag = '2' where detail_id = #{detailId}
|
|
</delete>
|
|
|
|
<delete id="deletePurchasePlanDetailByPlanId" parameterType="Long">
|
|
update ims_purchase_plan_detail set del_flag = '2' where plan_id = #{planId}
|
|
</delete>
|
|
|
|
<delete id="deletePurchasePlanDetailByPlanIds" parameterType="String">
|
|
update ims_purchase_plan_detail set del_flag = '2' where plan_id in
|
|
<foreach item="planId" collection="array" open="(" separator="," close=")">
|
|
#{planId}
|
|
</foreach>
|
|
</delete>
|
|
|
|
<delete id="deletePurchasePlanDetailByDetailIds" parameterType="String">
|
|
update ims_purchase_plan_detail set del_flag = '2' where detail_id in
|
|
<foreach item="detailId" collection="array" open="(" separator="," close=")">
|
|
#{detailId}
|
|
</foreach>
|
|
</delete>
|
|
|
|
<select id="selectPurchasePlanDetailsCategoryByPlanId" parameterType="Long" resultMap="PurchasePlanDetailResult">
|
|
select detail_id, ippd.plan_id, ippd.plan_code, cmt.material_type_name, cmt.material_type_id
|
|
from ims_purchase_plan_detail ippd
|
|
left join ims_purchase_plan ipp on ippd.plan_id = ipp.plan_id
|
|
left join cook_material cm on cm.material_id = ippd.material_id
|
|
left join cook_material_type cmt on cm.material_type_id = cmt.material_type_id
|
|
left join ims_unit iu on iu.unit_id = ippd.unit_id
|
|
left join basic_stall bs on bs.stall_id = ippd.stall_id
|
|
where ippd.plan_id = #{planId}
|
|
and ipp.deliver_goods_date = #{deliverGoodsDate}
|
|
group by cmt.material_type_id
|
|
</select>
|
|
|
|
<select id="selectPurchasePlanDetailsGoodsByPlanId" parameterType="Long" resultMap="PurchasePlanDetailResult">
|
|
select detail_id, ippd.plan_id, ippd.plan_code, ippd.material_id, iu.unit_name,
|
|
cmt.material_type_name, cmt.material_type_id, cm.material_name
|
|
from ims_purchase_plan_detail ippd
|
|
left join ims_purchase_plan ipp on ippd.plan_id = ipp.plan_id
|
|
left join cook_material cm on cm.material_id = ippd.material_id
|
|
left join cook_material_type cmt on cm.material_type_id = cmt.material_type_id
|
|
left join ims_unit iu on iu.unit_id = ippd.unit_id
|
|
left join basic_stall bs on bs.stall_id = ippd.stall_id
|
|
where ippd.plan_id = #{planId}
|
|
and ipp.deliver_goods_date = #{deliverGoodsDate}
|
|
group by ippd.material_id
|
|
</select>
|
|
</mapper> |