Files
37duAutomation/plugins/xq0010/__init__.py
T
puddy 843ff244a6 feat: 新增多插件 UI 支持及运行日志集中回传功能
本次提交包含多项功能更新:
1. 为多个插件(xq0002/0003/0004/0008/0010/0011/0020/0031_xq0032/0033/0035/0037/0045_xq0046/0047/0048)新增 UI 界面及配置支持
2. 新增运行日志集中回传功能,客户端自动上传运行日志到中心机集中存储
3. 新增插件分类字段支持,用于场景库分组管理
4. 优化 xq0034/0037/0048 等插件的功能及描述
5. 修复控制面响应兼容问题,支持新旧版本数据格式
6. 新增 xq0033 插件的状态存储模块,用于历史记录管理
7. 优化 CRM 登录窗口模式,支持全屏置顶
2026-10-26 15:42:50 +08:00

98 lines
4.4 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 -*-
"""XQ0010 EHR系统月考勤异常处理 插件入口。
流程编排(由影刀版 attendance_abnormal_monthly.py 移植,登录态改由底座注入):
1) 会话准备:底座注入 HR session/userId → getCurUserInfo 校验(失效抛错提示重新登录);
2) 拉取基础数据:考勤异常(已确认 is_adjusted=2 / 未调整 is_adjusted=0)、全部请假、
休息日加班(类型=3,仅保留已备案 BPM_STATUS=002);
3) 保存过程数据 JSON(与报告同目录,追溯复核);
4) 依次执行检查1/2/3(检查2 休息日半天加班×打卡校验 / 检查3 整日请假×残留异常,
内部按工号实时拉取打卡/排班);
5) 多 Sheet Excel 输出(汇总 + 检查1/2/3,无数据保留表头)。
运行上下文:底座注入 HR 会话与 userId(config 全局钩子),platform = hr,uses_month = True
(前端页眉月份选择器经 payload.ref_month 注入)。
"""
from webhost.backend.plugins.base import ScenePlugin, PLUGINS
from . import config
from .data import hr_api
from .report.abnormal_report import (
collect_data, save_process_data, run_all_checks, write_workbook,
resolve_month, month_begin_end,
)
class AttendanceAbnormalMonthlyPlugin(ScenePlugin):
"""EHR系统月考勤异常处理(需求 XQ0010)。"""
id = "xq0010"
name = "EHR系统月考勤异常处理"
version = "1.1.0"
description = ("对上月考勤异常做三重复核:检查1 已确认异常日期是否存在请假流程(提前确认后请假);"
"检查2 休息日半天加班当日打卡是否按考勤班段正常打卡;"
"检查3 整日请假当日是否残留考勤异常。"
"结合考勤异常/请假/加班/打卡/排班五类 HR 接口,输出多 Sheet Excel 报告。")
platform = "hr"
uses_month = True
capabilities = ["xq0010"]
permissions = {"platforms": ["hr"]}
fields = {
"ref_month": {
"type": "string", "title": "执行月份", "default": "",
"description": "留空=上月;格式 YYYY-MM",
},
"save_dir": {
"type": "string", "title": "输出目录",
"default": r"D:\资料\人资\考勤异常",
"description": "多 Sheet 报告与过程数据 JSON 统一输出目录",
},
}
def run(self, fields: dict, ctx):
# ---- 注入运行上下文:日志 / HR 会话 / userId ----
config.set_log(ctx.log)
config.set_session(ctx.get_session("hr"))
config.set_user_id(ctx.get_user_id("hr"))
month = resolve_month(fields.get("ref_month") or fields.get("month") or "")
save_dir = (fields.get("save_dir") or "").strip() or config.DEFAULT_SAVE_DIR
session = config.require_session()
user_id = config.require_user_id()
ctx.log(f"===== 月考勤异常三查启动:月份 {month},输出目录 {save_dir} =====", "INFO")
# ---- 步骤1:会话校验(5%) ----
ctx.progress(5)
session, user_id, treecode = hr_api.validate_session(session, user_id)
ctx.progress(8)
# ---- 步骤2:拉取基础数据(8% ~ 45%) ----
begin, end = month_begin_end(month)
data = collect_data(session, user_id, treecode, begin, end)
ctx.progress(45)
# ---- 步骤3:保存过程数据(45% ~ 50%) ----
process_path = save_process_data(data, save_dir, month)
ctx.progress(50)
# ---- 步骤4:依次执行检查1/2/3(50% ~ 95%) ----
results = run_all_checks(session, user_id, treecode, data, begin, end)
ctx.progress(95)
# ---- 步骤5:多 Sheet 导出(95% ~ 100%) ----
save_path = write_workbook(results, save_dir, month)
ctx.progress(100)
detail = {key: len(rows) for key, rows in results.items()}
total = sum(detail.values())
summary = ("月考勤异常三查完成({ym}),检查1={c1} 条、检查2={c2} 条、检查3={c3} 条。"
"报告:{path};过程数据:{proc}").format(
ym=month, c1=detail.get("check1", 0), c2=detail.get("check2", 0),
c3=detail.get("check3", 0), path=save_path, proc=process_path)
return {"summary": summary, "detail": detail,
"path": save_path, "process_path": process_path, "ym": month}
PLUGINS.append(AttendanceAbnormalMonthlyPlugin())