<?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.cirs.biz.mapper.FactoryScoreMapper">
    
    <resultMap type="FactoryScore" id="FactoryScoreResult">
        <result property="id"    column="id"    />
        <result property="factoryName"    column="factory_name"    />
        <result property="factor1"    column="factor1"    />
        <result property="factor2"    column="factor2"    />
        <result property="factor3"    column="factor3"    />
        <result property="factor4"    column="factor4"    />
        <result property="factor5"    column="factor5"    />
        <result property="factor6"    column="factor6"    />
        <result property="factor7"    column="factor7"    />
        <result property="factor8"    column="factor8"    />
        <result property="factor9"    column="factor9"    />
        <result property="factor10"    column="factor10"    />
        <result property="factor11"    column="factor11"    />
        <result property="factor12"    column="factor12"    />
        <result property="factor13"    column="factor13"    />
        <result property="factor14"    column="factor14"    />
        <result property="factor15"    column="factor15"    />
        <result property="factor16"    column="factor16"    />
        <result property="factor17"    column="factor17"    />
        <result property="factor18"    column="factor18"    />
        <result property="factor19"    column="factor19"    />
        <result property="factor20"    column="factor20"    />
        <result property="factor21"    column="factor21"    />
        <result property="factor22"    column="factor22"    />
        <result property="factor23"    column="factor23"    />
        <result property="factor24"    column="factor24"    />
        <result property="factor25"    column="factor25"    />
        <result property="factor26"    column="factor26"    />
        <result property="factor27"    column="factor27"    />
        <result property="factor28"    column="factor28"    />
        <result property="factor29"    column="factor29"    />
        <result property="factor30"    column="factor30"    />
        <result property="factor31"    column="factor31"    />
        <result property="factor32"    column="factor32"    />
        <result property="factor33"    column="factor33"    />
        <result property="factor34"    column="factor34"    />
        <result property="factor35"    column="factor35"    />
        <result property="factor36"    column="factor36"    />
        <result property="factor37"    column="factor37"    />
        <result property="factor38"    column="factor38"    />
        <result property="factor39"    column="factor39"    />
        <result property="factor40"    column="factor40"    />
        <result property="factor41"    column="factor41"    />
        <result property="factor42"    column="factor42"    />
        <result property="factor43"    column="factor43"    />
        <result property="factor44"    column="factor44"    />
        <result property="finalGrade"    column="final_grade"    />
    </resultMap>

    <sql id="selectFactoryScoreVo">
        select id, factory_name, factor1, factor2, factor3, factor4, factor5, factor6, factor7, factor8, factor9, factor10, factor11, factor12, factor13, factor14, factor15, factor16, factor17, factor18, factor19, factor20, factor21, factor22, factor23, factor24, factor25, factor26, factor27, factor28, factor29, factor30, factor31, factor32, factor33, factor34, factor35, factor36, factor37, factor38, factor39, factor40, factor41, factor42, factor43, factor44, final_grade from factory_score
    </sql>

    <select id="selectFactoryScoreList" parameterType="FactoryScore" resultMap="FactoryScoreResult">
        <include refid="selectFactoryScoreVo"/>
        <where>  
            <if test="factoryName != null  and factoryName != ''"> and factory_name like concat('%', #{factoryName}, '%')</if>
            <if test="factor1 != null  and factor1 != ''"> and factor1 = #{factor1}</if>
            <if test="factor2 != null  and factor2 != ''"> and factor2 = #{factor2}</if>
            <if test="factor3 != null  and factor3 != ''"> and factor3 = #{factor3}</if>
            <if test="factor4 != null  and factor4 != ''"> and factor4 = #{factor4}</if>
            <if test="factor5 != null  and factor5 != ''"> and factor5 = #{factor5}</if>
            <if test="factor6 != null  and factor6 != ''"> and factor6 = #{factor6}</if>
            <if test="factor7 != null  and factor7 != ''"> and factor7 = #{factor7}</if>
            <if test="factor8 != null  and factor8 != ''"> and factor8 = #{factor8}</if>
            <if test="factor9 != null  and factor9 != ''"> and factor9 = #{factor9}</if>
            <if test="factor10 != null  and factor10 != ''"> and factor10 = #{factor10}</if>
            <if test="factor11 != null  and factor11 != ''"> and factor11 = #{factor11}</if>
            <if test="factor12 != null  and factor12 != ''"> and factor12 = #{factor12}</if>
            <if test="factor13 != null  and factor13 != ''"> and factor13 = #{factor13}</if>
            <if test="factor14 != null  and factor14 != ''"> and factor14 = #{factor14}</if>
            <if test="factor15 != null  and factor15 != ''"> and factor15 = #{factor15}</if>
            <if test="factor16 != null  and factor16 != ''"> and factor16 = #{factor16}</if>
            <if test="factor17 != null  and factor17 != ''"> and factor17 = #{factor17}</if>
            <if test="factor18 != null  and factor18 != ''"> and factor18 = #{factor18}</if>
            <if test="factor19 != null  and factor19 != ''"> and factor19 = #{factor19}</if>
            <if test="factor20 != null  and factor20 != ''"> and factor20 = #{factor20}</if>
            <if test="factor21 != null  and factor21 != ''"> and factor21 = #{factor21}</if>
            <if test="factor22 != null  and factor22 != ''"> and factor22 = #{factor22}</if>
            <if test="factor23 != null  and factor23 != ''"> and factor23 = #{factor23}</if>
            <if test="factor24 != null  and factor24 != ''"> and factor24 = #{factor24}</if>
            <if test="factor25 != null  and factor25 != ''"> and factor25 = #{factor25}</if>
            <if test="factor26 != null  and factor26 != ''"> and factor26 = #{factor26}</if>
            <if test="factor27 != null  and factor27 != ''"> and factor27 = #{factor27}</if>
            <if test="factor28 != null  and factor28 != ''"> and factor28 = #{factor28}</if>
            <if test="factor29 != null  and factor29 != ''"> and factor29 = #{factor29}</if>
            <if test="factor30 != null  and factor30 != ''"> and factor30 = #{factor30}</if>
            <if test="factor31 != null  and factor31 != ''"> and factor31 = #{factor31}</if>
            <if test="factor32 != null  and factor32 != ''"> and factor32 = #{factor32}</if>
            <if test="factor33 != null  and factor33 != ''"> and factor33 = #{factor33}</if>
            <if test="factor34 != null  and factor34 != ''"> and factor34 = #{factor34}</if>
            <if test="factor35 != null  and factor35 != ''"> and factor35 = #{factor35}</if>
            <if test="factor36 != null  and factor36 != ''"> and factor36 = #{factor36}</if>
            <if test="factor37 != null  and factor37 != ''"> and factor37 = #{factor37}</if>
            <if test="factor38 != null  and factor38 != ''"> and factor38 = #{factor38}</if>
            <if test="factor39 != null  and factor39 != ''"> and factor39 = #{factor39}</if>
            <if test="factor40 != null  and factor40 != ''"> and factor40 = #{factor40}</if>
            <if test="factor41 != null  and factor41 != ''"> and factor41 = #{factor41}</if>
            <if test="factor42 != null  and factor42 != ''"> and factor42 = #{factor42}</if>
            <if test="factor43 != null  and factor43 != ''"> and factor43 = #{factor43}</if>
            <if test="factor44 != null  and factor44 != ''"> and factor44 = #{factor44}</if>
            <if test="finalGrade != null  and finalGrade != ''"> and final_grade = #{finalGrade}</if>
        </where>
    </select>
    
    <select id="selectFactoryScoreById" parameterType="Long" resultMap="FactoryScoreResult">
        <include refid="selectFactoryScoreVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertFactoryScore" parameterType="FactoryScore" useGeneratedKeys="true" keyProperty="id">
        insert into factory_score
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="factoryName != null">factory_name,</if>
            <if test="factor1 != null">factor1,</if>
            <if test="factor2 != null">factor2,</if>
            <if test="factor3 != null">factor3,</if>
            <if test="factor4 != null">factor4,</if>
            <if test="factor5 != null">factor5,</if>
            <if test="factor6 != null">factor6,</if>
            <if test="factor7 != null">factor7,</if>
            <if test="factor8 != null">factor8,</if>
            <if test="factor9 != null">factor9,</if>
            <if test="factor10 != null">factor10,</if>
            <if test="factor11 != null">factor11,</if>
            <if test="factor12 != null">factor12,</if>
            <if test="factor13 != null">factor13,</if>
            <if test="factor14 != null">factor14,</if>
            <if test="factor15 != null">factor15,</if>
            <if test="factor16 != null">factor16,</if>
            <if test="factor17 != null">factor17,</if>
            <if test="factor18 != null">factor18,</if>
            <if test="factor19 != null">factor19,</if>
            <if test="factor20 != null">factor20,</if>
            <if test="factor21 != null">factor21,</if>
            <if test="factor22 != null">factor22,</if>
            <if test="factor23 != null">factor23,</if>
            <if test="factor24 != null">factor24,</if>
            <if test="factor25 != null">factor25,</if>
            <if test="factor26 != null">factor26,</if>
            <if test="factor27 != null">factor27,</if>
            <if test="factor28 != null">factor28,</if>
            <if test="factor29 != null">factor29,</if>
            <if test="factor30 != null">factor30,</if>
            <if test="factor31 != null">factor31,</if>
            <if test="factor32 != null">factor32,</if>
            <if test="factor33 != null">factor33,</if>
            <if test="factor34 != null">factor34,</if>
            <if test="factor35 != null">factor35,</if>
            <if test="factor36 != null">factor36,</if>
            <if test="factor37 != null">factor37,</if>
            <if test="factor38 != null">factor38,</if>
            <if test="factor39 != null">factor39,</if>
            <if test="factor40 != null">factor40,</if>
            <if test="factor41 != null">factor41,</if>
            <if test="factor42 != null">factor42,</if>
            <if test="factor43 != null">factor43,</if>
            <if test="factor44 != null">factor44,</if>
            <if test="finalGrade != null">final_grade,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="factoryName != null">#{factoryName},</if>
            <if test="factor1 != null">#{factor1},</if>
            <if test="factor2 != null">#{factor2},</if>
            <if test="factor3 != null">#{factor3},</if>
            <if test="factor4 != null">#{factor4},</if>
            <if test="factor5 != null">#{factor5},</if>
            <if test="factor6 != null">#{factor6},</if>
            <if test="factor7 != null">#{factor7},</if>
            <if test="factor8 != null">#{factor8},</if>
            <if test="factor9 != null">#{factor9},</if>
            <if test="factor10 != null">#{factor10},</if>
            <if test="factor11 != null">#{factor11},</if>
            <if test="factor12 != null">#{factor12},</if>
            <if test="factor13 != null">#{factor13},</if>
            <if test="factor14 != null">#{factor14},</if>
            <if test="factor15 != null">#{factor15},</if>
            <if test="factor16 != null">#{factor16},</if>
            <if test="factor17 != null">#{factor17},</if>
            <if test="factor18 != null">#{factor18},</if>
            <if test="factor19 != null">#{factor19},</if>
            <if test="factor20 != null">#{factor20},</if>
            <if test="factor21 != null">#{factor21},</if>
            <if test="factor22 != null">#{factor22},</if>
            <if test="factor23 != null">#{factor23},</if>
            <if test="factor24 != null">#{factor24},</if>
            <if test="factor25 != null">#{factor25},</if>
            <if test="factor26 != null">#{factor26},</if>
            <if test="factor27 != null">#{factor27},</if>
            <if test="factor28 != null">#{factor28},</if>
            <if test="factor29 != null">#{factor29},</if>
            <if test="factor30 != null">#{factor30},</if>
            <if test="factor31 != null">#{factor31},</if>
            <if test="factor32 != null">#{factor32},</if>
            <if test="factor33 != null">#{factor33},</if>
            <if test="factor34 != null">#{factor34},</if>
            <if test="factor35 != null">#{factor35},</if>
            <if test="factor36 != null">#{factor36},</if>
            <if test="factor37 != null">#{factor37},</if>
            <if test="factor38 != null">#{factor38},</if>
            <if test="factor39 != null">#{factor39},</if>
            <if test="factor40 != null">#{factor40},</if>
            <if test="factor41 != null">#{factor41},</if>
            <if test="factor42 != null">#{factor42},</if>
            <if test="factor43 != null">#{factor43},</if>
            <if test="factor44 != null">#{factor44},</if>
            <if test="finalGrade != null">#{finalGrade},</if>
         </trim>
    </insert>

    <update id="updateFactoryScore" parameterType="FactoryScore">
        update factory_score
        <trim prefix="SET" suffixOverrides=",">
            <if test="factoryName != null">factory_name = #{factoryName},</if>
            <if test="factor1 != null">factor1 = #{factor1},</if>
            <if test="factor2 != null">factor2 = #{factor2},</if>
            <if test="factor3 != null">factor3 = #{factor3},</if>
            <if test="factor4 != null">factor4 = #{factor4},</if>
            <if test="factor5 != null">factor5 = #{factor5},</if>
            <if test="factor6 != null">factor6 = #{factor6},</if>
            <if test="factor7 != null">factor7 = #{factor7},</if>
            <if test="factor8 != null">factor8 = #{factor8},</if>
            <if test="factor9 != null">factor9 = #{factor9},</if>
            <if test="factor10 != null">factor10 = #{factor10},</if>
            <if test="factor11 != null">factor11 = #{factor11},</if>
            <if test="factor12 != null">factor12 = #{factor12},</if>
            <if test="factor13 != null">factor13 = #{factor13},</if>
            <if test="factor14 != null">factor14 = #{factor14},</if>
            <if test="factor15 != null">factor15 = #{factor15},</if>
            <if test="factor16 != null">factor16 = #{factor16},</if>
            <if test="factor17 != null">factor17 = #{factor17},</if>
            <if test="factor18 != null">factor18 = #{factor18},</if>
            <if test="factor19 != null">factor19 = #{factor19},</if>
            <if test="factor20 != null">factor20 = #{factor20},</if>
            <if test="factor21 != null">factor21 = #{factor21},</if>
            <if test="factor22 != null">factor22 = #{factor22},</if>
            <if test="factor23 != null">factor23 = #{factor23},</if>
            <if test="factor24 != null">factor24 = #{factor24},</if>
            <if test="factor25 != null">factor25 = #{factor25},</if>
            <if test="factor26 != null">factor26 = #{factor26},</if>
            <if test="factor27 != null">factor27 = #{factor27},</if>
            <if test="factor28 != null">factor28 = #{factor28},</if>
            <if test="factor29 != null">factor29 = #{factor29},</if>
            <if test="factor30 != null">factor30 = #{factor30},</if>
            <if test="factor31 != null">factor31 = #{factor31},</if>
            <if test="factor32 != null">factor32 = #{factor32},</if>
            <if test="factor33 != null">factor33 = #{factor33},</if>
            <if test="factor34 != null">factor34 = #{factor34},</if>
            <if test="factor35 != null">factor35 = #{factor35},</if>
            <if test="factor36 != null">factor36 = #{factor36},</if>
            <if test="factor37 != null">factor37 = #{factor37},</if>
            <if test="factor38 != null">factor38 = #{factor38},</if>
            <if test="factor39 != null">factor39 = #{factor39},</if>
            <if test="factor40 != null">factor40 = #{factor40},</if>
            <if test="factor41 != null">factor41 = #{factor41},</if>
            <if test="factor42 != null">factor42 = #{factor42},</if>
            <if test="factor43 != null">factor43 = #{factor43},</if>
            <if test="factor44 != null">factor44 = #{factor44},</if>
            <if test="finalGrade != null">final_grade = #{finalGrade},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteFactoryScoreById" parameterType="Long">
        delete from factory_score where id = #{id}
    </delete>

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