drop table if exists jetplasma_alteration_apply;
CREATE TABLE `jetplasma_alteration_apply`  (
    `id`  bigint(20)      not null auto_increment primary key comment '主键ID',
    `no` varchar(20) COMMENT '申请编号',
    `type` varchar(20)  NOT NULL COMMENT '变更类型',
    `child_type` varchar(50)  NOT NULL COMMENT '变更子类型',
    `item_type` varchar(100)  NOT NULL COMMENT '变更项目',
    `apply_depart` bigint(20) NULL DEFAULT NULL COMMENT '申请部门',
    `apply_user` bigint(20) NULL DEFAULT NULL COMMENT '申请人',
    `apply_date` datetime COMMENT '申请日期',
    `reason` longtext COMMENT '变更原因',
    `description` longtext COMMENT '变更详细描述',
	`problem` longtext COMMENT '问题描述',
	`suggest` longtext COMMENT '改善建议',
	`level` varchar(1) COMMENT '重要程度: S / A / B / C',
	`approve_status` int COMMENT '审核状态：1 - 创建， 2 - 审核中 3 - 审核未通过 4 - 审核通过',
    `create_at`   datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间'
)  engine=innodb comment = '变更申请表';

INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) VALUES (2023, '变更管理', 0, 6, 'alteration', null, null, 1, 0, 'M', '0', '0', '', 'table', 'admin', '2024-05-17 16:39:18', 'admin', '2024-05-22 11:48:34', '');
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) VALUES (2053, '变更申请', 2023, 1, 'apply', 'alteration/apply/index', null, 1, 0, 'C', '0', '0', '', 'edit', 'admin', '2024-05-17 16:44:03', 'admin', '2024-05-17 21:27:53', '');
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) VALUES (2054, 'ECO验证', 2023, 2, 'verify', 'alteration/verify/index', null, 1, 0, 'C', '0', '0', '', 'server', 'admin', '2024-05-17 16:49:08', 'admin', '2024-05-23 17:52:02', '');
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) VALUES (2055, 'ECN执行', 2023, 3, 'execute', 'alteration/execute/index', null, 1, 0, 'C', '0', '0', 'jetplasma:alteration:execute', 'excel', 'admin', '2024-05-17 16:50:32', 'admin', '2024-05-25 00:34:14', '');
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) VALUES (2056, 'DEMO管理', 0, 7, 'demo', null, null, 1, 0, 'M', '0', '0', '', 'clipboard', 'admin', '2024-05-17 16:51:07', 'admin', '2024-05-22 17:55:37', '');
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) VALUES (2057, 'DEMO申请', 2027, 1, 'demo/apply', 'demo/apply/index', null, 1, 0, 'C', '0', '0', '', 'druid', 'admin', '2024-05-17 16:52:28', 'admin', '2024-05-25 11:31:50', '');
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) VALUES (2058, 'DEMO执行', 2027, 2, 'demo/execute', 'demo/execute/index', '', 1, 0, 'C', '0', '0', 'jetplasma:demo:execute', 'job', 'admin', '2024-05-17 16:53:45', 'admin', '2024-05-25 21:16:11', '');
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) VALUES (2059, '验证报告预览', 2054, 1, '', null, null, 1, 0, 'F', '0', '0', 'jetplasma:verify:preview', '#', 'admin', '2024-05-25 00:17:24', '', null, '');
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) VALUES (2060, '验证报告下载', 2054, 1, '', null, null, 1, 0, 'F', '0', '0', 'jetplasma:verify:download', '#', 'admin', '2024-05-25 00:17:49', 'admin', '2024-05-25 00:21:00', '');
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) VALUES (2061, '进度执行报告预览', 2055, 0, '', null, null, 1, 0, 'F', '0', '0', 'jetplasma:progress:preview', '#', 'admin', '2024-05-25 00:20:14', '', null, '');
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) VALUES (2062, '进度执行报告下载', 2055, 1, '', null, null, 1, 0, 'F', '0', '0', 'jetplasma:progress:download', '#', 'admin', '2024-05-25 00:20:44', 'admin', '2024-05-25 00:21:10', '');
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) VALUES (2063, '技术要求附件预览', 2057, 1, '', null, null, 1, 0, 'F', '0', '0', 'jetplasma:demo:preview', '#', 'admin', '2024-05-25 16:42:40', '', null, '');
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) VALUES (2064, '技术要求附件下载', 2057, 2, '', null, null, 1, 0, 'F', '0', '0', 'jetplasma:demo:download', '#', 'admin', '2024-05-25 16:43:01', '', null, '');
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) VALUES (2065, '阶段成果报告预览', 2058, 0, '', null, null, 1, 0, 'F', '0', '0', 'jetplasma:demo:exec:preview', '#', 'admin', '2024-05-25 23:51:16', '', null, '');
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) VALUES (2066, '阶段成果报告下载', 2058, 1, '', null, null, 1, 0, 'F', '0', '0', 'jetplasma:demo:exec:download', '#', 'admin', '2024-05-25 23:51:38', '', null, '');
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) VALUES (2067, 'ECO确认', 2054, 3, '', null, null, 1, 0, 'F', '0', '0', 'jetplasma:verify:confirm', '#', 'admin', '2024-06-02 17:04:24', '', null, '');

