<?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.SysTrainMapper">
    
    <resultMap type="SysTrain" id="SysTrainResult">
        <result property="id"    column="id"    />
        <result property="useScene"    column="use_scene"    />
        <result property="searchCondition"    column="search_condition"    />
        <result property="result1"    column="result1"    />
        <result property="result1Id"    column="result1_id"    />
        <result property="result2"    column="result2"    />
        <result property="result2Id"    column="result2_id"    />
        <result property="result3"    column="result3"    />
        <result property="result3Id"    column="result3_id"    />
        <result property="result4"    column="result4"    />
        <result property="result4Id"    column="result4_id"    />
        <result property="result5"    column="result5"    />
        <result property="result5Id"    column="result5_id"    />
    </resultMap>

    <resultMap type="TrainReturn" id="TrainReturn">

        <result property="useScene"    column="use_scene"    />
        <result property="searchCondition"    column="search_condition"    />

        <result property="result1Id"    column="result1_id"    />

        <result property="result2Id"    column="result2_id"    />

        <result property="result3Id"    column="result3_id"    />

        <result property="result4Id"    column="result4_id"    />

        <result property="result5Id"    column="result5_id"    />
    </resultMap>

    <resultMap type="VerificationData" id="VerificationData">
        <result property="id"    column="id"    />

        <result property="useScene" column="use_scene"/>
        <result property="searchCondition"    column="search_condition"    />

        <result property="result1Id"    column="result1_id"    />

        <result property="result2Id"    column="result2_id"    />

        <result property="result3Id"    column="result3_id"    />

        <result property="result4Id"    column="result4_id"    />

        <result property="result5Id"    column="result5_id"    />

        <result property="calculate1Id"    column="calculate1_id"    />

        <result property="calculate2Id"    column="calculate2_id"    />

        <result property="calculate3Id"    column="calculate3_id"    />

        <result property="calculate4Id"    column="calculate4_id"    />

        <result property="calculate5Id"    column="calculate5_id"    />

        <result property="trained"    column="trained"    />
        <result property="tested"    column="tested"    />
    </resultMap>
    <sql id="selectSysTrainVo">
        select id, use_scene, search_condition, result1, result2, result3, result4, result5 from sys_train
    </sql>

    <select id="selectSysTrainList" parameterType="SysTrain" resultMap="SysTrainResult">
        <include refid="selectSysTrainVo"/>
        <where>  
            <if test="useScene != null  and useScene != ''"> and use_scene = #{useScene}</if>
            <if test="searchCondition != null  and searchCondition != ''"> and search_condition = #{searchCondition}</if>
            <if test="result1 != null  and result1 != ''"> and result1 = #{result1}</if>
            <if test="result2 != null  and result2 != ''"> and result2 = #{result2}</if>
            <if test="result3 != null  and result3 != ''"> and result3 = #{result3}</if>
            <if test="result4 != null  and result4 != ''"> and result4 = #{result4}</if>
            <if test="result5 != null  and result5 != ''"> and result5 = #{result5}</if>
        </where>
    </select>
    
    <select id="selectSysTrainById" parameterType="Long" resultMap="SysTrainResult">
        <include refid="selectSysTrainVo"/>
        where id = #{id}
    </select>
    <select id="getComponentId" resultType="java.lang.Long">
        select id from t_electron_component
              <where>
                  <if test="attr != null  and attr != ''"> AND t_electron_component.component_model=#{attr}</if>
                  <if test="attr1 != null  and attr1 != ''"> AND t_electron_component.quality_grade=#{attr1}</if>
                  <if test="attr2 != null  and attr2 != ''"> AND t_electron_component.component_name=#{attr2}</if>
              </where>

        LIMIT 1
    </select>


    <select id="getall_data" resultMap="SysTrainResult">
        select id, use_scene, search_condition, result1,result1_id, result2,result2_id, result3,result3_id, result4,result4_id, result5,result5_id from sys_train
    </select>
    <select id="getComponentids" resultMap="TrainReturn">
        select use_scene, search_condition, result1_id, result2_id, result3_id, result4_id, result5_id from sys_train
    </select>
    <select id="gettraindataset" resultMap="VerificationData">
        select use_scene, search_condition, result1_id, result2_id, result3_id, result4_id, result5_id from sys_train
    </select>


    <insert id="insertSysTrain" parameterType="SysTrain">
        insert into sys_train
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="useScene != null">use_scene,</if>
            <if test="searchCondition != null">search_condition,</if>
            <if test="result1 != null">result1,</if>
            <if test="result1 != null">result1_id,</if>
            <if test="result2 != null">result2,</if>
            <if test="result2 != null">result2_id,</if>
            <if test="result3 != null">result3,</if>
            <if test="result3 != null">result3_id,</if>
            <if test="result4 != null">result4,</if>
            <if test="result4 != null">result4_id,</if>
            <if test="result5 != null">result5,</if>
            <if test="result5 != null">result5_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="useScene != null">#{useScene},</if>
            <if test="searchCondition != null">#{searchCondition},</if>
            <if test="result1 != null">#{result1},</if>
            <if test="result1 != null">#{result1Id},</if>
            <if test="result2 != null">#{result2},</if>
            <if test="result2 != null">#{result2Id},</if>
            <if test="result3 != null">#{result3},</if>
            <if test="result3 != null">#{result3Id},</if>
            <if test="result4 != null">#{result4},</if>
            <if test="result4 != null">#{result4Id},</if>
            <if test="result5 != null">#{result5},</if>
            <if test="result5 != null">#{result5Id},</if>
         </trim>
    </insert>

    <update id="updateSysTrain" parameterType="SysTrain">
        update sys_train
        <trim prefix="SET" suffixOverrides=",">
            <if test="useScene != null">use_scene = #{useScene},</if>
            <if test="searchCondition != null">search_condition = #{searchCondition},</if>
            <if test="result1 != null">result1 = #{result1},</if>
            <if test="result1Id != null">result1_id = #{result1Id},</if>
            <if test="result2 != null">result2 = #{result2},</if>
            <if test="result2Id != null">result2_id = #{result2Id},</if>
            <if test="result3 != null">result3 = #{result3},</if>
            <if test="result3Id != null">result3_id = #{result3Id},</if>
            <if test="result4 != null">result4 = #{result4},</if>
            <if test="result4Id != null">result4_id = #{result4Id},</if>
            <if test="result5 != null">result5 = #{result5},</if>
            <if test="result5Id != null">result5_id = #{result5Id},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysTrainById" parameterType="Long">
        delete from sys_train where id = #{id}
    </delete>

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