refactor: countryRegion 统一中文归一化; label-ocr 改用 countryRegion; destinationCountry 还原 ISO2

This commit is contained in:
yeuimu
2026-08-02 16:07:24 +00:00
parent 7ed1893b83
commit c5efa457d1
3 changed files with 33 additions and 50 deletions
+7 -7
View File
@@ -102,25 +102,25 @@ class SyncDB:
def get_ocr_pending(
self, limit: int = 0,
destination_countries: list[str] | None = None,
country_regions: list[str] | None = None,
courier_source: str | None = None,
days: int = 0,
) -> list[tuple[str, datetime, str, str | None]]:
"""查待 OCR 订单(所有系统):(orderNo, createdAt, labelPdfUrl, destinationCountry)。
"""查待 OCR 订单(所有系统):(orderNo, createdAt, labelPdfUrl, countryRegion)。
条件:有 labelPdfUrl、ocrLayout 未处理(Null)。
limit=0 表示不限。可选按 destinationCountries / courierSource 筛选。
limit=0 表示不限。可选按 countryRegions / courierSource 筛选。
days>0 时只取近 N 天下单的订单。
"""
sql = (
'SELECT "orderNo","createdAt","labelPdfUrl","destinationCountry" '
'SELECT "orderNo","createdAt","labelPdfUrl","countryRegion" '
'FROM "Orders" '
'WHERE "labelPdfUrl" IS NOT NULL AND "ocrLayout" IS NULL'
)
params: list = []
if destination_countries:
sql += ' AND "destinationCountry"=ANY(%s)'
params.append(destination_countries)
if country_regions:
sql += ' AND "countryRegion"=ANY(%s)'
params.append(country_regions)
if courier_source:
sql += ' AND "courierSource"=%s'
params.append(courier_source)