feat: label-ocr 默认 GB+US 近7天; refresh_pending 合并无面单订单(近7天)

This commit is contained in:
yeuimu
2026-07-31 01:57:52 +00:00
parent 3e075fd366
commit a742f4169e
4 changed files with 63 additions and 25 deletions
+16 -8
View File
@@ -86,20 +86,28 @@ def process_all(pending: list) -> dict[str, int]:
@flow(name="label-ocr", log_prints=True)
def label_ocr(destination_country: str | None = 'GB', courier_source: str | None = None) -> dict:
"""面单 OCR enrichment。默认只处理英国(GB),可选 courierSource 进一步筛选。
def label_ocr(
destination_countries: list[str] | None = None,
courier_source: str | None = None,
days: int = 7,
) -> dict:
"""面单 OCR enrichment。默认处理英国(GB)+美国(US),近 7 天下单的订单。
手动跑其他国家: label_ocr(destination_country='US')
手动跑其他国家: label_ocr(destination_countries=['DE'])
"""
if destination_countries is None:
destination_countries = ['GB', 'US']
db = SyncDB()
before = db.count_ocr_status()
print(f"OCR 状态(开始): {before}")
pending = db.get_ocr_pending(destination_country=destination_country, courier_source=courier_source)
scope = ""
if destination_country or courier_source:
scope = f" [{destination_country or ''} {courier_source or ''}]".strip()
print(f"待 OCR: {len(pending)} 单{scope} (RIIN+SDS)")
pending = db.get_ocr_pending(
destination_countries=destination_countries,
courier_source=courier_source,
days=days,
)
scope = f" [{'/'.join(destination_countries)}{f' {courier_source}' if courier_source else ''}]"
print(f"待 OCR: {len(pending)} 单{scope} (RIIN+SDS, 近{days}天)")
if not pending:
emit_sync_summary(f"面单 OCR{scope}", build_stats_rows("ALL", {}, [
("待处理", 0), ("累计已完成", before.get("done", 0)),