<?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.EarlyWarningsRecordMapper">

    <update id="updEarly">
        UPDATE tb_warn SET status = #{status}, update_time = NOW(), user_id = #{userId} WHERE `warn_id` = #{warnId}
    </update>
    <!--获取信息列表-->
    <select id="getEarlyWarningsRecordLists" resultType="com.securitycontrol.entity.background.vo.EarlyWarningsRecordVo">
        SELECT tw.warn_id as warnId, tw.warn_content as warnContent, tw.warn_time as warnTime,
        case when tw.`status` = '0' then '未处理'
        when tw.`status` = '1' then '预警正确'
        when tw.`status` = '2' then '预警错误' else '预警错误' end status
        FROM tb_warn tw
        LEFT JOIN tb_device_detail  tdd ON tw.device_id = tdd.device_id
        LEFT JOIN tb_bd_device tbd ON tdd.device_id = tbd.device_id
        LEFT JOIN sys_dict sd ON sd.dict_id = tbd.devic_type
        WHERE sd.dict_code ='6664'
        <if test="date != null and date != ''">
            and date (tw.warn_time) = #{date}
        </if>
    </select>
</mapper>