|
@@ -34,7 +34,17 @@ select
|
|
|
floor((`m`.`alarm_count` / `m`.`days`)) AS `avg_alarm_count`,
|
|
|
if((`m`.`alarm_source` = '性能告警'),
|
|
|
((60 / 5) * 24),
|
|
|
- ((60 * 2) * 24)) AS `collection_frequency`
|
|
|
+ ((60 * 2) * 24)) AS `collection_frequency`,
|
|
|
+ (case
|
|
|
+ when ((`m`.`occur_time` <= `m`.`thedvalue_b`)
|
|
|
+ and (`m`.`update_time` >= `m`.`thedvalue_e`)) then (60 * 24)
|
|
|
+ when ((`m`.`occur_time` > `m`.`thedvalue_b`)
|
|
|
+ and (`m`.`update_time` >= `m`.`thedvalue_e`)) then ((60 * 24) - (`m`.`occur_time` % 100))
|
|
|
+ when ((`m`.`occur_time` <= `m`.`thedvalue_b`)
|
|
|
+ and (`m`.`update_time` < `m`.`thedvalue_e`)) then (`m`.`update_time` % 100)
|
|
|
+ when ((`m`.`occur_time` > `m`.`thedvalue_b`)
|
|
|
+ and (`m`.`update_time` < `m`.`thedvalue_e`)) then ((`m`.`update_time` % 100) - (`m`.`occur_time` % 100))
|
|
|
+ end) AS `alarm_duration`
|
|
|
from
|
|
|
(
|
|
|
select
|
|
@@ -53,7 +63,11 @@ from
|
|
|
'DAY' AS `dtype`,
|
|
|
`dates`.`YYYYMMDD` AS `thedvalue`,
|
|
|
1 AS `is_active_alarm`,
|
|
|
- `aa`.`alarm_source` AS `alarm_source`
|
|
|
+ `aa`.`alarm_source` AS `alarm_source`,
|
|
|
+ date_format(str_to_date(`dates`.`YYYYMMDD`, '%Y%m%d%H%m'), '%Y%m%d%H00') AS `thedvalue_b`,
|
|
|
+ date_format((str_to_date(`dates`.`YYYYMMDD`, '%Y%m%d%H%m') + interval 1 day), '%Y%m%d%H00') AS `thedvalue_e`,
|
|
|
+ date_format(`aa`.`occur_time`, '%Y%m%d%H%m') AS `occur_time`,
|
|
|
+ date_format(`aa`.`update_time`, '%Y%m%d%H%m') AS `update_time`
|
|
|
from
|
|
|
(`t_alm_active_alarm` `aa`
|
|
|
join (
|
|
@@ -80,7 +94,11 @@ union all
|
|
|
'DAY' AS `dtype`,
|
|
|
`dates`.`YYYYMMDD` AS `thedvalue`,
|
|
|
0 AS `is_active_alarm`,
|
|
|
- `ha`.`alarm_source` AS `alarm_source`
|
|
|
+ `ha`.`alarm_source` AS `alarm_source`,
|
|
|
+ date_format(str_to_date(`dates`.`YYYYMMDD`, '%Y%m%d%H%m'), '%Y%m%d%H00') AS `thedvalue_b`,
|
|
|
+ date_format((str_to_date(`dates`.`YYYYMMDD`, '%Y%m%d%H%m') + interval 1 day), '%Y%m%d%H00') AS `thedvalue_e`,
|
|
|
+ date_format(`ha`.`occur_time`, '%Y%m%d%H%m') AS `occur_time`,
|
|
|
+ date_format(`ha`.`update_time`, '%Y%m%d%H%m') AS `update_time`
|
|
|
from
|
|
|
(`t_alm_history_alarm` `ha`
|
|
|
join (
|