feat(plugin): XQ0084 0.1.1 插件界面 + 核对通过自动导入 HR 工资卡并回写台账
- 新增 ui-src(Vue3+Element Plus,v3 规范)与构建产物 ui/,plugin.json 开启 ui - 接入 hr_sdk.wage_import:核对通过记录按身份证匹配导入工资卡,成功后回写「是否更新HR系统=是」 - 委托发放/缺开户银行记录跳过并注明原因,现金发放仍不导入;导入失败不中断出表与推送 - 工作簿新增 HR导入/说明列,推送正文补充导入统计;_pack 排除 ui-src 并校验 ui/index.html
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""XQ0084 流程编排:拉取待处理行 → 下载影像 → 识别 → 判定 → 输出/提醒。"""
|
||||
"""XQ0084 流程编排:拉取待处理行 → 下载影像 → 识别 → 判定 → 导入 HR → 回写/输出/提醒。"""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
@@ -11,9 +11,10 @@ from ..report.notify import send_markdown
|
||||
from ..report.workbook import write_workbook
|
||||
from .recognize import recognize
|
||||
from .verify import verify
|
||||
from .wage import import_passed
|
||||
|
||||
|
||||
def _push_text(rows, stats, path):
|
||||
def _push_text(rows, stats, path, hr=None):
|
||||
lines = [
|
||||
"### 银行卡变更影像核对(XQ0084)",
|
||||
f"- 待处理:**{stats['total']}** 条;通过 **{stats['passed']}**、"
|
||||
@@ -24,6 +25,9 @@ def _push_text(rows, stats, path):
|
||||
stats["trigger"][config.F_REG_DATE],
|
||||
),
|
||||
]
|
||||
if hr and hr.get("enabled"):
|
||||
lines.append(f"- HR 工资卡导入:成功 **{hr['imported']}**、失败 **{hr['failed']}**、"
|
||||
f"跳过 **{hr['skipped']}**;台账已回写 **{hr['written']}** 条")
|
||||
manual = [r for r in rows if r["conclusion"] == "需人工核实"]
|
||||
if manual:
|
||||
lines.append(f"#### 需人工核实({len(manual)})")
|
||||
@@ -31,12 +35,20 @@ def _push_text(rows, stats, path):
|
||||
lines.append(f"- {r['holder']}({r['emp_no']}):{r['notes'][:120]}")
|
||||
if len(manual) > 20:
|
||||
lines.append(f"- …… 其余 {len(manual) - 20} 条见结果文件")
|
||||
failed = [r for r in rows if r.get("hr_status") == "导入失败"]
|
||||
if failed:
|
||||
lines.append(f"#### HR 导入失败({len(failed)})")
|
||||
for r in failed[:10]:
|
||||
lines.append(f"- {r['holder']}({r['emp_no']}):{r.get('hr_note', '')[:120]}")
|
||||
if len(failed) > 10:
|
||||
lines.append(f"- …… 其余 {len(failed) - 10} 条见结果文件")
|
||||
lines.append(f"- 结果文件:{path}")
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def run_verify(save_dir, keep_files=config.DEFAULT_KEEP_FILES, push_webhook="",
|
||||
push_secret="", limit_rows=0, progress=None):
|
||||
push_secret="", limit_rows=0, write_hr=False, hr_session=None,
|
||||
progress=None):
|
||||
p = progress or (lambda _pct: None)
|
||||
stamp = time.strftime("%Y%m%d_%H%M%S")
|
||||
image_batch = os.path.join(save_dir, config.IMAGE_DIR_NAME, stamp)
|
||||
@@ -52,6 +64,7 @@ def run_verify(save_dir, keep_files=config.DEFAULT_KEEP_FILES, push_webhook="",
|
||||
config.logger.info("按配置仅处理前 %d 条", len(items))
|
||||
if not items:
|
||||
return {"path": "", "rows": [], "stats": _stats([], []),
|
||||
"hr": {"enabled": bool(write_hr)},
|
||||
"push": {"success": False, "message": "无待处理记录"},
|
||||
"cleaned": [], "batch_dir": image_batch}
|
||||
|
||||
@@ -78,19 +91,30 @@ def run_verify(save_dir, keep_files=config.DEFAULT_KEEP_FILES, push_webhook="",
|
||||
p(25 + int(65 * (i + 1) / len(items)))
|
||||
|
||||
stats = _stats(rows, items)
|
||||
|
||||
# 3) 闭环:核对通过 → 导入 HR 工资卡 → 回写 AI 表格(关闭时只核对出表)
|
||||
hr = {"enabled": bool(write_hr)}
|
||||
if write_hr:
|
||||
if not hr_session:
|
||||
raise RuntimeError("未获取到 HR 登录态,无法导入工资卡;请先在壳子登录 HR")
|
||||
p(88)
|
||||
hr = import_passed(rows, hr_session, progress=p)
|
||||
hr["enabled"] = True
|
||||
|
||||
path = write_workbook(rows, config.build_result_path(save_dir))
|
||||
p(94)
|
||||
p(98)
|
||||
|
||||
cleaned = config.cleanup_old_results(save_dir, keep_files, protect=path)
|
||||
config.cleanup_old_images(os.path.join(save_dir, config.IMAGE_DIR_NAME), keep_files,
|
||||
protect=image_batch)
|
||||
|
||||
abnormal = bool(stats["manual"] or any(r.get("hr_status") == "导入失败" for r in rows))
|
||||
push = {"success": False, "message": "无需推送(无异常)"}
|
||||
if stats["manual"] and push_webhook:
|
||||
if abnormal and push_webhook:
|
||||
push = send_markdown(push_webhook, push_secret, "银行卡变更影像核对异常",
|
||||
_push_text(rows, stats, path))
|
||||
_push_text(rows, stats, path, hr))
|
||||
p(100)
|
||||
return {"path": path, "rows": rows, "stats": stats, "push": push,
|
||||
return {"path": path, "rows": rows, "stats": stats, "hr": hr, "push": push,
|
||||
"cleaned": cleaned, "batch_dir": image_batch}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user