

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for auxiliary_data
-- ----------------------------
DROP TABLE IF EXISTS `auxiliary_data`;
CREATE TABLE `auxiliary_data`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  `auxiliary_resource_coding` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NOT NULL COMMENT '辅助资源编码',
  `auxiliary_resource_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '辅助资源名称',
  `type` tinyint NOT NULL COMMENT '类型',
  `status` int NULL DEFAULT NULL COMMENT '状态',
  `description` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '描述',
  `data_source` tinyint NULL DEFAULT NULL COMMENT '数据来源',
  `creator` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 145 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '辅助资料' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for bom
-- ----------------------------
DROP TABLE IF EXISTS `bom`;
CREATE TABLE `bom`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `bom_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NOT NULL COMMENT 'BOM编码',
  `bom_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'bom名称',
  `material_id` bigint NULL DEFAULT NULL COMMENT '物料id',
  `material_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NOT NULL COMMENT '物料编码',
  `material_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '物料名称',
  `data_source` tinyint NULL DEFAULT 1 COMMENT '数据来源:1-->数据录入;2-->人工录入',
  `creator` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '创建人',
  `create_time` datetime(0) NOT NULL COMMENT '创建时间',
  `update_time` datetime(0) NOT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_create_time`(`create_time`) USING BTREE,
  INDEX `idx_bom_name`(`bom_name`) USING BTREE,
  INDEX `idx_material_code`(`material_code`) USING BTREE,
  INDEX `idx_bom_code`(`bom_code`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1426072199 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'BOM表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for bom_item
-- ----------------------------
DROP TABLE IF EXISTS `bom_item`;
CREATE TABLE `bom_item`  (
  `id` bigint NOT NULL COMMENT '主键id',
  `level` tinyint NOT NULL COMMENT '层级',
  `bom_id` int NOT NULL COMMENT 'bom id',
  `bom_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NOT NULL COMMENT 'BOM编码',
  `parent_id` bigint NULL DEFAULT NULL COMMENT '上层子项Bom',
  `material_id` bigint NULL DEFAULT NULL COMMENT '物料id',
  `material_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NOT NULL COMMENT '物料编码',
  `material_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '物料名称',
  `material_specification` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '物料规格',
  `production_type` tinyint NULL DEFAULT NULL COMMENT '生产类型',
  `unit_usage` decimal(65, 2) NULL DEFAULT NULL,
  `unit` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '单位',
  `remarks` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime(0) NOT NULL COMMENT '创建时间',
  `update_time` datetime(0) NOT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_bom_code`(`bom_code`) USING BTREE,
  INDEX `idx_material_code`(`material_code`) USING BTREE,
  INDEX `idx_parent_id`(`parent_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'bom子项表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for class_system
-- ----------------------------
DROP TABLE IF EXISTS `class_system`;
CREATE TABLE `class_system`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  `period_ids` json NOT NULL COMMENT '工作时段Id列表 下标周一到周日',
  `device_ids` json NOT NULL COMMENT '设备组id集合',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 147 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '班制' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for customer_information
-- ----------------------------
DROP TABLE IF EXISTS `customer_information`;
CREATE TABLE `customer_information`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  `customer_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '客户编码',
  `customer_company_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `customer_phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `customer_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '客户名称',
  `customer_priority` int NULL DEFAULT NULL COMMENT '客户优先级',
  `data_source` tinyint NULL DEFAULT NULL COMMENT '数据来源',
  `creator` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_create_time`(`create_time`) USING BTREE COMMENT '创建时间索引',
  INDEX `idx_customer_code`(`customer_code`) USING BTREE COMMENT '客户编码索引'
) ENGINE = InnoDB AUTO_INCREMENT = 1000005 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '客户信息' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for equipment
-- ----------------------------
DROP TABLE IF EXISTS `equipment`;
CREATE TABLE `equipment`  (
  `id` bigint NOT NULL COMMENT '主键',
  `equipment_number` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '设备编号',
  `device_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备名称',
  `device_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备类型',
  `equipment_status` tinyint NOT NULL COMMENT '设备状态',
  `workshop_id` int NOT NULL COMMENT '所属车间id',
  `workshop_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '车间编码',
  `workshop_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '所属车间',
  `creator` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '创建人',
  `data_source` tinyint NOT NULL COMMENT '数据来源',
  `create_time` datetime(0) NOT NULL COMMENT '创建时间',
  `update_time` datetime(0) NOT NULL ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '更新时间',
  `latest_time` datetime(0) NOT NULL COMMENT '设备最后工作时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_equipment_number`(`equipment_number`) USING BTREE COMMENT '设备编码索引'
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备' ROW_FORMAT = Dynamic;


-- ----------------------------
-- Table structure for gantt_chartequipment
-- ----------------------------
DROP TABLE IF EXISTS `gantt_chartequipment`;
CREATE TABLE `gantt_chartequipment`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  `device_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '设备编码',
  `device_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '设备名称',
  `workshop_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '车间名称',
  `number_of_tasks` int NULL DEFAULT NULL COMMENT '任务数',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '甘特图-设备' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for global_settings_for_scheduling
-- ----------------------------
DROP TABLE IF EXISTS `global_settings_for_scheduling`;
CREATE TABLE `global_settings_for_scheduling`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  `scheduling_start_time` date NULL DEFAULT NULL COMMENT '排程开始时间',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '更新时间',
  `scheduling_latest_start_time` datetime(0) NULL DEFAULT NULL COMMENT '排程最新开始时间',
  `scheduling_end_time` date NULL DEFAULT NULL COMMENT '排程结束时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 875929601 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '排产全局设置' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for material
-- ----------------------------
DROP TABLE IF EXISTS `material`;
CREATE TABLE `material`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `material_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '物料编码',
  `material_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '物料名称',
  `material_classification_id` int NOT NULL COMMENT '物料分类',
  `production_type` tinyint NOT NULL COMMENT '生产类型',
  `material_specification` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '物料规格',
  `manufacturing_strategy` int NOT NULL COMMENT '制造策略',
  `actual_inventory` decimal(65, 2) NULL DEFAULT NULL COMMENT '实际库存',
  `safety_inventory` decimal(65, 2) NULL DEFAULT NULL COMMENT '安全库存',
  `inventory` decimal(65, 2) NULL DEFAULT NULL COMMENT '库存',
  `minimum_order_quantity` int NULL DEFAULT NULL COMMENT '最小起订量',
  `maximum_order_quantity` int NULL DEFAULT NULL COMMENT '最大起订量',
  `fixed_lead_time` bigint NULL DEFAULT NULL COMMENT '固定提前期',
  `fixed_lead_time_batch` bigint NULL DEFAULT NULL COMMENT '固定提前期批量',
  `finished_product_rate` decimal(5, 2) NULL DEFAULT NULL COMMENT '成品率',
  `material` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '材质',
  `data_source` tinyint NULL DEFAULT NULL COMMENT '数据来源',
  `creator` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime(0) NOT NULL COMMENT '创建时间',
  `update_time` datetime(0) NOT NULL COMMENT '更新时间',
  `material_unit_id` int NULL DEFAULT NULL COMMENT '物料单位id',
  `product_unit` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '生产单位',
  `purchase_unit` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '采购单位',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_material_code`(`material_code`) USING BTREE COMMENT '物料编码索引'
) ENGINE = InnoDB AUTO_INCREMENT = 1770695851045322753 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '物料' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for material_classification
-- ----------------------------
DROP TABLE IF EXISTS `material_classification`;
CREATE TABLE `material_classification`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  `classification_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '分类名称',
  `description` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '描述',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_classification_name`(`classification_name`) USING BTREE COMMENT '物料分类索引'
) ENGINE = InnoDB AUTO_INCREMENT = 40 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '物料分类' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for material_unit
-- ----------------------------
DROP TABLE IF EXISTS `material_unit`;
CREATE TABLE `material_unit`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  `product_unit` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '生产单位',
  `purchase_unit` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '采购单位',
  `product_purchase_unit_ratio` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '生产单位:采购单位',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_product_unit`(`product_unit`) USING BTREE COMMENT '生产单位索引',
  INDEX `idx_purchase_unit`(`purchase_unit`) USING BTREE COMMENT '采购单位索引'
) ENGINE = InnoDB AUTO_INCREMENT = 177 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '物料单位' ROW_FORMAT = Dynamic;


-- ----------------------------
-- Table structure for order_information
-- ----------------------------
DROP TABLE IF EXISTS `order_information`;
CREATE TABLE `order_information`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  `order_number` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '订单号',
  `item_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '物料编码',
  `item_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '物料名称',
  `item_stock` decimal(65, 2) NULL DEFAULT NULL COMMENT '物料实际库存',
  `order_quantity` decimal(10, 2) NULL DEFAULT NULL COMMENT '产品数量',
  `order_delivery_date` date NULL DEFAULT NULL COMMENT '订单交期',
  `order_date` date NULL DEFAULT NULL COMMENT '下单日期',
  `planned_quantity` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '计划数量',
  `planned_end_time` datetime(0) NULL DEFAULT NULL COMMENT '计划结束时间',
  `customer_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '客户编码',
  `customer_company_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '客户公司名称',
  `scheduling_status` tinyint NULL DEFAULT 0 COMMENT '排产状态',
  `creator` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `order_priority` tinyint NULL DEFAULT 5 COMMENT '订单优先级',
  `data_source` tinyint NULL DEFAULT 2 COMMENT '数据来源',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  `is_wait_arrange` tinyint(1) NULL DEFAULT 0 COMMENT '排程备注 0->非重排 1->待重排',
  `labels` json NULL COMMENT '订单标签',
  `plan_extension` int NULL DEFAULT NULL COMMENT '计划延期(天)',
  `reality_extension` int NULL DEFAULT NULL COMMENT '实际延期(天)',
  `manufacturing_strategy` tinyint(1) NOT NULL DEFAULT 1 COMMENT '制造策略',
  `planned_start_time` datetime(0) NULL DEFAULT NULL COMMENT '计划开始时间',
  `material_id` bigint NOT NULL COMMENT '物料id',
  `customer_id` int NULL DEFAULT NULL COMMENT '客户id',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_item_code`(`item_code`) USING BTREE,
  INDEX `order_number`(`order_number`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1595318547 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '订单信息' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for plan_operation_progress
-- ----------------------------
DROP TABLE IF EXISTS `plan_operation_progress`;
CREATE TABLE `plan_operation_progress`  (
  `id` bigint NOT NULL COMMENT '主键id',
  `rate` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '进度百分比',
  `order_ids` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '排程订单号集合',
  `status` int NULL DEFAULT 1 COMMENT '状态（1成功 2失败）',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '操作时间',
  `creator` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '操作人',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '计划运算进度' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for process_details
-- ----------------------------
DROP TABLE IF EXISTS `process_details`;
CREATE TABLE `process_details`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  `order_number` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '订单号',
  `process_id` int NULL DEFAULT NULL COMMENT '工序id',
  `process_number` int NULL DEFAULT NULL COMMENT '工序号',
  `process_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '工序编码',
  `process_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '工序名称',
  `process_description` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '工序描述',
  `material_id` bigint NULL DEFAULT NULL COMMENT '物料id',
  `material_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '物料编码',
  `material_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '物料名称',
  `workshop_id` int NULL DEFAULT NULL COMMENT '车间id',
  `workshop_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '车间编码',
  `workshop_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '车间名称',
  `equipment_id` bigint NOT NULL COMMENT '设备id',
  `equipment_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '设备编码',
  `equipment_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '设备名称',
  `auxiliary_data_id` int NULL DEFAULT NULL COMMENT '辅助资料id',
  `auxiliary_data_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '辅助资料名称',
  `auxiliary_data_coding` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '辅助资料编码',
  `planned_start_time` datetime(0) NOT NULL COMMENT '计划开始时间',
  `planned_end_time` datetime(0) NOT NULL COMMENT '计划结束时间',
  `auxiliary_begin_time` datetime(0) NULL DEFAULT NULL COMMENT '辅助资料开始时间',
  `auxiliary_end_time` datetime(0) NULL DEFAULT NULL COMMENT '辅助资料结束时间',
  `actual_end_time` datetime(0) NULL DEFAULT NULL COMMENT '实际结束时间',
  `demand_quantity` decimal(10, 2) NOT NULL COMMENT '需求数量',
  `planned_quantity` decimal(10, 2) NOT NULL COMMENT '计划数量',
  `completed_quantity` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '已完工数量',
  `process_schedule` decimal(5, 2) NULL DEFAULT NULL COMMENT '工序进度',
  `total_process_time` int NULL DEFAULT 0 COMMENT '总加工时间(单位：秒)',
  `specific_time` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '具体时间',
  `create_time` datetime(0) NOT NULL COMMENT '创建时间',
  `update_time` datetime(0) NOT NULL COMMENT '更新时间',
  `order_id` int NOT NULL COMMENT '订单id',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_order_number`(`order_number`) USING BTREE,
  INDEX `idx_material_code`(`material_code`) USING BTREE,
  INDEX `idx_equipment_id`(`equipment_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2055278217 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '工序明细' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for process_equipment
-- ----------------------------
DROP TABLE IF EXISTS `process_equipment`;
CREATE TABLE `process_equipment`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  `process_route_id` int NOT NULL COMMENT '工艺路线id',
  `process_process_id` int NOT NULL COMMENT '工艺工序id',
  `equipment_id` bigint NOT NULL COMMENT '设备id',
  `equipment_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '设备编码',
  `production_beat` bigint NULL DEFAULT NULL COMMENT '生产节拍',
  `process_id` int NOT NULL COMMENT '工序id',
  `auxiliary_data_id` int NULL DEFAULT NULL COMMENT '辅助资料id',
  `auxiliary_data_coding` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '辅助资料编码',
  `processing_batch` bigint NULL DEFAULT NULL COMMENT '加工批量',
  `material_id` bigint NOT NULL COMMENT '物料id',
  `material_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '物料编码',
  `create_time` datetime(0) NOT NULL COMMENT '创建时间',
  `update_time` datetime(0) NOT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_process_route_id`(`process_route_id`) USING BTREE,
  INDEX `idx_process_process_id`(`process_process_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1232 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '工艺工序设备' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for process_route
-- ----------------------------
DROP TABLE IF EXISTS `process_route`;
CREATE TABLE `process_route`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  `process_route_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '工艺路线编码',
  `process_route_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '工艺路线名称',
  `process_route_desc` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '工艺路线描述',
  `creator` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `remarks` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `material_id` bigint NULL DEFAULT NULL COMMENT '物料id',
  `material_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '物料编码',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  `process_remark` tinyint(1) NULL DEFAULT 0 COMMENT '工艺备注 0-->无须编辑,1-->待编辑',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_material_code`(`material_code`) USING BTREE,
  INDEX `idx_process_route_name`(`process_route_name`) USING BTREE,
  INDEX `process_route_code`(`process_route_code`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 164 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '工艺路线' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for purchase_plan
-- ----------------------------
DROP TABLE IF EXISTS `purchase_plan`;
CREATE TABLE `purchase_plan`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  `item_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '物料编码',
  `item_type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '物料类型',
  `item_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '物料名称',
  `specification` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '规格',
  `unit` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '单位',
  `quantity` decimal(10, 2) NULL DEFAULT NULL COMMENT '数量',
  `demand_period` datetime(0) NULL DEFAULT NULL COMMENT '需求期',
  `procurement_lead_time` datetime(0) NULL DEFAULT NULL COMMENT '预计到货日期',
  `proposed_purchase_date` datetime(0) NULL DEFAULT NULL COMMENT '建议采购日期',
  `creator` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  `supplier_id` bigint NULL DEFAULT NULL COMMENT '供应商id',
  `supplier_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '供应商编码',
  `supplier_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供应商名称',
  `order_number` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '订单号',
  `production_type` int NULL DEFAULT 1 COMMENT '生产类型',
  `material_id` bigint NOT NULL COMMENT '物料id',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `order_number`(`order_number`) USING BTREE,
  INDEX `item_code`(`item_code`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 585 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '采购计划' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for scheduling_task_view
-- ----------------------------
DROP TABLE IF EXISTS `scheduling_task_view`;
CREATE TABLE `scheduling_task_view`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  `order_number` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '订单号',
  `material_id` bigint NULL DEFAULT NULL COMMENT '物料id',
  `item_number` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '物料编码',
  `item_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '物料名称',
  `demand_quantity` decimal(10, 2) NULL DEFAULT NULL COMMENT '需求数量',
  `planned_quantity` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '计划数量',
  `order_delivery_time` date NULL DEFAULT NULL COMMENT '订单交期',
  `order_status` tinyint NULL DEFAULT NULL COMMENT '订单状态',
  `scheduled_quantity` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '已排程数量',
  `unscheduled_quantity` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '未排程数量',
  `completed_quantity` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '已完工数量',
  `unfinished_quantity` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '未完工数量',
  `planned_start_time` datetime(0) NULL DEFAULT NULL COMMENT '计划开始时间',
  `planned_end_time` datetime(0) NULL DEFAULT NULL COMMENT '计划结束时间',
  `actual_completion_time` datetime(0) NULL DEFAULT NULL COMMENT '实际完工时间',
  `deviation_days` int NULL DEFAULT NULL COMMENT '偏差天数',
  `order_progress` decimal(5, 2) NULL DEFAULT NULL COMMENT '订单进度',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  `order_id` int NOT NULL COMMENT '订单id',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_order_number`(`order_number`) USING BTREE,
  INDEX `idx_item_number`(`item_number`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2278 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '排产任务视图' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for suggested_plan
-- ----------------------------
DROP TABLE IF EXISTS `suggested_plan`;
CREATE TABLE `suggested_plan`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  `order_number` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '订单号',
  `material_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '物料编码',
  `material_parent_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '父级物料编码',
  `level` int NULL DEFAULT NULL COMMENT '层级',
  `scheduling_status` int NULL DEFAULT NULL COMMENT '排产状态',
  `material_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '物料名称',
  `manufacturing_strategy` int NULL DEFAULT 1 COMMENT '制造策略',
  `production_type` int NULL DEFAULT NULL COMMENT '生产类型',
  `demand_quantity` decimal(10, 2) NULL DEFAULT NULL COMMENT '需求数量',
  `order_delivery_time` date NULL DEFAULT NULL COMMENT '订单交期',
  `demand_time` date NULL DEFAULT NULL COMMENT '需求时间',
  `planned_quantity` decimal(10, 2) NULL DEFAULT NULL COMMENT '计划数量',
  `plan_start_time` datetime(0) NULL DEFAULT NULL COMMENT '计划开始时间',
  `plan_completion_time` datetime(0) NULL DEFAULT NULL COMMENT '计划完成时间',
  `immediate_inventory` decimal(65, 2) NULL DEFAULT NULL COMMENT '实际库存',
  `possession_inventory` decimal(65, 2) NULL DEFAULT NULL COMMENT '物料占用量',
  `creator` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  `material_id` bigint NOT NULL COMMENT '物料id',
  `order_id` bigint NOT NULL COMMENT '订单id',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `order_number`(`order_number`) USING BTREE,
  INDEX `material_code`(`material_code`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2143293249 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '建议计划' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for supplier
-- ----------------------------
DROP TABLE IF EXISTS `supplier`;
CREATE TABLE `supplier`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `supplier_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '供应商编码',
  `supplier_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供应商名称',
  `supplier_phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供应商电话',
  `supplier_person` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供应商姓名',
  `creator` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `data_source` int NULL DEFAULT NULL COMMENT '数据来源',
  `state` tinyint NULL DEFAULT NULL COMMENT '状态',
  `create_time` datetime(0) NOT NULL COMMENT '创建时间',
  `update_time` datetime(0) NOT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_supplier_code`(`supplier_code`) USING BTREE COMMENT '供应商编码索引'
) ENGINE = InnoDB AUTO_INCREMENT = 1765626190662569985 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '供应商' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for supplier_material
-- ----------------------------
DROP TABLE IF EXISTS `supplier_material`;
CREATE TABLE `supplier_material`  (
  `id` bigint NOT NULL COMMENT '主键id',
  `supplier_id` bigint NOT NULL COMMENT '供应商id',
  `material_id` bigint NOT NULL COMMENT '物料id',
  `material_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '物料编码',
  `material_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '物料名称',
  `finished_product_rate` decimal(10, 2) NOT NULL COMMENT '成品率',
  `quasi_delivery_rate` decimal(10, 2) NOT NULL COMMENT '准交率',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '供应商物料表' ROW_FORMAT = Dynamic;


-- ----------------------------
-- Table structure for technological_process
-- ----------------------------
DROP TABLE IF EXISTS `technological_process`;
CREATE TABLE `technological_process`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  `process_route_id` int NOT NULL COMMENT '工艺路线id',
  `process_id` int NOT NULL COMMENT '工序id',
  `process_number` int NOT NULL COMMENT '工序号',
  `process_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '工序编码',
  `process_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '工序名称',
  `replacement_time` bigint NULL DEFAULT NULL COMMENT '换型时间',
  `transshipment_batch` bigint NULL DEFAULT NULL COMMENT '转运批量',
  `transshipment_time` bigint NULL DEFAULT NULL COMMENT '转运时间',
  `processing_content` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '加工内容',
  `material_id` bigint NOT NULL COMMENT '物料id',
  `material_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '物料编码',
  `create_time` datetime(0) NOT NULL COMMENT '创建时间',
  `update_time` datetime(0) NOT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_process_route_id`(`process_route_id`) USING BTREE,
  INDEX `idx_material_code`(`material_code`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 546 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '工艺工序' ROW_FORMAT = Dynamic;


-- ----------------------------
-- Table structure for working_calendar
-- ----------------------------
DROP TABLE IF EXISTS `working_calendar`;
CREATE TABLE `working_calendar`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  `class_id` int NOT NULL COMMENT '班制 id',
  `device_id` bigint NOT NULL COMMENT '设备id',
  `date` date NOT NULL COMMENT '日期',
  `working_day` int NOT NULL COMMENT '工作日',
  `working_time_id` int NULL DEFAULT NULL COMMENT '工作时段id',
  `period_info` json NULL COMMENT '工作时段信息',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `device_id_index`(`device_id`) USING BTREE,
  INDEX `working_time_id`(`working_time_id`) USING BTREE,
  INDEX `date`(`date`) USING BTREE,
  INDEX `class_id`(`class_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 8674853 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '工作日历' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for working_period
-- ----------------------------
DROP TABLE IF EXISTS `working_period`;
CREATE TABLE `working_period`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  `work_time_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '工作时段名称',
  `start_and_end_time_interval_set` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '开始结束时间区间集合',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 48 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '工作时段' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for working_procedure
-- ----------------------------
DROP TABLE IF EXISTS `working_procedure`;
CREATE TABLE `working_procedure`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  `process_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '工序编码',
  `process_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '工序名称',
  `remarks` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `creator` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_process_name`(`process_name`) USING BTREE,
  INDEX `idx_creator`(`creator`) USING BTREE,
  INDEX `idx_process_code`(`process_code`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 167 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '工序' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for working_procedure_auxiliary
-- ----------------------------
DROP TABLE IF EXISTS `working_procedure_auxiliary`;
CREATE TABLE `working_procedure_auxiliary`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT 'id',
  `working_procedure_id` int NULL DEFAULT NULL COMMENT '工序id',
  `auxiliary_id` int NULL DEFAULT NULL COMMENT '辅助id',
  `auxiliary_data_coding` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '辅助编码',
  `create_time` datetime(0) NOT NULL COMMENT '创建时间',
  `update_time` datetime(0) NOT NULL COMMENT '更新时间',
  `auxiliary_resource_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '辅助资源名称名称',
  `procedure_equipment_id` int NOT NULL COMMENT '工序设备id',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_working_procedure_id`(`working_procedure_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 340 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '工序辅助' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for working_procedure_equipment
-- ----------------------------
DROP TABLE IF EXISTS `working_procedure_equipment`;
CREATE TABLE `working_procedure_equipment`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT 'id',
  `working_procedure_id` int NULL DEFAULT NULL COMMENT '工序id',
  `equipment_id` bigint NULL DEFAULT NULL COMMENT '设备id',
  `equipment_number` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '设备编码',
  `create_time` datetime(0) NOT NULL COMMENT '创建时间',
  `update_time` datetime(0) NOT NULL COMMENT '更新时间',
  `device_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备名称',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_working_procedure_id`(`working_procedure_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 609 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '工序设备' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for workshop
-- ----------------------------
DROP TABLE IF EXISTS `workshop`;
CREATE TABLE `workshop`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `workshop_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '车间名称',
  `workshop_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '车间编码',
  `job_number` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '工号',
  `user_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '用户id',
  `workshop_leader` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '车间负责人',
  `contact_number` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '联系电话',
  `data_source` int NULL DEFAULT NULL COMMENT '数据来源',
  `state` tinyint NULL DEFAULT NULL COMMENT '状态',
  `creator` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime(0) NOT NULL COMMENT '创建时间',
  `update_time` datetime(0) NOT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_workshop_code`(`workshop_code`) USING BTREE COMMENT '车间编码索引'
) ENGINE = InnoDB AUTO_INCREMENT = 105 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '车间表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for workshop_production_statistics
-- ----------------------------
DROP TABLE IF EXISTS `workshop_production_statistics`;
CREATE TABLE `workshop_production_statistics`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `workshop_id` int NULL DEFAULT NULL COMMENT '车间id',
  `scheduled_equipment_cnt` decimal(10, 2) NULL DEFAULT NULL COMMENT '已排产设备数量',
  `unscheduled_equipment_cnt` decimal(10, 2) NULL DEFAULT NULL COMMENT '未排产设备数量',
  `planned_cnt` decimal(10, 2) NULL DEFAULT NULL COMMENT '计划数量',
  `completed_cnt` decimal(10, 2) NULL DEFAULT NULL COMMENT '已完工数量',
  `production_schedule` decimal(5, 2) NULL DEFAULT NULL COMMENT '生产进度',
  `associated_order_cnt` int NULL DEFAULT NULL COMMENT '关联订单数',
  `statistics_date` date NOT NULL COMMENT '车间维度的各个字段的统计时间',
  `create_time` datetime(0) NOT NULL COMMENT '创建时间',
  `update_time` datetime(0) NOT NULL ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_workshop_id_statdate`(`workshop_id`, `statistics_date`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 5310 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '车间维度排产任务统计表' ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `sys_user_role`;
CREATE TABLE `sys_user_role`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  `role_id` int NULL DEFAULT NULL COMMENT '角色ID',
  `user_id` bigint NULL DEFAULT NULL COMMENT '用户ID',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '系统管理 - 用户角色关联' ROW_FORMAT = DYNAMIC;

DROP TABLE IF EXISTS `sys_user`;
CREATE TABLE `sys_user`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `username` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL COMMENT '员工姓名',
  `password` varchar(200) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL COMMENT '登录密码',
  `job_number` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '工号',
  `position` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL COMMENT '职位',
  `workshop_id` int NULL DEFAULT NULL COMMENT '车间id',
  `phone` varchar(11) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL COMMENT '手机号码',
  `email` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '邮箱',
  `salt` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '盐值',
  `plain_password` varchar(8) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '明文密码',
  `data_source` tinyint NULL DEFAULT NULL COMMENT '数据来源',
  `remarks` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '备注',
  `creator` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime(0) NOT NULL COMMENT '创建时间',
  `update_time` datetime(0) NOT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_phone`(`phone`) USING BTREE COMMENT '手机号索引',
  INDEX `idx_job_number`(`job_number`) USING BTREE COMMENT '员工工号索引'
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '系统管理-用户基础信息' ROW_FORMAT = DYNAMIC;


DROP TABLE IF EXISTS `sys_role_menu`;
CREATE TABLE `sys_role_menu`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  `role_id` int NULL DEFAULT NULL COMMENT '角色ID',
  `menu_id` bigint NULL DEFAULT NULL COMMENT '菜单ID',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '系统管理 - 角色-权限资源关联' ROW_FORMAT = DYNAMIC;


DROP TABLE IF EXISTS `sys_role`;
CREATE TABLE `sys_role`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT '角色名称',
  `value` tinyint NULL DEFAULT NULL COMMENT '角色值',
  `remarks` varchar(500) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '角色描述',
  `data_source` tinyint NULL DEFAULT NULL COMMENT '数据来源',
  `creator` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_name`(`name`) USING BTREE COMMENT '角色名称索引'
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '系统管理-角色' ROW_FORMAT = DYNAMIC;


DROP TABLE IF EXISTS `sys_menu`;
CREATE TABLE `sys_menu`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `parent_id` bigint NOT NULL COMMENT '上级资源ID',
  `path` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL COMMENT '路由地址',
  `title` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL COMMENT '资源名称',
  `sort_no` int NOT NULL COMMENT '显示顺序',
  `icon` varchar(32) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '资源图标',
  `type` tinyint NOT NULL COMMENT '类型 menu、button',
  `state` tinyint NOT NULL COMMENT '状态',
  `remarks` varchar(500) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime(0) NOT NULL COMMENT '创建时间',
  `update_time` datetime(0) NOT NULL ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `parent_id`(`parent_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '系统管理-权限资源' ROW_FORMAT = DYNAMIC;

SET FOREIGN_KEY_CHECKS = 1;
