Files
37duAutomation/tools/xq0012_payapply_pdf.py
T
puddy c4615bc8e3 chore(tools): 新增打印/PDF/表格工具与 OA→ERP 单点登录脚本
- tools/printer_probe.py:打印机协议非破坏性探测(端口/IPP 能力/LPD 队列,绝不提交作业)
- tools/printer_client.py:IPP 直连打印(info / validate 干跑 / print 需显式 --yes)
- tools/doc2pdf.py:网页 / HTML / Excel 指定区域转 PDF,产物可直接交给 printer_client
- tools/sheet_print.py:Excel·WPS 表格按列过滤排版后分页打印
- tools/xq0012_payapply_pdf.py:XQ0012 套打 PDF 本地预览工具
- workflows/share/erp_sso_login.py:读 OA 登录态换 ERP 会话(新版/旧版,纯接口无浏览器)
- workflows/README.md 新增 4.9 节说明
2026-11-16 11:28:01 +08:00

49 lines
1.7 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 -*-
"""XQ0012 套打 PDF 开发入口(薄封装)。
真正的实现在插件里:`plugins/XQ0001-0100/XQ0012 .../report/payapply_pdf.py`(随插件发布)。
本脚本只是开发期的便利入口:从测试服取一张单,按套打版面出一张 PDF,便于比对/打印。
用法:
.venv\\Scripts\\python.exe tools/xq0012_payapply_pdf.py
"""
import importlib.util
import os
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
_PLUGIN_MOD = (ROOT / 'plugins' / 'XQ0001-0100' /
'XQ0012 EHR预支及支付报酬自动发起ERP付款申请' / 'report' / 'payapply_pdf.py')
_spec = importlib.util.spec_from_file_location('xq0012_payapply_pdf', _PLUGIN_MOD)
_mod = importlib.util.module_from_spec(_spec)
_spec.loader.exec_module(_mod)
from_view = _mod.from_view
render_payapply = _mod.render_payapply
BILL_NO = 'FKSQ20261100023' # 演练单;可改成任意已存在的单据编号
ACCT = '6842cfeb653336' # 集团备份账套(唯一开了 MQ)
def main():
sys.path.insert(0, str(ROOT / 'libs' / 'erpsdk'))
from erpsdk import ErpClient
kv = {}
for line in (ROOT / '.env').read_text(encoding='utf-8').splitlines():
line = line.strip()
if line and not line.startswith('#') and '=' in line:
k, v = line.split('=', 1)
kv[k.strip()] = v.strip()
erp = ErpClient('test', acct=ACCT).login(
kv['test_erp_login_username'], kv['test_erp_login_password'])
doc = erp.view('CN_PAYAPPLY', number=BILL_NO)
out = str(ROOT / 'out' / f'套打_付款申请单_{BILL_NO}.pdf')
print(render_payapply(from_view(doc, BILL_NO), out))
if __name__ == '__main__':
main()