<?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.RecordInspectionInfoMapper">
    
    <resultMap type="RecordInspectionInfo" id="RecordInspectionInfoResult">
        <result property="inspectionId"    column="inspection_id"    />
        <result property="epcCode"    column="epc_code"    />
        <result property="locationCode"    column="location_code"    />
        <result property="inspectionState"    column="inspection_state"    />
        <result property="inspectionRemark"    column="inspection_remark"    />
    </resultMap>

    <sql id="selectRecordInspectionInfoVo">
        select inspection_id, epc_code, location_code, inspection_state, inspection_remark from record_inspection_info
    </sql>

    <select id="selectRecordInspectionInfoList" parameterType="RecordInspectionInfo" resultMap="RecordInspectionInfoResult">
        <include refid="selectRecordInspectionInfoVo"/>
        <where>  
            <if test="inspectionId != null "> and inspection_id = #{inspectionId}</if>
            <if test="epcCode != null  and epcCode != ''"> and epc_code = #{epcCode}</if>
            <if test="locationCode != null  and locationCode != ''"> and location_code = #{locationCode}</if>
            <if test="inspectionState != null  and inspectionState != ''"> and inspection_state = #{inspectionState}</if>
            <if test="inspectionRemark != null  and inspectionRemark != ''"> and inspection_remark = #{inspectionRemark}</if>
        </where>
    </select>
    
    <select id="selectRecordInspectionInfoByInspectionId" parameterType="Long" resultMap="RecordInspectionInfoResult">
        <include refid="selectRecordInspectionInfoVo"/>
        where inspection_id = #{inspectionId}
    </select>
        
    <insert id="insertRecordInspectionInfo" parameterType="RecordInspectionInfo">
        insert into record_inspection_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="inspectionId != null">inspection_id,</if>
            <if test="epcCode != null">epc_code,</if>
            <if test="locationCode != null">location_code,</if>
            <if test="inspectionState != null">inspection_state,</if>
            <if test="inspectionRemark != null">inspection_remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="inspectionId != null">#{inspectionId},</if>
            <if test="epcCode != null">#{epcCode},</if>
            <if test="locationCode != null">#{locationCode},</if>
            <if test="inspectionState != null">#{inspectionState},</if>
            <if test="inspectionRemark != null">#{inspectionRemark},</if>
         </trim>
    </insert>

    <update id="updateRecordInspectionInfo" parameterType="RecordInspectionInfo">
        update record_inspection_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="epcCode != null">epc_code = #{epcCode},</if>
            <if test="locationCode != null">location_code = #{locationCode},</if>
            <if test="inspectionState != null">inspection_state = #{inspectionState},</if>
            <if test="inspectionRemark != null">inspection_remark = #{inspectionRemark},</if>
        </trim>
        where inspection_id = #{inspectionId}
    </update>

    <delete id="deleteRecordInspectionInfoByInspectionId" parameterType="Long">
        delete from record_inspection_info where inspection_id = #{inspectionId}
    </delete>

    <delete id="deleteRecordInspectionInfoByInspectionIds" parameterType="String">
        delete from record_inspection_info where inspection_id in 
        <foreach item="inspectionId" collection="array" open="(" separator="," close=")">
            #{inspectionId}
        </foreach>
    </delete>

</mapper>