docs: 更新 AGENTS/README 平台架构说明与月度总结,运行日志视图支持已取消状态

This commit is contained in:
2026-10-31 17:55:25 +08:00
parent e1b4097573
commit b976b80d9d
201 changed files with 11049 additions and 7398 deletions
@@ -1,97 +1,97 @@
# -*- 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())
# -*- 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.2"
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())
@@ -7,7 +7,7 @@ zip 根含 plugin.json,可被 agent_cli publish 直接发布。详见 docs/插
用法(任意 cwd 均可):
d:\\work\\code\\37duAutomation\\.venv\\Scripts\\python.exe "plugins\\XQ0001-0100\\XQ0010 EHR系统月考勤异常处理\\_pack.py"
随后发布:
.venv\\Scripts\\python.exe -m controlplane.tools.agent_cli publish \
.venv\\Scripts\\python.exe tools\\agent_cli.py publish \
dist-plugin\\xq0010_v<版本>.zip --id xq0010 --version <版本>
"""
import json
@@ -2,16 +2,20 @@
"schema_version": 1,
"id": "xq0010",
"name": "EHR系统月考勤异常处理",
"version": "1.1.1",
"version": "1.1.2",
"description": "对上月考勤异常做三重复核:检查1 已确认异常日期是否存在请假流程(提前确认后请假);检查2 休息日半天加班当日打卡是否按考勤班段正常打卡;检查3 整日请假当日是否残留考勤异常。结合考勤异常/请假/加班/打卡/排班五类 HR 接口,输出多 Sheet Excel 报告(含过程数据 JSON 追溯)。",
"category": "人事考勤",
"icon": "",
"platform": "hr",
"uses_month": true,
"ui": true,
"capabilities": ["xq0010"],
"capabilities": [
"xq0010"
],
"permissions": {
"platforms": ["hr"]
"platforms": [
"hr"
]
},
"fields": {
"type": "object",
@@ -293,7 +293,8 @@ export function usePluginUI(opts = {}) {
ws = connectWS((ev) => {
if (ev.run_id && ev.run_id !== runId) return // 只看本次运行
if (ev.t === 'progress') progress.value = Math.max(progress.value, ev.pct || 0)
else if (ev.t === 'run_done') ev.ok ? finished() : failed(ev.error || '执行失败')
// 用户强制停止 / 排队取消 / 排队超时 → 「已取消」,不显示成「执行失败」
else if (ev.t === 'run_done') ev.ok ? finished() : (ev.status === 'cancelled' ? cancelled(ev.error) : failed(ev.error || '执行失败'))
})
ws.onclose = () => { ws = null }
}
@@ -305,6 +306,7 @@ export function usePluginUI(opts = {}) {
try {
const r = await getRun(runId)
if (r.status === 'done') finished(r.result?.summary || '执行完成')
else if (r.status === 'cancelled') cancelled(r.error)
else if (r.status === 'error') failed(r.error || '执行失败')
} catch (_) { /* 下轮再试 */ }
}, 5000)
@@ -321,6 +323,13 @@ export function usePluginUI(opts = {}) {
banner.value = { type: 'success', text: summary || '执行完成' }
}
// 用户主动停止 / 排队取消 / 排队超时:不算失败,给中性的「已取消」提示
function cancelled(err) {
stopPolling()
running.value = false
banner.value = { type: 'warning', text: '任务已取消:' + (err || '用户已停止') }
}
function failed(err) {
stopPolling()
running.value = false
@@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>EHR系统月考勤异常处理</title>
<script type="module" crossorigin src="/pui/xq0010/assets/index-B-_Qk0-P.js"></script>
<script type="module" crossorigin src="/pui/xq0010/assets/index-BeZ032rr.js"></script>
<link rel="stylesheet" crossorigin href="/pui/xq0010/assets/index-ZKovqcSp.css">
</head>
<body>