主要变更: 1. 移除废弃的发货通知字段抽取独立Workflow Agent相关代码 2. 重构Dify服务调用,新增inputs参数支持注入环境变量配置的工具API地址与密钥 3. 新增auto_progress工具API与checkpoint catalog接口,支持流程自动推进 4. 统一字段命名,将column_mapping_json改为map_json并兼容旧有调用 5. 重构库存匹配、解析结果的展示格式,改为标准化多语言Markdown表格 6. 新增ODM ID库存字段支持,优化库存解析与映射逻辑 7. 新增LibreOffice转换隔离Profile配置,避免多实例运行冲突 8. 新增完整环境变量配置、数据库迁移脚本与测试用例 9. 适配前端代码,更新字段命名与聊天跳转逻辑 10. 更新OpenAPI规范适配Dify工具调用,删除已归档的旧部署文档
62 lines
2.1 KiB
Python
62 lines
2.1 KiB
Python
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 "| 采购单号 | 16754796 |" in msg
|
|
assert "| 预订单号 | 1000140351 |" in msg
|
|
assert "| 料号 | 504-010213-001 |" in msg
|
|
po_idx = msg.index("| 采购单号 |")
|
|
rid_idx = msg.index("| 预订单号 |")
|
|
sku_idx = msg.index("| 料号 |")
|
|
assert po_idx < rid_idx < sku_idx
|
|
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-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
|