feat(file-check): 更新文件检核工具 API Key 配置及相关文档

This commit is contained in:
hugo committed 2026-06-17 22:29:15 +08:00
1 parent 634dee4b81
commit 55cf7ff734
74 files changed
+1525 -1182

No files matched your search

+21 -2
View File
@@ -27,7 +27,7 @@ def _line_key(sku: str, reservation_id: str | None) -> tuple[str, str]:
def _aggregate_inventory(inventory_lines: list[dict[str, Any]]) -> dict[tuple[str, str], float]:
"""Sum available_qty by (AWS Sku, Reservation ID). Same key rows are aggregated."""
"""按 (sku, reservation_id) 汇总库存 available_qty。"""
totals: dict[tuple[str, str], float] = {}
for row in inventory_lines:
sku = _norm(row.get("sku"))
@@ -61,6 +61,15 @@ 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]]:
"""
将订单行与库存行按 (sku, reservation_id) 匹配,计算 fulfillable/partial/unfulfillable。
核心逻辑:聚合库存 → 逐行比对 required vs available → 汇总 match_status 与 shortages。
Returns:
tuple: (match_status, line_results, shortage_json)。
"""
# [STEP 1] 按 (sku, reservation_id) 聚合库存可用量。
inv_totals = _aggregate_inventory(inventory_lines)
line_results: list[dict[str, Any]] = []
@@ -68,6 +77,7 @@ def match_notice_lines(
has_partial = False
has_shortage = False
# [STEP 2] 逐订单行计算 ok/partial/shortage 并收集缺口明细。
for line in notice_lines:
sku = _norm(line.get("sku"))
reservation_id = _norm_reservation(line.get("reservation_id")) or None
@@ -101,6 +111,7 @@ def match_notice_lines(
if shortage > 0:
shortages.append(result)
# [STEP 3] 汇总整体 match_status(fulfillable / partial / unfulfillable)。
if not notice_lines:
return "unfulfillable", line_results, {"lines": shortages}
@@ -132,7 +143,15 @@ def format_match_summary(
task_no: str | None = None,
lang: str | None = None,
) -> str:
"""Fixed Markdown table for match_inventory responses (Agent must display verbatim)."""
"""
生成 match_inventory 固定 Markdown 表格摘要(Agent 须原文展示给用户)。
Args:
match_status: fulfillable / partial / unfulfillable 等。
line_results: match_notice_lines 返回的逐行结果。
task_no: 可选任务编号,用于标题行。
lang: 可选语言码(zh-CN/en/th 等)。
"""
resolved = resolve_lang({"lang": lang} if lang else None)
if not line_results:
return t("match.no_lines", lang=resolved)