<?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.securitycontrol.background.mapper.TowerRecordMapper">
    <!--获取信息列表-->
    <select id="getTowerRecordLists"  resultType="com.securitycontrol.entity.background.vo.TowerRecordVo">
        SELECT tbd.device_name as deviceName, ta.area_name as areaName, tdd.mode_name as modeName,a.val,
               a.change_val as changeVal,
               case when a.is_warn = '0' then '否' else '是' end isWarn,
               a.create_time as createTime
        FROM tb_his_device_value a
         LEFT JOIN tb_device_detail tdd ON a.attribute_id = tdd.id
         LEFT JOIN tb_bd_device tbd ON tdd.device_id = tbd.device_id
         LEFT JOIN tb_area  ta ON tbd.area_id = ta.area_id
         LEFT JOIN sys_dict sd ON sd.dict_id = tbd.devic_type
         LEFT JOIN tb_project tp ON tp.bid_code = a.bid_code
        WHERE sd.dict_code ='6661'
        <if test="keyWord !=null and keyWord!=''">
            AND (
            INSTR(tbd.device_name,#{keyWord}) > 0
            )
        </if>

        <if test="proIds != null and proIds != ''">
            AND tp.bid_code = #{proIds}
        </if>

        <if test="date != null and date != ''">
            and date (a.create_time) = #{date}
        </if>
    </select>
</mapper>