110 lines
5.2 KiB
Python
110 lines
5.2 KiB
Python
# -*- 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.2.0"
|
|
description = ("下载在职 + 离职工资卡数据,按 BIN 规则核对银行卡号并比对员工与开户人姓名/身份证,"
|
|
"输出单工作簿三 sheet(异常名单 / 完整核对结果 / 原始数据),文件名带时间戳留档、"
|
|
"按留档份数自动清理旧文件,可选推送摘要到钉钉群。")
|
|
platform = "hr"
|
|
uses_month = False
|
|
capabilities = ["xq0005"]
|
|
permissions = {"platforms": ["hr"]}
|
|
fields = {
|
|
"save_dir": {
|
|
"type": "string", "title": "输出目录",
|
|
"default": r"D:\资料\人资\银行卡检查",
|
|
"description": "结果工作簿输出目录;文件名 工资卡核对结果_YYYYMMDD_HHMMSS.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": "机器人安全设置为「加签」时填写,未配置加签留空",
|
|
},
|
|
"keep_files": {
|
|
"type": "integer", "title": "结果留档份数", "default": 30,
|
|
"description": "输出目录最多保留最近 N 份结果工作簿(含本次);0 = 不清理,全部保留",
|
|
},
|
|
}
|
|
|
|
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 ""
|
|
keep_files = config.normalize_keep(fields.get("keep_files"))
|
|
|
|
ctx.log(f"===== 银行卡检查启动:输出目录 {save_dir}(留档 {keep_files} 份,0=不清理)=====",
|
|
"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,
|
|
keep_files=keep_files,
|
|
)
|
|
|
|
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]}",
|
|
"清理历史留档": result["cleaned"],
|
|
"推送": "成功" if result["push"].get("success") else result["push"].get("message", ""),
|
|
},
|
|
"path": result["path"],
|
|
}
|
|
|
|
|
|
PLUGINS.append(BankCardCheckPlugin())
|