You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
besure_server/sql/mysql/2026-06-23-bit-wms-location...

49 lines
3.2 KiB
SQL

-- BIT 样品仓库位库存台账
CREATE TABLE IF NOT EXISTS `erp_bit_wms_location_stock` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
`product_id` bigint NOT NULL COMMENT '样品产品ID',
`warehouse_id` bigint NOT NULL COMMENT '仓库ID',
`area_id` bigint NULL COMMENT '库区ID',
`location_id` bigint NOT NULL COMMENT '库位ID',
`count` decimal(24, 6) NOT NULL DEFAULT 0.000000 COMMENT '当前库存数量',
`unit_id` bigint NULL COMMENT '单位ID',
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `uk_product_location` (`product_id`, `location_id`, `deleted`, `tenant_id`) USING BTREE,
KEY `idx_location` (`location_id`) USING BTREE,
KEY `idx_warehouse_area` (`warehouse_id`, `area_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='BIT 样品库位库存';
CREATE TABLE IF NOT EXISTS `erp_bit_wms_location_stock_record` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
`product_id` bigint NOT NULL COMMENT '样品产品ID',
`warehouse_id` bigint NOT NULL COMMENT '仓库ID',
`area_id` bigint NULL COMMENT '库区ID',
`location_id` bigint NOT NULL COMMENT '库位ID',
`count` decimal(24, 6) NOT NULL COMMENT '变动数量',
`total_count` decimal(24, 6) NOT NULL COMMENT '变动后库位结存',
`unit_id` bigint NULL COMMENT '单位ID',
`biz_direction` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '业务方向',
`biz_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '业务类型',
`biz_id` bigint NULL COMMENT '业务单ID',
`biz_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '业务单号',
`remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '备注',
`record_time` datetime NOT NULL COMMENT '操作时间',
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_product_location` (`product_id`, `location_id`) USING BTREE,
KEY `idx_biz_no` (`biz_no`) USING BTREE,
KEY `idx_record_time` (`record_time`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='BIT 样品库位库存流水';