<?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.ruoyi.system.mapper.TDeviceSetMapper">
    
    <resultMap type="TDeviceSet" id="TDeviceSetResult">
        <result property="id"    column="id"    />
        <result property="deviceIdCode"    column="device_id_code"    />
        <result property="sostelno1"    column="sostelno1"    />
        <result property="sostelno2"    column="sostelno2"    />
        <result property="gpsInterval"    column="gps_interval"    />
        <result property="heartInterval"    column="heart_interval"    />
        <result property="bodyInterval"    column="body_interval"    />
        <result property="bloodInterval"    column="blood_interval"    />
        <result property="oxygenInterval"    column="oxygen_interval"    />
        <result property="stepStatus"    column="step_status"    />
        <result property="contactPer1"    column="contact_per1"    />
        <result property="contactTel1"    column="contact_tel1"    />
        <result property="contactPer2"    column="contact_per2"    />
        <result property="contactTel2"    column="contact_tel2"    />
        <result property="contactPer3"    column="contact_per3"    />
        <result property="contactTel3"    column="contact_tel3"    />
        <result property="timeStatus"    column="time_status"    />
        <result property="timeBegin"    column="time_begin"    />
        <result property="timeEnd"    column="time_end"    />
        <result property="useStatus"    column="use_status"    />
        <result property="fallStatus"    column="fall_status"    />
        <result property="levelStatus"    column="level_status"    />
    </resultMap>

    <sql id="selectTDeviceSetVo">
        select id, device_id_code, sostelno1, sostelno2, gps_interval, heart_interval, body_interval, blood_interval, oxygen_interval, step_status, contact_per1, contact_tel1, contact_per2, contact_tel2, contact_per3, contact_tel3, time_status, time_begin, time_end, use_status, fall_status, level_status from t_device_set
    </sql>

    <select id="selectTDeviceSetList" parameterType="TDeviceSet" resultMap="TDeviceSetResult">
        <include refid="selectTDeviceSetVo"/>
        <where>  
            <if test="deviceIdCode != null  and deviceIdCode != ''"> and device_id_code = #{deviceIdCode}</if>
            <if test="sostelno1 != null  and sostelno1 != ''"> and sostelno1 = #{sostelno1}</if>
            <if test="sostelno2 != null  and sostelno2 != ''"> and sostelno2 = #{sostelno2}</if>
            <if test="gpsInterval != null  and gpsInterval != ''"> and gps_interval = #{gpsInterval}</if>
            <if test="heartInterval != null  and heartInterval != ''"> and heart_interval = #{heartInterval}</if>
            <if test="bodyInterval != null  and bodyInterval != ''"> and body_interval = #{bodyInterval}</if>
            <if test="bloodInterval != null  and bloodInterval != ''"> and blood_interval = #{bloodInterval}</if>
            <if test="oxygenInterval != null  and oxygenInterval != ''"> and oxygen_interval = #{oxygenInterval}</if>
            <if test="stepStatus != null "> and step_status = #{stepStatus}</if>
            <if test="contactPer1 != null  and contactPer1 != ''"> and contact_per1 = #{contactPer1}</if>
            <if test="contactTel1 != null  and contactTel1 != ''"> and contact_tel1 = #{contactTel1}</if>
            <if test="contactPer2 != null  and contactPer2 != ''"> and contact_per2 = #{contactPer2}</if>
            <if test="contactTel2 != null  and contactTel2 != ''"> and contact_tel2 = #{contactTel2}</if>
            <if test="contactPer3 != null  and contactPer3 != ''"> and contact_per3 = #{contactPer3}</if>
            <if test="contactTel3 != null  and contactTel3 != ''"> and contact_tel3 = #{contactTel3}</if>
            <if test="timeStatus != null "> and time_status = #{timeStatus}</if>
            <if test="timeBegin != null  and timeBegin != ''"> and time_begin = #{timeBegin}</if>
            <if test="timeEnd != null  and timeEnd != ''"> and time_end = #{timeEnd}</if>
            <if test="useStatus != null "> and use_status = #{useStatus}</if>
            <if test="fallStatus != null "> and fall_status = #{fallStatus}</if>
            <if test="levelStatus != null "> and level_status = #{levelStatus}</if>
        </where>
    </select>
    
    <select id="selectTDeviceSetById" parameterType="Integer" resultMap="TDeviceSetResult">
        <include refid="selectTDeviceSetVo"/>
        where id = #{id}
    </select>
    <select id="selectTDeviceSetByCode" resultMap="TDeviceSetResult">
        <include refid="selectTDeviceSetVo"/>
        where device_id_code = #{device_id_code}
    </select>

    <insert id="insertTDeviceSet" parameterType="TDeviceSet" useGeneratedKeys="true" keyProperty="id">
        insert into t_device_set
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="deviceIdCode != null">device_id_code,</if>
            <if test="sostelno1 != null">sostelno1,</if>
            <if test="sostelno2 != null">sostelno2,</if>
            <if test="gpsInterval != null">gps_interval,</if>
            <if test="heartInterval != null">heart_interval,</if>
            <if test="bodyInterval != null">body_interval,</if>
            <if test="bloodInterval != null">blood_interval,</if>
            <if test="oxygenInterval != null">oxygen_interval,</if>
            <if test="stepStatus != null">step_status,</if>
            <if test="contactPer1 != null">contact_per1,</if>
            <if test="contactTel1 != null">contact_tel1,</if>
            <if test="contactPer2 != null">contact_per2,</if>
            <if test="contactTel2 != null">contact_tel2,</if>
            <if test="contactPer3 != null">contact_per3,</if>
            <if test="contactTel3 != null">contact_tel3,</if>
            <if test="timeStatus != null">time_status,</if>
            <if test="timeBegin != null">time_begin,</if>
            <if test="timeEnd != null">time_end,</if>
            <if test="useStatus != null">use_status,</if>
            <if test="fallStatus != null">fall_status,</if>
            <if test="levelStatus != null">level_status,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="deviceIdCode != null">#{deviceIdCode},</if>
            <if test="sostelno1 != null">#{sostelno1},</if>
            <if test="sostelno2 != null">#{sostelno2},</if>
            <if test="gpsInterval != null">#{gpsInterval},</if>
            <if test="heartInterval != null">#{heartInterval},</if>
            <if test="bodyInterval != null">#{bodyInterval},</if>
            <if test="bloodInterval != null">#{bloodInterval},</if>
            <if test="oxygenInterval != null">#{oxygenInterval},</if>
            <if test="stepStatus != null">#{stepStatus},</if>
            <if test="contactPer1 != null">#{contactPer1},</if>
            <if test="contactTel1 != null">#{contactTel1},</if>
            <if test="contactPer2 != null">#{contactPer2},</if>
            <if test="contactTel2 != null">#{contactTel2},</if>
            <if test="contactPer3 != null">#{contactPer3},</if>
            <if test="contactTel3 != null">#{contactTel3},</if>
            <if test="timeStatus != null">#{timeStatus},</if>
            <if test="timeBegin != null">#{timeBegin},</if>
            <if test="timeEnd != null">#{timeEnd},</if>
            <if test="useStatus != null">#{useStatus},</if>
            <if test="fallStatus != null">#{fallStatus},</if>
            <if test="levelStatus != null">#{levelStatus},</if>
         </trim>
    </insert>

    <update id="updateTDeviceSet" parameterType="TDeviceSet">
        update t_device_set
        <trim prefix="SET" suffixOverrides=",">
            <if test="deviceIdCode != null">device_id_code = #{deviceIdCode},</if>
            <if test="sostelno1 != null">sostelno1 = #{sostelno1},</if>
            <if test="sostelno2 != null">sostelno2 = #{sostelno2},</if>
            <if test="gpsInterval != null">gps_interval = #{gpsInterval},</if>
            <if test="heartInterval != null">heart_interval = #{heartInterval},</if>
            <if test="bodyInterval != null">body_interval = #{bodyInterval},</if>
            <if test="bloodInterval != null">blood_interval = #{bloodInterval},</if>
            <if test="oxygenInterval != null">oxygen_interval = #{oxygenInterval},</if>
            <if test="stepStatus != null">step_status = #{stepStatus},</if>
            <if test="contactPer1 != null">contact_per1 = #{contactPer1},</if>
            <if test="contactTel1 != null">contact_tel1 = #{contactTel1},</if>
            <if test="contactPer2 != null">contact_per2 = #{contactPer2},</if>
            <if test="contactTel2 != null">contact_tel2 = #{contactTel2},</if>
            <if test="contactPer3 != null">contact_per3 = #{contactPer3},</if>
            <if test="contactTel3 != null">contact_tel3 = #{contactTel3},</if>
            <if test="timeStatus != null">time_status = #{timeStatus},</if>
            <if test="timeBegin != null">time_begin = #{timeBegin},</if>
            <if test="timeEnd != null">time_end = #{timeEnd},</if>
            <if test="useStatus != null">use_status = #{useStatus},</if>
            <if test="fallStatus != null">fall_status = #{fallStatus},</if>
            <if test="levelStatus != null">level_status = #{levelStatus},</if>
        </trim>
        where device_id_code = #{deviceIdCode}
    </update>

    <delete id="deleteTDeviceSetById" parameterType="Integer">
        delete from t_device_set where id = #{id}
    </delete>

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