<?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.ygtx.gxt.mapper.GxtCoefficientScoreMapper">
    
    <resultMap type="GxtCoefficientScore" id="GxtCoefficientScoreResult">
        <result property="id"    column="id"/>
        <result property="subitemCoefficient"    column="subitem_coefficient"/>
        <result property="subitemCoefficientSum"    column="subitem_coefficient_sum"/>
        <result property="plannedCount"    column="planned_count"/>
        <result property="actualCount"    column="actual_count"/>
        <result property="explainCode"    column="explain_code"/>
        <result property="groupDeduction"    column="group_deduction"/>
        <result property="monthPeriod"    column="month_period"/>
        <result property="status"    column="status"/>
        <result property="detpName"    column="detp_name"/>
        <result property="repairOrderCoefficient"    column="repair_order_coefficient"/>
        <result property="workOrderCoefficient"    column="work_order_coefficient"/>
        <result property="deptId"    column="dept_id"/>
        <result property="createBy"    column="create_by"/>
        <result property="createTime"    column="create_time"/>
        <result property="updateBy"    column="update_by"/>
        <result property="updateTime"    column="update_time"/>
        <result property="remark"    column="remark"/>
    </resultMap>

    <sql id="selectGxtCoefficientScoreVo">
        select id, subitem_coefficient, subitem_coefficient_sum, explain_code, planned_count, actual_count, group_deduction, month_period, status, detp_name, repair_order_coefficient, work_order_coefficient, dept_id, create_by, create_time, update_by, update_time, remark from gxt_coefficient_score
    </sql>

    <select id="selectGxtCoefficientScoreById" parameterType="Long" resultMap="GxtCoefficientScoreResult">
        <include refid="selectGxtCoefficientScoreVo"/>
        where id = #{id}
    </select>

    <select id="selectGxtCoefficientScoreList" parameterType="GxtCoefficientScore" resultMap="GxtCoefficientScoreResult">
        <include refid="selectGxtCoefficientScoreVo"/>
        <where>  
            <if test="subitemCoefficient != null "> and subitem_coefficient = #{subitemCoefficient}</if>
            <if test="subitemCoefficientSum != null "> and subitem_coefficient_sum = #{subitemCoefficientSum}</if>
            <if test="plannedCount != null "> and planned_count = #{plannedCount}</if>
            <if test="actualCount != null "> and actual_count = #{actualCount}</if>
            <if test="explainCode != null and explainCode != '' "> and explain_code = #{explainCode}</if>
            <if test="groupDeduction != null "> and group_deduction = #{groupDeduction}</if>
            <if test="monthPeriod != null  and monthPeriod != ''"> and month_period = #{monthPeriod}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="detpName != null  and detpName != ''"> and detp_name = #{detpName}</if>
            <if test="repairOrderCoefficient != null "> and repair_order_coefficient = #{repairOrderCoefficient}</if>
            <if test="workOrderCoefficient != null "> and work_order_coefficient = #{workOrderCoefficient}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
        </where>
        order by create_time desc
    </select>
    
    <insert id="insertGxtCoefficientScore" parameterType="GxtCoefficientScore" useGeneratedKeys="true" keyProperty="id">
        insert into gxt_coefficient_score
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="subitemCoefficient != null">subitem_coefficient,</if>
            <if test="subitemCoefficientSum != null">subitem_coefficient_sum,</if>
            <if test="plannedCount != null">planned_count,</if>
            <if test="actualCount != null">actual_count,</if>
            <if test="explainCode != null and explainCode != ''">explain_code,</if>
            <if test="groupDeduction != null">group_deduction,</if>
            <if test="monthPeriod != null and monthPeriod != ''">month_period,</if>
            <if test="status != null">status,</if>
            <if test="detpName != null and detpName != ''">detp_name,</if>
            <if test="repairOrderCoefficient != null">repair_order_coefficient,</if>
            <if test="workOrderCoefficient != null">work_order_coefficient,</if>
            <if test="deptId != null">dept_id,</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>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="subitemCoefficient != null">#{subitemCoefficient},</if>
            <if test="subitemCoefficientSum != null">#{subitemCoefficientSum},</if>
            <if test="plannedCount != null">#{plannedCount},</if>
            <if test="actualCount != null">#{actualCount},</if>
            <if test="explainCode != null and explainCode != ''">#{explainCode},</if>
            <if test="groupDeduction != null">#{groupDeduction},</if>
            <if test="monthPeriod != null and monthPeriod != ''">#{monthPeriod},</if>
            <if test="status != null">#{status},</if>
            <if test="detpName != null and detpName != ''">#{detpName},</if>
            <if test="repairOrderCoefficient != null">#{repairOrderCoefficient},</if>
            <if test="workOrderCoefficient != null">#{workOrderCoefficient},</if>
            <if test="deptId != null">#{deptId},</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>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateGxtCoefficientScore" parameterType="GxtCoefficientScore">
        update gxt_coefficient_score
        <trim prefix="SET" suffixOverrides=",">
            <if test="subitemCoefficient != null">subitem_coefficient = #{subitemCoefficient},</if>
            <if test="subitemCoefficientSum != null">subitem_coefficient_sum = #{subitemCoefficientSum},</if>
            <if test="plannedCount != null">planned_count = #{plannedCount},</if>
            <if test="actualCount != null">actual_count = #{actualCount},</if>
            <if test="explainCode != null and explainCode != ''">explain_code = #{explainCode},</if>
            <if test="groupDeduction != null">group_deduction = #{groupDeduction},</if>
            <if test="monthPeriod != null and monthPeriod != ''">month_period = #{monthPeriod},</if>
            <if test="status != null">status = #{status},</if>
            <if test="detpName != null and detpName != ''">detp_name = #{detpName},</if>
            <if test="repairOrderCoefficient != null">repair_order_coefficient = #{repairOrderCoefficient},</if>
            <if test="workOrderCoefficient != null">work_order_coefficient = #{workOrderCoefficient},</if>
            <if test="deptId != null">dept_id = #{deptId},</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>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteGxtCoefficientScoreById" parameterType="Long">
        delete from gxt_coefficient_score where id = #{id}
    </delete>

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