CREATE TABLE `mes_work_team`
(
    `id`                  bigint                                                       NOT NULL AUTO_INCREMENT COMMENT 'ID',
    `team_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci          DEFAULT NULL COMMENT '班组名称',
    `team_leader_id`     bigint   NOT NULL COMMENT '组长ID',

    `team_type`         varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci         DEFAULT '' COMMENT '工序类型',

    `remark`              varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci         DEFAULT '' COMMENT '备注',
    `is_enable`           bit(1)                                                       NOT NULL DEFAULT b'1' COMMENT '是否启用',
    `creator`             varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci          DEFAULT '' COMMENT '创建者',
    `create_time`         datetime                                                     NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater`             varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci          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                                                                DEFAULT NULL COMMENT '租户id',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=91 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='生产报工单';

CREATE TABLE `mes_work_team_detail`
(
    `id`          bigint   NOT NULL AUTO_INCREMENT COMMENT 'ID',
    `work_team_id`  bigint   DEFAULT NULL COMMENT '班组id',
    `user_id`  bigint   NOT NULL COMMENT '用户ID',

    `user_role`         tinyint                                                      NOT NULL COMMENT '角色',
    `remark`            varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '备注',

    `creator`           varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci  DEFAULT '' COMMENT '创建者',
    `create_time`       datetime NOT NULL                                             DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater`           varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci  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                                                        DEFAULT NULL COMMENT '租户id',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=91 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='生产报工明细';

CREATE TABLE `mes_produce_report`
(
    `id`                  bigint                                                       NOT NULL AUTO_INCREMENT COMMENT 'ID',
    `process_instance_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci          DEFAULT NULL COMMENT '流程实例的编号',
    `work_team_id`     bigint   NOT NULL COMMENT '组别ID',
    `group_id`     bigint   NOT NULL COMMENT '班组ID',
    `report_date`         datetime                                                     NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '报工日期',
    `status`         tinyint                                                      NOT NULL COMMENT '状态',
    `group_type`         tinyint                                                      NOT NULL COMMENT '白班/夜班',

    `remark`              varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci         DEFAULT '' COMMENT '备注',
    `is_enable`           bit(1)                                                       NOT NULL DEFAULT b'1' COMMENT '是否启用',
    `creator`             varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci          DEFAULT '' COMMENT '创建者',
    `create_time`         datetime                                                     NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater`             varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci          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                                                                DEFAULT NULL COMMENT '租户id',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=91 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='生产报工单';

CREATE TABLE `mes_produce_report_detail`
(
    `id`          bigint   NOT NULL AUTO_INCREMENT COMMENT 'ID',
    `report_id`  bigint   DEFAULT NULL COMMENT '报工单id',
    `plan_id`     bigint   NOT NULL COMMENT '生产计划ID',
    `product_id`  bigint   NOT NULL COMMENT '产品ID',
    `user_id`  bigint   NOT NULL COMMENT '用户ID',
    `org_id`  bigint   NOT NULL COMMENT '组织ID',
    `quality_number`       decimal(24, 6)                                                DEFAULT NULL COMMENT '成品数量',
    `waste_number`       decimal(24, 6)                                                DEFAULT NULL COMMENT '废品数量',
    `total_number`       decimal(24, 6)                                                DEFAULT NULL COMMENT '废品数量',
    `quality_rate`       decimal(24, 6)                                                DEFAULT NULL COMMENT '成品率',
    `waste_reason`      varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '备注',
    `report_time`       datetime NOT NULL                                             DEFAULT CURRENT_TIMESTAMP COMMENT '计件时间',
    `total_time`       decimal(24, 6)                                                DEFAULT NULL COMMENT '总时长',
    `package_number`       decimal(24, 6)                                                DEFAULT NULL COMMENT '打包数量',
    `remark`            varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '备注',
    `is_enable`         bit(1)   NOT NULL                                             DEFAULT b'1' COMMENT '是否启用',
    `creator`           varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci  DEFAULT '' COMMENT '创建者',
    `create_time`       datetime NOT NULL                                             DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater`           varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci  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                                                        DEFAULT NULL COMMENT '租户id',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=91 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='生产报工明细';