update sys_menu set order_num = 1, path = 'approve' , component = 'flow/approve/index' where menu_id = 2001;
update sys_menu set order_num = 2, path = 'definition' ,component = 'flow/definition/index' where menu_id = 2002;
update sys_menu set order_num = 8, path = 'flow' where menu_id = 2013;
update sys_menu set order_num = 9 where menu_id = 2020;

alter table app_master change cip_id alteration_id bigint null comment '变更申请编号';
alter table app_master
    add eco_id bigint null comment 'ECO验证ID' after alteration_id;
alter table app_master
    add demo_id int null comment 'demo编号' after eco_id;

drop table if exists jetplasma_eco;
CREATE TABLE `jetplasma_eco`  (
    `id`  bigint(20)      not null auto_increment primary key comment '主键ID',
    `alteration_id` bigint(20) NULL DEFAULT NULL COMMENT '变更申请ID',
    `alteration_no` varchar(20) COMMENT '申请编号',
    `item_type` varchar(100)  NOT NULL COMMENT '变更项目',
    `approve_status` int COMMENT '审核状态：1 - 创建， 2 - 审核中 3 - 审核不通过 4 - 审核通过',
    `description` longtext COMMENT '验证过程描述',
    `result` int NULL DEFAULT NULL COMMENT '验证结果: 1 - 通过，0 - 未通过',
    `report` varchar(200) COMMENT '验证报告',
    `confirm` int COMMENT '是否已确认：1 - 已确认， 0 - 未确认',
    `create_at`   datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间'
)  engine=innodb comment = 'ECO验证';

drop table if exists jetplasma_ecn;
create table jetplasma_ecn
(
    id            bigint auto_increment comment '主键ID' primary key,
    alteration_id bigint                             null comment '变更申请ID',
    alteration_no varchar(20)                        null comment '变更申请编号',
    eco_id        bigint                             null comment 'ECO编号',
    ecn_no        varchar(20)                        null comment 'ECN单号',
    device_type   varchar(500)                       null comment '设备类型',
    module        varchar(200)                       null comment '模块',
    ecn_depart    varchar(200)                       null comment '负责部门',
    ecn_user      varchar(200)                       null comment '负责人',
    pri           int(1)                             null comment 'pri',
    suggestion    longtext                           null comment '改善方案',
    open_day      datetime                           null comment 'OPEN_DAY',
    due_day       datetime                           null comment 'OPEN_DAY',
    close_day     datetime                           null comment 'OPEN_DAY',
    status        varchar(10)                        null comment '状态',
    create_at     datetime default CURRENT_TIMESTAMP null comment '创建时间'
) engine=innodb  comment 'ECN执行';




