/*
 Navicat Premium Dump SQL

 Source Server         : localhost
 Source Server Type    : MySQL
 Source Server Version : 80408 (8.4.8)
 Source Host           : localhost:3306
 Source Schema         : product-inventory-management-new-pro

 Target Server Type    : MySQL
 Target Server Version : 80408 (8.4.8)
 File Encoding         : 65001

 Date: 16/06/2026 10:13:25
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for account_expense
-- ----------------------------
DROP TABLE IF EXISTS `account_expense`;
CREATE TABLE `account_expense`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `business_id` int NULL DEFAULT NULL COMMENT '业务id',
  `business_type` int NULL DEFAULT NULL COMMENT '业务类型 1-付款 2-还借款',
  `expense_date` date NULL DEFAULT NULL COMMENT '支出日期',
  `expense_type` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '支出类型',
  `supplier_name` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '供应商名称',
  `expense_money` decimal(18, 2) NULL DEFAULT NULL COMMENT '支出金额',
  `expense_described` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '支出描述',
  `expense_method` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '付款方式',
  `invoice_number` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '发票号码',
  `note` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '备注',
  `input_user` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '录入人员',
  `input_time` date NULL DEFAULT NULL COMMENT '录入时间',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 100 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '财务管理--支出管理' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for account_file
-- ----------------------------
DROP TABLE IF EXISTS `account_file`;
CREATE TABLE `account_file`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '文件名称',
  `url` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '文件路径',
  `file_size` int NULL DEFAULT NULL COMMENT '文件大小',
  `account_id` bigint NULL DEFAULT NULL COMMENT '财务ID',
  `account_type` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '类型(收入/支出)',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 272 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '财务管理--附件' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for account_income
-- ----------------------------
DROP TABLE IF EXISTS `account_income`;
CREATE TABLE `account_income`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `income_date` date NULL DEFAULT NULL COMMENT '收入日期',
  `income_type` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '收入类型',
  `customer_name` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '客户名称',
  `income_money` decimal(18, 2) NULL DEFAULT NULL COMMENT '收入金额',
  `income_described` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '收入描述',
  `income_method` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '收款方式',
  `invoice_number` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '发票号码',
  `note` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '备注',
  `input_user` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '录入人员',
  `input_time` date NULL DEFAULT NULL COMMENT '录入时间',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `business_id` int NULL DEFAULT NULL COMMENT '业务id',
  `business_type` int NULL DEFAULT NULL COMMENT '业务类型 1-回款 2-借款',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 696 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '财务管理--收入管理' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for account_invoice_application
-- ----------------------------
DROP TABLE IF EXISTS `account_invoice_application`;
CREATE TABLE `account_invoice_application`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `create_user` int NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` int NULL DEFAULT NULL COMMENT '修改人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `customer_id` int NOT NULL COMMENT '客户id',
  `stock_out_record_ids` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '关联出库单id(多选)',
  `invoice_application_no` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '开票申请单号',
  `invoice_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '发票类型',
  `apply_date` date NULL DEFAULT NULL COMMENT '申请日期',
  `invoice_content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '发票内容',
  `remark` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '备注',
  `status` int NULL DEFAULT 0 COMMENT '审核状态:0待审核1审核通过2审核不通过',
  `invoice_amount` decimal(18, 4) NULL DEFAULT NULL COMMENT '开票金额',
  `tax_rate` decimal(5, 0) NULL DEFAULT NULL COMMENT '税率',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '财务管理--开票申请' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for account_payment_application
-- ----------------------------
DROP TABLE IF EXISTS `account_payment_application`;
CREATE TABLE `account_payment_application`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `create_user` int NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` int NULL DEFAULT NULL COMMENT '修改人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `supplier_id` int NOT NULL COMMENT '供应商id',
  `stock_in_record_ids` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL COMMENT '关联入库单id(多选)',
  `invoice_application_no` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '付款申请单号',
  `payment_method` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '付款方式',
  `payment_content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '付款事由',
  `apply_date` date NULL DEFAULT NULL COMMENT '申请日期',
  `remark` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '备注',
  `status` int NULL DEFAULT 0 COMMENT '审核状态:0待审核1审核通过2审核不通过',
  `payment_amount` decimal(15, 4) NULL DEFAULT NULL COMMENT '付款金额',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '财务管理--付款申请' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for account_purchase_invoice
-- ----------------------------
DROP TABLE IF EXISTS `account_purchase_invoice`;
CREATE TABLE `account_purchase_invoice`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `create_user` int NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` int NULL DEFAULT NULL COMMENT '修改人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `invoice_number` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '发票号码',
  `tax_rate` decimal(5, 0) NULL DEFAULT NULL COMMENT '税率',
  `invoice_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '发票类型',
  `issue_date` date NULL DEFAULT NULL COMMENT '开票日期',
  `tax_exclusivel_price` decimal(15, 2) NULL DEFAULT NULL COMMENT '金额(不含税)',
  `tax_price` decimal(15, 2) NULL DEFAULT NULL COMMENT '税额',
  `tax_inclusive_price` decimal(15, 2) NULL DEFAULT NULL COMMENT '价税合计',
  `remark` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '备注',
  `invoice_content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '发票内容',
  `supplier_id` int NOT NULL COMMENT '供应商id',
  `storage_attachment_id` int NULL DEFAULT NULL COMMENT '关联上传的发票附件id',
  `stock_in_record_ids` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL COMMENT '关联入库单id(多选)',
  `status` int NULL DEFAULT 0 COMMENT '状态 0启用 1禁用',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '财务管理--进项发票' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for account_purchase_payment
-- ----------------------------
DROP TABLE IF EXISTS `account_purchase_payment`;
CREATE TABLE `account_purchase_payment`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `account_payment_application_id` int NOT NULL COMMENT '关联付款申请id',
  `create_user` int NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` int NULL DEFAULT NULL COMMENT '修改人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `supplier_id` int NOT NULL COMMENT '供应商id',
  `payment_date` date NULL DEFAULT NULL COMMENT '付款日期',
  `payment_method` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '付款方式',
  `payment_amount` decimal(15, 2) NULL DEFAULT NULL COMMENT '付款金额',
  `payment_number` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '付款单号',
  `remark` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '财务管理--付款单' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for account_sales_collection
-- ----------------------------
DROP TABLE IF EXISTS `account_sales_collection`;
CREATE TABLE `account_sales_collection`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `stock_out_record_ids` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '关联出库单id(多选)',
  `create_user` int NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` int NULL DEFAULT NULL COMMENT '修改人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `customer_id` int NOT NULL COMMENT '客户id',
  `collection_date` date NULL DEFAULT NULL COMMENT '收款日期',
  `collection_amount` decimal(15, 2) NULL DEFAULT NULL COMMENT '收款金额',
  `collection_method` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '收款方式',
  `collection_number` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '收款单号',
  `remark` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '财务管理--收款单' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for account_sales_invoice
-- ----------------------------
DROP TABLE IF EXISTS `account_sales_invoice`;
CREATE TABLE `account_sales_invoice`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `account_invoice_application_id` int NOT NULL COMMENT '关联开票申请id',
  `create_user` int NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` int NULL DEFAULT NULL COMMENT '修改人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `invoice_number` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '发票号码',
  `tax_rate` decimal(5, 0) NULL DEFAULT NULL COMMENT '税率',
  `invoice_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '发票类型',
  `issue_date` date NULL DEFAULT NULL COMMENT '开票日期',
  `tax_exclusivel_price` decimal(15, 2) NULL DEFAULT NULL COMMENT '金额(不含税)',
  `tax_price` decimal(15, 2) NULL DEFAULT NULL COMMENT '税额',
  `tax_inclusive_price` decimal(15, 2) NULL DEFAULT NULL COMMENT '价税合计',
  `remark` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '备注',
  `invoice_content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '发票内容',
  `customer_id` int NULL DEFAULT NULL COMMENT '客户id',
  `storage_attachment_id` int NULL DEFAULT NULL COMMENT '关联上传的发票附件id',
  `status` int NULL DEFAULT 0 COMMENT '状态 0启用 1禁用',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '财务管理--销项发票' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for account_statement
-- ----------------------------
DROP TABLE IF EXISTS `account_statement`;
CREATE TABLE `account_statement`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `customer_id` int NOT NULL COMMENT '客户id',
  `statement_month` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '对账月份(yyyy-MM)',
  `account_type` int NOT NULL COMMENT '业务类型(1应收对账;2应付对账)',
  `statement_number` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '对账单号',
  `opening_balance` decimal(15, 2) NULL DEFAULT NULL COMMENT '期初余额',
  `current_plan` decimal(15, 2) NULL DEFAULT NULL COMMENT '本期应收/应付',
  `current_actually` decimal(15, 2) NULL DEFAULT NULL COMMENT '本期收款/付款',
  `closing_balance` decimal(15, 2) NULL DEFAULT NULL COMMENT '期末余额',
  `create_user` int NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` int NULL DEFAULT NULL COMMENT '修改人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '财务管理--对账单' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for account_statement_details
-- ----------------------------
DROP TABLE IF EXISTS `account_statement_details`;
CREATE TABLE `account_statement_details`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `account_statement_id` int NOT NULL COMMENT '关联对账单id',
  `occurrence_date` date NULL DEFAULT NULL COMMENT '数据日期',
  `receipt_number` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '单据编号',
  `type` int NULL DEFAULT NULL COMMENT '数据类型(1出库;2入库;3收款;4付款;5退货)',
  `amount` decimal(15, 2) NULL DEFAULT NULL COMMENT '金额',
  `remark` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '备注',
  `create_user` int NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` int NULL DEFAULT NULL COMMENT '修改人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 24 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '财务管理--对账单明细' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for account_subject
-- ----------------------------
DROP TABLE IF EXISTS `account_subject`;
CREATE TABLE `account_subject`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `parent_id` bigint NULL DEFAULT NULL COMMENT '父科目ID（为空表示根节点）',
  `subject_code` varchar(255) 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(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '科目类型',
  `balance_direction` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '余额方向',
  `status` int NULL DEFAULT 0 COMMENT '状态 0启用 1禁用',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_user` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '修改人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_account_subject_parent_id`(`parent_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 15 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '总账科目表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for after_sales_near_expiry
-- ----------------------------
DROP TABLE IF EXISTS `after_sales_near_expiry`;
CREATE TABLE `after_sales_near_expiry`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `product_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '临期产品名称',
  `batch_number` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '产品批号',
  `expire_date` date NULL DEFAULT NULL COMMENT '临期日期',
  `stock_quantity` int NULL DEFAULT NULL COMMENT '库存数量',
  `customer_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '客户名称',
  `dis_res` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '问题描述',
  `status` int NULL DEFAULT NULL COMMENT '处理状态 (如: 1-待处理 2-已处理)',
  `dispose_user_id` bigint NULL DEFAULT NULL COMMENT '处理人ID',
  `dispose_nick_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '处理人名称',
  `dis_date` date NULL DEFAULT NULL COMMENT '处理日期',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `tenant_id` int NULL DEFAULT NULL COMMENT '租户id',
  `contact_phone` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '联系电话',
  `dispose_result` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '处理结果',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '临期售后管理表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for after_sales_service
-- ----------------------------
DROP TABLE IF EXISTS `after_sales_service`;
CREATE TABLE `after_sales_service`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `status` int NULL DEFAULT NULL COMMENT '状态 1-待处理 2-已处理',
  `check_user_id` bigint NULL DEFAULT NULL COMMENT '登记人',
  `check_nick_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '登记人名称',
  `dispose_user_id` bigint NULL DEFAULT NULL COMMENT '处理人',
  `dispose_nick_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '处理人名称',
  `customer_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '客户名称',
  `dis_res` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '问题描述',
  `pro_desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '处理结果',
  `feedback_date` date NULL DEFAULT NULL COMMENT '反馈日期',
  `dis_date` date NULL DEFAULT NULL COMMENT '处理日期',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `tenant_id` int NULL DEFAULT NULL COMMENT '租户id',
  `service_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '售后类型',
  `urgency` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '紧急程度',
  `sales_ledger_id` bigint NULL DEFAULT NULL COMMENT '销售订单id',
  `distribution_user_id` bigint NULL DEFAULT NULL COMMENT '分配人id',
  `product_model_ids` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '售后产品id集合',
  `after_sales_service_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '售后单号',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '售后服务' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for after_sales_service_file
-- ----------------------------
DROP TABLE IF EXISTS `after_sales_service_file`;
CREATE TABLE `after_sales_service_file`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `service_id` bigint NOT NULL COMMENT '售后服务记录ID',
  `file_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '文件名称',
  `file_url` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '文件访问地址',
  `file_size` bigint NULL DEFAULT NULL COMMENT '文件大小',
  `file_suffix` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '文件后缀',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT '0' COMMENT '删除标志（0代表存在 1代表删除）',
  `create_user` bigint NULL DEFAULT NULL COMMENT '上传者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `tenant_id` int NULL DEFAULT NULL COMMENT '租户id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_service_id`(`service_id` ASC) USING BTREE COMMENT '售后ID索引'
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '售后服务附件表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ai_chat_session
-- ----------------------------
DROP TABLE IF EXISTS `ai_chat_session`;
CREATE TABLE `ai_chat_session`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `memory_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '会话ID',
  `user_id` bigint NOT NULL COMMENT '用户ID',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `title` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '会话标题',
  `last_message` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '最后一条消息',
  `message_count` int NOT NULL DEFAULT 0 COMMENT '消息数量',
  `last_chat_time` datetime NULL DEFAULT NULL COMMENT '最后聊天时间',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 32 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'AI历史会话元数据表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for annual_leave_setting
-- ----------------------------
DROP TABLE IF EXISTS `annual_leave_setting`;
CREATE TABLE `annual_leave_setting`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `employee_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '员工类型',
  `work_years` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '工作年限',
  `annual_days` int NULL DEFAULT NULL COMMENT '年假天数',
  `max_carry_over` int NULL DEFAULT NULL COMMENT '最大结转天数',
  `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '状态',
  `create_user` int NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` int NULL DEFAULT NULL COMMENT '修改者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `tenant_id` int NULL DEFAULT NULL COMMENT '租户id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '年假设置' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for approval_instance
-- ----------------------------
DROP TABLE IF EXISTS `approval_instance`;
CREATE TABLE `approval_instance`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '审批实例ID',
  `instance_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '审批编号',
  `template_id` bigint NULL DEFAULT NULL COMMENT '模板ID',
  `template_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '模板名称',
  `business_id` bigint NULL DEFAULT NULL COMMENT '业务ID',
  `business_type` int NULL DEFAULT NULL COMMENT '业务类型',
  `title` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '审批标题',
  `status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '审批状态',
  `current_level` int NULL DEFAULT NULL COMMENT '当前审批级别',
  `applicant_id` bigint NOT NULL COMMENT '申请人ID',
  `applicant_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '申请人名称',
  `apply_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '申请时间',
  `finish_time` datetime NULL DEFAULT NULL COMMENT '完成时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `deleted` tinyint NOT NULL DEFAULT 0 COMMENT '逻辑删除',
  `dept_id` int NULL DEFAULT NULL,
  `form_config` json NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_business`(`business_type` ASC, `business_id` ASC) USING BTREE,
  INDEX `idx_status`(`status` ASC) USING BTREE,
  INDEX `idx_applicant`(`applicant_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 99 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '审批实例表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for approval_instance_node
-- ----------------------------
DROP TABLE IF EXISTS `approval_instance_node`;
CREATE TABLE `approval_instance_node`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '节点实例ID',
  `instance_id` bigint NOT NULL COMMENT '审批实例ID',
  `level_no` int NOT NULL COMMENT '审批级别',
  `approve_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '审批类型',
  `status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '节点状态',
  `start_time` datetime NULL DEFAULT NULL COMMENT '开始时间',
  `finish_time` datetime NULL DEFAULT NULL COMMENT '完成时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `deleted` tinyint NOT NULL DEFAULT 0 COMMENT '逻辑删除',
  `dept_id` int NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_instance_id`(`instance_id` ASC) USING BTREE,
  INDEX `idx_instance_level`(`instance_id` ASC, `level_no` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 123 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '审批节点实例表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for approval_record
-- ----------------------------
DROP TABLE IF EXISTS `approval_record`;
CREATE TABLE `approval_record`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '审批记录ID',
  `instance_id` bigint NULL DEFAULT NULL COMMENT '审批实例ID',
  `node_id` bigint NULL DEFAULT NULL COMMENT '节点实例ID',
  `task_id` bigint NULL DEFAULT NULL COMMENT '审批任务ID',
  `operator_id` bigint NULL DEFAULT NULL COMMENT '操作人ID',
  `operator_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '操作人名称',
  `action` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '操作类型',
  `comment` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '审批意见',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间',
  `deleted` tinyint(1) NULL DEFAULT 0 COMMENT '逻辑删除',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 180 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '审批记录表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for approval_task
-- ----------------------------
DROP TABLE IF EXISTS `approval_task`;
CREATE TABLE `approval_task`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '审批任务ID',
  `instance_id` bigint NOT NULL COMMENT '审批实例ID',
  `node_id` bigint NOT NULL COMMENT '节点实例ID',
  `level_no` int NOT NULL COMMENT '审批级别',
  `approver_id` bigint NOT NULL COMMENT '审批人ID',
  `approver_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '审批人名称',
  `task_status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '任务状态',
  `approve_time` datetime NULL DEFAULT NULL COMMENT '审批时间',
  `comment` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '审批意见',
  `is_read` tinyint NOT NULL DEFAULT 0 COMMENT '是否已读',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `deleted` tinyint NOT NULL DEFAULT 0 COMMENT '逻辑删除',
  `dept_id` int NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_approver`(`approver_id` ASC, `task_status` ASC) USING BTREE,
  INDEX `idx_instance`(`instance_id` ASC) USING BTREE,
  INDEX `idx_node`(`node_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 124 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '审批任务表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for approval_template
-- ----------------------------
DROP TABLE IF EXISTS `approval_template`;
CREATE TABLE `approval_template`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '模板ID',
  `template_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '模板名称',
  `enabled` tinyint NOT NULL DEFAULT 1 COMMENT '启用状态：1启用，0停用',
  `description` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '模板说明',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `deleted` tinyint NOT NULL DEFAULT 0 COMMENT '逻辑删除：0否，1是',
  `dept_id` int NULL DEFAULT NULL,
  `form_config` json NULL COMMENT '动态表单配置JSON',
  `template_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '0' COMMENT '模板类型：0系统内置，1自定义',
  `business_type` int NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 46 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '审批模板表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for approval_template_node
-- ----------------------------
DROP TABLE IF EXISTS `approval_template_node`;
CREATE TABLE `approval_template_node`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '节点ID',
  `template_id` bigint NOT NULL COMMENT '审批模板ID',
  `level_no` int NOT NULL COMMENT '审批级别，从1开始',
  `approve_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '审批方式：AND会签，OR或签',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `create_user` int NULL DEFAULT NULL,
  `dept_id` int NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_template_level`(`template_id` ASC, `level_no` ASC) USING BTREE,
  INDEX `idx_template_id`(`template_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 68 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '审批模板节点表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for approval_template_node_approver
-- ----------------------------
DROP TABLE IF EXISTS `approval_template_node_approver`;
CREATE TABLE `approval_template_node_approver`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `node_id` bigint NOT NULL COMMENT '审批节点ID',
  `template_id` bigint NOT NULL COMMENT '审批模板ID',
  `approver_id` bigint NOT NULL COMMENT '审批人ID',
  `approver_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '审批人名称冗余',
  `sort_no` int NOT NULL DEFAULT 1 COMMENT '审批人排序',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `dept_id` int NULL DEFAULT NULL,
  `create_user` int NULL DEFAULT NULL,
  `deleted` int NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_node_approver`(`node_id` ASC, `approver_id` ASC) USING BTREE,
  INDEX `idx_node_id`(`node_id` ASC) USING BTREE,
  INDEX `idx_template_id`(`template_id` ASC) USING BTREE,
  INDEX `idx_approver_id`(`approver_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 76 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '审批模板节点审批人表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for approve_log
-- ----------------------------
DROP TABLE IF EXISTS `approve_log`;
CREATE TABLE `approve_log`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `approve_id` bigint NOT NULL COMMENT '审批id',
  `approve_node_order` int NOT NULL COMMENT '审批节点顺序',
  `approve_user` bigint NOT NULL COMMENT '审批人id',
  `approve_time` datetime NOT NULL COMMENT '审批时间',
  `approve_status` int NOT NULL COMMENT '审批状态',
  `approve_remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '审批备注',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '审批日志表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for approve_node
-- ----------------------------
DROP TABLE IF EXISTS `approve_node`;
CREATE TABLE `approve_node`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `approve_process_id` char(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '审批编号',
  `approve_node_order` int NOT NULL COMMENT '审批节点顺序',
  `approve_node_user_id` int NULL DEFAULT NULL COMMENT '审批节点用户id',
  `approve_node_user` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '审批节点用户名字',
  `approve_node_time` datetime NOT NULL COMMENT '审批节点时间',
  `approve_node_status` int NOT NULL COMMENT '审批节点状态:1同意，2拒绝，0尚未审核（默认为0）',
  `tenant_id` bigint NOT NULL COMMENT '租户id',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建者',
  `delete_flag` int NOT NULL COMMENT '删除标记:0正常，1删除',
  `approve_node_reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '审批节点拒绝原因',
  `approve_node_remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '审批节点备注',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 115 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '审批节点表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for approve_process
-- ----------------------------
DROP TABLE IF EXISTS `approve_process`;
CREATE TABLE `approve_process`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `approve_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '审批id',
  `approve_user` bigint NOT NULL COMMENT '申请人id',
  `approve_user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '申请人名称',
  `approve_dept_id` bigint NULL DEFAULT NULL COMMENT '申请部门id',
  `approve_dept_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '申请部门名称',
  `approve_user_ids` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '审批用户ids',
  `approve_user_names` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '审批用户名称',
  `approve_user_current_id` bigint NULL DEFAULT NULL COMMENT '当前审批用户id',
  `approve_user_current_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '当前审批用户名称',
  `approve_reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '申请原因',
  `approve_time` datetime NOT NULL COMMENT '申请日期',
  `approve_over_time` datetime NULL DEFAULT NULL COMMENT '审批完成时间',
  `approve_status` int NOT NULL COMMENT '审批状态：0待审核，1审核中，2审核完成',
  `approve_delete` int NOT NULL COMMENT '审批是否删除：0正常，1删除',
  `tenant_id` bigint NOT NULL COMMENT '租户id',
  `approve_type` int NULL DEFAULT NULL COMMENT '审批类型',
  `approve_remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '审批备注',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `start_date_time` datetime NULL DEFAULT NULL COMMENT '开始时间',
  `end_date_time` datetime NULL DEFAULT NULL COMMENT '结束时间',
  `start_date` date NULL DEFAULT NULL COMMENT '开始日期',
  `end_date` date NULL DEFAULT NULL COMMENT '结束日期',
  `location` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '地点',
  `price` decimal(10, 2) NULL DEFAULT NULL COMMENT '报销金额',
  `maintenance_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '维修价格',
  `device_repair_id` int NULL DEFAULT NULL COMMENT '设备报修id',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 98 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '审批流程表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for approve_process_config_node
-- ----------------------------
DROP TABLE IF EXISTS `approve_process_config_node`;
CREATE TABLE `approve_process_config_node`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `approve_type` int NULL DEFAULT NULL COMMENT '审批类型：1公出管理，2请假管理，3出差管理，4报销管理，5采购审批，6报价审批，7发货审批，8危险作业审批',
  `node_order` int NULL DEFAULT NULL COMMENT '节点顺序',
  `approver_id` int NULL DEFAULT NULL COMMENT '审批人ID',
  `approver_name` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '审批人名称',
  `timeout_hours` int NULL DEFAULT NULL COMMENT '超时时长（小时）',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户ID',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户ID',
  `update_time` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
  `delete_flag` tinyint(1) NULL DEFAULT 0 COMMENT '删除标记：0正常，1删除',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 13 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '审批流程配置节点表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for bank
-- ----------------------------
DROP TABLE IF EXISTS `bank`;
CREATE TABLE `bank`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `bank_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '银行名称',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '银行管理表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for borrow_info
-- ----------------------------
DROP TABLE IF EXISTS `borrow_info`;
CREATE TABLE `borrow_info`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '借款记录主键ID',
  `borrower_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '借款人姓名',
  `borrow_amount` decimal(18, 2) NULL DEFAULT NULL COMMENT '借款金额（元）',
  `interest_rate` decimal(5, 2) NULL DEFAULT NULL COMMENT '借款利率（如：5.85 代表5.85%）',
  `borrow_date` date NULL DEFAULT NULL COMMENT '借款日期',
  `repay_date` date NULL DEFAULT NULL 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 NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_user` int NULL DEFAULT NULL COMMENT '创建者ID',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
  `update_user` int NULL DEFAULT NULL COMMENT '修改者ID',
  `tenant_id` bigint NOT NULL COMMENT '租户id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '借款信息表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for common_file
-- ----------------------------
DROP TABLE IF EXISTS `common_file`;
CREATE TABLE `common_file`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `common_id` int NOT NULL COMMENT '关联销售台账主表主键',
  `type` int NULL DEFAULT NULL COMMENT '关联表类型',
  `url` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '附件路径',
  `name` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '附件名称',
  `create_time` date NULL DEFAULT NULL,
  `update_time` date NULL DEFAULT NULL,
  `file_size` bigint NULL DEFAULT NULL COMMENT '文件大小',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '销售台账文件' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for compensation_performance
-- ----------------------------
DROP TABLE IF EXISTS `compensation_performance`;
CREATE TABLE `compensation_performance`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
  `staff_id` bigint NOT NULL COMMENT '员工id',
  `pay_date` date NULL DEFAULT NULL COMMENT '薪资月份',
  `name` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '姓名',
  `should_attended_num` decimal(10, 2) NULL DEFAULT NULL COMMENT '应出勤天数',
  `actual_attended_num` decimal(10, 2) NULL DEFAULT NULL COMMENT '实际出勤天数',
  `basic_salary` decimal(10, 2) NULL DEFAULT NULL COMMENT '基本工资',
  `post_salary` decimal(10, 2) NULL DEFAULT NULL COMMENT '岗位工资',
  `deduction_absenteeism` decimal(10, 2) NULL DEFAULT NULL COMMENT '入离职缺勤扣款',
  `sick_leave_deductions` decimal(10, 2) NULL DEFAULT NULL COMMENT '病假扣款',
  `deduction_personal_leave` decimal(10, 2) NULL DEFAULT NULL COMMENT '事假扣款',
  `forget_clock_deduct` decimal(10, 2) NULL DEFAULT NULL COMMENT '忘记打卡扣款',
  `performance_score` decimal(10, 2) NULL DEFAULT NULL COMMENT '绩效得分',
  `performance_pay` decimal(10, 2) NULL DEFAULT NULL COMMENT '绩效工资',
  `payable_wages` decimal(10, 2) NULL DEFAULT NULL COMMENT '应发合计',
  `social_security_individuals` decimal(10, 2) NULL DEFAULT NULL COMMENT '社保个人',
  `social_security_companies` decimal(10, 2) NULL DEFAULT NULL COMMENT '社保公司',
  `social_security_total` decimal(10, 2) NULL DEFAULT NULL COMMENT '社保合计',
  `provident_fund_individuals` decimal(10, 2) NULL DEFAULT NULL COMMENT '公积金个人',
  `provident_fund_company` decimal(10, 2) NULL DEFAULT NULL COMMENT '公积金公司',
  `provident_fund_total` decimal(10, 2) NULL DEFAULT NULL COMMENT '公积金合计',
  `taxable_waget` decimal(10, 2) NULL DEFAULT NULL COMMENT '应税工资',
  `personal_income_tax` decimal(10, 2) NULL DEFAULT NULL COMMENT '个人所得税',
  `actual_wages` decimal(10, 2) NULL DEFAULT NULL COMMENT '实发工资',
  `create_user` int NULL DEFAULT NULL COMMENT '创建者',
  `update_user` int NULL DEFAULT NULL COMMENT '修改者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '薪酬绩效' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for custom_storage
-- ----------------------------
DROP TABLE IF EXISTS `custom_storage`;
CREATE TABLE `custom_storage`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT 'id',
  `item_type` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '物品类型',
  `inbound_date` date NULL DEFAULT NULL COMMENT '入库时间',
  `inbound_batches` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '入库批次',
  `inbound_num` decimal(10, 2) NULL DEFAULT NULL COMMENT '入库数量',
  `supplier_name` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '供应商名称',
  `product_category` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '产品大类',
  `specification_model` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '规格型号',
  `unit` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '单位',
  `tax_inclusive_unit_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '含税单价',
  `tax_inclusive_total_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '含税总价',
  `tax_rate` decimal(10, 2) NULL DEFAULT NULL COMMENT '税率(%)',
  `tax_exclusive_total_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '不含税总价',
  `create_by` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '入库人',
  `create_time` datetime NULL DEFAULT NULL,
  `update_time` datetime NULL DEFAULT NULL,
  `create_user` int NULL DEFAULT NULL,
  `update_user` int NULL DEFAULT NULL,
  `tenant_id` bigint NULL DEFAULT NULL,
  `code` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '编号',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for customer
-- ----------------------------
DROP TABLE IF EXISTS `customer`;
CREATE TABLE `customer`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `customer_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '客户名称',
  `taxpayer_identification_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '纳税人识别号',
  `company_address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '公司地址',
  `company_phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '公司电话',
  `contact_person` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '联系人',
  `contact_phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '联系电话',
  `maintainer` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '维护人',
  `maintenance_time` date NOT NULL COMMENT '维护时间',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `basic_bank_account` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '银行基本户',
  `bank_account` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '银行账号',
  `bank_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '开户行号',
  `customer_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '客户分类：零售客户，进销商客户',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `usage_user` int NULL DEFAULT NULL COMMENT '使用用户',
  `usage_status` int NULL DEFAULT NULL COMMENT '使用状态',
  `type` smallint NOT NULL DEFAULT 0 COMMENT '类型 0 私海客户 1 公海客户',
  `is_assigned` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否被分配：0-未分配，1-已分配',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 427 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '客户档案' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for customer_follow_up
-- ----------------------------
DROP TABLE IF EXISTS `customer_follow_up`;
CREATE TABLE `customer_follow_up`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `follow_up_method` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '跟进方式',
  `follow_up_level` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '跟进程度',
  `follow_up_time` datetime NOT NULL COMMENT '跟进时间',
  `follower_user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '跟进人姓名',
  `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '跟进内容',
  `follower_user_id` bigint NULL DEFAULT NULL COMMENT '跟进人ID',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `customer_id` bigint NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_tenant_id`(`tenant_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '客户跟进进度表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for customer_follow_up_file
-- ----------------------------
DROP TABLE IF EXISTS `customer_follow_up_file`;
CREATE TABLE `customer_follow_up_file`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `follow_up_id` int NULL DEFAULT NULL COMMENT '跟进记录ID',
  `file_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '文件名称',
  `file_url` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '文件访问地址',
  `file_size` bigint NULL DEFAULT NULL COMMENT '文件大小',
  `file_suffix` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '文件后缀',
  `create_user` bigint NULL DEFAULT NULL COMMENT '上传者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_follow_up_id`(`follow_up_id` ASC) USING BTREE COMMENT '跟进记录ID索引'
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '客户跟进附件表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for customer_private
-- ----------------------------
DROP TABLE IF EXISTS `customer_private`;
CREATE TABLE `customer_private`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `customer_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '客户名称',
  `taxpayer_identification_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '纳税人识别号',
  `company_address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '公司地址',
  `company_phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '公司电话',
  `contact_person` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '联系人',
  `contact_phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '联系电话',
  `maintainer` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '维护人',
  `maintenance_time` date NOT NULL COMMENT '维护时间',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `basic_bank_account` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '银行基本户',
  `bank_account` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '银行账号',
  `bank_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '开户行号',
  `customer_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '客户分类：零售客户，进销商客户',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `usage_user` int NULL DEFAULT NULL,
  `usage_status` int NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '客户档案' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for customer_private_pool
-- ----------------------------
DROP TABLE IF EXISTS `customer_private_pool`;
CREATE TABLE `customer_private_pool`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `customer_id` bigint NULL DEFAULT NULL COMMENT '客户id',
  `bound_id` bigint NULL DEFAULT NULL COMMENT '绑定人id',
  `create_user` int NULL DEFAULT NULL COMMENT '创建人',
  `update_user` int NULL DEFAULT NULL COMMENT '更新人',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
  `dept_id` int NULL DEFAULT NULL,
  `type` int NULL DEFAULT 0 COMMENT '类型区分公海客户和私海客户 默认是私海客户0 公海1',
  `delete_flag` int NULL DEFAULT 0 COMMENT '删除标志',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '私海客户' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for customer_return_visit
-- ----------------------------
DROP TABLE IF EXISTS `customer_return_visit`;
CREATE TABLE `customer_return_visit`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `is_enabled` tinyint(1) NULL DEFAULT 1 COMMENT '提醒开关 (0:关闭, 1:开启)',
  `content` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '提醒内容',
  `reminder_time` datetime NOT NULL COMMENT '提醒时间',
  `is_completed` tinyint(1) NULL DEFAULT 0 COMMENT '处理状态 (0:待提醒, 1:已提醒)',
  `remind_user_id` bigint NOT NULL COMMENT '接收提醒的用户ID',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `customer_id` bigint NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_remind_user`(`remind_user_id` ASC, `is_completed` ASC) USING BTREE COMMENT '用户待办查询索引'
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '客户回访提醒表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for customer_user
-- ----------------------------
DROP TABLE IF EXISTS `customer_user`;
CREATE TABLE `customer_user`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `customer_id` bigint NOT NULL DEFAULT 0 COMMENT '客户id',
  `user_id` bigint NOT NULL DEFAULT 0 COMMENT '用户id',
  `create_time` datetime NULL DEFAULT NULL COMMENT '录入时间',
  `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户id',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for customer_visits
-- ----------------------------
DROP TABLE IF EXISTS `customer_visits`;
CREATE TABLE `customer_visits`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT 'id',
  `customer_name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '客户名称',
  `contact` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '联系人',
  `contact_phone` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '联系电话',
  `location` varchar(150) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '位置',
  `visiting_people` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '拜访人',
  `purpose_visit` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '拜访目的',
  `purpose_date` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '拜访时间',
  `visit_address` varchar(150) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '拜访地址',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '备注',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建者id',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改者id',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '客户拜访登记' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for device_defect_record
-- ----------------------------
DROP TABLE IF EXISTS `device_defect_record`;
CREATE TABLE `device_defect_record`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `device_ledger_id` bigint NOT NULL COMMENT '设备台账id',
  `defect_description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '描述',
  `eliminate_time` datetime NULL DEFAULT NULL COMMENT '消缺时间',
  `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '设备状态',
  `create_user` int NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` int NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `tenant_id` int NULL DEFAULT NULL COMMENT '租户id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备缺陷记录表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for device_ledger
-- ----------------------------
DROP TABLE IF EXISTS `device_ledger`;
CREATE TABLE `device_ledger`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `device_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '设备名称',
  `device_model` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '规格型号',
  `supplier_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供应商',
  `unit` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '单位',
  `number` decimal(10, 0) NULL DEFAULT NULL COMMENT '数量',
  `tax_including_price_unit` decimal(10, 0) NULL DEFAULT NULL COMMENT '含税单价',
  `tax_including_price_total` decimal(10, 0) NULL DEFAULT NULL COMMENT '含税总价',
  `tax_rate` decimal(10, 0) NULL DEFAULT NULL COMMENT '税率',
  `un_tax_including_price_total` decimal(10, 0) NULL DEFAULT NULL COMMENT '不含税总价',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '录入时间',
  `update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
  `create_user` int NULL DEFAULT NULL COMMENT '录入人',
  `update_user` int NULL DEFAULT NULL COMMENT '更新人',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户id',
  `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '设备状态',
  `plan_runtime_time` date NULL DEFAULT NULL COMMENT '计划运行时间',
  `start_runtime_time` datetime NULL DEFAULT NULL COMMENT '开始运行时间',
  `end_runtime_time` datetime NULL DEFAULT NULL COMMENT '结束运行时间',
  `runtime_duration` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '运行时长',
  `device_brand` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '设备品牌',
  `storage_location` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '存放位置',
  `is_depr` int NULL DEFAULT NULL COMMENT '是否折旧 1-是 2-否',
  `annual_depreciation_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '每年折旧金额',
  `type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '设备类型',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 18 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for device_maintenance
-- ----------------------------
DROP TABLE IF EXISTS `device_maintenance`;
CREATE TABLE `device_maintenance`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `device_ledger_id` bigint NOT NULL COMMENT '设备台账id',
  `maintenance_plan_time` timestamp NULL DEFAULT NULL COMMENT '计划保养日期',
  `maintenance_actually_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '实际保养人',
  `maintenance_actually_time` timestamp NULL DEFAULT NULL COMMENT '实际保养日期',
  `status` int NOT NULL DEFAULT 0 COMMENT '状态 0 待保养 1 完结',
  `create_time` datetime NULL DEFAULT NULL COMMENT '录入时间',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `create_user` int NOT NULL COMMENT '录入人',
  `update_user` int NOT NULL COMMENT '更新人',
  `tenant_id` bigint NOT NULL COMMENT '租户id',
  `device_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `device_model` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `maintenance_result` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '保养结果',
  `maintenance_task_id` int NULL DEFAULT NULL COMMENT '保养任务id',
  `frequency_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '频次',
  `frequency_detail` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '频次详情',
  `next_execution_time` timestamp NULL DEFAULT NULL COMMENT '下次执行时间',
  `last_execution_time` timestamp NULL DEFAULT NULL COMMENT '最后执行时间',
  `spare_parts_ids` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `machinery_category` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 39 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for device_maintenance_file
-- ----------------------------
DROP TABLE IF EXISTS `device_maintenance_file`;
CREATE TABLE `device_maintenance_file`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '文件名称',
  `url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '文件路径',
  `file_size` int NULL DEFAULT NULL COMMENT '文件大小',
  `device_maintenance_id` int NULL DEFAULT NULL COMMENT '设备保养记录ID',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备保养附件' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for device_repair
-- ----------------------------
DROP TABLE IF EXISTS `device_repair`;
CREATE TABLE `device_repair`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `device_ledger_id` bigint NOT NULL COMMENT '设备台账id',
  `repair_time` timestamp NULL DEFAULT NULL COMMENT '报修日期',
  `repair_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '报修人',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '故障现象',
  `maintenance_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '维修人',
  `maintenance_time` timestamp NULL DEFAULT NULL COMMENT '维修时间',
  `maintenance_result` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '维修结果',
  `status` int NULL DEFAULT 0 COMMENT '状态',
  `create_time` datetime NULL DEFAULT NULL COMMENT '录入时间',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `create_user` int NOT NULL COMMENT '录入人',
  `update_user` int NULL DEFAULT NULL COMMENT '更新人',
  `tenant_id` bigint NOT NULL COMMENT '租户id',
  `device_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `device_model` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `maintenance_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '维修价格',
  `approver_id` int NULL DEFAULT NULL COMMENT '审批人id',
  `spare_parts_ids` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `machinery_category` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `acceptance_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '验收人',
  `acceptance_time` datetime NULL DEFAULT NULL COMMENT '验收时间',
  `acceptance_remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '验收备注',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 25 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for device_runtime
-- ----------------------------
DROP TABLE IF EXISTS `device_runtime`;
CREATE TABLE `device_runtime`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `device_ledger_id` bigint NOT NULL COMMENT '设备台账id',
  `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '设备状态',
  `plan_runtime_time` datetime NULL DEFAULT NULL COMMENT '计划运行时间',
  `start_runtime_time` datetime NULL DEFAULT NULL COMMENT '开始运行时间',
  `end_runtime_time` datetime NULL DEFAULT NULL COMMENT '结束运行时间',
  `runtime_duration` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '运行时长',
  `create_user` int NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` int NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `tenant_id` int NULL DEFAULT NULL COMMENT '租户id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备运行表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for document_classification
-- ----------------------------
DROP TABLE IF EXISTS `document_classification`;
CREATE TABLE `document_classification`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `category` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '类别名称',
  `parent_id` bigint NULL DEFAULT NULL COMMENT '父类id',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '文档分类表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for documentation
-- ----------------------------
DROP TABLE IF EXISTS `documentation`;
CREATE TABLE `documentation`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `document_classification_id` bigint NULL DEFAULT NULL COMMENT '类别名称id',
  `doc_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '文档名称',
  `doc_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '文档编号',
  `year` bigint NULL DEFAULT NULL COMMENT '年份',
  `responsible_person` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '责任人',
  `warehouse_goods_shelves_rowcol_id` bigint NULL DEFAULT NULL COMMENT '文档放置货架id',
  `doc_date` datetime NULL DEFAULT NULL COMMENT '文档日期',
  `retention_period` bigint NULL DEFAULT NULL COMMENT '保管期限',
  `security_level` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '保密级别(绝密，一般)',
  `copy_count` bigint NULL DEFAULT NULL COMMENT '份数',
  `page_count` bigint NULL DEFAULT NULL COMMENT '页数',
  `doc_category` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '文档类别',
  `doc_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '文档种类',
  `urgency_level` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '紧急程度(紧急，普通)',
  `doc_status` 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 '备注',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '文档信息表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for documentation_borrow_management
-- ----------------------------
DROP TABLE IF EXISTS `documentation_borrow_management`;
CREATE TABLE `documentation_borrow_management`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `documentation_id` bigint NULL DEFAULT NULL COMMENT '文档id',
  `borrower` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '借阅人',
  `borrow_purpose` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '借阅目的',
  `borrow_date` datetime NULL DEFAULT NULL COMMENT '借阅日期',
  `due_return_date` datetime NULL DEFAULT NULL COMMENT '应归还日期',
  `returner` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '归还人',
  `return_date` datetime NULL DEFAULT NULL COMMENT '实际归还日期',
  `borrow_status` 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 '备注',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '文档借阅表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for documentation_file
-- ----------------------------
DROP TABLE IF EXISTS `documentation_file`;
CREATE TABLE `documentation_file`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '文件名称',
  `url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '文件路径',
  `file_size` bigint NULL DEFAULT NULL COMMENT '文件大小',
  `documentation_id` bigint NULL DEFAULT NULL COMMENT '文档ID',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '文档--附件' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for documentation_return_management
-- ----------------------------
DROP TABLE IF EXISTS `documentation_return_management`;
CREATE TABLE `documentation_return_management`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `documentation_id` bigint NULL DEFAULT NULL COMMENT '文档id',
  `borrow_id` bigint NULL DEFAULT NULL COMMENT '借阅id',
  `borrower` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '借阅人',
  `borrow_purpose` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '借阅目的',
  `borrow_date` datetime NULL DEFAULT NULL COMMENT '借阅日期',
  `due_return_date` datetime NULL DEFAULT NULL COMMENT '应归还日期',
  `returner` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '归还人',
  `return_date` datetime NULL DEFAULT NULL COMMENT '实际归还日期',
  `borrow_status` 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 '备注',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '文档归还表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for duty_plan
-- ----------------------------
DROP TABLE IF EXISTS `duty_plan`;
CREATE TABLE `duty_plan`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '计划标题',
  `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '计划描述',
  `level` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '计划级别',
  `period` 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 '结束时间',
  `assignee` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '负责人',
  `priority` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '优先级',
  `tags` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '标签',
  `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '状态',
  `progress` int NULL DEFAULT NULL COMMENT '完成度',
  `create_user` int NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` int NULL DEFAULT NULL COMMENT '修改者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `tenant_id` int NULL DEFAULT NULL COMMENT '租户id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '值班与计划' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for electricity_consumption_area
-- ----------------------------
DROP TABLE IF EXISTS `electricity_consumption_area`;
CREATE TABLE `electricity_consumption_area`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  `area_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '区域名称',
  `area_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '区域类型',
  `sort` bigint NULL DEFAULT NULL COMMENT '排序',
  `fu_id` int NULL DEFAULT NULL COMMENT '父类id',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户id',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '用电区域' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for energy_period
-- ----------------------------
DROP TABLE IF EXISTS `energy_period`;
CREATE TABLE `energy_period`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `date` date NULL DEFAULT NULL COMMENT '日期',
  `price` decimal(10, 2) NULL DEFAULT NULL COMMENT '时段单价 (元 / 度)',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户id',
  `peak` decimal(10, 2) NULL DEFAULT NULL COMMENT '峰段',
  `flat` decimal(10, 2) NULL DEFAULT NULL COMMENT '平段',
  `valley` decimal(10, 2) NULL DEFAULT NULL COMMENT '谷段',
  `sharp` decimal(10, 2) NULL DEFAULT NULL COMMENT '尖段',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '用电时段表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for enterprise_news
-- ----------------------------
DROP TABLE IF EXISTS `enterprise_news`;
CREATE TABLE `enterprise_news`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
  `title` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '标题',
  `summary` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '摘要',
  `content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '正文',
  `category` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '分类',
  `read_scope` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'all' COMMENT '阅读范围 all全员 dept部门 custom自定义',
  `is_required` tinyint NOT NULL DEFAULT 0 COMMENT '是否必读 0否 1是',
  `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '状态 0草稿 1已发布 2已下线',
  `required_read_count` int NOT NULL DEFAULT 0 COMMENT '需要阅读的数量',
  `read_count` int NOT NULL DEFAULT 0 COMMENT '已经阅读的数量',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_enterprise_news_status`(`status` ASC) USING BTREE,
  INDEX `idx_enterprise_news_category`(`category` ASC) USING BTREE,
  INDEX `idx_enterprise_news_dept_id`(`dept_id` ASC) USING BTREE,
  INDEX `idx_enterprise_news_create_time`(`create_time` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '企业新闻表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for enterprise_news_scope_dept
-- ----------------------------
DROP TABLE IF EXISTS `enterprise_news_scope_dept`;
CREATE TABLE `enterprise_news_scope_dept`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
  `news_id` bigint NOT NULL COMMENT '企业新闻ID',
  `dept_id` bigint NOT NULL COMMENT '部门ID',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_enterprise_news_scope_dept`(`news_id` ASC, `dept_id` ASC) USING BTREE,
  INDEX `idx_enterprise_news_scope_dept_dept_id`(`dept_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '企业新闻阅读范围部门表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for enterprise_news_scope_user
-- ----------------------------
DROP TABLE IF EXISTS `enterprise_news_scope_user`;
CREATE TABLE `enterprise_news_scope_user`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
  `news_id` bigint NOT NULL COMMENT '企业新闻ID',
  `user_id` bigint NOT NULL COMMENT '用户ID',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_enterprise_news_scope_user`(`news_id` ASC, `user_id` ASC) USING BTREE,
  INDEX `idx_enterprise_news_scope_user_user_id`(`user_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '企业新闻阅读范围用户表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for equipment_energy_consumption
-- ----------------------------
DROP TABLE IF EXISTS `equipment_energy_consumption`;
CREATE TABLE `equipment_energy_consumption`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '设备编号',
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '设备名称',
  `power_rating` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '额定功率',
  `power_actual` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '实际功率',
  `day_num` decimal(18, 2) NULL DEFAULT 0.00 COMMENT '当日用电量',
  `sum_num` decimal(18, 2) NULL DEFAULT 0.00 COMMENT '累计用电量',
  `every_num` decimal(18, 2) NULL DEFAULT 0.00 COMMENT '每日限制电量',
  `run_date` date NULL DEFAULT NULL COMMENT '运行时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `tenant_id` int NULL DEFAULT NULL COMMENT '租户id',
  `electricity_consumption_area_id` bigint NULL DEFAULT NULL COMMENT '区域id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '设备能耗' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for file_sharing
-- ----------------------------
DROP TABLE IF EXISTS `file_sharing`;
CREATE TABLE `file_sharing`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '共享标题',
  `departments` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '接收部门',
  `files` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '上传文件',
  `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '共享描述',
  `create_user` int NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` int NULL DEFAULT NULL COMMENT '修改者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `tenant_id` int NULL DEFAULT NULL COMMENT '租户id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '行政管理-通知管理-文件共享' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for fin_fixed_asset
-- ----------------------------
DROP TABLE IF EXISTS `fin_fixed_asset`;
CREATE TABLE `fin_fixed_asset`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `asset_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '资产编号',
  `asset_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '资产名称',
  `category` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '资产类别',
  `specification` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '规格型号',
  `purchase_date` date NOT NULL COMMENT '购置日期',
  `original_value` decimal(18, 2) NOT NULL DEFAULT 0.00 COMMENT '资产原值',
  `useful_life` int NOT NULL DEFAULT 1 COMMENT '使用年限(年)',
  `residual_rate` decimal(18, 2) NOT NULL DEFAULT 0.00 COMMENT '残值率(%)',
  `accumulated_depreciation` decimal(18, 2) NOT NULL DEFAULT 0.00 COMMENT '累计折旧',
  `net_value` decimal(18, 2) NOT NULL DEFAULT 0.00 COMMENT '净值',
  `location` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '存放地点',
  `department` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '使用部门',
  `keeper` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '保管人',
  `status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'in_use' COMMENT '状态: in_use/idle/repair/scrapped',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `create_user` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_user` 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 '修改时间',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_fin_fixed_asset_code`(`asset_code` ASC) USING BTREE,
  INDEX `idx_fin_fixed_asset_status`(`status` ASC) USING BTREE,
  INDEX `idx_fin_fixed_asset_category`(`category` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '固定资产' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for fin_intangible_asset
-- ----------------------------
DROP TABLE IF EXISTS `fin_intangible_asset`;
CREATE TABLE `fin_intangible_asset`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `asset_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '资产编号',
  `asset_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '资产名称',
  `category` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '资产类别',
  `certificate_no` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '证书编号',
  `acquisition_date` date NOT NULL COMMENT '取得日期',
  `original_value` decimal(18, 2) NOT NULL DEFAULT 0.00 COMMENT '资产原值',
  `amortization_period` int NOT NULL DEFAULT 1 COMMENT '摊销年限(年)',
  `residual_rate` decimal(18, 2) NOT NULL DEFAULT 0.00 COMMENT '残值率(%)',
  `accumulated_amortization` decimal(18, 2) NOT NULL DEFAULT 0.00 COMMENT '累计摊销',
  `net_value` decimal(18, 2) NOT NULL DEFAULT 0.00 COMMENT '净值',
  `validity_date` date NULL DEFAULT NULL COMMENT '有效期至',
  `status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'in_use' COMMENT '状态: in_use/expired/amortized',
  `description` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '资产描述',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `create_user` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_user` 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 '修改时间',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_fin_intangible_asset_code`(`asset_code` ASC) USING BTREE,
  INDEX `idx_fin_intangible_asset_status`(`status` ASC) USING BTREE,
  INDEX `idx_fin_intangible_asset_category`(`category` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '无形资产' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for fin_reimbursement
-- ----------------------------
DROP TABLE IF EXISTS `fin_reimbursement`;
CREATE TABLE `fin_reimbursement`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `bill_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '报销单号',
  `reimbursement_type` tinyint NOT NULL COMMENT '报销类型：1-差旅报销，2-费用报销',
  `expense_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '费用类型：差旅费/办公采购/业务招待/交通费/通讯费/其他',
  `applicant_id` bigint NOT NULL COMMENT '申请人ID',
  `applicant_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '员工编号',
  `applicant_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '员工姓名',
  `applicant_dept_id` bigint NULL DEFAULT NULL COMMENT '申请部门ID',
  `applicant_dept_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '申请部门名称',
  `reason` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '报销原因',
  `apply_amount` decimal(18, 4) NOT NULL DEFAULT 0.0000 COMMENT '申请金额',
  `detail_total_amount` decimal(18, 4) NOT NULL DEFAULT 0.0000 COMMENT '明细汇总金额',
  `payee_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '收款人',
  `payee_account` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '收款账号',
  `payee_bank` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '开户支行',
  `approval_instance_id` bigint NULL DEFAULT NULL COMMENT '审批实例ID，对应 approval_instance.id',
  `approve_process_id` bigint NULL DEFAULT NULL COMMENT '审批流程ID，对应 approve_process.id',
  `bill_status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'DRAFT' COMMENT '单据状态：DRAFT-草稿，IN_APPROVAL-审批中，APPROVED-审批通过，REJECTED-审批驳回，WITHDRAWN-已撤回，PAID-已付款',
  `approved_time` datetime NULL DEFAULT NULL COMMENT '审批通过时间',
  `paid_time` datetime NULL DEFAULT NULL COMMENT '付款时间',
  `account_expense_id` bigint NULL DEFAULT NULL COMMENT '生成的财务支出记录ID，对应 account_expense.id',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '归属部门ID',
  `deleted` tinyint NOT NULL DEFAULT 0 COMMENT '逻辑删除：0-否，1-是',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_fin_reimbursement_bill_no`(`bill_no` ASC) USING BTREE,
  INDEX `idx_fin_reimbursement_type_status`(`reimbursement_type` ASC, `bill_status` ASC) USING BTREE,
  INDEX `idx_fin_reimbursement_applicant`(`applicant_id` ASC) USING BTREE,
  INDEX `idx_fin_reimbursement_approval_instance`(`approval_instance_id` ASC) USING BTREE,
  INDEX `idx_fin_reimbursement_apply_amount`(`apply_amount` ASC) USING BTREE,
  INDEX `idx_fin_reimbursement_create_time`(`create_time` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 8 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '报销单主表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for fin_reimbursement_detail
-- ----------------------------
DROP TABLE IF EXISTS `fin_reimbursement_detail`;
CREATE TABLE `fin_reimbursement_detail`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `reimbursement_id` bigint NOT NULL COMMENT '报销单ID，对应 fin_reimbursement.id',
  `row_no` int NOT NULL DEFAULT 1 COMMENT '明细行号',
  `invoice_date` date NULL DEFAULT NULL COMMENT '发票日期',
  `expense_category` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '费用科目',
  `amount` decimal(18, 2) NOT NULL DEFAULT 0.00 COMMENT '金额',
  `description` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '描述',
  `invoice_no` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '发票号码',
  `invoice_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '发票类型',
  `invoice_amount` decimal(18, 2) NULL DEFAULT NULL COMMENT '票面金额',
  `tax_rate` decimal(8, 2) NULL DEFAULT NULL COMMENT '税率',
  `tax_amount` decimal(18, 2) NULL DEFAULT NULL COMMENT '税额',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '归属部门ID',
  `deleted` tinyint NOT NULL DEFAULT 0 COMMENT '逻辑删除：0-否，1-是',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_fin_reimbursement_detail_reimbursement`(`reimbursement_id` ASC) USING BTREE,
  INDEX `idx_fin_reimbursement_detail_category`(`expense_category` ASC) USING BTREE,
  INDEX `idx_fin_reimbursement_detail_invoice_date`(`invoice_date` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 19 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '报销单明细表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for fin_reimbursement_travel
-- ----------------------------
DROP TABLE IF EXISTS `fin_reimbursement_travel`;
CREATE TABLE `fin_reimbursement_travel`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `reimbursement_id` bigint NOT NULL COMMENT '报销单ID，对应 fin_reimbursement.id',
  `start_time` datetime NOT NULL COMMENT '出差开始时间',
  `end_time` datetime NOT NULL COMMENT '出差结束时间',
  `travel_days` decimal(8, 2) NULL DEFAULT NULL COMMENT '出差天数',
  `departure_city` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '出差地/出发城市',
  `destination_city` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '目的地/目的城市',
  `hotel_standard` decimal(18, 4) NULL DEFAULT 0.0000 COMMENT '酒店标准',
  `lodging_days` decimal(8, 4) NULL DEFAULT 0.0000 COMMENT '住宿天数',
  `meal_allowance` decimal(18, 4) NULL DEFAULT 0.0000 COMMENT '生活补贴',
  `transport_allowance` decimal(18, 4) NULL DEFAULT 0.0000 COMMENT '交通补贴',
  `lodging_limit` decimal(18, 4) NULL DEFAULT 0.0000 COMMENT '住宿限额',
  `standard_tag` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '特批标记文本，如在标准范围内/超标特批',
  `within_standard` tinyint NOT NULL DEFAULT 1 COMMENT '是否在标准内：1-是，0-否',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '归属部门ID',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_fin_reimbursement_travel_reimbursement`(`reimbursement_id` ASC) USING BTREE,
  INDEX `idx_fin_reimbursement_travel_start_end`(`start_time` ASC, `end_time` ASC) USING BTREE,
  INDEX `idx_fin_reimbursement_travel_city`(`departure_city` ASC, `destination_city` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '差旅报销扩展表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for fin_voucher
-- ----------------------------
DROP TABLE IF EXISTS `fin_voucher`;
CREATE TABLE `fin_voucher`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `voucher_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '凭证字号',
  `voucher_date` date NOT NULL COMMENT '凭证日期',
  `summary` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '摘要',
  `debit` decimal(18, 2) NOT NULL DEFAULT 0.00 COMMENT '借方合计',
  `credit` decimal(18, 2) NOT NULL DEFAULT 0.00 COMMENT '贷方合计',
  `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '制单人',
  `status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'unposted' COMMENT '状态: unposted/posted/cancelled',
  `attachment_count` int NOT NULL DEFAULT 0 COMMENT '附件张数',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `create_user` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_user` 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 '修改时间',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_fin_voucher_no`(`voucher_no` ASC) USING BTREE,
  INDEX `idx_fin_voucher_date`(`voucher_date` ASC) USING BTREE,
  INDEX `idx_fin_voucher_status`(`status` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '凭证主表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for fin_voucher_entry
-- ----------------------------
DROP TABLE IF EXISTS `fin_voucher_entry`;
CREATE TABLE `fin_voucher_entry`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `voucher_id` bigint NOT NULL COMMENT '凭证ID',
  `row_no` int NOT NULL DEFAULT 1 COMMENT '行号',
  `subject_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '科目编码',
  `subject_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '科目名称',
  `summary` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '摘要',
  `debit` decimal(18, 2) NOT NULL DEFAULT 0.00 COMMENT '借方金额',
  `credit` decimal(18, 2) NOT NULL DEFAULT 0.00 COMMENT '贷方金额',
  `auxiliary_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '辅助核算类型',
  `auxiliary_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '辅助核算对象ID',
  `auxiliary_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '辅助核算对象名称',
  `create_user` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_user` 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 '修改时间',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_fin_voucher_entry_voucher`(`voucher_id` ASC) USING BTREE,
  INDEX `idx_fin_voucher_entry_subject`(`subject_code` ASC) USING BTREE,
  INDEX `idx_fin_voucher_entry_aux`(`auxiliary_type` ASC, `auxiliary_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '凭证分录' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for gas_tank_warning
-- ----------------------------
DROP TABLE IF EXISTS `gas_tank_warning`;
CREATE TABLE `gas_tank_warning`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `tank_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '储气罐编码',
  `tank_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '储气罐名称',
  `tank_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '储气罐类型',
  `specification_model` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '规格型号',
  `volume` bigint NULL DEFAULT NULL COMMENT '容积(m³)',
  `current_gas_level` bigint NULL DEFAULT NULL COMMENT '当前气体量',
  `safety_gas_level` bigint NULL DEFAULT NULL COMMENT '安全气体量',
  `min_gas_level` bigint NULL DEFAULT NULL COMMENT '最低气体量',
  `max_gas_level` bigint NULL DEFAULT NULL COMMENT '最高气体量',
  `current_pressure` decimal(10, 1) NULL DEFAULT NULL COMMENT '当前压力(MPa)',
  `warning_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '预警类型',
  `warning_level` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '预警级别',
  `warning_threshold` bigint NULL DEFAULT NULL COMMENT '预警阈值',
  `is_enabled` int NULL DEFAULT NULL COMMENT '是否启用',
  `warning_time` datetime NULL DEFAULT NULL COMMENT '预警时间',
  `warning_duration` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '预警持续天数',
  `last_update_time` datetime NULL DEFAULT NULL COMMENT '最后更新时间',
  `expected_refill_time` datetime NULL DEFAULT NULL COMMENT '预计充装时间',
  `expected_shortage_time` datetime NULL DEFAULT NULL COMMENT '预计缺气时间',
  `warning_rule` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '当???时触发预警-预警规则',
  `create_user` int NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` int NULL DEFAULT NULL COMMENT '修改者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `tenant_id` int NULL DEFAULT NULL COMMENT '租户id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '库存预警-气罐警告' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for gen_table
-- ----------------------------
DROP TABLE IF EXISTS `gen_table`;
CREATE TABLE `gen_table`  (
  `table_id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
  `table_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '表名称',
  `table_comment` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '表描述',
  `sub_table_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '关联子表的表名',
  `sub_table_fk_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '子表关联的外键名',
  `class_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '实体类名称',
  `tpl_category` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT 'crud' COMMENT '使用的模板（crud单表操作 tree树表操作）',
  `tpl_web_type` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '前端模板类型（element-ui模版 element-plus模版）',
  `package_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '生成包路径',
  `module_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '生成模块名',
  `business_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '生成业务名',
  `function_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '生成功能名',
  `function_author` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '生成功能作者',
  `gen_type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '0' COMMENT '生成代码方式（0zip压缩包 1自定义路径）',
  `gen_path` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '/' COMMENT '生成路径（不填默认项目路径）',
  `options` varchar(1000) 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 '' 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 '更新时间',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`table_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_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 AUTO_INCREMENT COMMENT '编号',
  `table_id` bigint NULL DEFAULT NULL COMMENT '归属表编号',
  `column_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '列名称',
  `column_comment` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '列描述',
  `column_type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '列类型',
  `java_type` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'JAVA类型',
  `java_field` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'JAVA字段名',
  `is_pk` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '是否主键（1是）',
  `is_increment` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '是否自增（1是）',
  `is_required` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '是否必填（1是）',
  `is_insert` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '是否为插入字段（1是）',
  `is_edit` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '是否编辑字段（1是）',
  `is_list` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '是否列表字段（1是）',
  `is_query` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '是否查询字段（1是）',
  `query_type` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT 'EQ' COMMENT '查询方式（等于、不等于、大于、小于、范围）',
  `html_type` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '显示类型（文本框、文本域、下拉框、复选框、单选框、日期控件）',
  `dict_type` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '字典类型',
  `sort` int NULL DEFAULT NULL COMMENT '排序',
  `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 '更新时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`column_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '代码生成业务表字段' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for holiday_application
-- ----------------------------
DROP TABLE IF EXISTS `holiday_application`;
CREATE TABLE `holiday_application`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `staff_id` int NULL DEFAULT NULL COMMENT '员工id',
  `type` 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 '结束日期',
  `days` int NULL DEFAULT NULL COMMENT '天数',
  `reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '申请原因',
  `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '状态',
  `tenant_id` int NULL DEFAULT NULL COMMENT '租户id',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '假期申请' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for holiday_settings
-- ----------------------------
DROP TABLE IF EXISTS `holiday_settings`;
CREATE TABLE `holiday_settings`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '假期名称',
  `type` 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 '结束日期',
  `days` int NULL DEFAULT NULL COMMENT '天数',
  `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '状态',
  `create_user` int NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` int NULL DEFAULT NULL COMMENT '修改者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `tenant_id` int NULL DEFAULT NULL COMMENT '租户id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '假期设置' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for inbound_management
-- ----------------------------
DROP TABLE IF EXISTS `inbound_management`;
CREATE TABLE `inbound_management`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '序号',
  `order_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '订单号',
  `arrival_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '到货单号',
  `supplier_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供应商名称',
  `status` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '到货状态',
  `arrival_time` datetime NULL DEFAULT NULL COMMENT '到货时间',
  `arrival_quantity` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '到货数量',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '备注',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_user` int NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
  `update_user` int NULL DEFAULT NULL COMMENT '修改用户',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '采购到货表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for inspection_task
-- ----------------------------
DROP TABLE IF EXISTS `inspection_task`;
CREATE TABLE `inspection_task`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '巡检任务唯一标识',
  `task_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '设备名称',
  `inspection_project` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '巡检项目',
  `task_id` int NULL DEFAULT NULL COMMENT '设备id',
  `inspector_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `inspector` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '执行巡检的人员姓名',
  `remarks` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '任务附加说明或特殊情况记录',
  `inspection_result` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '巡检结果 0异常 1正常',
  `abnormal_description` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '异常描述',
  `device_repair_id` bigint NULL DEFAULT NULL COMMENT '关联维修单ID',
  `acceptance_user_id` bigint NULL DEFAULT NULL COMMENT '验收人ID',
  `acceptance_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '验收人',
  `registrant_id` bigint NULL DEFAULT NULL,
  `registrant` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '任务登记人姓名',
  `frequency_type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '频次',
  `inspection_location` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '巡检地点详细描述',
  `frequency_detail` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '时间细节',
  `deleted` int NOT NULL DEFAULT 0 COMMENT '软删除标志，0=未删除，1=已删除',
  `create_user` int NULL DEFAULT NULL COMMENT '创建该记录的用户',
  `create_time` datetime(6) NULL DEFAULT NULL COMMENT '记录创建时间',
  `update_user` int NULL DEFAULT NULL COMMENT '最后修改该记录的用户',
  `update_time` datetime(6) NULL DEFAULT NULL COMMENT '记录最后更新时间',
  `tenant_id` int NULL DEFAULT NULL COMMENT '租户',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_inspection_task_device_repair_id`(`device_repair_id` ASC) USING BTREE,
  INDEX `idx_inspection_task_inspection_result`(`inspection_result` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 22 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '巡检任务表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for invoice_ledger
-- ----------------------------
DROP TABLE IF EXISTS `invoice_ledger`;
CREATE TABLE `invoice_ledger`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `invoice_registration_product_id` bigint NULL DEFAULT NULL COMMENT '产品开票登记记录表主键',
  `invoice_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '发票号',
  `invoice_total` decimal(10, 2) NULL DEFAULT NULL COMMENT '发票金额',
  `invoice_person` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '开票人',
  `invoice_date` datetime NULL DEFAULT NULL COMMENT '开票日期',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 666 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '开票台账' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for invoice_ledger_file
-- ----------------------------
DROP TABLE IF EXISTS `invoice_ledger_file`;
CREATE TABLE `invoice_ledger_file`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '文件名称',
  `url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '文件路径',
  `file_size` int NULL DEFAULT NULL COMMENT '文件大小',
  `invoice_ledger_id` bigint NULL DEFAULT NULL COMMENT '开票台账ID',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 49 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '开票台账附件表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for invoice_purchase
-- ----------------------------
DROP TABLE IF EXISTS `invoice_purchase`;
CREATE TABLE `invoice_purchase`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `purchase_contract_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '采购合同号',
  `sales_contract_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '销售合同号',
  `supplier_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '供应商名称',
  `invoice_number` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '发票号',
  `invoice_amount` decimal(10, 2) NOT NULL COMMENT '发票金额（元）',
  `tax_rate` decimal(5, 2) NOT NULL COMMENT '税率',
  `iss_uer_id` int NULL DEFAULT NULL,
  `iss_uer` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '开票人',
  `issue_date` date NOT NULL COMMENT '开票日期',
  `invoice_file` longblob NULL COMMENT '发票文件（PDF格式）',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `purchase_ledger_id` int NULL DEFAULT NULL,
  `sales_ledger_id` int NULL DEFAULT NULL COMMENT '关联销售台账主表主键',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '发票信息表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for invoice_registration
-- ----------------------------
DROP TABLE IF EXISTS `invoice_registration`;
CREATE TABLE `invoice_registration`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `sales_ledger_id` bigint NULL DEFAULT NULL COMMENT '销售台账sales_ledger主键',
  `sales_contract_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '销售合同号',
  `customer_id` bigint NULL DEFAULT NULL COMMENT '客户名称ID',
  `salesman` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '业务员',
  `project_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '项目名称',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 503 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '开票登记记录表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for invoice_registration_product
-- ----------------------------
DROP TABLE IF EXISTS `invoice_registration_product`;
CREATE TABLE `invoice_registration_product`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `sales_ledger_id` bigint NOT NULL COMMENT '关联销售台账主表主键',
  `sales_ledger_product_id` bigint NULL DEFAULT NULL COMMENT '关联sales_ledger_product主键',
  `invoice_registration_id` bigint NULL DEFAULT NULL COMMENT '开票登记表invoice_registration主键',
  `product_category` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产品大类',
  `specification_model` varchar(100) 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 '单位',
  `quantity` decimal(18, 2) NOT NULL COMMENT '数量',
  `tax_rate` decimal(5, 2) NOT NULL COMMENT '税率',
  `tax_inclusive_unit_price` decimal(18, 2) NOT NULL COMMENT '含税单价',
  `tax_inclusive_total_price` decimal(18, 2) NOT NULL COMMENT '含税总价',
  `tax_exclusive_total_price` decimal(18, 2) NOT NULL COMMENT '不含税总价',
  `invoice_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '发票类型',
  `invoice_num` decimal(10, 2) NULL DEFAULT NULL COMMENT '开票数',
  `invoice_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '开票金额',
  `no_invoice_num` decimal(10, 2) NULL DEFAULT NULL COMMENT '未开票数',
  `no_invoice_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '未开票金额',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 666 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '产品开票登记记录表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for knowledge_base
-- ----------------------------
DROP TABLE IF EXISTS `knowledge_base`;
CREATE TABLE `knowledge_base`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '知识标题',
  `type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '知识类型',
  `scenario` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '适用场景',
  `efficiency` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '解决效率',
  `problem` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '问题描述',
  `solution` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '解决方案',
  `key_points` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '关键要点',
  `creator` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `usage_count` int NULL DEFAULT 0 COMMENT '使用次数',
  `file_count` int NULL DEFAULT 0 COMMENT '文件数量',
  `total_chunk_count` int NULL DEFAULT 0 COMMENT '总切片数量',
  `description` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '知识库描述',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `create_user` int NULL DEFAULT NULL,
  `update_user` int NULL DEFAULT NULL,
  `tenant_id` bigint NULL DEFAULT NULL,
  `dept_id` bigint NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '知识库表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for knowledge_base_vector
-- ----------------------------
DROP TABLE IF EXISTS `knowledge_base_vector`;
CREATE TABLE `knowledge_base_vector`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `knowledge_base_id` bigint NOT NULL COMMENT '关联知识库ID',
  `storage_blob_id` bigint NOT NULL COMMENT '关联文件blob ID',
  `file_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '文件名称',
  `file_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '文件类型',
  `vector_status` tinyint NULL DEFAULT 0 COMMENT '向量化状态: 0-待处理, 1-处理中, 2-已完成, 3-失败',
  `vector_error` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '向量化失败原因',
  `chunk_count` int NULL DEFAULT 0 COMMENT '切片数量',
  `namespace` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '向量命名空间',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP,
  `create_user` int NULL DEFAULT NULL,
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `update_user` int NULL DEFAULT NULL,
  `tenant_id` bigint NULL DEFAULT NULL,
  `dept_id` bigint NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_knowledge_base_id`(`knowledge_base_id` ASC) USING BTREE,
  INDEX `idx_storage_blob_id`(`storage_blob_id` ASC) USING BTREE,
  INDEX `idx_vector_status`(`vector_status` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '知识库文件向量记录表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for labor_issue
-- ----------------------------
DROP TABLE IF EXISTS `labor_issue`;
CREATE TABLE `labor_issue`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `order_no` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '劳保单号',
  `staff_id` bigint NULL DEFAULT NULL COMMENT '员工id',
  `dict_type` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '劳保类型（字典）',
  `dict_id` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '字典id',
  `num` bigint NULL DEFAULT NULL COMMENT '发放数量',
  `factory_date` date NULL DEFAULT NULL COMMENT '进厂日期',
  `Issue_date` date NULL DEFAULT NULL COMMENT '发放日期',
  `adopted_date` date NULL DEFAULT NULL COMMENT '领用日期',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `tenant_id` int NULL DEFAULT NULL COMMENT '租户id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '劳保发放表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for loss
-- ----------------------------
DROP TABLE IF EXISTS `loss`;
CREATE TABLE `loss`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `rate` decimal(10, 2) NULL DEFAULT NULL,
  `tenant_id` int NULL DEFAULT NULL,
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for maintenance_task
-- ----------------------------
DROP TABLE IF EXISTS `maintenance_task`;
CREATE TABLE `maintenance_task`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `task_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备名称',
  `task_id` int NULL DEFAULT NULL COMMENT '设备id',
  `frequency_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '频次',
  `frequency_detail` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `next_execution_time` datetime(6) NULL DEFAULT NULL,
  `last_execution_time` datetime(6) NULL DEFAULT NULL,
  `is_active` tinyint(1) NULL DEFAULT NULL,
  `remarks` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '备注',
  `registrant_id` bigint NULL DEFAULT NULL COMMENT '录入人id',
  `registrant` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '录入人',
  `registration_date` date NOT NULL COMMENT '录入日期',
  `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `deleted` int NOT NULL DEFAULT 0 COMMENT '软删除标志，0=未删除，1=已删除',
  `create_user` int NULL DEFAULT NULL COMMENT '创建该记录的用户',
  `create_time` datetime(6) NULL DEFAULT NULL COMMENT '记录创建时间',
  `update_user` int NULL DEFAULT NULL COMMENT '最后修改该记录的用户',
  `update_time` datetime(6) NULL DEFAULT NULL COMMENT '记录最后更新时间',
  `tenant_id` int NULL DEFAULT NULL,
  `device_model` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `machinery_category` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '设备项目',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `maintenance_person` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '保养人',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 13 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '定时保养任务表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for measuring_instrument_ledger
-- ----------------------------
DROP TABLE IF EXISTS `measuring_instrument_ledger`;
CREATE TABLE `measuring_instrument_ledger`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `user_id` bigint NULL DEFAULT NULL COMMENT '录入人id',
  `user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '录入人名称',
  `code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '计量器具编号',
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '计量器具名称',
  `model` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '规格型号',
  `most_date` date NULL DEFAULT NULL COMMENT '最近一次检定日期',
  `valid` int NULL DEFAULT NULL COMMENT '检定有效期（单位天）',
  `next_date` date NULL DEFAULT NULL COMMENT '预计下次检定日期',
  `record_date` date NULL DEFAULT NULL COMMENT '录入日期',
  `status` int NULL DEFAULT NULL COMMENT '状态（1-有效 2-逾期）',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `tenant_id` int NULL DEFAULT NULL COMMENT '租户id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `instation_location` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '安装位置',
  `unit` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '检定单位',
  `cycle` int NULL DEFAULT NULL COMMENT '检定周期（天）',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 8 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '计量器具台账' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for measuring_instrument_ledger_record
-- ----------------------------
DROP TABLE IF EXISTS `measuring_instrument_ledger_record`;
CREATE TABLE `measuring_instrument_ledger_record`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `measuring_instrument_ledger_id` bigint NULL DEFAULT NULL COMMENT '计量器具台账id',
  `user_id` bigint NULL DEFAULT NULL COMMENT '检定id',
  `user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '检定人名称',
  `record_date` date NULL DEFAULT NULL COMMENT '检定日期',
  `entry_date` date NULL DEFAULT NULL COMMENT '录入日期',
  `valid` int NULL DEFAULT NULL COMMENT '检定有效期（单位天）',
  `status` int NULL DEFAULT NULL COMMENT '状态（1-有效 2-逾期）',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `tenant_id` int NULL DEFAULT NULL COMMENT '租户id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '计量器具台账记录' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for meet_application
-- ----------------------------
DROP TABLE IF EXISTS `meet_application`;
CREATE TABLE `meet_application`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '申请ID',
  `title` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '会议主题',
  `room_id` bigint NOT NULL COMMENT '会议室ID',
  `host` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '主持人',
  `meeting_date` date NOT NULL COMMENT '会议日期',
  `start_time` datetime NOT NULL COMMENT '开始时间',
  `end_time` datetime NOT NULL COMMENT '结束时间',
  `participants` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '参会人员（JSON格式存储ID数组）',
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '会议说明',
  `application_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'approval' COMMENT '申请类型（approval:审批流程, department:部门级, notification:通知发布）',
  `status` tinyint NOT NULL DEFAULT 0 COMMENT '状态（0:待审批, 1:已通过, 2:已拒绝, 3:已取消）',
  `applicant` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '申请人',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建者',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '更新者',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `publish_status` int NULL DEFAULT 0 COMMENT '发布状态',
  `publish_comment` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '发布评论',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_title`(`title` ASC) USING BTREE,
  INDEX `idx_meeting_date`(`meeting_date` ASC) USING BTREE,
  INDEX `idx_applicant`(`applicant` ASC) USING BTREE,
  INDEX `idx_status`(`status` ASC) USING BTREE,
  INDEX `idx_create_time`(`create_time` ASC) USING BTREE,
  INDEX `idx_tenant_id`(`tenant_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '会议申请表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for meet_draft
-- ----------------------------
DROP TABLE IF EXISTS `meet_draft`;
CREATE TABLE `meet_draft`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '草稿ID',
  `room_id` bigint NOT NULL COMMENT '会议编号',
  `title` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '会议主题',
  `host` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '主持人',
  `meeting_date` date NOT NULL COMMENT '会议日期',
  `start_time` datetime NOT NULL COMMENT '开始时间',
  `end_time` datetime NOT NULL COMMENT '结束时间',
  `participants` int NOT NULL DEFAULT 0 COMMENT '参会人数',
  `participant_list` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '参会人员列表',
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '会议说明',
  `creator` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '创建人',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建者',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '更新者',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '会议草稿表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for meeting_minutes
-- ----------------------------
DROP TABLE IF EXISTS `meeting_minutes`;
CREATE TABLE `meeting_minutes`  (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '纪要ID',
  `meeting_id` bigint UNSIGNED NOT NULL COMMENT '关联的会议ID',
  `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '纪要标题',
  `content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '纪要内容（富文本）',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建者',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '更新者',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_meeting_id`(`meeting_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '会议纪要表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for meeting_room
-- ----------------------------
DROP TABLE IF EXISTS `meeting_room`;
CREATE TABLE `meeting_room`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '会议室ID',
  `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '会议室名称',
  `location` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '位置',
  `capacity` int NOT NULL DEFAULT 10 COMMENT '容纳人数',
  `equipment` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '设备配置（逗号分隔）',
  `status` tinyint NOT NULL DEFAULT 1 COMMENT '状态（1:启用 0:禁用）',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建者',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '更新者',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '会议室表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for notice
-- ----------------------------
DROP TABLE IF EXISTS `notice`;
CREATE TABLE `notice`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '公告ID',
  `title` varchar(200) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL COMMENT '公告标题',
  `type` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '1' COMMENT '公告类型（1放假通知 2设备维修通知）',
  `status` tinyint NOT NULL DEFAULT 0 COMMENT '状态（0草稿 1发布 2已下线）',
  `content` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL COMMENT '公告内容',
  `priority` tinyint NOT NULL DEFAULT 0 COMMENT '优先级(1普通 2重要 3紧急)',
  `create_user` bigint NOT NULL COMMENT '创建者',
  `create_time` timestamp NOT NULL COMMENT '创建时间',
  `remark` varchar(500) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '备注',
  `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户id',
  `expiration_date` date NULL DEFAULT NULL,
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '通知公告表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for notice_type
-- ----------------------------
DROP TABLE IF EXISTS `notice_type`;
CREATE TABLE `notice_type`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `notice_type` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '通知公告的公告类型',
  `tenant_id` int NULL DEFAULT NULL,
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '通知公告的公告类型维护' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for notification_management
-- ----------------------------
DROP TABLE IF EXISTS `notification_management`;
CREATE TABLE `notification_management`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '通知标题',
  `type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '通知类型',
  `priority` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '优先级',
  `expire_date` datetime NULL DEFAULT NULL COMMENT '有效期时间',
  `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '状态',
  `departments` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '接收部门',
  `sync_methods` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '同步方式',
  `content` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '通知内容',
  `create_user` int NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` int NULL DEFAULT NULL COMMENT '修改者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `tenant_id` int NULL DEFAULT NULL COMMENT '租户id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '行政管理-通知管理' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for office_supplies
-- ----------------------------
DROP TABLE IF EXISTS `office_supplies`;
CREATE TABLE `office_supplies`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '注解',
  `code` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '编号',
  `applicant` varchar(15) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '申请人',
  `item_name` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '物品名称',
  `dept` varchar(15) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '部门',
  `material_type` int NULL DEFAULT NULL COMMENT '物资类型（1-其他 2-清洁用品 3-电子用品 4-电子设备）',
  `apply_num` int NULL DEFAULT NULL COMMENT '申请数量',
  `approval_opinions` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '审批意见',
  `reason` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '申请原因',
  `urgency` int NULL DEFAULT NULL COMMENT '紧急程度（1-普通 2-紧急 3-非常紧急）',
  `status` int NULL DEFAULT NULL COMMENT '状态（1-待审批 2-已拒绝 3-已通过 4-已发放）',
  `apply_time` datetime NULL DEFAULT NULL COMMENT '申请时间',
  `approval` varchar(15) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '审批人',
  `approval_time` datetime NULL DEFAULT NULL COMMENT '审批时间',
  `issue_user` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '发放人',
  `issue_time` datetime NULL DEFAULT NULL COMMENT '发放时间',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `create_user` int NULL DEFAULT NULL COMMENT '创建人',
  `update_user` int NULL DEFAULT NULL COMMENT '修改人',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for online_meeting
-- ----------------------------
DROP TABLE IF EXISTS `online_meeting`;
CREATE TABLE `online_meeting`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '会议标题',
  `start_time` datetime NULL DEFAULT NULL COMMENT '开始时间',
  `duration` int NULL DEFAULT NULL COMMENT '会议时长',
  `platform` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '会议平台',
  `participants` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '参会人员',
  `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '会议描述',
  `create_user` int NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` int NULL DEFAULT NULL COMMENT '修改者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `tenant_id` int NULL DEFAULT NULL COMMENT '租户id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '行政管理-通知管理-在线会议' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for overtime_setting
-- ----------------------------
DROP TABLE IF EXISTS `overtime_setting`;
CREATE TABLE `overtime_setting`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '加班规则名称',
  `type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '加班类型',
  `start_time` time NULL DEFAULT NULL COMMENT '开始时间',
  `end_time` time NULL DEFAULT NULL COMMENT '结束时间',
  `rate` decimal(10, 2) NULL DEFAULT NULL COMMENT '倍率',
  `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '状态',
  `create_user` int NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` int NULL DEFAULT NULL COMMENT '修改者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `tenant_id` int NULL DEFAULT NULL COMMENT '租户id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '加班设置' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for payment_registration
-- ----------------------------
DROP TABLE IF EXISTS `payment_registration`;
CREATE TABLE `payment_registration`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
  `sale_ledger_id` bigint NULL DEFAULT 0 COMMENT '销售台账id',
  `sales_ledger_product_id` int NULL DEFAULT NULL COMMENT '销售产品id',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `purchase_ledger_id` bigint NOT NULL DEFAULT 0 COMMENT '采购台账id',
  `supplier_id` bigint NOT NULL DEFAULT 0 COMMENT '供应商id',
  `ticket_registration_id` bigint NOT NULL DEFAULT 0 COMMENT '发票id',
  `current_payment_amount` decimal(12, 2) NOT NULL COMMENT '本次付款金额',
  `payment_method` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '付款形式',
  `registrant_id` bigint NOT NULL DEFAULT 0 COMMENT '登记人',
  `payment_date` date NOT NULL COMMENT '付款日期',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `registrationt_date` date NULL DEFAULT NULL COMMENT '登记日期',
  `tax_rate` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '税率',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 45 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '付款登记表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for pda_version
-- ----------------------------
DROP TABLE IF EXISTS `pda_version`;
CREATE TABLE `pda_version`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '名称',
  `version` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '版本',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `create_user` int NULL DEFAULT NULL COMMENT '创建人',
  `update_user` int NULL DEFAULT NULL COMMENT '更新人',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'PDA版本信息表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for personal_attendance_location_config
-- ----------------------------
DROP TABLE IF EXISTS `personal_attendance_location_config`;
CREATE TABLE `personal_attendance_location_config`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `sys_dept_id` int NOT NULL DEFAULT 0 COMMENT '部门id',
  `location_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '地点名称',
  `longitude` double NULL DEFAULT NULL COMMENT '经度',
  `latitude` double NULL DEFAULT NULL COMMENT '纬度',
  `radius` double NULL DEFAULT NULL COMMENT '打卡范围',
  `start_at` time NULL DEFAULT NULL COMMENT '上班时间',
  `end_at` time NULL DEFAULT NULL COMMENT '下班时间',
  `shift` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '班次',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `shift`(`shift` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '人员打卡规则配置' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for personal_attendance_records
-- ----------------------------
DROP TABLE IF EXISTS `personal_attendance_records`;
CREATE TABLE `personal_attendance_records`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `staff_on_job_id` bigint NOT NULL DEFAULT 0 COMMENT '员工在职id',
  `date` date NOT NULL COMMENT '日期',
  `work_start_at` datetime NULL DEFAULT NULL COMMENT '工作开始时间',
  `work_end_at` datetime NULL DEFAULT NULL COMMENT '工作结束时间',
  `work_hours` decimal(5, 2) NULL DEFAULT NULL COMMENT '工作时长',
  `status` tinyint NOT NULL DEFAULT 0 COMMENT '状态 0正常 1迟到 2早退',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '备注',
  `tenant_id` bigint NOT NULL COMMENT '租户id',
  `create_time` datetime NULL DEFAULT NULL COMMENT '录入时间',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 65 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '个人考勤记录表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for personal_shift
-- ----------------------------
DROP TABLE IF EXISTS `personal_shift`;
CREATE TABLE `personal_shift`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `personal_attendance_location_config_id` int NULL DEFAULT NULL COMMENT '班次(打卡规则id)',
  `staff_on_job_id` bigint NOT NULL DEFAULT 0 COMMENT '员工在职id',
  `create_time` datetime NULL DEFAULT NULL COMMENT '录入时间',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `work_time` datetime NULL DEFAULT NULL COMMENT '排班日期',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 123 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for procurement_exception_record
-- ----------------------------
DROP TABLE IF EXISTS `procurement_exception_record`;
CREATE TABLE `procurement_exception_record`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT 'id',
  `purchase_ledger_id` int NOT NULL COMMENT '采购台账id',
  `exception_reason` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '异常原因',
  `exception_num` decimal(18, 2) NULL DEFAULT NULL COMMENT '异常数量',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建者id',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改者id',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '采购异常记录-不合格物品' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for procurement_plan
-- ----------------------------
DROP TABLE IF EXISTS `procurement_plan`;
CREATE TABLE `procurement_plan`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT 'id',
  `code` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '编码',
  `plan_name` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '名称',
  `description` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '描述',
  `status` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '状态',
  `is_system_preset` tinyint(1) NULL DEFAULT NULL COMMENT '是否系统预置',
  `consider_existing_stock` tinyint(1) NULL DEFAULT NULL,
  `warehouse_control` tinyint(1) NULL DEFAULT NULL,
  `calculate_total_demand` tinyint(1) NULL DEFAULT NULL,
  `consider_safety_stock` tinyint(1) NULL DEFAULT NULL,
  `consider_locked_stock` tinyint(1) NULL DEFAULT NULL,
  `not_consider_material_aux` tinyint(1) NULL DEFAULT NULL,
  `negative_stock_as_demand` tinyint(1) NULL DEFAULT NULL,
  `summary_material` tinyint(1) NULL DEFAULT NULL,
  `summary_aux_attributes` tinyint(1) NULL DEFAULT NULL,
  `summary_demand_date` tinyint(1) NULL DEFAULT NULL,
  `formula` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '计算公式',
  `create_time` datetime NULL DEFAULT NULL,
  `create_user` int NULL DEFAULT NULL,
  `update_time` datetime NULL DEFAULT NULL,
  `update_user` int NULL DEFAULT NULL,
  `tenant_id` int NULL DEFAULT NULL,
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_bin COMMENT = '采购计划表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for procurement_price_management
-- ----------------------------
DROP TABLE IF EXISTS `procurement_price_management`;
CREATE TABLE `procurement_price_management`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT 'id',
  `product_name` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '商品名称',
  `specification` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '规格型号',
  `product_code` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '商品编码',
  `supplier_name` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '供应商',
  `base_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '基础价格',
  `unit` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '单位',
  `discount_type` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '折扣类型',
  `discount_value` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '折扣值',
  `discount_end_time` datetime NULL DEFAULT NULL COMMENT '折扣有效期',
  `min_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '最低价格',
  `max_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '最高价格',
  `warning_threshold` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '预警阈值(%)',
  `effective_time` datetime NULL DEFAULT NULL COMMENT '生效时间',
  `expire_time` datetime NULL DEFAULT NULL COMMENT '失效时间',
  `reason` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '调价原因',
  `remark` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` int NULL DEFAULT NULL COMMENT '创建用户',
  `update_user` int NULL DEFAULT NULL COMMENT '修改用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_bin COMMENT = '采购价格管理' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for procurement_record_out
-- ----------------------------
DROP TABLE IF EXISTS `procurement_record_out`;
CREATE TABLE `procurement_record_out`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT 'id',
  `sales_ledger_product_id` int NOT NULL DEFAULT 0 COMMENT '产品信息表id',
  `procurement_record_storage_id` int NOT NULL COMMENT '入库记录表id',
  `inbound_batches` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '出库批次',
  `inbound_num` decimal(18, 2) NULL DEFAULT NULL COMMENT '出库数量',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '出库用户名称',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` int NULL DEFAULT NULL COMMENT '创建者id',
  `update_user` int NULL DEFAULT NULL COMMENT '修改者id',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户id',
  `code` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '编号',
  `type` int NULL DEFAULT NULL,
  `product_model_id` bigint NULL DEFAULT NULL COMMENT '产品规格id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '采购出库记录' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for procurement_record_storage
-- ----------------------------
DROP TABLE IF EXISTS `procurement_record_storage`;
CREATE TABLE `procurement_record_storage`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT 'id',
  `sales_ledger_product_id` int NOT NULL COMMENT '产品信息表id',
  `inbound_batches` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '入库批次',
  `total_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '总价',
  `unit_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '单价',
  `inbound_num` decimal(18, 2) NULL DEFAULT NULL COMMENT '入库数量',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '入库用户名称',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建者id',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改者id',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户id',
  `warn_num` decimal(10, 2) NULL DEFAULT NULL,
  `type` int NULL DEFAULT 1,
  `product_model_id` bigint NULL DEFAULT NULL COMMENT '产品规格id',
  `quality_inspect_id` bigint NULL DEFAULT NULL COMMENT '质检id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '采购入库记录' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for product
-- ----------------------------
DROP TABLE IF EXISTS `product`;
CREATE TABLE `product`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `parent_id` int NULL DEFAULT NULL COMMENT '父id',
  `product_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产品',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 409 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '产品' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for product_borrow
-- ----------------------------
DROP TABLE IF EXISTS `product_borrow`;
CREATE TABLE `product_borrow`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `borrow_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '领用单号',
  `product_model_id` bigint NOT NULL COMMENT '产品规格ID',
  `batch_no` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '批号',
  `borrow_quantity` decimal(18, 4) NOT NULL COMMENT '领用数量',
  `returned_quantity` decimal(18, 4) NULL DEFAULT 0.0000 COMMENT '已归还数量',
  `borrower_id` bigint NULL DEFAULT NULL COMMENT '领用人ID',
  `borrower_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '领用人姓名',
  `borrow_time` datetime NOT NULL COMMENT '领用时间',
  `expected_return_time` datetime NULL DEFAULT NULL COMMENT '预计归还时间',
  `approval_status` tinyint NULL DEFAULT 0 COMMENT '审批状态（0-待审批，1-已通过，2-已驳回）',
  `status` tinyint NULL DEFAULT 0 COMMENT '归还状态（0-未归还，1-部分归还，2-已全部归还）',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `create_user` int NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` int NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_borrow_no`(`borrow_no` ASC) USING BTREE,
  INDEX `idx_product_model_id`(`product_model_id` ASC) USING BTREE,
  INDEX `idx_borrower_id`(`borrower_id` ASC) USING BTREE,
  INDEX `idx_approval_status`(`approval_status` ASC) USING BTREE,
  INDEX `idx_status`(`status` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 10 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '产品领用表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for product_borrow_return
-- ----------------------------
DROP TABLE IF EXISTS `product_borrow_return`;
CREATE TABLE `product_borrow_return`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `borrow_id` bigint NOT NULL COMMENT '领用记录ID',
  `product_model_id` bigint NOT NULL COMMENT '产品规格ID',
  `batch_no` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '批号',
  `return_quantity` decimal(18, 4) NOT NULL COMMENT '归还数量',
  `returner_id` bigint NULL DEFAULT NULL COMMENT '归还人ID',
  `returner_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '归还人姓名',
  `return_time` datetime NOT NULL COMMENT '归还时间',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `create_user` int NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_borrow_id`(`borrow_id` ASC) USING BTREE,
  INDEX `idx_product_model_id`(`product_model_id` ASC) USING BTREE,
  INDEX `idx_returner_id`(`returner_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '产品归还记录表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for product_model
-- ----------------------------
DROP TABLE IF EXISTS `product_model`;
CREATE TABLE `product_model`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `product_id` int NULL DEFAULT NULL COMMENT '关联产品id',
  `model` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '规格信号',
  `unit` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '单位',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `product_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 386 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '产品型号表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for product_record
-- ----------------------------
DROP TABLE IF EXISTS `product_record`;
CREATE TABLE `product_record`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `ticket_registration_id` int NULL DEFAULT NULL COMMENT '来票登记id',
  `purchase_ledger_id` int NULL DEFAULT NULL COMMENT '采购台账id',
  `product_category` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产品大类',
  `specification_model` varchar(100) 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 '单位',
  `quantity` decimal(18, 0) NOT NULL COMMENT '数量',
  `tax_rate` decimal(5, 0) NOT NULL COMMENT '税率',
  `tax_inclusive_unit_price` decimal(18, 2) NOT NULL COMMENT '含税单价',
  `tax_inclusive_total_price` decimal(18, 2) NOT NULL COMMENT '含税总价',
  `tax_exclusive_total_price` decimal(18, 2) NOT NULL COMMENT '不含税总价',
  `invoice_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '发票类型',
  `type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '1.销售台账，2.采购台账',
  `tickets_num` decimal(10, 2) NULL DEFAULT NULL COMMENT '本次来票数',
  `tickets_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '本次来票金额(元)',
  `future_tickets` decimal(10, 2) NULL DEFAULT NULL COMMENT '未来票数',
  `future_tickets_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '未来票金额(元)',
  `product_id` int NULL DEFAULT NULL COMMENT '产品id',
  `product_model_id` int NULL DEFAULT NULL COMMENT '型号id',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `sale_ledger_project_id` int NULL DEFAULT NULL COMMENT 'sale_ledger_projectI_id',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '采购台账产品开票记录' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for production_account
-- ----------------------------
DROP TABLE IF EXISTS `production_account`;
CREATE TABLE `production_account`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `sales_ledger_id` bigint NULL DEFAULT NULL COMMENT '销售台账id',
  `sales_ledger_product_id` bigint NULL DEFAULT NULL COMMENT '销售产品规格id',
  `production_product_main_id` bigint NULL DEFAULT NULL COMMENT '报工表id',
  `scheduling_user_id` bigint NULL DEFAULT NULL COMMENT '生产人id',
  `scheduling_user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '生产人名称',
  `finished_num` decimal(18, 2) NULL DEFAULT 0.00 COMMENT '生产数量',
  `work_hours` decimal(18, 2) NULL DEFAULT 0.00 COMMENT '工时定额',
  `technology_operation_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '工序名称',
  `scheduling_date` timestamp NULL DEFAULT NULL COMMENT '生产日期',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 42 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '生产核算表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for production_bom_structure
-- ----------------------------
DROP TABLE IF EXISTS `production_bom_structure`;
CREATE TABLE `production_bom_structure`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `parent_id` bigint NULL DEFAULT NULL COMMENT '父节点ID',
  `production_order_id` bigint NULL DEFAULT NULL COMMENT '生产订单id',
  `product_model_id` bigint NOT NULL COMMENT '产品规格id',
  `technology_operation_id` bigint NULL DEFAULT NULL COMMENT '工序id',
  `production_order_bom_id` bigint NULL DEFAULT NULL COMMENT '生产订单BOMid',
  `unit_quantity` decimal(16, 4) NOT NULL COMMENT '单位产出需要数量',
  `demanded_quantity` decimal(16, 4) NULL DEFAULT NULL COMMENT '需求数量',
  `unit` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '单位',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 327 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '生产订单BOM产品结构' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for production_operation_main_param
-- ----------------------------
DROP TABLE IF EXISTS `production_operation_main_param`;
CREATE TABLE `production_operation_main_param`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
  `technology_routing_operation_param_id` bigint NOT NULL COMMENT '工艺路线工序参数表id',
  `param_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '参数编码(唯一标识)',
  `param_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '参数名称',
  `param_type` tinyint NOT NULL COMMENT '参数类型(1数字 2文本 3下拉选择 4时间)',
  `param_format` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '参数格式',
  `unit` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '单位',
  `is_required` tinyint NULL DEFAULT 0 COMMENT '是否必填',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `create_user` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '修改人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `technology_param_id` bigint NULL DEFAULT NULL COMMENT '基础参数ID',
  `technology_operation_id` bigint NULL DEFAULT NULL COMMENT '工序id',
  `technology_operation_param_id` bigint NULL DEFAULT NULL COMMENT '工序参数ID',
  `technology_routing_operation_id` bigint NULL DEFAULT NULL COMMENT '工艺路线工序ID',
  `standard_value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '标准值',
  `value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '输入值',
  `production_order_routing_operation_param_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '生产订单工艺路线工序参数ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '生产工单报工参数表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for production_operation_task
-- ----------------------------
DROP TABLE IF EXISTS `production_operation_task`;
CREATE TABLE `production_operation_task`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
  `production_order_routing_operation_id` bigint NOT NULL DEFAULT 0 COMMENT '生产工艺路线工序表id',
  `technology_routing_operation_id` bigint NOT NULL DEFAULT 0 COMMENT '工艺路线工序表id',
  `create_time` datetime NULL DEFAULT NULL COMMENT '录入时间',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `work_order_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '工单编号',
  `plan_start_time` date NULL DEFAULT NULL COMMENT '计划开始时间',
  `plan_end_time` date NULL DEFAULT NULL COMMENT '计划结束时间',
  `actual_start_time` date NULL DEFAULT NULL COMMENT '实际开始时间',
  `actual_end_time` date NULL DEFAULT NULL COMMENT '实际结束时间',
  `status` int NOT NULL DEFAULT 0 COMMENT '状态 1 待确认 2 待生产 3生产中 4已生产',
  `production_order_id` bigint NOT NULL DEFAULT 0 COMMENT '生产订单id',
  `plan_quantity` decimal(16, 4) NULL DEFAULT NULL COMMENT '计划数量',
  `complete_quantity` decimal(18, 2) NULL DEFAULT 0.00 COMMENT '完成数量',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `user_ids` json NULL COMMENT '权限用户，格式：[1,2,3]',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 238 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '生产工单表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for production_order
-- ----------------------------
DROP TABLE IF EXISTS `production_order`;
CREATE TABLE `production_order`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `production_plan_ids` json NULL COMMENT '生产计划ID列表，格式：[1,2,3]',
  `product_model_id` bigint NOT NULL DEFAULT 0 COMMENT '产品规格id',
  `technology_routing_id` bigint NOT NULL DEFAULT 0 COMMENT '工艺路线id',
  `nps_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '生产订单号',
  `create_time` datetime NULL DEFAULT NULL COMMENT '录入时间',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `quantity` decimal(18, 2) NOT NULL COMMENT '需求数量',
  `complete_quantity` decimal(18, 2) NULL DEFAULT NULL COMMENT '完成数量',
  `start_time` datetime NULL DEFAULT NULL COMMENT '开始日期',
  `end_time` datetime NULL DEFAULT NULL COMMENT '结束日期',
  `plan_complete_time` date NULL DEFAULT NULL COMMENT '计划完成时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `status` int NULL DEFAULT 1 COMMENT '状态（1.待开始、2.进行中、3.已完成、4.已取消）',
  `is_end_order` tinyint(1) NULL DEFAULT 0 COMMENT '是否结束',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 64 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '生产订单表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for production_order_bom
-- ----------------------------
DROP TABLE IF EXISTS `production_order_bom`;
CREATE TABLE `production_order_bom`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `production_order_id` bigint NULL DEFAULT NULL COMMENT '生产订单id',
  `product_model_id` bigint NOT NULL COMMENT '产品规格id',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `version` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '版本号',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建者',
  `bom_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'BOM编号',
  `bom_id` bigint NOT NULL COMMENT 'bom的id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 75 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '生产订单BOM' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for production_order_pick
-- ----------------------------
DROP TABLE IF EXISTS `production_order_pick`;
CREATE TABLE `production_order_pick`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `product_model_id` int NULL DEFAULT NULL COMMENT '产品规格id',
  `quantity` decimal(16, 2) NULL DEFAULT NULL COMMENT '数量',
  `batch_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '批号',
  `create_time` timestamp NULL DEFAULT NULL,
  `update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
  `production_order_id` bigint NOT NULL DEFAULT 0 COMMENT '生产订单id',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `operation_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '工序名称',
  `technology_operation_id` bigint NULL DEFAULT NULL COMMENT '工序id\r\n',
  `demanded_quantity` decimal(16, 2) NULL DEFAULT NULL COMMENT '需求数量',
  `is_bom` tinyint(1) NULL DEFAULT NULL COMMENT '是否bom领料',
  `is_returned` tinyint(1) NULL DEFAULT 0 COMMENT '是否已退料',
  `feeding_qty` decimal(20, 2) NULL DEFAULT NULL COMMENT '补料总量',
  `return_qty` decimal(20, 2) NULL DEFAULT NULL COMMENT '退料数量',
  `actual_qty` decimal(20, 2) NULL DEFAULT NULL COMMENT '实际数量',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 81 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '订单领料线边仓' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for production_order_pick_record
-- ----------------------------
DROP TABLE IF EXISTS `production_order_pick_record`;
CREATE TABLE `production_order_pick_record`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `pick_id` bigint NOT NULL DEFAULT 0 COMMENT '关联领料单id（production_order_pick.id）',
  `production_order_id` bigint NULL DEFAULT 0 COMMENT '生产订单id',
  `production_operation_task_id` bigint NULL DEFAULT 0 COMMENT '生产工单id',
  `product_model_id` int NULL DEFAULT NULL COMMENT '产品规格id',
  `batch_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '批号',
  `pick_quantity` decimal(16, 4) NULL DEFAULT NULL COMMENT '领料数量',
  `before_quantity` decimal(16, 4) NULL DEFAULT NULL COMMENT '领料前数量',
  `after_quantity` decimal(16, 4) NULL DEFAULT NULL COMMENT '领料后剩余数量',
  `pick_type` tinyint NULL DEFAULT 1 COMMENT '领料类型：1正常领料  2补料',
  `remark` varchar(255) 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 '更新时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `feeding_reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '补料原因',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_pick_id`(`pick_id` ASC) USING BTREE,
  INDEX `idx_production_order_id`(`production_order_id` ASC) USING BTREE,
  INDEX `idx_batch_no`(`batch_no` ASC) USING BTREE,
  INDEX `idx_create_time`(`create_time` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 105 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '线边仓出入库记录' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for production_order_routing
-- ----------------------------
DROP TABLE IF EXISTS `production_order_routing`;
CREATE TABLE `production_order_routing`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `product_model_id` bigint NOT NULL DEFAULT 0 COMMENT '产品规格id',
  `production_order_id` bigint NOT NULL DEFAULT 0 COMMENT '生产订单id',
  `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '描述',
  `create_time` datetime NULL DEFAULT NULL COMMENT '录入时间',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `technology_routing_id` bigint NOT NULL DEFAULT 0 COMMENT '工艺路线id',
  `process_route_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '工艺路线编码',
  `bom_id` int NULL DEFAULT NULL COMMENT '关联bom的id',
  `order_bom_id` int NULL DEFAULT NULL COMMENT '关联订单bom的id',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 74 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '生产订单工艺路线表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for production_order_routing_operation
-- ----------------------------
DROP TABLE IF EXISTS `production_order_routing_operation`;
CREATE TABLE `production_order_routing_operation`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `production_order_id` bigint NOT NULL DEFAULT 0 COMMENT '生产订单id',
  `technology_routing_operation_id` bigint NULL DEFAULT NULL COMMENT '工艺路线工序表id',
  `technology_operation_id` bigint NULL DEFAULT NULL COMMENT '工序表id',
  `order_routing_id` int NULL DEFAULT NULL COMMENT '关联订单工艺路线的id',
  `operation_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '工序名称',
  `product_model_id` bigint NOT NULL DEFAULT 0 COMMENT '产品规格id',
  `create_time` datetime NULL DEFAULT NULL COMMENT '录入时间',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `drag_sort` int NULL DEFAULT NULL COMMENT '拖动排序',
  `is_quality` tinyint(1) NULL DEFAULT 1 COMMENT '是否质检工序',
  `is_production` tinyint(1) NULL DEFAULT 1 COMMENT '是否生产',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `type` int NULL DEFAULT NULL COMMENT '类型 区分计时和计件(0计时1计件)',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 260 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '生产订单工艺路线工序表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for production_order_routing_operation_param
-- ----------------------------
DROP TABLE IF EXISTS `production_order_routing_operation_param`;
CREATE TABLE `production_order_routing_operation_param`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
  `production_order_id` bigint NULL DEFAULT NULL COMMENT '生产订单id',
  `technology_routing_operation_param_id` bigint NULL DEFAULT NULL COMMENT '工艺路线工序参数表id',
  `param_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '参数编码(唯一标识)',
  `param_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '参数名称',
  `param_type` tinyint NOT NULL COMMENT '参数类型(1数字 2文本 3下拉选择 4时间)',
  `param_format` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '参数格式',
  `unit` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '单位',
  `is_required` tinyint NULL DEFAULT 0 COMMENT '是否必填',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `create_user` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '修改人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `param_id` bigint NULL DEFAULT NULL COMMENT '基础参数ID',
  `technology_operation_id` bigint NULL DEFAULT NULL COMMENT '工序id',
  `technology_operation_param_id` bigint NULL DEFAULT NULL COMMENT '工序参数ID',
  `production_order_routing_operation_id` bigint NOT NULL COMMENT '生产订单工艺路线工序ID',
  `standard_value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '标准值',
  `input_value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '输入值',
  `production_product_main_id` bigint NULL DEFAULT NULL COMMENT '报工id',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 334 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '生产订单工艺路线工序参数表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for production_plan
-- ----------------------------
DROP TABLE IF EXISTS `production_plan`;
CREATE TABLE `production_plan`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `sales_ledger_id` bigint NULL DEFAULT 0 COMMENT '销售台账id',
  `sales_ledger_product_id` bigint NULL DEFAULT NULL COMMENT '销售产品规格id',
  `mps_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '主生产计划号',
  `required_date` datetime(6) NULL DEFAULT NULL COMMENT '需求日期',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime(6) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(6) NULL DEFAULT NULL COMMENT '更新时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `product_model_id` bigint NULL DEFAULT NULL COMMENT '产品型号id',
  `qty_required` decimal(12, 6) NULL DEFAULT NULL COMMENT '需求数量',
  `status` int NULL DEFAULT NULL COMMENT '状态 0未下发 1部分下发 2已下发',
  `source` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '来源',
  `promised_delivery_date` datetime(6) NULL DEFAULT NULL COMMENT '承诺日期',
  `quantity_issued` decimal(12, 6) NULL DEFAULT NULL COMMENT '已下发数量',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 70 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '生产计划表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for production_product_input
-- ----------------------------
DROP TABLE IF EXISTS `production_product_input`;
CREATE TABLE `production_product_input`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
  `input_quantity` decimal(18, 6) NOT NULL COMMENT '投入数量',
  `production_product_main_id` bigint NOT NULL COMMENT '报工表id',
  `product_model_id` bigint NULL DEFAULT NULL COMMENT '产品型号id',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `create_time` datetime NULL DEFAULT NULL COMMENT '录入时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '更新用户',
  `product_main_id` bigint NULL DEFAULT NULL COMMENT '生产报工表id',
  `quantity` decimal(18, 2) NULL DEFAULT NULL,
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_product_main_id`(`production_product_main_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 52 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '生产报工投入表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for production_product_main
-- ----------------------------
DROP TABLE IF EXISTS `production_product_main`;
CREATE TABLE `production_product_main`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
  `product_no` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '报工单号',
  `user_id` bigint NULL DEFAULT NULL COMMENT '报工人员id',
  `user_name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '报工人员',
  `production_operation_task_id` bigint NULL DEFAULT NULL COMMENT '工单id',
  `status` int NULL DEFAULT NULL COMMENT '报工状态',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `create_time` datetime NULL DEFAULT NULL COMMENT '录入时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '更新用户',
  `work_hour` decimal(10, 2) NULL DEFAULT NULL COMMENT '工时',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 45 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '生产报工表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for production_product_output
-- ----------------------------
DROP TABLE IF EXISTS `production_product_output`;
CREATE TABLE `production_product_output`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `production_product_main_id` bigint NOT NULL COMMENT '报工单id',
  `product_model_id` bigint NOT NULL COMMENT '产品规格id',
  `quantity` decimal(16, 4) NOT NULL DEFAULT 0.0000 COMMENT '报工数量',
  `scrap_qty` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '报废数量',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `create_time` datetime NULL DEFAULT NULL COMMENT '录入时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '更新用户',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `product_main_id` bigint NULL DEFAULT NULL COMMENT '生产报工表id',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 45 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '生产报工产出表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for project_management_contract_info
-- ----------------------------
DROP TABLE IF EXISTS `project_management_contract_info`;
CREATE TABLE `project_management_contract_info`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '名称',
  `sex` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '性别',
  `birthday` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '生日',
  `department` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '部门',
  `job` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '职务',
  `phone_number` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '手机号',
  `email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '邮箱',
  `qq` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'QQ',
  `linea_fissa` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '固定号码',
  `wx` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '微信',
  `origine_etnica` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '籍贯',
  `rappresentante_legale` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '法人代表',
  `project_management_info_id` bigint NULL DEFAULT NULL COMMENT '对应项目管理信息id',
  `is_delete` int NOT NULL DEFAULT 0,
  `create_user` bigint NULL DEFAULT NULL,
  `update_user` bigint NULL DEFAULT NULL,
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `update_user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `create_user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '项目联系信息' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for project_management_info
-- ----------------------------
DROP TABLE IF EXISTS `project_management_info`;
CREATE TABLE `project_management_info`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '项目编号',
  `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '主题',
  `client_id` bigint NULL DEFAULT NULL COMMENT '客户id',
  `client_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '客户名称',
  `project_management_info_parent_id` bigint NULL DEFAULT NULL COMMENT '索引的父项目id',
  `establish_time` date NULL DEFAULT NULL COMMENT '立项时间',
  `project_management_plan_id` bigint NOT NULL COMMENT '项目阶段id',
  `source` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '来源',
  `manager_id` bigint NULL DEFAULT NULL COMMENT '项目经理id',
  `manager_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '项目经理名字',
  `salesman_id` bigint NULL DEFAULT NULL COMMENT '业务员id',
  `salesman_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '业务员名字',
  `is_delete` int NOT NULL DEFAULT 0,
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `create_user` int NULL DEFAULT NULL,
  `update_user` int NULL DEFAULT NULL,
  `plan_start_time` date NULL DEFAULT NULL COMMENT '计划开始时间',
  `plan_end_time` date NULL DEFAULT NULL COMMENT '计划结束时间',
  `actual_start_time` date NULL DEFAULT NULL COMMENT '实际开始时间',
  `actual_end_time` date NULL DEFAULT NULL COMMENT '实际结束日期',
  `review_status` int NULL DEFAULT NULL COMMENT '审核状态',
  `status` int NULL DEFAULT NULL COMMENT '项目状态',
  `department_id` bigint NULL DEFAULT NULL COMMENT '部门id',
  `department_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '部门名字',
  `order_date` timestamp NULL DEFAULT NULL COMMENT '订单日期',
  `order_amount` 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 NULL COMMENT '备注',
  `attachment` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '附件',
  `plan_stage` json NULL COMMENT '项目阶段 json',
  `team` json NULL COMMENT '团队',
  `create_user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `update_user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '项目管理信息' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for project_management_info_stage
-- ----------------------------
DROP TABLE IF EXISTS `project_management_info_stage`;
CREATE TABLE `project_management_info_stage`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `project_management_plan_node_id` bigint NOT NULL COMMENT '对应计划节点id',
  `project_management_info_id` bigint NOT NULL COMMENT '对应项目id',
  `description` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '描述',
  `actual_leader_id` bigint NULL DEFAULT NULL COMMENT '实际负责人id',
  `actual_leader_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '实际负责人名称',
  `estimated_duration` int NULL DEFAULT NULL COMMENT '预计工期',
  `plan_start_time` date NULL DEFAULT NULL COMMENT '计划开始',
  `plan_end_time` date NULL DEFAULT NULL COMMENT '计划结束',
  `progress` int NOT NULL DEFAULT 0 COMMENT '进度',
  `actual_start_time` date NULL DEFAULT NULL COMMENT '实际开始时间',
  `actual_end_time` date NULL DEFAULT NULL COMMENT '实际结束时间',
  `attachment` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '附件',
  `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `is_delete` int NOT NULL DEFAULT 0,
  `create_user` bigint NULL DEFAULT NULL,
  `update_user` bigint NULL DEFAULT NULL,
  `create_user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `update_user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '项目阶段' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for project_management_plan
-- ----------------------------
DROP TABLE IF EXISTS `project_management_plan`;
CREATE TABLE `project_management_plan`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '计划名称',
  `description` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '计划描述',
  `attachment` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '附件 ,进行分割',
  `is_delete` int NOT NULL DEFAULT 0,
  `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `create_user` int NULL DEFAULT NULL,
  `update_user` int NULL DEFAULT NULL,
  `create_user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `update_user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '项目管理计划表(项目管理类型)' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for project_management_plan_node
-- ----------------------------
DROP TABLE IF EXISTS `project_management_plan_node`;
CREATE TABLE `project_management_plan_node`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `project_management_plan_id` bigint NOT NULL COMMENT '对应id',
  `sort` int NOT NULL COMMENT '排序',
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '阶段名称',
  `leader_id` bigint NULL DEFAULT NULL COMMENT '负责任ID',
  `leader_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '负责任名称',
  `estimated_duration` int NULL DEFAULT NULL COMMENT '预计工期(天)',
  `hourly_rate` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `work_content` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '作业内容',
  `is_delete` int NOT NULL DEFAULT 0,
  `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `create_user` int NULL DEFAULT NULL,
  `update_user` int NULL DEFAULT NULL,
  `create_user_name` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `update_user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '计划节点' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for project_management_roles
-- ----------------------------
DROP TABLE IF EXISTS `project_management_roles`;
CREATE TABLE `project_management_roles`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
  `no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT 'id',
  `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '名称',
  `status` tinyint NOT NULL DEFAULT 1 COMMENT '状态(1:启用, 0:禁用)',
  `create_time` timestamp NOT NULL COMMENT '创建时间',
  `create_user` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` timestamp NOT NULL COMMENT '更新时间',
  `update_user` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `create_user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `update_user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '项目角色' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for project_management_shipping_address
-- ----------------------------
DROP TABLE IF EXISTS `project_management_shipping_address`;
CREATE TABLE `project_management_shipping_address`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `consignee` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '收货人',
  `contract` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '联系方式',
  `address` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '地址',
  `is_delete` int NOT NULL DEFAULT 0,
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `create_user` bigint NULL DEFAULT NULL,
  `update_user` bigint NULL DEFAULT NULL,
  `project_management_info_id` bigint NULL DEFAULT NULL COMMENT '对应项目信息id',
  `update_user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `create_user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '收货地址' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for purchase_ledger
-- ----------------------------
DROP TABLE IF EXISTS `purchase_ledger`;
CREATE TABLE `purchase_ledger`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '自增主键ID',
  `purchase_contract_number` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '采购合同号',
  `supplier_id` int NULL DEFAULT NULL COMMENT '供应商名称id',
  `supplier_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '供应商名称',
  `recorder_id` int NULL DEFAULT NULL COMMENT '录入人id\r\n',
  `recorder_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '录入人姓名',
  `sales_contract_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '销售合同号',
  `project_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '项目名称',
  `entry_date` date NOT NULL COMMENT '录入日期',
  `remarks` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '备注',
  `attachment_materials` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '附件材料路径或名称',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '记录创建时间',
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '记录最后更新时间',
  `sales_ledger_id` int NULL DEFAULT NULL COMMENT '关联销售台账主表主键',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `contract_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '合同金额',
  `business_person` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '业务员',
  `business_person_id` int NULL DEFAULT NULL COMMENT '业务员id',
  `phone_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '录入人电话',
  `payment_method` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `execution_date` datetime NULL DEFAULT NULL,
  `approval_status` bigint NULL DEFAULT 1 COMMENT '1-待审核，2-审批中，3-审批通过，4-审批失败',
  `template_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '模板名称',
  `approve_user_ids` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '审批人id',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `template_id` int NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 44 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '采购台账' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for purchase_ledger_template
-- ----------------------------
DROP TABLE IF EXISTS `purchase_ledger_template`;
CREATE TABLE `purchase_ledger_template`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '自增主键ID',
  `purchase_contract_number` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '采购合同号',
  `supplier_id` int NULL DEFAULT NULL COMMENT '供应商名称id',
  `supplier_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供应商名称',
  `recorder_id` int NULL DEFAULT NULL COMMENT '录入人id\r\n',
  `recorder_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '录入人姓名',
  `sales_contract_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '销售合同号',
  `project_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '项目名称',
  `entry_date` date NULL DEFAULT NULL COMMENT '录入日期',
  `remarks` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '备注',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '记录创建时间',
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '记录最后更新时间',
  `sales_ledger_id` int NULL DEFAULT NULL COMMENT '关联销售台账主表主键',
  `contract_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '合同金额',
  `business_person` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '业务员',
  `business_person_id` int NULL DEFAULT NULL COMMENT '业务员id',
  `phone_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '录入人电话',
  `payment_method` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `execution_date` datetime NULL DEFAULT NULL,
  `template_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '模板名称',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '采购台账模板' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for purchase_return_order_products
-- ----------------------------
DROP TABLE IF EXISTS `purchase_return_order_products`;
CREATE TABLE `purchase_return_order_products`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `purchase_return_order_id` bigint NOT NULL DEFAULT 0 COMMENT '退货单id',
  `sales_ledger_product_id` bigint NOT NULL DEFAULT 0 COMMENT '采购产品id',
  `return_quantity` decimal(16, 4) NOT NULL DEFAULT 0.0000 COMMENT '退货数量',
  `create_time` datetime NULL DEFAULT NULL COMMENT '录入时间',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `stock_in_record_id` bigint NOT NULL COMMENT '关联入库单id',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_purchase_return_order_id`(`purchase_return_order_id` ASC) USING BTREE,
  INDEX `idx_sales_ledger_product_id`(`sales_ledger_product_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '采购退货产品表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for purchase_return_orders
-- ----------------------------
DROP TABLE IF EXISTS `purchase_return_orders`;
CREATE TABLE `purchase_return_orders`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '退货单编号',
  `return_type` tinyint NOT NULL DEFAULT 0 COMMENT '退货方式 0退货退款 1拒收',
  `supplier_id` bigint NOT NULL DEFAULT 0 COMMENT '供应商id',
  `shipping_type` tinyint NULL DEFAULT NULL COMMENT '发货类型 1货车 2快递',
  `truck_plate_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '发货车牌号',
  `express_company` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '快递公司',
  `express_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '快递单号',
  `project_id` bigint NOT NULL DEFAULT 0 COMMENT '项目id',
  `project_phase` tinyint NOT NULL DEFAULT 0 COMMENT '项目阶段',
  `prepared_at` datetime NULL DEFAULT NULL COMMENT '制单日期',
  `prepared_user_id` bigint NOT NULL DEFAULT 0 COMMENT '制单人id',
  `return_user_id` bigint NOT NULL DEFAULT 0 COMMENT '退料人id',
  `purchase_ledger_id` bigint NOT NULL DEFAULT 0 COMMENT '采购订单id',
  `total_discount_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '整单折扣额',
  `total_discount_rate` decimal(10, 2) NULL DEFAULT NULL COMMENT '整单折扣率',
  `total_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '成交金额',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '备注',
  `create_time` datetime NULL DEFAULT NULL COMMENT '录入时间',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `income_type` int NULL DEFAULT NULL COMMENT '收入类型',
  `prepared_user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '制单人名称',
  `return_user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '退料人名称',
  `create_user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `create_user` int NULL DEFAULT NULL,
  `update_user` int NULL DEFAULT NULL,
  `update_user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_supplier_id`(`supplier_id` ASC) USING BTREE,
  INDEX `idx_purchase_ledger_id`(`purchase_ledger_id` ASC) USING BTREE,
  INDEX `idx_project_id`(`project_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '采购退货单表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for qr_code
-- ----------------------------
DROP TABLE IF EXISTS `qr_code`;
CREATE TABLE `qr_code`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '二维码唯一标识',
  `device_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '设备名称',
  `location` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '所在位置描述',
  `tenant_id` int NULL DEFAULT NULL COMMENT '租户ID，用于多租户隔离',
  `deleted` int NOT NULL DEFAULT 0 COMMENT '软删除标志，0=未删除，1=已删除',
  `create_user` int NULL DEFAULT NULL COMMENT '创建该记录的用户',
  `create_time` datetime(6) NULL DEFAULT NULL COMMENT '记录创建时间',
  `update_user` int NULL DEFAULT NULL COMMENT '最后修改该记录的用户',
  `update_time` datetime(6) NULL DEFAULT NULL COMMENT '记录最后更新时间',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '二维码管理表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for qr_code_scan_record
-- ----------------------------
DROP TABLE IF EXISTS `qr_code_scan_record`;
CREATE TABLE `qr_code_scan_record`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '扫码记录唯一标识',
  `qr_code_id` bigint NULL DEFAULT NULL COMMENT '关联的二维码ID',
  `scanner_id` bigint NULL DEFAULT NULL COMMENT '扫码人用户ID',
  `device_id` int NULL DEFAULT NULL COMMENT '设备id',
  `device_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '设备名称',
  `scan_time` datetime(6) NULL DEFAULT NULL COMMENT '实际扫码时间',
  `tenant_id` int NULL DEFAULT NULL COMMENT '租户ID，用于多租户隔离',
  `deleted` int NOT NULL DEFAULT 0 COMMENT '软删除标志，0=未删除，1=已删除',
  `create_user` int NULL DEFAULT NULL COMMENT '创建该记录的用户',
  `create_time` datetime(6) NULL DEFAULT NULL COMMENT '记录创建时间',
  `update_user` int NULL DEFAULT NULL COMMENT '最后修改该记录的用户',
  `update_time` datetime(6) NULL DEFAULT NULL COMMENT '记录最后更新时间',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '二维码扫码记录表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for qrtz_blob_triggers
-- ----------------------------
DROP TABLE IF EXISTS `qrtz_blob_triggers`;
CREATE TABLE `qrtz_blob_triggers`  (
  `sched_name` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '调度名称',
  `trigger_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'qrtz_triggers表trigger_name的外键',
  `trigger_group` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'qrtz_triggers表trigger_group的外键',
  `blob_data` blob NULL COMMENT '存放持久化Trigger对象',
  PRIMARY KEY (`sched_name`, `trigger_name`, `trigger_group`) USING BTREE,
  CONSTRAINT `qrtz_blob_triggers_ibfk_1` FOREIGN KEY (`sched_name`, `trigger_name`, `trigger_group`) REFERENCES `qrtz_triggers` (`sched_name`, `trigger_name`, `trigger_group`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'Blob类型的触发器表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for qrtz_calendars
-- ----------------------------
DROP TABLE IF EXISTS `qrtz_calendars`;
CREATE TABLE `qrtz_calendars`  (
  `sched_name` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '调度名称',
  `calendar_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '日历名称',
  `calendar` blob NOT NULL COMMENT '存放持久化calendar对象',
  PRIMARY KEY (`sched_name`, `calendar_name`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '日历信息表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for qrtz_cron_triggers
-- ----------------------------
DROP TABLE IF EXISTS `qrtz_cron_triggers`;
CREATE TABLE `qrtz_cron_triggers`  (
  `sched_name` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '调度名称',
  `trigger_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'qrtz_triggers表trigger_name的外键',
  `trigger_group` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'qrtz_triggers表trigger_group的外键',
  `cron_expression` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'cron表达式',
  `time_zone_id` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '时区',
  PRIMARY KEY (`sched_name`, `trigger_name`, `trigger_group`) USING BTREE,
  CONSTRAINT `qrtz_cron_triggers_ibfk_1` FOREIGN KEY (`sched_name`, `trigger_name`, `trigger_group`) REFERENCES `qrtz_triggers` (`sched_name`, `trigger_name`, `trigger_group`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'Cron类型的触发器表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for qrtz_fired_triggers
-- ----------------------------
DROP TABLE IF EXISTS `qrtz_fired_triggers`;
CREATE TABLE `qrtz_fired_triggers`  (
  `sched_name` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '调度名称',
  `entry_id` varchar(95) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '调度器实例id',
  `trigger_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'qrtz_triggers表trigger_name的外键',
  `trigger_group` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'qrtz_triggers表trigger_group的外键',
  `instance_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '调度器实例名',
  `fired_time` bigint NOT NULL COMMENT '触发的时间',
  `sched_time` bigint NOT NULL COMMENT '定时器制定的时间',
  `priority` int NOT NULL COMMENT '优先级',
  `state` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '状态',
  `job_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '任务名称',
  `job_group` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '任务组名',
  `is_nonconcurrent` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '是否并发',
  `requests_recovery` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '是否接受恢复执行',
  PRIMARY KEY (`sched_name`, `entry_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '已触发的触发器表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for qrtz_job_details
-- ----------------------------
DROP TABLE IF EXISTS `qrtz_job_details`;
CREATE TABLE `qrtz_job_details`  (
  `sched_name` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '调度名称',
  `job_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '任务名称',
  `job_group` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '任务组名',
  `description` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '相关介绍',
  `job_class_name` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '执行任务类名称',
  `is_durable` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '是否持久化',
  `is_nonconcurrent` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '是否并发',
  `is_update_data` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '是否更新数据',
  `requests_recovery` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '是否接受恢复执行',
  `job_data` blob NULL COMMENT '存放持久化job对象',
  PRIMARY KEY (`sched_name`, `job_name`, `job_group`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '任务详细信息表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for qrtz_locks
-- ----------------------------
DROP TABLE IF EXISTS `qrtz_locks`;
CREATE TABLE `qrtz_locks`  (
  `sched_name` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '调度名称',
  `lock_name` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '悲观锁名称',
  PRIMARY KEY (`sched_name`, `lock_name`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '存储的悲观锁信息表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for qrtz_paused_trigger_grps
-- ----------------------------
DROP TABLE IF EXISTS `qrtz_paused_trigger_grps`;
CREATE TABLE `qrtz_paused_trigger_grps`  (
  `sched_name` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '调度名称',
  `trigger_group` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'qrtz_triggers表trigger_group的外键',
  PRIMARY KEY (`sched_name`, `trigger_group`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '暂停的触发器表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for qrtz_scheduler_state
-- ----------------------------
DROP TABLE IF EXISTS `qrtz_scheduler_state`;
CREATE TABLE `qrtz_scheduler_state`  (
  `sched_name` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '调度名称',
  `instance_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '实例名称',
  `last_checkin_time` bigint NOT NULL COMMENT '上次检查时间',
  `checkin_interval` bigint NOT NULL COMMENT '检查间隔时间',
  PRIMARY KEY (`sched_name`, `instance_name`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '调度器状态表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for qrtz_simple_triggers
-- ----------------------------
DROP TABLE IF EXISTS `qrtz_simple_triggers`;
CREATE TABLE `qrtz_simple_triggers`  (
  `sched_name` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '调度名称',
  `trigger_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'qrtz_triggers表trigger_name的外键',
  `trigger_group` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'qrtz_triggers表trigger_group的外键',
  `repeat_count` bigint NOT NULL COMMENT '重复的次数统计',
  `repeat_interval` bigint NOT NULL COMMENT '重复的间隔时间',
  `times_triggered` bigint NOT NULL COMMENT '已经触发的次数',
  PRIMARY KEY (`sched_name`, `trigger_name`, `trigger_group`) USING BTREE,
  CONSTRAINT `qrtz_simple_triggers_ibfk_1` FOREIGN KEY (`sched_name`, `trigger_name`, `trigger_group`) REFERENCES `qrtz_triggers` (`sched_name`, `trigger_name`, `trigger_group`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '简单触发器的信息表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for qrtz_simprop_triggers
-- ----------------------------
DROP TABLE IF EXISTS `qrtz_simprop_triggers`;
CREATE TABLE `qrtz_simprop_triggers`  (
  `sched_name` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '调度名称',
  `trigger_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'qrtz_triggers表trigger_name的外键',
  `trigger_group` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'qrtz_triggers表trigger_group的外键',
  `str_prop_1` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'String类型的trigger的第一个参数',
  `str_prop_2` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'String类型的trigger的第二个参数',
  `str_prop_3` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'String类型的trigger的第三个参数',
  `int_prop_1` int NULL DEFAULT NULL COMMENT 'int类型的trigger的第一个参数',
  `int_prop_2` int NULL DEFAULT NULL COMMENT 'int类型的trigger的第二个参数',
  `long_prop_1` bigint NULL DEFAULT NULL COMMENT 'long类型的trigger的第一个参数',
  `long_prop_2` bigint NULL DEFAULT NULL COMMENT 'long类型的trigger的第二个参数',
  `dec_prop_1` decimal(13, 4) NULL DEFAULT NULL COMMENT 'decimal类型的trigger的第一个参数',
  `dec_prop_2` decimal(13, 4) NULL DEFAULT NULL COMMENT 'decimal类型的trigger的第二个参数',
  `bool_prop_1` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'Boolean类型的trigger的第一个参数',
  `bool_prop_2` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'Boolean类型的trigger的第二个参数',
  PRIMARY KEY (`sched_name`, `trigger_name`, `trigger_group`) USING BTREE,
  CONSTRAINT `qrtz_simprop_triggers_ibfk_1` FOREIGN KEY (`sched_name`, `trigger_name`, `trigger_group`) REFERENCES `qrtz_triggers` (`sched_name`, `trigger_name`, `trigger_group`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '同步机制的行锁表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for qrtz_triggers
-- ----------------------------
DROP TABLE IF EXISTS `qrtz_triggers`;
CREATE TABLE `qrtz_triggers`  (
  `sched_name` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '调度名称',
  `trigger_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '触发器的名字',
  `trigger_group` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '触发器所属组的名字',
  `job_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'qrtz_job_details表job_name的外键',
  `job_group` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'qrtz_job_details表job_group的外键',
  `description` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '相关介绍',
  `next_fire_time` bigint NULL DEFAULT NULL COMMENT '上一次触发时间（毫秒）',
  `prev_fire_time` bigint NULL DEFAULT NULL COMMENT '下一次触发时间（默认为-1表示不触发）',
  `priority` int NULL DEFAULT NULL COMMENT '优先级',
  `trigger_state` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '触发器状态',
  `trigger_type` varchar(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '触发器的类型',
  `start_time` bigint NOT NULL COMMENT '开始时间',
  `end_time` bigint NULL DEFAULT NULL COMMENT '结束时间',
  `calendar_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '日程表名称',
  `misfire_instr` smallint NULL DEFAULT NULL COMMENT '补偿执行的策略',
  `job_data` blob NULL COMMENT '存放持久化job对象',
  PRIMARY KEY (`sched_name`, `trigger_name`, `trigger_group`) USING BTREE,
  INDEX `sched_name`(`sched_name` ASC, `job_name` ASC, `job_group` ASC) USING BTREE,
  CONSTRAINT `qrtz_triggers_ibfk_1` FOREIGN KEY (`sched_name`, `job_name`, `job_group`) REFERENCES `qrtz_job_details` (`sched_name`, `job_name`, `job_group`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '触发器详细信息表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for quality_inspect
-- ----------------------------
DROP TABLE IF EXISTS `quality_inspect`;
CREATE TABLE `quality_inspect`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `inspect_type` int NULL DEFAULT NULL COMMENT '类别(0:原材料检验;1:过程检验;2:出厂检验)',
  `check_time` date NULL DEFAULT NULL COMMENT '检测日期',
  `supplier` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供应商名称(原材料检验)',
  `customer` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '客户名称(过程检验/出厂检验)',
  `process` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '工序(过程检验)',
  `check_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '检验员',
  `product_id` bigint NULL DEFAULT NULL COMMENT '产品ID',
  `product_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产品名称',
  `model` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '规格型号',
  `unit` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '单位',
  `quantity` decimal(18, 2) NULL DEFAULT NULL COMMENT '全部数量',
  `qualified_quantity` decimal(18, 2) NULL DEFAULT NULL COMMENT '合格的数量',
  `unqualified_quantity` decimal(18, 2) NULL DEFAULT NULL COMMENT '不合格的数量',
  `check_company` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '检测单位',
  `check_result` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '检测结果',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `inspect_state` int NULL DEFAULT NULL COMMENT '类别（0-未提交 1-已提交）',
  `purchase_ledger_id` int NULL DEFAULT NULL COMMENT '采购订单id',
  `product_main_id` bigint NULL DEFAULT NULL COMMENT '报工单id',
  `defective_phenomena` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '不合格现象描述',
  `product_model_id` bigint NULL DEFAULT NULL COMMENT '产品规格id',
  `test_standard_id` int NULL DEFAULT NULL COMMENT '关联检测标准主表id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 71 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '质量管理--原材料/过程/出厂检验' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for quality_inspect_file
-- ----------------------------
DROP TABLE IF EXISTS `quality_inspect_file`;
CREATE TABLE `quality_inspect_file`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '文件名称',
  `url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '文件路径',
  `file_size` int NULL DEFAULT NULL COMMENT '文件大小',
  `inspect_id` bigint NULL DEFAULT NULL COMMENT '检验ID',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '质量管理--检验附件' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for quality_inspect_param
-- ----------------------------
DROP TABLE IF EXISTS `quality_inspect_param`;
CREATE TABLE `quality_inspect_param`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `parameter_item` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '指标',
  `unit` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '单位',
  `standard_value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '标准值',
  `control_value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '内控值',
  `test_value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '检验值',
  `inspect_id` bigint NULL DEFAULT NULL COMMENT '检验ID',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 30 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '质量管理--检验记录' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for quality_test_standard
-- ----------------------------
DROP TABLE IF EXISTS `quality_test_standard`;
CREATE TABLE `quality_test_standard`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `standard_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '标准编号指标',
  `standard_name` 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 '备注',
  `state` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '状态',
  `process_id` int NULL DEFAULT NULL COMMENT '关联工序id',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `inspect_type` int NULL DEFAULT NULL COMMENT '类别(0:原材料检验;1:过程检验;2:出厂检验)',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '质量管理--检测指标维护' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for quality_test_standard_binding
-- ----------------------------
DROP TABLE IF EXISTS `quality_test_standard_binding`;
CREATE TABLE `quality_test_standard_binding`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `product_id` bigint NULL DEFAULT NULL COMMENT '产品ID',
  `test_standard_id` int NULL DEFAULT NULL COMMENT '关联检测标准主表id',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 19 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '检测标准主表与产品关联表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for quality_test_standard_param
-- ----------------------------
DROP TABLE IF EXISTS `quality_test_standard_param`;
CREATE TABLE `quality_test_standard_param`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `parameter_item` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '参数项',
  `unit` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '单位',
  `standard_value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '标准值',
  `control_value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '内控值',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `test_standard_id` int NULL DEFAULT NULL COMMENT '关联检测标准主表id',
  `default_value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '默认值',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '检测标准参数' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for quality_unqualified
-- ----------------------------
DROP TABLE IF EXISTS `quality_unqualified`;
CREATE TABLE `quality_unqualified`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `inspect_type` int NULL DEFAULT NULL COMMENT '类别(0:原材料检验;1:过程检验;2:出厂检验)',
  `inspect_state` int NULL DEFAULT NULL COMMENT '状态(0:待处理;1:已处理)',
  `check_time` date NULL DEFAULT NULL COMMENT '检测日期',
  `check_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '检验员',
  `product_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产品名称',
  `model` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '规格型号',
  `unit` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '单位',
  `quantity` decimal(18, 2) NULL DEFAULT NULL COMMENT '数量',
  `defective_phenomena` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '不合格现象',
  `deal_result` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '处理结果',
  `deal_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '处理人',
  `deal_time` date NULL DEFAULT NULL COMMENT '处理日期',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `product_id` bigint NULL DEFAULT NULL COMMENT '产品ID',
  `inspect_id` int NULL DEFAULT NULL COMMENT '关联检验id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `product_model_id` int NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 52 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '质量管理--不合格品管理' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for reading_status
-- ----------------------------
DROP TABLE IF EXISTS `reading_status`;
CREATE TABLE `reading_status`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `rule_id` int NULL DEFAULT NULL COMMENT '用印管理-规章制度id',
  `employee` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '员工姓名',
  `department` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '所属部门',
  `confirm_time` datetime NULL DEFAULT NULL COMMENT '确认时间',
  `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '状态',
  `create_time` datetime NULL DEFAULT NULL COMMENT '阅读时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `tenant_id` int NULL DEFAULT NULL COMMENT '租户id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '用印管理-规章制度-阅读状态' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for receipt_payment
-- ----------------------------
DROP TABLE IF EXISTS `receipt_payment`;
CREATE TABLE `receipt_payment`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `sales_ledger_id` int NULL DEFAULT NULL COMMENT '销售台账id',
  `sales_ledger_product_id` int NULL DEFAULT NULL COMMENT '销售产品id',
  `invoice_ledger_id` bigint NULL DEFAULT NULL COMMENT 'invoice_ledger开票台账表主键ID',
  `receipt_payment_type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '回款形式 0电汇1承兑',
  `receipt_payment_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '回款金额',
  `registrant` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '登记人',
  `receipt_payment_date` datetime NULL DEFAULT NULL COMMENT '来款日期',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 286 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '回款登记表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for return_management
-- ----------------------------
DROP TABLE IF EXISTS `return_management`;
CREATE TABLE `return_management`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '序号',
  `return_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '退货单号',
  `customer_id` bigint NULL DEFAULT NULL COMMENT '客户 id',
  `shipping_id` bigint NULL DEFAULT NULL COMMENT '关联发货单号',
  `shipping_type` tinyint NULL DEFAULT NULL COMMENT '发货类型 1货车 2快递',
  `truck_plate_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '发货车牌号',
  `express_company` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '快递公司',
  `express_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '快递单号',
  `project_stage` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '项目阶段',
  `maker` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '制单人',
  `make_time` timestamp NULL DEFAULT NULL COMMENT '制单时间',
  `settler` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '结算人',
  `status` int NOT NULL DEFAULT 0,
  `project_id` int NULL DEFAULT NULL COMMENT '项目id',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
  `return_reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '退货原因',
  `refund_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '退款总额',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '退货管理表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for return_sale_product
-- ----------------------------
DROP TABLE IF EXISTS `return_sale_product`;
CREATE TABLE `return_sale_product`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `return_management_id` int NULL DEFAULT NULL COMMENT '退货单id',
  `stock_out_record_id` bigint NULL DEFAULT NULL COMMENT '关联出库单id',
  `num` decimal(16, 3) NOT NULL COMMENT '退货产品数量',
  `status` int NULL DEFAULT NULL COMMENT '退货状态',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `is_quality` int NULL DEFAULT NULL COMMENT '是否有质量问题(1-是 2-否)',
  `price` decimal(10, 2) NULL DEFAULT NULL COMMENT '单价',
  `amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '金额',
  `product_model_id` bigint NULL DEFAULT NULL COMMENT '产品规格id',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '退货产品表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for rpa_process_automation
-- ----------------------------
DROP TABLE IF EXISTS `rpa_process_automation`;
CREATE TABLE `rpa_process_automation`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `program_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '程序名',
  `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '执行状态',
  `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '描述',
  `create_user` int NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` int NULL DEFAULT NULL COMMENT '修改者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `tenant_id` int NULL DEFAULT NULL COMMENT '租户id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'RPA流程自动化' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for rules_regulations_management
-- ----------------------------
DROP TABLE IF EXISTS `rules_regulations_management`;
CREATE TABLE `rules_regulations_management`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `regulation_num` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '制度编号',
  `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '制度标题',
  `category` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '制度分类',
  `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '制度内容',
  `effective_time` datetime NULL DEFAULT NULL COMMENT '生效时间',
  `scope` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '适用范围',
  `require_confirm` int NULL DEFAULT NULL COMMENT '是否需要确认',
  `version` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '版本',
  `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '状态',
  `read_count` int NULL DEFAULT NULL COMMENT '已读人数',
  `create_user` int NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` int NULL DEFAULT NULL COMMENT '修改者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `tenant_id` int NULL DEFAULT NULL COMMENT '租户id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '规章制度管理' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for rules_regulations_management_file
-- ----------------------------
DROP TABLE IF EXISTS `rules_regulations_management_file`;
CREATE TABLE `rules_regulations_management_file`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '文件名称',
  `url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '文件路径',
  `file_size` int NULL DEFAULT NULL COMMENT '文件大小',
  `rules_regulations_management_id` int NULL DEFAULT NULL COMMENT '规章制度ID',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '规章制度管理--附件' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for rygl_add_employee
-- ----------------------------
DROP TABLE IF EXISTS `rygl_add_employee`;
CREATE TABLE `rygl_add_employee`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '序号',
  `status` int NULL DEFAULT NULL COMMENT '1入职2离职',
  `employee_number` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '员工编号',
  `name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '姓名',
  `sex` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '性别',
  `native_place` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '籍贯',
  `post` varchar(255) 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 '家庭住址',
  `first_degree` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '第一学历',
  `major` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '专业',
  `id_number` int NULL DEFAULT NULL COMMENT '身份证号',
  `age` int NULL DEFAULT NULL COMMENT '年龄',
  `contact_number` int NULL DEFAULT NULL COMMENT '联系电话',
  `emergency_contact` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '紧急联系人',
  `emergency_contact_number` int NULL DEFAULT NULL COMMENT '紧急联系电话',
  `contract_term` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '合同年限',
  `contract_start_date` datetime NULL DEFAULT NULL COMMENT '合同开始日期',
  `contract_end_date` datetime NULL DEFAULT NULL COMMENT '合同结束日期',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for safe_accident
-- ----------------------------
DROP TABLE IF EXISTS `safe_accident`;
CREATE TABLE `safe_accident`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `accident_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '事故编号',
  `accident_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '事故名称',
  `accident_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '事故类型',
  `happen_time` datetime NULL DEFAULT NULL COMMENT '事故发生时间',
  `happen_location` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '事故发生位置',
  `accident_grade` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '事故等级',
  `accident_cause` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '事故直接原因',
  `root_cause` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '事故根本原因',
  `person_loss` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '人员损失情况',
  `asset_loss` decimal(10, 2) NULL DEFAULT NULL COMMENT '直接财产损失（元）	',
  `production_loss` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '生产影响情况',
  `handle_measures` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '现场应急处置措施',
  `responsible_person` 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 '备注',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '上报时间',
  `create_user` int NULL DEFAULT NULL COMMENT '上报人id',
  `update_time` timestamp NULL DEFAULT NULL,
  `update_user` int NULL DEFAULT NULL,
  `tenant_id` int NULL DEFAULT NULL,
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '安全生产--事故上报记录' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for safe_certification
-- ----------------------------
DROP TABLE IF EXISTS `safe_certification`;
CREATE TABLE `safe_certification`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '规程资质名称',
  `code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '规程资质编号',
  `type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '规程资质类型',
  `version` 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 '备注',
  `effective_time` date NULL DEFAULT NULL COMMENT '有效期',
  `create_time` timestamp NULL DEFAULT NULL,
  `create_user` int NULL DEFAULT NULL,
  `update_time` timestamp NULL DEFAULT NULL,
  `update_user` int NULL DEFAULT NULL,
  `tenant_id` int NULL DEFAULT NULL,
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '安全生产--安全规程与资质管理' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for safe_certification_file
-- ----------------------------
DROP TABLE IF EXISTS `safe_certification_file`;
CREATE TABLE `safe_certification_file`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `safe_certification_id` int NULL DEFAULT NULL COMMENT '关联安全生产资质id',
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `file_size` double NULL DEFAULT NULL,
  `create_time` timestamp NULL DEFAULT NULL,
  `create_user` int NULL DEFAULT NULL,
  `update_time` timestamp NULL DEFAULT NULL,
  `update_user` int NULL DEFAULT NULL,
  `tenant_id` int NULL DEFAULT NULL,
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '安全生产--安全规程与资质管理--附件' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for safe_contingency_plan
-- ----------------------------
DROP TABLE IF EXISTS `safe_contingency_plan`;
CREATE TABLE `safe_contingency_plan`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `plan_code` varchar(255) 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(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '预案类型',
  `apply_scope` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '适用范围',
  `core_responsor_user_id` int NULL DEFAULT NULL COMMENT '核心责任人',
  `exec_steps` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '应急处置步骤',
  `publish_time` date NULL DEFAULT NULL COMMENT '发布生效时间',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` timestamp NULL DEFAULT NULL,
  `create_user` int NULL DEFAULT NULL,
  `update_time` timestamp NULL DEFAULT NULL COMMENT '最后修订时间',
  `update_user` int NULL DEFAULT NULL,
  `tenant_id` int NULL DEFAULT NULL,
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '安全生产--应急预案查阅' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for safe_hazard
-- ----------------------------
DROP TABLE IF EXISTS `safe_hazard`;
CREATE TABLE `safe_hazard`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '危险源名称',
  `code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '危险源编码',
  `type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '危险源类型',
  `risk_level` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '风险等级',
  `location` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '所在位置',
  `spec_info` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '规格 / 风险描述',
  `control_measures` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '管控措施',
  `principal_user_id` int NULL DEFAULT NULL COMMENT '管控责任人 ID',
  `principal_mobile` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '责任人联系电话',
  `stock_qty` decimal(10, 2) NULL DEFAULT NULL COMMENT '库存数量',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` timestamp NULL DEFAULT NULL,
  `create_user` int NULL DEFAULT NULL,
  `update_time` timestamp NULL DEFAULT NULL,
  `update_user` int NULL DEFAULT NULL,
  `tenant_id` int NULL DEFAULT NULL,
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '安全生产--危险源台账' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for safe_hazard_record
-- ----------------------------
DROP TABLE IF EXISTS `safe_hazard_record`;
CREATE TABLE `safe_hazard_record`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `material_record_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '单号',
  `safe_hazard_id` int NULL DEFAULT NULL COMMENT '关联危险源台账 ID',
  `apply_user_id` int NULL DEFAULT NULL COMMENT '领用人 ID',
  `apply_time` date NULL DEFAULT NULL COMMENT '领用时间',
  `apply_qty` decimal(10, 2) NULL DEFAULT NULL COMMENT '领用数量',
  `apply_purpose` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '领用用途',
  `return_user_id` int NULL DEFAULT NULL COMMENT '归还人 ID',
  `return_time` date NULL DEFAULT NULL COMMENT '归还时间',
  `return_remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '归还情况说明',
  `create_time` timestamp NULL DEFAULT NULL,
  `create_user` int NULL DEFAULT NULL,
  `update_time` timestamp NULL DEFAULT NULL,
  `update_user` int NULL DEFAULT NULL,
  `tenant_id` int NULL DEFAULT NULL,
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '安全生产--危险物料管控' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for safe_hidden
-- ----------------------------
DROP TABLE IF EXISTS `safe_hidden`;
CREATE TABLE `safe_hidden`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `hidden_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '隐患编号',
  `type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '隐患类型',
  `risk_level` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '隐患风险等级',
  `location` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '隐患具体位置',
  `hidden_desc` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '隐患描述',
  `rectify_user_id` int NULL DEFAULT NULL COMMENT '整改责任人 ID',
  `rectify_user_mobile` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '整改人联系电话',
  `rectify_time` date NULL DEFAULT NULL COMMENT '整改完成期限(日期)',
  `rectify_measures` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '整改具体措施',
  `rectify_actual_time` date NULL DEFAULT NULL COMMENT '实际整改完成时间',
  `verify_user_id` int NULL DEFAULT NULL COMMENT '验收人 ID',
  `verify_result` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '验收结果',
  `verify_remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '验收意见',
  `verify_time` date NULL DEFAULT NULL COMMENT '验收时间',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '上报时间',
  `create_user` int NULL DEFAULT NULL COMMENT '上报人id',
  `update_time` timestamp NULL DEFAULT NULL,
  `update_user` int NULL DEFAULT NULL,
  `tenant_id` int NULL DEFAULT NULL,
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '安全生产--隐患排查上报' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for safe_hidden_file
-- ----------------------------
DROP TABLE IF EXISTS `safe_hidden_file`;
CREATE TABLE `safe_hidden_file`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `safe_hidden_id` int NULL DEFAULT NULL COMMENT '关联隐患排查上报id',
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `file_size` double NULL DEFAULT NULL,
  `create_time` timestamp NULL DEFAULT NULL,
  `create_user` int NULL DEFAULT NULL,
  `update_time` timestamp NULL DEFAULT NULL,
  `update_user` int NULL DEFAULT NULL,
  `tenant_id` int NULL DEFAULT NULL,
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '安全生产--隐患排查上报--附件' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for safe_training
-- ----------------------------
DROP TABLE IF EXISTS `safe_training`;
CREATE TABLE `safe_training`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `course_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '课程编号',
  `training_objectives` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '培训目标',
  `training_content` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '培训内容',
  `training_mode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '培训方式',
  `state` int NULL DEFAULT NULL COMMENT '状态(0：未开始1：进行中；2：已结束)',
  `participants` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '参加对象',
  `place_training` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '培训地点',
  `training_lecturer` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '培训讲师',
  `training_date` date NULL DEFAULT NULL COMMENT '培训日期',
  `opening_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '开始时间(时分秒)',
  `end_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '结束时间(时分秒)',
  `project_credits` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '课题学分',
  `class_hour` double NULL DEFAULT NULL COMMENT '课时',
  `assessment_method` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '考核方式',
  `comprehensive_assessment` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '本次培训综合评价',
  `remarks` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `assessment_user_id` int NULL DEFAULT NULL COMMENT '评价人id',
  `assessment_date` date NULL DEFAULT NULL COMMENT '评价时间',
  `training_abstract` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '培训摘要',
  `create_time` timestamp NULL DEFAULT NULL,
  `create_user` int NULL DEFAULT NULL,
  `update_time` timestamp NULL DEFAULT NULL,
  `update_user` int NULL DEFAULT NULL,
  `tenant_id` int NULL DEFAULT NULL,
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '安全生产--安全培训考核' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for safe_training_details
-- ----------------------------
DROP TABLE IF EXISTS `safe_training_details`;
CREATE TABLE `safe_training_details`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `user_id` int NULL DEFAULT NULL COMMENT '用户表格（user）主键',
  `safe_training_id` int NULL DEFAULT NULL COMMENT '关联安全培训考核id',
  `examination_results` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '考核结果',
  `create_time` timestamp NULL DEFAULT NULL,
  `create_user` int NULL DEFAULT NULL,
  `update_time` timestamp NULL DEFAULT NULL,
  `update_user` int NULL DEFAULT NULL,
  `tenant_id` int NULL DEFAULT NULL,
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '安全生产--安全培训考核--记录详情' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for safe_training_file
-- ----------------------------
DROP TABLE IF EXISTS `safe_training_file`;
CREATE TABLE `safe_training_file`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `safe_training_id` int NULL DEFAULT NULL COMMENT '关联安全培训考核id',
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `file_size` double NULL DEFAULT NULL,
  `create_time` timestamp NULL DEFAULT NULL,
  `create_user` int NULL DEFAULT NULL,
  `update_time` timestamp NULL DEFAULT NULL,
  `update_user` int NULL DEFAULT NULL,
  `tenant_id` int NULL DEFAULT NULL,
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '安全生产--安全培训考核--附件' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sales_ledger
-- ----------------------------
DROP TABLE IF EXISTS `sales_ledger`;
CREATE TABLE `sales_ledger`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '销售台账主键',
  `sales_contract_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '销售合同号',
  `customer_contract_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '客户合同号',
  `project_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '项目名称',
  `entry_date` date NULL DEFAULT NULL COMMENT '录入日期',
  `salesman` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '业务员',
  `customer_id` int NULL DEFAULT NULL COMMENT '客户名称id',
  `customer_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '客户名称',
  `entry_person` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '录入人',
  `remarks` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '备注',
  `attachment_materials` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '附件材料，存储文件名等相关信息',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `contract_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '合同金额（产品含税总价）',
  `execution_date` datetime NULL DEFAULT NULL COMMENT '签订日期',
  `payment_method` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `delivery_date` timestamp NULL DEFAULT NULL COMMENT '交货日期',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_sales_entry_person`(`entry_person` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 57 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '销售台账' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sales_ledger_product
-- ----------------------------
DROP TABLE IF EXISTS `sales_ledger_product`;
CREATE TABLE `sales_ledger_product`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '产品信息主键',
  `sales_ledger_id` int NOT NULL COMMENT '关联台账主表主键',
  `product_category` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产品大类',
  `specification_model` varchar(100) 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 '单位',
  `quantity` decimal(18, 2) NOT NULL COMMENT '数量',
  `min_stock` decimal(10, 2) NULL DEFAULT NULL COMMENT '最低库存',
  `tax_rate` decimal(5, 0) NOT NULL COMMENT '税率',
  `tax_inclusive_unit_price` decimal(18, 2) NOT NULL COMMENT '含税单价',
  `tax_inclusive_total_price` decimal(18, 2) NOT NULL COMMENT '含税总价',
  `tax_exclusive_total_price` decimal(18, 2) NOT NULL COMMENT '不含税总价',
  `invoice_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '发票类型',
  `type` int NULL DEFAULT NULL COMMENT '1.销售台账，2.采购台账',
  `product_id` int NULL DEFAULT NULL COMMENT '产品id',
  `product_model_id` int NULL DEFAULT NULL COMMENT '型号id',
  `register` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '登记人',
  `register_date` datetime NULL DEFAULT NULL COMMENT '登记日期',
  `warn_num` decimal(10, 2) NULL DEFAULT NULL COMMENT '预警数量',
  `approve_status` int NULL DEFAULT 0 COMMENT '审批状态：0未出库,1已出库,2待审核(审核中),3审核完成,4审核失败',
  `is_checked` tinyint(1) NOT NULL DEFAULT 1 COMMENT '是否推送质检',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `is_production` tinyint(1) NULL DEFAULT 0 COMMENT '是否生产',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 105 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '产品信息' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sales_ledger_product_template
-- ----------------------------
DROP TABLE IF EXISTS `sales_ledger_product_template`;
CREATE TABLE `sales_ledger_product_template`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '产品信息主键',
  `sales_ledger_id` int NOT NULL COMMENT '关联台账模板主表主键',
  `product_category` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产品大类',
  `specification_model` varchar(100) 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 '单位',
  `quantity` decimal(18, 2) NULL DEFAULT NULL COMMENT '数量',
  `min_stock` decimal(10, 2) NULL DEFAULT NULL COMMENT '最低库存',
  `tax_rate` decimal(5, 0) NULL DEFAULT NULL COMMENT '税率',
  `tax_inclusive_unit_price` decimal(18, 2) NULL DEFAULT NULL COMMENT '含税单价',
  `tax_inclusive_total_price` decimal(18, 2) NULL DEFAULT NULL COMMENT '含税总价',
  `tax_exclusive_total_price` decimal(18, 2) NULL DEFAULT NULL COMMENT '不含税总价',
  `invoice_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '发票类型',
  `type` int NULL DEFAULT NULL COMMENT '1.销售台账，2.采购台账',
  `product_id` bigint NULL DEFAULT NULL COMMENT '产品id',
  `product_model_id` bigint NULL DEFAULT NULL COMMENT '型号id',
  `register` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `register_date` datetime NULL DEFAULT NULL,
  `warn_num` decimal(10, 2) NULL DEFAULT NULL,
  `is_checked` tinyint NULL DEFAULT 1 COMMENT '是否推送质检',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 13 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '产品信息模板' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sales_quotation
-- ----------------------------
DROP TABLE IF EXISTS `sales_quotation`;
CREATE TABLE `sales_quotation`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `quotation_no` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '报价单号',
  `customer_id` bigint NOT NULL DEFAULT 0 COMMENT '客户id',
  `salesperson` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '业务员',
  `quotation_date` date NULL DEFAULT NULL COMMENT '报价日期',
  `valid_date` date NULL DEFAULT NULL COMMENT '有效期至',
  `total_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '报价金额',
  `payment_method` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '付款方式',
  `delivery_period` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '交货期,天数',
  `status` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '报价状态',
  `remark` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '备注',
  `create_user` int NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` int NULL DEFAULT NULL COMMENT '修改者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `tenant_id` int NULL DEFAULT NULL COMMENT '租户id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `customer` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 49 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_bin COMMENT = '销售/报价' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sales_quotation_product
-- ----------------------------
DROP TABLE IF EXISTS `sales_quotation_product`;
CREATE TABLE `sales_quotation_product`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `sales_quotation_id` int NULL DEFAULT NULL COMMENT '销售报价单id',
  `product` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '产品名称',
  `product_id` bigint NULL DEFAULT NULL COMMENT '产品Id',
  `specification` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '规格型号',
  `quantity` int NULL DEFAULT NULL COMMENT '数量',
  `unit` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '单位',
  `unit_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '单价',
  `amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '金额',
  `create_user` int NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` int NULL DEFAULT NULL COMMENT '修改者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `tenant_id` int NULL DEFAULT NULL COMMENT '租户id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `product_model_id` bigint NULL DEFAULT NULL COMMENT '产品规格Id',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 55 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_bin COMMENT = '销售报价产品表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sales_receipt_return
-- ----------------------------
DROP TABLE IF EXISTS `sales_receipt_return`;
CREATE TABLE `sales_receipt_return`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键 ID',
  `refund_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '退款单号',
  `payment_account` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '付款账号',
  `payment_account_name` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '付款账号名称',
  `payment_method` tinyint NULL DEFAULT NULL COMMENT '付款方式',
  `actual_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '实际付款金额',
  `fee` decimal(10, 2) NULL DEFAULT NULL COMMENT '手续费',
  `transaction_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '交易号',
  `discount_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '优惠金额',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建者',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '收款退货表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sales_refund_amount_order
-- ----------------------------
DROP TABLE IF EXISTS `sales_refund_amount_order`;
CREATE TABLE `sales_refund_amount_order`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `return_management_id` bigint NULL DEFAULT NULL COMMENT '退货单号id',
  `status` int NULL DEFAULT NULL COMMENT '状态 0:待审核 1:待退款 2：已退款',
  `refund_amount` decimal(16, 3) NULL DEFAULT NULL COMMENT '应退款金额',
  `refunded_amount` decimal(16, 3) NULL DEFAULT NULL COMMENT '已退款金额',
  `not_refunded_amount` decimal(16, 3) NULL DEFAULT NULL COMMENT '未退款金额',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人id',
  `update_user` bigint NULL DEFAULT NULL COMMENT '更新人id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '销售管理--退款单' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for salesperson_management
-- ----------------------------
DROP TABLE IF EXISTS `salesperson_management`;
CREATE TABLE `salesperson_management`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
  `name` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '姓名',
  `phone` varchar(15) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '联系电话',
  `email` varchar(30) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '邮箱',
  `department` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '部门',
  `position` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '职位',
  `hire_date` datetime NULL DEFAULT NULL COMMENT '入职日期',
  `permissions` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '权限',
  `status` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '状态',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改时间',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改日期',
  `tenant_id` int NULL DEFAULT NULL COMMENT '租户id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_bin COMMENT = '业务员管理表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for scheme_applicable_staff
-- ----------------------------
DROP TABLE IF EXISTS `scheme_applicable_staff`;
CREATE TABLE `scheme_applicable_staff`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `title` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '标题',
  `dept_ids` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '部门ids',
  `staff_names` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '人员名称,多个使用,隔开',
  `staff_ids` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '人员id,多个使用,隔开',
  `insurance_types` 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 '备注',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
  `create_user` int NULL DEFAULT NULL COMMENT '创建人',
  `update_user` int NULL DEFAULT NULL COMMENT '更新人',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '社保方案适用人员表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for scheme_insurance_detail
-- ----------------------------
DROP TABLE IF EXISTS `scheme_insurance_detail`;
CREATE TABLE `scheme_insurance_detail`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '明细ID（主键）',
  `scheme_id` bigint NULL DEFAULT NULL COMMENT '关联的社保方案ID',
  `insurance_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '保险类型（如医疗保险、养老保险等）',
  `payment_base` decimal(10, 2) NULL DEFAULT NULL COMMENT '缴费基数',
  `use_basic_salary` int NULL DEFAULT 1 COMMENT '是否调用基本工资：1-否，2-是',
  `personal_ratio` decimal(5, 2) NULL DEFAULT 0.00 COMMENT '个人缴费比例（%）',
  `personal_fixed` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '个人固定缴费金额',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
  `create_user` int NULL DEFAULT NULL COMMENT '创建人',
  `update_user` int NULL DEFAULT NULL COMMENT '更新人',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '社保方案保险福利明细表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for seal_application_management
-- ----------------------------
DROP TABLE IF EXISTS `seal_application_management`;
CREATE TABLE `seal_application_management`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `application_num` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '申请编号',
  `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '申请标题',
  `seal_type` varchar(255) 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 '申请用印原因',
  `urgency` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '紧急程度',
  `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '状态',
  `create_user` int NULL DEFAULT NULL COMMENT '创建人-申请人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间-申请时间',
  `tenant_id` int NULL DEFAULT NULL COMMENT '租户id',
  `approve_user_id` int NULL DEFAULT NULL COMMENT '审批人id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '用印申请管理' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for shipping_info
-- ----------------------------
DROP TABLE IF EXISTS `shipping_info`;
CREATE TABLE `shipping_info`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
  `sales_ledger_id` bigint NULL DEFAULT NULL COMMENT '销售台账id',
  `shipping_date` datetime NULL DEFAULT NULL COMMENT '发货日期',
  `shipping_car_number` varchar(30) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '发货车牌号',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户id',
  `sales_ledger_product_id` int NULL DEFAULT NULL COMMENT '销售台账产品表id',
  `shipping_no` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '发货编号',
  `express_number` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '快递单号',
  `express_company` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '快递公司',
  `type` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '发货类型',
  `status` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '状态',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_shipping_sales_ledger_status`(`sales_ledger_id` ASC, `status` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 68 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_bin COMMENT = '发货信息表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for shipping_product_detail
-- ----------------------------
DROP TABLE IF EXISTS `shipping_product_detail`;
CREATE TABLE `shipping_product_detail`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `stock_inventory_id` bigint NULL DEFAULT NULL COMMENT '库存表id',
  `batch_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '批次号',
  `quantity` decimal(16, 4) NULL DEFAULT NULL COMMENT '发货的数量',
  `shipping_info_id` bigint NULL DEFAULT NULL COMMENT '发货台账id',
  `product_model_id` bigint NULL DEFAULT NULL COMMENT '产品id',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 80 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '发货台账详情表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for spare_parts
-- ----------------------------
DROP TABLE IF EXISTS `spare_parts`;
CREATE TABLE `spare_parts`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备件分类名称',
  `parent_id` int NULL DEFAULT NULL COMMENT '备件分类父id',
  `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '状态',
  `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '描述',
  `create_user` int NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` int NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `tenant_id` int NULL DEFAULT NULL COMMENT '租户id',
  `price` decimal(10, 2) NULL DEFAULT NULL COMMENT '价格',
  `quantity` decimal(10, 2) NULL DEFAULT NULL COMMENT '数量',
  `device_ids` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '设备id集合（字符串,隔开）',
  `spare_parts_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备管理-备件管理' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for spare_parts_requisition_record
-- ----------------------------
DROP TABLE IF EXISTS `spare_parts_requisition_record`;
CREATE TABLE `spare_parts_requisition_record`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `source_type` smallint NULL DEFAULT NULL COMMENT '来源类型(0 维修 1 保养)',
  `source_id` bigint NOT NULL DEFAULT 0 COMMENT '来源id',
  `device_ledger_id` bigint NOT NULL DEFAULT 0 COMMENT '设备id',
  `spare_parts_id` bigint NOT NULL DEFAULT 0 COMMENT '备件id',
  `quantity` int NOT NULL DEFAULT 0 COMMENT '数量',
  `create_user` bigint NOT NULL DEFAULT 0 COMMENT '创建人',
  `tenant_id` bigint NOT NULL COMMENT '租户id',
  `create_time` datetime NULL DEFAULT NULL COMMENT '录入时间',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 12 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备报修保养的备件领使用表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for staff_contacts_personal
-- ----------------------------
DROP TABLE IF EXISTS `staff_contacts_personal`;
CREATE TABLE `staff_contacts_personal`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `contact_id` int NULL DEFAULT NULL COMMENT '员工ID',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_bin COMMENT = '个人通讯录' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for staff_contract
-- ----------------------------
DROP TABLE IF EXISTS `staff_contract`;
CREATE TABLE `staff_contract`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `staff_on_job_id` bigint NOT NULL DEFAULT 0 COMMENT '员工在职id',
  `contract_start_time` datetime NULL DEFAULT NULL COMMENT '合同开始时间',
  `contract_end_time` datetime NULL DEFAULT NULL COMMENT '合同结束时间',
  `contract_term` int NOT NULL DEFAULT 0 COMMENT '合同期限',
  `tenant_id` bigint NOT NULL COMMENT '租户id',
  `create_time` datetime NULL DEFAULT NULL COMMENT '录入时间',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 23 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for staff_education
-- ----------------------------
DROP TABLE IF EXISTS `staff_education`;
CREATE TABLE `staff_education`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `staff_on_job_id` bigint NOT NULL COMMENT '关联staff_on_job表主键ID',
  `education` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '学历',
  `school_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '毕业院校',
  `enroll_time` date NULL DEFAULT NULL COMMENT '入学时间',
  `graduate_time` date NULL DEFAULT NULL COMMENT '毕业时间',
  `major` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '专业',
  `degree` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '学位',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '员工教育经历表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for staff_emergency_contact
-- ----------------------------
DROP TABLE IF EXISTS `staff_emergency_contact`;
CREATE TABLE `staff_emergency_contact`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `staff_on_job_id` bigint NOT NULL COMMENT '关联staff_on_job表主键ID',
  `contact_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '紧急联系人姓名',
  `contact_relation` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '紧急联系人关系',
  `contact_phone` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '紧急联系人手机',
  `contact_address` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '紧急联系人住址',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '员工紧急联系人表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for staff_join_leave_record
-- ----------------------------
DROP TABLE IF EXISTS `staff_join_leave_record`;
CREATE TABLE `staff_join_leave_record`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `staff_state` int NULL DEFAULT NULL COMMENT '状态(0:离职;1:入职)',
  `staff_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '员工编号',
  `leave_date` date NULL DEFAULT NULL COMMENT '离职日期',
  `staff_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '员工姓名',
  `sex` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '性别',
  `native_place` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '籍贯',
  `post_job` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '岗位',
  `adress` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '家庭住址',
  `first_study` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '第一学历',
  `profession` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '专业',
  `identity_card` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '身份证号码',
  `age` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '年龄',
  `phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '联系电话',
  `emergency_contact` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '紧急联系人',
  `emergency_contact_phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '紧急联系人电话',
  `contract_term` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '合同年限',
  `contract_start_time` date NULL DEFAULT NULL COMMENT '合同开始日期',
  `contract_end_time` date NULL DEFAULT NULL COMMENT '合同结束日期',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `probation_period` int NULL DEFAULT NULL COMMENT '试用期（月）',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '人员管理--新增入职/离职' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for staff_leave
-- ----------------------------
DROP TABLE IF EXISTS `staff_leave`;
CREATE TABLE `staff_leave`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `staff_on_job_id` bigint NOT NULL DEFAULT 0 COMMENT '员工在职id',
  `reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '离职原因',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '离职备注',
  `tenant_id` bigint NOT NULL COMMENT '租户id',
  `create_time` datetime NULL DEFAULT NULL COMMENT '录入时间',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `leave_date` date NULL DEFAULT NULL COMMENT '离职日期',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for staff_on_job
-- ----------------------------
DROP TABLE IF EXISTS `staff_on_job`;
CREATE TABLE `staff_on_job`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `staff_state` int NULL DEFAULT NULL COMMENT '状态(0:离职;1:在职)',
  `staff_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '员工编号',
  `staff_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '员工姓名',
  `sex` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '性别',
  `native_place` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '籍贯',
  `adress` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '家庭住址',
  `first_study` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '第一学历',
  `profession` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '专业',
  `identity_card` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '身份证号码',
  `age` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '年龄',
  `phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '联系电话',
  `emergency_contact` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '紧急联系人',
  `emergency_contact_phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '紧急联系人电话',
  `contract_term` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '合同年限',
  `contract_expire_time` date NULL DEFAULT NULL COMMENT '合同到期日期',
  `trial_end_date` date NULL DEFAULT NULL COMMENT '结束试用时间',
  `trial_start_date` date NULL DEFAULT NULL COMMENT '开始试用时间',
  `salary_select` char(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '工资报酬选择条款',
  `pro_salary` decimal(10, 2) NULL DEFAULT NULL COMMENT '试用期工资',
  `date_select` char(15) 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 '无' COMMENT '备注（福利待遇）',
  `sign_date` date NULL DEFAULT NULL COMMENT '签订日期',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `sys_post_id` bigint NOT NULL DEFAULT 0 COMMENT '岗位id',
  `sys_dept_id` bigint NOT NULL DEFAULT 0 COMMENT '部门id',
  `role_id` bigint NULL DEFAULT NULL COMMENT '角色id',
  `alias` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '别名',
  `birth_date` date NULL DEFAULT NULL COMMENT '出生日期',
  `nation` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '汉族' COMMENT '民族',
  `marital_status` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '未婚' COMMENT '婚姻状况',
  `pro_term` int NULL DEFAULT 3 COMMENT '试用期（月）',
  `positive_date` date NULL DEFAULT NULL COMMENT '转正日期',
  `basic_salary` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '基本工资',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `staff_no`(`staff_no` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 27 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '人员管理--员工台账/合同管理' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for staff_salary_detail
-- ----------------------------
DROP TABLE IF EXISTS `staff_salary_detail`;
CREATE TABLE `staff_salary_detail`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `main_id` bigint NOT NULL COMMENT '关联工资主表ID',
  `staff_on_job_id` bigint NOT NULL COMMENT '关联staff_on_job表主键ID',
  `staff_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '员工姓名',
  `post_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '职位名称',
  `dept_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '部门名称',
  `basic_salary` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '基本工资',
  `piece_salary` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '计件工资',
  `hourly_salary` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '计时工资',
  `other_income` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '其他收入',
  `social_personal` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '社保个人',
  `fund_personal` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '公积金个人',
  `other_deduct` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '其他支出',
  `salary_tax` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '工资个税',
  `gross_salary` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '应发工资',
  `deduct_salary` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '应扣工资',
  `net_salary` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '实发工资',
  `remark` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `social_supplement_amount` decimal(18, 2) NOT NULL DEFAULT 0.00 COMMENT '社保补缴',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 185 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '员工工资明细表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for staff_salary_main
-- ----------------------------
DROP TABLE IF EXISTS `staff_salary_main`;
CREATE TABLE `staff_salary_main`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `audit_user_id` bigint NULL DEFAULT NULL COMMENT '审核人id',
  `audit_user_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '审核人名称',
  `salary_title` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '工资主题',
  `dept_ids` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '关联部门ID，多个用逗号分隔',
  `salary_month` varchar(7) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '工资月份，格式：yyyy-MM',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `status` tinyint NOT NULL DEFAULT 0 COMMENT '状态：1-草稿 2-审核未通过 3-待审核 4-待发放 5-已发放',
  `total_salary` decimal(12, 2) NULL DEFAULT NULL COMMENT '工资总额',
  `pay_bank` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '支付银行',
  `pay_time` datetime NULL DEFAULT NULL COMMENT '发放时间',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '员工工资主表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for staff_scheduling
-- ----------------------------
DROP TABLE IF EXISTS `staff_scheduling`;
CREATE TABLE `staff_scheduling`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `staff_id` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '员工ID',
  `department` int NULL DEFAULT NULL COMMENT '部门',
  `shift_type` int NULL DEFAULT NULL COMMENT '排班类型',
  `work_date` date NULL DEFAULT NULL COMMENT '工作日期',
  `work_start_time` timestamp NULL DEFAULT NULL COMMENT '开始工作时间',
  `lunch_time` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '午休时间',
  `work_end_time` timestamp NULL DEFAULT NULL COMMENT '结束工作时间',
  `work_hours` decimal(10, 2) NULL DEFAULT NULL COMMENT '工作时长',
  `status` int NULL DEFAULT NULL COMMENT '状态',
  `staff_name` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL,
  `remark` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_bin ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for staff_work_experience
-- ----------------------------
DROP TABLE IF EXISTS `staff_work_experience`;
CREATE TABLE `staff_work_experience`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `staff_on_job_id` bigint NOT NULL COMMENT '关联staff_on_job表主键ID',
  `former_company` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '前公司',
  `former_dept` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '前公司部门',
  `former_position` varchar(50) 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 '结束日期',
  `work_desc` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '工作描述',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '员工工作经历表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for stock_in_record
-- ----------------------------
DROP TABLE IF EXISTS `stock_in_record`;
CREATE TABLE `stock_in_record`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `inbound_batches` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '入库批次',
  `batch_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '批号',
  `stock_in_num` decimal(16, 4) NULL DEFAULT NULL COMMENT '入库数量',
  `record_id` int NULL DEFAULT NULL COMMENT '入库来源id',
  `record_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '入库类型',
  `product_model_id` int NULL DEFAULT NULL COMMENT '产品规格id',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
  `create_user` int NULL DEFAULT NULL COMMENT '创建人',
  `update_user` int NULL DEFAULT NULL COMMENT '更新人',
  `type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '0合格入库1不合格入库',
  `weighing_date` datetime NULL DEFAULT NULL COMMENT '过磅日期',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `approval_status` int NULL DEFAULT 0,
  `warn_num` decimal(16, 4) NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 153 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '入库记录表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for stock_inventory
-- ----------------------------
DROP TABLE IF EXISTS `stock_inventory`;
CREATE TABLE `stock_inventory`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `product_model_id` int NULL DEFAULT NULL COMMENT '规格id',
  `batch_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '批号',
  `qualitity` decimal(16, 4) NULL DEFAULT NULL COMMENT '数量',
  `create_time` timestamp NULL DEFAULT NULL,
  `update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
  `version` int NULL DEFAULT NULL COMMENT '版本号',
  `locked_quantity` decimal(16, 4) NULL DEFAULT 0.0000 COMMENT '被订单锁定数量',
  `warn_num` decimal(16, 4) NULL DEFAULT NULL COMMENT '预警数量',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 72 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '库存表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for stock_out_record
-- ----------------------------
DROP TABLE IF EXISTS `stock_out_record`;
CREATE TABLE `stock_out_record`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `outbound_batches` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '入库批次',
  `batch_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '批号',
  `stock_out_num` decimal(16, 4) NULL DEFAULT NULL COMMENT '入库数量',
  `record_id` int NULL DEFAULT NULL COMMENT '入库来源id',
  `record_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '入库类型',
  `product_model_id` int NULL DEFAULT NULL COMMENT '产品规格id',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
  `create_user` int NULL DEFAULT NULL COMMENT '创建人',
  `update_user` int NULL DEFAULT NULL COMMENT '更新人',
  `type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '0合格出库1不合格出库',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `approval_status` int NULL DEFAULT 0 COMMENT '审批状态  0-待审批 1-通过 2-驳回 3-销售出库待确认',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 157 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '出库记录表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for stock_uninventory
-- ----------------------------
DROP TABLE IF EXISTS `stock_uninventory`;
CREATE TABLE `stock_uninventory`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `product_model_id` int NULL DEFAULT NULL COMMENT '规格id',
  `batch_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '批号',
  `qualitity` decimal(16, 4) NULL DEFAULT NULL COMMENT '数量',
  `create_time` timestamp NULL DEFAULT NULL,
  `update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
  `version` int NULL DEFAULT NULL COMMENT '版本号',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `locked_quantity` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '冻结数量',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 12 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '不合格库存表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for storage_attachment
-- ----------------------------
DROP TABLE IF EXISTS `storage_attachment`;
CREATE TABLE `storage_attachment`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `deleted` bigint NOT NULL DEFAULT 0 COMMENT '逻辑删除（0正常）',
  `record_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '关联的记录类型',
  `record_id` bigint NULL DEFAULT NULL COMMENT '关联的记录ID',
  `application` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '文件用途，如 file/avatar',
  `storage_blob_id` bigint NULL DEFAULT NULL COMMENT '关联storage_blob记录ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 215 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '文件关联表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for storage_blob
-- ----------------------------
DROP TABLE IF EXISTS `storage_blob`;
CREATE TABLE `storage_blob`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `resource_key` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '资源唯一标识（如对象存储key）',
  `content_type` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '资源类型，如 image/jpeg',
  `original_filename` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '原文件名',
  `uid_filename` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '唯一文件名',
  `byte_size` bigint NULL DEFAULT NULL COMMENT '文件大小（字节）',
  `path` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '文件路径（本地或URL）',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 195 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '文件表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for supplier_manage
-- ----------------------------
DROP TABLE IF EXISTS `supplier_manage`;
CREATE TABLE `supplier_manage`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `supplier_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供应商名称',
  `taxpayer_identification_num` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '纳税人识别号',
  `company_address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '公司地址',
  `supplier_type` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供应商类型',
  `company_phone` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '公司电话',
  `bank_account_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '开户行',
  `bank_account_num` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '账号',
  `contact_user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '联系人',
  `contact_user_phone` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '联系电话',
  `maintain_user_id` bigint NULL DEFAULT NULL COMMENT '维护人ID',
  `maintain_time` datetime NULL DEFAULT NULL COMMENT '维护时间',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `is_white` bigint NULL DEFAULT 0 COMMENT '是否白名单（0是 1否）',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 223 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '供应商管理' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for supplier_manage_file
-- ----------------------------
DROP TABLE IF EXISTS `supplier_manage_file`;
CREATE TABLE `supplier_manage_file`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '文件名称',
  `url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '文件路径',
  `file_size` int NULL DEFAULT NULL COMMENT '文件大小',
  `supplier_id` bigint NULL DEFAULT NULL COMMENT '供应商ID',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '供应商管理--资质附件' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sys_config
-- ----------------------------
DROP TABLE IF EXISTS `sys_config`;
CREATE TABLE `sys_config`  (
  `config_id` int NOT NULL AUTO_INCREMENT COMMENT '参数主键',
  `config_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '参数名称',
  `config_key` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '参数键名',
  `config_value` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '参数键值',
  `config_type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT 'N' COMMENT '系统内置（Y是 N否）',
  `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 '更新时间',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`config_id`) USING BTREE,
  INDEX `idx_config_key`(`config_key` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_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 AUTO_INCREMENT COMMENT '部门id',
  `parent_id` bigint NULL DEFAULT 0 COMMENT '父部门id',
  `ancestors` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '祖级列表',
  `dept_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '部门名称',
  `order_num` int NULL DEFAULT 0 COMMENT '显示顺序',
  `leader` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '负责人',
  `phone` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '联系电话',
  `email` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '邮箱',
  `status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '0' COMMENT '部门状态（0正常 1停用）',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '0' COMMENT '删除标志（0代表存在 2代表删除）',
  `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 '更新时间',
  `dept_nick` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '部门编号',
  PRIMARY KEY (`dept_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 213 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_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 AUTO_INCREMENT COMMENT '字典编码',
  `dict_sort` int NULL DEFAULT 0 COMMENT '字典排序',
  `dict_label` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '字典标签',
  `dict_value` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '字典键值',
  `dict_type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '字典类型',
  `css_class` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '样式属性（其他样式扩展）',
  `list_class` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '表格回显样式',
  `is_default` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT 'N' COMMENT '是否默认（Y是 N否）',
  `status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci 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 '更新时间',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`dict_code`) USING BTREE,
  INDEX `idx_dict_type_status`(`dict_type` ASC, `status` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 260 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_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 AUTO_INCREMENT COMMENT '字典主键',
  `dict_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '字典名称',
  `dict_type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '字典类型',
  `status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci 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 '更新时间',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`dict_id`) USING BTREE,
  UNIQUE INDEX `dict_type`(`dict_type` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 137 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '字典类型表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sys_job
-- ----------------------------
DROP TABLE IF EXISTS `sys_job`;
CREATE TABLE `sys_job`  (
  `job_id` bigint NOT NULL AUTO_INCREMENT COMMENT '任务ID',
  `job_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '任务名称',
  `job_group` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'DEFAULT' COMMENT '任务组名',
  `invoke_target` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '调用目标字符串',
  `cron_expression` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT 'cron执行表达式',
  `misfire_policy` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '3' COMMENT '计划执行错误策略（1立即执行 2执行一次 3放弃执行）',
  `concurrent` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '1' COMMENT '是否并发执行（0允许 1禁止）',
  `status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci 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 '更新时间',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '备注信息',
  PRIMARY KEY (`job_id`, `job_name`, `job_group`) USING BTREE,
  INDEX `idx_job_status`(`status` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '定时任务调度表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sys_job_log
-- ----------------------------
DROP TABLE IF EXISTS `sys_job_log`;
CREATE TABLE `sys_job_log`  (
  `job_log_id` bigint NOT NULL AUTO_INCREMENT COMMENT '任务日志ID',
  `job_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '任务名称',
  `job_group` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '任务组名',
  `invoke_target` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '调用目标字符串',
  `job_message` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '日志信息',
  `status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '0' COMMENT '执行状态（0正常 1失败）',
  `exception_info` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '异常信息',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  PRIMARY KEY (`job_log_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_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 AUTO_INCREMENT COMMENT '访问ID',
  `user_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '用户账号',
  `ipaddr` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '登录IP地址',
  `login_location` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '登录地点',
  `browser` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '浏览器类型',
  `os` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '操作系统',
  `status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '0' COMMENT '登录状态（0成功 1失败）',
  `msg` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '提示消息',
  `login_time` datetime NULL DEFAULT NULL COMMENT '访问时间',
  PRIMARY KEY (`info_id`) USING BTREE,
  INDEX `idx_sys_logininfor_s`(`status` ASC) USING BTREE,
  INDEX `idx_sys_logininfor_lt`(`login_time` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4498 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_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 AUTO_INCREMENT COMMENT '菜单ID',
  `menu_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_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_0900_ai_ci NULL DEFAULT '' COMMENT '路由地址',
  `component` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '组件路径',
  `query` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '路由参数',
  `route_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' 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_0900_ai_ci NULL DEFAULT '' COMMENT '菜单类型（M目录 C菜单 F按钮）',
  `visible` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '0' COMMENT '菜单状态（0显示 1隐藏）',
  `status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '0' COMMENT '菜单状态（0正常 1停用）',
  `perms` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '权限标识',
  `icon` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '#' COMMENT '菜单图标',
  `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 '更新时间',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '备注',
  `app_component` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'app组件路径',
  PRIMARY KEY (`menu_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2348 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '菜单权限表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sys_notice
-- ----------------------------
DROP TABLE IF EXISTS `sys_notice`;
CREATE TABLE `sys_notice`  (
  `notice_id` int NOT NULL AUTO_INCREMENT COMMENT '公告ID',
  `notice_title` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '公告标题',
  `notice_type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '公告类型（1通知 2公告）',
  `notice_content` longblob NULL COMMENT '公告内容',
  `status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '0' COMMENT '公告状态（0正常 1关闭）',
  `consignee_id` bigint NULL DEFAULT NULL COMMENT '发送人id',
  `sender_id` bigint NULL DEFAULT NULL COMMENT '收件人id',
  `jump_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '跳转路径',
  `app_jump_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'APP跳转路径',
  `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 '更新时间',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `tenant_id` int NULL DEFAULT NULL,
  PRIMARY KEY (`notice_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1296 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_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 AUTO_INCREMENT COMMENT '日志主键',
  `title` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '模块标题',
  `business_type` int NULL DEFAULT 0 COMMENT '业务类型（0其它 1新增 2修改 3删除）',
  `method` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '方法名称',
  `request_method` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '请求方式',
  `operator_type` int NULL DEFAULT 0 COMMENT '操作类别（0其它 1后台用户 2手机端用户）',
  `oper_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '操作人员',
  `dept_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '部门名称',
  `oper_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '请求URL',
  `oper_ip` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '主机地址',
  `oper_location` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '操作地点',
  `oper_param` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '请求参数',
  `json_result` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '返回参数',
  `status` int NULL DEFAULT 0 COMMENT '操作状态（0正常 1异常）',
  `error_msg` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '错误消息',
  `oper_time` datetime NULL DEFAULT NULL COMMENT '操作时间',
  `cost_time` bigint NULL DEFAULT 0 COMMENT '消耗时间',
  PRIMARY KEY (`oper_id`) USING BTREE,
  INDEX `idx_sys_oper_log_bt`(`business_type` ASC) USING BTREE,
  INDEX `idx_sys_oper_log_s`(`status` ASC) USING BTREE,
  INDEX `idx_sys_oper_log_ot`(`oper_time` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 119789 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_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 AUTO_INCREMENT COMMENT '岗位ID',
  `post_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '岗位编码',
  `post_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '岗位名称',
  `post_sort` int NOT NULL COMMENT '显示顺序',
  `status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL 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 '更新时间',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`post_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 26 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_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 AUTO_INCREMENT COMMENT '角色ID',
  `role_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '角色名称',
  `role_key` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '角色权限字符串',
  `role_sort` int NOT NULL COMMENT '显示顺序',
  `data_scope` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_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_0900_ai_ci NOT NULL COMMENT '角色状态（0正常 1停用）',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '0' COMMENT '删除标志（0代表存在 2代表删除）',
  `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 '更新时间',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`role_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 112 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_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_0900_ai_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_0900_ai_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 AUTO_INCREMENT COMMENT '用户ID',
  `user_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '用户账号',
  `nick_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '用户昵称',
  `user_type` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '00' COMMENT '用户类型（00系统用户）',
  `email` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '用户邮箱',
  `phonenumber` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '手机号码',
  `sex` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '0' COMMENT '用户性别（0男 1女 2未知）',
  `avatar` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '头像地址',
  `password` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '密码',
  `status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '0' COMMENT '账号状态（0正常 1停用）',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '0' COMMENT '删除标志（0代表存在 2代表删除）',
  `login_ip` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '最后登录IP',
  `login_date` datetime NULL DEFAULT NULL COMMENT '最后登录时间',
  `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 '更新时间',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `ai_enabled` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否开通AI功能（0否 1是）',
  PRIMARY KEY (`user_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 262 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '用户信息表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sys_user_client
-- ----------------------------
DROP TABLE IF EXISTS `sys_user_client`;
CREATE TABLE `sys_user_client`  (
  `user_id` bigint NOT NULL COMMENT '用户ID',
  `cid` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '个推CID',
  `update_time` datetime NULL DEFAULT NULL COMMENT '最后活跃时间',
  PRIMARY KEY (`user_id`) USING BTREE,
  UNIQUE INDEX `uk_cid`(`cid` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '用户安卓设备' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sys_user_dept
-- ----------------------------
DROP TABLE IF EXISTS `sys_user_dept`;
CREATE TABLE `sys_user_dept`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `user_id` bigint NULL DEFAULT NULL COMMENT 'sys_user表主键',
  `dept_id` bigint NULL DEFAULT NULL COMMENT 'sys_dept表主键',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '更新者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 648 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci 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_0900_ai_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_0900_ai_ci COMMENT = '用户和角色关联表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for technology_bom
-- ----------------------------
DROP TABLE IF EXISTS `technology_bom`;
CREATE TABLE `technology_bom`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `product_model_id` bigint NOT NULL COMMENT '产品规格id',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `version` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '版本号',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建者',
  `update_user` bigint NULL DEFAULT NULL COMMENT '更新者',
  `bom_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'BOM编号',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 17 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'BOM表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for technology_bom_structure
-- ----------------------------
DROP TABLE IF EXISTS `technology_bom_structure`;
CREATE TABLE `technology_bom_structure`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `parent_id` bigint NULL DEFAULT NULL COMMENT '父节点ID',
  `product_model_id` bigint NOT NULL COMMENT '产品id',
  `operation_id` bigint NULL DEFAULT NULL COMMENT '工序id',
  `unit_quantity` decimal(16, 4) NOT NULL COMMENT '单位产出需要数量',
  `demanded_quantity` decimal(16, 4) NULL DEFAULT NULL COMMENT '需求数量',
  `unit` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '单位',
  `bom_id` bigint NOT NULL COMMENT 'bom的id',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 61 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'BOM产品结构表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for technology_operation
-- ----------------------------
DROP TABLE IF EXISTS `technology_operation`;
CREATE TABLE `technology_operation`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `create_time` datetime NULL DEFAULT NULL COMMENT '录入时间',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '工艺名称',
  `no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '工艺编号',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '备注',
  `salary_quota` decimal(16, 3) NULL DEFAULT NULL COMMENT '工资定额',
  `is_quality` tinyint(1) NULL DEFAULT 1 COMMENT '是否质检工序',
  `is_production` tinyint(1) NULL DEFAULT 1 COMMENT '是否生产',
  `type` int NULL DEFAULT NULL COMMENT '类型 区分计时和计件(0计时1计件)',
  `device_ledger_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '设备id',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 18 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '工序表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for technology_operation_param
-- ----------------------------
DROP TABLE IF EXISTS `technology_operation_param`;
CREATE TABLE `technology_operation_param`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
  `technology_param_id` bigint NULL DEFAULT NULL COMMENT '基础参数表id',
  `technology_operation_id` bigint NULL DEFAULT NULL COMMENT '工序id',
  `standard_value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '标准值',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 20 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '工序参数' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for technology_param
-- ----------------------------
DROP TABLE IF EXISTS `technology_param`;
CREATE TABLE `technology_param`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `param_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '参数编码(唯一标识)',
  `param_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '参数名称',
  `param_type` tinyint NOT NULL COMMENT '参数类型(1数字 2文本 3下拉选择 4时间)',
  `param_format` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '参数格式',
  `unit` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '单位',
  `is_required` tinyint NULL DEFAULT 0 COMMENT '是否必填',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_user` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '修改人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 38 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '基础参数表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for technology_routing
-- ----------------------------
DROP TABLE IF EXISTS `technology_routing`;
CREATE TABLE `technology_routing`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `product_model_id` bigint NOT NULL DEFAULT 0 COMMENT '产品id',
  `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '描述',
  `create_time` datetime NULL DEFAULT NULL COMMENT '录入时间',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `process_route_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '工艺路线编码',
  `bom_id` int NULL DEFAULT NULL COMMENT '关联bom的id',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 17 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '工艺路线表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for technology_routing_operation
-- ----------------------------
DROP TABLE IF EXISTS `technology_routing_operation`;
CREATE TABLE `technology_routing_operation`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `technology_routing_id` bigint NOT NULL DEFAULT 0 COMMENT '工艺路线id',
  `product_model_id` bigint NOT NULL DEFAULT 0 COMMENT '产品id',
  `technology_operation_id` bigint NOT NULL DEFAULT 0 COMMENT '工序id',
  `create_time` datetime NULL DEFAULT NULL COMMENT '录入时间',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `drag_sort` int NULL DEFAULT NULL COMMENT '拖动排序',
  `is_quality` tinyint(1) NULL DEFAULT 1 COMMENT '是否质检工序',
  `is_production` tinyint(1) NULL DEFAULT 1 COMMENT '是否生产',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `type` int NULL DEFAULT NULL COMMENT '类型 区分计时和计件(0计时1计件)',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 42 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '工艺路线工序表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for technology_routing_operation_param
-- ----------------------------
DROP TABLE IF EXISTS `technology_routing_operation_param`;
CREATE TABLE `technology_routing_operation_param`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
  `param_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '参数编码(唯一标识)',
  `param_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '参数名称',
  `param_type` tinyint NOT NULL COMMENT '参数类型(1数字 2文本 3下拉选择 4时间)',
  `param_format` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '参数格式',
  `unit` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '单位',
  `is_required` tinyint NULL DEFAULT 0 COMMENT '是否必填',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `create_user` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '修改人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  `param_id` bigint NULL DEFAULT NULL COMMENT '基础参数ID',
  `technology_operation_id` bigint NULL DEFAULT NULL COMMENT '工序id',
  `technology_operation_param_id` bigint NULL DEFAULT NULL COMMENT '工序参数ID',
  `technology_routing_operation_id` bigint NULL DEFAULT NULL COMMENT '工艺路线工序ID',
  `standard_value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '标准值',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 79 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '工艺路线工序参数表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for temp_file
-- ----------------------------
DROP TABLE IF EXISTS `temp_file`;
CREATE TABLE `temp_file`  (
  `temp_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '临时文件ID',
  `original_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '原始文件名',
  `temp_path` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '临时存储路径',
  `expire_time` datetime NOT NULL COMMENT '过期时间',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `status` tinyint NULL DEFAULT 0 COMMENT '状态：0=临时，1=已确认，2=已过期',
  `type` int NULL DEFAULT NULL,
  `file_size` bigint NULL DEFAULT NULL COMMENT '文件大小',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`temp_id`) USING BTREE,
  INDEX `idx_expire_time`(`expire_time` ASC) USING BTREE COMMENT '用于过期文件清理的索引',
  INDEX `idx_status`(`status` ASC) USING BTREE COMMENT '用于状态查询的索引'
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '临时文件记录表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ticket_registration
-- ----------------------------
DROP TABLE IF EXISTS `ticket_registration`;
CREATE TABLE `ticket_registration`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `purchase_contract_number` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '采购合同号',
  `sales_contract_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '销售合同号',
  `customer_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '客户名称',
  `business_person` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '业务员',
  `project_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '项目名称',
  `product_id` int NULL DEFAULT NULL COMMENT '产品信息',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `purchase_ledger_id` int NULL DEFAULT NULL COMMENT '采购台账id',
  `supplier_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供应商名称',
  `sales_ledger_id` int NULL DEFAULT NULL COMMENT '关联销售台账主表主键',
  `business_person_id` int NULL DEFAULT NULL COMMENT '业务员id',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `contract_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '合同金额',
  `invoice_number` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '发票号',
  `invoice_amount` decimal(10, 2) NOT NULL COMMENT '发票金额（元）',
  `iss_uer_id` int NULL DEFAULT NULL COMMENT '开票人id',
  `iss_uer` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '开票人',
  `issue_date` date NULL DEFAULT NULL COMMENT '开票日期',
  `enter_date` timestamp NULL DEFAULT NULL,
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建人ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 158 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '来票登记表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for timing_task
-- ----------------------------
DROP TABLE IF EXISTS `timing_task`;
CREATE TABLE `timing_task`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `task_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备名称',
  `inspection_project` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '巡检项目',
  `task_id` int NULL DEFAULT NULL COMMENT '设备id',
  `inspector_ids` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '巡检人',
  `inspection_location` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '巡检地点',
  `frequency_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '频次',
  `frequency_detail` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `next_execution_time` datetime(6) NULL DEFAULT NULL,
  `last_execution_time` datetime(6) NULL DEFAULT NULL,
  `is_active` tinyint(1) NULL DEFAULT NULL,
  `is_enabled` tinyint(1) NOT NULL DEFAULT 1 COMMENT '是否启用 0否 1是',
  `remarks` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '备注',
  `registrant_id` bigint NULL DEFAULT NULL COMMENT '登记人id',
  `registrant` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '登记人',
  `registration_date` date NOT NULL COMMENT '登记日期',
  `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `deleted` int NOT NULL DEFAULT 0 COMMENT '软删除标志，0=未删除，1=已删除',
  `create_user` int NULL DEFAULT NULL COMMENT '创建该记录的用户',
  `create_time` datetime(6) NULL DEFAULT NULL COMMENT '记录创建时间',
  `update_user` int NULL DEFAULT NULL COMMENT '最后修改该记录的用户',
  `update_time` datetime(6) NULL DEFAULT NULL COMMENT '记录最后更新时间',
  `tenant_id` int NULL DEFAULT NULL,
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_timing_task_is_enabled`(`is_enabled` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '定时巡检任务表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for warehouse
-- ----------------------------
DROP TABLE IF EXISTS `warehouse`;
CREATE TABLE `warehouse`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `warehouse_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '仓库名称',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '仓库表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for warehouse_goods_shelves
-- ----------------------------
DROP TABLE IF EXISTS `warehouse_goods_shelves`;
CREATE TABLE `warehouse_goods_shelves`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '货架名称',
  `row` bigint NULL DEFAULT NULL COMMENT '层数',
  `col` bigint NULL DEFAULT NULL COMMENT '列数',
  `warehouse_id` bigint NULL DEFAULT NULL COMMENT '仓库id',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '仓库货架表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for warehouse_goods_shelves_rowcol
-- ----------------------------
DROP TABLE IF EXISTS `warehouse_goods_shelves_rowcol`;
CREATE TABLE `warehouse_goods_shelves_rowcol`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `row` bigint NULL DEFAULT NULL COMMENT '层数',
  `col` bigint NULL DEFAULT NULL COMMENT '列数',
  `warehouse_goods_shelves_id` bigint NULL DEFAULT NULL COMMENT '货架id',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建用户',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改用户',
  `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 101 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '仓库货架层，列表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for water_record
-- ----------------------------
DROP TABLE IF EXISTS `water_record`;
CREATE TABLE `water_record`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  `device_model` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '设备规格型号',
  `type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '用水类型',
  `rated_rate` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '额定流量',
  `actual_traffic` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '实际流量',
  `run_time` date NULL DEFAULT NULL COMMENT '运行时间',
  `water_day` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '当日用水量',
  `water_day_limit` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '每日限制水量',
  `water_price` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '水费单价',
  `remarks` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '备注',
  `create_user` bigint NULL DEFAULT NULL COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` bigint NULL DEFAULT NULL COMMENT '修改者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `tenant_id` int NULL DEFAULT NULL COMMENT '租户id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '用水记录' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for work_report
-- ----------------------------
DROP TABLE IF EXISTS `work_report`;
CREATE TABLE `work_report`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `plan_id` int NULL DEFAULT NULL COMMENT '所属计划ID，关联duty_plan表',
  `report_title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '汇报标题',
  `progress` int NULL DEFAULT NULL COMMENT '工作进度百分比',
  `content` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '工作内容',
  `issues` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '遇到的问题',
  `next_plan` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '下一步计划',
  `create_user` int NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` int NULL DEFAULT NULL COMMENT '修改者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `tenant_id` int NULL DEFAULT NULL COMMENT '租户id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '工作汇报表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for working_hours_setting
-- ----------------------------
DROP TABLE IF EXISTS `working_hours_setting`;
CREATE TABLE `working_hours_setting`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '时间段名称',
  `start_time` time NULL DEFAULT NULL COMMENT '上班时间',
  `end_time` time NULL DEFAULT NULL COMMENT '下班时间',
  `flexible_start` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '弹性上班',
  `flexible_minutes` int NULL DEFAULT NULL COMMENT '弹性时间(分钟)',
  `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '状态',
  `create_user` int NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_user` int NULL DEFAULT NULL COMMENT '修改者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `tenant_id` int NULL DEFAULT NULL COMMENT '租户id',
  `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '上班时间设置' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Procedure structure for add_create_user_to_all_tables
-- ----------------------------
DROP PROCEDURE IF EXISTS `add_create_user_to_all_tables`;
delimiter ;;
CREATE PROCEDURE `add_create_user_to_all_tables`()
BEGIN
    DECLARE v_table_name VARCHAR(255);
    DECLARE col_exists INT;
    DECLARE done INT DEFAULT 0;

    -- 游标：获取所有需要处理的表（明确指定表别名）
    DECLARE table_cursor CURSOR FOR
        SELECT t.TABLE_NAME
        FROM information_schema.TABLES t
        WHERE t.TABLE_SCHEMA = DATABASE()
          AND t.TABLE_TYPE = 'BASE TABLE'
          AND t.TABLE_NAME NOT LIKE 'sys_%'
          AND t.TABLE_NAME NOT LIKE 'qrtz_%';

    -- 游标结束处理
    DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;

    OPEN table_cursor;

    table_loop: LOOP
        FETCH table_cursor INTO v_table_name;
        IF done = 1 THEN
            LEAVE table_loop;
        END IF;

        -- 检查字段是否存在（明确别名，彻底解决 1052 错误）
        SELECT COUNT(*) INTO col_exists
        FROM information_schema.COLUMNS c
        WHERE c.TABLE_SCHEMA = DATABASE()
          AND c.TABLE_NAME = v_table_name
          AND c.COLUMN_NAME = 'create_user';

        -- 不存在则添加
        IF col_exists = 0 THEN
            SET @sql = CONCAT('ALTER TABLE `', v_table_name, '` ADD COLUMN create_user BIGINT NULL COMMENT \'创建人ID\'');
            PREPARE stmt FROM @sql;
            EXECUTE stmt;
            DEALLOCATE PREPARE stmt;
        END IF;

    END LOOP table_loop;

    CLOSE table_cursor;
    SELECT '执行完成！所有表已添加 create_user 字段' AS result;
END
;;
delimiter ;

-- ----------------------------
-- Procedure structure for add_dept_id_to_all_tables
-- ----------------------------
DROP PROCEDURE IF EXISTS `add_dept_id_to_all_tables`;
delimiter ;;
CREATE PROCEDURE `add_dept_id_to_all_tables`()
BEGIN
    DECLARE v_table_name VARCHAR(255);
    DECLARE col_exists INT;
    DECLARE done INT DEFAULT 0;

    -- 游标：获取所有需要处理的表（明确指定表别名）
    DECLARE table_cursor CURSOR FOR
        SELECT t.TABLE_NAME
        FROM information_schema.TABLES t
        WHERE t.TABLE_SCHEMA = DATABASE()
          AND t.TABLE_TYPE = 'BASE TABLE'
          AND t.TABLE_NAME NOT LIKE 'sys_%'
          AND t.TABLE_NAME NOT LIKE 'qrtz_%';

    -- 游标结束处理
    DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;

    OPEN table_cursor;

    table_loop: LOOP
        FETCH table_cursor INTO v_table_name;
        IF done = 1 THEN
            LEAVE table_loop;
        END IF;

        -- 检查字段是否存在（明确别名，彻底解决 1052 错误）
        SELECT COUNT(*) INTO col_exists
        FROM information_schema.COLUMNS c
        WHERE c.TABLE_SCHEMA = DATABASE()
          AND c.TABLE_NAME = v_table_name
          AND c.COLUMN_NAME = 'dept_id';

        -- 不存在则添加
        IF col_exists = 0 THEN
            SET @sql = CONCAT('ALTER TABLE `', v_table_name, '` ADD COLUMN dept_id BIGINT NULL COMMENT \'部门ID\'');
            PREPARE stmt FROM @sql;
            EXECUTE stmt;
            DEALLOCATE PREPARE stmt;
        END IF;

    END LOOP table_loop;

    CLOSE table_cursor;
    SELECT '执行完成！所有表已添加 dept_id 字段' AS result;
END
;;
delimiter ;

-- ----------------------------
-- Procedure structure for truncate_non_sys_tables
-- ----------------------------
DROP PROCEDURE IF EXISTS `truncate_non_sys_tables`;
delimiter ;;
CREATE PROCEDURE `truncate_non_sys_tables`()
BEGIN
    DECLARE done INT DEFAULT FALSE;
    DECLARE tbl_name VARCHAR(255);

    DECLARE cur CURSOR FOR 
        SELECT TABLE_NAME 
        FROM INFORMATION_SCHEMA.TABLES 
        WHERE TABLE_SCHEMA = DATABASE() 
        AND (
            TABLE_NAME NOT LIKE 'sys\\_%' 
            OR TABLE_NAME IN (
                'sys_oper_log',
                'sys_logininfor',
                'sys_notice',
                'sys_job',
                'sys_job_log'
            )
        )
        -- 不清理product表
        AND TABLE_NAME <> 'product'
        AND TABLE_TYPE = 'BASE TABLE';

    DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;

    -- 临时禁用外键约束
    SET FOREIGN_KEY_CHECKS = 0;
    SET AUTOCOMMIT = 0;

    OPEN cur;

    read_loop: LOOP
        FETCH cur INTO tbl_name;

        IF done THEN
            LEAVE read_loop;
        END IF;

        SET @sql = CONCAT('DELETE FROM `', tbl_name, '`');

        PREPARE stmt FROM @sql;
        EXECUTE stmt;
        DEALLOCATE PREPARE stmt;

        SELECT CONCAT('已清理表: ', tbl_name) AS message;
    END LOOP;

    CLOSE cur;

    -- 恢复配置
    SET FOREIGN_KEY_CHECKS = 1;
    SET AUTOCOMMIT = 1;

    SELECT '所有目标表已清空完成（已排除product表）！' AS final_message;
END
;;
delimiter ;

SET FOREIGN_KEY_CHECKS = 1;
