feat: 新增续签电子签插件及多插件钉钉通知功能
- 新增 xq0034 续签电子签插件,包含核心流程与钉钉通知能力 - 为 xq0035、xq0008、xq0009、xq0010、xq0011、xq0031_xq0032、xq0037、xq0038、xq0045_xq0046 插件添加钉钉群通知配置 - 优化续签电子签执行结果日志,减少重复名单输出 - 桌面端插件列表新增分页功能,优化长列表展示
This commit is contained in:
@@ -17,6 +17,7 @@ from webhost.backend.plugins.base import PLUGINS, ScenePlugin
|
||||
|
||||
from . import config
|
||||
from .data import renewal_esign
|
||||
from .data import dingtalk_robot
|
||||
|
||||
|
||||
class _LogWriter:
|
||||
@@ -47,7 +48,7 @@ class _LogWriter:
|
||||
class Xq0034Plugin(ScenePlugin):
|
||||
id = "xq0034"
|
||||
name = "续签电子签"
|
||||
version = "1.0.0"
|
||||
version = "1.0.6"
|
||||
description = ("XQ0034 续签电子签:AI表格【续签名单到期跟进-月更新】驱动——否续签回填、"
|
||||
"是续签手机号校验后 HR 生效中合同属性页「续签合同」提交推送电子签并回填,"
|
||||
"HR 会话由壳子注入")
|
||||
@@ -58,11 +59,31 @@ class Xq0034Plugin(ScenePlugin):
|
||||
# 与 plugin.json.fields 一致(ui=true 前端自渲染,此处分层作为参数契约文档)
|
||||
fields = {
|
||||
"dry_run": {"type": "boolean", "title": "试算模式", "default": False},
|
||||
"notify_dingtalk": {"type": "boolean", "title": "钉钉群通知", "default": True},
|
||||
"dingtalk_env": {"type": "string", "title": "通知对象", "default": config.DINGTALK_ENV,
|
||||
"enum": ["prod", "dev"]},
|
||||
}
|
||||
|
||||
def _notify_dingtalk(self, texts, status="info", env=""):
|
||||
"""钉钉群机器人逐条推送;失败只记 WARN,不影响主流程。env 缺省取 config.DINGTALK_ENV。"""
|
||||
try:
|
||||
ret = dingtalk_robot.main(texts, title="续签电子签", status=status,
|
||||
env=(env or config.DINGTALK_ENV).strip().lower())
|
||||
if ret.get("success"):
|
||||
config.log("钉钉群通知已推送", "INFO")
|
||||
else:
|
||||
config.log(f"钉钉群通知推送失败:{ret.get('message', '')}", "WARN")
|
||||
except Exception as e:
|
||||
config.log(f"钉钉群通知推送失败(不影响主流程):{e}", "WARN")
|
||||
|
||||
def run(self, fields, ctx) -> dict:
|
||||
fields = fields or {}
|
||||
dry_run = bool(fields.get("dry_run"))
|
||||
notify_on = fields.get("notify_dingtalk")
|
||||
notify_on = True if notify_on is None else bool(notify_on)
|
||||
dingtalk_env = str(fields.get("dingtalk_env") or config.DINGTALK_ENV).strip().lower()
|
||||
if dingtalk_env not in ("prod", "dev"):
|
||||
dingtalk_env = config.DINGTALK_ENV
|
||||
|
||||
# ---------- 注入钩子(日志/会话)+ print 改道 ----------
|
||||
config.set_log(ctx.log)
|
||||
@@ -81,8 +102,17 @@ class Xq0034Plugin(ScenePlugin):
|
||||
message = str(ret.get("message") or "完成")
|
||||
results = ret.get("results") or []
|
||||
if not ret.get("success"):
|
||||
# 业务层捕获后的失败(含登录态失效):置为运行失败,便于前端横幅与排查
|
||||
# 业务层捕获后的失败(含登录态失效):先推钉钉失败通知,再置为运行失败
|
||||
if notify_on:
|
||||
self._notify_dingtalk([f"❌ 续签电子签执行失败:{message}"],
|
||||
status="error", env=dingtalk_env)
|
||||
raise RuntimeError(message)
|
||||
if notify_on:
|
||||
msgs = ret.get("messages")
|
||||
if isinstance(msgs, list) and msgs:
|
||||
self._notify_dingtalk(msgs, status="success", env=dingtalk_env)
|
||||
else:
|
||||
self._notify_dingtalk([message], status="success", env=dingtalk_env)
|
||||
ctx.log(f"=== XQ0034 续签电子签 结束:{message} ===")
|
||||
ctx.progress(100)
|
||||
notes = []
|
||||
|
||||
Reference in New Issue
Block a user