fix(runtime): ingest before db_compare so first-run/force reads fresh data
DB 比对发生在入库之前,导致首次/force 时 PG 无当天数据,比对返回 None、不产出 Excel。在 _site_undelivered_handler 下载成功后、比对前,前置 _record_business_date + ingest_task,使比对能读到本次下载的数据。dispatch_task 后置 _persist_to_db 保持不变(对 undelivered 幂等重复一次,安全)。 四站真机验证通过(中通/韵达/安能 + 顺心):前置入库日志均出现在 db_compare 之前,force 首跑即产出 Excel。 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -493,6 +493,23 @@ def _site_undelivered_handler(site):
|
||||
os.remove(stale)
|
||||
return False
|
||||
|
||||
# ── 先入库再比对(修复时序:比对须读到本次下载的数据,
|
||||
# 否则首次/force 时 PG 无当天数据,比对返回 None、不产出 Excel)──
|
||||
try:
|
||||
_record_business_date(site, "undelivered", date)
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
from inbound_verify import store # 懒导入,避免成环
|
||||
|
||||
if store.ingest_enabled():
|
||||
store.ingest_task(
|
||||
site, "undelivered"
|
||||
) # 4 站 = ingest expected + actual
|
||||
print(f">> [入库] {site} 前置入库完成")
|
||||
except Exception as e:
|
||||
print(f">> [入库] {site} 前置入库失败(不影响比对尝试): {e}")
|
||||
|
||||
# ── DB 比对(替代旧 Excel 比对)──
|
||||
try:
|
||||
from inbound_verify import db_compare # 懒导入,避免成环
|
||||
|
||||
Reference in New Issue
Block a user