Misaka
36b204abe5
refactor(db_compare): 差缺统计改为应到驱动,以出库日为批次归属日
...
将未到统计从实到驱动(实到锚点反推批次)改为应到驱动(batch_out_date 归属日直接取应到批次),以吸收应到任务提前 1~2 天提交的扰动(韵达固定 +1、中通偶发 +1)。
- expected_record 新增 out_date / batch_out_date + 索引;入库解析出库时间并聚合批次归属日,支持历史回填
- 新增 compare_site_outdate 应到驱动入口,保留 compare_site_date 实到驱动作对照
- 未到任务 / POST /compare / 全站汇总切换到应到驱动
- 附现状梳理、设计、实现总结三篇文档
2026-08-03 22:52:28 +08:00
Misaka
c1bd53d832
feat(tasks): record trigger mode, target date and force in task history
2026-08-02 14:14:30 +08:00
Misaka
eaf56c1c9e
refactor(status): derive readiness from ingest_state; drop Excel probe & /data
...
状态盘就绪态 {kind}_ready 改为从持久的 ingest_state 派生(DB 真相、重启不丢),
不再由心跳读 downloads/ Excel、也不在启动时重置:
- 心跳 _fresh_ingest/_ready_flags/_apply_ready:expected/actual_ready=该类今天入库成功;
undelivered_ready=百世原生(今天入库) / 4 站派生(expected ∧ actual)。
- _persist_to_db 入库后调 _refresh_ready 立即派生(省 30s 心跳等待,与心跳同源);
4 站 undelivered 连入 expected+actual,故 ingest_state 补记 expected/actual/undelivered 三行。
- _record_business_date 只写 business_date,不再碰 ready。
- 删 run_heartbeat 的 Excel 探测循环、DATA_FILENAMES、probe_data_file、遗物清理。
- state_store 增 set_business_date / set_ready(仅写单字段,不碰彼此)。
- 删 GET /data/{filename}(前端不再下载原始中转 Excel);/report 保留。
原则:Excel 只作「站点下载→入库」中转,状态/比对一律走 DB。
真机+单元验证:重启后心跳派生(百世今日入库→立即绿、重启不掉灰);韵达 expected-only
时 undelivered 不亮、补 actual 后亮(派生);百世原生;_ready_flags 7 例边界全过。
Co-Authored-By: Claude <noreply@anthropic.com >
2026-07-31 23:47:23 +08:00
Misaka_Company
541836fd1b
feat(db_compare): add PostgreSQL-based comparison engine with SF handling
...
Replace Excel-based undelivered comparison with DB queries for all four
sites. The engine anchors on actual scan_time, reverse-lookups handover
batches, and compares expected vs actual waybill-by-waybill.
Shunxin SF waybills: use COUNT(*) instead of COUNT(DISTINCT piece_no)
since SF piece numbers are random and not derivable from the waybill.
Changes:
- db_compare.py: new module with compare_site_date(), compare_site_batch(),
write_result_excel(), and POST /compare API endpoint
- runtime.py: switch _site_undelivered_handler from compare.write_site_file
(Excel) to db_compare (DB); downloads succeed independently of comparison
- server.py: add POST /compare endpoint with date validation
- docs: implementation plan for Shunxin DB comparison
Co-Authored-By: Claude <noreply@anthropic.com >
2026-07-31 16:31:54 +08:00
Misaka_Company
4f0ef69739
fix(server): lower date backtrack limit from 90 to 31 days
...
Aneng only supports querying data up to 31 days back. The previous
90-day cap allowed dates that would silently fail at download time,
so restrict the POST /tasks `date` validation to a 31-day window.
2026-07-29 16:55:14 +08:00
Misaka_Company
5e2ef72afd
feat(server): add date field to POST /tasks with legality validation
...
Co-Authored-By: Claude <noreply@anthropic.com >
2026-07-29 13:11:12 +08:00
Misaka_Company
f710622a3d
feat: dedup expected data by handover_no before export submit
...
- store.get_existing_handover_nos: query PG expected_record.handover_no
- inject dedup skip before submitting export in zto/yunda/anneng/shunxin
- shunxin reads RTS handover_no from waybill-list view (method 1)
- force-redownload switch threaded via task_spec -> dispatch -> impl
- schema: add idx_expected_handover index
Co-Authored-By: Claude <noreply@anthropic.com >
2026-07-29 10:57:07 +08:00
Misaka
d74a35844f
feat(schedule): 周期抓取调度取代每日定点下载
...
应到/实到数据各自独立周期抓取(启用+激活时段+频率),抓取与处理解耦,抓完自动落库(复用现有 _persist_to_db 钩子)。
- state_store: 新增 fetch_schedule 表(site,kind);所有连接加 timeout=3.0 防并发锁;get/set/get_all_fetch_schedules、create_task_if_idle(周期去重)、allowed_kinds;get_all_config 改返回 fetch_schedules;旧 set_schedule 标废弃。修复 get_all_fetch_schedules 列错位(_fetch_spec(r[2:]))。
- server: IntervalTrigger + _in_active_window(含跨午夜) + _enqueue_fetch(就绪门/激活窗口/去重) + _reschedule_fetch + lifespan 按(site,kind)注册 + FetchScheduleSpec + PUT/GET /config 新结构。
- runtime/store/BFF: 零改动。
Co-Authored-By: Claude <noreply@anthropic.com >
2026-07-28 22:58:47 +08:00
Misaka
82ab6d8be3
feat(runtime): 服务模式任务执行不再激活浏览器窗口
...
网页站点(顺心/百世/中通/韵达)执行下载流程时不再把浏览器窗口置顶,避免打扰用户当前工作;流程在后台静默跑。启动登录阶段与交互模式不受影响。
- RuntimeContext 加 foreground 标志:True=任务执行时置顶(交互调试),False=后台静默(服务模式)
- launch_and_prepare(foreground=True) 透传;server worker 以 foreground=False 启动
- _web_handler 按 ctx.foreground 决定单 page 置顶;顺心(list) 透传给 shunxin_download
- shunxin 两个 download 加 foreground 参数,逐账号 bring_to_front 加条件
- 启动登录/初始弹窗清理的 bring_to_front 不变(启动时窗口需可见)
Co-Authored-By: Claude <noreply@anthropic.com >
2026-07-27 23:17:10 +08:00
Misaka_Company
5e4889e845
docs: sync docs with current package layout and auto-ingest hook
...
- config.example.yaml: replace stale site_yunda/main_router with new
module paths (sites.yunda, runtime)
- CLAUDE.md: add ingest-one to DB CLI list; new subsection documenting
the download->PostgreSQL auto-ingest hook (_persist_to_db, ingest_task,
ingest_state, /status.ingest, auto_ingest config)
- README.md: store tree comment lists all 5 CLI commands (add ingest-one)
- docs: /status row notes the ingest field; anneng CDP guide snippet
gets timeout=15
- cli/server.py: docstring run command -> python -m inbound_verify.cli.server
Co-Authored-By: Claude <noreply@anthropic.com >
2026-07-24 12:35:54 +08:00
Misaka_Company
615661c275
feat(server): expose ingest state in /status; doc auto-ingest in README
2026-07-24 11:16:19 +08:00
Misaka_Company
7065b88269
refactor: move flat modules into inbound_verify package (Tier 1, behavior-identical)
...
Relocate 12 root .py modules into inbound_verify/ (sites/, cli/ subpackages). Rewrite all internal imports to package-qualified; drop the site_ prefix on the 5 site modules and their 28 call sites. Fix paths.py BASE_DIR to anchor at the project root. Add main() entry wrappers (cli/router, cli/server, store). No behavior change.
Co-Authored-By: Claude <noreply@anthropic.com >
2026-07-23 12:21:31 +08:00