/*工时分析模块*/

DROP TABLE IF EXISTS `part_workinghour`;
CREATE TABLE `part_workinghour`
(
    `id`           bigint(0)                                                     NOT NULL COMMENT '主键',
    `status`       tinyint(0)                                                    NULL DEFAULT NULL COMMENT '状态',
    `is_deleted`   int                                                      NULL DEFAULT NULL COMMENT '删除',
    `create_user`  varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
    `create_dept`  bigint(0)                                                     NULL DEFAULT NULL COMMENT '创建部门',
    `create_time`  datetime(0)                                                   NULL DEFAULT NULL COMMENT '创建时间',
    `update_user`  bigint(0)                                                     NULL DEFAULT NULL COMMENT '更新人',
    `update_time`  datetime(0)                                                   NULL DEFAULT NULL COMMENT '更新时间',
    `tenant_id`    varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL DEFAULT '0' COMMENT '租户',
    `part_no`      varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '零件编号',
    `process_no`   varchar(20)                                                   NULL DEFAULT NULL COMMENT '工序号',
    `version` varchar(20)  NULL DEFAULT NULL COMMENT '版次',
    
    `seg_total`   int                                                      NULL DEFAULT NULL COMMENT '工序段数',
    `workstation_id`    bigint                                               NULL DEFAULT 0 COMMENT '工位id',
    `start_time`  datetime(3)                                                   NULL DEFAULT NULL COMMENT '开始时间',
    `end_time`  datetime(3)                                                   NULL DEFAULT NULL COMMENT '结束时间',
    `occupancy_secs`    bigint                                               NULL DEFAULT 0 COMMENT '占机时间(秒)', 	
	`clamping_secs`    bigint                                               NULL DEFAULT 0 COMMENT '装夹调试时间(秒)', 	
	`first_working_secs`    bigint                                               NULL DEFAULT 0 COMMENT '首件切削时间(秒)',
	`last_remove_secs`    bigint                                               NULL DEFAULT 0 COMMENT '末件拆卸时间(秒)',
    `first_measure_secs`    bigint                                               NULL DEFAULT 0 COMMENT '首件计量时间(秒)',
    `processing_secs`    bigint                                               NULL DEFAULT 0 COMMENT '加工时间(秒)',
    `prepare_secs`    bigint                                               NULL DEFAULT 0 COMMENT '准备时间(秒)',
    `single_process_secs`    bigint                                               NULL DEFAULT 0 COMMENT '单件工时(秒)',
    `amount`    bigint                                               NULL DEFAULT 0 COMMENT '数量(该批次内)',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '零件工时'
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `part_working_process`;
CREATE TABLE `part_working_process`
(
    `id`           bigint(0)                                                     NOT NULL COMMENT '主键',
    `status`       tinyint(0)                                                    NULL DEFAULT NULL COMMENT '状态',
    `is_deleted`   int                                                      NULL DEFAULT NULL COMMENT '删除',
    `create_user`  varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
    `create_dept`  bigint(0)                                                     NULL DEFAULT NULL COMMENT '创建部门',
    `create_time`  datetime(0)                                                   NULL DEFAULT NULL COMMENT '创建时间',
    `update_user`  bigint(0)                                                     NULL DEFAULT NULL COMMENT '更新人',
    `update_time`  datetime(0)                                                   NULL DEFAULT NULL COMMENT '更新时间',
    `prog_name`    varchar(120) NULL DEFAULT NULL COMMENT '程序名称',
    `workinghour_id`    bigint                                               NOT NULL COMMENT '零件工时表id',
    `start_time`  datetime(3)                                                   NULL DEFAULT NULL COMMENT '开始时间',
    `end_time`  datetime(3)                                                   NULL DEFAULT NULL COMMENT '结束时间',
    `device_status`  int                                                   NULL DEFAULT NULL COMMENT '设备状态',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '零件加工过程记录'
  ROW_FORMAT = Dynamic;