guoshilong
2023-05-23 76d9d4af124631ffe68c5f8dfd2c6d54c61fcefa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?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="cn.gistack.sm.alarmRule.mapper.AlarmRuleMapper">
 
    <!--自定义分页列表查询-->
    <select id="selectAlarmRulePage" resultType="cn.gistack.sm.alarmRule.vo.AlarmRuleVO">
        select
            a.*,
            if(waterAlarmRuleType!='',waterAlarmRuleType,if(rainAlarmRuleType!='',rainAlarmRuleType,'')) as alarmRuleTypeName,
            if(waterCreateAlarmType!='',waterCreateAlarmType,if(rainCreateAlarmType!='',rainCreateAlarmType,'')) as createAlarmTypeName
        from (
            select
            sar.*,
            bdb1.dict_value as typeName,
            bdb2.dict_value as waterAlarmRuleType,
            bdb3.dict_value as rainAlarmRuleType,
            bdb4.dict_value as waterCreateAlarmType,
            bdb5.dict_value as rainCreateAlarmType,
            bdb6.dict_value as targetName,
            bdb7.dict_value as alarmLevelName,
            bdb8.dict_value as alarmModeName,
            bdb9.dict_value as alarmFrequencyName
            from YWXT.sm_alarm_rule sar
            LEFT JOIN (select * from YWXT.blade_dict_biz where code = 'ALARM_TYPE' and dict_key!=-1 and is_deleted = 0) bdb1 on bdb1.dict_key = sar.type
            LEFT JOIN (select * from YWXT.blade_dict_biz where code = 'WATER_ALARM_RULE_TYPE' and dict_key!=-1 and is_deleted = 0) bdb2 on bdb2.dict_key = sar.ALARM_RULE_TYPE
            LEFT JOIN (select * from YWXT.blade_dict_biz where code = 'RAIN_ALARM_RULE_TYPE' and dict_key!=-1 and is_deleted = 0) bdb3 on bdb3.dict_key = sar.ALARM_RULE_TYPE
            LEFT JOIN (select * from YWXT.blade_dict_biz where code = 'WATER_CREATE_ALARM_TYPE' and dict_key!=-1 and is_deleted = 0) bdb4 on bdb4.dict_key = sar.CREATE_ALARM_TYPE
            LEFT JOIN (select * from YWXT.blade_dict_biz where code = 'RAIN_CREATE_ALARM_TYPE' and dict_key!=-1 and is_deleted = 0) bdb5 on bdb5.dict_key = sar.CREATE_ALARM_TYPE
            LEFT JOIN (select * from YWXT.blade_dict_biz where code = 'ALARM_TARGET' and dict_key!=-1 and is_deleted = 0) bdb6 on bdb6.dict_key = sar.TARGET
            LEFT JOIN (select * from YWXT.blade_dict_biz where code = 'ALARM_LEVEL' and dict_key!=-1 and is_deleted = 0) bdb7 on bdb7.dict_key = sar.ALARM_LEVEL
            LEFT JOIN (select * from YWXT.blade_dict_biz where code = 'ALARM_MODE' and dict_key!=-1 and is_deleted = 0) bdb8 on bdb8.dict_key = sar.ALARM_MODE
            LEFT JOIN (select * from YWXT.blade_dict_biz where code = 'ALARM_FREQUENCY' and dict_key!=-1 and is_deleted = 0) bdb9 on bdb9.dict_key = sar.ALARM_FREQUENCY
            where sar.is_deleted = 0
            <if test="alarmRule.type!=null and alarmRule.type!=''">
                and sar.type = #{alarmRule.type}
            </if>
            <if test="alarmRule.alarmRuleType!=null and alarmRule.alarmRuleType!=''">
                and sar.alarm_rule_type = #{alarmRule.alarmRuleType}
            </if>
            <if test="alarmRule.createAlarmType!=null and alarmRule.createAlarmType!=''">
                and sar.create_alarm_type = #{alarmRule.createAlarmType}
            </if>
            <if test="alarmRule.ruleName!=null and alarmRule.ruleName!=''">
                and sar.rule_name like concat(concat('%',#{alarmRule.ruleName}),'%')
            </if>
        ) a
    </select>
 
</mapper>