drop table if exists jetplasma_ecn_progress;
CREATE TABLE `jetplasma_ecn_progress`  (
    `id`  bigint(20)      not null auto_increment primary key comment '主键ID',
    `ecn_id` bigint(20) NULL DEFAULT NULL COMMENT '关联ECN ID',
    `user_id` bigint(20) NULL DEFAULT NULL COMMENT '填写人',
    `depart_id` bigint(20) NULL DEFAULT NULL COMMENT '填写部门',
    `apply_date` datetime NULL COMMENT '填写日期',
    `description` longtext COMMENT '进度描述',
    `report` varchar(200) COMMENT '进度执行报告',
    `create_at`   datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间'
)  engine=innodb comment = 'ECN执行进度';


drop table if exists jetplasma_ecn_spread;
CREATE TABLE `jetplasma_ecn_spread`  (
    `id`  bigint(20)      not null auto_increment primary key comment '主键ID',
    `ecn_id` bigint(20) NULL DEFAULT NULL COMMENT '所属ECN编号',
    `alteration_no` varchar(20) NULL DEFAULT NULL COMMENT '变更申请编号',
    `device_type` varchar(200) NULL DEFAULT NULL COMMENT '设备类型',
    `remark` varchar(200) COMMENT '备注',
    `create_at`   datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间'
)  engine=innodb comment = 'ECN展开机型';

drop table if exists jetplasma_demo;
CREATE TABLE `jetplasma_demo`  (
    `id`  bigint(20)      not null auto_increment primary key comment '主键ID',
    `demo_no` varchar(20) NULL DEFAULT NULL COMMENT '申请单号',
    `customer` varchar(20) NULL DEFAULT NULL COMMENT '客户名称',
    `device_type` varchar(200) NULL DEFAULT NULL COMMENT '产品类型',
    `order_num` int(4) COMMENT '预计订单量',
    `requirements` longtext comment '技术要求',
    `saler` varchar(200) NULL DEFAULT NULL COMMENT '负责销售',
    `delivery` datetime comment '预计交付日期',
    `blanket_qty` int comment 'Blanket Qty',
    `paffern_qty` int comment 'Paffern Qty',
    `structure_qty` int comment 'Structure Qty',
    `wafer_return` varchar(100) comment 'Wafer Return Or Not',
    `por_chamber` varchar(100) comment 'POR chamber type',
    `attachment` varchar(100) comment '技术要求附件',
    `approve_status` int COMMENT '审核状态：1 - 创建， 2 - 审核中 3 - 审核不通过 4- 审核通过',
    `create_at`   datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间'
)  engine=innodb comment = 'DEMO申请表';


drop table if exists jetplasma_demo_execute;
CREATE TABLE `jetplasma_demo_execute`  (
    `id`  bigint(20)      not null auto_increment primary key comment '主键ID',
    `demo_id` bigint(20) NULL DEFAULT NULL COMMENT 'DEMO编号',
    `exec_no` varchar(20) NULL DEFAULT NULL COMMENT '执行编号',
    `exec_date` datetime NULL DEFAULT NULL COMMENT '执行日期',
    `principals` varchar(200) NULL DEFAULT NULL COMMENT '执行负责人',
    `exec_status` int(1) NULL DEFAULT NULL COMMENT '执行状态：1 - 进行中, 2 - 已完成',
    `exec_result` varchar(20) NULL DEFAULT NULL COMMENT '执行结果， positive match、partial match、miss match',
    `suggestion` longtext COMMENT '建议',
    `conclusion` longtext COMMENT '销售结论',
    `create_at`   datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间'
)  engine=innodb comment = 'DEMO执行表';




drop table if exists jetplasma_demo_execute_progress;
CREATE TABLE `jetplasma_demo_execute_progress`  (
    `id`  bigint(20)      not null auto_increment primary key comment '主键ID',
    `exec_id` bigint(20) NULL DEFAULT NULL COMMENT 'demo执行ID',
    `description` longtext COMMENT '执行进展描述',
    `report` varchar(200) COMMENT '阶段成果报告',
    `create_at`   datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间'
)  engine=innodb comment = 'DEMO执行进度表';

alter table jetplasma_demo_execute
    add attachment varchar(200) null comment '附件' after conclusion;

