<?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.api.manage.dao.operationManagement.SysAlarmDao">

    <select id="fireAlarmList" resultType="com.api.vo.operationManagement.VoFireAlarm">
        select * from sys_fire_alarm order by create_date desc
    </select>
    <select id="oneButtonAlarmList" resultType="com.api.vo.operationManagement.VoOneButtonAlarm">
        select soba.id,ur.name,ur.tel,concat(cb.no,'-',cbu.no,'-',cbue.room_number) as room_name,soba.create_date
        from user_resident as ur,sys_one_button_alarm as soba
        LEFT JOIN cpm_building_unit_estate as cbue on soba.estate_id = cbue.id
        LEFT JOIN cpm_building_unit as cbu on cbue.building_unit_id = cbu.id
        LEFT JOIN cpm_building as cb on cbu.building_id = cb.id
        where soba.create_id = ur.id
        order by soba.create_date desc
    </select>
    <select id="butlerOneButtonAlarmList" resultType="com.api.vo.operationManagement.VoButlerOneButtonAlarm">
        select sobab.id,su.actual_name as name,su.tel,so.name as organization_name,sobab.create_date
        from sys_one_button_alarm_butler as sobab,sys_user as su,sys_organization as so
        where sobab.create_id = su.id and su.organization_id = so.id
        order by sobab.create_date desc
    </select>
    <select id="planAlarmList" resultType="com.api.vo.operationManagement.VoPlanAlarm">
        select * from sys_plan_alarm order by create_date desc
    </select>
    <update id="updatePlanAlarmStatusById" parameterType="com.api.model.operationManagement.PushRelieveAlert">
        update sys_plan_alarm set status = 2,content_description = #{contentDescription}  where id = #{planAlertId}
    </update>

</mapper>