定时下载(APScheduler) + 跑比对纯离线 + 偏移拆 expected/actual + 报告下载
定时下载:
- state_store:site_config 加 schedule_enabled/schedule_time(旧库迁移)+ set_schedule/get_all_config
- server:APScheduler BackgroundScheduler,启动按配置注册各站 cron job、改配置重排;job 投 undelivered 任务到队列(错过跳过);/config 扩展 schedule
- runtime:("__compare__","compare") 改纯离线 expected_undelivered.main()(不下载)
- requirements:加 apscheduler
偏移拆分 + 报告下载:
- state_store:date_offset 拆 expected_offset/actual_offset(迁移)+ get_offset(site,kind)/set_offset(site,kind,n)
- 4 站 actual impl 改读 actual 偏移(expected 走默认 kind)
- server:/config 用 expected_offset/actual_offset;新增 GET /report(服务 output/应到未到数据.xlsx)
- paths:加 OUTPUT_DIR
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
22
runtime.py
22
runtime.py
@@ -429,25 +429,7 @@ def _site_undelivered_handler(site):
|
||||
return handler
|
||||
|
||||
|
||||
def _run_all_compare_handler():
|
||||
"""顶部「跑比对」:顺序跑 5 站未到(4 站 expected+actual→比对;百世直供),
|
||||
记录本次成功站 → build_full_report。失败/未登录站保留行、无数据,不影响他站。"""
|
||||
|
||||
def handler(ctx):
|
||||
include = set()
|
||||
for site in ("顺心", "中通", "韵达", "安能", "百世"):
|
||||
if not probe_site_login(site, ctx.pages_map):
|
||||
print(f">> [跑比对] {site} 未登录,跳过其统计")
|
||||
continue
|
||||
h = TASK_HANDLERS.get((site, "undelivered"))
|
||||
if h and h(ctx):
|
||||
include.add(site)
|
||||
else:
|
||||
print(f">> [跑比对] {site} 未到数据获取失败,跳过其统计")
|
||||
expected_undelivered.build_full_report(include)
|
||||
return True
|
||||
|
||||
return handler
|
||||
# 「跑比对」= 纯离线比对(用 downloads/ 现有文件生成全站汇总;下载交由各站定时/手动)。
|
||||
|
||||
|
||||
TASK_HANDLERS = {
|
||||
@@ -466,7 +448,7 @@ TASK_HANDLERS = {
|
||||
("安能", "expected"): lambda ctx: site_anneng.anneng_expected_download(),
|
||||
("安能", "actual"): lambda ctx: site_anneng.anneng_actual_download(),
|
||||
("安能", "undelivered"): _site_undelivered_handler("安能"),
|
||||
("__compare__", "compare"): _run_all_compare_handler(),
|
||||
("__compare__", "compare"): lambda ctx: (expected_undelivered.main() or True),
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user