仓储与库存管理
High Contrast
Dark Mode
Light Mode
Sepia
Forest
2 min read306 words

仓储与库存管理

库存是供应链的缓冲器——太多浪费,太少断货。

库存管理架构

graph TD DEMAND[需求信号] --> POLICY[库存策略] POLICY --> MODEL[库存模型] MODEL --> EOQ[经济订货量] MODEL --> SS[安全库存] MODEL --> ROP[补货点] POLICY --> CLASSIFY[分类管理] CLASSIFY --> ABC[ABC 分析] CLASSIFY --> XYZ[XYZ 波动分析] ABC --> EXEC[执行补货] EXEC --> MONITOR[库存监控] MONITOR --> KPI[周转率] style POLICY fill:#e3f2fd,stroke:#1565c0,stroke-width:2px style KPI fill:#c8e6c9,stroke:#388e3c,stroke-width:2px

库存模型

"""
库存管理模型
"""
import math
from dataclasses import dataclass
@dataclass
class InventoryItem:
sku: str
annual_demand: int
unit_cost: float
order_cost: float       # 每次下单成本
holding_rate: float     # 持有成本率 (占货值%)
lead_time_days: int
demand_std_daily: float # 日需求标准差
class InventoryModels:
"""库存模型集合"""
@staticmethod
def eoq(item: InventoryItem) -> dict:
"""经济订货量"""
holding = item.unit_cost * item.holding_rate
eoq = math.sqrt(
2 * item.annual_demand * item.order_cost / holding
)
cycles = item.annual_demand / eoq
total_cost = cycles * item.order_cost + (eoq / 2) * holding
return {
"EOQ": round(eoq),
"年订货次数": round(cycles, 1),
"订货间隔": f"{365 / cycles:.0f} 天",
"年库存总成本": f"¥{total_cost:,.0f}",
}
@staticmethod
def safety_stock(
item: InventoryItem, service_level: float = 0.95
) -> dict:
"""安全库存"""
z_map = {0.90: 1.28, 0.95: 1.65, 0.99: 2.33}
z = z_map.get(service_level, 1.65)
ss = z * item.demand_std_daily * math.sqrt(
item.lead_time_days
)
daily_demand = item.annual_demand / 365
rop = daily_demand * item.lead_time_days + ss
return {
"安全库存": round(ss),
"补货点 (ROP)": round(rop),
"日均需求": round(daily_demand, 1),
"服务水平": f"{service_level*100}%",
}
@staticmethod
def abc_xyz(items: list[dict]) -> list[dict]:
"""ABC-XYZ 交叉分析"""
# ABC 按收入排序
total_rev = sum(i["revenue"] for i in items)
sorted_items = sorted(
items, key=lambda x: x["revenue"], reverse=True
)
result = []
cumulative = 0
for item in sorted_items:
cumulative += item["revenue"]
pct = cumulative / total_rev
abc = "A" if pct <= 0.80 else "B" if pct <= 0.95 else "C"
cv = item.get("cv", 0.5)  # 变异系数
xyz = "X" if cv < 0.3 else "Y" if cv < 0.7 else "Z"
result.append({
"SKU": item["sku"],
"收入": f"¥{item['revenue']:,.0f}",
"ABC": abc,
"XYZ": xyz,
"策略": _get_strategy(abc, xyz),
})
return result
def _get_strategy(abc: str, xyz: str) -> str:
"""ABC-XYZ 策略"""
strategies = {
("A", "X"): "JIT精确补货",
("A", "Y"): "安全库存+定期补货",
("A", "Z"): "高安全库存+密切监控",
("B", "X"): "自动补货",
("B", "Y"): "定期检查补货",
("B", "Z"): "较高安全库存",
("C", "X"): "简化流程批量采购",
("C", "Y"): "按需采购",
("C", "Z"): "最小批量或淘汰",
}
return strategies.get((abc, xyz), "待定")
# 演示
item = InventoryItem(
sku="X100-PCB",
annual_demand=50000,
unit_cost=25.0,
order_cost=300,
holding_rate=0.20,
lead_time_days=14,
demand_std_daily=15,
)
models = InventoryModels()
print("=== EOQ ===")
for k, v in models.eoq(item).items():
print(f"  {k}: {v}")
print("\n=== 安全库存 ===")
for k, v in models.safety_stock(item).items():
print(f"  {k}: {v}")
print("\n=== ABC-XYZ 分析 ===")
products = [
{"sku": "A001", "revenue": 500000, "cv": 0.15},
{"sku": "A002", "revenue": 350000, "cv": 0.45},
{"sku": "B001", "revenue": 120000, "cv": 0.80},
{"sku": "C001", "revenue": 30000, "cv": 0.20},
{"sku": "C002", "revenue": 8000, "cv": 0.90},
]
for r in models.abc_xyz(products):
print(f"  {r['SKU']}: {r['ABC']}{r['XYZ']} — {r['策略']} ({r['收入']})")

库存 KPI

KPI 公式 优秀基准
库存周转率 年销售成本 ÷ 平均库存 >12
库存天数 365 ÷ 周转率 <30
缺货率 缺货次数 ÷ 订单总数 <2%
呆滞库存比 呆滞品 ÷ 总库存 <5%
库存准确率 实盘=系统 的比率 >99%

行动清单

下一节02-仓库运营与WMS — 仓库运营与 WMS 系统实战。