zhongrj
2023-05-27 4e44231626f378c7a7cdb690dc55859ab14153a5
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/alarmRule/mapper/AlarmRuleMapper.xml
@@ -4,46 +4,19 @@
    <!--自定义分页列表查询-->
    <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 sar.* from YWXT.sm_alarm_rule sar 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>
    </select>
</mapper>