Files
37duAutomation/plugins/XQ0001-0100/XQ0083 调动流程生效确认/__init__.py
T
puddy 4941e8b6c0 feat(plugin): 新增 XQ0006 周考勤异常处理、XQ0083 调动流程生效确认;其余插件累积改动
XQ0001 排班异常识别 / XQ0002 雇主险增减操作 / XQ0012 ERP 付款申请 / XQ0013 社保费用申报 / XQ0042 抖音平台核对 / XQ0084 银行卡更新:逻辑与界面 bundle 更新(含各自版本号变更)
2026-11-18 18:55:59 +08:00

141 lines
6.9 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
"""XQ0083 调动流程生效确认 插件入口。
流程编排:
1) 登录态预检(底座注入 HR session,失效提示重新登录);
2) 拉取调动台账待处理记录(员工管理-事务管理-调动管理,未生效 + 在用 + 主职);
3) 来源=流程的记录,只有流程状态=已完成(002)才处理;申请中/已取消静默跳过;
4) 其余记录逐条校验 R1/R2/R4/R5,再按员工统计当月已生效次数执行 R3;
5) 全部通过 → 确认前预检(IfExist)→ 批量确认 → 回查 EXC_STATUS 校验生效;
6) 输出 Excel(异常名单插入人工处理提示),可选推送钉钉群机器人摘要。
定时执行由外部调度平台触发,本插件不内置定时器。
"""
from webhost.backend.plugins.base import PLUGINS, ScenePlugin
from . import config
from .report.move_confirm_report import run_confirm
_FIELDS = {
"save_dir": {
"type": "string", "title": "输出目录",
"default": config.DEFAULT_SAVE_DIR,
"description": "结果工作簿输出目录;文件名 调动流程生效确认结果_YYYYMMDD_HHMMSS.xlsx,"
"每次运行独立留档不覆盖",
},
"keep_files": {
"type": "integer", "title": "结果留档份数", "default": config.DEFAULT_KEEP_FILES,
"description": "输出目录最多保留最近 N 份结果工作簿(含本次);0 = 不清理",
},
"dry_run": {
"type": "boolean", "title": "试算模式", "default": False,
"description": "开启后只校验不写入:不向 HR 提交批量确认,输出表逐条给出校验结论与原因",
},
"push_webhook": {
"type": "string", "title": "钉钉群机器人 Webhook", "default": "",
"description": "留空=只导出不推送;填写后推送处理摘要与异常名单(文本,结果文件在本机输出目录)",
},
"push_secret": {
"type": "string", "title": "钉钉机器人加签密钥", "format": "password", "default": "",
"description": "机器人安全设置为「加签」时填写,未配置加签留空",
},
"tech_sequence": {
"type": "string", "title": "技师职位序列名称", "default": config.TECH_SEQUENCE_NAME,
"description": "该职位序列要求现技师工号必须有值;按名称与字典匹配",
},
"brand_units": {
"type": "string", "title": "品牌单位关键字",
"default": "水庄,秒创,裕见阳光,声艺大咖,束合",
"description": "现所属单位含任一关键字时,现岗位须含同一关键字;逗号分隔",
},
"skip_unit_keywords": {
"type": "string", "title": "免校验岗位的单位关键字",
"default": "金色印象,金色湖畔,集团",
"description": "现所属单位含任一关键字时不校验现岗位字样;逗号分隔",
},
"max_moves_per_month": {
"type": "integer", "title": "每月可生效调动次数", "default": config.MAX_MOVES_PER_MONTH,
"description": "员工当月已生效调动次数达到该值后,后续调动无法直接生效,转异常名单走"
"「确认(调动超2次)」",
},
"early_month_day": {
"type": "integer", "title": "早于当月校验起始日", "default": config.EARLY_MONTH_CHECK_DAY,
"description": "每月从几号起校验「调动生效日期早于当前自然月」;默认 3 = 3 号起校验,2 号当天不校验",
},
"future_days": {
"type": "integer", "title": "未来日期容差(天)", "default": config.FUTURE_DAYS,
"description": "调动生效日期超过今天 + N 天报异常",
},
"limit_rows": {
"type": "integer", "title": "限制处理条数", "default": 0,
"description": "0 = 全部处理;大于 0 时仅处理按生效日期倒序的前 N 条(用于小范围试跑)",
},
}
def _as_bool(value):
if isinstance(value, bool):
return value
return str(value or "").strip().lower() in ("1", "true", "yes", "on", "y", "是")
class MoveConfirmPlugin(ScenePlugin):
"""调动流程生效确认(需求 XQ0083)。"""
id = "xq0083"
name = "调动流程生效确认"
version = "1.0.5"
description = ("定时校验调动管理页面的待生效记录(来源=流程的须流程已完成,申请中/已取消跳过),"
"按技师工号、品牌单位与岗位匹配、当月调动超 2 次、生效日期早于当月 / 超过今天+5 天"
"等规则筛选,通过的批量确认生效,异常的整理名单输出 Excel 并推送钉钉群。")
platform = "hr"
uses_month = False
capabilities = ["xq0083"]
permissions = {"platforms": ["hr"]}
fields = _FIELDS
def run(self, fields: dict, ctx):
# ---- 注入运行上下文:日志 / HR 会话 / 当前登录用户ID ----
config.set_log(ctx.log)
config.set_session(ctx.get_session("hr"))
config.set_user_id(ctx.get_user_id("hr"))
config.apply_fields(fields)
ctx.progress(2)
save_dir = (fields.get("save_dir") or "").strip() or config.DEFAULT_SAVE_DIR
keep_files = config.normalize_keep(fields.get("keep_files"))
dry_run = _as_bool(fields.get("dry_run"))
mode = "试算(只校验不确认)" if dry_run else "校验并确认"
ctx.log(f"===== 调动流程生效确认启动:{mode},输出目录 {save_dir}(留档 {keep_files} 份)=====",
"INFO")
result = run_confirm(
save_dir=save_dir,
push_webhook=(fields.get("push_webhook") or "").strip(),
push_secret=fields.get("push_secret") or "",
dry_run=dry_run,
progress=ctx.progress,
keep_files=keep_files,
)
summary = ("调动流程生效确认{done}:待处理 {total} 条,跳过(流程未完成/已取消){skipped} 条,"
"提交确认 {submitted} 条(生效 {confirmed} 条),异常 {abnormal} 条。文件:{path}").format(
done="试算完成(未提交确认)" if dry_run else "完成",
total=result["total"], skipped=result["skipped"], submitted=result["submitted"],
confirmed=result["confirmed"], abnormal=result["abnormal"], path=result["path"])
detail = {
"待处理记录": result["total"],
"跳过(流程未完成/已取消)": result["skipped"],
"提交确认": result["submitted"],
"确认生效": result["confirmed"],
"异常": result["abnormal"],
"仅校验未提交": result["pending"],
"清理历史留档": len(result.get("cleaned") or []),
"推送": "成功" if result["push"].get("success") else result["push"].get("message", ""),
}
return {"summary": summary, "detail": detail, "path": result["path"]}
PLUGINS.append(MoveConfirmPlugin())