feat(shipping-notice): 完成货代发货通知全流程开发与代码重构

- 新增PO号提取、预约ID解析(支持`PR@xxx`格式)工具,完善库存匹配逻辑
- 新增库存映射缓存、匹配/解析结果格式化摘要,优化用户提示
- 修复数据库迁移脚本未检查表存在的问题,避免全新部署失败
- 新增路径工具类统一管理相对路径,优化配置文件处理逻辑
- 归档旧文档,将部署、Dify配置合并到`shipping_notice.md`
- 新增完整单元测试与集成测试覆盖核心流程
- 更新前端国际化与会话管理逻辑,优化界面交互
This commit is contained in:
hugo committed 2026-06-04 15:26:34 +08:00
1 parent b62082758b
commit 8deae3146b
65 files changed
+6477 -1937

No files matched your search

@@ -0,0 +1,57 @@
from app.services.shipping_notice.parse_summary import format_parse_summary
def test_format_parse_summary_single_line():
msg = format_parse_summary(
task_no="SN-20260604-7249E4D7",
po_number="16754796",
ship_to="Wistron Corporation, Czech Republic",
lines=[
{
"sku": "504-010213-001",
"reservation_id": "1000140351",
"qty": 9,
"uom": "PCS",
"unit_price": 1607.72,
"amount": 14469.48,
"currency": "USD",
"required_date": "2026-06-15",
}
],
)
assert "【发货通知解析确认】任务编号:SN-20260604-7249E4D7" in msg
assert "| PO | 16754796 |" in msg
assert "| SKU | 504-010213-001 |" in msg
assert "| Reservation ID | 1000140351 |" in msg
assert "| 数量 | 9 PCS |" in msg
assert "| 单价 | $1,607.72 |" in msg
assert "| 金额 | $14,469.48 |" in msg
assert "| 需求日期 | 2026-06-15 |" in msg
assert "Wistron Corporation, Czech Republic" in msg
assert "请确认以上信息是否正确?" in msg
assert "待从任务中获取" not in msg
def test_format_parse_summary_multiple_lines():
msg = format_parse_summary(
task_no="SN-1",
po_number="PO-1",
lines=[
{"sku": "A", "qty": 1, "reservation_id": "R1"},
{"sku": "B", "qty": 2, "reservation_id": "R2"},
],
)
assert "【明细 1】" in msg
assert "【明细 2】" in msg
assert "PO:PO-1" in msg
def test_format_parse_summary_includes_warnings():
msg = format_parse_summary(
task_no="SN-1",
lines=[{"sku": "A", "qty": 1}],
warnings=["订单行未解析到 Reservation ID"],
low_confidence=True,
)
assert "订单行未解析到 Reservation ID" in msg
assert "解析置信度较低" in msg