restore: 恢复 11-06~11-09 本地未提交改动
- libs: 新增 hr_sdk / hotel_report / dingtalk,更新 desktopauto - controlplane-next: SDK 管理模块(controller/entity/migrations)与前端视图 - electron-shell: 插件同步、注册表、runner 调整 - plugins: XQ0035/XQ0041/XQ0042/XQ0045_XQ0046/XQ0048/XQ0076/XQ0078 等版本更新 - tests/tools: 新增 SDK 兼容性检查与打包工具(sdk_pack.py、sdk_compat_check.py)
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""XQ0052 台账维护端到端:在**模板副本**上跑一遍(不碰生产文件),验证四张 sheet 的写入。
|
||||
|
||||
流程与插件一致:
|
||||
交班时间逐日追加 → 明细按天追加(支付方式按列名对应)→ 新办卡追加(A 列交班时间)
|
||||
→ 余额整体覆盖 → 重算 → 汇总核对
|
||||
|
||||
用法(项目根):
|
||||
.venv\\Scripts\\python.exe tests\\xq0052_湖畔储值卡\\ledger_e2e.py --no-recalc
|
||||
.venv\\Scripts\\python.exe tests\\xq0052_湖畔储值卡\\ledger_e2e.py # 含重算
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
import time
|
||||
from datetime import datetime
|
||||
|
||||
BASE = os.path.dirname(os.path.abspath(__file__))
|
||||
ROOT = os.path.abspath(os.path.join(BASE, "..", ".."))
|
||||
sys.path.insert(0, os.path.join(ROOT, "libs", "hotel_report"))
|
||||
sys.path.insert(0, os.path.join(ROOT, "plugins", "XQ0001-0100",
|
||||
"XQ0052 湖畔储值卡每日导出统计"))
|
||||
|
||||
TEMPLATE = r"D:\资料\财务\湖畔储值卡每日导出统计\2026年11月会员卡统计-模版调整-新会员卡.xlsx"
|
||||
OUT_DIR = os.path.join(BASE, "out_test")
|
||||
|
||||
|
||||
def main(argv=None) -> int:
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--day", default="", help="目标营业日,留空=今天")
|
||||
ap.add_argument("--no-recalc", action="store_true", help="跳过工作簿重算(快)")
|
||||
ap.add_argument("--template", default=TEMPLATE)
|
||||
ap.add_argument("--inplace", action="store_true",
|
||||
help="直接维护 --template 指向的台账(会先自动备份),不复制副本")
|
||||
args = ap.parse_args(argv)
|
||||
|
||||
if hasattr(sys.stdout, "reconfigure"):
|
||||
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
||||
|
||||
import hotel_report
|
||||
from logic.ledger import LedgerMaintainer
|
||||
from logic.provider import SdkProvider
|
||||
|
||||
if args.inplace:
|
||||
target = args.template
|
||||
print(f"原地维护:{target}(会先自动备份)")
|
||||
else:
|
||||
os.makedirs(OUT_DIR, exist_ok=True)
|
||||
target = os.path.join(OUT_DIR, "台账副本.xlsx")
|
||||
t0 = time.time()
|
||||
shutil.copy2(args.template, target)
|
||||
print(f"已复制模板副本({os.path.getsize(target) / 1048576:.1f} MB,{time.time() - t0:.1f}s)")
|
||||
|
||||
day = (datetime.strptime(args.day, "%Y-%m-%d").date() if args.day
|
||||
else datetime.now().date())
|
||||
cfg = hotel_report.HotelConfig.resolve(timeout=300)
|
||||
maint = LedgerMaintainer(target, log=lambda m, lv="INFO": print(f" [{lv}] {m}"),
|
||||
progress=lambda p: None, backup=args.inplace,
|
||||
recalc=not args.no_recalc)
|
||||
|
||||
t0 = time.time()
|
||||
res = maint.run(day, SdkProvider(hotel_report, cfg))
|
||||
cost = time.time() - t0
|
||||
|
||||
print(f"\n耗时 {cost / 60:.1f} 分钟")
|
||||
print(f"补的天:{[str(d) for d in res['days']]}")
|
||||
print(f"明细 +{res['detail_rows']} 行,新办卡 +{res['new_cards']} 行,"
|
||||
f"余额 {res['balance_rows']} 人(合计 {res['balance_total']:,.2f})")
|
||||
print("核对:")
|
||||
for c in res["checks"]:
|
||||
print(f" {'✓' if c['ok'] else '✗'} {c['name']}:应为 {c['expect']} / 实际 {c['actual']}"
|
||||
f"{(' ' + c['note']) if c['note'] else ''}")
|
||||
bad = [c for c in res["checks"] if not c["ok"]]
|
||||
print(f"\n结论:{'全部一致' if not bad else f'{len(bad)} 项不一致'}")
|
||||
return 0 if not bad else 2
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user