<?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.yfd.platform.modules.auxcontrol.mapper.DeviceAlarmParameterMapper">

    <select id="getDeviceAlarmParameterPage"
            resultType="com.yfd.platform.modules.auxcontrol.domain.DeviceAlarmParameter">

        SELECT
        dap.*,
        sdi1.dictname AS alarmTypeName,
        sdi2.dictname AS alarmLevelName,
        COALESCE (
        (
        SELECT
        GROUP_CONCAT( dictname ORDER BY itemcode SEPARATOR ',' )
        FROM
        sys_dictionary_items
        WHERE
        dictid = 'd3a5c69ef214012abcdb31495ef4e772'
        AND FIND_IN_SET( itemcode, dap.notice_type ) > 0
        ),
        ''
        ) AS noticeTypeName
        FROM
        fk_device_alarm_parameter dap
        LEFT JOIN sys_dictionary_items sdi1 ON sdi1.dictid = 'aad92e9fd54d05e090b074f3e0666c8c'
        AND sdi1.itemcode = dap.alarm_type
        LEFT JOIN sys_dictionary_items sdi2 ON sdi2.dictid = '138d15a0ce89e5abd516389a1176db6e'
        AND sdi2.itemcode = dap.alarm_level
        WHERE 1 =1
        <if test="signalId != null and signalId != ''">
            and dap.signal_id= #{signalId}
        </if>
        <if test="meterDeviceId != null and meterDeviceId != ''">
            and dap.device_id= #{meterDeviceId}
        </if>
        <if test="alarmType != null and alarmType != ''">
            and dap.alarm_type= #{alarmType}
        </if>
        <if test="alarmLevel != null and alarmLevel != ''">
            and dap.alarm_level= #{alarmLevel}
        </if>
    </select>
</mapper>
