<?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.casic.missiles.modular.system.dao.AlarmNowViewMapper">

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        wellId AS wellId, deviceId AS deviceId, devcode as devcode, wellCode AS wellCode, alarmId AS alarmId, deptid AS deptid, owner AS owner,
        alarmType AS alarmType, alarmValue AS alarmValue, alarmContent AS alarmContent, alarmTimeDate AS alarmTimeDate,
        position AS position, coordinateX AS coordinateX, coordinateY AS coordinateY,
        lngBaidu AS lngBaidu, latBaidu AS latBaidu, lngGaode AS lngGaode, latGaode AS latGaode
    </sql>

    <sql id="Alarm_Column_List">
        deviceId AS deviceId, devcode as devcode, alarmId AS alarmId, alarmType AS alarmType, alarmValue AS alarmValue, alarmContent AS alarmContent, alarmTimeDate AS alarmTimeDate
    </sql>

    <select id="getNowAlarmRecords" resultType="com.casic.missiles.modular.system.dto.AlarmNowView">
        SELECT <include refid="Base_Column_List"/> FROM ALARM_NOW_VIEW w WHERE 1 = 1 ORDER BY alarmTimeDate DESC
    </select>

    <select id="getAlarmsByWell" resultType="com.casic.missiles.modular.system.dto.AlarmNowView">
        SELECT <include refid="Alarm_Column_List"/> FROM ALARM_NOW_VIEW w WHERE 1 = 1 AND wellId = #{id}
    </select>

</mapper>
