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
@@ -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),