release: bump version to 1.1.7, update xq0031_xq0032 plugin to 1.0.8

主要变更:
1. 整体版本升级至1.1.7,更新安装包与shell版本号
2. 新增API与后端能力:
   - 新增停止运行接口,支持强制终止插件进程与浏览器子进程
   - 云端会话令牌与下载票据落库,适配多worker部署
   - 优化Chrome版本读取逻辑,避免弹窗与编码问题
3. xq0031_xq0032插件升级至1.0.8:
   - 新增仓库中文名自动筛选功能,简化用户操作
   - 优化ERP登录与报表导出流程,修复标签页残留问题
   - 新增前端强制停止按钮,支持实时终止运行
   - 修复中文编码与乱码问题,兼容Windows非UTF-8环境
4. 修复授权校验逻辑,确保账号与授权匹配
5. 更新文档与部署脚本,修正发版流程说明
This commit is contained in:
2026-09-17 23:25:33 +08:00
parent f30ab9cc29
commit 78aa8c361c
29 changed files with 975 additions and 2015 deletions
+55 -11
View File
@@ -11,6 +11,7 @@ import time
from datetime import datetime
from . import config
from . import erp_login
from . import k3_common as kc
TAG = '[采购订单列表]'
@@ -46,10 +47,46 @@ def _diag_search(page):
config.log(f'{TAG} [探针] 过滤按钮可见: {filter_visible}')
def _open_report(page):
def _back_home(page, erp='new'):
"""整页回到 K3 主控台首页(index.aspx 带会话自动进控制台),清掉残留标签页。"""
try:
home = erp_login.ERP_URLS.get(erp, erp_login.ERP_URLS['new'])
page.get(home)
time.sleep(2.5)
except Exception as e:
config.log(f'{TAG} 回主控台首页异常(继续尝试): {e}')
def _active_tab_title(page):
"""当前激活的主标签页标题。K3 多表单标签残留(物料收发汇总表/采购订单列表并存)时,
必须确认操作的是激活的那个,否则会读到隐藏标签页的旧条数。"""
try:
t = page.ele('css:li[aria-selected="true"] .k-link', timeout=2)
if t is not None:
return (t.text or '').strip()
except Exception:
pass
return ''
def _open_report(page, erp='new'):
"""点击全局搜索 → 输入「采购订单列表」→ 等联想下拉出现 → 点选编号 CGDDLB 项。
注意:不能按回车——K3 全局搜索回车会默认直接进入第一个结果,下拉随即关闭,
无法精确选中 CGDDLB 项。输入后等待联想下拉,再点对应项。"""
打开后必须校验主标签页已切到「采购订单列表」,否则可能停留在上一个报表标签、
读到错页面的行数;校验不过回主控台首页重新搜索进入(最多 2 轮)。"""
for _ in range(2):
if _do_search_open(page):
if REPORT_KEYWORD in _active_tab_title(page):
config.log(f'{TAG} 已打开列表({REPORT_NUMBER})')
return True
config.log(f'{TAG} 列表标签页未激活(可能残留其它表单标签),回主控台重新搜索')
_back_home(page, erp)
time.sleep(1)
config.log(f'{TAG} 打开「采购订单列表」失败:未能确认列表标签页激活')
return False
def _do_search_open(page):
"""执行一次全局搜索并点选 CGDDLB 结果(不校验标签页是否真的激活,由 _open_report 负责)。"""
if not kc.click_visible(page, 'css:.kd-fullsearch-searchicon', timeout=10):
config.log(f'{TAG} 找不到全局搜索图标')
return False
@@ -78,7 +115,6 @@ def _open_report(page):
li.click()
time.sleep(2)
if kc.ele_visible(page, 'css:[id*="BILLMENU_TOOLBAR-tbFilter"]', timeout=2):
config.log(f'{TAG} 已打开列表({REPORT_NUMBER})')
return True
except Exception:
pass
@@ -186,9 +222,11 @@ def _read_rowcount(page):
return None, -1
def _wait_progress(page, timeout=300):
def _wait_progress(page, timeout=30):
"""等待查询完成:进入页面时分页栏已带旧条数,查询时会先变 0(或消失)再变新条数。
故记录初始条数,等行数经历「变 0/消失」或「发生变化」后,再出现非 0 条数才算完成。"""
故记录初始条数,等行数经历「变 0/消失」或「发生变化」后,再出现非 0 条数才算完成。
超时不再判定失败:现场结论查询可能太快、行数不经历 0 直接保持旧值,死等会白白卡
几分钟。故超时后直接继续导出(由上层重试机制兜底,避免整单卡死)。"""
_, init_cnt = _read_rowcount(page)
config.log(f'{TAG} 当前条数: {init_cnt if init_cnt >= 0 else "无"},等待查询刷新...')
saw_reset = init_cnt < 0 # 初始无条数视为已重置
@@ -202,8 +240,8 @@ def _wait_progress(page, timeout=300):
config.log(f'{TAG} 查询完成: {txt}')
return True
time.sleep(1)
config.log(f'{TAG} 等待查询完成超时(行数未刷新)')
return False
config.log(f'{TAG} 等待查询完成超时(行数未刷新,直接继续导出)')
return True
def _export_all_pages(page):
@@ -378,15 +416,21 @@ def _run_once(page, scheme):
# ================== 入口 ==================
def run(page, save_dir, scheme, progress=None):
"""先全局搜索打开列表,再按方案导出(快捷方案 → 等查询 → 引出 → 下载,重试 3 次)。
def run(page, save_dir, scheme, erp='new', progress=None):
"""先全局搜索打开列表(校验列表标签页已激活),再按方案导出(快捷方案 → 等查询 → 引出 → 下载,重试 3 次)。
每次导出前校验仍处于「采购订单列表」标签页,不对则回主控台首页重新搜索进入。
progress(done, total) 为整体进度回调;返回保存文件路径,失败返回 None。"""
if not _open_report(page):
if not _open_report(page, erp):
raise RuntimeError("打开「采购订单列表」失败:全局搜索未命中 CGDDLB 列表(详见日志)")
new_name = f'{config.FILE_PREFIX_32}_{datetime.now():%Y-%m-%d}.xlsx'
config.log(f'{TAG} 导出文件: {new_name}')
for attempt in range(1, config.RETRY_MAX + 1):
config.log(f'{TAG} 第 {attempt}/{config.RETRY_MAX} 次导出')
# 做之前校验:当前激活标签必须是「采购订单列表」,否则回首页重新搜索进入
if REPORT_KEYWORD not in _active_tab_title(page):
config.log(f'{TAG} 当前标签页不是「采购订单列表」,回主控台重新搜索进入')
if not _open_report(page, erp):
break
if _run_once(page, scheme):
if kc.download_file(page, save_dir, new_name, tag=TAG):
if progress: