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

165 lines
10 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.InspectGoodsDetailMapper">
<resultMap type="com.bonus.canteen.core.ims.domain.vo.InspectGoodsDetailVO" id="InspectGoodsDetailResult">
<result property="inspectGoodsDetailId" column="inspect_goods_detail_id" />
<result property="inspectGoodsId" column="inspect_goods_id" />
<result property="inspectGoodsCode" column="inspect_goods_code" />
<result property="deliveryGoodsDetailId" column="delivery_goods_detail_id" />
<result property="materialId" column="material_id" />
<result property="unitPrice" column="unit_price" />
<result property="orderNum" column="order_num" />
<result property="deliveryNum" column="delivery_num" />
<result property="totalQualifiedNum" column="total_qualified_num" />
<result property="qualifiedNum" column="qualified_num" />
<result property="unqualifiedReason" column="unqualified_reason" />
<result property="checkPicUrls" column="check_pic_urls" />
<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="materialCode" column="material_code" />
<result property="materialTypeName" column="material_type_name" />
<result property="unitName" column="unit_name" />
<result property="size" column="size" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectInspectGoodsDetailVo">
select inspect_goods_detail_id, iigd.inspect_goods_id, iigd.inspect_goods_code, delivery_goods_detail_id,
iigd.material_id, iigd.unit_price, order_num, delivery_num, iigd.total_qualified_num, qualified_num,
unqualified_reason, check_pic_urls, iigd.create_by, iigd.create_time, iigd.update_by, iigd.update_time,
cm.material_name, cm.material_code, cmt.material_type_name, cm.size, iigd.remark
from ims_inspect_goods_detail iigd
left join ims_inspect_goods iig on iigd.inspect_goods_id = iig.inspect_goods_id
left join cook_material cm on cm.material_id = iigd.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 = cm.unit_id
</sql>
<select id="selectInspectGoodsDetailList" parameterType="com.bonus.canteen.core.ims.domain.InspectGoodsDetail" resultMap="InspectGoodsDetailResult">
<include refid="selectInspectGoodsDetailVo"/>
<where>
<if test="inspectGoodsId != null "> and iigd.inspect_goods_id = #{inspectGoodsId}</if>
<if test="inspectGoodsCode != null and inspectGoodsCode != ''"> and iigd.inspect_goods_code = #{inspectGoodsCode}</if>
<if test="deliveryGoodsDetailId != null "> and iigd.delivery_goods_detail_id = #{deliveryGoodsDetailId}</if>
<if test="materialId != null "> and iigd.material_id = #{materialId}</if>
<if test="unitPrice != null "> and iigd.unit_price = #{unitPrice}</if>
<if test="orderNum != null "> and iigd.order_num = #{orderNum}</if>
<if test="deliveryNum != null "> and iigd.delivery_num = #{deliveryNum}</if>
<if test="totalQualifiedNum != null "> and iigd.total_qualified_num = #{totalQualifiedNum}</if>
<if test="qualifiedNum != null "> and iigd.qualified_num = #{qualifiedNum}</if>
<if test="unqualifiedReason != null and unqualifiedReason != ''"> and iigd.unqualified_reason = #{unqualifiedReason}</if>
<if test="checkPicUrls != null and checkPicUrls != ''"> and iigd.check_pic_urls = #{checkPicUrls}</if>
<if test="relateOrderGoodsId != null and relateOrderGoodsId != ''"> and iig.relate_order_goods_id = #{relateOrderGoodsId}</if>
</where>
order by iigd.inspect_goods_detail_id
</select>
<select id="selectInspectGoodsDetailByInspectGoodsDetailId" parameterType="Long" resultMap="InspectGoodsDetailResult">
<include refid="selectInspectGoodsDetailVo"/>
where iig.relate_order_goods_id = (
select DISTINCT relate_order_goods_id from ims_inspect_goods where inspect_goods_id = #{inspectGoodsId} limit 1
)
</select>
<insert id="insertInspectGoodsDetail" parameterType="com.bonus.canteen.core.ims.domain.InspectGoodsDetail" useGeneratedKeys="true" keyProperty="inspectGoodsDetailId">
insert into ims_inspect_goods_detail
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="inspectGoodsId != null">inspect_goods_id,</if>
<if test="inspectGoodsCode != null and inspectGoodsCode != ''">inspect_goods_code,</if>
<if test="deliveryGoodsDetailId != null">delivery_goods_detail_id,</if>
<if test="materialId != null">material_id,</if>
<if test="unitPrice != null">unit_price,</if>
<if test="orderNum != null">order_num,</if>
<if test="deliveryNum != null">delivery_num,</if>
<if test="totalQualifiedNum != null">total_qualified_num,</if>
<if test="qualifiedNum != null">qualified_num,</if>
<if test="unqualifiedReason != null">unqualified_reason,</if>
<if test="checkPicUrls != null">check_pic_urls,</if>
<if test="remark != null">remark,</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="inspectGoodsId != null">#{inspectGoodsId},</if>
<if test="inspectGoodsCode != null and inspectGoodsCode != ''">#{inspectGoodsCode},</if>
<if test="deliveryGoodsDetailId != null">#{deliveryGoodsDetailId},</if>
<if test="materialId != null">#{materialId},</if>
<if test="unitPrice != null">#{unitPrice},</if>
<if test="orderNum != null">#{orderNum},</if>
<if test="deliveryNum != null">#{deliveryNum},</if>
<if test="totalQualifiedNum != null">#{totalQualifiedNum},</if>
<if test="qualifiedNum != null">#{qualifiedNum},</if>
<if test="unqualifiedReason != null">#{unqualifiedReason},</if>
<if test="checkPicUrls != null">#{checkPicUrls},</if>
<if test="remark != null">#{remark},</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="updateInspectGoodsDetail" parameterType="com.bonus.canteen.core.ims.domain.InspectGoodsDetail">
update ims_inspect_goods_detail
<trim prefix="SET" suffixOverrides=",">
<if test="inspectGoodsId != null">inspect_goods_id = #{inspectGoodsId},</if>
<if test="inspectGoodsCode != null and inspectGoodsCode != ''">inspect_goods_code = #{inspectGoodsCode},</if>
<if test="deliveryGoodsDetailId != null">delivery_goods_detail_id = #{deliveryGoodsDetailId},</if>
<if test="materialId != null">material_id = #{materialId},</if>
<if test="unitPrice != null">unit_price = #{unitPrice},</if>
<if test="orderNum != null">order_num = #{orderNum},</if>
<if test="deliveryNum != null">delivery_num = #{deliveryNum},</if>
<if test="totalQualifiedNum != null">total_qualified_num = #{totalQualifiedNum},</if>
<if test="qualifiedNum != null">qualified_num = #{qualifiedNum},</if>
<if test="unqualifiedReason != null">unqualified_reason = #{unqualifiedReason},</if>
<if test="checkPicUrls != null">check_pic_urls = #{checkPicUrls},</if>
<if test="remark != null">remark = #{remark},</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 inspect_goods_detail_id = #{inspectGoodsDetailId}
</update>
<delete id="deleteInspectGoodsDetailByInspectGoodsDetailId" parameterType="Long">
delete from ims_inspect_goods_detail where inspect_goods_detail_id = #{inspectGoodsDetailId}
</delete>
<delete id="deleteInspectGoodsDetailByInspectGoodsId" parameterType="Long">
delete from ims_inspect_goods_detail where inspect_goods_id = #{inspectGoodsId}
</delete>
<delete id="deleteInspectGoodsDetailByInspectGoodsIds" parameterType="String">
delete from ims_inspect_goods_detail where inspect_goods_id in
<foreach item="inspectGoodsId" collection="array" open="(" separator="," close=")">
#{inspectGoodsId}
</foreach>
</delete>
<delete id="deleteInspectGoodsDetailByInspectGoodsDetailIds" parameterType="String">
delete from ims_inspect_goods_detail where inspect_goods_detail_id in
<foreach item="inspectGoodsDetailId" collection="array" open="(" separator="," close=")">
#{inspectGoodsDetailId}
</foreach>
</delete>
<select id="selectOrderGoodCodeByInspectGoodsId" resultType="java.lang.String">
update ims_order_goods SET if_all_inspect = 2 where order_goods_code = (
select DISTINCT iig.relate_order_goods_id from ims_inspect_goods iig
where iig.inspect_goods_id = #{inspectGoodsId} limit 1)
</select>
<select id="selectInspectGoodsDetailListByInspectGoodsId" parameterType="Long" resultMap="InspectGoodsDetailResult">
<include refid="selectInspectGoodsDetailVo"/>
where iigd.inspect_goods_id = #{inspectGoodsId}
</select>
</mapper>