<?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.business.mapper.TInspectReportMapper">
    
    <resultMap type="TInspectReport" id="TInspectReportResult">
        <result property="inspectid"    column="inspectId"    />
        <result property="goodsid"    column="goodsId"    />
        <result property="goodsname"    column="goodsName"    />
        <result property="productlotid"    column="productlotid"    />
        <result property="ctl"    column="ctl"    />
        <result property="location"    column="location"    />
        <result property="productiondate"    column="productionDate"    />
        <result property="expirationdate"    column="expirationDate"    />
        <result property="shelfnum"    column="shelfNum"    />
        <result property="provider"    column="provider"    />
        <result property="status"    column="status"    />
        <result property="createtime"    column="createTime"    />
        <result property="username"    column="userName"    />
    </resultMap>

    <sql id="selectTInspectReportVo">
        select inspectId, goodsId, goodsName, productlotid, ctl, location, productionDate, expirationDate, shelfNum, provider, status, createTime, userName from t_inspect_report
    </sql>

    <select id="selectTInspectReportList" parameterType="TInspectReport" resultMap="TInspectReportResult">
        <include refid="selectTInspectReportVo"/>
        <where>  
            <if test="goodsid != null  and goodsid != ''"> and goodsId like concat('%', #{goodsid}, '%')</if>
            <if test="goodsname != null  and goodsname != ''"> and goodsName like concat('%', #{goodsname}, '%')</if>
            <if test="productlotid != null  and productlotid != ''"> and productlotid = #{productlotid}</if>
            <if test="ctl != null  and ctl != ''"> and ctl = #{ctl}</if>
            <if test="location != null  and location != ''"> and location = #{location}</if>
            <if test="productiondate != null "> and productionDate = #{productiondate}</if>
            <if test="expirationdate != null "> and expirationDate = #{expirationdate}</if>
            <if test="shelfnum != null  and shelfnum != ''"> and shelfNum = #{shelfnum}</if>
            <if test="provider != null  and provider != ''"> and provider = #{provider}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="createtime != null "> and createTime = #{createtime}</if>
            <if test="username != null  and username != ''"> and userName like concat('%', #{username}, '%')</if>
        </where>
    </select>
    
    <select id="selectTInspectReportByInspectid" parameterType="String" resultMap="TInspectReportResult">
        <include refid="selectTInspectReportVo"/>
        where inspectId = #{inspectid}
    </select>
        
    <insert id="insertTInspectReport" parameterType="TInspectReport">
        insert into t_inspect_report
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="inspectid != null">inspectId,</if>
            <if test="goodsid != null and goodsid != ''">goodsId,</if>
            <if test="goodsname != null">goodsName,</if>
            <if test="productlotid != null">productlotid,</if>
            <if test="ctl != null">ctl,</if>
            <if test="location != null">location,</if>
            <if test="productiondate != null">productionDate,</if>
            <if test="expirationdate != null">expirationDate,</if>
            <if test="shelfnum != null">shelfNum,</if>
            <if test="provider != null">provider,</if>
            <if test="status != null">status,</if>
            <if test="createtime != null">createTime,</if>
            <if test="username != null">userName,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="inspectid != null">#{inspectid},</if>
            <if test="goodsid != null and goodsid != ''">#{goodsid},</if>
            <if test="goodsname != null">#{goodsname},</if>
            <if test="productlotid != null">#{productlotid},</if>
            <if test="ctl != null">#{ctl},</if>
            <if test="location != null">#{location},</if>
            <if test="productiondate != null">#{productiondate},</if>
            <if test="expirationdate != null">#{expirationdate},</if>
            <if test="shelfnum != null">#{shelfnum},</if>
            <if test="provider != null">#{provider},</if>
            <if test="status != null">#{status},</if>
            <if test="createtime != null">#{createtime},</if>
            <if test="username != null">#{username},</if>
         </trim>
    </insert>

    <update id="updateTInspectReport" parameterType="TInspectReport">
        update t_inspect_report
        <trim prefix="SET" suffixOverrides=",">
            <if test="goodsid != null and goodsid != ''">goodsId = #{goodsid},</if>
            <if test="goodsname != null">goodsName = #{goodsname},</if>
            <if test="productlotid != null">productlotid = #{productlotid},</if>
            <if test="ctl != null">ctl = #{ctl},</if>
            <if test="location != null">location = #{location},</if>
            <if test="productiondate != null">productionDate = #{productiondate},</if>
            <if test="expirationdate != null">expirationDate = #{expirationdate},</if>
            <if test="shelfnum != null">shelfNum = #{shelfnum},</if>
            <if test="provider != null">provider = #{provider},</if>
            <if test="status != null">status = #{status},</if>
            <if test="createtime != null">createTime = #{createtime},</if>
            <if test="username != null">userName = #{username},</if>
        </trim>
        where inspectId = #{inspectid}
    </update>

    <delete id="deleteTInspectReportByInspectid" parameterType="String">
        delete from t_inspect_report where inspectId = #{inspectid}
    </delete>

    <delete id="deleteTInspectReportByInspectids" parameterType="String">
        delete from t_inspect_report where inspectId in 
        <foreach item="inspectid" collection="array" open="(" separator="," close=")">
            #{inspectid}
        </foreach>
    </delete>

</mapper>