DROP TABLE IF EXISTS `pro_assy_kpsn`;
DROP TABLE IF EXISTS `pro_issue_part`;
DROP TABLE IF EXISTS pro_pack_d_data;
DROP TABLE IF EXISTS pro_pack_m_data;
DROP TABLE IF EXISTS pro_piece_count;
DROP TABLE IF EXISTS pro_piece_status;
DROP TABLE IF EXISTS pro_piece_status_log;
DROP TABLE IF EXISTS pro_put_in_storage;
DROP TABLE IF EXISTS pro_report_work;
DROP TABLE IF EXISTS pro_temp_kpsn;
DROP TABLE IF EXISTS pro_wo;
DROP TABLE IF EXISTS pro_wo_sn;

DROP TABLE IF EXISTS `pro_task_dispatch`;
CREATE TABLE `pro_task_dispatch` (
                                     `id` BIGINT ( 20 ) NOT NULL AUTO_INCREMENT COMMENT '自增字段，唯一',
                                     `code` VARCHAR ( 32 ) DEFAULT NULL COMMENT '编号，唯一',
                                     `dispatch_type` varchar(16) not null comment '派工类型 生产任务|装配任务 PRODUCTION|ASSEMBLE',
                                     `task_id` BIGINT ( 20 ) COMMENT '生产任务id',
                                     `plan_id` BIGINT ( 20 ) NOT NULL COMMENT '生产计划id',
                                     `project_id` BIGINT ( 20 ) NOT NULL COMMENT '项目id',
                                     `project_sub_id` BIGINT ( 20 ) NOT NULL COMMENT '子项目id',
                                     `bom_detail_id` BIGINT ( 20 ) COMMENT 'bom明细id',
                                     `dispatch_status` TINYINT ( 1 ) NOT NULL COMMENT '派工状态 已保存|已提交|已终止 1|2|3',
                                     `remark` VARCHAR ( 255 ) DEFAULT NULL COMMENT '备注',
                                     `status` TINYINT ( 1 ) NOT NULL DEFAULT '1' COMMENT '状态,1表示正常，2表示禁用',
                                     `creator` VARCHAR ( 64 ) DEFAULT '' COMMENT '创建者',
                                     `create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                     `updater` VARCHAR ( 64 ) DEFAULT '' COMMENT '更新者',
                                     `update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
                                     `deleted` BIT ( 1 ) NOT NULL DEFAULT b'0' COMMENT '是否删除',
                                     `tenant_id` BIGINT ( 20 ) NOT NULL DEFAULT '0' COMMENT '租户编号',
                                     PRIMARY KEY ( `id` ) USING BTREE,
                                     KEY `idx_plan` ( `plan_id` ) USING BTREE,
                                     KEY `idx_project` ( `project_id` ) USING BTREE
) ENGINE = InnoDB COMMENT = '派工单表';

DROP TABLE IF EXISTS `pro_task_dispatch_detail`;
CREATE TABLE `pro_task_dispatch_detail` (
                                            `id` BIGINT ( 20 ) NOT NULL AUTO_INCREMENT COMMENT '自增字段，唯一',
                                            `procedure_id` BIGINT ( 20 ) NOT NULL COMMENT '工序id',
                                            `sort` INT ( 11 ) NOT NULL COMMENT '顺序号',
                                            `owner` BIGINT ( 20 ) NOT NULL COMMENT '负责人',
                                            `work_time` DECIMAL ( 20, 2 ) NOT NULL COMMENT '预计工时',
                                            `amount` INT ( 11 ) NOT NULL COMMENT '派工数量',
                                            `summary` VARCHAR ( 255 ) DEFAULT NULL COMMENT '工序要点',
                                            `status` TINYINT ( 1 ) NOT NULL DEFAULT '1' COMMENT '状态,1表示正常，2表示禁用',
                                            `creator` VARCHAR ( 64 ) DEFAULT '' COMMENT '创建者',
                                            `create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                            `updater` VARCHAR ( 64 ) DEFAULT '' COMMENT '更新者',
                                            `update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
                                            `deleted` BIT ( 1 ) NOT NULL DEFAULT b'0' COMMENT '是否删除',
                                            `tenant_id` BIGINT ( 20 ) NOT NULL DEFAULT '0' COMMENT '租户编号',
                                            PRIMARY KEY ( `id` ) USING BTREE
) ENGINE = InnoDB COMMENT = '派工明细表';
