feat: 新增银行卡检查插件及相关依赖与配置文件
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""XQ0005 银行卡检查 插件入口(由影刀版 workflows/XQ0001-0100/XQ0005 银行卡检查 移植)。
|
||||
|
||||
流程编排:
|
||||
1) 登录态预检:底座注入 HR session → 拉一条工资卡数据验证(失效提示重新登录);
|
||||
2) 在职 + 离职工资卡全量拉取(离职按「每月8号前后」自动范围,可用字段手动覆盖);
|
||||
3) 剔除姓名含 虚拟/人资/测试 的记录 → 逐行核对(银行卡 BIN + 开户人姓名/身份证 + 现金发放);
|
||||
4) 输出单工作簿三 sheet(工资卡异常名单 / 完整核对结果 / 原始数据);
|
||||
5) 配置了钉钉群机器人 Webhook 时推送核对摘要(文本,附件留在本机输出目录)。
|
||||
|
||||
运行上下文:底座注入 HR 会话(config 全局钩子),platform = hr;不使用月份(uses_month = False)。
|
||||
校验规则见 docs/银行卡检查/需求文档.md。
|
||||
"""
|
||||
from webhost.backend.plugins.base import ScenePlugin, PLUGINS
|
||||
|
||||
from . import config
|
||||
from .report.bank_card_report import run_bank_card_check
|
||||
|
||||
|
||||
class BankCardCheckPlugin(ScenePlugin):
|
||||
"""银行卡检查(需求 XQ0005)。"""
|
||||
|
||||
id = "xq0005"
|
||||
name = "银行卡检查"
|
||||
version = "1.0.0"
|
||||
description = ("下载在职 + 离职工资卡数据,按 BIN 规则核对银行卡号并比对员工与开户人姓名/身份证,"
|
||||
"输出单工作簿三 sheet(异常名单 / 完整核对结果 / 原始数据),可选推送摘要到钉钉群。")
|
||||
platform = "hr"
|
||||
uses_month = False
|
||||
capabilities = ["xq0005"]
|
||||
permissions = {"platforms": ["hr"]}
|
||||
fields = {
|
||||
"save_dir": {
|
||||
"type": "string", "title": "输出目录",
|
||||
"default": r"D:\资料\人资\银行卡检查",
|
||||
"description": "结果工作簿(工资卡核对结果.xlsx)输出目录",
|
||||
},
|
||||
"leave_start": {
|
||||
"type": "string", "title": "离职日期起", "default": "",
|
||||
"description": "留空=自动(8号及以前:上月1日~今天;8号之后:本月1日~今天)",
|
||||
},
|
||||
"leave_end": {
|
||||
"type": "string", "title": "离职日期止", "default": "",
|
||||
"description": "留空=今天;与「离职日期起」成对填写才生效",
|
||||
},
|
||||
"push_webhook": {
|
||||
"type": "string", "title": "钉钉群机器人 Webhook", "default": "",
|
||||
"description": "留空=只导出不推送;填写后推送核对摘要文本(不支持发附件)",
|
||||
},
|
||||
"push_secret": {
|
||||
"type": "string", "title": "钉钉机器人加签密钥", "format": "password", "default": "",
|
||||
"description": "机器人安全设置为「加签」时填写,未配置加签留空",
|
||||
},
|
||||
}
|
||||
|
||||
def run(self, fields: dict, ctx):
|
||||
# ---- 注入运行上下文:日志 / HR 会话 ----
|
||||
config.set_log(ctx.log)
|
||||
config.set_session(ctx.get_session("hr"))
|
||||
ctx.progress(2)
|
||||
|
||||
save_dir = (fields.get("save_dir") or "").strip() or config.DEFAULT_SAVE_DIR
|
||||
leave_start = (fields.get("leave_start") or "").strip()
|
||||
leave_end = (fields.get("leave_end") or "").strip()
|
||||
push_webhook = (fields.get("push_webhook") or "").strip()
|
||||
push_secret = fields.get("push_secret") or ""
|
||||
|
||||
ctx.log(f"===== 银行卡检查启动:输出目录 {save_dir} =====", "INFO")
|
||||
|
||||
result = run_bank_card_check(
|
||||
save_dir=save_dir,
|
||||
leave_start=leave_start,
|
||||
leave_end=leave_end,
|
||||
push_webhook=push_webhook,
|
||||
push_secret=push_secret,
|
||||
progress=ctx.progress,
|
||||
)
|
||||
|
||||
stats = result["stats"]
|
||||
summary = ("银行卡检查完成:通过 {passed} / 总计 {total},工资卡异常 {abnormal} 人"
|
||||
"(含无工资卡 {no_bank} 人),代发 {daifa} 人。文件:{path}").format(
|
||||
path=result["path"], **stats)
|
||||
|
||||
return {
|
||||
"summary": summary,
|
||||
"detail": {
|
||||
"核对总数": stats["total"],
|
||||
"通过": stats["passed"],
|
||||
"工资卡异常": stats["abnormal"],
|
||||
"无工资卡": stats["no_bank"],
|
||||
"代发": stats["daifa"],
|
||||
"剔除虚拟测试": result["excluded"],
|
||||
"离职筛选范围": f"{result['leave_range'][0]} ~ {result['leave_range'][1]}",
|
||||
"推送": "成功" if result["push"].get("success") else result["push"].get("message", ""),
|
||||
},
|
||||
"path": result["path"],
|
||||
}
|
||||
|
||||
|
||||
PLUGINS.append(BankCardCheckPlugin())
|
||||
Reference in New Issue
Block a user