<?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.cpms.project.process.mapper.TSisRecordMapper">
    
    <resultMap type="TSisRecord" id="TSisRecordResult">
        <result property="id"    column="id"    />
        <result property="sisId"    column="sis_id"    />
        <result property="sensorTag"    column="sensor_tag"    />
        <result property="type"    column="type"    />
        <result property="service"    column="service"    />
        <result property="votingQ"    column="voting_q"    />
        <result property="condition"    column="condition"    />
        <result property="mainPti"    column="main_pti"    />
        <result property="finalElementTag"    column="final_element_tag"    />
        <result property="votingH"    column="voting_h"    />
        <result property="action"    column="action"    />
        <result property="mainPtiH"    column="main_pti_h"    />
        <result property="h"    column="h"    />
        <result property="hType"    column="h_type"    />
        <result property="hService"    column="h_service"    />
        <result property="filter"    column="filter"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createrCode"    column="creater_code"    />
        <result property="createdate"    column="createdate"    />
        <result property="updaterCode"    column="updater_code"    />
        <result property="updatedate"    column="updatedate"    />
        <result property="deptId"    column="dept_id"    />
    </resultMap>

    <sql id="selectTSisRecordVo">
        select id, sis_id, sensor_tag, type, service, voting_q, `condition`, main_pti,main_pti_h, final_element_tag,h,h_type,h_service,voting_h, `action`, `filter`, del_flag, creater_code, createdate, updater_code, updatedate, dept_id from t_sis_record
    </sql>

    <select id="selectTSisRecordList" parameterType="TSisRecord" resultMap="TSisRecordResult">
        <include refid="selectTSisRecordVo"/>
        <where>  
            <if test="sisId != null "> and sis_id = #{sisId}</if>
            <if test="sensorTag != null  and sensorTag != ''"> and sensor_tag = #{sensorTag}</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="service != null  and service != ''"> and service = #{service}</if>
            <if test="votingQ != null  and votingQ != ''"> and voting_q = #{votingQ}</if>
            <if test="condition != null  and condition != ''"> and `condition` = #{condition}</if>
            <if test="mainPti != null  and mainPti != ''"> and main_pti = #{mainPti}</if>
            <if test="finalElementTag != null  and finalElementTag != ''"> and final_element_tag = #{finalElementTag}</if>
            <if test="votingH != null  and votingH != ''"> and voting_h = #{votingH}</if>
            <if test="action != null  and action != ''"> and `action` = #{action}</if>
            <if test="filter != null  and filter != ''"> and `filter` = #{filter}</if>
            <if test="createrCode != null  and createrCode != ''"> and creater_code = #{createrCode}</if>
            <if test="createdate != null "> and createdate = #{createdate}</if>
            <if test="updaterCode != null  and updaterCode != ''"> and updater_code = #{updaterCode}</if>
            <if test="updatedate != null "> and updatedate = #{updatedate}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
        and del_flag=0
        </where>
    </select>
    
    <select id="selectTSisRecordById" parameterType="Long" resultMap="TSisRecordResult">
        <include refid="selectTSisRecordVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTSisRecord" parameterType="TSisRecord" useGeneratedKeys="true" keyProperty="id">
        insert into t_sis_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="sisId != null">sis_id,</if>
            <if test="sensorTag != null">sensor_tag,</if>
            <if test="type != null">type,</if>
            <if test="service != null">service,</if>
            <if test="votingQ != null">voting_q,</if>
            <if test="condition != null">`condition`,</if>
            <if test="mainPti != null">main_pti,</if>
            <if test="mainPtiH != null">main_pti_h,</if>
            <if test="finalElementTag != null">final_element_tag,</if>
            <if test="h != null">h,</if>
            <if test="hType != null">h_type,</if>
            <if test="hService != null">h_service,</if>
            <if test="votingH != null">voting_h,</if>
            <if test="action != null">`action`,</if>
            <if test="filter != null">`filter`,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createrCode != null">creater_code,</if>
            <if test="createdate != null">createdate,</if>
            <if test="updaterCode != null">updater_code,</if>
            <if test="updatedate != null">updatedate,</if>
            <if test="deptId != null">dept_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="sisId != null">#{sisId},</if>
            <if test="sensorTag != null">#{sensorTag},</if>
            <if test="type != null">#{type},</if>
            <if test="service != null">#{service},</if>
            <if test="votingQ != null">#{votingQ},</if>
            <if test="condition != null">#{condition},</if>
            <if test="mainPti != null">#{mainPti},</if>
            <if test="mainPtiH != null">#{mainPtiH},</if>
            <if test="finalElementTag != null">#{finalElementTag},</if>
            <if test="h != null">#{h},</if>
            <if test="hType != null">#{hType},</if>
            <if test="hService != null">#{hService},</if>
            <if test="votingH != null">#{votingH},</if>
            <if test="action != null">#{action},</if>
            <if test="filter != null">#{filter},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createrCode != null">#{createrCode},</if>
            <if test="createdate != null">#{createdate},</if>
            <if test="updaterCode != null">#{updaterCode},</if>
            <if test="updatedate != null">#{updatedate},</if>
            <if test="deptId != null">#{deptId},</if>
         </trim>
    </insert>

    <update id="updateTSisRecord" parameterType="TSisRecord">
        update t_sis_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="sisId != null">sis_id = #{sisId},</if>
            <if test="sensorTag != null">sensor_tag = #{sensorTag},</if>
            <if test="type != null">type = #{type},</if>
            <if test="service != null">service = #{service},</if>
            <if test="votingQ != null">voting_q = #{votingQ},</if>
            <if test="condition != null">`condition` = #{condition},</if>
            <if test="mainPti != null">main_pti = #{mainPti},</if>
            <if test="mainPtiH != null">main_pti_h = #{mainPtiH},</if>
            <if test="finalElementTag != null">final_element_tag = #{finalElementTag},</if>
            <if test="h != null">h = #{h},</if>
            <if test="hType != null">h_type = #{hType},</if>
            <if test="hService != null">h_service = #{hService},</if>
            <if test="votingH != null">voting_h = #{votingH},</if>
            <if test="action != null">`action` = #{action},</if>
            <if test="filter != null">`filter` = #{filter},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createrCode != null">creater_code = #{createrCode},</if>
            <if test="createdate != null">createdate = #{createdate},</if>
            <if test="updaterCode != null">updater_code = #{updaterCode},</if>
            <if test="updatedate != null">updatedate = #{updatedate},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTSisRecordById" parameterType="Long">
        delete from t_sis_record where id = #{id}
    </delete>

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