feat: label-ocr 支持 destination_country/courier_source 筛选优先处理
This commit is contained in:
+12
-4
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user