feat: label-ocr 支持 destination_country/courier_source 筛选优先处理

This commit is contained in:
yeuimu
2026-07-24 02:10:03 +00:00
parent 72039e480b
commit f0580a8ce4
2 changed files with 25 additions and 10 deletions
+12 -4
View File
@@ -100,19 +100,27 @@ class SyncDB:
# ---------- OCR 面单 enrichment ----------
def get_ocr_pending(self, limit: int = 0) -> list[tuple[str, datetime, str, str | None]]:
def get_ocr_pending(
self, limit: int = 0, destination_country: str | None = None, courier_source: str | None = None,
) -> list[tuple[str, datetime, str, str | None]]:
"""查待 OCR 订单(所有系统):(orderNo, createdAt, labelPdfUrl, destinationCountry)。
条件:有 labelPdfUrl、ocr_layout 未处理(Null)。
limit=0 表示不限。
limit=0 表示不限。可选按 destinationCountry / courierSource 筛选。
"""
sql = (
'SELECT "orderNo","createdAt","labelPdfUrl","destinationCountry" '
'FROM "Orders" '
'WHERE "labelPdfUrl" IS NOT NULL AND "ocr_layout" IS NULL '
'ORDER BY "orderedAt" DESC'
'WHERE "labelPdfUrl" IS NOT NULL AND "ocr_layout" IS NULL'
)
params: list = []
if destination_country:
sql += ' AND "destinationCountry"=%s'
params.append(destination_country)
if courier_source:
sql += ' AND "courierSource"=%s'
params.append(courier_source)
sql += ' ORDER BY "orderedAt" DESC'
if limit > 0:
sql += " LIMIT %s"
params.append(limit)