drop view if exists jetplasma_demo_execute_view;
create view jetplasma_demo_execute_view as
select e.*, d.customer, d.device_type, d.saler, d.requirements from jetplasma_demo d, jetplasma_demo_execute e where d.id = e.demo_id;

INSERT INTO jetplasma.sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) VALUES (2042, 'DEMO执行附件预览', 2029, 2, '', null, null, 1, 0, 'F', '0', '0', 'jetplasma:demo:attachment:preview', '#', 'admin', '2021-07-22 16:23:23', 'admin', '2021-07-22 16:23:23', null);preview', '#', 'admin', '2024-06-03 18:46:56', '', null, '');
INSERT INTO jetplasma.sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) VALUES (2043, 'DEMO执行附件下载', 2029, 3, '', null, null, 1, 0, 'F', '0', '0', 'jetplasma:demo:attachment:download', '#', 'admin', '2024-06-03 18:47:24', '', null, '');

INSERT INTO jetplasma.sys_dict_type (dict_id, dict_name, dict_type, status, create_by, create_time, update_by, update_time, remark) VALUES (100, '流程流转状态', 'flow_status', '0', 'admin', '2024-05-28 20:33:24', '', null, null);
INSERT INTO jetplasma.sys_dict_type (dict_id, dict_name, dict_type, status, create_by, create_time, update_by, update_time, remark) VALUES (101, '是否发布', 'is_publish', '0', 'admin', '2024-06-04 09:43:29', '', null, null);
INSERT INTO jetplasma.sys_dict_type (dict_id, dict_name, dict_type, status, create_by, create_time, update_by, update_time, remark) VALUES (102, '重要程度', 'level', '0', 'admin', '2024-06-04 17:05:24', '', null, null);

