Commit Graph

11 Commits

Author SHA1 Message Date
Misaka
5030e5b89b 统一各站成败反馈信号;修复中通报错卡死与提示框误判
成败信号统一化(顺心/中通/韵达/安能/百世):
- 各站 impl 开头清理上次的最终文件,避免无数据/失败时残留旧数据误导比对
- 轮询下载段加汇总校验:下载数 < 预期则 raise,堵住"零/部分下载被判成功"
- 正常完成统一显式 return True(原中通/韵达/安能靠 None 隐式成功)
- 无数据统一不落文件(安能实到不再落空 xlsx);韵达裸 except 改 except Exception
- 中通"票数0无空提示"分支改判失败

中通 bug 修复(site_zto.py):
- poll 加 stall 快速失败(连续4轮无进展即 raise)+ 刷新短超时 + 双失败 raise,
  避免页面被遮挡时干等 5 分钟才触发重试
- "生成离线导出任务成功"提示所在 iframe 提交后被销毁,wait_for 抛
  "Frame was detached" 属正常(提示已随 iframe 消失=任务已建立),改判成功

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-16 21:38:56 +08:00
Misaka
55e9e9e931 顺心站点支持双账号(双归属地)下载与融合
- main_router: 顺心在同一窗口开两个标签页登录两个归属地账号;就绪轮询、
  初始弹窗、菜单 [1][2]、自动化测试均改为按 page 列表处理
- site_shunxin: download 入口改为接收 page 列表;新增 shunxin_belonging
  读归属地、shunxin_merge_final 融合两账号数据;impl 加 out_tag 参数化
  各账号产物文件名;两账号同归属地时去重校验中止以防数据翻倍
- expected_undelivered: 零改动(融合后产物仍为同名文件)
- 更新 CLAUDE.md / README.md 文档说明

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-15 22:36:58 +08:00
Misaka
a71924ca1a Cap export-task poll loops at 5min to avoid infinite hang
顺心/中通/韵达/安能 的导出任务轮询循环原本只在"本批任务全部完成"时
退出,无任何时间上限:任务卡在生成中、或因时钟偏移没落进 40s 容差窗口
匹配不上时,会无限轮询、流程永不返回,连 with_retry 都没机会触发。

给这 5 处轮询加 300s deadline,超时即 raise → 流程返回 False → 触发
已有的重置重试机制。把"永久挂死"变成"有界失败→自动重试"。

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-14 22:24:41 +08:00
Misaka
2d49c3d6f1 Add per-site exception fallback (reset + retry), router stays pure dispatch
每个站点模块自带"失败→重置回初始态→重试"兜底(最多 3 次,含首次;每次
失败都重置,含最终放弃那次清场),对外只暴露 xxx_download 公开入口,路由
层无感、只负责调度。

- 各站点模块新增:HOME_URL、xxx_reset、内联 with_retry;原流程拆为
  xxx_download(带重试) + xxx_download_impl(单次,供自动化测试探测原始失败)。
- 网页站重置=goto 首页 URL;安能(Electron)重置=关业务 tab+收菜单(实测
  reload 会留下杀不掉的僵尸 webContents,故不用 reload)。
- main_router:SITES_CONFIG 改引用各模块 HOME_URL(单一来源);菜单分派回归
  朴素调用;run_automation_test 改走 _impl 以保留"暴露问题"的测试本意。

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-08 22:39:38 +08:00
Misaka
63ee8bbae1 Unify export-task matching to time tolerance only (≤40s)
去掉顺心/中通/韵达/安能(应到) 导出任务认领时的标题/模块名校验,
统一改为仅按提交时间容差 ≤40 秒匹配本批任务。

理由:单账号无并发,时间窗内的任务必为本批所建;而站点可能调整
任务标题名,写死标题会导致匹配失败、任务已创建却一直查不到。
同步清理因此变成死代码的局部变量与函数形参。

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-06 22:04:22 +08:00
Misaka
5b7a024fa8 Parameterize Shunxin query window and document it in example config
- site_shunxin: replace the hardcoded 1天 radio with config-driven
  shunxin.query_days, set the date range via the ant-picker, and add a
  two-pass query/retry to clear stale "暂无数据" DOM state; return True
  on completion
- config.example.yaml: add the shunxin section (query_days) so the
  example matches what the code reads

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-21 10:43:55 +08:00
Misaka
229e474b58 Add cross-flow automation test and tone down log/comment wording
- main_router: add run_automation_test that runs each site's download
  flows in a cross sequence (expected/actual) plus a pass/fail report
  with timings; expose it as menu [8]
- Site download functions now return False on their exception paths so
  the test harness can record failures (baishi also flags config-read
  failure)
- Replace overblown log/comment phrasing across all modules with plain
  statements; trim docstrings

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-20 23:33:22 +08:00
Misaka
ab3f25a10e Centralize paths in paths.py and harden waybill-number handling
- Add paths.py: BASE_DIR/DOWNLOAD_DIR/CONFIG_PATH anchored on __file__
  so paths resolve regardless of the launch cwd
- Route main_router and all site modules through DOWNLOAD_DIR/CONFIG_PATH,
  replacing os.getcwd()-based download dirs and the "config.yaml" literal
- main_router compare engine: read Excel as str with keep_default_na,
  strip/normalize 运单号, drop blanks, and isin against a set so
  int/float-vs-str mismatches no longer produce false "undelivered"
- Shunxin: give downloaded files unique microsecond temp names and read
  Excel as str to preserve long-waybill precision
- Normalize bare except: to except Exception: across affected files

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-20 22:28:30 +08:00
Misaka
5d13c13f40 Close Shunxin tabs after each stage via shared _close_tab helper
- Add _close_tab(page, tab_name) for closing Ant Design Tabs by label
- Close 运单列表 / 车辆点到 in the expected-arrival flow after export
  submission, and 数据导出 after download/merge
- Close 卸车扫描记录 and 数据导出 likewise in the actual-arrival flow
- Renumber step comments

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-20 21:47:05 +08:00
Misaka
497fd11674 Add per-site file prefix for undelivered-data comparison
- task_process_undelivered_data now accepts site_name (default 顺心)
  and reads/writes {site}-{应到/实到/应到未到}货物数据.xlsx
- Menu option 5 prompts for site name before running reconciliation
- Update 顺心 site outputs to 顺心-应到/实到货物数据.xlsx naming
- Remove redundant inline comments in site_shunxin.py

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-15 22:09:12 +08:00
Misaka
411a2487fc Refactor monolithic script into multi-site module architecture
- Introduce main_router.py as multi-site controller with interactive menu
- Extract 顺心 site logic into site_shunxin.py (expected & actual download)
- Add site_baishi.py stub for upcoming 百世 integration
- Add global 应到未到 data reconciliation via Left Anti-Join on 运单号

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-15 22:02:51 +08:00