<?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.RecordInMapper">
    
    <resultMap type="RecordIn" id="RecordInResult">
        <result property="objid"    column="objid"    />
        <result property="epcCode"    column="epc_code"    />
        <result property="batchCode"    column="batch_code"    />
        <result property="locationCode"    column="location_code"    />
        <result property="manufacturerName"    column="manufacturer_Name"    />
        <result property="remark"    column="remark"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectRecordInVo">
        select objid, epc_code, batch_code, location_code, manufacturer_Name, remark, create_by, create_time from record_in
    </sql>

    <select id="selectRecordInList" parameterType="RecordIn" resultMap="RecordInResult">
        <include refid="selectRecordInVo"/>
        <where>  
            <if test="epcCode != null  and epcCode != ''"> and epc_code = #{epcCode}</if>
            <if test="batchCode != null  and batchCode != ''"> and batch_code like concat('%', #{batchCode}, '%')</if>
            <if test="locationCode != null  and locationCode != ''"> and location_code = #{locationCode}</if>
            <if test="manufacturerName != null  and manufacturerName != ''"> and manufacturer_Name = #{manufacturerName}</if>
        </where>
    </select>
    
    <select id="selectRecordInByObjid" parameterType="Long" resultMap="RecordInResult">
        <include refid="selectRecordInVo"/>
        where objid = #{objid}
    </select>
        
    <insert id="insertRecordIn" parameterType="RecordIn" useGeneratedKeys="true" keyProperty="objid">
        insert into record_in
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="epcCode != null">epc_code,</if>
            <if test="batchCode != null">batch_code,</if>
            <if test="locationCode != null">location_code,</if>
            <if test="manufacturerName != null">manufacturer_Name,</if>
            <if test="remark != null">remark,</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="batchCode != null">#{batchCode},</if>
            <if test="locationCode != null">#{locationCode},</if>
            <if test="manufacturerName != null">#{manufacturerName},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateRecordIn" parameterType="RecordIn">
        update record_in
        <trim prefix="SET" suffixOverrides=",">
            <if test="epcCode != null">epc_code = #{epcCode},</if>
            <if test="batchCode != null">batch_code = #{batchCode},</if>
            <if test="locationCode != null">location_code = #{locationCode},</if>
            <if test="manufacturerName != null">manufacturer_Name = #{manufacturerName},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where objid = #{objid}
    </update>

    <delete id="deleteRecordInByObjid" parameterType="Long">
        delete from record_in where objid = #{objid}
    </delete>

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

</mapper>