INSERT INTO jetplasma.sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, update_by, update_time, remark) VALUES (100, 0, '待提交', '0', 'flow_status', null, 'info', 'N', '0', 'admin', '2024-05-28 20:34:27', 'admin', '2024-05-28 20:35:07', null);
INSERT INTO jetplasma.sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, update_by, update_time, remark) VALUES (101, 0, '审批中', '1', 'flow_status', null, 'primary', 'N', '0', 'admin', '2024-05-28 20:35:31', '', null, null);
INSERT INTO jetplasma.sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, update_by, update_time, remark) VALUES (102, 0, '审批通过', '2', 'flow_status', null, 'primary', 'N', '0', 'admin', '2024-05-28 20:35:41', '', null, null);
INSERT INTO jetplasma.sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, update_by, update_time, remark) VALUES (103, 0, '已完成', '3', 'flow_status', null, 'success', 'N', '0', 'admin', '2024-05-28 20:36:02', 'admin', '2024-06-04 11:11:35', null);
INSERT INTO jetplasma.sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, update_by, update_time, remark) VALUES (104, 0, '审批不通过', '9', 'flow_status', null, 'danger', 'N', '0', 'admin', '2024-05-30 17:17:26', '', null, null);
INSERT INTO jetplasma.sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, update_by, update_time, remark) VALUES (105, 0, '失效', '10', 'flow_status', null, 'danger', 'N', '0', 'admin', '2024-05-30 17:43:08', 'admin', '2024-06-04 11:11:56', null);
INSERT INTO jetplasma.sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, update_by, update_time, remark) VALUES (106, 0, '未发布', '0', 'is_publish', null, 'info', 'N', '0', 'admin', '2024-06-04 09:43:50', 'admin', '2024-06-04 14:49:19', null);
INSERT INTO jetplasma.sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, update_by, update_time, remark) VALUES (107, 1, '已发布', '1', 'is_publish', null, 'success', 'N', '0', 'admin', '2024-06-04 09:44:12', '', null, null);
INSERT INTO jetplasma.sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, update_by, update_time, remark) VALUES (108, 0, 'S', 'S', 'level', null, 'default', 'N', '0', 'admin', '2024-06-04 17:05:51', '', null, null);
INSERT INTO jetplasma.sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, update_by, update_time, remark) VALUES (109, 0, 'A', 'A', 'level', null, 'default', 'N', '0', 'admin', '2024-06-04 17:05:58', '', null, null);
INSERT INTO jetplasma.sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, update_by, update_time, remark) VALUES (110, 0, 'B', 'B', 'level', null, 'default', 'N', '0', 'admin', '2024-06-04 17:06:05', '', null, null);
INSERT INTO jetplasma.sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, update_by, update_time, remark) VALUES (111, 0, 'C', 'C', 'level', null, 'default', 'N', '0', 'admin', '2024-06-04 17:06:35', '', null, null);
-- 2024-06-15
INSERT INTO jetplasma.sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) VALUES (2044, 'ECO新增', 2024, 1, '', null, null, 1, 0, 'F', '0', '0', 'jetplasma:eco:add', '#', 'admin', '2024-06-15 14:39:43', '', null, '');
INSERT INTO jetplasma.sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) VALUES (2045, 'ECN新增', 2025, 2, '', null, null, 1, 0, 'F', '0', '0', 'jetplasma:ecn:add', '#', 'admin', '2024-06-15 14:40:10', '', null, '');
INSERT INTO jetplasma.sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) VALUES (2046, 'DEMO执行新增', 2028, 3, '', null, null, 1, 0, 'F', '0', '0', 'jetplasma:demo:execute:add', '#', 'admin', '2024-06-15 14:40:51', 'admin', '2024-06-15 14:41:26', '');
INSERT INTO jetplasma.sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) VALUES (2047, '执行状态', 2029, 0, '', null, null, 1, 0, 'F', '0', '0', 'jetplasma:demo:execute:complete', '#', 'admin', '2024-06-15 16:38:10', '', null, '');
INSERT INTO jetplasma.sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) VALUES (2048, '首页-变更管理跟踪报表导出', 2023, 4, '', null, null, 1, 0, 'F', '0', '0', 'jetplasma:trace:alter:export', '#', 'admin', '2024-06-15 18:55:59', '', null, '');
INSERT INTO jetplasma.sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) VALUES (2049, '首页-DEMO管理跟踪报表导出', 2027, 3, '', null, null, 1, 0, 'F', '0', '0', 'jetplasma:trace:demo:export', '#', 'admin', '2024-06-15 18:56:41', '', null, '');

-- 2024-06-16
 update sys_dict_data set dict_value = '8' where dict_code=103;

drop view if exists jetplasma_device_problem_all;
CREATE VIEW jetplasma_device_problem_all AS
select `jetplasma`.`jetplasma_device_problem_install`.`pro_no`        AS `pro_no`,
       `jetplasma`.`jetplasma_device_problem_install`.`device_id`     AS `device_id`,
       `jetplasma`.`jetplasma_device_problem_install`.`type`          AS `type`,
       `jetplasma`.`jetplasma_device_problem_install`.`subject`       AS `subject`,
       `jetplasma`.`jetplasma_device_problem_install`.`depart_id`     AS `depart_id`,
       `jetplasma`.`jetplasma_device_problem_install`.`user_id`       AS `user_id`,
       `jetplasma`.`jetplasma_device_problem_install`.`principal`     AS `principal`,
       `jetplasma`.`jetplasma_device_problem_install`.`CREATE_AT`     AS `create_at`,
       `jetplasma`.`jetplasma_device_problem_install`.`complete_date` AS `complete_date`,
       `jetplasma`.`jetplasma_device_problem_install`.`status`        AS `status`,
       NULL                                                           AS `expect_date`,
       'install'                                                      AS `pro_type`,
       `jetplasma`.`jetplasma_device_problem_install`.`case_id`       AS `case_id`,
       `jetplasma`.`jetplasma_device_problem_install`.`id`            AS `id`
