diff --git a/script/3.5/schema/1.add_alarm_code.sql b/script/3.5/schema/1.add_alarm_code.sql new file mode 100644 index 0000000..46e5474 --- /dev/null +++ b/script/3.5/schema/1.add_alarm_code.sql @@ -0,0 +1,54 @@ +DO +$$ +BEGIN + + +INSERT INTO t_alarm_group_unit("id","name", "group_id") VALUES (47,'数据中断', 1); --group=1数据中断 +INSERT INTO t_alarm_group_unit("id","name", "group_id") VALUES (48,'数据异常趋势', 3); --group=3策略命中 +INSERT INTO t_alarm_group_unit("id","name", "group_id") VALUES (49,'数据毛刺', 3); --group=3策略命中 + + +-- 添加[异常识别]告警类型 + IF NOT EXISTS(SELECT 1 FROM t_alarm_type WHERE name='数据中断' AND code='3020' ) + THEN + INSERT INTO t_alarm_type (code, name,description,category,enabled,alarm_group,alarm_group_unit,advice_problem) VALUES ('3020','数据中断','数据中断',1,true, + 1,(select id from "t_alarm_group_unit" where name='数据中断' LIMIT 1),'非软件处理'); + END IF; + + IF NOT EXISTS(SELECT 1 FROM t_alarm_code WHERE name='数据中断' AND type_code='30200001' ) + THEN + INSERT INTO t_alarm_code (code, name,type_code,level,enable,alarm_group,alarm_group_unit,advice_problem) VALUES ('30200001','数据中断','3020',1,true, + 1,(select id from "t_alarm_group_unit" where name='数据中断' LIMIT 1),'非软件处理'); + END IF; + +-- 添加[数据异常趋势]告警类型 + IF NOT EXISTS(SELECT 1 FROM t_alarm_type WHERE name='数据异常趋势' AND code='3021' ) + THEN + INSERT INTO t_alarm_type (code, name,description,category,enabled,alarm_group,alarm_group_unit,advice_problem) VALUES ('3021','数据异常趋势','数据异常趋势',1,true, + 3,(select id from "t_alarm_group_unit" where name='数据异常趋势' LIMIT 1),'非软件处理'); + END IF; + + + IF NOT EXISTS(SELECT 1 FROM t_alarm_code WHERE name='数据异常趋势' AND type_code='3021' ) + THEN + INSERT INTO t_alarm_code (code, name,type_code,level,enable,alarm_group,alarm_group_unit,advice_problem) VALUES ('30210001','数据异常趋势','3021',1,true, + 1,(select id from "t_alarm_group_unit" where name='数据异常趋势' LIMIT 1),'非软件处理'); + END IF; + + +-- 添加[数据毛刺]告警类型 + IF NOT EXISTS(SELECT 1 FROM t_alarm_type WHERE name='数据毛刺' AND code='3022' ) + THEN + INSERT INTO t_alarm_type (code, name,description,category,enabled,alarm_group,alarm_group_unit,advice_problem) VALUES ('3022','数据毛刺','数据毛刺',1,true, + 3,(select id from "t_alarm_group_unit" where name='数据毛刺' LIMIT 1),'非软件处理'); + END IF; + + + IF NOT EXISTS(SELECT 1 FROM t_alarm_code WHERE name='数据毛刺' AND type_code='3022' ) + THEN + INSERT INTO t_alarm_code (code, name,type_code,level,enable,alarm_group,alarm_group_unit,advice_problem) VALUES ('30220001','数据毛刺','3022',1,true, + 1,(select id from "t_alarm_group_unit" where name='数据毛刺' LIMIT 1),'非软件处理'); + END IF; + +END +$$ \ No newline at end of file