<?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.ruoyi.manage.mapper.RecordWasteOutMapper">
    
    <resultMap type="RecordWasteOut" id="RecordWasteOutResult">
        <result property="objid"    column="objid"    />
        <result property="epcCode"    column="epc_code"    />
        <result property="locationCode"    column="location_code"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectRecordWasteOutVo">
        select objid, epc_code, location_code, create_by, create_time from record_waste_out
    </sql>

    <select id="selectRecordWasteOutList" parameterType="RecordWasteOut" resultMap="RecordWasteOutResult">
        <include refid="selectRecordWasteOutVo"/>
        <where>  
            <if test="epcCode != null  and epcCode != ''"> and epc_code = #{epcCode}</if>
            <if test="createBy != null  and createBy != ''"> and create_by = #{createBy}</if>
            <if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> and create_time between #{params.beginCreateTime} and #{params.endCreateTime}</if>
        </where>
    </select>
    
    <select id="selectRecordWasteOutByObjid" parameterType="Long" resultMap="RecordWasteOutResult">
        <include refid="selectRecordWasteOutVo"/>
        where objid = #{objid}
    </select>
        
    <insert id="insertRecordWasteOut" parameterType="RecordWasteOut" useGeneratedKeys="true" keyProperty="objid">
        insert into record_waste_out
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="epcCode != null">epc_code,</if>
            <if test="locationCode != null">location_code,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="epcCode != null">#{epcCode},</if>
            <if test="locationCode != null">#{locationCode},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateRecordWasteOut" parameterType="RecordWasteOut">
        update record_waste_out
        <trim prefix="SET" suffixOverrides=",">
            <if test="epcCode != null">epc_code = #{epcCode},</if>
            <if test="locationCode != null">location_code = #{locationCode},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where objid = #{objid}
    </update>

    <delete id="deleteRecordWasteOutByObjid" parameterType="Long">
        delete from record_waste_out where objid = #{objid}
    </delete>

    <delete id="deleteRecordWasteOutByObjids" parameterType="String">
        delete from record_waste_out where objid in 
        <foreach item="objid" collection="array" open="(" separator="," close=")">
            #{objid}
        </foreach>
    </delete>

</mapper>