feat(雇主险): 新增钉钉群通知推送功能,版本更新至1.0.7

新增钉钉群通知配置项,支持推送调度汇总、HR导入结果及异常名单;
新增钉钉通知模块,推送失败不影响主流程;
调整雇主险调度描述,补充钉钉推送功能说明;
优化UI开关区布局,适配新增配置项显示;
同步更新相关文档,明确钉钉通知功能与口径。
This commit is contained in:
2026-09-30 15:59:37 +08:00
parent afa11d2821
commit 2e514d54d1
37 changed files with 1720 additions and 650 deletions
@@ -9,11 +9,14 @@
5) 再次重算公式(刷新变更清单/在参名单公式列缓存);
6) 生成增员/减员导入文件 + 导出变更清单独立工作簿(公式转值);
7) HR 自动导入(可选开关,默认开启):浏览器自动化把调度生成的导入文件导入
HR「待增减人员」(先全部减员再全部增员,仅导入本次调度成功的类别)。
HR「待增减人员」(先全部减员再全部增员,仅导入本次调度成功的类别);
8) 钉钉群通知(可选开关,默认开启):汇总 + 增/减员导入异常名单推送到钉钉群
(失败不影响主流程)。
运行上下文:底座注入 HR 会话与 userId(config 全局钩子),平台 = hr,uses_month = False。
字段(fields)由 plugin.json 权威定义:base_dir / ref_date / categories / roster_path /
enable_validation / wps_recalc / export_change_sheet / gen_import_files / import_to_hr。
enable_validation / wps_recalc / export_change_sheet / gen_import_files / import_to_hr /
dingtalk_notify。
"""
import os
@@ -22,7 +25,7 @@ from webhost.backend.plugins.base import ScenePlugin, PLUGINS
from . import config
from .logic import roster_filter, schedule, hr_import
from .logic.wps_recalc import recalc_target, ComRecalcError
from .report import output
from .report import notify, output
class EmployerInsurancePlugin(ScenePlugin):
@@ -30,10 +33,11 @@ class EmployerInsurancePlugin(ScenePlugin):
id = "xq0002"
name = "雇主险增减操作"
version = "1.0.4"
version = "1.0.7"
description = ("雇主险名额调度全流程:花名册导出→筛选复制→WPS/Excel 后台重算公式→"
"三阶段名额调度→更新在参名单与变更清单→生成增员/减员导入文件"
"(可选自动导入 HR 系统),替代人工 Ctrl+S 刷新公式与人工上传导入环节")
"(可选自动导入 HR 系统)→钉钉群推送汇总与导入异常名单,"
"替代人工 Ctrl+S 刷新公式与人工上传导入环节")
platform = "hr"
uses_month = False
capabilities = ["xq0002"]
@@ -62,6 +66,7 @@ class EmployerInsurancePlugin(ScenePlugin):
export_change_sheet = bool(fields.get("export_change_sheet", True))
gen_import_files = bool(fields.get("gen_import_files", True))
import_to_hr = bool(fields.get("import_to_hr", True))
dingtalk_notify = bool(fields.get("dingtalk_notify", True))
import_on = import_to_hr and gen_import_files
if import_to_hr and not gen_import_files:
ctx.log("已开启「自动导入HR系统」但「生成导入文件」未开启,本次无可导入文件,导入步骤将跳过", "WARN")
@@ -184,12 +189,10 @@ class EmployerInsurancePlugin(ScenePlugin):
"筛选复制成功": len(ok_categories),
"调度成功": len(scheduled),
}
import_lines = hr_import.summarize_results(import_results) \
if import_on and import_results else []
if import_on:
if import_results:
import_lines = hr_import.summarize_results(import_results)
import_text = ";".join(import_lines) if import_lines else "无导入结果"
else:
import_text = "未执行(登录态缺失或整体失败,详见注意事项与日志)"
import_text = ";".join(import_lines) if import_lines else "无导入结果"
tail = ("增/减员导入文件与变更清单独立工作簿已生成在各类别文件夹。"
f"HR 导入结果:{import_text}。")
else:
@@ -201,6 +204,16 @@ class EmployerInsurancePlugin(ScenePlugin):
filtered=len(ok_categories), scheduled=len(scheduled), tail=tail)
if notes:
summary += "\n注意事项:\n- " + "\n- ".join(notes)
# ---- 步骤8:钉钉群通知(汇总 + 导入异常名单;失败不影响主流程) ----
if dingtalk_notify:
notify.push_run_result(total=len(categories), filtered=len(ok_categories),
scheduled=len(scheduled), import_on=import_on,
import_lines=import_lines,
import_results=import_results, notes=notes)
else:
ctx.log("钉钉群通知已关闭,跳过推送", "INFO")
return {"summary": summary, "notes": notes, "detail": detail,
"path": base_dir, "date": config.today_date()}