from `jetplasma`.`jetplasma_device_problem_install`
union all
select `jetplasma`.`jetplasma_device_problem_test`.`pro_no`        AS `pro_no`,
       `jetplasma`.`jetplasma_device_problem_test`.`device_id`     AS `device_id`,
       `jetplasma`.`jetplasma_device_problem_test`.`type`          AS `type`,
       `jetplasma`.`jetplasma_device_problem_test`.`subject`       AS `subject`,
       `jetplasma`.`jetplasma_device_problem_test`.`depart_id`     AS `depart_id`,
       `jetplasma`.`jetplasma_device_problem_test`.`user_id`       AS `user_id`,
       `jetplasma`.`jetplasma_device_problem_test`.`principal`     AS `principal`,
       `jetplasma`.`jetplasma_device_problem_test`.`CREATE_AT`     AS `create_at`,
       `jetplasma`.`jetplasma_device_problem_test`.`complete_date` AS `complete_date`,
       `jetplasma`.`jetplasma_device_problem_test`.`status`        AS `status`,
       NULL                                                        AS `expect_date`,
       'test'                                                      AS `pro_type`,
       `jetplasma`.`jetplasma_device_problem_test`.`case_id`       AS `case_id`,
       `jetplasma`.`jetplasma_device_problem_test`.`id`    AS `id`
from `jetplasma`.`jetplasma_device_problem_test`
union all
select `jetplasma`.`jetplasma_device_problem_check`.`pro_no`        AS `pro_no`,
       `jetplasma`.`jetplasma_device_problem_check`.`device_id`     AS `device_id`,
       `jetplasma`.`jetplasma_device_problem_check`.`type`          AS `type`,
       `jetplasma`.`jetplasma_device_problem_check`.`subject`       AS `subject`,
       `jetplasma`.`jetplasma_device_problem_check`.`depart_id`     AS `depart_id`,
       `jetplasma`.`jetplasma_device_problem_check`.`user_id`       AS `user_id`,
       `jetplasma`.`jetplasma_device_problem_check`.`principal`     AS `principal`,
       `jetplasma`.`jetplasma_device_problem_check`.`CREATE_AT`     AS `create_at`,
       `jetplasma`.`jetplasma_device_problem_check`.`complete_date` AS `complete_date`,
       `jetplasma`.`jetplasma_device_problem_check`.`status`        AS `status`,
       NULL                                                         AS `expect_date`,
       'check'                                                      AS `pro_type`,
       `jetplasma`.`jetplasma_device_problem_check`.`case_id`       AS `case_id`,
       `jetplasma`.`jetplasma_device_problem_check`.`id`    AS `id`
from `jetplasma`.`jetplasma_device_problem_check`
union all
select `jetplasma`.`jetplasma_device_problem_sale`.`pro_no`        AS `pro_no`,
       `jetplasma`.`jetplasma_device_problem_sale`.`device_id`     AS `device_id`,
       `jetplasma`.`jetplasma_device_problem_sale`.`type`          AS `type`,
       `jetplasma`.`jetplasma_device_problem_sale`.`subject`       AS `subject`,
       `jetplasma`.`jetplasma_device_problem_sale`.`depart_id`     AS `depart_id`,
       `jetplasma`.`jetplasma_device_problem_sale`.`user_id`       AS `user_id`,
       `jetplasma`.`jetplasma_device_problem_sale`.`principal`     AS `principal`,
       `jetplasma`.`jetplasma_device_problem_sale`.`CREATE_AT`     AS `create_at`,
       `jetplasma`.`jetplasma_device_problem_sale`.`complete_date` AS `complete_date`,
       `jetplasma`.`jetplasma_device_problem_sale`.`status`        AS `status`,
       `jetplasma`.`jetplasma_device_problem_sale`.`expect_date`   AS `expect_date`,
       'sale'                                                      AS `pro_type`,
       `jetplasma`.`jetplasma_device_problem_sale`.`case_id`       AS `case_id`,
       `jetplasma`.`jetplasma_device_problem_sale`.`id`            AS `id`
from `jetplasma`.`jetplasma_device_problem_sale`;


---20240626
alter table jetplasma_alteration_apply
    add attachment varchar(200) null comment '附件' after approve_status;
alter table jetplasma_alteration_apply
    add project varchar(200) null comment '项目' after item_type;

