Files
37duAutomation/plugins/XQ0001-0100/XQ0021 酒店报表导出/_selftest.py
T
puddy 9873eb1963 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)
2026-11-09 17:27:10 +08:00

41 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
"""离线自测:用演示数据跑一遍 SDK 取数+渲染(不联网、不碰生产)。
由 SDK 兼容预检(`tools/sdk_compat_check.py`)在子进程里执行:
python -c "<runpy 调本文件>" (sys.path 已含 SDK 根与插件目录)
也可手动跑:
.venv\\Scripts\\python.exe "plugins\\XQ0001-0100\\XQ0021 酒店报表导出\\_selftest.py"
"""
from __future__ import annotations
import os
import sys
import tempfile
def main() -> int:
try:
from hotel_report import HotelConfig, export_shift
except ImportError as e:
print(f"SDK hotel_report 未挂载:{e}", file=sys.stderr)
return 2
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from data import demo
cfg = HotelConfig(wcf_url="http://127.0.0.1:1/unused", timeout=1)
out = os.path.join(tempfile.mkdtemp(prefix="xq0021_selftest_"), "交班查询.xlsx")
res = export_shift(cfg, "2026-11-05", "2026-11-05", out, query=demo.query)
if not res.get("path") or not os.path.isfile(res["path"]):
print(f"交班查询未产出文件:{res}", file=sys.stderr)
return 1
if int(res.get("count") or 0) <= 0:
print(f"交班条数异常:{res}", file=sys.stderr)
return 1
print(f"xq0021 selftest OK(交班 {res['count']} 条)")
return 0
if __name__ == "__main__":
raise SystemExit(main())