/*
 Navicat Premium Dump SQL

 Source Server         : pocket
 Source Server Type    : MySQL
 Source Server Version : 80043 (8.0.43)
 Source Host           : 140.143.206.120:13306
 Source Schema         : klp-oa

 Target Server Type    : MySQL
 Target Server Version : 80043 (8.0.43)
 File Encoding         : 65001

 Date: 24/04/2026 14:08:18
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for aps_plan_detail
-- ----------------------------
DROP TABLE IF EXISTS `aps_plan_detail`;
CREATE TABLE `aps_plan_detail`  (
  `plan_detail_id` bigint NOT NULL AUTO_INCREMENT COMMENT '排产明细主键ID',
  `plan_sheet_id` bigint NOT NULL COMMENT '关联排产单ID',
  `biz_seq_no` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '内容序号',
  `order_id` bigint NULL DEFAULT NULL COMMENT '订单ID',
  `order_code` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '销售内容:订单号',
  `contract_code` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '销售内容:订单合同号',
  `customer_name` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '销售内容:客户',
  `salesman` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '销售内容:业务员',
  `raw_manufacturer` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '原料信息:厂家',
  `raw_material` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '原料信息:材质',
  `raw_thick` decimal(18, 3) NULL DEFAULT NULL COMMENT '原料信息:厚度mm',
  `raw_width` decimal(18, 3) NULL DEFAULT NULL COMMENT '原料信息:宽度mm',
  `raw_material_id` bigint NULL DEFAULT NULL COMMENT '原料钢卷ID',
  `raw_coil_nos` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '原料卷号',
  `raw_location` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '钢卷位置',
  `raw_packaging` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '包装要求',
  `raw_edge_req` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '宽度要求',
  `raw_coating_type` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '镀层种类',
  `raw_net_weight` decimal(18, 3) NULL DEFAULT NULL COMMENT '原料净重',
  `product_name` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '成品信息:成品名称',
  `product_material` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '成品信息:材质',
  `coating_g` decimal(18, 3) NULL DEFAULT NULL COMMENT '成品信息:镀层g',
  `product_width` decimal(18, 3) NULL DEFAULT NULL COMMENT '成品信息:成品宽度',
  `rolling_thick` decimal(18, 3) NULL DEFAULT NULL COMMENT '成品信息:轧制厚度',
  `mark_coat_thick` decimal(18, 3) NULL DEFAULT NULL COMMENT '成品信息:标签厚度',
  `ton_steel_length_range` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '成品信息:吨钢长度区间m',
  `plan_qty` decimal(18, 3) NULL DEFAULT NULL COMMENT '成品信息:数量',
  `plan_weight` decimal(18, 3) NULL DEFAULT NULL COMMENT '成品信息:重量',
  `surface_treatment` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '成品信息:表面处理',
  `width_req` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '成品信息:切边要求',
  `product_packaging` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '成品信息:包装要求',
  `product_edge_req` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '成品信息:宽度要求',
  `usage_req` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '成品信息:用途',
  `post_process` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '后处理',
  `next_process` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '下工序',
  `sample_req` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '取样',
  `start_time` datetime NULL DEFAULT NULL COMMENT '生产开始时间',
  `end_time` datetime NULL DEFAULT NULL COMMENT '生产结束时间',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标记(0正常 1删除)',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`plan_detail_id`) USING BTREE,
  INDEX `idx_aps_plan_detail_plan_sheet_id`(`plan_sheet_id` ASC) USING BTREE,
  INDEX `idx_aps_plan_detail_order_code`(`order_code` ASC) USING BTREE,
  INDEX `idx_aps_plan_detail_customer_name`(`customer_name` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2046049621158096898 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '排产单明细表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for aps_plan_sheet
-- ----------------------------
DROP TABLE IF EXISTS `aps_plan_sheet`;
CREATE TABLE `aps_plan_sheet`  (
  `plan_sheet_id` bigint NOT NULL AUTO_INCREMENT COMMENT '排产单主键ID',
  `plan_date` date NOT NULL COMMENT '排产日期',
  `line_id` bigint NULL DEFAULT NULL COMMENT '产线ID',
  `line_name` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产线名称',
  `plan_code` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '排产单号',
  `plan_type` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '排产类型',
  `scheduler` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '排产人',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标记(0正常 1删除)',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`plan_sheet_id`) USING BTREE,
  UNIQUE INDEX `uk_aps_plan_sheet_plan_code`(`plan_code` ASC) USING BTREE,
  INDEX `idx_aps_plan_sheet_plan_date`(`plan_date` ASC) USING BTREE,
  INDEX `idx_aps_plan_sheet_line_id`(`line_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2045027469176832003 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '排产单主表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for aps_quick_sheet
-- ----------------------------
DROP TABLE IF EXISTS `aps_quick_sheet`;
CREATE TABLE `aps_quick_sheet`  (
  `quick_sheet_id` bigint NOT NULL AUTO_INCREMENT,
  `plan_date` date NOT NULL COMMENT '排产日期',
  `line_id` bigint NULL DEFAULT NULL COMMENT '产线ID',
  `line_name` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产线名称',
  `plan_code` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '排产单号',
  `plan_type` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '排产类型',
  `scheduler` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '排产人',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `biz_seq_no` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '内容序号',
  `order_code` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '销售内容/订单号',
  `contract_code` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '订单合同号',
  `customer_name` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '客户',
  `salesman` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '业务员',
  `product_name` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '成品名称',
  `product_material` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '材质',
  `coating_g` decimal(18, 3) NULL DEFAULT NULL COMMENT '镀层g',
  `product_width` decimal(18, 3) NULL DEFAULT NULL COMMENT '成品宽度',
  `rolling_thick` decimal(18, 3) NULL DEFAULT NULL COMMENT '轧制厚度',
  `mark_coat_thick` decimal(18, 3) NULL DEFAULT NULL COMMENT '标丝厚度',
  `ton_steel_length_range` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '吨钢长度区间m',
  `plan_qty` decimal(18, 3) NULL DEFAULT NULL COMMENT '数量',
  `plan_weight` decimal(18, 3) NULL DEFAULT NULL COMMENT '重量',
  `surface_treatment` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '表面处理',
  `width_req` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '切边要求',
  `usage_req` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '用途',
  `post_process` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '后处理',
  `next_process` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '下工序',
  `sample_req` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '取样',
  `raw_manufacturer` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '厂家',
  `raw_material` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '原料信息',
  `raw_thick` decimal(18, 3) NULL DEFAULT NULL COMMENT '原料厚度mm',
  `raw_width` decimal(18, 3) NULL DEFAULT NULL COMMENT '宽度mm',
  `raw_material_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '原料钢卷',
  `raw_coil_nos` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '原料卷号',
  `raw_location` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '钢卷位置',
  `raw_packaging` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '包装要求',
  `raw_edge_req` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '宽度要求',
  `raw_coating_type` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '镀层种类',
  `raw_net_weight` decimal(18, 3) NULL DEFAULT NULL COMMENT '原料净重',
  `start_time` datetime NULL DEFAULT NULL COMMENT '开始时间',
  `end_time` datetime NULL DEFAULT NULL COMMENT '结束时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标记(0正常 1删除)',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`quick_sheet_id`) USING BTREE,
  INDEX `idx_aps_quick_sheet_plan_date`(`plan_date` ASC) USING BTREE,
  INDEX `idx_aps_quick_sheet_line_id`(`line_id` ASC) USING BTREE,
  INDEX `idx_aps_quick_sheet_plan_code`(`plan_code` ASC) USING BTREE,
  INDEX `idx_aps_quick_sheet_customer_name`(`customer_name` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '快速排产表(Excel样式)' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for attendance_records
-- ----------------------------
DROP TABLE IF EXISTS `attendance_records`;
CREATE TABLE `attendance_records`  (
  `id` int NOT NULL,
  `pin` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `ename` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `deptname` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `sn` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `checktime` datetime NULL DEFAULT NULL,
  `verify` int NULL DEFAULT NULL,
  `stateno` int NULL DEFAULT NULL,
  `state` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for crm_contract
-- ----------------------------
DROP TABLE IF EXISTS `crm_contract`;
CREATE TABLE `crm_contract`  (
  `contract_id` bigint NOT NULL AUTO_INCREMENT COMMENT '合同主键ID',
  `contract_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '合同名称',
  `contract_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '合同编号',
  `supplier` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供方',
  `customer` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '需方',
  `customer_id` bigint NULL DEFAULT NULL COMMENT '客户ID',
  `delivery_date` date NULL DEFAULT NULL COMMENT '交货时间',
  `sign_time` datetime NULL DEFAULT NULL COMMENT '签订时间',
  `sign_location` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '签订地点',
  `product_content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '产品内容',
  `contract_content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '合同内容',
  `supplier_address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供方地址',
  `supplier_phone` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供方电话',
  `supplier_bank` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供方开户行',
  `supplier_account` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供方账号',
  `supplier_tax_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供方税号',
  `customer_address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '需方地址',
  `customer_phone` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '需方电话',
  `customer_bank` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '需方开户行',
  `customer_account` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '需方账号',
  `customer_tax_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '需方税号',
  `tech_annex` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '技术附件',
  `business_annex` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '商务附件',
  `production_schedule` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '排产函',
  `status` tinyint NOT NULL DEFAULT 0 COMMENT '合同状态 0=草稿 1=生效 2=作废 3=已完成',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  PRIMARY KEY (`contract_id`) USING BTREE,
  UNIQUE INDEX `uk_contract_no`(`contract_no` ASC) USING BTREE COMMENT '合同编号唯一',
  INDEX `idx_status`(`status` ASC) USING BTREE,
  INDEX `idx_del_flag`(`del_flag` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2041756879183618050 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '合同信息表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for crm_contract_product
-- ----------------------------
DROP TABLE IF EXISTS `crm_contract_product`;
CREATE TABLE `crm_contract_product`  (
  `contract_product_id` bigint NOT NULL AUTO_INCREMENT COMMENT '合同产品主键ID',
  `contract_id` bigint NOT NULL COMMENT '关联合同ID（绑定wms_contract表主键）',
  `product_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产品名称',
  `spec_min` decimal(4, 1) NULL DEFAULT NULL COMMENT '规格最小值(mm)',
  `spec_max` decimal(4, 1) NULL DEFAULT NULL COMMENT '规格最大值(mm)',
  `material` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '材质',
  `quantity` decimal(10, 2) NULL DEFAULT NULL COMMENT '数量(吨)',
  `tax_inclusive_unit_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '含税单价(元/吨)',
  `ex_tax_unit_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '不含税单价(元/吨)',
  `tax_inclusive_amount` decimal(12, 2) NULL DEFAULT NULL COMMENT '含税总额(元)',
  `del_flag` tinyint NOT NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`contract_product_id`) USING BTREE,
  INDEX `idx_contract_id`(`contract_id` ASC) USING BTREE COMMENT '关联合同ID索引',
  INDEX `idx_material`(`material` ASC) USING BTREE COMMENT '材质索引',
  CONSTRAINT `fk_contract_product_contract` FOREIGN KEY (`contract_id`) REFERENCES `wms_contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '合同产品明细表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for crm_customer
-- ----------------------------
DROP TABLE IF EXISTS `crm_customer`;
CREATE TABLE `crm_customer`  (
  `customer_id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '客户ID（主键）',
  `customer_code` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '客户统一编码',
  `company_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '公司名称',
  `contact_person` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '联系人',
  `contact_way` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '联系方式（电话/微信等）',
  `industry` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '所属行业',
  `customer_level` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '普通' COMMENT '客户等级（如：VIP/普通）',
  `address` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '客户地址（需权限查看）',
  `bank_info` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '银行信息（多条，需权限查看，JSON格式存储）',
  `tax_number` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '纳税人识别号/税号',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  PRIMARY KEY (`customer_id`) USING BTREE,
  UNIQUE INDEX `uk_customer_code`(`customer_code` ASC) USING BTREE,
  INDEX `idx_company_name`(`company_name` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2017968950019809827 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '客户信息表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for crm_order
-- ----------------------------
DROP TABLE IF EXISTS `crm_order`;
CREATE TABLE `crm_order`  (
  `order_id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '订单ID（主键）',
  `order_code` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '订单编号',
  `contract_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '合同号',
  `contract_id` bigint UNSIGNED NULL DEFAULT NULL COMMENT '关联合同ID（wms_contract.contract_id）',
  `order_type` tinyint NOT NULL DEFAULT 0 COMMENT '订单类型：0-预订单，1-正式订单',
  `customer_id` bigint UNSIGNED NULL DEFAULT NULL COMMENT '关联客户ID',
  `order_amount` decimal(18, 2) NOT NULL COMMENT '订单总金额',
  `salesman` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '销售员',
  `delivery_date` date NULL DEFAULT NULL COMMENT '交货日期',
  `pre_order_status` tinyint NOT NULL DEFAULT 0 COMMENT '预订单状态',
  `audit_user` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '审核人',
  `audit_time` datetime NULL DEFAULT NULL COMMENT '审核时间',
  `order_status` tinyint NOT NULL DEFAULT 0 COMMENT '订单状态',
  `finance_status` tinyint NOT NULL DEFAULT 0 COMMENT '财务状态',
  `unpaid_amount` decimal(18, 2) NOT NULL DEFAULT 0.00 COMMENT '未结款数额',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `annex_files` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '其他附件（多个文件URL用逗号分隔）',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  `contract_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '合同名称',
  `supplier` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供方',
  `customer` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '需方',
  `sign_time` datetime NULL DEFAULT NULL COMMENT '签订时间',
  `sign_location` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '签订地点',
  `product_content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '产品内容',
  `contract_content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '合同内容',
  `supplier_address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供方地址',
  `supplier_phone` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供方电话',
  `supplier_bank` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供方开户行',
  `supplier_account` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供方账号',
  `supplier_tax_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供方税号',
  `customer_address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '需方地址',
  `customer_phone` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '需方电话',
  `customer_bank` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '需方开户行',
  `customer_account` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '需方账号',
  `customer_tax_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '需方税号',
  `tech_annex` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '技术附件',
  `business_annex` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '商务附件',
  `production_schedule` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '排产函',
  `unit_price_remark` varchar(2048) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '算单价备注',
  `deposit_payable` decimal(18, 2) NULL DEFAULT NULL COMMENT '应付定金（万元）',
  `deposit_paid` decimal(18, 2) NULL DEFAULT NULL COMMENT '已付定金（万元）',
  `deposit_ratio` decimal(5, 2) NULL DEFAULT NULL COMMENT '定金比例（%）',
  `status` tinyint NOT NULL DEFAULT 0 COMMENT '合同状态 0=草稿 1=生效 2=作废 3=已完成',
  PRIMARY KEY (`order_id`) USING BTREE,
  UNIQUE INDEX `uk_order_code`(`order_code` ASC) USING BTREE,
  INDEX `idx_customer_id`(`customer_id` ASC) USING BTREE,
  INDEX `idx_order_status`(`order_status` ASC) USING BTREE,
  INDEX `idx_finance_status`(`finance_status` ASC) USING BTREE,
  INDEX `idx_contract_id`(`contract_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2043618688547762746 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '正式订单主表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for crm_order_item
-- ----------------------------
DROP TABLE IF EXISTS `crm_order_item`;
CREATE TABLE `crm_order_item`  (
  `item_id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '正式订单明细ID（主键）',
  `order_id` bigint UNSIGNED NOT NULL COMMENT '关联正式订单ID（外键）',
  `product_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '产品类型',
  `raw_material_spec` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '原料规格',
  `product_num` int NULL DEFAULT NULL COMMENT '产品数量',
  `special_require` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '特殊要求',
  `item_amount` decimal(18, 2) NULL DEFAULT NULL COMMENT '明细金额（单商品金额）',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  `finished_product_spec` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '成品规格',
  `material` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '材质',
  `grade` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '等级',
  `weight` decimal(10, 3) NULL DEFAULT NULL COMMENT '重量',
  `width_tolerance` decimal(10, 3) NULL DEFAULT NULL COMMENT '宽度公差',
  `thickness_tolerance` decimal(10, 3) NULL DEFAULT NULL COMMENT '厚度公差',
  `contract_price` decimal(18, 2) NULL DEFAULT NULL COMMENT '合同定价',
  `customizer` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '定制人',
  `shipper` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '发货人',
  `production_batch` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '排产批次',
  `surface_treatment` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '表面处理',
  `edge_cutting_req` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '切边要求',
  `packaging_req` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '包装要求',
  `width` decimal(10, 3) NULL DEFAULT NULL COMMENT '宽度',
  `thickness` decimal(10, 3) NULL DEFAULT NULL COMMENT '厚度',
  `purpose` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '用途',
  PRIMARY KEY (`item_id`) USING BTREE,
  INDEX `idx_order_id`(`order_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2018189324112977922 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '正式订单明细表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for crm_order_operation_trace
-- ----------------------------
DROP TABLE IF EXISTS `crm_order_operation_trace`;
CREATE TABLE `crm_order_operation_trace`  (
  `trace_id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '追溯ID（主键）',
  `order_id` bigint UNSIGNED NOT NULL COMMENT '关联订单ID（外键）',
  `operation_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '操作类型（如：创建/修改/审核/取消/发货等）',
  `old_status` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '操作前状态',
  `new_status` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '操作后状态',
  `operation_content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '操作内容（如：修改了交货日期）',
  `operator` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '操作人',
  `operation_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '操作时间',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  PRIMARY KEY (`trace_id`) USING BTREE,
  INDEX `idx_order_id`(`order_id` ASC) USING BTREE,
  INDEX `idx_operation_time`(`operation_time` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2041757096435982339 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '订单操作追溯表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for crm_sales_contract
-- ----------------------------
DROP TABLE IF EXISTS `crm_sales_contract`;
CREATE TABLE `crm_sales_contract`  (
  `contract_id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '合同ID（主键）',
  `contract_code` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '合同编号',
  `contract_type` tinyint NULL DEFAULT 0 COMMENT '合同类型',
  `customer_id` bigint UNSIGNED NOT NULL COMMENT '关联客户ID（外键）',
  `total_amount` decimal(18, 2) NOT NULL COMMENT '合同总金额',
  `delivery_date` date NULL DEFAULT NULL COMMENT '交货日期',
  `contract_status` tinyint NULL DEFAULT 0 COMMENT '合同状态',
  `create_user` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '录入人',
  `review_user` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '评审人',
  `review_time` datetime NULL DEFAULT NULL COMMENT '评审时间',
  `audit_user` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '审核人',
  `audit_time` datetime NULL DEFAULT NULL COMMENT '审核时间',
  `issue_user` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '下发人',
  `issue_time` datetime NULL DEFAULT NULL COMMENT '下发时间',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  PRIMARY KEY (`contract_id`) USING BTREE,
  UNIQUE INDEX `uk_contract_code`(`contract_code` ASC) USING BTREE,
  INDEX `idx_customer_id`(`customer_id` ASC) USING BTREE,
  INDEX `idx_contract_status`(`contract_status` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '销售合同表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for crm_sales_objection
-- ----------------------------
DROP TABLE IF EXISTS `crm_sales_objection`;
CREATE TABLE `crm_sales_objection`  (
  `objection_id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '异议ID（主键）',
  `objection_code` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '异议编号',
  `order_id` bigint UNSIGNED NOT NULL COMMENT '关联订单ID（外键）',
  `customer_id` bigint UNSIGNED NOT NULL COMMENT '关联客户ID（外键）',
  `objection_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '异议类型（如：质量异议）',
  `objection_content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '异议内容',
  `objection_status` tinyint NOT NULL DEFAULT 0 COMMENT '异议状态',
  `handle_content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '处理内容',
  `handle_user` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '处理人',
  `handle_time` datetime NULL DEFAULT NULL COMMENT '处理时间',
  `close_time` datetime NULL DEFAULT NULL COMMENT '结案时间',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  PRIMARY KEY (`objection_id`) USING BTREE,
  UNIQUE INDEX `uk_objection_code`(`objection_code` ASC) USING BTREE,
  INDEX `idx_order_id`(`order_id` ASC) USING BTREE,
  INDEX `idx_customer_id`(`customer_id` ASC) USING BTREE,
  INDEX `idx_objection_status`(`objection_status` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2004125765787750403 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '销售异议管理表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for dv_check_machinery
-- ----------------------------
DROP TABLE IF EXISTS `dv_check_machinery`;
CREATE TABLE `dv_check_machinery`  (
  `record_id` bigint NOT NULL AUTO_INCREMENT COMMENT '流水号',
  `plan_id` bigint NOT NULL COMMENT '计划ID',
  `machinery_id` bigint NOT NULL COMMENT '设备ID',
  `machinery_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备编码',
  `machinery_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备名称',
  `machinery_brand` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '品牌',
  `machinery_spec` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '规格型号',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '备注',
  `attr1` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '预留字段1',
  `attr2` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '预留字段2',
  `attr3` int NULL DEFAULT 0 COMMENT '预留字段3',
  `attr4` int NULL DEFAULT 0 COMMENT '预留字段4',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '更新者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`record_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 207 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '点检设备表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for dv_check_plan
-- ----------------------------
DROP TABLE IF EXISTS `dv_check_plan`;
CREATE TABLE `dv_check_plan`  (
  `plan_id` bigint NOT NULL AUTO_INCREMENT COMMENT '计划ID',
  `plan_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '计划编码',
  `plan_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '计划名称',
  `plan_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '计划类型',
  `start_date` datetime NULL DEFAULT NULL COMMENT '开始日期',
  `end_date` datetime NULL DEFAULT NULL COMMENT '结束日期',
  `cycle_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '频率',
  `cycle_count` int NULL DEFAULT NULL COMMENT '次数',
  `status` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '状态',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '备注',
  `attr1` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '预留字段1',
  `attr2` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '预留字段2',
  `attr3` int NULL DEFAULT 0 COMMENT '预留字段3',
  `attr4` int NULL DEFAULT 0 COMMENT '预留字段4',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '更新者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`plan_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 210 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备点检保养计划头表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for dv_check_record
-- ----------------------------
DROP TABLE IF EXISTS `dv_check_record`;
CREATE TABLE `dv_check_record`  (
  `record_id` bigint NOT NULL AUTO_INCREMENT COMMENT '计划ID',
  `plan_id` bigint NULL DEFAULT NULL COMMENT '计划ID',
  `plan_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '计划编码',
  `plan_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '计划名称',
  `plan_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '计划类型',
  `machinery_id` bigint NOT NULL COMMENT '设备ID',
  `machinery_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备编码',
  `machinery_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备名称',
  `machinery_brand` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '品牌',
  `machinery_spec` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '规格型号',
  `check_time` datetime NOT NULL COMMENT '点检时间',
  `user_id` bigint NULL DEFAULT NULL COMMENT '点检人',
  `user_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '点检人用户名',
  `nick_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '点检人名称',
  `status` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT 'PREPARE' COMMENT '状态',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '备注',
  `attr1` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '预留字段1',
  `attr2` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '预留字段2',
  `attr3` int NULL DEFAULT 0 COMMENT '预留字段3',
  `attr4` int NULL DEFAULT 0 COMMENT '预留字段4',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '更新者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`record_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 224 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备点检记录表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for dv_check_record_line
-- ----------------------------
DROP TABLE IF EXISTS `dv_check_record_line`;
CREATE TABLE `dv_check_record_line`  (
  `line_id` bigint NOT NULL AUTO_INCREMENT COMMENT '计划ID',
  `record_id` bigint NOT NULL COMMENT '计划ID',
  `subject_id` bigint NOT NULL COMMENT '项目ID',
  `subject_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '项目编码',
  `subject_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '项目名称',
  `subject_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '项目类型',
  `subject_content` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '项目内容',
  `subject_standard` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '标准',
  `check_status` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '点检结果',
  `check_result` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '异常描述',
  `attr1` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '预留字段1',
  `attr2` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '预留字段2',
  `attr3` int NULL DEFAULT 0 COMMENT '预留字段3',
  `attr4` int NULL DEFAULT 0 COMMENT '预留字段4',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '更新者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`line_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 215 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备点检记录行表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for dv_check_subject
-- ----------------------------
DROP TABLE IF EXISTS `dv_check_subject`;
CREATE TABLE `dv_check_subject`  (
  `record_id` bigint NOT NULL AUTO_INCREMENT COMMENT '流水号',
  `plan_id` bigint NOT NULL COMMENT '计划ID',
  `subject_id` bigint NOT NULL COMMENT '设备ID',
  `subject_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '项目编码',
  `subject_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '项目名称',
  `subject_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '项目类型',
  `subject_content` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '项目内容',
  `subject_standard` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '标准',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '备注',
  `attr1` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '预留字段1',
  `attr2` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '预留字段2',
  `attr3` int NULL DEFAULT 0 COMMENT '预留字段3',
  `attr4` int NULL DEFAULT 0 COMMENT '预留字段4',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '更新者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`record_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '点检项目表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for dv_machinery
-- ----------------------------
DROP TABLE IF EXISTS `dv_machinery`;
CREATE TABLE `dv_machinery`  (
  `machinery_id` bigint NOT NULL AUTO_INCREMENT COMMENT '设备类型ID',
  `machinery_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备类型编码',
  `machinery_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备类型名称',
  `machinery_brand` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '品牌',
  `machinery_spec` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '规格型号',
  `machinery_type_id` bigint NOT NULL COMMENT '设备类型ID',
  `machinery_type_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '设备类型编码',
  `machinery_type_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '设备类型名称',
  `workshop_id` bigint NOT NULL COMMENT '所属车间ID',
  `workshop_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '所属车间编码',
  `workshop_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '所属车间名称',
  `status` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'STOP' COMMENT '设备状态',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '备注',
  `attr1` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '预留字段1',
  `attr2` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '预留字段2',
  `attr3` int NULL DEFAULT 0 COMMENT '预留字段3',
  `attr4` int NULL DEFAULT 0 COMMENT '预留字段4',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '更新者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `last_mainten_time` datetime NULL DEFAULT NULL COMMENT '最近保养时间',
  `last_check_time` datetime NULL DEFAULT NULL COMMENT '最近点检时间',
  PRIMARY KEY (`machinery_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 217 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for dv_machinery_type
-- ----------------------------
DROP TABLE IF EXISTS `dv_machinery_type`;
CREATE TABLE `dv_machinery_type`  (
  `machinery_type_id` bigint NOT NULL AUTO_INCREMENT COMMENT '设备类型ID',
  `machinery_type_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备类型编码',
  `machinery_type_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备类型名称',
  `parent_type_id` bigint NULL DEFAULT 0 COMMENT '父类型ID',
  `ancestors` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '所有父节点ID',
  `enable_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'Y' COMMENT '是否启用',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '备注',
  `attr1` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '预留字段1',
  `attr2` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '预留字段2',
  `attr3` int NULL DEFAULT 0 COMMENT '预留字段3',
  `attr4` int NULL DEFAULT 0 COMMENT '预留字段4',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '更新者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`machinery_type_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 219 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备类型表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for dv_mainten_record
-- ----------------------------
DROP TABLE IF EXISTS `dv_mainten_record`;
CREATE TABLE `dv_mainten_record`  (
  `record_id` bigint NOT NULL AUTO_INCREMENT COMMENT '计划ID',
  `plan_id` bigint NULL DEFAULT NULL COMMENT '计划ID',
  `plan_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '计划编码',
  `plan_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '计划名称',
  `plan_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '计划类型',
  `machinery_id` bigint NOT NULL COMMENT '设备ID',
  `machinery_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备编码',
  `machinery_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备名称',
  `machinery_brand` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '品牌',
  `machinery_spec` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '规格型号',
  `mainten_time` datetime NOT NULL COMMENT '保养时间',
  `user_id` bigint NULL DEFAULT NULL COMMENT '用户ID',
  `user_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '用户名',
  `nick_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '昵称',
  `status` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT 'PREPARE' COMMENT '状态',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '备注',
  `attr1` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '预留字段1',
  `attr2` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '预留字段2',
  `attr3` int NULL DEFAULT 0 COMMENT '预留字段3',
  `attr4` int NULL DEFAULT 0 COMMENT '预留字段4',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '更新者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`record_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 208 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备保养记录表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for dv_mainten_record_line
-- ----------------------------
DROP TABLE IF EXISTS `dv_mainten_record_line`;
CREATE TABLE `dv_mainten_record_line`  (
  `line_id` bigint NOT NULL AUTO_INCREMENT COMMENT '计划ID',
  `record_id` bigint NOT NULL COMMENT '计划ID',
  `subject_id` bigint NOT NULL COMMENT '项目ID',
  `subject_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '项目编码',
  `subject_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '项目名称',
  `subject_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '项目类型',
  `subject_content` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '项目内容',
  `subject_standard` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '标准',
  `mainten_status` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '保养结果',
  `mainten_result` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '异常描述',
  `attr1` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '预留字段1',
  `attr2` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '预留字段2',
  `attr3` int NULL DEFAULT 0 COMMENT '预留字段3',
  `attr4` int NULL DEFAULT 0 COMMENT '预留字段4',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '更新者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`line_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备保养记录行表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for dv_repair
-- ----------------------------
DROP TABLE IF EXISTS `dv_repair`;
CREATE TABLE `dv_repair`  (
  `repair_id` bigint NOT NULL AUTO_INCREMENT COMMENT '维修单ID',
  `repair_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '维修单编号',
  `repair_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '维修单名称',
  `machinery_id` bigint NOT NULL COMMENT '设备ID',
  `machinery_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备编码',
  `machinery_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备名称',
  `machinery_brand` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '品牌',
  `machinery_spec` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '规格型号',
  `machinery_type_id` bigint NULL DEFAULT NULL COMMENT '设备类型ID',
  `require_date` datetime NULL DEFAULT NULL COMMENT '报修日期',
  `finish_date` datetime NULL DEFAULT NULL COMMENT '维修完成日期',
  `confirm_date` datetime NULL DEFAULT NULL COMMENT '验收日期',
  `repair_result` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '维修结果',
  `accepted_id` bigint NULL DEFAULT NULL COMMENT '维修人员ID',
  `accepted_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '维修人员用户名',
  `accepted_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '维修人员名称',
  `confirm_id` bigint NULL DEFAULT NULL COMMENT '验收人员ID',
  `confirm_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '验收人员用户名',
  `confirm_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '验收人员名称',
  `source_doc_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '来源单据类型',
  `source_doc_id` bigint NULL DEFAULT NULL COMMENT '来源单据ID',
  `source_doc_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '来源单据编号',
  `status` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT 'PREPARE' COMMENT '单据状态',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '备注',
  `attr1` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '预留字段1',
  `attr2` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '预留字段2',
  `attr3` int NULL DEFAULT 0 COMMENT '预留字段3',
  `attr4` int NULL DEFAULT 0 COMMENT '预留字段4',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '更新者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`repair_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 205 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备维修单' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for dv_repair_line
-- ----------------------------
DROP TABLE IF EXISTS `dv_repair_line`;
CREATE TABLE `dv_repair_line`  (
  `line_id` bigint NOT NULL AUTO_INCREMENT COMMENT '行ID',
  `repair_id` bigint NOT NULL COMMENT '维修单ID',
  `subject_id` bigint NULL DEFAULT NULL COMMENT '项目ID',
  `subject_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '项目编码',
  `subject_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '项目名称',
  `subject_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '项目类型',
  `subject_content` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '项目内容',
  `subject_standard` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '标准',
  `malfunction` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '故障描述',
  `malfunction_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '故障描述资源',
  `repair_des` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '维修情况',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '备注',
  `attr1` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '预留字段1',
  `attr2` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '预留字段2',
  `attr3` int NULL DEFAULT 0 COMMENT '预留字段3',
  `attr4` int NULL DEFAULT 0 COMMENT '预留字段4',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '更新者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`line_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 205 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备维修单行' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for dv_special_equipment
-- ----------------------------
DROP TABLE IF EXISTS `dv_special_equipment`;
CREATE TABLE `dv_special_equipment`  (
  `equipment_id` bigint NOT NULL COMMENT '设备ID',
  `equipment_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备编码',
  `equipment_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备名称（如：锅炉、压力容器、压力管道、电梯、起重机械等）',
  `specification_model` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '规格型号',
  `manufacturer` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '制造单位',
  `production_date` date NULL DEFAULT NULL COMMENT '制造日期',
  `installation_date` date NULL DEFAULT NULL COMMENT '安装日期',
  `use_start_date` date NULL DEFAULT NULL COMMENT '投入使用日期',
  `registration_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '特种设备注册编号',
  `safety_manager` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '安全负责人',
  `attachment` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '附件路径（多个附件用逗号分隔）',
  `inspection_cycle` int NOT NULL COMMENT '检验周期（月）',
  `last_inspection_time` datetime NULL DEFAULT NULL COMMENT '上次检验时间',
  `next_inspection_time` datetime NULL DEFAULT NULL COMMENT '下次检验时间',
  `current_status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '当前状态（在用、停用、报废等）',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '备注',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '更新者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`equipment_id`) USING BTREE,
  INDEX `idx_equipment_code`(`equipment_code` ASC) USING BTREE,
  INDEX `idx_equipment_type`(`equipment_name` ASC) USING BTREE,
  INDEX `idx_next_inspection`(`next_inspection_time` ASC) USING BTREE,
  INDEX `idx_safety_manager`(`safety_manager` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '特种设备表（包含锅炉、压力管道、电梯等特种设备信息）' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for dv_subject
-- ----------------------------
DROP TABLE IF EXISTS `dv_subject`;
CREATE TABLE `dv_subject`  (
  `subject_id` bigint NOT NULL AUTO_INCREMENT COMMENT '项目ID',
  `subject_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '项目编码',
  `subject_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '项目名称',
  `subject_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '0' COMMENT '项目类型',
  `subject_content` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '项目内容',
  `subject_standard` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '标准',
  `enable_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'Y' COMMENT '是否启用',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '备注',
  `attr1` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '预留字段1',
  `attr2` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '预留字段2',
  `attr3` int NULL DEFAULT 0 COMMENT '预留字段3',
  `attr4` int NULL DEFAULT 0 COMMENT '预留字段4',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '更新者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`subject_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 205 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备点检保养项目表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ems_alarm_device
-- ----------------------------
DROP TABLE IF EXISTS `ems_alarm_device`;
CREATE TABLE `ems_alarm_device`  (
  `device_id` bigint NOT NULL AUTO_INCREMENT,
  `device_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '设备名称',
  `device_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '设备编码',
  `device_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '设备类型',
  `location_id` bigint NOT NULL COMMENT '绑定的能源位置区域ID',
  `status` tinyint NOT NULL DEFAULT 0 COMMENT '设备状态（0=正常 1=故障 2=离线）',
  `ip_address` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '设备IP地址',
  `firmware_ver` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '固件版本',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '删除标志（0=存在 2=删除）',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '备注',
  PRIMARY KEY (`device_id`) USING BTREE,
  UNIQUE INDEX `uk_device_code`(`device_code` ASC) USING BTREE,
  INDEX `idx_device_location`(`location_id` ASC) USING BTREE,
  INDEX `idx_device_status`(`status` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1972864143538819074 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '安全警报设备表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ems_alarm_record
-- ----------------------------
DROP TABLE IF EXISTS `ems_alarm_record`;
CREATE TABLE `ems_alarm_record`  (
  `record_id` bigint NOT NULL AUTO_INCREMENT,
  `device_id` bigint NOT NULL COMMENT '绑定的设备ID',
  `alarm_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '警报类型',
  `alarm_level` tinyint NOT NULL COMMENT '警报级别（1=低 2=中 3=高）',
  `alarm_content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '警报内容',
  `alarm_time` datetime NOT NULL COMMENT '警报发生时间',
  `handle_status` tinyint NOT NULL DEFAULT 0 COMMENT '处理状态（0=未处理 1=处理中 2=已处理）',
  `handle_user` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '处理人',
  `handle_time` datetime NULL DEFAULT NULL COMMENT '处理时间',
  `handle_notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '处理备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '删除标志（0=存在 2=删除）',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '备注',
  PRIMARY KEY (`record_id`) USING BTREE,
  INDEX `idx_record_device`(`device_id` ASC) USING BTREE,
  INDEX `idx_record_alarm_time`(`alarm_time` ASC) USING BTREE,
  INDEX `idx_record_handle_status`(`handle_status` ASC) USING BTREE,
  INDEX `idx_record_alarm_level`(`alarm_level` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2047556139430842370 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '警报记录表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ems_alert
-- ----------------------------
DROP TABLE IF EXISTS `ems_alert`;
CREATE TABLE `ems_alert`  (
  `alert_id` bigint NOT NULL AUTO_INCREMENT,
  `meter_id` bigint NOT NULL COMMENT '关联计量设备',
  `alert_type` int NOT NULL COMMENT '告警类型：0=异常用量,1=高用量,2=设备故障',
  `actual_value` decimal(15, 2) NULL DEFAULT NULL COMMENT '实际值',
  `alert_time` datetime NOT NULL COMMENT '告警时间',
  `status` int NOT NULL DEFAULT 0 COMMENT '告警状态：0=待处理,1=已处理',
  `resolved_by` bigint NULL DEFAULT NULL COMMENT '处理人（不设外键）',
  `resolved_time` datetime NULL DEFAULT NULL COMMENT '处理时间',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '删除标志（0=存在 2=删除）',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '备注',
  PRIMARY KEY (`alert_id`) USING BTREE,
  INDEX `idx_alert_meter_time`(`meter_id` ASC, `alert_time` ASC) USING BTREE,
  INDEX `idx_alert_status_time`(`status` ASC, `alert_time` ASC) USING BTREE,
  CONSTRAINT `fk_alert_meter` FOREIGN KEY (`meter_id`) REFERENCES `ems_meter` (`meter_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `chk_alert_status` CHECK (`status` in (0,1)),
  CONSTRAINT `chk_alert_type` CHECK (`alert_type` in (0,1,2))
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '告警（alert_type 为 INT：0=异常用量,1=高用量,2=设备故障）' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ems_energy_consumption
-- ----------------------------
DROP TABLE IF EXISTS `ems_energy_consumption`;
CREATE TABLE `ems_energy_consumption`  (
  `energy_consumption_id` bigint NOT NULL AUTO_INCREMENT,
  `meter_id` bigint NOT NULL COMMENT '关联计量设备',
  `start_reading` decimal(15, 2) NOT NULL COMMENT '起始读数',
  `end_reading` decimal(15, 2) NOT NULL COMMENT '结束读数',
  `consumption` decimal(15, 2) NOT NULL COMMENT '消耗量',
  `start_time` datetime NOT NULL COMMENT '起始时间',
  `end_time` datetime NOT NULL COMMENT '结束时间',
  `recorded_by` bigint NULL DEFAULT NULL COMMENT '记录人（不设外键）',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '删除标志（0=存在 2=删除）',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '备注',
  PRIMARY KEY (`energy_consumption_id`) USING BTREE,
  INDEX `idx_energy_consumption_meter_time`(`meter_id` ASC, `start_time` ASC, `end_time` ASC) USING BTREE,
  CONSTRAINT `fk_energy_consumption_meter` FOREIGN KEY (`meter_id`) REFERENCES `ems_meter` (`meter_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `chk_consumption_readings` CHECK ((`start_reading` >= 0) and (`end_reading` >= `start_reading`)),
  CONSTRAINT `chk_consumption_time` CHECK (`end_time` > `start_time`)
) ENGINE = InnoDB AUTO_INCREMENT = 2007655484722327554 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '能耗记录' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ems_energy_rate
-- ----------------------------
DROP TABLE IF EXISTS `ems_energy_rate`;
CREATE TABLE `ems_energy_rate`  (
  `energy_rate_id` bigint NOT NULL AUTO_INCREMENT,
  `energy_type_id` bigint NOT NULL COMMENT '关联能源类型',
  `rate` decimal(10, 4) NULL DEFAULT NULL COMMENT '基础费率',
  `currency` int NOT NULL DEFAULT 0 COMMENT '货币：0=CNY,1=USD,2=EUR',
  `effective_date` date NOT NULL COMMENT '生效日期',
  `expiry_date` date NULL DEFAULT NULL COMMENT '失效日期，NULL表示长期有效',
  `use_peak_valley` int NOT NULL DEFAULT 0 COMMENT '是否使用峰谷时段：0=否，1=是',
  `use_tiered_pricing` int NOT NULL DEFAULT 0 COMMENT '是否使用梯度收费：0=否，1=是',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '删除标志（0=存在 2=删除）',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '备注',
  PRIMARY KEY (`energy_rate_id`) USING BTREE,
  UNIQUE INDEX `uk_energy_rate_type_effective`(`energy_type_id` ASC, `effective_date` ASC) USING BTREE,
  INDEX `idx_energy_rate_type_range`(`energy_type_id` ASC, `effective_date` ASC, `expiry_date` ASC) USING BTREE,
  CONSTRAINT `fk_energy_rate_type` FOREIGN KEY (`energy_type_id`) REFERENCES `ems_energy_type` (`energy_type_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `chk_energy_rate_currency` CHECK (`currency` in (0,1,2)),
  CONSTRAINT `chk_energy_rate_dates` CHECK ((`expiry_date` is null) or (`expiry_date` >= `effective_date`)),
  CONSTRAINT `chk_energy_rate_nonneg` CHECK (`rate` >= 0),
  CONSTRAINT `chk_peak_valley_flag` CHECK (`use_peak_valley` in (0,1)),
  CONSTRAINT `chk_tiered_pricing_flag` CHECK (`use_tiered_pricing` in (0,1))
) ENGINE = InnoDB AUTO_INCREMENT = 1997223781889855490 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '能源费率（支持峰谷分时、阶梯电价）' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ems_energy_record
-- ----------------------------
DROP TABLE IF EXISTS `ems_energy_record`;
CREATE TABLE `ems_energy_record`  (
  `energy_record_id` bigint NOT NULL AUTO_INCREMENT COMMENT '能耗记录主键ID',
  `meter_id` bigint NOT NULL COMMENT '表计ID（关联计量设备表）',
  `energy_id` bigint NOT NULL COMMENT '能源ID（关联能源类型表：电/水/气/暖等）',
  `consumption` decimal(15, 2) NOT NULL COMMENT '消耗量',
  `record_date` date NOT NULL COMMENT '统计日期（yyyy-MM-dd）',
  `recorded_by` bigint NULL DEFAULT NULL COMMENT '记录人ID',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '删除标志（0=存在 2=删除）',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '备注',
  PRIMARY KEY (`energy_record_id`) USING BTREE,
  INDEX `idx_energy_record_meter_energy_date`(`meter_id` ASC, `energy_id` ASC, `record_date` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2046822792274550787 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '能源消耗记录表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ems_energy_type
-- ----------------------------
DROP TABLE IF EXISTS `ems_energy_type`;
CREATE TABLE `ems_energy_type`  (
  `energy_type_id` bigint NOT NULL AUTO_INCREMENT,
  `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '能源名称，如：电力、自来水、天然气',
  `unit` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '计量单位，如：kWh、m³',
  `code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '能源编码',
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '能源描述',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '删除标志（0=存在 2=删除）',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '备注',
  PRIMARY KEY (`energy_type_id`) USING BTREE,
  UNIQUE INDEX `code`(`code` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1996864222876667906 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '能源类型（阈值已移除）' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ems_hazard_record
-- ----------------------------
DROP TABLE IF EXISTS `ems_hazard_record`;
CREATE TABLE `ems_hazard_record`  (
  `hazard_id` bigint NOT NULL AUTO_INCREMENT,
  `device_id` bigint NOT NULL COMMENT '关联的设备ID',
  `hazard_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '隐患类型',
  `hazard_level` tinyint NOT NULL COMMENT '隐患级别（1=一般 2=较大 3=重大）',
  `hazard_desc` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '隐患描述',
  `discovery_time` datetime NOT NULL COMMENT '发现时间',
  `input_time` datetime NOT NULL COMMENT '录入时间',
  `input_user` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '录入人',
  `status` tinyint NOT NULL DEFAULT 0 COMMENT '处理状态（0=未处理 1=处理中 2=已整改 3=已关闭）',
  `rectify_user` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '整改人',
  `rectify_time` datetime NULL DEFAULT NULL COMMENT '整改时间',
  `rectify_desc` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '整改说明',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '删除标志（0=存在 2=删除）',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '备注',
  PRIMARY KEY (`hazard_id`) USING BTREE,
  INDEX `idx_hazard_device`(`device_id` ASC) USING BTREE,
  INDEX `idx_hazard_level`(`hazard_level` ASC) USING BTREE,
  INDEX `idx_hazard_status`(`status` ASC) USING BTREE,
  INDEX `idx_hazard_discovery_time`(`discovery_time` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '设备隐患记录表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ems_location
-- ----------------------------
DROP TABLE IF EXISTS `ems_location`;
CREATE TABLE `ems_location`  (
  `location_id` bigint NOT NULL AUTO_INCREMENT,
  `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '区域名称',
  `parent_id` bigint NULL DEFAULT NULL COMMENT '父级区域ID，用于构建区域层级',
  `x` int NULL DEFAULT 0 COMMENT '横坐标',
  `y` int NULL DEFAULT 0 COMMENT '纵坐标',
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '区域描述',
  `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '详细地址',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '删除标志（0=存在 2=删除）',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '备注',
  PRIMARY KEY (`location_id`) USING BTREE,
  INDEX `idx_location_parent`(`parent_id` ASC) USING BTREE,
  CONSTRAINT `fk_location_parent` FOREIGN KEY (`parent_id`) REFERENCES `ems_location` (`location_id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE = InnoDB AUTO_INCREMENT = 1997237263951503363 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '位置' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ems_meter
-- ----------------------------
DROP TABLE IF EXISTS `ems_meter`;
CREATE TABLE `ems_meter`  (
  `meter_id` bigint NOT NULL AUTO_INCREMENT,
  `meter_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '设备编号',
  `energy_type_id` bigint NOT NULL COMMENT '关联能源类型',
  `location_id` bigint NULL DEFAULT NULL COMMENT '安装位置',
  `model` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '设备型号',
  `manufacturer` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '制造商',
  `install_date` date NULL DEFAULT NULL COMMENT '安装日期',
  `status` int NOT NULL DEFAULT 0 COMMENT '设备状态：0=在用,1=停用,2=维护',
  `last_calibration_date` date NULL DEFAULT NULL COMMENT '上次校准日期',
  `threshold_value` decimal(15, 2) NULL DEFAULT NULL COMMENT '阈值（按设备设置）',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '删除标志（0=存在 2=删除）',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '备注',
  PRIMARY KEY (`meter_id`) USING BTREE,
  UNIQUE INDEX `meter_code`(`meter_code` ASC) USING BTREE,
  INDEX `idx_meter_energy_type`(`energy_type_id` ASC) USING BTREE,
  INDEX `idx_meter_location`(`location_id` ASC) USING BTREE,
  CONSTRAINT `fk_meter_energy_type` FOREIGN KEY (`energy_type_id`) REFERENCES `ems_energy_type` (`energy_type_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `chk_meter_status` CHECK (`status` in (0,1,2))
) ENGINE = InnoDB AUTO_INCREMENT = 1996773089685381122 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '计量设备（阈值移至此处）' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ems_rate_tier
-- ----------------------------
DROP TABLE IF EXISTS `ems_rate_tier`;
CREATE TABLE `ems_rate_tier`  (
  `tier_id` bigint NOT NULL AUTO_INCREMENT,
  `energy_rate_id` bigint NOT NULL COMMENT '关联费率ID',
  `tier_level` int NOT NULL COMMENT '梯度等级（1、2、3...）',
  `min_usage` decimal(10, 2) NOT NULL COMMENT '最小用量（包含）',
  `max_usage` decimal(10, 2) NULL DEFAULT NULL COMMENT '最大用量（不包含），NULL表示无上限',
  `rate` decimal(10, 4) NOT NULL COMMENT '该梯度的费率',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '删除标志（0=存在 2=删除）',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '备注',
  PRIMARY KEY (`tier_id`) USING BTREE,
  UNIQUE INDEX `uk_tier_rate_level`(`energy_rate_id` ASC, `tier_level` ASC) USING BTREE,
  INDEX `idx_rate_tier_rate_id`(`energy_rate_id` ASC, `tier_level` ASC) USING BTREE,
  CONSTRAINT `fk_rate_tier_rate` FOREIGN KEY (`energy_rate_id`) REFERENCES `ems_energy_rate` (`energy_rate_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `chk_tier_rate_nonneg` CHECK (`rate` >= 0),
  CONSTRAINT `chk_tier_usage_range` CHECK ((`max_usage` is null) or (`max_usage` > `min_usage`))
) ENGINE = InnoDB AUTO_INCREMENT = 1997223591954993154 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '梯度费率（用量梯度收费规则）' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ems_rate_time_period_link
-- ----------------------------
DROP TABLE IF EXISTS `ems_rate_time_period_link`;
CREATE TABLE `ems_rate_time_period_link`  (
  `link_id` bigint NOT NULL AUTO_INCREMENT,
  `energy_rate_id` bigint NOT NULL COMMENT '费率ID',
  `period_id` bigint NOT NULL COMMENT '时间段ID',
  `rate` decimal(10, 4) NOT NULL COMMENT '该时间段的费率',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '删除标志（0=存在 2=删除）',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '备注',
  PRIMARY KEY (`link_id`) USING BTREE,
  UNIQUE INDEX `uk_rate_period_link`(`energy_rate_id` ASC, `period_id` ASC) USING BTREE,
  INDEX `idx_rate_time_period_link_rate`(`energy_rate_id` ASC) USING BTREE,
  INDEX `idx_rate_time_period_link_period`(`period_id` ASC) USING BTREE,
  CONSTRAINT `fk_link_period` FOREIGN KEY (`period_id`) REFERENCES `ems_time_period` (`period_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `fk_link_rate` FOREIGN KEY (`energy_rate_id`) REFERENCES `ems_energy_rate` (`energy_rate_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `chk_link_rate_nonneg` CHECK (`rate` >= 0)
) ENGINE = InnoDB AUTO_INCREMENT = 1997199504662626307 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '费率与时间段关联（峰谷时段费率）' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ems_safety_env_doc
-- ----------------------------
DROP TABLE IF EXISTS `ems_safety_env_doc`;
CREATE TABLE `ems_safety_env_doc`  (
  `doc_id` bigint NOT NULL AUTO_INCREMENT COMMENT '文档ID（主键）',
  `doc_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '文档编号（唯一）',
  `doc_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '文档名称',
  `doc_category` tinyint NOT NULL COMMENT '文档分类（1=安全 2=环保）',
  `doc_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '文档类型（如：制度、规范、手册等）',
  `accessory` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '附件',
  `version` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '1.0' COMMENT '文档版本',
  `publish_status` tinyint NOT NULL DEFAULT 0 COMMENT '发布状态（0=草稿 1=已发布）',
  `publish_time` date NULL DEFAULT NULL COMMENT '发布日期',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新人',
  PRIMARY KEY (`doc_id`) USING BTREE,
  INDEX `idx_doc_category`(`doc_category` ASC) USING BTREE,
  INDEX `idx_doc_publish_status`(`publish_status` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1978035095038754819 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '安全环保制度文档表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ems_tier_period_link
-- ----------------------------
DROP TABLE IF EXISTS `ems_tier_period_link`;
CREATE TABLE `ems_tier_period_link`  (
  `link_id` bigint NOT NULL AUTO_INCREMENT,
  `tier_id` bigint NOT NULL COMMENT '梯度ID',
  `period_id` bigint NOT NULL COMMENT '时间段ID',
  `rate` decimal(10, 4) NOT NULL COMMENT '该梯度+时段的费率',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '删除标志（0=存在 2=删除）',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '备注',
  PRIMARY KEY (`link_id`) USING BTREE,
  UNIQUE INDEX `uk_tier_period_link`(`tier_id` ASC, `period_id` ASC) USING BTREE,
  INDEX `idx_tier_period_link_tier`(`tier_id` ASC) USING BTREE,
  INDEX `idx_tier_period_link_period`(`period_id` ASC) USING BTREE,
  CONSTRAINT `fk_tier_period_link_period` FOREIGN KEY (`period_id`) REFERENCES `ems_time_period` (`period_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `fk_tier_period_link_tier` FOREIGN KEY (`tier_id`) REFERENCES `ems_rate_tier` (`tier_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `chk_tier_period_link_rate_nonneg` CHECK (`rate` >= 0)
) ENGINE = InnoDB AUTO_INCREMENT = 1997213998172401667 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '梯度与时段关联（梯度+峰谷组合）' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ems_time_period
-- ----------------------------
DROP TABLE IF EXISTS `ems_time_period`;
CREATE TABLE `ems_time_period`  (
  `period_id` bigint NOT NULL AUTO_INCREMENT,
  `period_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '时间段名称（峰、谷、平）',
  `period_type` int NOT NULL COMMENT '时间段类型：0=峰，1=谷，2=平',
  `start_time` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '开始时间（HH:mm格式）',
  `end_time` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '结束时间（HH:mm格式）',
  `cross_day` int NOT NULL DEFAULT 0 COMMENT '是否跨天：0=否，1=是',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '删除标志（0=存在 2=删除）',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '备注',
  PRIMARY KEY (`period_id`) USING BTREE,
  UNIQUE INDEX `uk_period_type_time`(`period_type` ASC, `start_time` ASC, `end_time` ASC) USING BTREE,
  INDEX `idx_period_type`(`period_type` ASC) USING BTREE,
  CONSTRAINT `chk_cross_day` CHECK (`cross_day` in (0,1)),
  CONSTRAINT `chk_period_type` CHECK (`period_type` in (0,1,2))
) ENGINE = InnoDB AUTO_INCREMENT = 1997199504406773762 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '时间段定义（峰、谷、平）' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for eqp_auxiliary_material
-- ----------------------------
DROP TABLE IF EXISTS `eqp_auxiliary_material`;
CREATE TABLE `eqp_auxiliary_material`  (
  `auxiliary_id` bigint NOT NULL AUTO_INCREMENT COMMENT '辅料ID',
  `auxiliary_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '辅料名称',
  `material_category` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '物料品类',
  `auxiliary_model` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '辅料型号',
  `unit` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '计量单位',
  `equipment_id` bigint NULL DEFAULT NULL COMMENT '关联设备ID（可为空，通用辅料）',
  `unit_team` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '机组（如：1#机组、2#机组、公用机组等）',
  `quantity` int NULL DEFAULT 0 COMMENT '当前库存数量',
  `unit_price` decimal(18, 6) NULL DEFAULT 0.000000 COMMENT '当前移动加权平均单价',
  `total_amount` decimal(18, 2) NULL DEFAULT 0.00 COMMENT '当前库存总金额（可冗余，= quantity * unit_price）',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建者',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新者',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '0' COMMENT '删除标志（0=存在 2=删除）',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '备注',
  PRIMARY KEY (`auxiliary_id`) USING BTREE,
  INDEX `fk_auxiliary_equipment`(`equipment_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2037805711684247555 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '辅料表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for eqp_auxiliary_material_change
-- ----------------------------
DROP TABLE IF EXISTS `eqp_auxiliary_material_change`;
CREATE TABLE `eqp_auxiliary_material_change`  (
  `change_id` bigint NOT NULL AUTO_INCREMENT COMMENT '变动记录ID',
  `auxiliary_id` bigint NOT NULL COMMENT '关联辅料ID',
  `change_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '变动类型（增加/减少）',
  `change_quantity` int NOT NULL COMMENT '变动数量',
  `in_unit_price` decimal(18, 6) NULL DEFAULT NULL COMMENT '入库单价（仅增加时有意义）',
  `unit_price_snapshot` decimal(18, 6) NULL DEFAULT NULL COMMENT '单价快照（减少时必填，增加时可记录入库后单价）',
  `amount` decimal(18, 2) NULL DEFAULT NULL COMMENT '本次变动金额（有符号；建议减少时为负数：-unit_price_snapshot*change_quantity）',
  `reason` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '变动原因',
  `change_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '变动时间',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建者',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新者',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '0' COMMENT '删除标志（0=存在 2=删除）',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '备注',
  PRIMARY KEY (`change_id`) USING BTREE,
  INDEX `fk_change_auxiliary`(`auxiliary_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2039910831331557378 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '辅料变动记录表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for eqp_equipment_management
-- ----------------------------
DROP TABLE IF EXISTS `eqp_equipment_management`;
CREATE TABLE `eqp_equipment_management`  (
  `equipment_id` bigint NOT NULL AUTO_INCREMENT COMMENT '设备ID',
  `equipment_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备名称',
  `model` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '设备型号',
  `type_id` bigint NULL DEFAULT NULL COMMENT '设备类型ID',
  `equipment_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备编码',
  `location` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '设备位置（在役时有效）',
  `quantity` int NULL DEFAULT 1 COMMENT '设备数量',
  `manager` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '负责人',
  `oss_id` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '图片路径',
  `status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备状态（in_service=在役，retired=退役）',
  `stop_reason` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '停用原因（退役时必填）',
  `equipment_destination` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '设备去向（退役时必填）',
  `enable_time` datetime NULL DEFAULT NULL COMMENT '启用时间',
  `retire_time` datetime NULL DEFAULT NULL COMMENT '退役时间（状态变更为退役时记录）',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建者',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新者',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '0' COMMENT '删除标志（0=存在 2=删除）',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '备注',
  PRIMARY KEY (`equipment_id`) USING BTREE,
  UNIQUE INDEX `uk_equipment_code`(`equipment_code` ASC) USING BTREE COMMENT '设备编码唯一',
  INDEX `fk_equipment_type`(`type_id` ASC) USING BTREE,
  INDEX `idx_equipment_status`(`status` ASC) USING BTREE COMMENT '按状态查询索引'
) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备管理表（合并在役和退役设备）' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for eqp_equipment_param
-- ----------------------------
DROP TABLE IF EXISTS `eqp_equipment_param`;
CREATE TABLE `eqp_equipment_param`  (
  `param_id` bigint NOT NULL AUTO_INCREMENT COMMENT '参数ID',
  `param_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '参数名称',
  `equipment_id` bigint NOT NULL COMMENT '关联设备ID',
  `param_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '参数类型（无需检修/离散值/连续值/范围）',
  `param_standard` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '参数标准范围',
  `param_unit` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '参数单位',
  `param_source` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '参数来源（设备/自定义/厂内标准等）',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建者',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新者',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '0' COMMENT '删除标志（0=存在 2=删除）',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '备注',
  PRIMARY KEY (`param_id`) USING BTREE,
  INDEX `fk_param_equipment`(`equipment_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1979357424225439747 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备参数表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for eqp_equipment_type
-- ----------------------------
DROP TABLE IF EXISTS `eqp_equipment_type`;
CREATE TABLE `eqp_equipment_type`  (
  `type_id` bigint NOT NULL AUTO_INCREMENT COMMENT '设备类型ID',
  `type_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '分类名称',
  `type_desc` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '分类描述',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建者',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新者',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '0' COMMENT '删除标志（0=存在 2=删除）',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '备注',
  PRIMARY KEY (`type_id`) USING BTREE,
  UNIQUE INDEX `uk_type_name`(`type_name` ASC) USING BTREE COMMENT '类型名称唯一'
) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备类型表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for eqp_inspected_equipment
-- ----------------------------
DROP TABLE IF EXISTS `eqp_inspected_equipment`;
CREATE TABLE `eqp_inspected_equipment`  (
  `inspect_id` bigint NOT NULL AUTO_INCREMENT COMMENT '待检ID',
  `equipment_id` bigint NOT NULL COMMENT '关联设备ID',
  `inspect_time` datetime NULL DEFAULT NULL COMMENT '计划检修时间',
  `inspect_vendor` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '检修厂商',
  `remain_time` int NULL DEFAULT NULL COMMENT '剩余检修天数',
  `status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '状态（正常/临近/超期）',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建者',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新者',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '0' COMMENT '删除标志（0=存在 2=删除）',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '备注',
  PRIMARY KEY (`inspect_id`) USING BTREE,
  INDEX `fk_inspect_equipment`(`equipment_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1979364126983303170 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '待检设备表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for eqp_inspection_record
-- ----------------------------
DROP TABLE IF EXISTS `eqp_inspection_record`;
CREATE TABLE `eqp_inspection_record`  (
  `record_id` bigint NOT NULL AUTO_INCREMENT COMMENT '记录ID',
  `equipment_id` bigint NOT NULL COMMENT '关联设备ID',
  `inspect_time` datetime NULL DEFAULT NULL COMMENT '实际检修时间',
  `inspect_vendor` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '检修厂商',
  `inspect_content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '检修内容',
  `result` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '检修结果（合格/不合格/待观察）',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建者',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新者',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '0' COMMENT '删除标志（0=存在 2=删除）',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '备注',
  PRIMARY KEY (`record_id`) USING BTREE,
  INDEX `fk_record_equipment`(`equipment_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1979371267420958722 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '检修记录表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for eqp_spare_part
-- ----------------------------
DROP TABLE IF EXISTS `eqp_spare_part`;
CREATE TABLE `eqp_spare_part`  (
  `part_id` bigint NOT NULL AUTO_INCREMENT COMMENT '备件ID',
  `part_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '备件名称',
  `material_category` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '物料品类',
  `model` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备件型号',
  `unit` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '计量单位',
  `equipment_id` bigint NULL DEFAULT NULL COMMENT '关联设备ID（可为空，通用备件）',
  `unit_team` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '机组（如：1#机组、2#机组、公用机组等）',
  `quantity` int NULL DEFAULT 0 COMMENT '当前库存数量',
  `unit_price` decimal(18, 6) NULL DEFAULT 0.000000 COMMENT '当前移动加权平均单价',
  `total_amount` decimal(18, 2) NULL DEFAULT 0.00 COMMENT '当前库存总金额（可冗余，= quantity * unit_price）',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建者',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新者',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '0' COMMENT '删除标志（0=存在 2=删除）',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '备注',
  PRIMARY KEY (`part_id`) USING BTREE,
  INDEX `fk_part_equipment`(`equipment_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2038420433802522627 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '备品备件表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for eqp_spare_parts_change
-- ----------------------------
DROP TABLE IF EXISTS `eqp_spare_parts_change`;
CREATE TABLE `eqp_spare_parts_change`  (
  `change_id` bigint NOT NULL AUTO_INCREMENT COMMENT '变动记录ID',
  `part_id` bigint NOT NULL COMMENT '关联备件ID',
  `change_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '变动类型（增加/减少）',
  `change_quantity` int NOT NULL COMMENT '变动数量',
  `in_unit_price` decimal(18, 6) NULL DEFAULT NULL COMMENT '入库单价',
  `unit_price_snapshot` decimal(18, 6) NULL DEFAULT NULL COMMENT '单价快照（减少时必填，增加时可记录入库后单价）',
  `amount` decimal(18, 2) NULL DEFAULT NULL COMMENT '本次变动金额（有符号；建议减少时为负数：-unit_price_snapshot*change_quantity）',
  `reason` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '变动原因',
  `change_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '变动时间',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建者',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新者',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '0' COMMENT '删除标志（0=存在 2=删除）',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '备注',
  PRIMARY KEY (`change_id`) USING BTREE,
  INDEX `fk_change_part`(`part_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1980201774324969474 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '备品备件变动记录表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for eqp_type_param
-- ----------------------------
DROP TABLE IF EXISTS `eqp_type_param`;
CREATE TABLE `eqp_type_param`  (
  `type_param_id` bigint NOT NULL AUTO_INCREMENT COMMENT '类型参数ID',
  `type_id` bigint NOT NULL COMMENT '关联设备类型ID',
  `param_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '参数名称',
  `param_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '参数类型（无需检修/离散值/连续值/范围）',
  `param_standard` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '参数标准范围（该类型设备的通用标准）',
  `param_unit` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '参数单位',
  `param_source` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '参数来源（行业标准/厂内标准/自定义等）',
  `is_mandatory` tinyint(1) NULL DEFAULT 0 COMMENT '是否为该类型设备的必选参数（0=否，1=是）',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建者',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新者',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '0' COMMENT '删除标志（0=存在 2=删除）',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '备注',
  PRIMARY KEY (`type_param_id`) USING BTREE,
  UNIQUE INDEX `uk_type_param_name`(`type_id` ASC, `param_name` ASC) USING BTREE COMMENT '同一类型下参数名称唯一',
  INDEX `fk_type_param_type`(`type_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1979113791601565698 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备类型参数表（某类设备的通用参数标准）' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for erp_purchase_order
-- ----------------------------
DROP TABLE IF EXISTS `erp_purchase_order`;
CREATE TABLE `erp_purchase_order`  (
  `order_id` bigint NOT NULL AUTO_INCREMENT COMMENT '订单ID',
  `order_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '订单编号',
  `supplier_id` bigint NOT NULL COMMENT '供应商ID',
  `order_date` date NULL DEFAULT NULL COMMENT '下单日期',
  `expected_arrival` date NULL DEFAULT NULL COMMENT '预计到货日期',
  `order_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '订单类型',
  `total_amount` decimal(14, 2) NULL DEFAULT 0.00 COMMENT '订单总金额',
  `order_status` tinyint NULL DEFAULT 0 COMMENT '订单状态 0-草稿 1-执行中 2-部分到货 3-已完成 4-已取消',
  `confirm_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '下达人',
  `confirm_by` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '下达人',
  `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标志',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`order_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2005832314990219266 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '采购订单主表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for erp_purchase_order_item
-- ----------------------------
DROP TABLE IF EXISTS `erp_purchase_order_item`;
CREATE TABLE `erp_purchase_order_item`  (
  `item_id` bigint NOT NULL AUTO_INCREMENT COMMENT '明细ID',
  `order_id` bigint NOT NULL COMMENT '订单ID',
  `material_type_code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '物料类型',
  `specification` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '规格',
  `quantity` decimal(12, 2) NULL DEFAULT 0.00 COMMENT '采购数量',
  `unit_price` decimal(12, 2) NULL DEFAULT 0.00 COMMENT '单价',
  `amount` decimal(14, 2) NULL DEFAULT 0.00 COMMENT '金额',
  `current_stock` decimal(12, 2) NULL DEFAULT 0.00 COMMENT '当前库存',
  `on_the_way` decimal(12, 2) NULL DEFAULT 0.00 COMMENT '在途数量',
  `sales_demand` decimal(12, 2) NULL DEFAULT 0.00 COMMENT '销售需求',
  `suggest_purchase` decimal(12, 2) NULL DEFAULT 0.00 COMMENT '建议采购数量',
  `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标志',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`item_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2005832479817977858 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '采购订单明细表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for erp_purchase_receipt
-- ----------------------------
DROP TABLE IF EXISTS `erp_purchase_receipt`;
CREATE TABLE `erp_purchase_receipt`  (
  `receipt_id` bigint NOT NULL AUTO_INCREMENT COMMENT '收货记录ID',
  `order_id` bigint NOT NULL COMMENT '订单ID',
  `item_id` bigint NOT NULL COMMENT '订单明细ID',
  `received_qty` decimal(12, 2) NULL DEFAULT 0.00 COMMENT '收货数量',
  `receipt_time` datetime NULL DEFAULT NULL COMMENT '收货时间',
  `quality_result` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '质检结果',
  `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标志',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`receipt_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1991072050067619842 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '采购收货记录表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for erp_purchase_requirement
-- ----------------------------
DROP TABLE IF EXISTS `erp_purchase_requirement`;
CREATE TABLE `erp_purchase_requirement`  (
  `req_id` bigint NOT NULL AUTO_INCREMENT COMMENT '需求ID',
  `material_type_code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '物料类型',
  `specification` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '规格',
  `sales_demand` decimal(12, 2) NULL DEFAULT 0.00 COMMENT '销售需求量',
  `product_stock` decimal(12, 2) NULL DEFAULT 0.00 COMMENT '成品库存',
  `raw_stock` decimal(12, 2) NULL DEFAULT 0.00 COMMENT '原料库存',
  `raw_stock_conv` decimal(12, 2) NULL DEFAULT 0.00 COMMENT '原料库存折算',
  `on_the_way` decimal(12, 2) NULL DEFAULT 0.00 COMMENT '在途数量',
  `on_the_way_conv` decimal(12, 2) NULL DEFAULT 0.00 COMMENT '在途折算量',
  `suggest_purchase_qty` decimal(12, 2) NULL DEFAULT 0.00 COMMENT '建议采购量',
  `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标志',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`req_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '采购需求分析表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for erp_purchase_return
-- ----------------------------
DROP TABLE IF EXISTS `erp_purchase_return`;
CREATE TABLE `erp_purchase_return`  (
  `return_id` bigint NOT NULL AUTO_INCREMENT COMMENT '退货单ID',
  `order_id` bigint NOT NULL COMMENT '订单ID',
  `return_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '退货类型',
  `reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '退货原因',
  `status` tinyint NULL DEFAULT 0 COMMENT '退货状态',
  `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标志',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`return_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1991055052201869314 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '采购退货主表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for erp_purchase_return_item
-- ----------------------------
DROP TABLE IF EXISTS `erp_purchase_return_item`;
CREATE TABLE `erp_purchase_return_item`  (
  `return_item_id` bigint NOT NULL AUTO_INCREMENT COMMENT '退货明细ID',
  `return_id` bigint NOT NULL COMMENT '退货单ID',
  `item_id` bigint NOT NULL COMMENT '订单明细ID',
  `return_qty` decimal(12, 2) NULL DEFAULT 0.00 COMMENT '退货数量',
  `photos` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '问题照片',
  `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标志',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`return_item_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '采购退货明细表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for erp_supplier
-- ----------------------------
DROP TABLE IF EXISTS `erp_supplier`;
CREATE TABLE `erp_supplier`  (
  `supplier_id` bigint NOT NULL AUTO_INCREMENT COMMENT '供应商ID',
  `supplier_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '供应商编码',
  `name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '供应商名称',
  `type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供应商类型',
  `credit_rating` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '信用等级 A/B/C/D',
  `contact_person` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '联系人',
  `contact_phone` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '联系电话',
  `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '地址',
  `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标志',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`supplier_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1991019395249156099 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '供应商档案表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for erp_supplier_price
-- ----------------------------
DROP TABLE IF EXISTS `erp_supplier_price`;
CREATE TABLE `erp_supplier_price`  (
  `price_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `supplier_id` bigint NOT NULL COMMENT '供应商ID',
  `material_type_code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '物料类型编码',
  `specification` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '规格',
  `price` decimal(12, 2) NULL DEFAULT NULL COMMENT '价格',
  `valid_from` date NULL DEFAULT NULL COMMENT '生效日期',
  `valid_to` date NULL DEFAULT NULL COMMENT '失效日期',
  `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标志',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`price_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1991019561721081858 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '供应商价格表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for gen_table
-- ----------------------------
DROP TABLE IF EXISTS `gen_table`;
CREATE TABLE `gen_table`  (
  `table_id` bigint NOT NULL COMMENT '编号',
  `table_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '表名称',
  `table_comment` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '表描述',
  `sub_table_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '关联子表的表名',
  `sub_table_fk_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '子表关联的外键名',
  `class_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '实体类名称',
  `tpl_category` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT 'crud' COMMENT '使用的模板（crud单表操作 tree树表操作）',
  `package_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '生成包路径',
  `module_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '生成模块名',
  `business_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '生成业务名',
  `function_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '生成功能名',
  `function_author` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '生成功能作者',
  `gen_type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '生成代码方式（0zip压缩包 1自定义路径）',
  `gen_path` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '/' COMMENT '生成路径（不填默认项目路径）',
  `options` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '其它生成选项',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`table_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '代码生成业务表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for gen_table_column
-- ----------------------------
DROP TABLE IF EXISTS `gen_table_column`;
CREATE TABLE `gen_table_column`  (
  `column_id` bigint NOT NULL COMMENT '编号',
  `table_id` bigint NULL DEFAULT NULL COMMENT '归属表编号',
  `column_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '列名称',
  `column_comment` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '列描述',
  `column_type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '列类型',
  `java_type` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'JAVA类型',
  `java_field` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'JAVA字段名',
  `is_pk` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '是否主键（1是）',
  `is_increment` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '是否自增（1是）',
  `is_required` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '是否必填（1是）',
  `is_insert` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '是否为插入字段（1是）',
  `is_edit` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '是否编辑字段（1是）',
  `is_list` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '是否列表字段（1是）',
  `is_query` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '是否查询字段（1是）',
  `query_type` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT 'EQ' COMMENT '查询方式（等于、不等于、大于、小于、范围）',
  `html_type` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '显示类型（文本框、文本域、下拉框、复选框、单选框、日期控件）',
  `dict_type` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '字典类型',
  `sort` int NULL DEFAULT NULL COMMENT '排序',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`column_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '代码生成业务表字段' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for hrm_attend_calc
-- ----------------------------
DROP TABLE IF EXISTS `hrm_attend_calc`;
CREATE TABLE `hrm_attend_calc`  (
  `calc_id` bigint NOT NULL COMMENT '考勤结果ID',
  `emp_id` bigint NOT NULL COMMENT '员工ID',
  `work_date` date NOT NULL COMMENT '工作日期',
  `shift_id` bigint NULL DEFAULT NULL COMMENT '班次ID',
  `status` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT 'normal' COMMENT '日考勤状态 normal/late/early/absent',
  `work_minutes` int NULL DEFAULT 0 COMMENT '出勤分钟数',
  `late_minutes` int NULL DEFAULT 0 COMMENT '迟到分钟数',
  `early_minutes` int NULL DEFAULT 0 COMMENT '早退分钟数',
  `ot_minutes` int NULL DEFAULT 0 COMMENT '加班分钟数',
  `leave_minutes_json` json NULL COMMENT '请假分钟分布JSON',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  PRIMARY KEY (`calc_id`) USING BTREE,
  UNIQUE INDEX `uk_emp_date`(`emp_id` ASC, `work_date` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '日考勤结果' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for hrm_certificate
-- ----------------------------
DROP TABLE IF EXISTS `hrm_certificate`;
CREATE TABLE `hrm_certificate`  (
  `cert_id` bigint NOT NULL COMMENT '证书ID',
  `emp_id` bigint NOT NULL COMMENT '员工ID',
  `cert_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '证书名称',
  `cert_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '证书编号',
  `issued_by` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '颁发机构',
  `valid_from` date NULL DEFAULT NULL COMMENT '有效期开始',
  `valid_to` date NULL DEFAULT NULL COMMENT '有效期结束',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  `file_ids` varchar(2525) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '证书附件 fileIds',
  PRIMARY KEY (`cert_id`) USING BTREE,
  INDEX `idx_emp`(`emp_id` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '证书' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for hrm_contract
-- ----------------------------
DROP TABLE IF EXISTS `hrm_contract`;
CREATE TABLE `hrm_contract`  (
  `contract_id` bigint NOT NULL COMMENT '合同ID',
  `emp_id` bigint NOT NULL COMMENT '员工ID',
  `contract_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '合同编号',
  `contract_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '合同类型',
  `start_date` date NULL DEFAULT NULL COMMENT '开始日期',
  `end_date` date NULL DEFAULT NULL COMMENT '结束日期',
  `status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '状态',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  `file_ids` varchar(5096) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '文件ids',
  PRIMARY KEY (`contract_id`) USING BTREE,
  UNIQUE INDEX `uk_contract_no`(`contract_no` ASC) USING BTREE,
  INDEX `idx_emp`(`emp_id` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '劳动合同' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for hrm_emp_org_position
-- ----------------------------
DROP TABLE IF EXISTS `hrm_emp_org_position`;
CREATE TABLE `hrm_emp_org_position`  (
  `rel_id` bigint NOT NULL COMMENT '关系ID',
  `emp_id` bigint NOT NULL COMMENT '员工ID',
  `dept_id` bigint NOT NULL COMMENT '组织ID',
  `post_id` bigint NOT NULL COMMENT '岗位ID',
  `is_primary` tinyint NULL DEFAULT 0 COMMENT '是否主岗位 1是 0否',
  `start_date` date NULL DEFAULT NULL COMMENT '开始日期',
  `end_date` date NULL DEFAULT NULL COMMENT '结束日期',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  PRIMARY KEY (`rel_id`) USING BTREE,
  INDEX `idx_emp`(`emp_id` ASC) USING BTREE,
  INDEX `idx_org`(`dept_id` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '员工-组织-岗位关系' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for hrm_employee
-- ----------------------------
DROP TABLE IF EXISTS `hrm_employee`;
CREATE TABLE `hrm_employee`  (
  `emp_id` bigint NOT NULL COMMENT '员工ID',
  `user_id` bigint NULL DEFAULT NULL COMMENT '绑定的系统用户ID',
  `emp_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '工号',
  `emp_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '姓名',
  `gender` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '性别',
  `mobile` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '手机号',
  `email` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '邮箱',
  `id_no` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '证件号码',
  `hire_date` date NULL DEFAULT NULL COMMENT '入职日期',
  `employment_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '雇佣类型 fulltime/intern/outsourcing/parttime',
  `status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT 'onboard' COMMENT '在职状态 onboard/leave/probation/frozen',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '主组织ID',
  `post_id` bigint NULL DEFAULT NULL COMMENT '主岗位ID',
  `seniority_years` decimal(5, 2) NULL DEFAULT 0.00 COMMENT '司龄(年)',
  `contract_end_date` date NULL DEFAULT NULL COMMENT '合同到期日',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  PRIMARY KEY (`emp_id`) USING BTREE,
  UNIQUE INDEX `uk_emp_no`(`emp_no` ASC) USING BTREE,
  INDEX `idx_user`(`user_id` ASC) USING BTREE,
  INDEX `idx_org`(`dept_id` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '员工主数据' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for hrm_flow_action
-- ----------------------------
DROP TABLE IF EXISTS `hrm_flow_action`;
CREATE TABLE `hrm_flow_action`  (
  `action_id` bigint NOT NULL COMMENT '操作ID',
  `task_id` bigint NULL DEFAULT NULL COMMENT '任务ID',
  `inst_id` bigint NOT NULL COMMENT '实例ID',
  `action` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '动作 approve/reject/cc/forward/withdraw',
  `remark` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '操作说明',
  `action_user_id` bigint NULL DEFAULT NULL COMMENT '操作人',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  `biz_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '业务类型',
  `biz_id` bigint NULL DEFAULT NULL COMMENT '业务ID',
  PRIMARY KEY (`action_id`) USING BTREE,
  INDEX `idx_inst`(`inst_id` ASC) USING BTREE,
  INDEX `idx_task`(`task_id` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '操作日志' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for hrm_flow_cc
-- ----------------------------
DROP TABLE IF EXISTS `hrm_flow_cc`;
CREATE TABLE `hrm_flow_cc`  (
  `cc_id` bigint NOT NULL COMMENT '抄送ID',
  `inst_id` bigint NOT NULL COMMENT '实例ID',
  `biz_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '业务类型',
  `biz_id` bigint NULL DEFAULT NULL COMMENT '业务ID',
  `node_id` bigint NULL DEFAULT NULL COMMENT '触发抄送的节点ID',
  `cc_user_id` bigint NOT NULL COMMENT '被抄送的用户ID',
  `from_user_id` bigint NULL DEFAULT NULL COMMENT '触发抄送的操作人ID',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  `read_flag` tinyint NULL DEFAULT 0 COMMENT '0未读1已读',
  `node_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '触发抄送的节点名称',
  PRIMARY KEY (`cc_id`) USING BTREE,
  INDEX `idx_inst`(`inst_id` ASC) USING BTREE,
  INDEX `idx_cc_user`(`cc_user_id` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '流程抄送记录' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for hrm_flow_instance
-- ----------------------------
DROP TABLE IF EXISTS `hrm_flow_instance`;
CREATE TABLE `hrm_flow_instance`  (
  `inst_id` bigint NOT NULL COMMENT '实例ID',
  `tpl_id` bigint NOT NULL COMMENT '模板ID',
  `biz_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '业务类型',
  `biz_id` bigint NOT NULL COMMENT '关联业务单ID',
  `status` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '状态 draft/running/approved/rejected/canceled',
  `current_node_id` bigint NULL DEFAULT NULL COMMENT '当前节点ID',
  `start_user_id` bigint NULL DEFAULT NULL COMMENT '发起人ID',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  PRIMARY KEY (`inst_id`) USING BTREE,
  INDEX `idx_biz`(`biz_type` ASC, `biz_id` ASC) USING BTREE,
  INDEX `idx_tpl`(`tpl_id` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '流程实例' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for hrm_flow_node
-- ----------------------------
DROP TABLE IF EXISTS `hrm_flow_node`;
CREATE TABLE `hrm_flow_node`  (
  `node_id` bigint NOT NULL COMMENT '节点ID',
  `tpl_id` bigint NOT NULL COMMENT '模板ID',
  `order_no` int NOT NULL COMMENT '节点顺序',
  `node_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '节点类型 approve/cc',
  `approver_rule` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '审批人规则 fixed/role/position/leader/dept_leader',
  `approver_value` json NULL COMMENT '审批人取值',
  `field_perm` json NULL COMMENT '字段权限配置',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  PRIMARY KEY (`node_id`) USING BTREE,
  INDEX `idx_tpl`(`tpl_id` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '模板节点配置' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for hrm_flow_task
-- ----------------------------
DROP TABLE IF EXISTS `hrm_flow_task`;
CREATE TABLE `hrm_flow_task`  (
  `task_id` bigint NOT NULL COMMENT '任务ID',
  `inst_id` bigint NOT NULL COMMENT '实例ID',
  `node_id` bigint NOT NULL COMMENT '节点ID',
  `assignee_user_id` bigint NULL DEFAULT NULL COMMENT '当前处理人',
  `status` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '状态 pending/approved/rejected/forwarded',
  `expire_time` datetime NULL DEFAULT NULL COMMENT '超时时间',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  `biz_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '业务类型',
  `biz_id` bigint NULL DEFAULT NULL COMMENT '业务ID',
  PRIMARY KEY (`task_id`) USING BTREE,
  INDEX `idx_inst`(`inst_id` ASC) USING BTREE,
  INDEX `idx_assignee`(`assignee_user_id` ASC) USING BTREE,
  INDEX `idx_hrm_flow_task_biz`(`biz_type` ASC, `biz_id` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '待办任务' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for hrm_flow_template
-- ----------------------------
DROP TABLE IF EXISTS `hrm_flow_template`;
CREATE TABLE `hrm_flow_template`  (
  `tpl_id` bigint NOT NULL COMMENT '模板ID',
  `tpl_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '模板编码',
  `tpl_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '模板名称',
  `biz_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '业务类型',
  `version` int NOT NULL DEFAULT 1 COMMENT '版本号',
  `enabled` tinyint NULL DEFAULT 1 COMMENT '是否启用 1是0否',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  PRIMARY KEY (`tpl_id`) USING BTREE,
  UNIQUE INDEX `uk_tpl`(`tpl_code` ASC, `version` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '流程模板' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for hrm_form_data
-- ----------------------------
DROP TABLE IF EXISTS `hrm_form_data`;
CREATE TABLE `hrm_form_data`  (
  `form_id` bigint NOT NULL COMMENT '表单ID',
  `biz_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '业务类型',
  `biz_id` bigint NOT NULL COMMENT '业务ID',
  `content_json` json NOT NULL COMMENT '表单内容JSON',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  PRIMARY KEY (`form_id`) USING BTREE,
  UNIQUE INDEX `uk_biz`(`biz_type` ASC, `biz_id` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '表单数据' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for hrm_headcount_plan
-- ----------------------------
DROP TABLE IF EXISTS `hrm_headcount_plan`;
CREATE TABLE `hrm_headcount_plan`  (
  `plan_id` bigint NOT NULL COMMENT '编制ID',
  `dept_id` bigint NOT NULL COMMENT '组织ID',
  `post_id` bigint NOT NULL COMMENT '岗位ID',
  `year` int NOT NULL COMMENT '年份',
  `month` int NOT NULL COMMENT '月份',
  `budget_count` int NOT NULL COMMENT '编制人数',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  PRIMARY KEY (`plan_id`) USING BTREE,
  UNIQUE INDEX `uk_plan`(`dept_id` ASC, `post_id` ASC, `year` ASC, `month` ASC) USING BTREE,
  INDEX `idx_org`(`dept_id` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '编制/预算' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for hrm_leave_balance
-- ----------------------------
DROP TABLE IF EXISTS `hrm_leave_balance`;
CREATE TABLE `hrm_leave_balance`  (
  `bal_id` bigint NOT NULL COMMENT '余额ID',
  `emp_id` bigint NOT NULL COMMENT '员工ID',
  `leave_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '假期类型',
  `balance_hours` decimal(8, 2) NOT NULL DEFAULT 0.00 COMMENT '余额小时',
  `expire_date` date NULL DEFAULT NULL COMMENT '到期日',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  PRIMARY KEY (`bal_id`) USING BTREE,
  UNIQUE INDEX `uk_emp_type`(`emp_id` ASC, `leave_type` ASC, `expire_date` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '假期余额' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for hrm_leave_job
-- ----------------------------
DROP TABLE IF EXISTS `hrm_leave_job`;
CREATE TABLE `hrm_leave_job`  (
  `biz_id` bigint NOT NULL COMMENT '业务ID',
  `emp_id` bigint NOT NULL COMMENT '员工ID',
  `apply_date` date NULL DEFAULT NULL COMMENT '申请日期',
  `last_work_date` date NULL DEFAULT NULL COMMENT '最后工作日',
  `reason` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '离职原因',
  `handover_status` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '交接状态',
  `status` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT 'draft' COMMENT '状态',
  `accessory_apply_ids` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '申请附件oss_id列表(CSV, sys_oss)',
  `accessory_receipt_ids` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '回执附件oss_id列表(CSV, sys_oss)',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  PRIMARY KEY (`biz_id`) USING BTREE,
  INDEX `idx_emp`(`emp_id` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '离职单' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for hrm_leave_req
-- ----------------------------
DROP TABLE IF EXISTS `hrm_leave_req`;
CREATE TABLE `hrm_leave_req`  (
  `biz_id` bigint NOT NULL COMMENT '业务ID',
  `emp_id` bigint NOT NULL COMMENT '员工ID',
  `leave_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '请假类型',
  `start_time` datetime NOT NULL COMMENT '开始时间',
  `end_time` datetime NOT NULL COMMENT '结束时间',
  `hours` decimal(8, 2) NOT NULL COMMENT '请假时长(小时)',
  `reason` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '请假原因',
  `status` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT 'draft' COMMENT '状态',
  `accessory_apply_ids` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '申请附件oss_id列表(CSV, sys_oss)',
  `accessory_receipt_ids` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '回执附件oss_id列表(CSV, sys_oss)',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  PRIMARY KEY (`biz_id`) USING BTREE,
  INDEX `idx_emp`(`emp_id` ASC) USING BTREE,
  INDEX `idx_time`(`start_time` ASC, `end_time` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '请假单' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for hrm_onboard
-- ----------------------------
DROP TABLE IF EXISTS `hrm_onboard`;
CREATE TABLE `hrm_onboard`  (
  `biz_id` bigint NOT NULL COMMENT '业务ID',
  `emp_id` bigint NULL DEFAULT NULL COMMENT '预建或生成的员工ID',
  `org_id` bigint NOT NULL COMMENT '入职组织ID',
  `position_id` bigint NOT NULL COMMENT '入职岗位ID',
  `plan_hire_date` date NULL DEFAULT NULL COMMENT '计划入职日期',
  `probation_months` int NULL DEFAULT NULL COMMENT '试用期（月）',
  `accessory_apply_ids` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '申请附件oss_id列表(CSV, sys_oss)',
  `status` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT 'draft' COMMENT '状态',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  PRIMARY KEY (`biz_id`) USING BTREE,
  INDEX `idx_org`(`org_id` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '入职单' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for hrm_pay_plan
-- ----------------------------
DROP TABLE IF EXISTS `hrm_pay_plan`;
CREATE TABLE `hrm_pay_plan`  (
  `plan_id` bigint NOT NULL COMMENT '方案ID',
  `plan_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '方案名称',
  `base_salary` decimal(12, 2) NULL DEFAULT 0.00 COMMENT '基础工资',
  `allowance_json` json NULL COMMENT '津贴配置JSON',
  `formula_json` json NULL COMMENT '公式配置JSON',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  PRIMARY KEY (`plan_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '薪酬方案' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for hrm_pay_run
-- ----------------------------
DROP TABLE IF EXISTS `hrm_pay_run`;
CREATE TABLE `hrm_pay_run`  (
  `run_id` bigint NOT NULL COMMENT '批次ID',
  `period` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '核算周期 YYYY-MM',
  `status` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT 'draft' COMMENT '状态 draft/locked',
  `plan_id` bigint NULL DEFAULT NULL COMMENT '方案ID',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  PRIMARY KEY (`run_id`) USING BTREE,
  UNIQUE INDEX `uk_period`(`period` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '薪酬计算批次' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for hrm_payslip
-- ----------------------------
DROP TABLE IF EXISTS `hrm_payslip`;
CREATE TABLE `hrm_payslip`  (
  `slip_id` bigint NOT NULL COMMENT '工资条ID',
  `run_id` bigint NOT NULL COMMENT '批次ID',
  `emp_id` bigint NOT NULL COMMENT '员工ID',
  `amount_gross` decimal(12, 2) NULL DEFAULT 0.00 COMMENT '应发金额',
  `amount_net` decimal(12, 2) NULL DEFAULT 0.00 COMMENT '实发金额',
  `items_json` json NULL COMMENT '工资项JSON',
  `status` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT 'issued' COMMENT '状态 issued/revoked',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  PRIMARY KEY (`slip_id`) USING BTREE,
  UNIQUE INDEX `uk_run_emp`(`run_id` ASC, `emp_id` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '工资条' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for hrm_punch
-- ----------------------------
DROP TABLE IF EXISTS `hrm_punch`;
CREATE TABLE `hrm_punch`  (
  `punch_id` bigint NOT NULL COMMENT '打卡ID',
  `emp_id` bigint NOT NULL COMMENT '员工ID',
  `punch_time` datetime NOT NULL COMMENT '打卡时间',
  `source` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT 'device' COMMENT '来源 device/gps/manual',
  `location` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '位置',
  `device_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '设备ID',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  PRIMARY KEY (`punch_id`) USING BTREE,
  INDEX `idx_emp_time`(`emp_id` ASC, `punch_time` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '打卡记录' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for hrm_reimburse_req
-- ----------------------------
DROP TABLE IF EXISTS `hrm_reimburse_req`;
CREATE TABLE `hrm_reimburse_req`  (
  `biz_id` bigint NOT NULL COMMENT '业务ID',
  `emp_id` bigint NOT NULL COMMENT '员工ID',
  `reimburse_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '报销类型(如：差旅费/招待费/办公费/其他)',
  `total_amount` decimal(12, 2) NULL DEFAULT 0.00 COMMENT '报销总金额',
  `reason` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '报销事由/说明',
  `status` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT 'draft' COMMENT '状态 draft/pending/approved/rejected/withdraw/canceled',
  `accessory_apply_ids` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '报销单据附件oss_id列表(CSV, sys_oss)',
  `accessory_receipt_ids` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '回执附件oss_id列表(CSV, sys_oss)',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  PRIMARY KEY (`biz_id`) USING BTREE,
  INDEX `idx_emp`(`emp_id` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '日常报销申请单' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for hrm_schedule
-- ----------------------------
DROP TABLE IF EXISTS `hrm_schedule`;
CREATE TABLE `hrm_schedule`  (
  `sched_id` bigint NOT NULL COMMENT '排班ID',
  `emp_id` bigint NOT NULL COMMENT '员工ID',
  `work_date` date NOT NULL COMMENT '工作日期',
  `shift_id` bigint NOT NULL COMMENT '班次ID',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  PRIMARY KEY (`sched_id`) USING BTREE,
  UNIQUE INDEX `uk_emp_date`(`emp_id` ASC, `work_date` ASC) USING BTREE,
  INDEX `idx_shift`(`shift_id` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '排班表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for hrm_seal_req
-- ----------------------------
DROP TABLE IF EXISTS `hrm_seal_req`;
CREATE TABLE `hrm_seal_req`  (
  `biz_id` bigint NOT NULL COMMENT '业务ID',
  `emp_id` bigint NOT NULL COMMENT '申请人ID',
  `seal_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '用印类型(公章/合同章/财务章等)',
  `purpose` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '用途说明',
  `apply_file_ids` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '申请材料附件ID列表(CSV，对应hrm_attachment)',
  `receipt_required` tinyint NULL DEFAULT 0 COMMENT '是否需要回执 1是0否',
  `receipt_status` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT 'none' COMMENT '回执状态 none/pending/done',
  `receipt_file_ids` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '回执附件ID列表(CSV，对应hrm_attachment)',
  `status` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT 'draft' COMMENT '状态 draft/pending/approved/rejected/canceled',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门id',
  PRIMARY KEY (`biz_id`) USING BTREE,
  INDEX `idx_emp`(`emp_id` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '用印申请' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for hrm_shift
-- ----------------------------
DROP TABLE IF EXISTS `hrm_shift`;
CREATE TABLE `hrm_shift`  (
  `shift_id` bigint NOT NULL COMMENT '班次ID',
  `shift_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '班次编码',
  `shift_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '班次名称',
  `start_time` time NOT NULL COMMENT '上班时间',
  `end_time` time NOT NULL COMMENT '下班时间',
  `break_minutes` int NULL DEFAULT 0 COMMENT '休息分钟数',
  `is_night` tinyint NULL DEFAULT 0 COMMENT '是否夜班 1是0否',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  PRIMARY KEY (`shift_id`) USING BTREE,
  UNIQUE INDEX `uk_shift_code`(`shift_code` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '班次' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for hrm_stat_snapshot
-- ----------------------------
DROP TABLE IF EXISTS `hrm_stat_snapshot`;
CREATE TABLE `hrm_stat_snapshot`  (
  `snap_id` bigint NOT NULL COMMENT '快照ID',
  `stat_date` date NOT NULL COMMENT '统计日期',
  `stat_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '指标类型 headcount/turnover/attendance/ot',
  `dim_json` json NULL COMMENT '维度信息JSON',
  `value_num` decimal(18, 4) NULL DEFAULT 0.0000 COMMENT '数值',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  PRIMARY KEY (`snap_id`) USING BTREE,
  INDEX `idx_date_type`(`stat_date` ASC, `stat_type` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '指标快照' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for hrm_transfer
-- ----------------------------
DROP TABLE IF EXISTS `hrm_transfer`;
CREATE TABLE `hrm_transfer`  (
  `biz_id` bigint NOT NULL COMMENT '业务ID',
  `emp_id` bigint NOT NULL COMMENT '员工ID',
  `from_org_id` bigint NULL DEFAULT NULL COMMENT '原组织ID',
  `to_org_id` bigint NOT NULL COMMENT '目标组织ID',
  `from_position_id` bigint NULL DEFAULT NULL COMMENT '原岗位ID',
  `to_position_id` bigint NOT NULL COMMENT '目标岗位ID',
  `effective_date` date NULL DEFAULT NULL COMMENT '生效日期',
  `salary_change_json` json NULL COMMENT '调薪内容JSON',
  `status` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT 'draft' COMMENT '状态',
  `accessory_apply_ids` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '申请附件oss_id列表(CSV, sys_oss)',
  `accessory_receipt_ids` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '回执附件oss_id列表(CSV, sys_oss)',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  PRIMARY KEY (`biz_id`) USING BTREE,
  INDEX `idx_emp`(`emp_id` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '转岗/调薪/借调单' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for hrm_travel_req
-- ----------------------------
DROP TABLE IF EXISTS `hrm_travel_req`;
CREATE TABLE `hrm_travel_req`  (
  `biz_id` bigint NOT NULL COMMENT '业务ID',
  `emp_id` bigint NOT NULL COMMENT '员工ID',
  `start_time` datetime NOT NULL COMMENT '开始时间',
  `end_time` datetime NOT NULL COMMENT '结束时间',
  `destination` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '目的地',
  `reason` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '出差原因',
  `status` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT 'draft' COMMENT '状态',
  `accessory_apply_ids` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '申请附件oss_id列表(CSV, sys_oss)',
  `accessory_receipt_ids` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '回执附件oss_id列表(CSV, sys_oss)',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  `travel_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '出差类型',
  `payee_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '收款人',
  `estimated_cost` decimal(10, 2) NULL DEFAULT NULL COMMENT '预估费用',
  `bank_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '开户行',
  `bank_account` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '银行账号',
  PRIMARY KEY (`biz_id`) USING BTREE,
  INDEX `idx_emp`(`emp_id` ASC) USING BTREE,
  INDEX `idx_time`(`start_time` ASC, `end_time` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '出差单' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for is_inspection_commission
-- ----------------------------
DROP TABLE IF EXISTS `is_inspection_commission`;
CREATE TABLE `is_inspection_commission`  (
  `commission_id` bigint NOT NULL AUTO_INCREMENT COMMENT '委托单ID',
  `commission_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '委托单号',
  `client` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '委托单位',
  `sample_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '样品名称',
  `sample_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '样品类型',
  `quantity` int NOT NULL COMMENT '样品数量',
  `inspection_items` json NOT NULL COMMENT '检验项目（JSON数组）',
  `commission_date` datetime NOT NULL COMMENT '委托日期',
  `deadline` date NOT NULL COMMENT '要求完成日期',
  `status` enum('待审核','已受理','已驳回') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '待审核' COMMENT '状态',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=删除）',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新人',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`commission_id`) USING BTREE,
  UNIQUE INDEX `commission_no`(`commission_no` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1978645218835865603 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '检验委托单表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for is_inspection_task
-- ----------------------------
DROP TABLE IF EXISTS `is_inspection_task`;
CREATE TABLE `is_inspection_task`  (
  `task_id` bigint NOT NULL AUTO_INCREMENT COMMENT '任务ID',
  `task_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '任务单号',
  `commission_id` bigint NOT NULL COMMENT '关联委托单ID',
  `assigned_to` bigint NOT NULL COMMENT '负责人（用户ID）',
  `start_time` datetime NULL DEFAULT NULL COMMENT '任务开始时间',
  `end_time` datetime NULL DEFAULT NULL COMMENT '任务完成时间',
  `result` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '检验结果',
  `conclusion` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '检验结论',
  `status` enum('待分配','进行中','已完成','已审核') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '待分配' COMMENT '状态',
  `priority` tinyint NULL DEFAULT 1 COMMENT '优先级（1-普通, 2-紧急）',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=删除）',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新人',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`task_id`) USING BTREE,
  UNIQUE INDEX `task_no`(`task_no` ASC) USING BTREE,
  INDEX `commission_id`(`commission_id` ASC) USING BTREE,
  CONSTRAINT `is_inspection_task_ibfk_1` FOREIGN KEY (`commission_id`) REFERENCES `is_inspection_commission` (`commission_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1978645337249456131 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '检验任务表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for is_sample_inventory
-- ----------------------------
DROP TABLE IF EXISTS `is_sample_inventory`;
CREATE TABLE `is_sample_inventory`  (
  `sample_id` bigint NOT NULL AUTO_INCREMENT COMMENT '样品ID',
  `commission_id` bigint NOT NULL COMMENT '关联委托单ID',
  `location` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '存放位置（如：A区-3排-2架）',
  `current_quantity` int NOT NULL COMMENT '当前库存量',
  `storage_time` datetime NOT NULL COMMENT '入库时间',
  `expiration_date` date NOT NULL COMMENT '有效期至',
  `status` enum('在库','已出库','已销毁') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '在库' COMMENT '状态',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=删除）',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新人',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`sample_id`) USING BTREE,
  INDEX `commission_id`(`commission_id` ASC) USING BTREE,
  CONSTRAINT `is_sample_inventory_ibfk_1` FOREIGN KEY (`commission_id`) REFERENCES `is_inspection_commission` (`commission_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '样品库存表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for report_export_file
-- ----------------------------
DROP TABLE IF EXISTS `report_export_file`;
CREATE TABLE `report_export_file`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `report_title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '报表标题',
  `report_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '报表名称(唯一)',
  `report_params` json NULL COMMENT '报表查询参数(JSON格式)',
  `production_line` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '相关产线',
  `oss_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '附件的OSSID, 用于下载',
  `attachment` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '附件(文件存储路径/URL)',
  `report_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '报表类型(如:Excel/PDF/Word)',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `del_flag` tinyint NOT NULL DEFAULT 0 COMMENT '删除标志 0-未删除 1-已删除',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_report_name`(`report_name` ASC, `del_flag` ASC) USING BTREE COMMENT '报表名称唯一索引(逻辑删除下唯一)'
) ENGINE = InnoDB AUTO_INCREMENT = 2045306917889474563 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '报表导出文件表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for scan_result
-- ----------------------------
DROP TABLE IF EXISTS `scan_result`;
CREATE TABLE `scan_result`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 13 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sys_config
-- ----------------------------
DROP TABLE IF EXISTS `sys_config`;
CREATE TABLE `sys_config`  (
  `config_id` bigint NOT NULL COMMENT '参数主键',
  `config_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '参数名称',
  `config_key` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '参数键名',
  `config_value` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '参数键值',
  `config_type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT 'N' COMMENT '系统内置（Y是 N否）',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`config_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '参数配置表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sys_dept
-- ----------------------------
DROP TABLE IF EXISTS `sys_dept`;
CREATE TABLE `sys_dept`  (
  `dept_id` bigint NOT NULL COMMENT '部门id',
  `parent_id` bigint NULL DEFAULT 0 COMMENT '父部门id',
  `ancestors` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '祖级列表',
  `dept_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '部门名称',
  `order_num` int NULL DEFAULT 0 COMMENT '显示顺序',
  `leader` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '负责人',
  `phone` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '联系电话',
  `email` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '邮箱',
  `status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '部门状态（0正常 1停用）',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '删除标志（0代表存在 2代表删除）',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`dept_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '部门表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sys_dict_data
-- ----------------------------
DROP TABLE IF EXISTS `sys_dict_data`;
CREATE TABLE `sys_dict_data`  (
  `dict_code` bigint NOT NULL COMMENT '字典编码',
  `dict_sort` int NULL DEFAULT 0 COMMENT '字典排序',
  `dict_label` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '字典标签',
  `dict_value` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '字典键值',
  `dict_type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '字典类型',
  `css_class` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '样式属性（其他样式扩展）',
  `list_class` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '表格回显样式',
  `is_default` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT 'N' COMMENT '是否默认（Y是 N否）',
  `status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '状态（0正常 1停用）',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`dict_code`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '字典数据表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sys_dict_type
-- ----------------------------
DROP TABLE IF EXISTS `sys_dict_type`;
CREATE TABLE `sys_dict_type`  (
  `dict_id` bigint NOT NULL COMMENT '字典主键',
  `dict_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '字典名称',
  `dict_type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '字典类型',
  `status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '状态（0正常 1停用）',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`dict_id`) USING BTREE,
  UNIQUE INDEX `dict_type`(`dict_type` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '字典类型表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sys_logininfor
-- ----------------------------
DROP TABLE IF EXISTS `sys_logininfor`;
CREATE TABLE `sys_logininfor`  (
  `info_id` bigint NOT NULL COMMENT '访问ID',
  `user_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '用户账号',
  `ipaddr` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '登录IP地址',
  `login_location` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '登录地点',
  `browser` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '浏览器类型',
  `os` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '操作系统',
  `status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '登录状态（0成功 1失败）',
  `msg` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '提示消息',
  `login_time` datetime NULL DEFAULT NULL COMMENT '访问时间',
  PRIMARY KEY (`info_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统访问记录' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sys_menu
-- ----------------------------
DROP TABLE IF EXISTS `sys_menu`;
CREATE TABLE `sys_menu`  (
  `menu_id` bigint NOT NULL COMMENT '菜单ID',
  `menu_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '菜单名称',
  `parent_id` bigint NULL DEFAULT 0 COMMENT '父菜单ID',
  `order_num` int NULL DEFAULT 0 COMMENT '显示顺序',
  `path` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '路由地址',
  `component` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '组件路径',
  `query_param` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '路由参数',
  `is_frame` int NULL DEFAULT 1 COMMENT '是否为外链（0是 1否）',
  `is_cache` int NULL DEFAULT 0 COMMENT '是否缓存（0缓存 1不缓存）',
  `menu_type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '菜单类型（M目录 C菜单 F按钮）',
  `visible` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '显示状态（0显示 1隐藏）',
  `status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '菜单状态（0正常 1停用）',
  `perms` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '权限标识',
  `icon` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '#' COMMENT '菜单图标',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '备注',
  PRIMARY KEY (`menu_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '菜单权限表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sys_notice
-- ----------------------------
DROP TABLE IF EXISTS `sys_notice`;
CREATE TABLE `sys_notice`  (
  `notice_id` bigint NOT NULL COMMENT '公告ID',
  `notice_title` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '公告标题',
  `notice_type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '公告类型（1通知 2公告）',
  `notice_content` longblob NULL COMMENT '公告内容',
  `status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '公告状态（0正常 1关闭）',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`notice_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '通知公告表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sys_oper_log
-- ----------------------------
DROP TABLE IF EXISTS `sys_oper_log`;
CREATE TABLE `sys_oper_log`  (
  `oper_id` bigint NOT NULL COMMENT '日志主键',
  `title` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '模块标题',
  `business_type` int NULL DEFAULT 0 COMMENT '业务类型（0其它 1新增 2修改 3删除）',
  `method` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '方法名称',
  `request_method` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '请求方式',
  `operator_type` int NULL DEFAULT 0 COMMENT '操作类别（0其它 1后台用户 2手机端用户）',
  `oper_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '操作人员',
  `dept_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '部门名称',
  `oper_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '请求URL',
  `oper_ip` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '主机地址',
  `oper_location` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '操作地点',
  `oper_param` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '请求参数',
  `json_result` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '返回参数',
  `status` int NULL DEFAULT 0 COMMENT '操作状态（0正常 1异常）',
  `error_msg` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '错误消息',
  `oper_time` datetime NULL DEFAULT NULL COMMENT '操作时间',
  PRIMARY KEY (`oper_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '操作日志记录' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sys_oss
-- ----------------------------
DROP TABLE IF EXISTS `sys_oss`;
CREATE TABLE `sys_oss`  (
  `oss_id` bigint NOT NULL COMMENT '对象存储主键',
  `file_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '文件名',
  `original_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '原名',
  `file_suffix` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '文件后缀名',
  `url` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'URL地址',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '上传人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新人',
  `service` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'minio' COMMENT '服务商',
  PRIMARY KEY (`oss_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'OSS对象存储表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sys_oss_config
-- ----------------------------
DROP TABLE IF EXISTS `sys_oss_config`;
CREATE TABLE `sys_oss_config`  (
  `oss_config_id` bigint NOT NULL COMMENT '主建',
  `config_key` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '配置key',
  `access_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT 'accessKey',
  `secret_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '秘钥',
  `bucket_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '桶名称',
  `prefix` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '前缀',
  `endpoint` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '访问站点',
  `domain` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '自定义域名',
  `is_https` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT 'N' COMMENT '是否https（Y=是,N=否）',
  `region` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '域',
  `access_policy` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '1' COMMENT '桶权限类型(0=private 1=public 2=custom)',
  `status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '1' COMMENT '状态（0=正常,1=停用）',
  `ext1` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '扩展字段',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`oss_config_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '对象存储配置表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sys_post
-- ----------------------------
DROP TABLE IF EXISTS `sys_post`;
CREATE TABLE `sys_post`  (
  `post_id` bigint NOT NULL COMMENT '岗位ID',
  `post_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '岗位编码',
  `post_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '岗位名称',
  `post_sort` int NOT NULL COMMENT '显示顺序',
  `status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '状态（0正常 1停用）',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`post_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '岗位信息表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sys_role
-- ----------------------------
DROP TABLE IF EXISTS `sys_role`;
CREATE TABLE `sys_role`  (
  `role_id` bigint NOT NULL COMMENT '角色ID',
  `role_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '角色名称',
  `role_key` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '角色权限字符串',
  `role_sort` int NOT NULL COMMENT '显示顺序',
  `data_scope` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '1' COMMENT '数据范围（1：全部数据权限 2：自定数据权限 3：本部门数据权限 4：本部门及以下数据权限）',
  `menu_check_strictly` tinyint(1) NULL DEFAULT 1 COMMENT '菜单树选择项是否关联显示',
  `dept_check_strictly` tinyint(1) NULL DEFAULT 1 COMMENT '部门树选择项是否关联显示',
  `status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '角色状态（0正常 1停用）',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '删除标志（0代表存在 2代表删除）',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`role_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '角色信息表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sys_role_dept
-- ----------------------------
DROP TABLE IF EXISTS `sys_role_dept`;
CREATE TABLE `sys_role_dept`  (
  `role_id` bigint NOT NULL COMMENT '角色ID',
  `dept_id` bigint NOT NULL COMMENT '部门ID',
  PRIMARY KEY (`role_id`, `dept_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '角色和部门关联表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sys_role_menu
-- ----------------------------
DROP TABLE IF EXISTS `sys_role_menu`;
CREATE TABLE `sys_role_menu`  (
  `role_id` bigint NOT NULL COMMENT '角色ID',
  `menu_id` bigint NOT NULL COMMENT '菜单ID',
  PRIMARY KEY (`role_id`, `menu_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '角色和菜单关联表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sys_user
-- ----------------------------
DROP TABLE IF EXISTS `sys_user`;
CREATE TABLE `sys_user`  (
  `user_id` bigint NOT NULL COMMENT '用户ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `user_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户账号',
  `nick_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户昵称',
  `user_type` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT 'sys_user' COMMENT '用户类型（sys_user系统用户）',
  `email` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '用户邮箱',
  `phonenumber` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '手机号码',
  `sex` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '用户性别（0男 1女 2未知）',
  `avatar` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '头像地址',
  `password` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '密码',
  `status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '帐号状态（0正常 1停用）',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '删除标志（0代表存在 2代表删除）',
  `login_ip` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '最后登录IP',
  `login_date` datetime NULL DEFAULT NULL COMMENT '最后登录时间',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`user_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户信息表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sys_user_post
-- ----------------------------
DROP TABLE IF EXISTS `sys_user_post`;
CREATE TABLE `sys_user_post`  (
  `user_id` bigint NOT NULL COMMENT '用户ID',
  `post_id` bigint NOT NULL COMMENT '岗位ID',
  PRIMARY KEY (`user_id`, `post_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户与岗位关联表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sys_user_role
-- ----------------------------
DROP TABLE IF EXISTS `sys_user_role`;
CREATE TABLE `sys_user_role`  (
  `user_id` bigint NOT NULL COMMENT '用户ID',
  `role_id` bigint NOT NULL COMMENT '角色ID',
  PRIMARY KEY (`user_id`, `role_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户和角色关联表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wf_category
-- ----------------------------
DROP TABLE IF EXISTS `wf_category`;
CREATE TABLE `wf_category`  (
  `category_id` bigint NOT NULL AUTO_INCREMENT COMMENT '流程分类id',
  `category_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '流程分类名称',
  `code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '分类编码',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '删除标志（0代表存在 2代表删除）',
  PRIMARY KEY (`category_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1958701110085033987 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '流程分类表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wf_copy
-- ----------------------------
DROP TABLE IF EXISTS `wf_copy`;
CREATE TABLE `wf_copy`  (
  `copy_id` bigint NOT NULL AUTO_INCREMENT COMMENT '抄送主键',
  `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '抄送标题',
  `process_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '流程主键',
  `process_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '流程名称',
  `category_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '流程分类主键',
  `deployment_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '部署主键',
  `instance_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '流程实例主键',
  `task_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '任务主键',
  `user_id` bigint NULL DEFAULT NULL COMMENT '用户主键',
  `originator_id` bigint NULL DEFAULT NULL COMMENT '发起人主键',
  `originator_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '发起人名称',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '删除标志（0代表存在 2代表删除）',
  PRIMARY KEY (`copy_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1958722386258305027 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '流程抄送表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wf_deploy_form
-- ----------------------------
DROP TABLE IF EXISTS `wf_deploy_form`;
CREATE TABLE `wf_deploy_form`  (
  `deploy_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '流程实例主键',
  `form_key` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '表单Key',
  `node_key` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '节点Key',
  `form_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '表单名称',
  `node_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '节点名称',
  `content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '表单内容',
  PRIMARY KEY (`deploy_id`, `form_key`, `node_key`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '流程实例关联表单' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wf_form
-- ----------------------------
DROP TABLE IF EXISTS `wf_form`;
CREATE TABLE `wf_form`  (
  `form_id` bigint NOT NULL AUTO_INCREMENT COMMENT '表单主键',
  `form_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '表单名称',
  `content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '表单内容',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '删除标志（0代表存在 2代表删除）',
  PRIMARY KEY (`form_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1958790461590708227 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '流程表单信息表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_account
-- ----------------------------
DROP TABLE IF EXISTS `wms_account`;
CREATE TABLE `wms_account`  (
  `account_id` bigint NOT NULL AUTO_INCREMENT COMMENT '科目ID（主键）',
  `account_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '科目编码',
  `account_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '科目名称',
  `account_type` enum('资产','负债','权益','收入','费用') CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '科目类型',
  `parent_id` bigint NULL DEFAULT NULL COMMENT '上级科目ID',
  `balance` decimal(15, 2) NOT NULL DEFAULT 0.00 COMMENT '当前余额（可容忍暂时不准确，过账汇总）',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  PRIMARY KEY (`account_id`) USING BTREE,
  UNIQUE INDEX `uk_wa_code`(`account_code` ASC) USING BTREE,
  INDEX `idx_wa_parent`(`parent_id` ASC) USING BTREE,
  CONSTRAINT `fk_wa_parent` FOREIGN KEY (`parent_id`) REFERENCES `wms_account` (`account_id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE = InnoDB AUTO_INCREMENT = 1955546179856822274 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '会计科目表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_actual_warehouse
-- ----------------------------
DROP TABLE IF EXISTS `wms_actual_warehouse`;
CREATE TABLE `wms_actual_warehouse`  (
  `actual_warehouse_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `parent_id` bigint UNSIGNED NULL DEFAULT 0 COMMENT '父节点ID（指向同表 warehouse_id）',
  `actual_warehouse_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '实际库区/库位编码',
  `actual_warehouse_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '实际库区/库位名称',
  `actual_warehouse_type` tinyint NOT NULL DEFAULT 0 COMMENT '类型：0=仓库，1=库区，2=库位，…',
  `sort_no` int NULL DEFAULT NULL COMMENT '同级排序号',
  `is_enabled` tinyint(1) NOT NULL DEFAULT 1 COMMENT '是否启用（0=否，1=是）',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `split_status` tinyint NOT NULL DEFAULT 0 COMMENT '拆分状态：0=未拆分（大库位），1=已拆分（小库位）',
  `split_type` tinyint NULL DEFAULT 0 COMMENT '拆分类型（仅当split_status=1时有效）：0=（1列拆2小库位）1=(1列拆3小库位)',
  PRIMARY KEY (`actual_warehouse_id`) USING BTREE,
  INDEX `idx_actual_wh_parent`(`parent_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2033746503029067894 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '实际库区/库位自关联表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_anneal_operate_event
-- ----------------------------
DROP TABLE IF EXISTS `wms_anneal_operate_event`;
CREATE TABLE `wms_anneal_operate_event`  (
  `event_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `anneal_furnace_id` bigint NOT NULL COMMENT '退火炉ID',
  `operate_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '操作类型 如:START/PAUSE/STOP/FEED/TAKE/RESET',
  `operate_content` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '操作内容描述',
  `coil_id` bigint NULL DEFAULT NULL COMMENT '钢卷ID(可选)',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常,1=已删除）',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  PRIMARY KEY (`event_id`) USING BTREE,
  INDEX `idx_anneal_furnace`(`anneal_furnace_id` ASC) USING BTREE,
  INDEX `idx_coil_id`(`coil_id` ASC) USING BTREE,
  INDEX `idx_operate_type`(`operate_type` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2047514104082722819 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '退火操作事件表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_approval
-- ----------------------------
DROP TABLE IF EXISTS `wms_approval`;
CREATE TABLE `wms_approval`  (
  `approval_id` bigint NOT NULL AUTO_INCREMENT COMMENT '审批记录主键ID',
  `apply_type` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '申请类型（leave=请假，out=外出）',
  `apply_id` bigint NOT NULL COMMENT '关联的申请ID（请假ID/外出ID）',
  `approver_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '审批人姓名',
  `approval_status` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '审批状态（待审批/已同意/已驳回/已撤销）',
  `approval_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT 'single' COMMENT '审批类型(single=单人审批,multi=多级审批)',
  `required_approvers` int NULL DEFAULT 0 COMMENT '需要审批的人数',
  `current_approvers` int NULL DEFAULT 0 COMMENT '已审批的人数',
  `final_status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT 'pending' COMMENT '最终状态(pending=审批中,all_approved=全部通过,rejected=已驳回)',
  `approval_opinion` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '审批意见',
  `approval_time` datetime NULL DEFAULT NULL COMMENT '审批时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '逻辑删除标识：0=正常，1=已删',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`approval_id`) USING BTREE,
  INDEX `idx_approval_apply_type_apply_id`(`apply_type` ASC, `apply_id` ASC) USING BTREE,
  INDEX `idx_approval_approver_name`(`approver_name` ASC) USING BTREE,
  INDEX `idx_approval_approval_status`(`approval_status` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2041725584244154371 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '通用审批表（支持请假/外出等申请的审批）' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_approval_task
-- ----------------------------
DROP TABLE IF EXISTS `wms_approval_task`;
CREATE TABLE `wms_approval_task`  (
  `task_id` bigint NOT NULL AUTO_INCREMENT COMMENT '审批任务ID',
  `approval_id` bigint NOT NULL COMMENT '审批主表ID',
  `approver_id` bigint NULL DEFAULT NULL COMMENT '审批人ID',
  `approver_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '审批人姓名',
  `task_status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT 'pending' COMMENT '任务状态(pending=待审批,approved=已同意,rejected=已驳回)',
  `approval_opinion` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '审批意见',
  `approval_time` datetime NULL DEFAULT NULL COMMENT '审批时间',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  PRIMARY KEY (`task_id`) USING BTREE,
  INDEX `idx_approval_id`(`approval_id` ASC) USING BTREE,
  INDEX `idx_approver_id`(`approver_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2041725584755859459 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '审批任务表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_batch
-- ----------------------------
DROP TABLE IF EXISTS `wms_batch`;
CREATE TABLE `wms_batch`  (
  `batch_id` bigint NOT NULL AUTO_INCREMENT COMMENT '批次ID',
  `batch_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '批次编号',
  `process_id` bigint NOT NULL COMMENT '关联工艺ID（合并的工艺）',
  `total_quantity` int NOT NULL COMMENT '批次总数量（合并的任务总量）',
  `merge_source` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '合并来源（记录被合并的工艺任务ID，用逗号分隔）',
  `estimated_start_time` datetime NULL DEFAULT NULL COMMENT '预计开始时间',
  `estimated_end_time` datetime NULL DEFAULT NULL COMMENT '预计结束时间',
  `batch_status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT 'created' COMMENT '批次状态：created-已创建/scheduled-已排产/executing-执行中/finished-已完成',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `plan_id` bigint NULL DEFAULT NULL COMMENT '排产计划ID',
  PRIMARY KEY (`batch_id`) USING BTREE,
  UNIQUE INDEX `batch_no`(`batch_no` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1956285268721086466 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '批次表（合并相同工艺的任务）' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_bom
-- ----------------------------
DROP TABLE IF EXISTS `wms_bom`;
CREATE TABLE `wms_bom`  (
  `bom_id` bigint NOT NULL AUTO_INCREMENT COMMENT 'BOM 主键ID',
  `bom_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'BOM 编码（可选）',
  `bom_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'BOM 名称（可选）',
  `is_enabled` tinyint(1) NOT NULL DEFAULT 1 COMMENT '是否启用（0=否，1=是）',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=删除）',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`bom_id`) USING BTREE,
  UNIQUE INDEX `uk_bom_code`(`bom_code` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2047528929630351363 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'BOM 表头，关联产品或原材料' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_bom_item
-- ----------------------------
DROP TABLE IF EXISTS `wms_bom_item`;
CREATE TABLE `wms_bom_item`  (
  `item_id` bigint NOT NULL AUTO_INCREMENT COMMENT 'BOM 明细ID',
  `bom_id` bigint NOT NULL COMMENT '关联 wms_bom.bom_id',
  `attr_key` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '属性名称',
  `attr_value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '属性值',
  `is_enabled` tinyint(1) NOT NULL DEFAULT 1 COMMENT '是否启用（0=否，1=是）',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=删除）',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`item_id`) USING BTREE,
  INDEX `idx_item_bom`(`bom_id` ASC) USING BTREE,
  INDEX `idx_item_attr`(`attr_key` ASC) USING BTREE,
  CONSTRAINT `fk_item_bom` FOREIGN KEY (`bom_id`) REFERENCES `wms_bom` (`bom_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 2047528930318217219 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'BOM 明细表，存放属性–值' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_calendar
-- ----------------------------
DROP TABLE IF EXISTS `wms_calendar`;
CREATE TABLE `wms_calendar`  (
  `calendar_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `calendar_date` date NOT NULL COMMENT '日期',
  `calendar_type` tinyint NOT NULL DEFAULT 1 COMMENT '日历类型：1工作日 2周末 3法定假日 4停机日',
  `factory_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'DEFAULT' COMMENT '工厂编码',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  PRIMARY KEY (`calendar_id`) USING BTREE,
  UNIQUE INDEX `uk_calendar_date_factory`(`calendar_date` ASC, `factory_code` ASC) USING BTREE,
  INDEX `idx_calendar_type`(`calendar_type` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 366 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '工厂日历' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_calendar_shift
-- ----------------------------
DROP TABLE IF EXISTS `wms_calendar_shift`;
CREATE TABLE `wms_calendar_shift`  (
  `config_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `calendar_date` date NOT NULL COMMENT '日期',
  `line_id` bigint NOT NULL COMMENT '产线ID',
  `shift_id` bigint NOT NULL COMMENT '班次ID',
  `planned_hours` decimal(8, 2) NOT NULL DEFAULT 8.00 COMMENT '计划工时',
  `status` tinyint NOT NULL DEFAULT 1 COMMENT '状态：1可排产 2停机',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `del_flag` int NULL DEFAULT 0 COMMENT '删除标志2删除',
  PRIMARY KEY (`config_id`) USING BTREE,
  UNIQUE INDEX `uk_calendar_shift`(`calendar_date` ASC, `line_id` ASC, `shift_id` ASC) USING BTREE,
  INDEX `idx_cs_line_date`(`line_id` ASC, `calendar_date` ASC) USING BTREE,
  INDEX `idx_cs_shift`(`shift_id` ASC) USING BTREE,
  CONSTRAINT `fk_cs_line` FOREIGN KEY (`line_id`) REFERENCES `wms_production_line` (`line_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `fk_cs_shift` FOREIGN KEY (`shift_id`) REFERENCES `wms_shift_template` (`shift_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 2191 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '日历班次配置' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_camera_management
-- ----------------------------
DROP TABLE IF EXISTS `wms_camera_management`;
CREATE TABLE `wms_camera_management`  (
  `camera_id` bigint NOT NULL AUTO_INCREMENT COMMENT '自增主键',
  `camera_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '摄像头编号（系统生成，如 camef8bd40d71795）',
  `camera_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '摄像头名称（如：仓库东门摄像头）',
  `rtsp_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'RTSP 推流地址（摄像头原生地址）',
  `ws_fmp4` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'ws - fmp4 播放地址',
  `http_fmp4` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'http - fmp4 播放地址',
  `rtsp_addr` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'rtsp 播放地址',
  `hls_addr` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'hls 播放地址',
  `location` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '安装位置（如：仓库 A 区货架 3）',
  `group_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '所属分组/区域（直接存储名称，如：仓库 A 区）',
  `warehouse_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '所属仓库（如：一号仓库）',
  `status` tinyint NULL DEFAULT 0 COMMENT '状态：0-未启用 1-正常 2-离线 3-故障',
  `username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '摄像头访问用户名',
  `password` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '摄像头访问密码',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT 'system' COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `del_flag` int NOT NULL DEFAULT 0 COMMENT '删除标志',
  `remark` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '无' COMMENT '备注',
  PRIMARY KEY (`camera_id`) USING BTREE,
  UNIQUE INDEX `camera_code`(`camera_code` ASC) USING BTREE,
  INDEX `idx_warehouse_group`(`warehouse_name` ASC, `group_name` ASC) USING BTREE,
  INDEX `idx_status`(`status` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1953723053939109891 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '摄像头管理表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_category
-- ----------------------------
DROP TABLE IF EXISTS `wms_category`;
CREATE TABLE `wms_category`  (
  `category_id` bigint NOT NULL AUTO_INCREMENT COMMENT '分类主键ID',
  `category_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '分类类型(base_material|surface_treatment|customer_req|spec_packaging)',
  `category_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '分类编码',
  `category_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '分类名称',
  `category_desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '分类描述',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `is_enabled` tinyint(1) NOT NULL DEFAULT 1 COMMENT '是否启用(0=否,1=是)',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志(0=正常,1=已删除)',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  PRIMARY KEY (`category_id`) USING BTREE,
  UNIQUE INDEX `uk_wms_cat_type_code`(`category_type` ASC, `category_code` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1953443038163619842 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '通用分类表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_check_item
-- ----------------------------
DROP TABLE IF EXISTS `wms_check_item`;
CREATE TABLE `wms_check_item`  (
  `item_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `item_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '检查项名称',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '逻辑删除标识：0=正常，1=已删',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `target_upper` decimal(10, 2) NULL DEFAULT NULL COMMENT '目标上限',
  `target_lower` decimal(10, 2) NULL DEFAULT NULL COMMENT '目标下限',
  `standard_target` decimal(10, 2) NULL DEFAULT NULL COMMENT '标准目标',
  `unit` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '单位',
  `qualitative_quantitative` tinyint(1) NULL DEFAULT NULL COMMENT '定性定量：0=定性，1=定量',
  PRIMARY KEY (`item_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1979012136688246791 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '检查项表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_check_task
-- ----------------------------
DROP TABLE IF EXISTS `wms_check_task`;
CREATE TABLE `wms_check_task`  (
  `task_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `task_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '任务名称',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '逻辑删除标识：0=正常，1=已删',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `verify_target` json NULL COMMENT '校验目标',
  `workshop_section` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '工段',
  `process` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '工序',
  `unit_group` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '机组',
  `inspection_result` tinyint(1) NULL DEFAULT NULL COMMENT '检验结果：0=未检验，1=合格，2=不合格',
  `inspection_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '检验类型',
  PRIMARY KEY (`task_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2018512053005541378 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '检查任务表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_check_task_coil_relation
-- ----------------------------
DROP TABLE IF EXISTS `wms_check_task_coil_relation`;
CREATE TABLE `wms_check_task_coil_relation`  (
  `relation_id` bigint NOT NULL AUTO_INCREMENT COMMENT '关联表主键',
  `task_id` bigint NOT NULL COMMENT '检查任务ID，关联wms_check_task.task_id',
  `coil_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '钢卷ID',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '逻辑删除标识：0=正常，1=已删',
  PRIMARY KEY (`relation_id`) USING BTREE,
  INDEX `idx_check_task_coil_relation_task_id`(`task_id` ASC) USING BTREE,
  INDEX `idx_check_task_coil_relation_coil_id`(`coil_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2018512054775537666 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '检查任务与钢卷关联表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_check_task_item
-- ----------------------------
DROP TABLE IF EXISTS `wms_check_task_item`;
CREATE TABLE `wms_check_task_item`  (
  `item_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `check_task_id` bigint NOT NULL COMMENT '检查任务ID',
  `check_item_id` bigint NOT NULL COMMENT '检查项ID',
  `status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '状态：0=未检测，1=通过，2=不通过',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '逻辑删除标识：0=正常，1=已删',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `target_upper` decimal(10, 2) NULL DEFAULT NULL COMMENT '目标上限',
  `target_lower` decimal(10, 2) NULL DEFAULT NULL COMMENT '目标下限',
  `standard_target` decimal(10, 2) NULL DEFAULT NULL COMMENT '标准目标',
  `unit` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '单位',
  `qualitative_quantitative` tinyint(1) NULL DEFAULT NULL COMMENT '定性定量：0=定性，1=定量',
  `actual_measure` decimal(10, 2) NULL DEFAULT NULL COMMENT '实测值',
  PRIMARY KEY (`item_id`) USING BTREE,
  INDEX `idx_task`(`check_task_id` ASC) USING BTREE,
  INDEX `idx_item`(`check_item_id` ASC) USING BTREE,
  CONSTRAINT `fk_item` FOREIGN KEY (`check_item_id`) REFERENCES `wms_check_item` (`item_id`) ON DELETE RESTRICT ON UPDATE CASCADE,
  CONSTRAINT `fk_task` FOREIGN KEY (`check_task_id`) REFERENCES `wms_check_task` (`task_id`) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE = InnoDB AUTO_INCREMENT = 2018512054435799043 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '检查任务与检查项关联表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_coil_abnormal
-- ----------------------------
DROP TABLE IF EXISTS `wms_coil_abnormal`;
CREATE TABLE `wms_coil_abnormal`  (
  `abnormal_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `coil_id` bigint NOT NULL COMMENT '钢卷ID',
  `production_line` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产线名称',
  `position` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '位置（上下，操作侧，中间，驱动侧）',
  `length` decimal(10, 2) NULL DEFAULT NULL COMMENT '缺陷长度',
  `start_position` decimal(10, 2) NULL DEFAULT NULL COMMENT '缺陷开始位置',
  `end_position` decimal(10, 2) NULL DEFAULT NULL COMMENT '缺陷结束位置',
  `defect_code` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '缺陷代码（S=表面缺陷、E=边部问题、M=尺寸问题、G=收卷问题）',
  `defect_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '缺陷类型（更详细的缺陷分类，如划痕、边裂、厚度超标等）',
  `defect_rate` decimal(8, 4) NULL DEFAULT NULL COMMENT '缺陷率（百分比，如0.05表示5%）',
  `defect_weight` decimal(10, 2) NULL DEFAULT NULL COMMENT '缺陷重量（单位：kg）',
  `degree` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '程度（轻微、重度、严重）',
  `judge_level` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '判级',
  `judge_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '判级人',
  `judge_time` datetime NULL DEFAULT NULL COMMENT '判级时间',
  `main_mark` tinyint NULL DEFAULT NULL COMMENT '主标记（1=是，0=否）',
  `whole_coil_mark` tinyint NULL DEFAULT NULL COMMENT '整卷标记（1=是，0=否）',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `plate_surface` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '上下板面',
  `source_system` tinyint NOT NULL DEFAULT 3 COMMENT '数据来源：2=二级系统同步，3=三级本地录入',
  `process_source` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '工序来源（如：粗轧、精轧、酸洗、退火等）',
  PRIMARY KEY (`abnormal_id`) USING BTREE,
  INDEX `idx_coil_id`(`coil_id` ASC) USING BTREE COMMENT '钢卷ID索引',
  INDEX `idx_judge_time`(`judge_time` ASC) USING BTREE COMMENT '判级时间索引（可选，根据查询需求添加）',
  INDEX `idx_ca_del_coil`(`del_flag` ASC, `coil_id` ASC) USING BTREE,
  INDEX `idx_production_line`(`production_line` ASC) USING BTREE COMMENT '产线名称索引'
) ENGINE = InnoDB AUTO_INCREMENT = 2047558223836352514 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '钢卷异常信息表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_coil_cache
-- ----------------------------
DROP TABLE IF EXISTS `wms_coil_cache`;
CREATE TABLE `wms_coil_cache`  (
  `cache_id` bigint NOT NULL AUTO_INCREMENT COMMENT '钢卷缓存主键ID',
  `coil_id` bigint NOT NULL COMMENT '钢卷ID',
  `coil_json` json NOT NULL COMMENT '钢卷JSON数据',
  `del_flag` tinyint NOT NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`cache_id`) USING BTREE,
  INDEX `idx_coil_id`(`coil_id` ASC) USING BTREE COMMENT '钢卷ID索引'
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '钢卷缓存表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_coil_contract_rel
-- ----------------------------
DROP TABLE IF EXISTS `wms_coil_contract_rel`;
CREATE TABLE `wms_coil_contract_rel`  (
  `rel_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `coil_id` bigint NOT NULL COMMENT '钢卷ID',
  `contract_id` bigint NOT NULL COMMENT '合同ID',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  PRIMARY KEY (`rel_id`) USING BTREE,
  INDEX `idx_coil_id`(`coil_id` ASC) USING BTREE,
  INDEX `idx_contract_id`(`contract_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '钢卷与合同关联关系表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_coil_packing_detail
-- ----------------------------
DROP TABLE IF EXISTS `wms_coil_packing_detail`;
CREATE TABLE `wms_coil_packing_detail`  (
  `detail_id` bigint NOT NULL AUTO_INCREMENT COMMENT '明细主键ID',
  `packing_id` bigint NOT NULL COMMENT '关联打包主表ID',
  `coil_id` bigint NOT NULL COMMENT '关联钢卷ID（wms_material_coil.coil_id）',
  `from_warehouse_id` bigint NOT NULL COMMENT '该钢卷打包前的库区ID',
  `to_warehouse_id` bigint NOT NULL COMMENT '该钢卷打包后的库区ID（打包待发区）',
  `coil_gross_weight` decimal(10, 3) NOT NULL COMMENT '该钢卷的毛重',
  `coil_net_weight` decimal(10, 3) NOT NULL COMMENT '该钢卷的净重',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '该钢卷的打包备注（如：库区A-钢卷1001）',
  PRIMARY KEY (`detail_id`) USING BTREE,
  INDEX `idx_detail_packing_id`(`packing_id` ASC) USING BTREE,
  INDEX `idx_detail_coil_id`(`coil_id` ASC) USING BTREE,
  INDEX `idx_detail_warehouse`(`from_warehouse_id` ASC, `to_warehouse_id` ASC) USING BTREE,
  INDEX `idx_detail_del_flag`(`del_flag` ASC) USING BTREE,
  CONSTRAINT `fk_packing_detail_coil_id` FOREIGN KEY (`coil_id`) REFERENCES `wms_material_coil` (`coil_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `fk_packing_detail_packing_id` FOREIGN KEY (`packing_id`) REFERENCES `wms_coil_packing_record` (`packing_id`) ON DELETE CASCADE ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '钢卷打包明细表（存储每个钢卷的库区/重量信息）' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_coil_packing_record
-- ----------------------------
DROP TABLE IF EXISTS `wms_coil_packing_record`;
CREATE TABLE `wms_coil_packing_record`  (
  `packing_id` bigint NOT NULL AUTO_INCREMENT COMMENT '打包记录主键ID',
  `packing_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '打包单号（自定义规则：年份后两位+月份+当日打包序号，如25100001）',
  `coil_count` int NULL DEFAULT NULL COMMENT '打包钢卷数量（累计卷数，自动计算）',
  `total_gross_weight` decimal(12, 3) NULL DEFAULT NULL COMMENT '打包总毛重（累计重量）',
  `total_net_weight` decimal(12, 3) NULL DEFAULT NULL COMMENT '打包总净重（累计重量）',
  `sale_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '销售人员姓名（冗余存储，避免关联查询）',
  `batch_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '打包批次号（如第一批/第二批，或自定义编码：251001-01）',
  `packing_status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '打包状态（0=待打包，1=已打包完成，2=已取消）',
  `packing_time` datetime NULL DEFAULT NULL COMMENT '打包完成时间',
  `packing_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '打包操作人',
  `warehouse_remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '库区操作备注（如移入打包待发区原因）',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '整体打包备注',
  PRIMARY KEY (`packing_id`) USING BTREE,
  INDEX `idx_packing_no`(`packing_no` ASC) USING BTREE,
  INDEX `idx_sale_name`(`sale_name` ASC) USING BTREE,
  INDEX `idx_batch_no`(`batch_no` ASC) USING BTREE,
  INDEX `idx_packing_status`(`packing_status` ASC) USING BTREE,
  INDEX `idx_del_flag_create`(`del_flag` ASC, `create_time` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '钢卷打包记录主表（打包待发区专用）' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_coil_pending_action
-- ----------------------------
DROP TABLE IF EXISTS `wms_coil_pending_action`;
CREATE TABLE `wms_coil_pending_action`  (
  `action_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `coil_id` bigint NOT NULL COMMENT '关联的钢卷ID',
  `current_coil_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '当前钢卷号',
  `action_type` int NOT NULL COMMENT '操作类型（1=分卷，2=合卷，3=更新）',
  `action_status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '操作状态（0=待处理，1=处理中，2=已完成，3=已取消）',
  `scan_time` datetime NULL DEFAULT NULL COMMENT '扫码时间',
  `scan_device` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '扫码设备（移动端设备信息）',
  `priority` tinyint(1) NULL DEFAULT 0 COMMENT '优先级（0=普通，1=重要，2=紧急）',
  `source_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'scan' COMMENT '来源类型（scan=扫码，manual=手动创建）',
  `warehouse_id` bigint NULL DEFAULT NULL COMMENT '所在库区ID',
  `operator_id` bigint NULL DEFAULT NULL COMMENT '操作人ID',
  `operator_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '操作人姓名',
  `process_time` datetime NULL DEFAULT NULL COMMENT '处理时间',
  `complete_time` datetime NULL DEFAULT NULL COMMENT '完成时间',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `processed_coil_ids` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '加工后钢卷ID（多个以英文逗号分隔）',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  PRIMARY KEY (`action_id`) USING BTREE,
  INDEX `idx_coil_id`(`coil_id` ASC) USING BTREE,
  INDEX `idx_action_type`(`action_type` ASC) USING BTREE,
  INDEX `idx_action_status`(`action_status` ASC) USING BTREE,
  INDEX `idx_scan_time`(`scan_time` ASC) USING BTREE,
  INDEX `idx_warehouse_id`(`warehouse_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 43126 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '钢卷待操作表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_coil_quality_rejudge
-- ----------------------------
DROP TABLE IF EXISTS `wms_coil_quality_rejudge`;
CREATE TABLE `wms_coil_quality_rejudge`  (
  `rejudge_id` bigint NOT NULL AUTO_INCREMENT COMMENT '改判记录主键ID',
  `coil_id` bigint NOT NULL COMMENT '钢卷ID',
  `before_quality` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '改判前质量状态',
  `after_quality` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '改判后质量状态',
  `rejudge_reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '改判原因',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '删除标志（0=存在 2=删除）',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '备注',
  PRIMARY KEY (`rejudge_id`) USING BTREE,
  INDEX `idx_wms_coil_quality_rejudge_coil`(`coil_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2047555388964999171 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '钢卷质量改判记录表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_coil_statistics_summary
-- ----------------------------
DROP TABLE IF EXISTS `wms_coil_statistics_summary`;
CREATE TABLE `wms_coil_statistics_summary`  (
  `summary_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `title` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '统计标题（如：2026年3月冷硬卷切边统计、2026年一季度钢卷产量统计）',
  `stat_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '统计类型（枚举：COIL_TRIM-切边统计、COIL_PRODUCTION-产量统计、COIL_STOCK-库存统计、COIL_QUALITY-质量统计等）',
  `stat_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '统计结果JSON字符串（存储透视分析结果，支持大文本）',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `attachment_info` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '附件信息（JSON格式，存储附件名称、路径、大小、类型等信息，支持多附件）',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标识 0正常 2删除',
  PRIMARY KEY (`summary_id`) USING BTREE,
  INDEX `idx_stat_type`(`stat_type` ASC) USING BTREE,
  INDEX `idx_del_flag`(`del_flag` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '钢卷生产统计汇总表（数据透视结果持久化）' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_coil_warehouse_operation_log
-- ----------------------------
DROP TABLE IF EXISTS `wms_coil_warehouse_operation_log`;
CREATE TABLE `wms_coil_warehouse_operation_log`  (
  `log_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `coil_id` bigint NOT NULL COMMENT '钢卷ID',
  `actual_warehouse_id` bigint NULL DEFAULT NULL COMMENT '实际库区ID',
  `operation_type` tinyint(1) NOT NULL DEFAULT 1 COMMENT '业务操作类型：1=收货，2=加工，3=调拨，4=发货',
  `in_out_type` tinyint(1) NOT NULL DEFAULT 1 COMMENT '出入库方向：1=入库，2=出库',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '更新人',
  PRIMARY KEY (`log_id`) USING BTREE,
  INDEX `idx_coil_id_create_time`(`coil_id` ASC, `create_time` ASC) USING BTREE,
  INDEX `idx_actual_warehouse_id_operation_type`(`actual_warehouse_id` ASC, `operation_type` ASC) USING BTREE,
  INDEX `idx_in_out_type`(`in_out_type` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2047558249727791106 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '钢卷库区操作记录表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_common_defect
-- ----------------------------
DROP TABLE IF EXISTS `wms_common_defect`;
CREATE TABLE `wms_common_defect`  (
  `defect_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `defect_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '缺陷名称',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '逻辑删除标识：0=正常，1=已删',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`defect_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1953342215010111490 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '常见缺陷表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_contract
-- ----------------------------
DROP TABLE IF EXISTS `wms_contract`;
CREATE TABLE `wms_contract`  (
  `contract_id` bigint NOT NULL AUTO_INCREMENT COMMENT '合同ID（主键）',
  `contract_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '合同编号（唯一）',
  `amount` decimal(15, 2) NOT NULL COMMENT '合同金额',
  `type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '合同类型（采购合同/销售合同/技术附件...）',
  `accessory` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '附件',
  `party_a` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '甲方',
  `party_b` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '乙方',
  `sign_date` date NULL DEFAULT NULL COMMENT '签约日期',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新人',
  PRIMARY KEY (`contract_id`) USING BTREE,
  UNIQUE INDEX `contract_no`(`contract_no` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1955138633606180867 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '合同信息表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_cost_coil_daily
-- ----------------------------
DROP TABLE IF EXISTS `wms_cost_coil_daily`;
CREATE TABLE `wms_cost_coil_daily`  (
  `cost_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `coil_id` bigint NOT NULL COMMENT '钢卷ID（关联wms_material_coil.coil_id）',
  `current_coil_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '当前钢卷号',
  `calc_date` date NOT NULL COMMENT '计算日期',
  `net_weight` decimal(10, 3) NOT NULL COMMENT '净重（吨）',
  `unit_cost` decimal(10, 2) NOT NULL COMMENT '单位成本（元/吨/天）',
  `daily_cost` decimal(12, 2) NOT NULL COMMENT '日成本（元）',
  `storage_days` int NOT NULL COMMENT '累计在库天数',
  `total_cost` decimal(12, 2) NOT NULL COMMENT '累计成本（元）',
  `warehouse_id` bigint NULL DEFAULT NULL COMMENT '所在库区ID',
  `item_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '物品类型（raw_material/product）',
  `material_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '材料类型',
  `energy_cost_amount` decimal(18, 2) NOT NULL DEFAULT 0.00 COMMENT '能源成本（元）',
  `energy_cost_breakdown` json NULL COMMENT '能源成本拆解（JSON数组，每项包含taskId/energyType/meter/cost/consumption）',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`cost_id`) USING BTREE,
  UNIQUE INDEX `uk_coil_calc_date`(`coil_id` ASC, `calc_date` ASC) USING BTREE,
  INDEX `idx_coil_id`(`coil_id` ASC) USING BTREE,
  INDEX `idx_calc_date`(`calc_date` ASC) USING BTREE,
  INDEX `idx_warehouse`(`warehouse_id` ASC) USING BTREE,
  INDEX `idx_coil_date`(`coil_id` ASC, `calc_date` ASC) USING BTREE,
  INDEX `idx_item_type`(`item_type` ASC) USING BTREE,
  INDEX `idx_material_type`(`material_type` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '钢卷日成本记录表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_cost_standard_config
-- ----------------------------
DROP TABLE IF EXISTS `wms_cost_standard_config`;
CREATE TABLE `wms_cost_standard_config`  (
  `config_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `unit_cost` decimal(10, 2) NOT NULL COMMENT '单位成本（元/吨/天）',
  `effective_date` date NOT NULL COMMENT '生效日期',
  `expire_date` date NULL DEFAULT NULL COMMENT '失效日期（NULL表示当前有效）',
  `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态（0=失效，1=有效）',
  `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标志',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注说明',
  PRIMARY KEY (`config_id`) USING BTREE,
  INDEX `idx_effective_date`(`effective_date` ASC) USING BTREE,
  INDEX `idx_status`(`status` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '成本标准配置表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_customer
-- ----------------------------
DROP TABLE IF EXISTS `wms_customer`;
CREATE TABLE `wms_customer`  (
  `customer_id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号，主键自增',
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '客户名称',
  `follow_up_status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '跟进状态',
  `contact_last_time` datetime NULL DEFAULT NULL COMMENT '最后跟进时间',
  `contact_last_content` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '最后跟进内容',
  `contact_next_time` datetime NULL DEFAULT NULL COMMENT '下次联系时间',
  `owner_user_id` bigint NULL DEFAULT NULL COMMENT '负责人的用户编号',
  `owner_time` datetime NULL DEFAULT NULL COMMENT '成为负责人的时间',
  `deal_status` tinyint NULL DEFAULT 0 COMMENT '成交状态',
  `mobile` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '手机',
  `telephone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '电话',
  `qq` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'QQ',
  `wechat` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '微信',
  `email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '邮箱',
  `area_id` bigint NULL DEFAULT NULL COMMENT '地区编号',
  `detail_address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '详细地址',
  `industry_id` int NULL DEFAULT NULL COMMENT '所属行业',
  `level` int NULL DEFAULT NULL COMMENT '客户等级',
  `source` int NULL DEFAULT NULL COMMENT '客户来源',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NOT NULL DEFAULT 0 COMMENT '是否删除',
  PRIMARY KEY (`customer_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1955164883901079554 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'CRM 客户表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_delivery_plan
-- ----------------------------
DROP TABLE IF EXISTS `wms_delivery_plan`;
CREATE TABLE `wms_delivery_plan`  (
  `plan_id` bigint NOT NULL AUTO_INCREMENT COMMENT '计划唯一ID',
  `order_id` bigint NULL DEFAULT NULL COMMENT '订单id(关联订单表)',
  `plan_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '发货计划名称（格式：YYYY-MM-DD-序号，如2025-11-25-001）',
  `plan_date` date NOT NULL COMMENT '计划日期',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `plan_type` tinyint NULL DEFAULT 0,
  `audit_status` tinyint NULL DEFAULT 0 COMMENT '审核状态（0=待审核，1=审核通过，2=审核驳回）',
  `audit_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '审核人（用户账号/ID）',
  `audit_time` datetime NULL DEFAULT NULL COMMENT '审核时间',
  `coil` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '钢卷ID（多个ID以英文逗号分隔，如：1001,1002,1003）',
  PRIMARY KEY (`plan_id`) USING BTREE,
  UNIQUE INDEX `wms_delivery_plan_pk`(`plan_name` ASC) USING BTREE,
  INDEX `idx_create_by_time`(`create_by` ASC, `create_time` ASC) USING BTREE COMMENT '按创建人+时间查询索引'
) ENGINE = InnoDB AUTO_INCREMENT = 2047477473048961027 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '发货计划表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_delivery_plan_coil_operate
-- ----------------------------
DROP TABLE IF EXISTS `wms_delivery_plan_coil_operate`;
CREATE TABLE `wms_delivery_plan_coil_operate`  (
  `operate_id` bigint NOT NULL AUTO_INCREMENT COMMENT '操作记录唯一ID',
  `plan_id` bigint NOT NULL COMMENT '关联发货计划表ID（wms_delivery_plan.plan_id）',
  `coil_id` bigint NOT NULL COMMENT '钢卷ID（单个钢卷，关联钢卷表）',
  `operate_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '操作类型',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '操作备注',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`operate_id`) USING BTREE,
  INDEX `idx_plan_coil`(`plan_id` ASC, `coil_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2001526515652440066 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '发货计划钢卷操作记录表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_delivery_plan_detail
-- ----------------------------
DROP TABLE IF EXISTS `wms_delivery_plan_detail`;
CREATE TABLE `wms_delivery_plan_detail`  (
  `detail_id` bigint NOT NULL AUTO_INCREMENT COMMENT '明细唯一ID',
  `plan_id` bigint NOT NULL COMMENT '关联发货计划表ID（wms_delivery_plan.plan_id）',
  `order_id` bigint NULL DEFAULT NULL COMMENT '订单ID',
  `order_detail` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '订单详情',
  `customer_id` bigint NULL DEFAULT NULL COMMENT '客户ID',
  `customer_detail` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '客户详情',
  `address` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '地址',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '明细备注',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  PRIMARY KEY (`detail_id`) USING BTREE,
  INDEX `idx_plan_id`(`plan_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2015993011358601218 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '发货计划明细表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_delivery_waybill
-- ----------------------------
DROP TABLE IF EXISTS `wms_delivery_waybill`;
CREATE TABLE `wms_delivery_waybill`  (
  `waybill_id` bigint NOT NULL AUTO_INCREMENT COMMENT '发货单唯一ID',
  `waybill_no` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '发货单编号（格式：WB-YYYYMMDD-XXXX，如WB-20251125-0001）',
  `waybill_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '发货单名称',
  `plan_id` bigint NOT NULL COMMENT '关联发货计划ID',
  `order_id` bigint UNSIGNED NULL DEFAULT NULL COMMENT '关联订单ID（关联crm_order.order_id）',
  `license_plate` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '车牌（支持新能源车牌）',
  `consignee_unit` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '收货单位',
  `sender_unit` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '发货单位',
  `delivery_time` datetime NULL DEFAULT NULL COMMENT '发货时间',
  `weighbridge` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '磅房',
  `sales_person` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '销售',
  `principal` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '负责人（司机/跟单员）',
  `principal_phone` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '负责人电话（手机号/固话）',
  `status` tinyint NULL DEFAULT 0 COMMENT '完成状态（0=待发货，1=已发货，2=已完成，3=取消）',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  PRIMARY KEY (`waybill_id`) USING BTREE,
  UNIQUE INDEX `uk_waybill_no`(`waybill_no` ASC) USING BTREE COMMENT '发货单编号唯一',
  INDEX `idx_plan_id`(`plan_id` ASC) USING BTREE COMMENT '关联计划查询索引',
  INDEX `idx_license_plate`(`license_plate` ASC) USING BTREE COMMENT '车牌查询索引',
  INDEX `idx_status_time`(`status` ASC, `create_time` ASC) USING BTREE COMMENT '状态+时间筛选索引',
  INDEX `idx_delivery_time`(`delivery_time` ASC) USING BTREE COMMENT '发货时间查询索引',
  INDEX `idx_sales_person`(`sales_person` ASC) USING BTREE COMMENT '销售负责人查询索引'
) ENGINE = InnoDB AUTO_INCREMENT = 2047558481744105474 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '发货单主表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_delivery_waybill_detail
-- ----------------------------
DROP TABLE IF EXISTS `wms_delivery_waybill_detail`;
CREATE TABLE `wms_delivery_waybill_detail`  (
  `detail_id` bigint NOT NULL AUTO_INCREMENT COMMENT '明细唯一ID',
  `waybill_id` bigint NOT NULL COMMENT '关联发货单主表ID',
  `coil_id` bigint NOT NULL COMMENT '关联钢卷表ID（钢卷基础信息在钢卷表中）',
  `product_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '品名（如：冷硬钢卷、冷轧钢卷）',
  `edge_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '切边（净边/毛边）',
  `packaging` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '包装（裸包/简包1/精包2等）',
  `settlement_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '结算方式（卷重/磅重）',
  `raw_material_factory` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '原料厂家',
  `coil_no` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '卷号',
  `specification` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '规格',
  `material` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '材质',
  `quantity` int NULL DEFAULT 1 COMMENT '数量（件）',
  `weight` decimal(15, 3) NULL DEFAULT 0.000 COMMENT '重量',
  `unit_price` decimal(15, 2) NULL DEFAULT NULL COMMENT '单价',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  PRIMARY KEY (`detail_id`) USING BTREE,
  INDEX `idx_waybill_id`(`waybill_id` ASC) USING BTREE COMMENT '关联发货单主表查询索引',
  INDEX `idx_coil_id`(`coil_id` ASC) USING BTREE COMMENT '关联钢卷表查询索引'
) ENGINE = InnoDB AUTO_INCREMENT = 2047553324432101379 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '发货单明细表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_dept
-- ----------------------------
DROP TABLE IF EXISTS `wms_dept`;
CREATE TABLE `wms_dept`  (
  `dept_id` bigint NOT NULL COMMENT '部门id',
  `parent_id` bigint NULL DEFAULT 0 COMMENT '父部门id（0表示顶级部门）',
  `dept_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '部门名称',
  `order_num` int NULL DEFAULT 0 COMMENT '部门显示顺序（同级排序）',
  `leader` bigint NULL DEFAULT NULL COMMENT '部门负责人',
  `status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '部门状态（0正常 1停用）',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新人',
  PRIMARY KEY (`dept_id`) USING BTREE,
  INDEX `idx_wms_dept_parent_id`(`parent_id` ASC) USING BTREE,
  INDEX `idx_wms_dept_dept_name`(`dept_name` ASC) USING BTREE,
  INDEX `idx_wms_dept_status_del_flag`(`status` ASC, `del_flag` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'WMS系统部门表（树形结构）' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_employee_change
-- ----------------------------
DROP TABLE IF EXISTS `wms_employee_change`;
CREATE TABLE `wms_employee_change`  (
  `change_id` bigint NOT NULL AUTO_INCREMENT COMMENT '异动记录主键ID',
  `info_id` bigint NOT NULL COMMENT '关联员工信息表的主键ID',
  `change_type` tinyint(1) NOT NULL COMMENT '异动类型：0=入职，1=离职，2=转正',
  `change_time` date NOT NULL COMMENT '异动时间（入职/离职/转正时间）',
  `change_reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '异动原因（离职必填，入职/转正可选）',
  `change_handler` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '负责人',
  `attachment` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '附件',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '逻辑删除标识：0=正常，1=已删',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`change_id`) USING BTREE,
  INDEX `idx_change_info_id`(`info_id` ASC) USING BTREE,
  INDEX `idx_change_type`(`change_type` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2047111284992942083 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '员工异动表（入职/离职/转正）' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_employee_info
-- ----------------------------
DROP TABLE IF EXISTS `wms_employee_info`;
CREATE TABLE `wms_employee_info`  (
  `info_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `serial_number` int NULL DEFAULT NULL COMMENT '序号',
  `dept` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '部门',
  `job_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '岗位工种',
  `name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '姓名',
  `id_card` varchar(18) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '身份证号',
  `age` tinyint NULL DEFAULT NULL COMMENT '年龄',
  `gender` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '性别（男/女）',
  `education` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '学历',
  `home_address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '家庭住址',
  `phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '联系电话',
  `entry_time` date NULL DEFAULT NULL COMMENT '入职时间',
  `emergency_contact` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '紧急联系人',
  `relationship` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '关系',
  `emergency_contact_phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '紧急联系人电话',
  `social_insurance_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '社保类型（三险/五险）',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '逻辑删除标识：0=正常，1=已删',
  `is_leave` tinyint(1) NULL DEFAULT 0 COMMENT '是否离职：0=未离职（在职），1=已离职',
  `leave_time` date NULL DEFAULT NULL COMMENT '离职时间',
  `is_regular` tinyint(1) NULL DEFAULT 0 COMMENT '是否转正：0=未转正，1=已转正',
  `regular_time` date NULL DEFAULT NULL COMMENT '转正时间',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `is_spicy_eater` tinyint(1) NULL DEFAULT 0 COMMENT '是否吃辣：0=否，1=是',
  PRIMARY KEY (`info_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2047111284850335746 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '员工信息表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_employee_transfer
-- ----------------------------
DROP TABLE IF EXISTS `wms_employee_transfer`;
CREATE TABLE `wms_employee_transfer`  (
  `transfer_id` bigint NOT NULL AUTO_INCREMENT COMMENT '转岗记录主键ID',
  `info_id` bigint NOT NULL COMMENT '关联员工信息表的主键ID',
  `old_dept` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '原部门',
  `old_job_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '原岗位工种',
  `new_dept` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '新部门',
  `new_job_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '新岗位工种',
  `transfer_time` date NOT NULL COMMENT '转岗生效时间',
  `transfer_reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '转岗原因',
  `transfer_handler` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '转岗经办人',
  `approval_status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '审批状态：0=待审批，1=已审批，2=已驳回',
  `attachment` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '附件（如转岗审批单等）',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '逻辑删除标识：0=正常，1=已删',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`transfer_id`) USING BTREE,
  INDEX `idx_transfer_info_id`(`info_id` ASC) USING BTREE,
  INDEX `idx_transfer_time`(`transfer_time` ASC) USING BTREE,
  INDEX `idx_transfer_dept_job`(`old_dept` ASC, `old_job_type` ASC, `new_dept` ASC, `new_job_type` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '员工转岗记录表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_energy_allocation_task
-- ----------------------------
DROP TABLE IF EXISTS `wms_energy_allocation_task`;
CREATE TABLE `wms_energy_allocation_task`  (
  `task_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `task_date` date NOT NULL COMMENT '任务对应日期（统计所属日）',
  `energy_type_id` bigint NOT NULL COMMENT '能源类型',
  `allocation_scope` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'warehouse' COMMENT '分摊维度：warehouse/actualWarehouse/bizLine',
  `status` tinyint NOT NULL DEFAULT 0 COMMENT '任务状态：0=待处理 1=处理中 2=成功 3=失败',
  `execute_mode` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'auto' COMMENT '触发方式：auto=定时任务 manual=手动重算',
  `time_from` datetime NOT NULL COMMENT '能耗统计开始时间',
  `time_to` datetime NOT NULL COMMENT '能耗统计结束时间',
  `total_consumption` decimal(18, 6) NULL DEFAULT NULL COMMENT '汇总能耗值（统一换算为基础单位）',
  `total_cost` decimal(18, 2) NULL DEFAULT NULL COMMENT '汇总能源费用（元）',
  `message` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '失败或警告信息',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`task_id`) USING BTREE,
  UNIQUE INDEX `uk_task_date_type_scope`(`task_date` ASC, `energy_type_id` ASC, `allocation_scope` ASC) USING BTREE,
  INDEX `idx_status`(`status` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '能源分摊任务表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_energy_area_link
-- ----------------------------
DROP TABLE IF EXISTS `wms_energy_area_link`;
CREATE TABLE `wms_energy_area_link`  (
  `link_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `energy_type_id` bigint NOT NULL COMMENT 'EMS能源类型ID，关联ems_energy_type.energy_type_id',
  `meter_id` bigint NULL DEFAULT NULL COMMENT 'EMS计量设备ID，关联ems_meter.meter_id',
  `location_id` bigint NULL DEFAULT NULL COMMENT 'EMS区域ID，关联ems_location.location_id',
  `warehouse_id` bigint NOT NULL COMMENT '逻辑库区ID，必须绑定 wms_warehouse.warehouse_id',
  `actual_warehouse_id` bigint NULL DEFAULT NULL COMMENT '实际库区ID，关联wms_actual_warehouse.actual_warehouse_id',
  `is_enabled` tinyint NOT NULL DEFAULT 1 COMMENT '是否启用 1=是 0=否',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`link_id`) USING BTREE,
  UNIQUE INDEX `uk_meter_warehouse`(`meter_id` ASC, `warehouse_id` ASC, `actual_warehouse_id` ASC) USING BTREE,
  INDEX `idx_energy_type`(`energy_type_id` ASC) USING BTREE,
  INDEX `idx_location`(`location_id` ASC) USING BTREE,
  INDEX `idx_warehouse`(`warehouse_id` ASC) USING BTREE,
  INDEX `idx_actual_warehouse`(`actual_warehouse_id` ASC) USING BTREE,
  CONSTRAINT `fk_energy_link_warehouse` FOREIGN KEY (`warehouse_id`) REFERENCES `wms_warehouse` (`warehouse_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1996759245223108634 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'EMS能源与库区映射关系表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_energy_coil_daily
-- ----------------------------
DROP TABLE IF EXISTS `wms_energy_coil_daily`;
CREATE TABLE `wms_energy_coil_daily`  (
  `energy_cost_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `task_id` bigint NOT NULL COMMENT '关联能源分摊任务ID',
  `calc_date` date NOT NULL COMMENT '归属日期',
  `coil_id` bigint NOT NULL COMMENT '钢卷ID',
  `enter_coil_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '入场钢卷号',
  `current_coil_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '当前钢卷号',
  `warehouse_id` bigint NULL DEFAULT NULL COMMENT '逻辑库区ID',
  `actual_warehouse_id` bigint NULL DEFAULT NULL COMMENT '实际库区ID',
  `energy_type_id` bigint NOT NULL COMMENT '能源类型',
  `meter_id` bigint NULL DEFAULT NULL COMMENT '计量设备ID',
  `consumption_qty` decimal(18, 6) NOT NULL COMMENT '按分摊结果得到的能耗量（基础单位）',
  `cost_amount` decimal(18, 2) NOT NULL COMMENT '对应能耗费用（元）',
  `allocation_basis_weight` decimal(18, 6) NOT NULL COMMENT '分摊基数-重量（吨）',
  `allocation_basis_days` decimal(10, 4) NOT NULL COMMENT '分摊基数-在库天数',
  `allocation_factor` decimal(20, 10) NOT NULL COMMENT '分摊系数（该卷基数/同区段合计）',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`energy_cost_id`) USING BTREE,
  UNIQUE INDEX `uk_task_coil`(`task_id` ASC, `coil_id` ASC) USING BTREE,
  INDEX `idx_calc_date`(`calc_date` ASC) USING BTREE,
  INDEX `idx_warehouse`(`warehouse_id` ASC) USING BTREE,
  INDEX `idx_actual_warehouse`(`actual_warehouse_id` ASC) USING BTREE,
  INDEX `idx_energy_type`(`energy_type_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '钢卷日能源成本分摊结果表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_express
-- ----------------------------
DROP TABLE IF EXISTS `wms_express`;
CREATE TABLE `wms_express`  (
  `express_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `express_code` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '物流编号',
  `status` int NULL DEFAULT 0 COMMENT '数据状态0未确认1进行中2已完成',
  `supply_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '供应商姓名',
  `supply_phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '供应商联系方式',
  `owner_id` bigint NULL DEFAULT NULL COMMENT '负责人id',
  `owner_phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '负责人手机号（快递手机号）',
  `plan_date` datetime NULL DEFAULT NULL COMMENT '计划到货时间',
  `express_type` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '物流公司标识',
  `last_update_time` datetime NULL DEFAULT NULL COMMENT '上次请求时间',
  `last_status` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '最后一次查询状态',
  `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标志',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`express_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1954858111651667971 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_express_question
-- ----------------------------
DROP TABLE IF EXISTS `wms_express_question`;
CREATE TABLE `wms_express_question`  (
  `question_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `express_id` bigint NULL DEFAULT NULL COMMENT '关联快递',
  `description` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '问题描述',
  `report_time` datetime NULL DEFAULT NULL COMMENT '汇报时间',
  `report_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '汇报人',
  `status` int NULL DEFAULT NULL COMMENT '0未解决1已解决',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新人',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标志',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`question_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_financial_document
-- ----------------------------
DROP TABLE IF EXISTS `wms_financial_document`;
CREATE TABLE `wms_financial_document`  (
  `document_id` bigint NOT NULL AUTO_INCREMENT COMMENT '单据ID（主键）',
  `doc_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '单据编号',
  `doc_type` enum('收款单','付款单','转账单','调账单') CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '单据类型',
  `doc_date` date NOT NULL COMMENT '单据日期',
  `amount` decimal(15, 2) NOT NULL COMMENT '单据金额',
  `related_order_id` bigint NULL DEFAULT NULL COMMENT '关联订单ID',
  `status` enum('草稿','已提交','已审核','已过账') CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '草稿' COMMENT '单据状态',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  PRIMARY KEY (`document_id`) USING BTREE,
  UNIQUE INDEX `uk_wfd_doc_no`(`doc_no` ASC) USING BTREE,
  INDEX `idx_wfd_doc_date`(`doc_date` ASC) USING BTREE,
  INDEX `idx_wfd_status`(`status` ASC) USING BTREE,
  INDEX `idx_wfd_related_order_id`(`related_order_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1955559888281001987 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '财务单据表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_furnace
-- ----------------------------
DROP TABLE IF EXISTS `wms_furnace`;
CREATE TABLE `wms_furnace`  (
  `furnace_id` bigint NOT NULL AUTO_INCREMENT,
  `furnace_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '炉编号',
  `furnace_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '名称',
  `busy_flag` tinyint NULL DEFAULT 0 COMMENT '是否忙碌(0否1是)',
  `status` tinyint NULL DEFAULT 1 COMMENT '状态(0停用1启用)',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标记(0正常 1删除)',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`furnace_id`) USING BTREE,
  UNIQUE INDEX `uk_wms_furnace_code`(`furnace_code` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2046468444705222658 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '退火炉信息表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_furnace_plan
-- ----------------------------
DROP TABLE IF EXISTS `wms_furnace_plan`;
CREATE TABLE `wms_furnace_plan`  (
  `plan_id` bigint NOT NULL AUTO_INCREMENT,
  `plan_no` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '计划号',
  `plan_start_time` datetime NULL DEFAULT NULL COMMENT '计划开始时间',
  `actual_start_time` datetime NULL DEFAULT NULL COMMENT '实际开始时间',
  `end_time` datetime NULL DEFAULT NULL COMMENT '结束时间',
  `target_furnace_id` bigint NOT NULL COMMENT '目标炉子ID',
  `status` tinyint NULL DEFAULT 0 COMMENT '计划状态(0未开始 1进行中 2已完成)',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标记(0正常 1删除)',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`plan_id`) USING BTREE,
  INDEX `idx_wms_furnace_plan_furnace`(`target_furnace_id` ASC) USING BTREE,
  INDEX `idx_wms_furnace_plan_status`(`status` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2047054285546627075 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '退火计划表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_furnace_plan_coil
-- ----------------------------
DROP TABLE IF EXISTS `wms_furnace_plan_coil`;
CREATE TABLE `wms_furnace_plan_coil`  (
  `plan_coil_id` bigint NOT NULL AUTO_INCREMENT,
  `plan_id` bigint NOT NULL COMMENT '计划ID',
  `coil_id` bigint NOT NULL COMMENT '钢卷ID',
  `logic_warehouse_id` bigint NULL DEFAULT NULL COMMENT '逻辑库区去向（钢卷退火后目标逻辑库区）',
  `furnace_level` tinyint(1) NULL DEFAULT NULL COMMENT '炉火层级（1=一层，2=二层，3=三层）',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标记(0正常 1删除)',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`plan_coil_id`) USING BTREE,
  UNIQUE INDEX `uk_wms_furnace_plan_coil`(`plan_id` ASC, `coil_id` ASC) USING BTREE,
  INDEX `idx_wms_furnace_plan_coil_plan`(`plan_id` ASC) USING BTREE,
  INDEX `idx_wms_furnace_plan_coil_coil`(`coil_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2047054643882795010 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '退火计划钢卷关系表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_generate_record
-- ----------------------------
DROP TABLE IF EXISTS `wms_generate_record`;
CREATE TABLE `wms_generate_record`  (
  `record_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `qrcode_type` tinyint NOT NULL DEFAULT 0 COMMENT '二维码类型（字典，默认为0）',
  `content` json NOT NULL COMMENT '二维码内容（JSON格式）',
  `is_enabled` tinyint NOT NULL DEFAULT 0 COMMENT '是否启用（0：启用，1：禁用）',
  `serial_number` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '编号',
  `size` int NULL DEFAULT 200 COMMENT '二维码尺寸（像素）',
  `status` tinyint NULL DEFAULT 0 COMMENT '状态(0,1,2)',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  PRIMARY KEY (`record_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2047557666325270531 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '二维码生成记录表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_inspection_item_template
-- ----------------------------
DROP TABLE IF EXISTS `wms_inspection_item_template`;
CREATE TABLE `wms_inspection_item_template`  (
  `template_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `template_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '模板名称',
  `template_desc` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '模板描述',
  `inspection_item` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '待检项（可存储单个待检项或待检项编码，多个可拆分或用JSON）',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '逻辑删除标识：0=正常，1=已删',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`template_id`) USING BTREE,
  INDEX `idx_template_name`(`template_name`(50) ASC) USING BTREE,
  INDEX `idx_inspection_item`(`inspection_item`(100) ASC) USING BTREE,
  INDEX `idx_del_flag`(`del_flag` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1997131130729193475 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '待检项模板表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_journal
-- ----------------------------
DROP TABLE IF EXISTS `wms_journal`;
CREATE TABLE `wms_journal`  (
  `journal_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `journal_date` date NOT NULL COMMENT '日期',
  `summary` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '摘要',
  `trans_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '收支类型',
  `counterpart` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '对方户名',
  `income_amount` decimal(18, 2) NULL DEFAULT 0.00 COMMENT '收入金额',
  `expense_amount` decimal(18, 2) NULL DEFAULT 0.00 COMMENT '支出金额',
  `balance_amount` decimal(18, 2) NULL DEFAULT 0.00 COMMENT '余额',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '修改人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标志（0正常 1删除）',
  PRIMARY KEY (`journal_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1955563037595033603 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '资金日记账表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_journal_entry
-- ----------------------------
DROP TABLE IF EXISTS `wms_journal_entry`;
CREATE TABLE `wms_journal_entry`  (
  `entry_id` bigint NOT NULL AUTO_INCREMENT COMMENT '分录ID（主键）',
  `voucher_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '凭证编号',
  `line_no` int NOT NULL DEFAULT 1 COMMENT '分录行号（同一凭证内序号）',
  `entry_date` date NOT NULL COMMENT '记账日期',
  `account_id` bigint NOT NULL COMMENT '科目ID',
  `debit_amount` decimal(15, 2) NOT NULL DEFAULT 0.00 COMMENT '借方金额（可为0或负数用于调账/红冲）',
  `credit_amount` decimal(15, 2) NOT NULL DEFAULT 0.00 COMMENT '贷方金额（可为0或负数用于调账/红冲）',
  `document_id` bigint NULL DEFAULT NULL COMMENT '参考单据Id',
  `related_order_id` bigint NULL DEFAULT NULL COMMENT '关联订单ID',
  `status` enum('草稿','已过账','已冲销') CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '草稿' COMMENT '状态',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  PRIMARY KEY (`entry_id`) USING BTREE,
  INDEX `idx_wje_voucher_date`(`voucher_no` ASC, `entry_date` ASC) USING BTREE,
  INDEX `idx_wje_account_date`(`account_id` ASC, `entry_date` ASC) USING BTREE,
  INDEX `idx_wje_status`(`status` ASC) USING BTREE,
  INDEX `uk_wje_voucher_line`(`voucher_no` ASC, `line_no` ASC) USING BTREE,
  CONSTRAINT `fk_wje_account` FOREIGN KEY (`account_id`) REFERENCES `wms_account` (`account_id`) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE = InnoDB AUTO_INCREMENT = 1955559889128251395 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '凭证表（宽松版）' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_leave_request
-- ----------------------------
DROP TABLE IF EXISTS `wms_leave_request`;
CREATE TABLE `wms_leave_request`  (
  `leave_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `leave_title` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '请假标题',
  `leave_type` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '请假类型（年假/事假/病假/调休/外出/出差等）',
  `applicant_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '请假人姓名',
  `applicant_dept_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '请假人部门名称',
  `start_time` datetime NOT NULL COMMENT '请假开始时间',
  `end_time` datetime NOT NULL COMMENT '请假结束时间',
  `leave_shift` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '请假班次（早班/中班/晚班/夜班/全天等）',
  `leave_days` decimal(5, 2) NOT NULL COMMENT '请假天数',
  `leave_reason` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '请假原因',
  `attachment_urls` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '附件（病假证明等）',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '逻辑删除标识：0=正常，1=已删',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`leave_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2041725583933775874 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '员工请假申请表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_line_capability
-- ----------------------------
DROP TABLE IF EXISTS `wms_line_capability`;
CREATE TABLE `wms_line_capability`  (
  `capability_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `line_id` bigint NOT NULL COMMENT '产线ID',
  `product_id` bigint NULL DEFAULT NULL COMMENT '产品ID，可空（按工序维度时可空）',
  `process_id` bigint NULL DEFAULT NULL COMMENT '工序ID，可空（按产品维度时可空）',
  `capacity_per_hour` decimal(18, 4) NOT NULL COMMENT '每小时产能',
  `setup_minutes` int NOT NULL DEFAULT 0 COMMENT '换型准备时间(分钟)',
  `priority` int NOT NULL DEFAULT 100 COMMENT '优先级（越小越优先）',
  `is_enabled` tinyint NOT NULL DEFAULT 1 COMMENT '是否启用：0否 1是',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `del_flag` int NULL DEFAULT 0 COMMENT '删除标志2删除',
  PRIMARY KEY (`capability_id`) USING BTREE,
  UNIQUE INDEX `uk_line_prod_proc`(`line_id` ASC, `product_id` ASC, `process_id` ASC) USING BTREE,
  INDEX `idx_lc_line`(`line_id` ASC) USING BTREE,
  INDEX `idx_lc_product`(`product_id` ASC) USING BTREE,
  INDEX `idx_lc_process`(`process_id` ASC) USING BTREE,
  CONSTRAINT `fk_lc_line` FOREIGN KEY (`line_id`) REFERENCES `wms_production_line` (`line_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `fk_lc_process` FOREIGN KEY (`process_id`) REFERENCES `wms_processe` (`process_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `fk_lc_product` FOREIGN KEY (`product_id`) REFERENCES `wms_product` (`product_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '产线能力（产品/工序可生产关系）' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_manufacturing_spec
-- ----------------------------
DROP TABLE IF EXISTS `wms_manufacturing_spec`;
CREATE TABLE `wms_manufacturing_spec`  (
  `spec_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `spec_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '制造规范编码',
  `spec_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '制造规范名称',
  `business_unit` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '所属事业部',
  `project_team` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '所属项目组',
  `product_module` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产品型号/模组',
  `identifier` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '标识',
  `material` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '材质',
  `specification` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '规格/尺寸',
  `process_route` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '工艺路线',
  `process_params` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '工艺参数',
  `scope` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '适用范围',
  `inspection_standard` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '检验标准',
  `status` int NULL DEFAULT 1 COMMENT '状态（字典：1=启用，2=未启用，3=作废）',
  `spec_type` int NULL DEFAULT 1 COMMENT '规范类型（字典：1=普通规范，2=新试规范，3=临时规范）',
  `version` decimal(4, 1) NULL DEFAULT 1.0 COMMENT '版本号',
  `version_date` date NULL DEFAULT NULL COMMENT '版本日期',
  `standard_hours` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '理论工时(h)',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` int NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=删除）',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`spec_id`) USING BTREE,
  UNIQUE INDEX `uq_spec_code`(`spec_code` ASC, `version` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1960145395077926915 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '制造规范表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_material_coil
-- ----------------------------
DROP TABLE IF EXISTS `wms_material_coil`;
CREATE TABLE `wms_material_coil`  (
  `coil_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `parent_coil_id` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '父钢卷ID',
  `enter_coil_no` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '入场钢卷号（年份后两位+月份+当月第几个，如25100001、25102422）',
  `current_coil_no` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '当前钢卷号（入场钢卷号和当前钢卷号可能不同）',
  `supplier_coil_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '厂家原料卷号',
  `data_type` tinyint(1) NOT NULL DEFAULT 1 COMMENT '数据类型（0=历史，1=现存）',
  `warehouse_id` bigint NULL DEFAULT NULL COMMENT '所在库区ID',
  `next_warehouse_id` bigint NULL DEFAULT NULL COMMENT '下一库区ID',
  `actual_warehouse_id` bigint NULL DEFAULT NULL COMMENT '所在实际库区ID（关联wms_actual_warehouse表）',
  `qrcode_record_id` bigint NULL DEFAULT NULL COMMENT '关联二维码ID（wms_generate_record.record_id）',
  `team` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '班组',
  `has_merge_split` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否合卷/分卷（0=否，1=分卷，2=合卷）',
  `parent_coil_nos` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '父卷号（合卷或分卷时用，逗号分隔）',
  `item_id` bigint NOT NULL COMMENT '物品ID（指向原材料或产品主键）',
  `item_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '物品类型（raw_material/product）',
  `material_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '材料类型(废品，成品，原料)',
  `quality_status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '质量状态（0=正常，1=待检，2=不合格）',
  `status` tinyint(1) NULL DEFAULT 0 COMMENT '状态（0=在库，1=已出库）',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `export_time` datetime NULL DEFAULT NULL COMMENT '发货时间',
  `export_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '发货人',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `gross_weight` decimal(10, 3) NULL DEFAULT NULL COMMENT '毛重',
  `net_weight` decimal(10, 3) NULL DEFAULT NULL COMMENT '毛重',
  `length` decimal(10, 3) NULL DEFAULT NULL COMMENT '钢卷长度（单位：米）',
  `trimming_requirement` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '切边要求',
  `packing_status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '原料材质',
  `packaging_requirement` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '包装要求',
  `sale_id` bigint NULL DEFAULT NULL COMMENT '销售id',
  `sale_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '销售人员姓名',
  `temper_grade` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '调制度（如T1、T2、T3、FH等）',
  `business_purpose` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '业务用途（如：生产领用、销售发货、样品送检、内部调拨等）',
  `is_related_to_order` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否与订单相关（0=否，1=是）',
  `coating_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '镀层种类（GI/GA/GL/ZAM/无镀层等）',
  `exclusive_status` int NULL DEFAULT 0 COMMENT '独占状态（0=未独占，1=特殊分卷中，2退火中）',
  `actual_length` decimal(10, 3) NULL DEFAULT NULL COMMENT '实测长度',
  `actual_width` decimal(10, 3) NULL DEFAULT NULL COMMENT '实测宽度',
  `actual_thickness` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '实测厚度（单位：毫米）',
  `production_start_time` datetime NULL DEFAULT NULL COMMENT '生产开始时间',
  `production_end_time` datetime NULL DEFAULT NULL COMMENT '生产结束时间',
  `production_duration` decimal(8, 2) NULL DEFAULT NULL COMMENT '生产耗时（单位：分钟）',
  `reserved_width` decimal(10, 3) NULL DEFAULT NULL COMMENT '预留宽度（单位：毫米）',
  `coil_surface_treatment` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '钢卷表面处理',
  `transfer_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '调拨类型',
  PRIMARY KEY (`coil_id`) USING BTREE,
  INDEX `fk_coil_next_warehouse`(`next_warehouse_id` ASC) USING BTREE,
  INDEX `fk_coil_qrcode`(`qrcode_record_id` ASC) USING BTREE,
  INDEX `idx_coil_current_no`(`current_coil_no` ASC) USING BTREE,
  INDEX `idx_coil_type`(`data_type` ASC) USING BTREE,
  INDEX `idx_coil_warehouse`(`warehouse_id` ASC) USING BTREE,
  INDEX `idx_mc_core`(`del_flag` ASC, `data_type` ASC, `status` ASC, `material_type` ASC, `actual_warehouse_id` ASC, `item_type` ASC, `item_id` ASC) USING BTREE,
  INDEX `idx_mc_enter_coil_no`(`enter_coil_no` ASC) USING BTREE,
  INDEX `idx_mc_fixed_group`(`del_flag` ASC, `data_type` ASC, `status` ASC, `item_type` ASC, `actual_warehouse_id` ASC, `item_id` ASC) USING BTREE,
  INDEX `idx_mc_del_item`(`del_flag` ASC, `item_type` ASC, `item_id` ASC) USING BTREE,
  INDEX `idx_mc_del_status_sale`(`del_flag` ASC, `status` ASC, `sale_id` ASC) USING BTREE,
  INDEX `idx_mc_del_wh`(`del_flag` ASC, `warehouse_id` ASC) USING BTREE,
  INDEX `idx_mc_del_awh`(`del_flag` ASC, `actual_warehouse_id` ASC) USING BTREE,
  INDEX `idx_mc_del_update`(`del_flag` ASC, `update_time` ASC) USING BTREE,
  INDEX `idx_mc_del_create`(`del_flag` ASC, `create_time` ASC) USING BTREE,
  INDEX `idx_mc_team`(`team` ASC) USING BTREE,
  INDEX `idx_mc_data_type`(`data_type` ASC) USING BTREE,
  INDEX `idx_mc_has_merge_split`(`has_merge_split` ASC) USING BTREE,
  INDEX `idx_mc_coil_id`(`coil_id` ASC) USING BTREE,
  CONSTRAINT `fk_coil_next_warehouse` FOREIGN KEY (`next_warehouse_id`) REFERENCES `wms_warehouse` (`warehouse_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `fk_coil_qrcode` FOREIGN KEY (`qrcode_record_id`) REFERENCES `wms_generate_record` (`record_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 2047557666526597123 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '钢卷物料表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_meal_report
-- ----------------------------
DROP TABLE IF EXISTS `wms_meal_report`;
CREATE TABLE `wms_meal_report`  (
  `report_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `report_date` date NOT NULL COMMENT '用餐日期',
  `meal_type` tinyint NOT NULL COMMENT '餐别：1早餐 2午餐 3晚餐 4夜宵',
  `dept_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '部门名称',
  `total_people` int NOT NULL COMMENT '用餐总人数',
  `dine_in_people` int NOT NULL COMMENT '堂食人数',
  `dine_in_people_list` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '堂食人名单',
  `takeout_people` int NOT NULL COMMENT '打包人数',
  `takeout_people_list` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '打包人名单',
  `report_user_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '报餐人姓名',
  `status` tinyint NOT NULL DEFAULT 1 COMMENT '状态：1已提交 2已修改 3已作废',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '逻辑删除标识：0=正常，1=已删',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`report_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2047477082278240258 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '部门报餐主表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_order
-- ----------------------------
DROP TABLE IF EXISTS `wms_order`;
CREATE TABLE `wms_order`  (
  `order_id` bigint NOT NULL AUTO_INCREMENT COMMENT '订单ID',
  `order_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '订单编号',
  `customer_id` bigint NULL DEFAULT NULL COMMENT '客户ID',
  `customer_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '客户名称',
  `sales_manager` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '销售经理',
  `order_status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '订单状态（0=新建，1=生产中，2=已完成，3=已取消）',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `tax_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '含税金额',
  `no_tax_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '无税金额',
  PRIMARY KEY (`order_id`) USING BTREE,
  UNIQUE INDEX `uk_order_code`(`order_code` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1960620329289330690 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '订单主表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_order_detail
-- ----------------------------
DROP TABLE IF EXISTS `wms_order_detail`;
CREATE TABLE `wms_order_detail`  (
  `detail_id` bigint NOT NULL AUTO_INCREMENT COMMENT '明细ID',
  `order_id` bigint NOT NULL COMMENT '订单ID',
  `product_id` bigint NOT NULL COMMENT '产品ID',
  `quantity` decimal(18, 0) NOT NULL COMMENT '产品数量',
  `unit` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '单位',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `tax_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '含税单价',
  `no_tax_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '无税单价',
  `group_id` bigint NULL DEFAULT NULL COMMENT '产品规范组ID',
  PRIMARY KEY (`detail_id`) USING BTREE,
  INDEX `idx_order_detail_order`(`order_id` ASC) USING BTREE,
  INDEX `fk_order_detail_product`(`product_id` ASC) USING BTREE,
  CONSTRAINT `fk_order_detail_order` FOREIGN KEY (`order_id`) REFERENCES `wms_order` (`order_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1960236891496038403 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '订单明细表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_order_profit
-- ----------------------------
DROP TABLE IF EXISTS `wms_order_profit`;
CREATE TABLE `wms_order_profit`  (
  `profit_id` bigint NOT NULL AUTO_INCREMENT COMMENT '盈亏ID（主键）',
  `order_id` bigint NOT NULL COMMENT '订单ID',
  `cost_amount` decimal(15, 2) NOT NULL COMMENT '成本金额',
  `revenue_amount` decimal(15, 2) NOT NULL COMMENT '收入金额',
  `profit_amount` decimal(15, 2) GENERATED ALWAYS AS ((`revenue_amount` - `cost_amount`)) VIRTUAL COMMENT '利润金额' NULL,
  `profit_rate` decimal(5, 2) GENERATED ALWAYS AS (if((`revenue_amount` <> 0),(((`revenue_amount` - `cost_amount`) / `revenue_amount`) * 100),0)) VIRTUAL COMMENT '利润率(%)' NULL,
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  PRIMARY KEY (`profit_id`) USING BTREE,
  INDEX `idx_wop_order_id`(`order_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '订单盈亏表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_other_income
-- ----------------------------
DROP TABLE IF EXISTS `wms_other_income`;
CREATE TABLE `wms_other_income`  (
  `other_income_id` bigint NOT NULL AUTO_INCREMENT COMMENT '其他收入ID（主键）',
  `income_date` date NOT NULL COMMENT '日期',
  `income_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '类型',
  `amount` decimal(15, 2) NOT NULL COMMENT '金额',
  `source` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '来源',
  `type` int NULL DEFAULT 0 COMMENT '收支类型(0=收入,1=值出)',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新人',
  PRIMARY KEY (`other_income_id`) USING BTREE,
  INDEX `idx_oi_income_date`(`income_date` ASC) USING BTREE,
  INDEX `idx_oi_income_type`(`income_type` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1971467204918308866 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '其他收支表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_out_request
-- ----------------------------
DROP TABLE IF EXISTS `wms_out_request`;
CREATE TABLE `wms_out_request`  (
  `out_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `out_type` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '外出类型（办公/办事/访客/其他）',
  `applicant_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '外出人姓名',
  `applicant_dept_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '外出人部门名称',
  `start_time` datetime NOT NULL COMMENT '外出开始时间',
  `end_time` datetime NOT NULL COMMENT '外出结束时间',
  `out_hours` decimal(5, 2) NOT NULL COMMENT '外出时长（小时）',
  `out_place` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '外出地点',
  `out_reason` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '外出原因',
  `attachment_urls` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '附件（相关证明等）',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '逻辑删除标识：0=正常，1=已删',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`out_id`) USING BTREE,
  INDEX `idx_out_request_applicant_name`(`applicant_name` ASC) USING BTREE,
  INDEX `idx_out_request_start_time`(`start_time` ASC) USING BTREE,
  INDEX `idx_out_request_out_type`(`out_type` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2028653305034297347 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '员工外出申请表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_payable
-- ----------------------------
DROP TABLE IF EXISTS `wms_payable`;
CREATE TABLE `wms_payable`  (
  `payable_id` bigint NOT NULL AUTO_INCREMENT COMMENT '应付ID（主键）',
  `supplier_id` bigint NOT NULL COMMENT '供应商ID',
  `order_id` bigint NOT NULL COMMENT '订单ID',
  `due_date` date NOT NULL COMMENT '到期日',
  `amount` decimal(15, 2) NOT NULL COMMENT '应付金额（可为负数用于调整）',
  `paid_amount` decimal(15, 2) NOT NULL DEFAULT 0.00 COMMENT '已付金额（可为负数用于冲销）',
  `balance_amount` decimal(15, 2) GENERATED ALWAYS AS ((`amount` - `paid_amount`)) VIRTUAL COMMENT '未付金额' NULL,
  `status` enum('未结清','部分支付','已结清') CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '未结清' COMMENT '状态',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  PRIMARY KEY (`payable_id`) USING BTREE,
  INDEX `idx_wp_supplier`(`supplier_id` ASC) USING BTREE,
  INDEX `idx_wp_order`(`order_id` ASC) USING BTREE,
  INDEX `idx_wp_due_status`(`due_date` ASC, `status` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1955477950484545538 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '应付款管理表（宽松版）' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_process_plan
-- ----------------------------
DROP TABLE IF EXISTS `wms_process_plan`;
CREATE TABLE `wms_process_plan`  (
  `plan_id` bigint NOT NULL COMMENT '主键',
  `version_id` bigint NOT NULL COMMENT '规程版本ID',
  `segment_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '段类型(INLET/PROCESS/OUTLET)',
  `segment_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '段名称',
  `point_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '点位名称',
  `point_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '点位编码',
  `sort_order` int NOT NULL DEFAULT 0 COMMENT '排序',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NOT NULL DEFAULT 0 COMMENT '删除标志(0正常2删除)',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`plan_id`) USING BTREE,
  UNIQUE INDEX `uk_plan_version_point_code`(`version_id` ASC, `point_code` ASC) USING BTREE,
  INDEX `idx_plan_version`(`version_id` ASC) USING BTREE,
  INDEX `idx_plan_sort`(`version_id` ASC, `sort_order` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '方案点位表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_process_plan_param
-- ----------------------------
DROP TABLE IF EXISTS `wms_process_plan_param`;
CREATE TABLE `wms_process_plan_param`  (
  `param_id` bigint NOT NULL COMMENT '主键',
  `plan_id` bigint NOT NULL COMMENT '方案点位ID',
  `param_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '参数编码',
  `param_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '参数名称',
  `target_value` decimal(24, 6) NULL DEFAULT NULL COMMENT '设定值',
  `lower_limit` decimal(24, 6) NULL DEFAULT NULL COMMENT '下限',
  `upper_limit` decimal(24, 6) NULL DEFAULT NULL COMMENT '上限',
  `unit` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '单位',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NOT NULL DEFAULT 0 COMMENT '删除标志(0正常2删除)',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`param_id`) USING BTREE,
  UNIQUE INDEX `uk_plan_param_code`(`plan_id` ASC, `param_code` ASC) USING BTREE,
  INDEX `idx_plan_param_plan`(`plan_id` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '方案参数表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_process_spec
-- ----------------------------
DROP TABLE IF EXISTS `wms_process_spec`;
CREATE TABLE `wms_process_spec`  (
  `spec_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `spec_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '规程编号',
  `spec_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '规程名称',
  `spec_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'PROCESS' COMMENT '类型(PROCESS=工艺规程,STANDARD=标准)',
  `line_id` bigint NOT NULL COMMENT '产线ID',
  `product_type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产品类型',
  `is_enabled` tinyint NOT NULL DEFAULT 1 COMMENT '是否启用(0否1是)',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NOT NULL DEFAULT 0 COMMENT '删除标志(0正常2删除，与全局逻辑删除配置一致)',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`spec_id`) USING BTREE,
  UNIQUE INDEX `uk_wms_process_spec_code`(`spec_code` ASC) USING BTREE,
  INDEX `idx_wms_process_spec_line`(`line_id` ASC) USING BTREE,
  INDEX `idx_wms_process_spec_type`(`spec_type` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '规程主表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_process_spec_version
-- ----------------------------
DROP TABLE IF EXISTS `wms_process_spec_version`;
CREATE TABLE `wms_process_spec_version`  (
  `version_id` bigint NOT NULL COMMENT '主键',
  `spec_id` bigint NOT NULL COMMENT '规程主表ID',
  `version_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '版本号',
  `is_active` tinyint NOT NULL DEFAULT 0 COMMENT '是否当前生效(0否1是)',
  `status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'DRAFT' COMMENT '状态(DRAFT草稿/PUBLISHED已发布/OBSOLETE作废等)',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` tinyint NOT NULL DEFAULT 0 COMMENT '删除标志(0正常2删除)',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`version_id`) USING BTREE,
  UNIQUE INDEX `uk_spec_version_code`(`spec_id` ASC, `version_code` ASC) USING BTREE,
  INDEX `idx_spec_version_spec`(`spec_id` ASC) USING BTREE,
  INDEX `idx_spec_version_active`(`spec_id` ASC, `is_active` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '规程版本表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_process_task
-- ----------------------------
DROP TABLE IF EXISTS `wms_process_task`;
CREATE TABLE `wms_process_task`  (
  `task_id` bigint NOT NULL AUTO_INCREMENT COMMENT '工艺任务ID',
  `plan_id` bigint NOT NULL COMMENT '关联生产计划ID',
  `process_id` bigint NOT NULL COMMENT '所需工艺ID',
  `product_id` bigint NOT NULL COMMENT '对应产品ID',
  `task_quantity` int NOT NULL COMMENT '任务数量',
  `task_status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT 'pending' COMMENT '任务状态：pending-待处理/processing-处理中/completed-已完成',
  `sequence` int NOT NULL COMMENT '工艺顺序',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  PRIMARY KEY (`task_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1955907289298587651 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '工艺任务表（生产计划所需工艺任务）' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_processe
-- ----------------------------
DROP TABLE IF EXISTS `wms_processe`;
CREATE TABLE `wms_processe`  (
  `process_id` bigint NOT NULL AUTO_INCREMENT COMMENT '工艺ID',
  `process_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '工艺编码',
  `process_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '工艺名称',
  `output_product_id` int NULL DEFAULT NULL COMMENT '产出产品（关联产品表，可选）',
  `process_desc` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '工艺描述',
  `standard_time` decimal(10, 2) NULL DEFAULT NULL COMMENT '标准工时（小时）',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  PRIMARY KEY (`process_id`) USING BTREE,
  UNIQUE INDEX `process_code`(`process_code` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1955895750285971458 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '工艺表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_product
-- ----------------------------
DROP TABLE IF EXISTS `wms_product`;
CREATE TABLE `wms_product`  (
  `product_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `product_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产品编号',
  `product_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '产品名称',
  `owner` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '负责人',
  `base_material_id` bigint NULL DEFAULT NULL COMMENT '基础材质分类ID',
  `surface_treatment_id` bigint NULL DEFAULT NULL COMMENT '表面处理分类ID',
  `customer_req_id` bigint NULL DEFAULT NULL COMMENT '客户需求分类ID',
  `packaging_id` bigint NULL DEFAULT NULL COMMENT '包装分类ID',
  `thickness` decimal(10, 2) NULL DEFAULT NULL COMMENT '厚度（mm）',
  `width` decimal(10, 2) NULL DEFAULT NULL COMMENT '宽度（mm）',
  `inner_diameter` decimal(10, 2) NULL DEFAULT NULL COMMENT '内径（mm）',
  `unit` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '卷' COMMENT '单位',
  `specification` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '规格',
  `is_enabled` tinyint(1) NULL DEFAULT 1 COMMENT '是否启用（0=否，1=是）',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `bom_id` bigint NULL DEFAULT NULL COMMENT 'BOM 表头ID',
  `type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产品类型（product=产品，semi=半成品，raw=原料）',
  `material` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '材质',
  `manufacturer` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '厂家',
  `surface_treatment_desc` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '表面处理详情',
  `zinc_layer` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '锌层厚度',
  PRIMARY KEY (`product_id`) USING BTREE,
  INDEX `idx_prod_base_mat`(`base_material_id` ASC) USING BTREE,
  INDEX `idx_prod_surf_treat`(`surface_treatment_id` ASC) USING BTREE,
  INDEX `idx_prod_cust_req`(`customer_req_id` ASC) USING BTREE,
  INDEX `idx_prod_packaging`(`packaging_id` ASC) USING BTREE,
  INDEX `idx_prod_bom`(`bom_id` ASC) USING BTREE,
  INDEX `idx_prod_material`(`material` ASC) USING BTREE,
  INDEX `idx_prod_manufacturer`(`manufacturer` ASC) USING BTREE,
  INDEX `idx_prod_surface`(`surface_treatment_desc` ASC) USING BTREE,
  INDEX `idx_prod_zinc`(`zinc_layer` ASC) USING BTREE,
  FULLTEXT INDEX `idx_prod_ft_name`(`product_name`),
  FULLTEXT INDEX `idx_prod_ft_specs`(`specification`),
  CONSTRAINT `fk_prod_base_mat` FOREIGN KEY (`base_material_id`) REFERENCES `wms_category` (`category_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `fk_prod_bom` FOREIGN KEY (`bom_id`) REFERENCES `wms_bom` (`bom_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `fk_prod_cust_req` FOREIGN KEY (`customer_req_id`) REFERENCES `wms_category` (`category_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `fk_prod_packaging` FOREIGN KEY (`packaging_id`) REFERENCES `wms_category` (`category_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `fk_prod_surf_treat` FOREIGN KEY (`surface_treatment_id`) REFERENCES `wms_category` (`category_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 2047528929777152003 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '产品表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_product_processe
-- ----------------------------
DROP TABLE IF EXISTS `wms_product_processe`;
CREATE TABLE `wms_product_processe`  (
  `pp_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `product_id` bigint NOT NULL COMMENT '产品ID（关联产品表）',
  `process_id` bigint NOT NULL COMMENT '工艺ID（关联工艺表）',
  `process_sequence` int NOT NULL COMMENT '工艺顺序（同一产品的工艺执行顺序）',
  `is_required` tinyint NULL DEFAULT 1 COMMENT '是否必选工艺：1-是/0-否',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  PRIMARY KEY (`pp_id`) USING BTREE,
  UNIQUE INDEX `uk_product_process`(`product_id` ASC, `process_id` ASC) USING BTREE COMMENT '同一产品的同一工艺不重复'
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '产品生产工艺表（预定义产品所需工艺）' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_product_sales_script
-- ----------------------------
DROP TABLE IF EXISTS `wms_product_sales_script`;
CREATE TABLE `wms_product_sales_script`  (
  `script_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `product_id` bigint NOT NULL COMMENT '关联产品ID',
  `script_title` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '话术标题/场景',
  `script_content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '话术内容',
  `feature_point` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产品特性/亮点',
  `is_enabled` tinyint(1) NOT NULL DEFAULT 1 COMMENT '是否启用（0=否，1=是）',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  PRIMARY KEY (`script_id`) USING BTREE,
  INDEX `idx_script_product`(`product_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1948314469833207811 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '产品销售话术表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_product_spec
-- ----------------------------
DROP TABLE IF EXISTS `wms_product_spec`;
CREATE TABLE `wms_product_spec`  (
  `spec_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `group_id` bigint NOT NULL COMMENT '所属产品规范组ID',
  `spec_key` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '规范键',
  `spec_value` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '规范值',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` int NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=删除）',
  PRIMARY KEY (`spec_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1960229418756259843 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '产品规范表（键值对模式）' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_product_spec_group
-- ----------------------------
DROP TABLE IF EXISTS `wms_product_spec_group`;
CREATE TABLE `wms_product_spec_group`  (
  `group_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `group_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '产品规范组编码',
  `product_id` bigint NOT NULL COMMENT '绑定的产品ID',
  `group_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产品规范组名称',
  `status` int NULL DEFAULT 1 COMMENT '状态（字典：1=启用，2=停用）',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` int NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=删除）',
  PRIMARY KEY (`group_id`) USING BTREE,
  UNIQUE INDEX `uq_group_code`(`group_code` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1960229274291847170 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '产品规范组表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_production_line
-- ----------------------------
DROP TABLE IF EXISTS `wms_production_line`;
CREATE TABLE `wms_production_line`  (
  `line_id` bigint NOT NULL AUTO_INCREMENT COMMENT '产线ID',
  `line_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '产线编号',
  `line_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '产线名称',
  `capacity` decimal(18, 4) NOT NULL COMMENT '日产能（单位同产品）',
  `unit` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产能单位',
  `is_enabled` tinyint(1) NOT NULL DEFAULT 1 COMMENT '是否启用（0=否，1=是）',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `del_flag` int NULL DEFAULT 0 COMMENT '删除标志2删除',
  PRIMARY KEY (`line_id`) USING BTREE,
  UNIQUE INDEX `uk_line_code`(`line_code` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1953348374098071554 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '产线表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_production_task
-- ----------------------------
DROP TABLE IF EXISTS `wms_production_task`;
CREATE TABLE `wms_production_task`  (
  `task_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `product_spec_group_id` bigint NOT NULL COMMENT '产品规范组ID',
  `manufacturing_spec_id` bigint NOT NULL COMMENT '制造规范ID',
  `order_id` bigint NULL DEFAULT NULL COMMENT '订单ID',
  `order_item_id` bigint NULL DEFAULT NULL COMMENT '订单明细ID',
  `plan_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '计划名称',
  `plan_code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '计划编号',
  `status` int NULL DEFAULT 0 COMMENT '状态（字典：0=未开始，1=进行中，2=完成，3=暂停，4=取消）',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` int NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=删除）',
  PRIMARY KEY (`task_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1960239799453138947 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '生产任务表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_raw_material
-- ----------------------------
DROP TABLE IF EXISTS `wms_raw_material`;
CREATE TABLE `wms_raw_material`  (
  `raw_material_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `raw_material_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '原材料编号',
  `raw_material_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '原材料名称',
  `steel_grade` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '钢种/牌号（如SPHC、SPHE、S350GD等）',
  `target_cold_grade` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '目标冷轧牌号（如SPCC、DC06、SGCC等）',
  `base_material_id` bigint NULL DEFAULT NULL COMMENT '基础材质分类ID',
  `surface_treatment_id` bigint NULL DEFAULT NULL COMMENT '表面处理分类ID',
  `unit` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '单位',
  `thickness` decimal(10, 2) NULL DEFAULT NULL COMMENT '厚度（mm）',
  `thickness_deviation` decimal(10, 2) NULL DEFAULT NULL COMMENT '厚度偏差（mm）',
  `width` decimal(10, 2) NULL DEFAULT NULL COMMENT '宽度（mm）',
  `target_cold_width` decimal(10, 2) NULL DEFAULT NULL COMMENT '目标冷轧宽度（mm）',
  `target_cold_thickness` decimal(10, 2) NULL DEFAULT NULL COMMENT '目标冷轧厚度（mm）',
  `crown` decimal(10, 2) NULL DEFAULT NULL COMMENT '凸度（mm）',
  `coil_weight` decimal(10, 2) NULL DEFAULT NULL COMMENT '卷重（kg）',
  `surface_quality` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '表面质量',
  `hardness_hv5` decimal(10, 2) NULL DEFAULT NULL COMMENT '硬度（HV5）',
  `hardness_diff` decimal(10, 2) NULL DEFAULT NULL COMMENT '硬度差值（HV5差值≤15为合格）',
  `composition_mn` decimal(5, 3) NULL DEFAULT NULL COMMENT '锰含量Mn（%）',
  `composition_p` decimal(5, 3) NULL DEFAULT NULL COMMENT '磷含量P（%）',
  `grain_size` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '晶粒级别（如ASTM 6-8级，仅电工钢）',
  `head_tail_cut_flag` tinyint(1) NULL DEFAULT NULL COMMENT '头尾切除标记（0=否，1=是，汽车板专用）',
  `inspection_result` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '检测结论（如合格/条纹/微裂纹/成分偏析等）',
  `specification` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '规格',
  `is_enabled` tinyint(1) NOT NULL DEFAULT 1 COMMENT '是否启用（0=否，1=是）',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `bom_id` bigint NULL DEFAULT NULL COMMENT 'BOM 表头ID',
  `material` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '材质',
  `manufacturer` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '厂家',
  `surface_treatment_desc` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '表面处理详情',
  `zinc_layer` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '锌层厚度',
  PRIMARY KEY (`raw_material_id`) USING BTREE,
  INDEX `idx_raw_base_mat`(`base_material_id` ASC) USING BTREE,
  INDEX `idx_raw_surf_treat`(`surface_treatment_id` ASC) USING BTREE,
  INDEX `idx_raw_bom`(`bom_id` ASC) USING BTREE,
  INDEX `idx_material_material`(`material` ASC) USING BTREE,
  INDEX `idx_material_manufacturer`(`manufacturer` ASC) USING BTREE,
  INDEX `idx_rm_material`(`material` ASC) USING BTREE,
  INDEX `idx_rm_manufacturer`(`manufacturer` ASC) USING BTREE,
  INDEX `idx_rm_surface`(`surface_treatment_desc` ASC) USING BTREE,
  INDEX `idx_rm_zinc`(`zinc_layer` ASC) USING BTREE,
  FULLTEXT INDEX `idx_rm_ft_name`(`raw_material_name`),
  FULLTEXT INDEX `idx_rm_ft_specs`(`specification`)
) ENGINE = InnoDB AUTO_INCREMENT = 2047469344819159043 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '原材料表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_receivable
-- ----------------------------
DROP TABLE IF EXISTS `wms_receivable`;
CREATE TABLE `wms_receivable`  (
  `receivable_id` bigint NOT NULL AUTO_INCREMENT COMMENT '应收ID（主键）',
  `customer_id` bigint NOT NULL COMMENT '客户ID',
  `order_id` bigint NOT NULL COMMENT '订单ID',
  `due_date` date NOT NULL COMMENT '到期日',
  `amount` decimal(15, 2) NOT NULL COMMENT '应收金额（可为负数用于调整）',
  `paid_amount` decimal(15, 2) NOT NULL DEFAULT 0.00 COMMENT '已收金额（可为负数用于冲销）',
  `balance_amount` decimal(15, 2) GENERATED ALWAYS AS ((`amount` - `paid_amount`)) VIRTUAL COMMENT '未收金额' NULL,
  `status` enum('未结清','部分支付','已结清') CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '未结清' COMMENT '状态',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  PRIMARY KEY (`receivable_id`) USING BTREE,
  INDEX `idx_wr_customer`(`customer_id` ASC) USING BTREE,
  INDEX `idx_wr_order`(`order_id` ASC) USING BTREE,
  INDEX `idx_wr_due_status`(`due_date` ASC, `status` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2018232157192675330 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '应收款管理表（宽松版）' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_report_detail
-- ----------------------------
DROP TABLE IF EXISTS `wms_report_detail`;
CREATE TABLE `wms_report_detail`  (
  `detail_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `summary_id` bigint NOT NULL COMMENT '关联汇报概述ID（oa_report_summary.id）',
  `device_code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备唯一编号',
  `category` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '设备类别',
  `device_description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '设备生产说明',
  `report_detail` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '汇报详情内容（含文字、图像说明等）',
  `oss_ids` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '关联图像 OSS ID 列表（逗号分隔）',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` int NULL DEFAULT 0 COMMENT '删除标志（0 正常，1 删除）',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`detail_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1954858755527663618 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设计项目汇报详情表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_report_result_storage
-- ----------------------------
DROP TABLE IF EXISTS `wms_report_result_storage`;
CREATE TABLE `wms_report_result_storage`  (
  `storage_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `report_date` date NOT NULL COMMENT '报表日期（横向对比用）',
  `report_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '报表类型（横向对比用）',
  `production_line` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '产线类型（横向对比用）',
  `report_json` json NULL COMMENT '报表完整JSON数据',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  PRIMARY KEY (`storage_id`) USING BTREE,
  INDEX `idx_report_date_type_line`(`report_date` ASC, `report_type` ASC, `production_line` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '报表结果存储表（JSON+横向对比专用）' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_report_summary
-- ----------------------------
DROP TABLE IF EXISTS `wms_report_summary`;
CREATE TABLE `wms_report_summary`  (
  `summary_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `report_title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '汇报标题',
  `report_date` date NOT NULL COMMENT '汇报日期',
  `reporter` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '汇报人',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `del_flag` int NULL DEFAULT 0 COMMENT '删除标志（0 正常，1 删除）',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `type` int NULL DEFAULT NULL COMMENT '1为施工进度2为收发货',
  PRIMARY KEY (`summary_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1960882697093197826 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设计项目汇报概述表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_schedule_change_log
-- ----------------------------
DROP TABLE IF EXISTS `wms_schedule_change_log`;
CREATE TABLE `wms_schedule_change_log`  (
  `log_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `operation_id` bigint NOT NULL COMMENT '工序排程ID',
  `change_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '变更类型：CREATE/UPDATE/DELETE/RESCHEDULE/LOCK/UNLOCK',
  `before_value` json NULL COMMENT '变更前快照',
  `after_value` json NULL COMMENT '变更后快照',
  `change_reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '变更原因',
  `change_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '变更时间',
  `change_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '变更人',
  PRIMARY KEY (`log_id`) USING BTREE,
  INDEX `idx_scl_operation`(`operation_id` ASC) USING BTREE,
  INDEX `idx_scl_time`(`change_time` ASC) USING BTREE,
  CONSTRAINT `fk_scl_operation` FOREIGN KEY (`operation_id`) REFERENCES `wms_schedule_operation` (`operation_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '排产变更日志' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_schedule_lock
-- ----------------------------
DROP TABLE IF EXISTS `wms_schedule_lock`;
CREATE TABLE `wms_schedule_lock`  (
  `lock_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `lock_type` tinyint NOT NULL COMMENT '锁定类型：1计划 2产线+时间窗 3工序记录',
  `plan_id` bigint NULL DEFAULT NULL COMMENT '计划ID',
  `line_id` bigint NULL DEFAULT NULL COMMENT '产线ID',
  `operation_id` bigint NULL DEFAULT NULL COMMENT '工序排程ID',
  `lock_start_time` datetime NULL DEFAULT NULL COMMENT '锁定开始时间',
  `lock_end_time` datetime NULL DEFAULT NULL COMMENT '锁定结束时间',
  `lock_reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '锁定原因',
  `status` tinyint NOT NULL DEFAULT 1 COMMENT '状态：1生效 0失效',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  PRIMARY KEY (`lock_id`) USING BTREE,
  INDEX `idx_sl_plan`(`plan_id` ASC) USING BTREE,
  INDEX `idx_sl_line_time`(`line_id` ASC, `lock_start_time` ASC, `lock_end_time` ASC) USING BTREE,
  INDEX `idx_sl_operation`(`operation_id` ASC) USING BTREE,
  CONSTRAINT `fk_sl_line` FOREIGN KEY (`line_id`) REFERENCES `wms_production_line` (`line_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `fk_sl_operation` FOREIGN KEY (`operation_id`) REFERENCES `wms_schedule_operation` (`operation_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `fk_sl_plan` FOREIGN KEY (`plan_id`) REFERENCES `wms_schedule_plan` (`plan_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '排产锁定表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_schedule_operation
-- ----------------------------
DROP TABLE IF EXISTS `wms_schedule_operation`;
CREATE TABLE `wms_schedule_operation`  (
  `operation_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `plan_id` bigint NOT NULL COMMENT '排产计划ID',
  `detail_id` bigint NULL DEFAULT NULL COMMENT '排产明细ID',
  `order_id` bigint NOT NULL COMMENT '订单ID',
  `order_detail_id` bigint NOT NULL COMMENT '订单明细ID',
  `product_id` bigint NOT NULL COMMENT '产品ID',
  `process_id` bigint NULL DEFAULT NULL COMMENT '工序ID',
  `line_id` bigint NOT NULL COMMENT '产线ID',
  `sequence_no` int NOT NULL COMMENT '工序顺序',
  `plan_qty` decimal(18, 4) NOT NULL COMMENT '计划数量',
  `start_time` datetime NOT NULL COMMENT '计划开始时间',
  `end_time` datetime NOT NULL COMMENT '计划结束时间',
  `setup_minutes` int NOT NULL DEFAULT 0 COMMENT '换型时长',
  `status` tinyint NOT NULL DEFAULT 0 COMMENT '状态：0待执行 1执行中 2已完成 3已锁定 4取消',
  `locked_flag` tinyint NOT NULL DEFAULT 0 COMMENT '是否锁定：0否 1是',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  PRIMARY KEY (`operation_id`) USING BTREE,
  INDEX `idx_so_plan`(`plan_id` ASC) USING BTREE,
  INDEX `idx_so_line_time`(`line_id` ASC, `start_time` ASC, `end_time` ASC) USING BTREE,
  INDEX `idx_so_order_detail`(`order_detail_id` ASC) USING BTREE,
  INDEX `idx_so_process`(`process_id` ASC) USING BTREE,
  INDEX `fk_so_detail`(`detail_id` ASC) USING BTREE,
  INDEX `fk_so_order`(`order_id` ASC) USING BTREE,
  INDEX `fk_so_product`(`product_id` ASC) USING BTREE,
  CONSTRAINT `fk_so_detail` FOREIGN KEY (`detail_id`) REFERENCES `wms_schedule_plan_detail` (`detail_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `fk_so_line` FOREIGN KEY (`line_id`) REFERENCES `wms_production_line` (`line_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `fk_so_order` FOREIGN KEY (`order_id`) REFERENCES `wms_order` (`order_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `fk_so_order_detail` FOREIGN KEY (`order_detail_id`) REFERENCES `wms_order_detail` (`detail_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `fk_so_plan` FOREIGN KEY (`plan_id`) REFERENCES `wms_schedule_plan` (`plan_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `fk_so_process` FOREIGN KEY (`process_id`) REFERENCES `wms_processe` (`process_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `fk_so_product` FOREIGN KEY (`product_id`) REFERENCES `wms_product` (`product_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '工序级排产记录' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_schedule_operation_coil
-- ----------------------------
DROP TABLE IF EXISTS `wms_schedule_operation_coil`;
CREATE TABLE `wms_schedule_operation_coil`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `operation_id` bigint NOT NULL COMMENT '工序排程ID（关联 wms_schedule_operation.operation_id）',
  `coil_id` bigint NOT NULL COMMENT '钢卷ID（关联 wms_material_coil.coil_id）',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_soc_operation`(`operation_id` ASC) USING BTREE,
  INDEX `idx_soc_coil`(`coil_id` ASC) USING BTREE,
  CONSTRAINT `fk_soc_coil` FOREIGN KEY (`coil_id`) REFERENCES `wms_material_coil` (`coil_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `fk_soc_operation` FOREIGN KEY (`operation_id`) REFERENCES `wms_schedule_operation` (`operation_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '工序排程钢卷关系表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_schedule_plan
-- ----------------------------
DROP TABLE IF EXISTS `wms_schedule_plan`;
CREATE TABLE `wms_schedule_plan`  (
  `plan_id` bigint NOT NULL AUTO_INCREMENT COMMENT '排产计划ID',
  `plan_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '排产计划编号',
  `version` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '版本控制',
  `order_id` bigint NOT NULL COMMENT '关联订单ID',
  `status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '状态（0=新建，1=已排产，2=生产中，3=已完成）',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `priority` tinyint NULL DEFAULT NULL COMMENT '优先级（0=低，1=中，2=高，3=vip ....）',
  `process_route` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '工艺路线',
  `start_date` datetime NULL DEFAULT NULL COMMENT '开始时间',
  `end_date` datetime NULL DEFAULT NULL COMMENT '结束时间',
  PRIMARY KEY (`plan_id`) USING BTREE,
  UNIQUE INDEX `uk_schedule_plan_code`(`plan_code` ASC) USING BTREE,
  INDEX `idx_schedule_order`(`order_id` ASC) USING BTREE,
  CONSTRAINT `fk_schedule_order` FOREIGN KEY (`order_id`) REFERENCES `wms_order` (`order_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1953437444170043395 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '排产计划主表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_schedule_plan_detail
-- ----------------------------
DROP TABLE IF EXISTS `wms_schedule_plan_detail`;
CREATE TABLE `wms_schedule_plan_detail`  (
  `detail_id` bigint NOT NULL AUTO_INCREMENT COMMENT '明细ID',
  `plan_id` bigint NULL DEFAULT NULL COMMENT '排产计划ID',
  `line_id` bigint NOT NULL COMMENT '产线ID',
  `task_id` bigint NOT NULL COMMENT '生产任务id(原批次batch_id)',
  `product_id` bigint NULL DEFAULT NULL COMMENT '产品ID',
  `quantity` decimal(18, 4) NOT NULL COMMENT '排产数量',
  `start_date` date NOT NULL COMMENT '计划开始日期',
  `end_date` date NOT NULL COMMENT '计划结束日期',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  PRIMARY KEY (`detail_id`) USING BTREE,
  INDEX `idx_schedule_detail_plan`(`plan_id` ASC) USING BTREE,
  INDEX `idx_schedule_detail_line`(`line_id` ASC) USING BTREE,
  INDEX `fk_schedule_detail_product`(`product_id` ASC) USING BTREE,
  CONSTRAINT `fk_schedule_detail_line` FOREIGN KEY (`line_id`) REFERENCES `wms_production_line` (`line_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `fk_schedule_detail_plan` FOREIGN KEY (`plan_id`) REFERENCES `wms_schedule_plan` (`plan_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1960266841070575618 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '排产计划明细表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_shift_template
-- ----------------------------
DROP TABLE IF EXISTS `wms_shift_template`;
CREATE TABLE `wms_shift_template`  (
  `shift_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `shift_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '班次编码',
  `shift_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '班次名称',
  `start_time` time NOT NULL COMMENT '开始时间',
  `end_time` time NOT NULL COMMENT '结束时间',
  `cross_day` tinyint NOT NULL DEFAULT 0 COMMENT '是否跨天：0否 1是',
  `efficiency_rate` decimal(6, 4) NOT NULL DEFAULT 1.0000 COMMENT '班次效率系数',
  `is_enabled` tinyint NOT NULL DEFAULT 1 COMMENT '是否启用：0否 1是',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `del_flag` int NULL DEFAULT 0 COMMENT '删除标志2删除',
  PRIMARY KEY (`shift_id`) USING BTREE,
  UNIQUE INDEX `uk_shift_code`(`shift_code` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '班次模板' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_stock
-- ----------------------------
DROP TABLE IF EXISTS `wms_stock`;
CREATE TABLE `wms_stock`  (
  `stock_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `item_id` bigint NOT NULL COMMENT '物品ID（指向原材料或产品主键）',
  `item_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '物品类型（raw_material/product）',
  `batch_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '批次号（可选）',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  PRIMARY KEY (`stock_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2047414866564784130 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '库存表：原材料-钢卷-库区的存放关系' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_supplier
-- ----------------------------
DROP TABLE IF EXISTS `wms_supplier`;
CREATE TABLE `wms_supplier`  (
  `supplier_id` bigint NOT NULL AUTO_INCREMENT COMMENT '供应商ID（主键）',
  `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '供应商名称',
  `contact_person` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '联系人',
  `phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '联系电话',
  `address` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '地址',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新人',
  PRIMARY KEY (`supplier_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1955139407119724547 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '供应商信息表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for wms_transfer_order
-- ----------------------------
DROP TABLE IF EXISTS `wms_transfer_order`;
CREATE TABLE `wms_transfer_order`  (
  `order_id` bigint NOT NULL AUTO_INCREMENT COMMENT '调拨单主键ID',
  `transfer_no` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '调拨单号(唯一，格式：DB+年月日+流水号)',
  `transfer_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '调拨单名称',
  `transfer_status` tinyint NOT NULL DEFAULT 0 COMMENT '调拨状态 0-待审核 1-已完成 2-已取消',
  `transfer_time` datetime NULL DEFAULT NULL COMMENT '实际调拨时间',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标记(0正常 1删除)',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `transfer_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '调拨类型',
  `approve_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '审批人',
  `approve_time` datetime NULL DEFAULT NULL COMMENT '审批时间',
  `approve_status` tinyint NOT NULL DEFAULT 0 COMMENT '审批状态 0-待审批 1-已通过 2-已驳回',
  PRIMARY KEY (`order_id`) USING BTREE,
  UNIQUE INDEX `uk_transfer_no`(`transfer_no` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2047468857667526658 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '调拨单主表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_transfer_order_item
-- ----------------------------
DROP TABLE IF EXISTS `wms_transfer_order_item`;
CREATE TABLE `wms_transfer_order_item`  (
  `order_item_id` bigint NOT NULL AUTO_INCREMENT COMMENT '调拨明细主键ID',
  `transfer_id` bigint NOT NULL COMMENT '关联调拨单ID',
  `coil_id` bigint NULL DEFAULT NULL COMMENT '钢卷id',
  `item_id_before` bigint NULL DEFAULT NULL COMMENT '调拨前itemId',
  `item_id_after` bigint NULL DEFAULT NULL COMMENT '调拨后itemId',
  `material_type_before` tinyint NULL DEFAULT NULL COMMENT '修改前物料类型 1-原料 2-成品',
  `material_type_after` tinyint NULL DEFAULT NULL COMMENT '修改后物料类型 1-原料 2-成品',
  `warehouse_id_before` bigint NULL DEFAULT NULL COMMENT '调拨前逻辑库区ID',
  `warehouse_id_after` bigint NULL DEFAULT NULL COMMENT '调拨后逻辑库区ID',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `del_flag` tinyint NULL DEFAULT 0 COMMENT '删除标记(0正常 1删除)',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `is_transferred` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否已经调拨 0-未调拨 1-已调拨',
  PRIMARY KEY (`order_item_id`) USING BTREE,
  INDEX `idx_transfer_id`(`transfer_id` ASC) USING BTREE,
  INDEX `idx_coil_id`(`coil_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2047469169971208195 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '调拨单明细表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for wms_warehouse
-- ----------------------------
DROP TABLE IF EXISTS `wms_warehouse`;
CREATE TABLE `wms_warehouse`  (
  `warehouse_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `parent_id` bigint NULL DEFAULT NULL COMMENT '父节点ID（指向同表 warehouse_id）',
  `warehouse_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '仓库/库区编码',
  `warehouse_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '仓库/库区名称',
  `warehouse_type` tinyint NOT NULL DEFAULT 0 COMMENT '类型：0=仓库，1=库区，2=库位，…',
  `sort_no` int NULL DEFAULT NULL COMMENT '同级排序号',
  `use_count` int NOT NULL DEFAULT 0 COMMENT '使用次数（用于排序：使用越多越靠前）',
  `is_enabled` tinyint(1) NOT NULL DEFAULT 1 COMMENT '是否启用（0=否，1=是）',
  `del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '删除标志（0=正常，1=已删除）',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  PRIMARY KEY (`warehouse_id`) USING BTREE,
  INDEX `idx_wms_wh_parent`(`parent_id` ASC) USING BTREE,
  INDEX `idx_use_count`(`use_count` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2035892198703349762 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '仓库/库区/库位自关联表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for xxl_job_group
-- ----------------------------
DROP TABLE IF EXISTS `xxl_job_group`;
CREATE TABLE `xxl_job_group`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `app_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '执行器AppName',
  `title` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '执行器名称',
  `address_type` tinyint NOT NULL DEFAULT 0 COMMENT '执行器地址类型：0=自动注册、1=手动录入',
  `address_list` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '执行器地址列表，多地址逗号分隔',
  `update_time` datetime NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for xxl_job_info
-- ----------------------------
DROP TABLE IF EXISTS `xxl_job_info`;
CREATE TABLE `xxl_job_info`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `job_group` int NOT NULL COMMENT '执行器主键ID',
  `job_desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `add_time` datetime NULL DEFAULT NULL,
  `update_time` datetime NULL DEFAULT NULL,
  `author` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '作者',
  `alarm_email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '报警邮件',
  `schedule_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'NONE' COMMENT '调度类型',
  `schedule_conf` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '调度配置，值含义取决于调度类型',
  `misfire_strategy` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'DO_NOTHING' COMMENT '调度过期策略',
  `executor_route_strategy` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '执行器路由策略',
  `executor_handler` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '执行器任务handler',
  `executor_param` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '执行器任务参数',
  `executor_block_strategy` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '阻塞处理策略',
  `executor_timeout` int NOT NULL DEFAULT 0 COMMENT '任务执行超时时间，单位秒',
  `executor_fail_retry_count` int NOT NULL DEFAULT 0 COMMENT '失败重试次数',
  `glue_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'GLUE类型',
  `glue_source` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT 'GLUE源代码',
  `glue_remark` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'GLUE备注',
  `glue_updatetime` datetime NULL DEFAULT NULL COMMENT 'GLUE更新时间',
  `child_jobid` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '子任务ID，多个逗号分隔',
  `trigger_status` tinyint NOT NULL DEFAULT 0 COMMENT '调度状态：0-停止，1-运行',
  `trigger_last_time` bigint NOT NULL DEFAULT 0 COMMENT '上次调度时间',
  `trigger_next_time` bigint NOT NULL DEFAULT 0 COMMENT '下次调度时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for xxl_job_lock
-- ----------------------------
DROP TABLE IF EXISTS `xxl_job_lock`;
CREATE TABLE `xxl_job_lock`  (
  `lock_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '锁名称',
  PRIMARY KEY (`lock_name`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for xxl_job_log
-- ----------------------------
DROP TABLE IF EXISTS `xxl_job_log`;
CREATE TABLE `xxl_job_log`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `job_group` int NOT NULL COMMENT '执行器主键ID',
  `job_id` int NOT NULL COMMENT '任务，主键ID',
  `executor_address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '执行器地址，本次执行的地址',
  `executor_handler` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '执行器任务handler',
  `executor_param` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '执行器任务参数',
  `executor_sharding_param` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '执行器任务分片参数，格式如 1/2',
  `executor_fail_retry_count` int NOT NULL DEFAULT 0 COMMENT '失败重试次数',
  `trigger_time` datetime NULL DEFAULT NULL COMMENT '调度-时间',
  `trigger_code` int NOT NULL COMMENT '调度-结果',
  `trigger_msg` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '调度-日志',
  `handle_time` datetime NULL DEFAULT NULL COMMENT '执行-时间',
  `handle_code` int NOT NULL COMMENT '执行-状态',
  `handle_msg` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '执行-日志',
  `alarm_status` tinyint NOT NULL DEFAULT 0 COMMENT '告警状态：0-默认、1-无需告警、2-告警成功、3-告警失败',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `I_trigger_time`(`trigger_time` ASC) USING BTREE,
  INDEX `I_handle_code`(`handle_code` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for xxl_job_log_report
-- ----------------------------
DROP TABLE IF EXISTS `xxl_job_log_report`;
CREATE TABLE `xxl_job_log_report`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `trigger_day` datetime NULL DEFAULT NULL COMMENT '调度-时间',
  `running_count` int NOT NULL DEFAULT 0 COMMENT '运行中-日志数量',
  `suc_count` int NOT NULL DEFAULT 0 COMMENT '执行成功-日志数量',
  `fail_count` int NOT NULL DEFAULT 0 COMMENT '执行失败-日志数量',
  `update_time` datetime NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `i_trigger_day`(`trigger_day` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for xxl_job_logglue
-- ----------------------------
DROP TABLE IF EXISTS `xxl_job_logglue`;
CREATE TABLE `xxl_job_logglue`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `job_id` int NOT NULL COMMENT '任务，主键ID',
  `glue_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'GLUE类型',
  `glue_source` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT 'GLUE源代码',
  `glue_remark` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'GLUE备注',
  `add_time` datetime NULL DEFAULT NULL,
  `update_time` datetime NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for xxl_job_registry
-- ----------------------------
DROP TABLE IF EXISTS `xxl_job_registry`;
CREATE TABLE `xxl_job_registry`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `registry_group` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `registry_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `registry_value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `update_time` datetime NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `i_g_k_v`(`registry_group` ASC, `registry_key` ASC, `registry_value` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for xxl_job_user
-- ----------------------------
DROP TABLE IF EXISTS `xxl_job_user`;
CREATE TABLE `xxl_job_user`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '账号',
  `password` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '密码',
  `role` tinyint NOT NULL COMMENT '角色：0-普通用户、1-管理员',
  `permission` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '权限：执行器ID列表，多个逗号分割',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `i_username`(`username` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;

SET FOREIGN_KEY_CHECKS = 1;
