<?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.hw.dms.mapper.DmsBillsInspectInstanceMapper">

    <resultMap type="DmsBillsInspectInstance" id="DmsBillsInspectInstanceResult">
        <result property="inspectInstanceId"    column="inspect_instance_id"    />
        <result property="planInspectId"    column="plan_inspect_id"    />
        <result property="wfProcessId"    column="wf_process_id"    />
        <result property="inspectType"    column="inspect_type"    />
        <result property="billsInspectCode"    column="bills_inspect_code"    />
        <result property="deviceAmount"    column="device_amount"    />
        <result property="planBeginTime"    column="plan_begin_time"    />
        <result property="planEndTime"    column="plan_end_time"    />
        <result property="realBeginTime"    column="real_begin_time"    />
        <result property="realEndTime"    column="real_end_time"    />
        <result property="performer"    column="performer"    />
        <result property="inspectStatus"    column="inspect_status"    />
        <result property="isFlag"    column="is_flag"    />
        <result property="remark"    column="remark"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectDmsBillsInspectInstanceVo">
        select inspect_instance_id, plan_inspect_id, wf_process_id, inspect_type, bills_inspect_code,   plan_begin_time,plan_end_time, real_begin_time, real_end_time,  inspect_status, is_flag, remark, create_by, create_time, update_by, update_time from dms_bills_inspect_instance
    </sql>

    <select id="selectDmsBillsInspectInstanceList" parameterType="DmsBillsInspectInstance" resultMap="DmsBillsInspectInstanceResult">
        <include refid="selectDmsBillsInspectInstanceVo"/>
        <where>
            <if test="planInspectId != null "> and plan_inspect_id = #{planInspectId}</if>
            <if test="wfProcessId != null "> and wf_process_id = #{wfProcessId}</if>
            <if test="inspectType != null  and inspectType != ''"> and inspect_type = #{inspectType}</if>
            <if test="billsInspectCode != null  and billsInspectCode != ''"> and bills_inspect_code = #{billsInspectCode}</if>
            <if test="deviceAmount != null "> and device_amount = #{deviceAmount}</if>
            <if test="planBeginTime != null "> and plan_begin_time = #{planBeginTime}</if>
            <if test="planEndTime != null "> and plan_end_time = #{planEndTime}</if>
            <if test="realBeginTime != null "> and real_begin_time = #{realBeginTime}</if>
            <if test="realEndTime != null "> and real_end_time = #{realEndTime}</if>
            <if test="performer != null  and performer != ''"> and performer = #{performer}</if>
            <if test="inspectStatus != null  and inspectStatus != ''"> and inspect_status = #{inspectStatus}</if>
            <if test="isFlag != null  and isFlag != ''"> and is_flag = #{isFlag}</if>
        </where>
    </select>

    <select id="selectDmsBillsInspectInstanceByInspectInstanceId" parameterType="Long" resultMap="DmsBillsInspectInstanceResult">
        <include refid="selectDmsBillsInspectInstanceVo"/>
        where inspect_instance_id = #{inspectInstanceId}
    </select>

    <insert id="insertDmsBillsInspectInstance" parameterType="DmsBillsInspectInstance" useGeneratedKeys="true" keyProperty="inspectInstanceId">
        insert into dms_bills_inspect_instance
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="planInspectId != null">plan_inspect_id,</if>
            <if test="wfProcessId != null">wf_process_id,</if>
            <if test="inspectType != null and inspectType != ''">inspect_type,</if>
            <if test="billsInspectCode != null">bills_inspect_code,</if>
            <if test="deviceAmount != null">device_amount,</if>
            <if test="planBeginTime != null">plan_begin_time,</if>
            <if test="planEndTime != null">plan_end_time,</if>
            <if test="realBeginTime != null">real_begin_time,</if>
            <if test="realEndTime != null">real_end_time,</if>
            <if test="performer != null">performer,</if>
            <if test="inspectStatus != null">inspect_status,</if>
            <if test="isFlag != null and isFlag != ''">is_flag,</if>
            <if test="remark != null">remark,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="planInspectId != null">#{planInspectId},</if>
            <if test="wfProcessId != null">#{wfProcessId},</if>
            <if test="inspectType != null and inspectType != ''">#{inspectType},</if>
            <if test="billsInspectCode != null">#{billsInspectCode},</if>
            <if test="deviceAmount != null">#{deviceAmount},</if>
            <if test="planBeginTime != null">#{planBeginTime},</if>
            <if test="planEndTime != null">#{planEndTime},</if>
            <if test="realBeginTime != null">#{realBeginTime},</if>
            <if test="realEndTime != null">#{realEndTime},</if>
            <if test="performer != null">#{performer},</if>
            <if test="inspectStatus != null">#{inspectStatus},</if>
            <if test="isFlag != null and isFlag != ''">#{isFlag},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateDmsBillsInspectInstance" parameterType="DmsBillsInspectInstance">
        update dms_bills_inspect_instance
        <trim prefix="SET" suffixOverrides=",">
            <if test="planInspectId != null">plan_inspect_id = #{planInspectId},</if>
            <if test="wfProcessId != null">wf_process_id = #{wfProcessId},</if>
            <if test="inspectType != null and inspectType != ''">inspect_type = #{inspectType},</if>
            <if test="billsInspectCode != null">bills_inspect_code = #{billsInspectCode},</if>
            <if test="deviceAmount != null">device_amount = #{deviceAmount},</if>
            <if test="planBeginTime != null">plan_begin_time = #{planBeginTime},</if>
            <if test="planEndTime != null">plan_end_time = #{planEndTime},</if>
            <if test="realBeginTime != null">real_begin_time = #{realBeginTime},</if>
            <if test="realEndTime != null">real_end_time = #{realEndTime},</if>
            <if test="performer != null">performer = #{performer},</if>
            <if test="inspectStatus != null">inspect_status = #{inspectStatus},</if>
            <if test="isFlag != null and isFlag != ''">is_flag = #{isFlag},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where inspect_instance_id = #{inspectInstanceId}
    </update>

    <delete id="deleteDmsBillsInspectInstanceByInspectInstanceId" parameterType="Long">
        delete from dms_bills_inspect_instance where inspect_instance_id = #{inspectInstanceId}
    </delete>

    <delete id="deleteDmsBillsInspectInstanceByInspectInstanceIds" parameterType="String">
        delete from dms_bills_inspect_instance where inspect_instance_id in
        <foreach item="inspectInstanceId" collection="array" open="(" separator="," close=")">
            #{inspectInstanceId}
        </foreach>
    </delete>
</mapper>
