refactor: extract domain.py (shared site/file/colmap config)

Move ALL_REPORT_SITES / SITE_UNDELIVERED_FILE / BAISHI_FILE / BAISHI_COLUMNS / arrived_pieces_* / STATIONS / _site_cfg out of expected_undelivered into a new leaf module inbound_verify/domain.py. store.py and runtime.py now read site/file config from domain directly instead of through the compare engine (store keeps eu only for _read_business_dates). Behavior identical.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Misaka_Company
2026-07-24 08:38:18 +08:00
parent bd0df8909f
commit 91ef8970b8
4 changed files with 114 additions and 94 deletions

View File

@@ -29,10 +29,14 @@ import yaml
from psycopg.types.json import Jsonb
from inbound_verify.paths import BASE_DIR, CONFIG_PATH, DOWNLOAD_DIR
from inbound_verify.domain import (
BAISHI_FILE,
_site_cfg,
) # 站点 / 文件名配置(单一来源)
from inbound_verify import (
expected_undelivered as eu,
) # 复用站点 / 文件名 / 列映射 / 基号口径(单一来源
) # _read_business_dates比对侧业务日期读取
SCHEMA_PATH = os.path.join(BASE_DIR, "schema.sql")
@@ -261,7 +265,7 @@ _SQL_UNDELIVERED = """
def _ingest_expected(cur, site, business_date):
"""入库单站应到(运单级,按 waybill_no 去重 keep-first 后 UPSERT"""
cfg = eu._site_cfg(site)
cfg = _site_cfg(site)
path = os.path.join(DOWNLOAD_DIR, cfg["exp"])
if not os.path.exists(path):
print(f" [跳过] {site} 应到:文件不存在 {cfg['exp']}")
@@ -293,7 +297,7 @@ def _ingest_expected(cur, site, business_date):
def _ingest_actual(cur, site):
"""入库单站实到(扫描件级,按 piece_no UPSERT"""
cfg = eu._site_cfg(site)
cfg = _site_cfg(site)
path = os.path.join(DOWNLOAD_DIR, cfg["act"])
if not os.path.exists(path):
print(f" [跳过] {site} 实到:文件不存在 {cfg['act']}")
@@ -332,9 +336,9 @@ def _ingest_actual(cur, site):
def _ingest_undelivered_baishi(cur):
"""入库百世应到未到明细(子单级,按 (site, piece_no) UPSERT"""
path = os.path.join(DOWNLOAD_DIR, eu.BAISHI_FILE)
path = os.path.join(DOWNLOAD_DIR, BAISHI_FILE)
if not os.path.exists(path):
print(f" [跳过] 百世 未到:文件不存在 {eu.BAISHI_FILE}")
print(f" [跳过] 百世 未到:文件不存在 {BAISHI_FILE}")
return 0
df = pd.read_excel(path, dtype=str).fillna("")
rows = []