<?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.zehong.system.mapper.TInspectionResultMapper">

    <resultMap type="com.zehong.system.domain.TInspectionResult" id="TInspectionResultResult">
        <result property="id"    column="id"    />
        <result property="enterpriseId"    column="enterprise_id"    />
        <result property="enterpriseName"    column="enterprise_name"    />
        <result property="inspectionMonth"    column="inspection_month"    />
        <result property="inspectionName"    column="inspection_name"    />
        <result property="inspectionType"    column="inspection_type"    />
        <result property="shouldInspectionNum"    column="should_inspection_num"    />
        <result property="completeInspectionNum"    column="complete_inspection_num"    />
        <result property="anomalyNum"    column="anomaly_num"    />
        <result property="rectifyNum"    column="rectify_num"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectTInspectionResultVo">
        select id, enterprise_id, enterprise_name, inspection_month, inspection_name, inspection_type, should_inspection_num, complete_inspection_num, anomaly_num, rectify_num, create_time from t_inspection_result
    </sql>

    <select id="selectTInspectionResultList" parameterType="com.zehong.system.domain.TInspectionResult" resultMap="TInspectionResultResult">
        <include refid="selectTInspectionResultVo"/>
        <where>
            <if test="enterpriseId != null  and enterpriseId != ''"> and enterprise_id = #{enterpriseId}</if>
            <if test="enterpriseName != null  and enterpriseName != ''"> and enterprise_name like concat('%', #{enterpriseName}, '%')</if>
            <if test="inspectionMonth != null  and inspectionMonth != ''"> and inspection_month = #{inspectionMonth}</if>
            <if test="inspectionName != null  and inspectionName != ''"> and inspection_name like concat('%', #{inspectionName}, '%')</if>
            <if test="inspectionType != null  and inspectionType != ''"> and inspection_type = #{inspectionType}</if>
            <if test="shouldInspectionNum != null  and shouldInspectionNum != ''"> and should_inspection_num = #{shouldInspectionNum}</if>
            <if test="completeInspectionNum != null  and completeInspectionNum != ''"> and complete_inspection_num = #{completeInspectionNum}</if>
            <if test="anomalyNum != null  and anomalyNum != ''"> and anomaly_num = #{anomalyNum}</if>
            <if test="rectifyNum != null  and rectifyNum != ''"> and rectify_num = #{rectifyNum}</if>
        </where>
    </select>

    <select id="selectTInspectionResultById" parameterType="Long" resultMap="TInspectionResultResult">
        <include refid="selectTInspectionResultVo"/>
        where id = #{id}
    </select>

    <insert id="insertTInspectionResult" parameterType="com.zehong.system.domain.TInspectionResult" useGeneratedKeys="true" keyProperty="id">
        insert into t_inspection_result
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="enterpriseId != null">enterprise_id,</if>
            <if test="enterpriseName != null">enterprise_name,</if>
            <if test="inspectionMonth != null">inspection_month,</if>
            <if test="inspectionName != null">inspection_name,</if>
            <if test="inspectionType != null">inspection_type,</if>
            <if test="shouldInspectionNum != null">should_inspection_num,</if>
            <if test="completeInspectionNum != null">complete_inspection_num,</if>
            <if test="anomalyNum != null">anomaly_num,</if>
            <if test="rectifyNum != null">rectify_num,</if>
            <if test="createTime != null">create_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="enterpriseId != null">#{enterpriseId},</if>
            <if test="enterpriseName != null">#{enterpriseName},</if>
            <if test="inspectionMonth != null">#{inspectionMonth},</if>
            <if test="inspectionName != null">#{inspectionName},</if>
            <if test="inspectionType != null">#{inspectionType},</if>
            <if test="shouldInspectionNum != null">#{shouldInspectionNum},</if>
            <if test="completeInspectionNum != null">#{completeInspectionNum},</if>
            <if test="anomalyNum != null">#{anomalyNum},</if>
            <if test="rectifyNum != null">#{rectifyNum},</if>
            <if test="createTime != null">#{createTime},</if>
        </trim>
    </insert>

    <update id="updateTInspectionResult" parameterType="com.zehong.system.domain.TInspectionResult">
        update t_inspection_result
        <trim prefix="SET" suffixOverrides=",">
            <if test="enterpriseId != null">enterprise_id = #{enterpriseId},</if>
            <if test="enterpriseName != null">enterprise_name = #{enterpriseName},</if>
            <if test="inspectionMonth != null">inspection_month = #{inspectionMonth},</if>
            <if test="inspectionName != null">inspection_name = #{inspectionName},</if>
            <if test="inspectionType != null">inspection_type = #{inspectionType},</if>
            <if test="shouldInspectionNum != null">should_inspection_num = #{shouldInspectionNum},</if>
            <if test="completeInspectionNum != null">complete_inspection_num = #{completeInspectionNum},</if>
            <if test="anomalyNum != null">anomaly_num = #{anomalyNum},</if>
            <if test="rectifyNum != null">rectify_num = #{rectifyNum},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTInspectionResultById" parameterType="Long">
        delete from t_inspection_result where id = #{id}
    </delete>

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