diff --git a/inbound_verify/cli/router.py b/inbound_verify/cli/router.py index 92ea662..4629bbf 100644 --- a/inbound_verify/cli/router.py +++ b/inbound_verify/cli/router.py @@ -1,8 +1,8 @@ -# main_router.py +# inbound_verify/cli/router.py # # 交互菜单模式入口(调试 / 人工操作)。核心 Playwright 管理、任务派发、心跳 # 已抽到 runtime.py 共享;本文件只保留交互菜单与自动化测试。 -# 服务模式(常驻 + FastAPI 接收指令)见 server.py。 +# 服务模式(常驻 + FastAPI 接收指令)见 cli/server.py。 import os import queue diff --git a/inbound_verify/runtime.py b/inbound_verify/runtime.py index c8bd56c..7fb24ef 100644 --- a/inbound_verify/runtime.py +++ b/inbound_verify/runtime.py @@ -2,8 +2,8 @@ # 阶段1:服务化共享核心。把"启动浏览器 + 各站就绪 + 弹窗 + 心跳初值" # (launch_and_prepare)、"执行一条任务"(dispatch_task)、"一轮心跳"(run_heartbeat) # 抽出来,供 -# - main_router.py(交互菜单模式:调试 / 人工操作) -# - server.py(FastAPI 服务模式:常驻 + 接收 API 指令) +# - cli/router.py(交互菜单模式:调试 / 人工操作) +# - cli/server.py(FastAPI 服务模式:常驻 + 接收 API 指令) # 共同复用,避免两处重复维护。 # # 线程模型:launch_and_prepare 内 sync_playwright().start() 必须在"持有 Playwright 的 diff --git a/inbound_verify/sites/anneng.py b/inbound_verify/sites/anneng.py index 3539441..a2e3a6b 100644 --- a/inbound_verify/sites/anneng.py +++ b/inbound_verify/sites/anneng.py @@ -2,11 +2,11 @@ # # 安能全网门户(Electron 应用)—— 应到货物数据下载。 # -# 与其他站点(网页、由 main_router 用 Playwright 驱动)不同,安能是一个 Electron -# 桌面应用:由 main_router 以调试模式启动(动态空闲端口,经 set_cdp_port 告知本模块), +# 与其他站点(网页、由 runtime 用 Playwright 驱动)不同,安能是一个 Electron +# 桌面应用:由 runtime 以调试模式启动(动态空闲端口,经 set_cdp_port 告知本模块), # 本模块通过该端口的 CDP 驱动它;「进站交接单查询」「导出下载」等右侧 tab 是 # **独立 webContents**(远程网页),在 /json 里是独立目标。 -# 也可脱离 main_router 独立运行(此时用默认端口 9222,需已自行启动应用): +# 也可脱离 runtime 独立运行(此时用默认端口 9222,需已自行启动应用): # python -m inbound_verify.sites.anneng expected # 或 actual # # 应到 = 运单信息导出(每张交接单下应到的运单明细)。整体流程: @@ -73,13 +73,13 @@ def with_retry(site_name, label, flow, reset, max_attempts=3): return False -CDP_PORT = 9222 # 默认端口(独立运行(python -m inbound_verify.sites.anneng)时用);main_router 启动时会用 set_cdp_port 覆盖 +CDP_PORT = 9222 # 默认端口(独立运行(python -m inbound_verify.sites.anneng)时用);runtime 启动时会用 set_cdp_port 覆盖 POLL_INTERVAL = 0.5 DEFAULT_TIMEOUT = 25.0 def set_cdp_port(port): - """由 main_router 在启动安能应用后调用,告知本模块实际使用的调试端口。""" + """由 runtime 在启动安能应用后调用,告知本模块实际使用的调试端口。""" global CDP_PORT CDP_PORT = int(port) @@ -186,7 +186,7 @@ def find_main_page_cdp(): def anneng_ready(): - """安能主页是否就绪(供 main_router 的就绪轮询调用)。 + """安能主页是否就绪(供 runtime 的就绪轮询调用)。 判据:能连上 CDP 且主页出现站点名称控件(带 title+fontsizenum 的 div)。 连不上或未就绪一律返回 False,不抛异常(就绪轮询会反复调用)。 diff --git a/inbound_verify/sites/baishi.py b/inbound_verify/sites/baishi.py index 91bec64..d0b145e 100644 --- a/inbound_verify/sites/baishi.py +++ b/inbound_verify/sites/baishi.py @@ -38,7 +38,7 @@ def with_retry(site_name, label, flow, reset, max_attempts=3): return False -# 站点首页 URL:异常兜底重置用,也供 main_router 的 SITES_CONFIG 引用(单一来源) +# 站点首页 URL:异常兜底重置用,也供 runtime 的 SITES_CONFIG 引用(单一来源) HOME_URL = "https://v5.800best.com" diff --git a/inbound_verify/sites/shunxin.py b/inbound_verify/sites/shunxin.py index e4f9645..2bcc1e2 100644 --- a/inbound_verify/sites/shunxin.py +++ b/inbound_verify/sites/shunxin.py @@ -41,7 +41,7 @@ def with_retry(site_name, label, flow, reset, max_attempts=3): return False -# 站点首页 URL:异常兜底重置用,也供 main_router 的 SITES_CONFIG 引用(单一来源) +# 站点首页 URL:异常兜底重置用,也供 runtime 的 SITES_CONFIG 引用(单一来源) HOME_URL = "https://sxne.sxjdfreight.com" diff --git a/inbound_verify/sites/yunda.py b/inbound_verify/sites/yunda.py index 0306bba..c742069 100644 --- a/inbound_verify/sites/yunda.py +++ b/inbound_verify/sites/yunda.py @@ -41,7 +41,7 @@ def with_retry(site_name, label, flow, reset, max_attempts=3): return False -# 站点首页 URL:异常兜底重置用,也供 main_router 的 SITES_CONFIG 引用(单一来源) +# 站点首页 URL:异常兜底重置用,也供 runtime 的 SITES_CONFIG 引用(单一来源) HOME_URL = "https://ky-sso.yunda56.com" diff --git a/inbound_verify/sites/zto.py b/inbound_verify/sites/zto.py index 4c78b95..efc0d9f 100644 --- a/inbound_verify/sites/zto.py +++ b/inbound_verify/sites/zto.py @@ -41,7 +41,7 @@ def with_retry(site_name, label, flow, reset, max_attempts=3): return False -# 站点首页 URL:异常兜底重置用,也供 main_router 的 SITES_CONFIG 引用(单一来源) +# 站点首页 URL:异常兜底重置用,也供 runtime 的 SITES_CONFIG 引用(单一来源) HOME_URL = "https://ws.zto56.com/" diff --git a/inbound_verify/store.py b/inbound_verify/store.py index 451485c..da18680 100644 --- a/inbound_verify/store.py +++ b/inbound_verify/store.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -db_store.py — 到货核销数据持久化(PostgreSQL) +store.py — 到货核销数据持久化(PostgreSQL) 职责:把 downloads/ 下各站点下载的应到 / 实到 / 未到 Excel 解析后,幂等写入 PostgreSQL。 与下载流程解耦:本模块只读 downloads/ 现有文件入库,不关心谁触发下载、下载了几次。 @@ -13,10 +13,10 @@ db_store.py — 到货核销数据持久化(PostgreSQL) - 单号一律按文本读写(dtype=str),防长数字被科学计数 / 精度丢失 命令行: - python db_store.py createdb 创建数据库(幂等) - python db_store.py init 建表(幂等 CREATE TABLE IF NOT EXISTS) - python db_store.py ingest [site] 入库全站或单站(幂等 UPSERT) - python db_store.py all createdb → init → 全站 ingest 一条龙 + python -m inbound_verify.store createdb 创建数据库(幂等) + python -m inbound_verify.store init 建表(幂等 CREATE TABLE IF NOT EXISTS) + python -m inbound_verify.store ingest [site] 入库全站或单站(幂等 UPSERT) + python -m inbound_verify.store all createdb → init → 全站 ingest 一条龙 """ import os