本目录包含WMS(仓储管理系统)的完整数据库设计,包括表结构、索引、视图、触发器和初始化数据。
数据库类型: PostgreSQL 15+
字符集: UTF-8
总表数: 40+ 张表
设计日期: 2025-10-06
database/
├── schema/ # 数据库表结构脚本
│ ├── 00_init_database.sql # 数据库初始化(创建数据库、Schema、函数、枚举)
│ ├── 01_basic_data.sql # 基础数据模块(仓库、库位、产品、客户、供应商)
│ ├── 02_inventory.sql # 库存管理模块(库存、流水、预警、快照)
│ ├── 03_inbound.sql # 入库管理模块(入库单、收货、上架、质检)
│ ├── 04_outbound.sql # 出库管理模块(出库单、分配、拣货、发货)
│ ├── 05_stocktaking_transfer.sql # 盘点和调拨模块(盘点、调拨、损坏报废)
│ ├── 06_system_finance.sql # 系统和财务模块(用户、角色、权限、账单)
│ └── 07_kit_management.sql # 套组管理模块(套组、组装、拆卸、波次)
├── data/ # 初始化数据脚本
│ └── init_data.sql # 初始化数据(用户、角色、权限、基础数据)
├── install.sh # Linux/Mac安装脚本
├── install.bat # Windows安装脚本
└── README.md # 本文档
- wms: 业务数据Schema,包含所有WMS业务表
- sys: 系统管理Schema,包含用户、角色、权限等系统表
- public: PostgreSQL默认Schema
wms_warehouse- 仓库表wms_area- 库区表wms_location- 库位表wms_product_category- 产品类别表wms_product- 产品表wms_customer- 客户表wms_supplier- 供应商表wms_unit- 单位表wms_carrier- 承运商表
wms_inventory- 库存主表wms_inventory_transaction- 库存流水表wms_inventory_alert_config- 库存预警配置表wms_inventory_snapshot- 库存快照表wms_inventory_lock- 库存锁定记录表wms_inventory_adjustment- 库存调整记录表v_inventory_by_product- 按产品汇总库存视图v_inventory_by_location- 按库位汇总库存视图
wms_inbound_order- 入库单主表wms_inbound_order_line- 入库单明细表wms_inbound_receive_record- 收货记录表wms_inbound_putaway_record- 上架记录表wms_inbound_quality_check- 质检记录表v_inbound_order_stats- 入库单统计视图
wms_outbound_order- 出库单主表wms_outbound_order_line- 出库单明细表wms_outbound_allocation- 出库分配表wms_picking_task- 拣货任务表wms_picking_task_line- 拣货任务明细表wms_picking_record- 拣货记录表wms_shipping_record- 发货记录表v_outbound_order_stats- 出库单统计视图
wms_stocktaking_order- 盘点单主表wms_stocktaking_order_line- 盘点单明细表wms_stocktaking_count_record- 盘点记录表wms_transfer_order- 调拨单主表wms_transfer_order_line- 调拨单明细表wms_transfer_move_record- 调拨记录表wms_damage_order- 损坏报废单表wms_damage_order_line- 损坏报废单明细表
sys_tenant- 租户表sys_user- 用户表sys_role- 角色表sys_permission- 权限表sys_user_role- 用户角色关联表sys_role_permission- 角色权限关联表sys_operation_log- 操作日志表sys_login_log- 登录日志表wms_billing- 财务账单表wms_billing_line- 账单明细表wms_payment_record- 收款记录表wms_rate_config- 费率配置表
wms_kit- 套组主表wms_kit_component- 套组组成表wms_kit_assembly_order- 套组组装单表wms_kit_disassembly_order- 套组拆卸单表wms_wave_picking- 波次拣货主表wms_wave_picking_order- 波次拣货订单关联表v_kit_available_inventory- 套组可用库存视图
- 所有业务表包含
tenant_id字段 - 数据隔离,确保不同租户数据安全
- 支持批次号管理 (
batch_no) - 支持序列号管理 (
serial_no) - 支持保质期管理 (
production_date,expiry_date)
- 总数量 = 可用数量 + 锁定数量
- 可用数量: 可以被分配出库的数量
- 锁定数量: 已分配但未出库的数量
- 入库流程: 创建 → 确认 → 收货 → 质检 → 上架 → 完成
- 出库流程: 创建 → 确认 → 分配 → 拣货 → 发货 → 完成
- 盘点流程: 创建 → 盘点 → 差异处理 → 调整 → 完成
- 调拨流程: 创建 → 确认 → 移库 → 完成
- FIFO (First In First Out): 先进先出
- FEFO (First Expired First Out): 保质期先出
- 手动分配: 人工指定库位
- 按巷道(aisle) → 货架(shelf) → 层(level) → 位(position)排序
- 支持S型路径、Z型路径等优化算法
- 仓储费、装卸费、增值服务费
- 支持多种计费方式: 固定、按数量、按重量、按体积、按天
- 完整的账单和收款记录
cd database
chmod +x install.sh
./install.shcd database
install.bat# 1. 创建数据库和基础结构
psql -U postgres -f schema/00_init_database.sql
# 2. 创建业务表
psql -U postgres -d wms_db -f schema/01_basic_data.sql
psql -U postgres -d wms_db -f schema/02_inventory.sql
psql -U postgres -d wms_db -f schema/03_inbound.sql
psql -U postgres -d wms_db -f schema/04_outbound.sql
psql -U postgres -d wms_db -f schema/05_stocktaking_transfer.sql
psql -U postgres -d wms_db -f schema/06_system_finance.sql
psql -U postgres -d wms_db -f schema/07_kit_management.sql
# 3. 插入初始化数据
psql -U postgres -d wms_db -f data/init_data.sql| 模块 | 表数量 | 视图数量 | 索引数量 |
|---|---|---|---|
| 基础数据 | 9 | 0 | 15+ |
| 库存管理 | 6 | 2 | 20+ |
| 入库管理 | 5 | 1 | 15+ |
| 出库管理 | 7 | 1 | 20+ |
| 盘点调拨 | 8 | 0 | 15+ |
| 系统财务 | 13 | 0 | 15+ |
| 套组管理 | 7 | 1 | 12+ |
| 总计 | 55 | 5 | 112+ |
安装完成后,系统会创建以下默认账号:
| 用户名 | 密码 | 角色 | 说明 |
|---|---|---|---|
| admin | admin123 | 系统管理员 | 拥有所有权限 |
| warehouse_manager | admin123 | 仓库经理 | 仓库管理权限 |
| operator | admin123 | 操作员 | 基本操作权限 |
- PostgreSQL版本: 需要PostgreSQL 15或更高版本
- 字符集: 必须使用UTF-8编码
- 扩展: 需要安装
uuid-ossp,pg_trgm,btree_gin扩展 - 权限: 执行脚本的用户需要有创建数据库和Schema的权限
- 备份: 生产环境部署前请做好数据备份
- ✅ 完成数据库初始设计
- ✅ 创建40+张业务表
- ✅ 创建5个统计视图
- ✅ 创建112+个索引
- ✅ 添加初始化数据
- ✅ 支持多租户架构
- ✅ 支持批次序列号管理
- ✅ 完整的业务流程支持
如有问题,请联系技术支持团队。
WMS数据库设计 v1.0.0
Copyright © 2025 和智云科技