WMS_MAIN/memories/repo/entry-receiving-match-callback.md
liufumingren 77435aeb79 1
2026-06-23 18:48:33 +08:00

29 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 入库单完成 → 异步匹配收货单并回传
## 实现日期
2026-06-18
## 涉及文件
### 新建
- `app/service/systems/receiving_entry_match.js` — 核心匹配与回传服务
### 修改
- `app/service/systems/entry_order.js` — `entryorderConfirm()` 事务提交后触发异步匹配
- `app/service/systems/storage/entry.js` — `completeEntry()` 状态更新后触发异步匹配
- `app/service/systems/storage/receiving.js` — `completeReceiving()` 事务提交后清除收货单缓存
## 核心流程
1. 入库单完成(COMPLETED)→ `setImmediate` 异步触发 `matchAfterEntryCompleted`
2. 从 Redis 缓存读取仓库近 3 天收货单列表(key: `cache:receiving_orders:warehouse:{warehouseId}`,TTL: 300s)
3. 根据入库单 `remark` 字符串包含匹配收货单号
4. 对比明细 SKU + 数量 → full_match / receiving_covers_entry / 其他
5. full_match / receiving_covers_entry → 按来源回传(QM 奇门 / API OpenAPI)
6. receiving_covers_entry → 标记收货单为"部分入库"(storage_status=partial)
7. 收货单完成时主动清除对应仓库缓存
## 注意事项
- 异步执行,不阻塞主流程
- 所有错误仅记录日志,不影响业务
- 缓存回退:Redis 不可用时直接查询数据库