feat: 新增交通银行数据导出插件及测试通道机制

This commit is contained in:
2026-11-05 15:20:34 +08:00
parent b976b80d9d
commit 4e8b3e7d43
230 changed files with 19827 additions and 1440 deletions
@@ -20,7 +20,7 @@ class DingXingEvalPushPlugin(ScenePlugin):
id = "xq0038"
name = "定性评价推送"
version = "1.1.3"
version = "1.1.5"
description = ("定性评价(绩效定性考评)批量推送:读取《定性评价导入明细.xlsx》加工辅助表,"
"按定性发起标记+部门负责人分组,在 OA 蓝凌 EKP 批量创建绩效评价发起单;"
"默认仅暂存草稿,开启真实发送后发起流程(含子流程启动、通知复核人),"
@@ -35,6 +35,11 @@ DATA_HEADER_ROW = 2 # 表头所在行(首
MAX_RETRY = 3 # 单组失败重试次数
DEBUG = False # True 时输出调试信息
# 导出核对等待(秒):单据刚提交时 OA 搜索索引里的「当前环节/当前处理人」刷新有延迟,
# 立即导出会把刚提交的单据读成「起草节点 + 发起人」,误判为「当前处理人含登录账号」异常。
EXPORT_SETTLE_WAIT = 60 # 推送结束 → 首次导出前的等待(0=不等待,直接导出)
EXPORT_RECHECK_WAIT = 30 # 首次导出检出异常行 → 二次导出复核前的等待(0=立即复核)
MODEL_NAME = 'com.landray.kmss.km.review.model.KmReviewMain'
SEARCH_PLANS = OrderedDict([ # 门户查询方案(管理/专业序列定性评价)
('管理序列(新)', '199bd93c6d6998ef08fc293409cbc6a7'),
@@ -326,7 +326,8 @@ def run_push():
items = list(groups.items())
n = len(items)
ok_cnt, fail_list, detail = 0, [], {}
for i, (seq, (key, grp_rows)) in enumerate(items, 1):
for i, (key, grp_rows) in enumerate(items, 1):
seq = i
config.progress(int(100 * (i - 1) / n) if n else 0)
group = {'key': key, 'rows': grp_rows}
ok, info = process_one(s, group, seq)
@@ -2,7 +2,7 @@
"schema_version": 1,
"id": "xq0038",
"name": "定性评价推送",
"version": "1.1.3",
"version": "1.1.5",
"description": "定性评价(绩效定性考评)批量推送:读取《定性评价导入明细.xlsx》加工辅助表,按定性发起标记+部门负责人分组,在 OA 蓝凌 EKP 批量创建绩效评价发起单;默认仅暂存草稿,开启真实发送后发起流程(含子流程启动、通知复核人),发完可自动导出当天定性评价单并核对当前处理人(异常标记)。",
"category": "人事绩效",
"icon": "",
@@ -70,12 +70,44 @@ def audit_xls(path, user_name):
return len(bad)
def export_and_audit(s, name, sid, day, out_path, user_name):
"""单方案导出 + 核对,含全局重试。返回 (行数, 异常行数, 错误信息);错误信息为空即成功。
异常行数:-1=未核对(导出表无「当前处理人」列或未取到登录账号),0=无异常。
"""
last_err = ''
for attempt in range(1, config.MAX_RETRY + 1):
try:
total, err = export_plan_once(s, sid, day, out_path)
except Exception:
total, err = None, '异常: ' + traceback.format_exc(limit=1).replace('\n', ' ')
if not err:
bad = audit_xls(out_path, user_name) if total else 0
return total, bad, ''
last_err = err
config.log('%s -> 第%d次失败:%s' % (name, attempt, err))
time.sleep(1)
return None, 0, last_err
def run_export():
"""导出编排:逐方案导出 + 核对。返回 {summary, detail, path}。"""
"""导出编排:逐方案导出 + 核对(含索引刷新等待与异常行二次复核)。
单据刚提交时 OA 搜索索引的「当前环节/当前处理人」尚未刷新,立即导出会读成
「起草节点 + 发起人」,从而把刚提交的单据误判为异常。因此:
1) 导出前等待 EXPORT_SETTLE_WAIT 秒让索引落定;
2) 首次导出仍检出异常行时,等待 EXPORT_RECHECK_WAIT 秒重新导出复核,
以复核结果为准(同名 xls 与 *_核对.xlsx 覆盖更新)。
返回 {summary, detail, path}。
"""
day = config.get_export_date() or time.strftime('%Y-%m-%d')
out_dir = config.export_output_dir()
s = config.get_oa_session()
config.log('导出模式:创建时间=%s,方案 %d 个' % (day, len(config.SEARCH_PLANS)))
if config.EXPORT_SETTLE_WAIT > 0:
config.log('等待 %d 秒让 OA 搜索索引刷新(当前环节/当前处理人)后再导出'
% config.EXPORT_SETTLE_WAIT)
time.sleep(config.EXPORT_SETTLE_WAIT)
user_name, login_no = get_login_user(s)
if user_name:
config.log('登录账号:%s(%s),将核对当前处理人' % (user_name, login_no))
@@ -88,26 +120,27 @@ def run_export():
label = name.split('(')[0]
out_path = os.path.join(out_dir, '定性评价结果_%s_%s.xls'
% (label, day.replace('-', '')))
last_err = ''
for attempt in range(1, config.MAX_RETRY + 1):
try:
total, err = export_plan_once(s, sid, day, out_path)
except Exception:
total, err = None, '异常: ' + traceback.format_exc(limit=1).replace('\n', ' ')
if not err:
config.log('%s -> %d 条 -> %s' % (name, total, out_path))
bad = 0
if total:
bad = audit_xls(out_path, user_name)
detail[label] = {'total': total, 'path': out_path,
'audit': bad if total else 0}
break
last_err = err
config.log('%s -> 第%d次失败:%s' % (name, attempt, err))
time.sleep(1)
else:
fail.append((name, last_err))
detail[label] = {'success': False, 'error': last_err}
total, bad, err = export_and_audit(s, name, sid, day, out_path, user_name)
if err:
fail.append((name, err))
detail[label] = {'success': False, 'error': err}
config.progress(int(100 * (idx + 1) / len(config.SEARCH_PLANS)))
continue
config.log('%s -> %d 条 -> %s' % (name, total, out_path))
if bad > 0 and user_name and config.EXPORT_RECHECK_WAIT >= 0:
config.log('%s 检出 %d 行异常,等待 %d 秒后重新导出复核(首次多为索引延迟误判)'
% (name, bad, config.EXPORT_RECHECK_WAIT))
if config.EXPORT_RECHECK_WAIT > 0:
time.sleep(config.EXPORT_RECHECK_WAIT)
total2, bad2, err2 = export_and_audit(s, name, sid, day, out_path, user_name)
if err2:
config.log('%s 复核导出失败(沿用首次结果):%s' % (name, err2))
else:
config.log('%s 复核:%d 条,异常 %d 行(首次 %d 行)'
% (name, total2, max(bad2, 0), bad))
total, bad = total2, bad2
detail[label] = {'total': total, 'path': out_path,
'audit': bad if total else 0}
config.progress(int(100 * (idx + 1) / len(config.SEARCH_PLANS)))
config.progress(100)
config.log('==== 导出完成:成功 %d / 失败 %d ====' % (len(config.SEARCH_PLANS) - len(fail),