<?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.bonus.tcp.smartIdentify.mapper.TcpDataMapper">
    <insert id="insertWarnInfo">
        insert into tb_warn(
            pro_id,team_id,dev_id,user_id,warn_content,warn_time,
                warn_type,create_time,data_source,del_flag,dev_type,people_type
        )values ( #{proId},#{teamId},#{devId},#{userId},#{warnContent},#{warnTime},
                 #{warnType},now(),#{dataSource},0,#{devType},#{peopleType} )

    </insert>
    <update id="updateTcpChannelId">
        update tb_device
            set channel_id=#{channelId},dev_status=1
            WHERE  dev_code=#{devCode} and dev_type=#{devType}
    </update>
    <update id="downLoadStatus">
        update tb_device  set dev_status=0 ,channel_id=''
             WHERE  channel_id=#{channelId}
    </update>
    <update id="updateDataVal">
        update tb_dev_details
            set data_val=#{value},data_time=#{dataTime}
          where id=#{id}
    </update>
    <select id="getDevInfoByCode" resultType="com.bonus.common.entity.tcp.TcpDataVo">
        select tdl.pro_id proId,tdl.team_id  teamId,tdl.ly_user userId,td.id devId
            from tb_device td
             left join tb_dev_ly tdl on td.id=tdl.dev_id
        WHERE  td.dev_code=#{devCode} and td.dev_type=#{devType}
    </select>
    <select id="getDevDetails" resultType="com.bonus.common.entity.tcp.TcpDataVo">
        select tdd.id id,tdd.data_code dataCode,tdd.dev_id devId,td.dev_name devName
        from tb_device td
         left join tb_dev_details tdd on tdd.dev_id=td.id
        WHERE  td.dev_code=#{devCode} and td.dev_type=#{devType}
    </select>
    <select id="getDevCodeByChannel" resultType="java.lang.String">
        select td.dev_code
             from tb_device td
              WHERE  channel_id=#{channelId}
    </select>
</mapper>