feat(shipping-notice): 新增货代发货通知全流程业务功能
- 新增后端完整业务支持:数据库模型、API接口、核心服务与RPA对接逻辑 - 新增前端工作台页面、路由适配与多语言国际化 - 新增Dify自定义工具OpenAPI规范、Agent配置脚本与部署文档 - 新增发货Excel模板生成脚本与默认模板 - 修复测试配置文件中的环境变量命名错误 - 更新本地开发环境变量配置
This commit is contained in:
1 parent
93e99793d8
commit
2d7bdecc43
46 files changed
+3462
-7
No files matched your search
@@ -0,0 +1,65 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
|
||||
def match_notice_lines(
|
||||
notice_lines: list[dict[str, Any]],
|
||||
inventory_lines: list[dict[str, Any]],
|
||||
) -> tuple[str, list[dict[str, Any]], dict[str, Any]]:
|
||||
inv_map: dict[str, float] = {}
|
||||
for row in inventory_lines:
|
||||
sku = str(row.get("sku") or "").strip()
|
||||
if not sku:
|
||||
continue
|
||||
try:
|
||||
inv_map[sku] = float(row.get("available_qty") or 0)
|
||||
except (TypeError, ValueError):
|
||||
inv_map[sku] = 0.0
|
||||
|
||||
line_results: list[dict[str, Any]] = []
|
||||
shortages: list[dict[str, Any]] = []
|
||||
has_partial = False
|
||||
has_shortage = False
|
||||
|
||||
for line in notice_lines:
|
||||
sku = str(line.get("sku") or "").strip()
|
||||
try:
|
||||
required = float(line.get("qty") or 0)
|
||||
except (TypeError, ValueError):
|
||||
required = 0.0
|
||||
available = inv_map.get(sku, 0.0)
|
||||
if available >= required:
|
||||
line_status = "ok"
|
||||
shortage = 0.0
|
||||
elif available > 0:
|
||||
line_status = "partial"
|
||||
shortage = required - available
|
||||
has_partial = True
|
||||
else:
|
||||
line_status = "shortage"
|
||||
shortage = required
|
||||
has_shortage = True
|
||||
|
||||
result = {
|
||||
"sku": sku,
|
||||
"required_qty": required,
|
||||
"available_qty": available,
|
||||
"shortage_qty": shortage,
|
||||
"line_status": line_status,
|
||||
}
|
||||
line_results.append(result)
|
||||
if shortage > 0:
|
||||
shortages.append(result)
|
||||
|
||||
if not notice_lines:
|
||||
return "unfulfillable", line_results, {"lines": shortages}
|
||||
|
||||
if has_shortage and not has_partial and all(r["line_status"] == "shortage" for r in line_results):
|
||||
match_status = "unfulfillable"
|
||||
elif has_partial or has_shortage:
|
||||
match_status = "partial"
|
||||
else:
|
||||
match_status = "fulfillable"
|
||||
|
||||
return match_status, line_results, {"lines": shortages}
|
||||
Reference in new issue
Block a user