| | |
| | | <select id="selectAlarmRecordPage" resultType="cn.gistack.alerts.alarmRule.vo.AlarmRecordVO"> |
| | | select |
| | | sar.*, |
| | | sar1.type,sar1.alarm_rule_type as alarmRuleType,sar1.create_alarm_type as createAlarmType, |
| | | arb."name" as reservoirName,aab."ad_name" as areaName |
| | | sar1.type,sar1.alarm_rule_type as alarmRuleType,sar1.create_alarm_type as createAlarmType,sar1.rule_name as ruleName, |
| | | a."name" as reservoirName,a."res_reg_code" as resRegCode,a."eng_scal" as engScal, |
| | | case when b."ad_grad" = 4 THEN b."ad_name" |
| | | ELSE NULL END AS townName, |
| | | case when b."ad_grad" = 3 THEN b."ad_name" |
| | | when c."ad_grad" = 3 THEN C."ad_name" |
| | | END AS countyName, |
| | | case when b."ad_grad" = 2 THEN b."ad_name" |
| | | when c."ad_grad" = 2 THEN c."ad_name" |
| | | ELSE d."ad_name" END AS cityName |
| | | from YWXT.sm_alarm_record sar |
| | | left join YWXT.sm_alarm_rule sar1 on sar.alarm_rule_id = sar1.id and sar1.is_deleted = 0 |
| | | left join SJZT_MD."att_res_base" arb on arb."guid" = sar.reservoir_number |
| | | left join SJZT_MD."att_ad_base" aab on aab."guid" = arb."interior_ad_guid" |
| | | left join SJZT_MD."att_res_base" a on a."guid" = sar.reservoir_number |
| | | left join SJZT_MD."att_ad_base" b on b."guid" = a."interior_ad_guid" |
| | | LEFT JOIN SJZT_MD."att_ad_base" c ON b."p_ad_code" = c."guid" |
| | | LEFT JOIN SJZT_MD."att_ad_base" d ON c."p_ad_code" = d."guid" |
| | | where sar.is_deleted = 0 |
| | | <if test="alarmRecord.reservoirName!=null and alarmRecord.reservoirName!=''"> |
| | | and arb."name" like concat('%',#{alarmRecord.reservoirName},'%') |
| | | and a."name" like concat('%',#{alarmRecord.reservoirName},'%') |
| | | </if> |
| | | <if test="alarmRecord.type!=null and alarmRecord.type!=''"> |
| | | and sar1.type = #{alarmRecord.type} |
| | |
| | | <if test="alarmRecord.createAlarmType!=null and alarmRecord.createAlarmType!=''"> |
| | | and sar1.create_alarm_type = #{alarmRecord.createAlarmType} |
| | | </if> |
| | | <if test="alarmRecord.ruleName!=null and alarmRecord.ruleName!=''"> |
| | | and sar1.rule_name = #{alarmRecord.ruleName} |
| | | </if> |
| | | <if test="alarmRecord.startTime!=null and alarmRecord.startTime!=''"> |
| | | and date_format(sar.create_time,'%Y-%m-%d') >= #{alarmRecord.startTime} |
| | | </if> |
| | | <if test="alarmRecord.endTime!=null and alarmRecord.endTime!=''"> |
| | | and date_format(sar.create_time,'%Y-%m-%d') <= #{alarmRecord.endTime} |
| | | </if> |
| | | order by sar.id desc |
| | | </select> |
| | | |
| | | <!--按行政区code 查询下级行政区--> |
| | | <select id="getAdNameList" resultType="java.lang.String"> |
| | | select "ad_name" from SJZT_MD."att_ad_base" where "p_ad_code" = #{adCode} order by "guid" |
| | | </select> |
| | | |
| | | <!--查询告警统计数据--> |
| | | <select id="statisticAlarmRecord" resultType="cn.gistack.alerts.alarmRule.vo.StatisticAlarmRecord"> |
| | | select cityName as adName,rule_name as ruleName,count(*) num from ( |
| | | select |
| | | sar.id,sar.alarm_rule_id,sar.create_time,sar.reservoir_number, |
| | | arb."name", |
| | | e.rule_name, |
| | | case when b."ad_grad" = 4 THEN b."ad_name" ELSE NULL END AS townName, |
| | | case when b."ad_grad" = 3 THEN b."ad_name" |
| | | when c."ad_grad" = 3 THEN c."ad_name" END AS countyName, |
| | | case when b."ad_grad" = 3 THEN b."ad_code" |
| | | when c."ad_grad" = 3 THEN c."ad_code" END AS countyCode, |
| | | case when b."ad_grad" = 2 THEN b."ad_code" |
| | | when c."ad_grad" = 2 THEN c."ad_code" |
| | | ELSE d."ad_code" END AS cityCode, |
| | | case when b."ad_grad" = 2 THEN b."ad_name" |
| | | when c."ad_grad" = 2 THEN c."ad_name" |
| | | ELSE d."ad_name" END AS cityName |
| | | from YWXT.sm_alarm_record sar |
| | | left join SJZT_MD."att_res_base" arb on arb."guid" = sar.reservoir_number |
| | | left join SJZT_MD."att_ad_base" b ON arb."interior_ad_guid" = b."guid" |
| | | left join SJZT_MD."att_ad_base" c ON b."p_ad_code" = c."guid" |
| | | left join SJZT_MD."att_ad_base" d ON c."p_ad_code" = d."guid" |
| | | left join YWXT.sm_alarm_rule e on e.id = sar.alarm_rule_id |
| | | where sar.is_deleted = 0 |
| | | <if test="alarmRecord.reservoirName!=null and alarmRecord.reservoirName!=''"> |
| | | and arb."name" like concat('%',#{alarmRecord.reservoirName},'%') |
| | | </if> |
| | | <if test="alarmRecord.type!=null and alarmRecord.type!=''"> |
| | | and e.type = #{alarmRecord.type} |
| | | </if> |
| | | <if test="alarmRecord.alarmRuleType!=null and alarmRecord.alarmRuleType!=''"> |
| | | and e.alarm_rule_type = #{alarmRecord.alarmRuleType} |
| | | </if> |
| | | <if test="alarmRecord.createAlarmType!=null and alarmRecord.createAlarmType!=''"> |
| | | and e.create_alarm_type = #{alarmRecord.createAlarmType} |
| | | </if> |
| | | <if test="alarmRecord.ruleName!=null and alarmRecord.ruleName!=''"> |
| | | and e.rule_name = #{alarmRecord.ruleName} |
| | | </if> |
| | | <if test="alarmRecord.startTime!=null and alarmRecord.startTime!=''"> |
| | | and date_format(sar.create_time,'%Y-%m-%d') >= #{alarmRecord.startTime} |
| | | </if> |
| | | <if test="alarmRecord.endTime!=null and alarmRecord.endTime!=''"> |
| | | and date_format(sar.create_time,'%Y-%m-%d') <= #{alarmRecord.endTime} |
| | | </if> |
| | | ) f |
| | | group by cityName,rule_name |
| | | </select> |
| | | |
| | | <!--查询告警统计数据-按三大类--> |
| | | <select id="statisticAlarmRecordByType" resultType="cn.gistack.alerts.alarmRule.vo.StatisticAlarmRecord"> |
| | | select |
| | | a.dict_value as ruleName, |
| | | case when ifnull(b.type,0)='0' then 0 else b.num end as num |
| | | from |
| | | ( |
| | | select dict_value from YWXT.blade_dict_biz where code = 'ALARM_TYPE' and dict_key!= '-1' and is_deleted = 0 |
| | | ) a left join |
| | | ( |
| | | select type,count(*) num |
| | | from YWXT.sm_alarm_record sar |
| | | left join YWXT.sm_alarm_rule e on e.id = sar.alarm_rule_id |
| | | where sar.is_deleted = 0 |
| | | <if test="alarmRecord.startTime!=null and alarmRecord.startTime!=''"> |
| | | and date_format(sar.create_time,'%Y-%m-%d') >= #{alarmRecord.startTime} |
| | | </if> |
| | | <if test="alarmRecord.endTime!=null and alarmRecord.endTime!=''"> |
| | | and date_format(sar.create_time,'%Y-%m-%d') <= #{alarmRecord.endTime} |
| | | </if> |
| | | group by type |
| | | ) b on a.dict_value = b.type |
| | | </select> |
| | | |
| | | <!--查询符合条件的告警类型--> |
| | | <select id="listAlarmRule" resultType="cn.gistack.alerts.alarmRule.entity.AlarmRule"> |
| | | select * from YWXT.sm_alarm_rule where is_deleted = 0 |
| | | <if test="alarmRecord.type!=null and alarmRecord.type!=''"> |
| | | and type = #{alarmRecord.type} |
| | | </if> |
| | | <if test="alarmRecord.alarmRuleType!=null and alarmRecord.alarmRuleType!=''"> |
| | | and alarm_rule_type = #{alarmRecord.alarmRuleType} |
| | | </if> |
| | | <if test="alarmRecord.createAlarmType!=null and alarmRecord.createAlarmType!=''"> |
| | | and create_alarm_type = #{alarmRecord.createAlarmType} |
| | | </if> |
| | | <if test="alarmRecord.ruleName!=null and alarmRecord.ruleName!=''"> |
| | | and rule_name = #{alarmRecord.ruleName} |
| | | </if> |
| | | </select> |
| | | |
| | | </mapper> |