alter table jetplasma_eco
    add level varchar(2) null comment '重要程度' after approve_status;

alter table jetplasma_alteration_apply drop column level;

alter table jetplasma_ecn drop column ecn_depart;

alter table jetplasma_ecn drop column ecn_user;

alter table jetplasma_ecn drop column open_day;

alter table jetplasma_ecn drop column due_day;

alter table jetplasma_ecn
    add attachment varchar(200) null comment '附件' after status;

alter table jetplasma_demo
    change paffern_qty pattern_qty varchar(100) null comment 'Pattern Qty';
alter table jetplasma_demo
    add wafer_day datetime null comment 'Wafer交付日期' after delivery;

create table jetplasma_ecn_meta (
    `id`  bigint(20)      not null auto_increment primary key comment '主键ID',
    `ecn_id` bigint(20) NULL DEFAULT NULL COMMENT 'ECN编号',
    `trace_type` varchar(20) NULL DEFAULT NULL COMMENT '变更追踪事项',
    `measure` longtext NULL DEFAULT NULL COMMENT '措施内容',
    `user_id` bigint(20) NULL DEFAULT NULL COMMENT '负责人',
    `depart_id` bigint(20) NULL DEFAULT NULL COMMENT '负责部门',
    `expect_date`datetime DEFAULT null COMMENT '预计完成日期',
    `complete_date`datetime DEFAULT null COMMENT '实际完成日期',
    `status` varchar(20) NULL DEFAULT NULL COMMENT '状态',
    `create_at`   datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间'
) engine=innodb comment = 'ECN执行辅助信息表';

INSERT INTO jetplasma.sys_dict_type (dict_id, dict_name, dict_type, status, create_by, create_time, update_by, update_time, remark) VALUES (103, 'ECN变更追踪事项', 'trace_type', '0', 'admin', '2024-06-27 23:04:51', '', null, null);
INSERT INTO jetplasma.sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, update_by, update_time, remark) VALUES (112, 0, '测试', '测试', 'trace_type', null, 'default', 'N', '0', 'admin', '2024-06-27 23:05:09', '', null, null);


alter table jetplasma_eco add open_day datetime null comment 'OPEN DAY' after description;
alter table jetplasma_eco add due_day datetime null comment 'DUE DAY' after open_day;
alter table jetplasma_eco add close_day datetime null comment 'CLOSE DAY' after open_day;


---20240702
alter table jetplasma_device
    add salesman bigint null comment '负责销售' after customer_name;
alter table jetplasma_ecn
    add project varchar(200) null comment '项目' after item_type;


---20240704
update sys_menu set perms='alteration:apply:index' where menu_id=2024;
update sys_menu set perms='alteration:verify:index' where menu_id=2025;
update sys_menu set perms='demo:apply:index' where menu_id=2028;
update sys_menu set perms='jetplasma:device:install' where menu_id=2004;

INSERT INTO jetplasma.sys_menu (menu_id, menu_name, perms, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, icon, create_by, create_time, update_by, update_time, remark) VALUES (2051, '附件预览', 'alteration:attachement:preview', 2024, 2, '', null, null, 1, 0, 'F', '0', '0', '#', 'admin', '2024-07-04 23:38:08', '', null, '');
INSERT INTO jetplasma.sys_menu (menu_id, menu_name, perms, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, icon, create_by, create_time, update_by, update_time, remark) VALUES (2052, '附件下载', 'alteration:attachement:download', 2024, 3, '', null, null, 1, 0, 'F', '0', '0', '#', 'admin', '2024-07-04 23:38:31', '', null, '');

---20240707
INSERT INTO jetplasma.flow_definition (id, flow_code, flow_name, version, is_publish, from_custom, from_path, create_time, update_time, del_flag, tenant_id) VALUES (8, 'Flow-008', 'ECN审核', '1.0.0', 0, 'N', null, '2024-05-27 16:50:01', '2024-07-04 23:18:09', null, null);
alter table jetplasma_ecn
    add approve_status int null comment '审核状态：1 - 创建， 2 - 审核中 3 - 已审核 ' after attachment;

