SET FOREIGN_KEY_CHECKS=0;

ALTER TABLE `hzims-ticket`.`hzims_standard_ticket_info` ADD COLUMN `signage` varchar(60) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '站点标识-两票编码' AFTER `ticket_type`;

ALTER TABLE `hzims-ticket`.`hzims_standard_ticket_info` ADD COLUMN `signage_code` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '编号（原站点ID）' AFTER `signage`;

ALTER TABLE `hzims-ticket`.`hzims_standard_ticket_info` ADD COLUMN `flow_user_id` varchar(2000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户Id' AFTER `signage_code`;

ALTER TABLE `hzims-ticket`.`hzims_standard_ticket_info` ADD COLUMN `flow_task_id` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '当前任务Id' AFTER `flow_user_id`;

ALTER TABLE `hzims-ticket`.`hzims_standard_ticket_info` ADD COLUMN `flow_task_name` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '当前任务名称' AFTER `flow_task_id`;

ALTER TABLE `hzims-ticket`.`hzims_standard_ticket_info` ADD COLUMN `next_step_operator` varchar(2000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '下一个审批人' AFTER `flow_task_name`;

ALTER TABLE `hzims-ticket`.`hzims_standard_ticket_info` ADD COLUMN `flow_status` int(11) NULL DEFAULT NULL COMMENT '流程状态' AFTER `next_step_operator`;

ALTER TABLE `hzims-ticket`.`hzims_standard_ticket_info` ADD COLUMN `flow_description` varchar(6000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程描述' AFTER `flow_status`;

ALTER TABLE `hzims-ticket`.`hzims_standard_ticket_info` ADD COLUMN `project_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '项目名称' AFTER `flow_description`;

ALTER TABLE `hzims-ticket`.`hzims_standard_ticket_info` ADD COLUMN `class_group_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '班组' AFTER `project_name`;

ALTER TABLE `hzims-ticket`.`hzims_standard_ticket_measure` ADD COLUMN `operation_time` datetime(0) NULL DEFAULT NULL COMMENT '操作时间' AFTER `matter_group`;

CREATE TABLE `hzims-ticket`.`hzims_ticket_info_danger`  (
                                                            `id` bigint(20) NULL DEFAULT NULL COMMENT '编号',
                                                            `ticket_id` bigint(20) NULL DEFAULT NULL,
                                                            `dangerous_point` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '危险点',
                                                            `maintenance` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '安全措施',
                                                            `create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '创建时间',
                                                            `update_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '更新时间',
                                                            `is_deleted` tinyint(4) NULL DEFAULT 0 COMMENT '逻辑删除'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

CREATE TABLE `hzims-ticket`.`hzims_work_ticket_finish`  (
                                                            `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '编号',
                                                            `ticket_id` bigint(20) NULL DEFAULT NULL COMMENT '工作票编号',
                                                            `temp_ground_num` int(11) NULL DEFAULT NULL COMMENT '临时接地线',
                                                            `temp_dismantle_num` int(11) NULL DEFAULT NULL COMMENT '临时拆除几组',
                                                            `ground_num` int(11) NULL DEFAULT NULL COMMENT '接地线几组',
                                                            `dismantle_num` int(11) NULL DEFAULT NULL COMMENT '拆除几组',
                                                            `retain_num` int(11) NULL DEFAULT NULL COMMENT '保留几组',
                                                            `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
                                                            `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
                                                            `principal` bigint(20) NULL DEFAULT NULL COMMENT '负责人名称',
                                                            `licensor` bigint(20) NULL DEFAULT NULL COMMENT '许可人',
                                                            `licensor_end_time` datetime(0) NULL DEFAULT NULL COMMENT '工作票终结时间',
                                                            `principal_end_time` datetime(0) NULL DEFAULT NULL COMMENT '负责人工作结束时间',
                                                            `content` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
                                                            `tell_content` varchar(5000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '交底内容',
                                                            `work_end_time` datetime(0) NULL DEFAULT NULL COMMENT '结束时间',
                                                            `brake_number` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '刀闸编号',
                                                            `guardian` bigint(20) NULL DEFAULT NULL COMMENT '监护人',
                                                            `guardian_place` varchar(60) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '监护人地址',
                                                            `other_items` varchar(2000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '其他事项',
                                                            PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '工作结束' ROW_FORMAT = Dynamic;

ALTER TABLE `hzims-ticket`.`hzims_work_ticket_info` ADD COLUMN `power` varchar(300) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT ' 工作条件（ 停电或不停电）' AFTER `watch_principal_end_time`;

ALTER TABLE `hzims-ticket`.`hzims_work_ticket_info` ADD COLUMN `flow_user_id` varchar(5000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户Id' AFTER `step_operator`;

ALTER TABLE `hzims-ticket`.`hzims_work_ticket_info` ADD COLUMN `project_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '项目名称' AFTER `flow_task_name`;

ALTER TABLE `hzims-ticket`.`hzims_work_ticket_info` ADD COLUMN `job_receiver` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '工作接收人' AFTER `project_name`;

ALTER TABLE `hzims-ticket`.`hzims_work_ticket_info` ADD COLUMN `job_receiver_time` datetime(0) NULL DEFAULT NULL COMMENT '工作接收人时间' AFTER `job_receiver`;

ALTER TABLE `hzims-ticket`.`hzims_work_ticket_info` ADD COLUMN `is_safety` tinyint(1) NULL DEFAULT 0 COMMENT '安全隔离措施附页 (true,展示附件,false,不展示附件)' AFTER `job_receiver_time`;

ALTER TABLE `hzims-ticket`.`hzims_work_ticket_info` ADD COLUMN `is_hazard` tinyint(1) NULL DEFAULT 0 COMMENT '危险点分析与预控措施票 (true,展示附件,false,不展示附件)' AFTER `is_safety`;

ALTER TABLE `hzims-ticket`.`hzims_work_ticket_info` ADD COLUMN `is_railway` tinyint(1) NULL DEFAULT 0 COMMENT '动火工作票 (true,展示附件,false,不展示附件)' AFTER `is_hazard`;

ALTER TABLE `hzims-ticket`.`hzims_work_ticket_info` ADD COLUMN `is_limited` tinyint(1) NULL DEFAULT 0 COMMENT ' 有限空间监测记录单(true,展示附件,false,不展示附件)' AFTER `is_railway`;

ALTER TABLE `hzims-ticket`.`hzims_work_ticket_info` ADD COLUMN `is_start` tinyint(1) NULL DEFAULT 0 COMMENT '每日开工和收工时间附页' AFTER `is_limited`;

ALTER TABLE `hzims-ticket`.`hzims_work_ticket_info` MODIFY COLUMN `flow_description` varchar(6000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程描述' AFTER `flow_status`;

ALTER TABLE `hzims-ticket`.`hzims_work_ticket_info` MODIFY COLUMN `follower_num` int(11) NULL DEFAULT 1 COMMENT '附页第几张' AFTER `flow_description`;

ALTER TABLE `hzims-ticket`.`hzims_work_ticket_info` MODIFY COLUMN `next_step_operator` varchar(2000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '下一个审批人' AFTER `input`;

ALTER TABLE `hzims-ticket`.`hzims_work_ticket_info` MODIFY COLUMN `step_operator` varchar(60) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '当前审批人' AFTER `next_step_operator`;

ALTER TABLE `hzims-ticket`.`hzims_work_ticket_info` DROP COLUMN `is_power`;

ALTER TABLE `hzims-ticket`.`hzims_work_ticket_info` DROP COLUMN `start_date_time`;

ALTER TABLE `hzims-ticket`.`hzims_work_ticket_info` DROP COLUMN `end_date_time`;

ALTER TABLE `hzims-ticket`.`hzims_work_ticket_info` DROP COLUMN `content`;

ALTER TABLE `hzims-ticket`.`hzims_work_ticket_info` DROP COLUMN `work_ticket_end_time`;

ALTER TABLE `hzims-ticket`.`hzims_work_ticket_info` DROP COLUMN `tell_content`;

CREATE TABLE `hzims-ticket`.`hzims_work_ticket_info_copy1`  (
                                                                `id` bigint(20) NOT NULL COMMENT '主键',
                                                                `em_code` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '设备名称',
                                                                `em_name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '设备名称',
                                                                `process_instance_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '工作流ID',
                                                                `type` varchar(2) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '工作票类型',
                                                                `company` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '单位',
                                                                `code` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '编号',
                                                                `task_type` varchar(2) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '关联业务类型',
                                                                `task_id` bigint(20) NULL DEFAULT NULL COMMENT '关联业务ID',
                                                                `task_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '关联业务名称',
                                                                `class_group` bigint(20) NULL DEFAULT NULL COMMENT '班组',
                                                                `class_group_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '班组名称',
                                                                `class_group_members` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '班组成员',
                                                                `class_group_members_manual` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '班组成员手填',
                                                                `address_equ_name` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '工作地点及设备名称',
                                                                `work_content` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '工作任务及内容',
                                                                `plan_start_time` datetime(0) NULL DEFAULT NULL COMMENT '计划开始时间',
                                                                `plan_end_time` datetime(0) NULL DEFAULT NULL COMMENT '计划结束时间',
                                                                `signer` bigint(20) NULL DEFAULT NULL COMMENT '签发人',
                                                                `principal` bigint(20) NULL DEFAULT NULL COMMENT '负责人',
                                                                `principal_manual` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '负责人手填',
                                                                `licensor` bigint(20) NULL DEFAULT NULL COMMENT '许可人',
                                                                `license_time` datetime(0) NULL DEFAULT NULL COMMENT '许可时间',
                                                                `flow_code` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程进行code',
                                                                `license_end_time` datetime(0) NULL DEFAULT NULL COMMENT '许可人确认工作结束时间',
                                                                `is_evaluate` tinyint(4) NULL DEFAULT 0 COMMENT '是否评价',
                                                                `status` tinyint(4) NULL DEFAULT NULL COMMENT '1：未完成 2：执行中 3：已完成',
                                                                `tenant_id` varchar(12) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '租户ID',
                                                                `create_user` bigint(20) NOT NULL COMMENT '创建人',
                                                                `create_time` datetime(0) NOT NULL COMMENT '创建时间',
                                                                `update_user` bigint(20) NULL DEFAULT NULL,
                                                                `update_time` datetime(0) NULL DEFAULT NULL,
                                                                `is_deleted` tinyint(4) NULL DEFAULT NULL,
                                                                `create_dept` bigint(20) NOT NULL COMMENT '创建部门',
                                                                `confirm_img_urls` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '工作负责人确认工作完成上传图片地址',
                                                                `confirm_img_filenames` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '工作负责人确认工作完成上传图片名称',
                                                                `sort` tinyint(4) NULL DEFAULT NULL COMMENT '排序',
                                                                `confirm_work_time` datetime(0) NULL DEFAULT NULL COMMENT '工作负责人确认工作完成时间',
                                                                `pattern` varchar(2) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '类型（1：值班人员添加2：许可人添加）',
                                                                PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '工作票' ROW_FORMAT = Dynamic;

ALTER TABLE `hzims-ticket`.`hzims_work_ticket_safety_measure` MODIFY COLUMN `type` varchar(4) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '类型（1：值班人员添加2：签发人添加3：许可人添加）' AFTER `measure`;

ALTER TABLE `hzims-ticket`.`hzims_work_ticket_safety_measure` MODIFY COLUMN `execute_img_url` varchar(300) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '拍照上传图片url' AFTER `execute_remark`;

ALTER TABLE `hzims-ticket`.`hzims_work_ticket_safety_measure` MODIFY COLUMN `completer` bigint(20) NULL DEFAULT NULL COMMENT '内容执行人' AFTER `status`;

ALTER TABLE `hzims-ticket`.`hzims_work_ticket_safety_measure` MODIFY COLUMN `complete_img_url` varchar(300) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '完成内容上传图片地址' AFTER `complete_time`;

ALTER TABLE `hzims-ticket`.`hzims_work_ticket_safety_measure` MODIFY COLUMN `pattern` varchar(2) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '1' COMMENT '类型（1：值班人员添加2：许可人添加）' AFTER `sort`;

CREATE TABLE `hzims-ticket`.`hzims_work_ticket_safety_measure_copy1`  (
                                                                          `id` bigint(20) NOT NULL COMMENT '主键ID',
                                                                          `ticket_id` bigint(20) NOT NULL COMMENT '工作票ID',
                                                                          `measure_id` bigint(20) NULL DEFAULT NULL COMMENT '安全措施ID',
                                                                          `matter_group` bigint(20) NULL DEFAULT NULL COMMENT '分组',
                                                                          `measure` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '安全措施',
                                                                          `type` varchar(4) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '类型（1：值班人员添加2：签发人添加3：许可人添加）',
                                                                          `executor` bigint(20) NULL DEFAULT NULL COMMENT '执行人',
                                                                          `execute_time` datetime(0) NULL DEFAULT NULL COMMENT '执行时间',
                                                                          `execute_remark` tinytext CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '执行情况',
                                                                          `execute_img_url` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '拍照上传图片url',
                                                                          `status` tinyint(20) NULL DEFAULT NULL,
                                                                          `completer` bigint(20) NULL DEFAULT NULL COMMENT '内容执行人',
                                                                          `complete_time` datetime(0) NULL DEFAULT NULL COMMENT '内容完成时间',
                                                                          `complete_img_url` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '完成内容上传图片地址',
                                                                          `create_user` bigint(20) NOT NULL COMMENT '创建人',
                                                                          `create_time` datetime(0) NOT NULL COMMENT '创建时间',
                                                                          `update_user` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
                                                                          `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
                                                                          `is_deleted` tinyint(4) NULL DEFAULT NULL,
                                                                          `create_dept` bigint(20) NOT NULL COMMENT '创建机构',
                                                                          `tenant_id` varchar(12) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '租户id',
                                                                          `sort` tinyint(4) NULL DEFAULT NULL COMMENT '排序',
                                                                          PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '工作票安全措施列表' ROW_FORMAT = Dynamic;

DROP TABLE `hzims-ticket`.`hzims_workflow_operation_log`;

SET FOREIGN_KEY_CHECKS=1;