--DW数据库--执行计划同步表dw_atu_plan_info新增字段
-- 2023/10/18
alter table dw_atu_plan_info add COLUMN manager_oper_code varchar(255) DEFAULT NULL comment '计划负责人雪狼账号';

-- 2023-10-30 修改explan数据库 atu_plan_batch的同步触发器
DROP TRIGGER IF EXISTS  triggre_atu_plan_batch_insert;
CREATE TRIGGER `triggre_atu_plan_batch_insert` AFTER INSERT ON `atu_plan_batch` FOR EACH ROW INSERT INTO mq_synchronize_task (id,task_type,task_info,created_time)
VALUES(NEW.id,2,
JSON_OBJECT('id',NEW.id,'plan_id',NEW.plan_id,'batch',NEW.batch,'status',NEW.status,
'start_time',date_format(NEW.start_time,'%Y-%m-%d %H:%i:%s'),
'end_time',date_format(NEW.end_time,'%Y-%m-%d %H:%i:%s'),
'task_total',NEW.task_total,
'success_num',NEW.success_num,
'exec_fail_num',NEW.exec_fail_num,
'assert_fail_num',NEW.assert_fail_num,
'timeout_num',NEW.timeout_num,'cancel_num',NEW.cancel_num,
'trigger_type',NEW.trigger_type,
'executed_by',NEW.executed_by,
'success_rate',NEW.success_rate,'created_time',CURDATE()),CURDATE());


DROP TRIGGER IF EXISTS  triggre_atu_plan_batch_update;

CREATE TRIGGER `triggre_atu_plan_batch_update` AFTER UPDATE ON `atu_plan_batch` FOR EACH ROW INSERT INTO mq_synchronize_task (id,task_type,task_info,created_time)
VALUES(NEW.id,2,
JSON_OBJECT('id',NEW.id,'plan_id',NEW.plan_id,'batch',NEW.batch,'status',NEW.status,
'start_time',date_format(NEW.start_time,'%Y-%m-%d %H:%i:%s'),
'end_time',date_format(NEW.end_time,'%Y-%m-%d %H:%i:%s'),
'task_total',NEW.task_total,
'success_num',NEW.success_num,
'exec_fail_num',NEW.exec_fail_num,
'assert_fail_num',NEW.assert_fail_num,
'timeout_num',NEW.timeout_num,'cancel_num',NEW.cancel_num,
'trigger_type',NEW.trigger_type,
'executed_by',NEW.executed_by,
'success_rate',NEW.success_rate,'created_time',CURDATE()),CURDATE()) ON DUPLICATE KEY UPDATE task_info=JSON_OBJECT('id',NEW.id,'plan_id',NEW.plan_id,'batch',NEW.batch,'status',NEW.status,
'start_time',date_format(NEW.start_time,'%Y-%m-%d %H:%i:%s'),
'end_time',date_format(NEW.end_time,'%Y-%m-%d %H:%i:%s'),
'task_total',NEW.task_total,
'success_num',NEW.success_num,
'exec_fail_num',NEW.exec_fail_num,
'assert_fail_num',NEW.assert_fail_num,
'timeout_num',NEW.timeout_num,'cancel_num',NEW.cancel_num,
'trigger_type',NEW.trigger_type,
'executed_by',NEW.executed_by,
'success_rate',NEW.success_rate,'created_time',CURDATE());




-- 2023-10-30 添加批次同步表字段 执行人executed_by、executed_name、雪狼账号manager_oper_code、公司manager_company
alter table dw_atu_plan_batch add COLUMN manager_oper_code varchar(255) DEFAULT NULL comment '执行人雪狼账号';

alter table dw_atu_plan_batch add COLUMN executed_by varchar(32) DEFAULT NULL comment '执行人id';
alter table dw_atu_plan_batch add COLUMN executed_name varchar(255) DEFAULT NULL comment '执行人姓名';

alter table dw_atu_plan_batch add COLUMN manager_company varchar(255) DEFAULT NULL comment '执行人公司';


