SHOW CREATE TABLE dmp_serp.dmp_im_stock_in;

CREATE TABLE dmp_serp.`dmp_im_stock_in` (
  `id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '主键id',
  `ecid` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '企业编码',
  `type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '入库类型',
  `source_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '单据来源',
  `material_properties` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '物资属性',
  `stock_in_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '入库单号',
  `factory_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '厂别code',
  `warehouse_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '仓库id',
  `takeover_warehouse_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '接管仓库id',
  `shelf_area_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '库区code（期初只有一个库区）',
  `shelf_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '库位code（期初只有一个库位）',
  `supply_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '供方id',
  `supply_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '供方code',
  `supply_code_type` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '供方编码类型',
  `supply_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '供方信息',
  `status` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '入库状态（10:待入库，20:部分入库，30:已入库）',
  `approval_status` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '审批状态',
  `approve_status` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程审批状态',
  `invoice_status` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '收票状态（0:不收票,1:待收票，2:部分收票，3：已收票）',
  `quality_status` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '质检状态',
  `on_shelf_mode` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '上架方式(10：pc上架，20：pda上架)',
  `bill_date` date DEFAULT NULL COMMENT '单据日期',
  `completed_at` datetime DEFAULT NULL COMMENT '完成入库时间',
  `remark` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
  `is_manual` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
  `print_count` int DEFAULT NULL COMMENT '打印次数',
  `is_deleted` tinyint(1) NOT NULL COMMENT '是否删除',
  `create_time` datetime NOT NULL COMMENT '创建时间',
  `created_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL COMMENT '更新时间',
  `updated_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '更新人',
  `version` int NOT NULL COMMENT '版本号',
  `workshop_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '车间编码',
  `dept_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '部门编码',
  `pick_status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '领料状态',
  `stock_out_id` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '出库单id',
  `stock_out_flow_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '出库流水单号',
  `warehouse_code_out` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '调拨出库仓库',
  `factory_code_out` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '调拨出库工厂',
  `return_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
  `return_category` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '退货类型；数据字典：(returnTypeStatus)',
  `red_reversal_flag` tinyint(1) DEFAULT '0' COMMENT '红冲标记；1：是；0：否',
  `reason_code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '入库原因',
  PRIMARY KEY (`id`),
  KEY `idx_im_stock_in_stock_in_no` (`stock_in_no`),
  KEY `idx_im_stock_in_ecid_type_status` (`ecid`,`type`,`status`),
  KEY `idx_im_stock_in_created_at` (`create_time`),
  KEY `idx_im_stock_in_takeover_ecid_type_status` (`type`,`status`),
  KEY `idx_im_stock_in_status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='入库单据表';

SHOW CREATE TABLE dmp_serp.dmp_im_stock_in_detail;

CREATE TABLE dmp_serp.`dmp_im_stock_in_detail` (
  `id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '主键id',
  `ecid` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '企业编码',
  `stock_in_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '入库单id',
  `stock_in_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '入库单号',
  `factory_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '厂别code',
  `warehouse_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '仓库code',
  `shelf_area_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '库区code',
  `shelf_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '库位code',
  `row_index` int DEFAULT NULL COMMENT '行号',
  `type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '入库类型',
  `status` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '入库状态',
  `material_no` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '物料编码',
  `model_name` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '物料名称',
  `model_spec` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '规格型号',
  `qr_status` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '品质属性',
  `apply_quantity` decimal(16,6) NOT NULL COMMENT '申请入库数量',
  `stock_in_quantity` decimal(16,6) NOT NULL COMMENT '入库数量',
  `auxiliary_quantity` decimal(16,6) DEFAULT NULL COMMENT '辅单位申请入库数量',
  `auxiliary_in_quantity` decimal(16,6) DEFAULT '0.000000' COMMENT '辅单位已入库数量',
  `apply_reserved_quantity` decimal(16,6) DEFAULT NULL COMMENT '申请预留数量',
  `auxiliaryUnitCode` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '辅助单位编码',
  `unit_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '单位名称',
  `remark` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
  `is_deleted` bit(1) NOT NULL COMMENT '是否删除',
  `create_time` datetime NOT NULL COMMENT '创建时间',
  `created_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL COMMENT '更新时间',
  `updated_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '更新人',
  `version` int NOT NULL COMMENT '版本号',
  `dept_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '部门编码',
  `price` decimal(20,6) DEFAULT NULL COMMENT '单价',
  `amount` decimal(20,6) DEFAULT NULL COMMENT '金额',
  `supply_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '供应商编码',
  `allocation_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '调拨单号',
  `allocation_row_index` int DEFAULT NULL COMMENT '行号',
  `cust_code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '客户编码',
  `inventory_line_no` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '复检明细id',
  `insp_remark` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '质检备注',
  PRIMARY KEY (`id`),
  KEY `idx_im_stock_in_detail_material_no` (`material_no`),
  KEY `idx_im_stock_in_detail_model_name` (`model_name`),
  KEY `idx_im_stock_in_detail_stock_in_id` (`stock_in_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='入库明细表';

SELECT id,stock_in_no,bill_date,completed_at,create_time,update_time FROM dmp_serp.dmp_im_stock_in WHERE ecid = 'kangda' AND stock_in_no = 'PE2026000035' AND is_deleted = 0;


SHOW CREATE TABLE dmp_serp.dmp_im_stock_in_out_flow_detail;

CREATE TABLE dmp_serp.`dmp_im_stock_in_out_flow_detail` (
  `id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '主键id',
  `ecid` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '企业编码',
  `flow_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '流水单id',
  `flow_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '流水单号',
  `type` varchar(64) COLLATE utf8mb4_general_ci NOT NULL COMMENT '单据类型(stockInOutType)',
  `stock_type` varchar(64) COLLATE utf8mb4_general_ci NOT NULL COMMENT '类型(in/out)',
  `stock_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '出入库单号',
  `stock_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '出入库id',
  `stock_detail_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '出入库明细id',
  `stock_shelf_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '出入库位关系id',
  `shelf_model_id` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '型号库存id',
  `material_properties` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '物资属性',
  `material_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '物料编码',
  `factory_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '厂别code',
  `warehouse_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '仓库编码',
  `shelf_area_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '库区编码',
  `shelf_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '库位编码',
  `batch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '批次号',
  `stock_quantity` decimal(16,6) DEFAULT NULL COMMENT '出入库数量',
  `stock_amount` decimal(16,6) DEFAULT NULL COMMENT '含税金额',
  `sales_amount` decimal(22,6) DEFAULT '0.000000' COMMENT '销售额',
  `no_tax_amount` decimal(16,6) DEFAULT NULL COMMENT '未税金额',
  `bill_date` date DEFAULT NULL COMMENT '单据日期',
  `remark` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
  `stock_remark` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
  `source_bill_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '来源单号',
  `source_row_index` int DEFAULT NULL COMMENT '行号',
  `production_task_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '生产任务单号',
  `sales_order_no_list` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '销售单号',
  `order_detail_row_index` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '销售订单行号',
  `purchase_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '采购单号',
  `mrp_no` varchar(600) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '计划单号',
  `supplier_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '供应商code',
  `stock_date` date DEFAULT NULL COMMENT '出、入库日期',
  `is_deleted` tinyint(1) NOT NULL COMMENT '是否已作废',
  `create_time` datetime NOT NULL COMMENT '创建时间',
  `created_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL COMMENT '修改时间',
  `updated_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '修改人',
  `version` int NOT NULL COMMENT '版本号',
  `pro_batch_no` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '生产批次',
  `auxiliary_stock_quantity` decimal(16,6) DEFAULT '0.000000' COMMENT '辅出入库数量',
  `inventory_type_code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '品质类型编码',
  `product_request` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '生产要求',
  `mat_trans_form_no` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '物料转换单号',
  `no_tax_price` decimal(16,6) DEFAULT NULL COMMENT '无税单价',
  `ial_stock_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '线边仓退料领料单号',
  `dept_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '部门编码',
  `tax_rate` decimal(12,6) DEFAULT NULL COMMENT '税率',
  `invoice_no` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '发票号码',
  `om_gift_tag` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '是否赠品：是|true,否|false',
  `factory_code_in_out` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '拨入拨出厂别',
  `warehouse_code_in_out` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '拨入拨出仓库',
  `shelf_area_code_in_out` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '拨入拨出库区编码',
  `shelf_code_in_out` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '拨入拨出库位编码',
  `allocation_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '调拨单号',
  `allocation_row_index` int DEFAULT NULL COMMENT '行号',
  `cust_code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '客户���码',
  `aggregate_model` int DEFAULT NULL COMMENT 'doris汇总类型：1仓库+物料 2，物料+仓库+批次 3，物料+仓库+库区/库位  4，库存明细  5，物料+供应商+仓库',
  `group_flag` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '分组标记',
  `work_shop_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '车间编码',
  `purchase_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '采购类型',
  `order_no_str` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '销售订单号(多个，以“，”分隔）',
  `order_no_row_str` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '销售订单行号(多个，以“，”分隔）',
  `insp_remark` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '质检备注',
  `apply_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '申请人 ID',
  PRIMARY KEY (`id`),
  KEY `idx_im_stock_in_out_flow_detail_batch_no` (`batch_no`),
  KEY `idx_dmp_im_stock_in_out_flow_detail_bill_date` (`bill_date`),
  KEY `idx_im_stock_in_out_flow_detail_type` (`type`),
  KEY `idx_im_stock_in_out_flow_detail_source_bill_no` (`source_bill_no`),
  KEY `idx_dmp_im_stock_in_out_flow_detail_stock_no` (`stock_no`),
  KEY `idx_im_stock_in_out_flow_detail_production_task_no` (`production_task_no`),
  KEY `idx_dmp_im_stock_in_out_flow_detail_ecid_material_no` (`ecid`,`material_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='出入库记录明细';

select * from dmp_serp.dmp_im_stock_in_out_flow_detail where ecid = 'kangda' and stock_no = 'PE2026000035' and is_deleted = 0;

SHOW CREATE TABLE dmp_serp.dmp_im_stock_out;