<?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.RecordWasteInMapper">
    
    <resultMap type="RecordWasteIn" id="RecordWasteInResult">
        <result property="objid"    column="objid"    />
        <result property="epc"    column="epc"    />
        <result property="locationCode"    column="location_code"    />
        <result property="bfTime"    column="bf_time"    />
        <result property="inCode"    column="in_code"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectRecordWasteInVo">
        select objid, epc, location_code, bf_time, in_code, create_by, create_time from record_waste_in
    </sql>

    <select id="selectRecordWasteInList" parameterType="RecordWasteIn" resultMap="RecordWasteInResult">
        <include refid="selectRecordWasteInVo"/>
        <where>  
            <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="selectRecordWasteInByObjid" parameterType="Long" resultMap="RecordWasteInResult">
        <include refid="selectRecordWasteInVo"/>
        where objid = #{objid}
    </select>
        
    <insert id="insertRecordWasteIn" parameterType="RecordWasteIn" useGeneratedKeys="true" keyProperty="objid">
        insert into record_waste_in
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="epc != null">epc,</if>
            <if test="locationCode != null">location_code,</if>
            <if test="bfTime != null">bf_time,</if>
            <if test="inCode != null">in_code,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="epc != null">#{epc},</if>
            <if test="locationCode != null">#{locationCode},</if>
            <if test="bfTime != null">#{bfTime},</if>
            <if test="inCode != null">#{inCode},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateRecordWasteIn" parameterType="RecordWasteIn">
        update record_waste_in
        <trim prefix="SET" suffixOverrides=",">
            <if test="epc != null">epc = #{epc},</if>
            <if test="locationCode != null">location_code = #{locationCode},</if>
            <if test="bfTime != null">bf_time = #{bfTime},</if>
            <if test="inCode != null">in_code = #{inCode},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where objid = #{objid}
    </update>

    <delete id="deleteRecordWasteInByObjid" parameterType="Long">
        delete from record_waste_in where objid = #{objid}
    </delete>

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

</mapper>