2 Commits 22e718bad6 ... 2628a0bbbf

Author SHA1 Message Date
  Ping 2628a0bbbf month, year视图增加告警时长 1 year ago
  Ping 271069c5f0 day, hour视图增加告警时长 1 year ago

+ 21 - 3
views/v_bi_alm_all_alarm_day.sql

@@ -34,7 +34,17 @@ select
     floor((`m`.`alarm_count` / `m`.`days`)) AS `avg_alarm_count`,
     floor((`m`.`alarm_count` / `m`.`days`)) AS `avg_alarm_count`,
     if((`m`.`alarm_source` = '性能告警'),
     if((`m`.`alarm_source` = '性能告警'),
     ((60 / 5) * 24),
     ((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
 from
     (
     (
     select
     select
@@ -53,7 +63,11 @@ from
         'DAY' AS `dtype`,
         'DAY' AS `dtype`,
         `dates`.`YYYYMMDD` AS `thedvalue`,
         `dates`.`YYYYMMDD` AS `thedvalue`,
         1 AS `is_active_alarm`,
         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
     from
         (`t_alm_active_alarm` `aa`
         (`t_alm_active_alarm` `aa`
     join (
     join (
@@ -80,7 +94,11 @@ union all
         'DAY' AS `dtype`,
         'DAY' AS `dtype`,
         `dates`.`YYYYMMDD` AS `thedvalue`,
         `dates`.`YYYYMMDD` AS `thedvalue`,
         0 AS `is_active_alarm`,
         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
     from
         (`t_alm_history_alarm` `ha`
         (`t_alm_history_alarm` `ha`
     join (
     join (

+ 15 - 3
views/v_bi_alm_all_alarm_hour.sql

@@ -21,7 +21,13 @@ select
     floor((`m`.`alarm_count` / `m`.`hours`)) AS `avg_alarm_count`,
     floor((`m`.`alarm_count` / `m`.`hours`)) AS `avg_alarm_count`,
     if((`m`.`alarm_source` = '性能告警'),
     if((`m`.`alarm_source` = '性能告警'),
     (60 / 5),
     (60 / 5),
-    (60 * 2)) AS `collection_frequency`
+    (60 * 2)) AS `collection_frequency`,
+    CASE 
+	    WHEN occur_time<=thedvalue_b and update_time>=thedvalue_e THEN 60
+	    WHEN occur_time>thedvalue_b and update_time>=thedvalue_e THEN 60-MOD(occur_time,100)
+	    WHEN occur_time<=thedvalue_b and update_time<thedvalue_e THEN MOD(update_time,100)
+	    WHEN occur_time>thedvalue_b and update_time<thedvalue_e THEN MOD(update_time,100)-MOD(occur_time,100)
+    END 'alarm_duration'
 from
 from
     (
     (
     select
     select
@@ -40,7 +46,10 @@ from
         'HOUR' AS `dtype`,
         'HOUR' AS `dtype`,
         `dates`.`thevalue` AS `thedvalue`,
         `dates`.`thevalue` AS `thedvalue`,
         1 AS `is_active_alarm`,
         1 AS `is_active_alarm`,
-        `aa`.`alarm_source` AS `alarm_source`
+        `aa`.`alarm_source` AS `alarm_source`,
+        date_format(STR_TO_DATE(`dates`.`thevalue`, '%Y%m%d%H%m'),'%Y%m%d%H00') 'thedvalue_b',
+        date_format(DATE_ADD(STR_TO_DATE(`dates`.`thevalue`, '%Y%m%d%H%m'), INTERVAL 1 HOUR),'%Y%m%d%H00') 'thedvalue_e',
+        date_format(`aa`.`occur_time`, '%Y%m%d%H%m') occur_time, date_format(`aa`.`update_time`, '%Y%m%d%H%m') update_time
     from
     from
         (`t_alm_active_alarm` `aa`
         (`t_alm_active_alarm` `aa`
     join (
     join (
@@ -67,7 +76,10 @@ union all
         'HOUR' AS `dtype`,
         'HOUR' AS `dtype`,
         `dates`.`thevalue` AS `thedvalue`,
         `dates`.`thevalue` AS `thedvalue`,
         0 AS `is_active_alarm`,
         0 AS `is_active_alarm`,
-        `ha`.`alarm_source` AS `alarm_source`
+        `ha`.`alarm_source` AS `alarm_source`,
+        date_format(STR_TO_DATE(`dates`.`thevalue`, '%Y%m%d%H%m'),'%Y%m%d%H00') 'thedvalue_b',
+        date_format(DATE_ADD(STR_TO_DATE(`dates`.`thevalue`, '%Y%m%d%H%m'), INTERVAL 1 HOUR),'%Y%m%d%H00') 'thedvalue_e',
+        date_format(`ha`.`occur_time`, '%Y%m%d%H%m') occur_time, date_format(`ha`.`update_time`, '%Y%m%d%H%m') update_time
     from
     from
         (`t_alm_history_alarm` `ha`
         (`t_alm_history_alarm` `ha`
     join (
     join (

+ 40 - 6
views/v_bi_alm_all_alarm_month.sql

@@ -20,8 +20,34 @@ select
     `m`.`is_active_alarm` AS `is_active_alarm`,
     `m`.`is_active_alarm` AS `is_active_alarm`,
     floor((`m`.`alarm_count` / `m`.`months`)) AS `avg_alarm_count`,
     floor((`m`.`alarm_count` / `m`.`months`)) AS `avg_alarm_count`,
     if((`m`.`alarm_source` = '性能告警'),
     if((`m`.`alarm_source` = '性能告警'),
-    ((60 / 5) * 24 * days_in_month),
-    ((60 * 2) * 24 * days_in_month)) AS `collection_frequency`
+    (((60 / 5) * 24) * `m`.`days_in_month`),
+    (((60 * 2) * 24) * `m`.`days_in_month`)) AS `collection_frequency`,
+    (case
+        when ((`m`.`occur_time` <= `m`.`thedvalue_b`)
+        and (`m`.`update_time` >= `m`.`thedvalue_e`)) then timestampdiff(MINUTE,
+        str_to_date(`m`.`thedvalue_b`,
+        '%Y%m%d%H%m'),
+        str_to_date(`m`.`thedvalue_e`,
+        '%Y%m%d%H%m'))
+        when ((`m`.`occur_time` > `m`.`thedvalue_b`)
+        and (`m`.`update_time` >= `m`.`thedvalue_e`)) then timestampdiff(MINUTE,
+        str_to_date(`m`.`occur_time`,
+        '%Y%m%d%H%m'),
+        str_to_date(`m`.`thedvalue_e`,
+        '%Y%m%d%H%m'))
+        when ((`m`.`occur_time` <= `m`.`thedvalue_b`)
+        and (`m`.`update_time` < `m`.`thedvalue_e`)) then timestampdiff(MINUTE,
+        str_to_date(`m`.`thedvalue_b`,
+        '%Y%m%d%H%m'),
+        str_to_date(`m`.`update_time`,
+        '%Y%m%d%H%m'))
+        when ((`m`.`occur_time` > `m`.`thedvalue_b`)
+        and (`m`.`update_time` < `m`.`thedvalue_e`)) then timestampdiff(MINUTE,
+        str_to_date(`m`.`occur_time`,
+        '%Y%m%d%H%m'),
+        str_to_date(`m`.`update_time`,
+        '%Y%m%d%H%m'))
+    end) AS `alarm_duration`
 from
 from
     (
     (
     select
     select
@@ -42,8 +68,12 @@ from
         'MONTH' AS `dtype`,
         'MONTH' AS `dtype`,
         `dates`.`thedvalue` AS `thedvalue`,
         `dates`.`thedvalue` AS `thedvalue`,
         1 AS `is_active_alarm`,
         1 AS `is_active_alarm`,
-        alarm_source,
-        DAYOFMONTH(last_day(DATE_ADD(MAKEDATE(`dates`.`thedvalue`/100, 1), INTERVAL MOD(`dates`.`thedvalue`,100)-1 MONTH))) days_in_month
+        `aa`.`alarm_source` AS `alarm_source`,
+        dayofmonth(last_day((makedate((`dates`.`thedvalue` / 100), 1) + interval ((`dates`.`thedvalue` % 100) - 1) month))) AS `days_in_month`,
+        date_format(str_to_date(concat(`dates`.`thedvalue`, '01'), '%Y%m%d'), '%Y%m%d0000') AS `thedvalue_b`,
+        date_format((str_to_date(concat(`dates`.`thedvalue`, '01'), '%Y%m%d') + interval 1 month), '%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
     from
         (`t_alm_active_alarm` `aa`
         (`t_alm_active_alarm` `aa`
     join (
     join (
@@ -72,8 +102,12 @@ union all
         'MONTH' AS `dtype`,
         'MONTH' AS `dtype`,
         `dates`.`thedvalue` AS `thedvalue`,
         `dates`.`thedvalue` AS `thedvalue`,
         0 AS `is_active_alarm`,
         0 AS `is_active_alarm`,
-        alarm_source,
-        DAYOFMONTH(last_day(DATE_ADD(MAKEDATE(`dates`.`thedvalue`/100, 1), INTERVAL MOD(`dates`.`thedvalue`,100)-1 MONTH))) days_in_month
+        `ha`.`alarm_source` AS `alarm_source`,
+        dayofmonth(last_day((makedate((`dates`.`thedvalue` / 100), 1) + interval ((`dates`.`thedvalue` % 100) - 1) month))) AS `days_in_month`,
+        date_format(str_to_date(concat(`dates`.`thedvalue`, '01'), '%Y%m%d'), '%Y%m%d0000') AS `thedvalue_b`,
+        date_format((str_to_date(concat(`dates`.`thedvalue`, '01'), '%Y%m%d%H%m') + interval 1 month), '%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
     from
         (`t_alm_history_alarm` `ha`
         (`t_alm_history_alarm` `ha`
     join (
     join (

File diff suppressed because it is too large
+ 13 - 4
views/v_bi_alm_all_alarm_year.sql