fix(db_compare): anchor comparison on actual_offset so yunda reads fresh data
比对以实到扫描日(actual.scan_time::date)为锚,锚点日期必须等于实到下载日 = actual_offset。 原 _site_undelivered_handler(runtime.py)与 _target_date_for(db_compare.py)误用 expected_offset 算锚点:韵达 exp=1 / act=0,锚点落到 today-1(昨天),读到历史数据。 两处改用 actual_offset 后韵达锚点 = today,反推出 expected 的昨天批次正确参与比对。 其余 3 站 exp == act == 0,锚点不变。 5 站真机验证:韵达 07-31 比对现读新鲜数据 107/104/3(修复前读昨天 116/115/1); 中通/安能/顺心 不变;全站汇总报表重新生成。 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -499,10 +499,10 @@ def _stats_to_dict(s: CompareStats) -> dict:
|
||||
|
||||
|
||||
def _target_date_for(site: str) -> str:
|
||||
"""4 站比对锚点:today - expected_offset(与 _site_undelivered_handler 一致)。"""
|
||||
"""4 站比对锚点:today - actual_offset(以实到扫描日为锚,与 _site_undelivered_handler 一致)。"""
|
||||
from inbound_verify import state_store # 懒导入,避免成环
|
||||
|
||||
offset = state_store.get_offset(site, "expected")
|
||||
offset = state_store.get_offset(site, "actual")
|
||||
return (date.today() - timedelta(days=offset)).strftime("%Y-%m-%d")
|
||||
|
||||
|
||||
@@ -555,7 +555,7 @@ def _baishi_from_pg(cur, target: str):
|
||||
|
||||
def build_full_report(date=None) -> str:
|
||||
"""DB 版全站汇总报表:4 站走 DB 比对、百世走 PG,复用 compare.build_summary 渲染。
|
||||
产出 output/应到未到数据.xlsx(/report 下载)。date=None 时各站按 expected_offset 算锚点。
|
||||
产出 output/应到未到数据.xlsx(/report 下载)。date=None 时各站按 actual_offset 算锚点(以实到扫描日为锚)。
|
||||
返回输出路径。"""
|
||||
from inbound_verify import compare # 复用 build_summary / write_station / OUTFILE
|
||||
|
||||
|
||||
Reference in New Issue
Block a user