Files
37duAutomation/plugins/xq0010/logic/check3.py
T
puddy c73c113721 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

81 lines
3.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系统月考勤异常处理 插件 - 检查3「整日请假 × 残留考勤异常」(由影刀版移植)。
员工整日请假(leave_days>=1)当日,仍存在其他考勤异常(未调整/已确认)→ 提示。
「班段」列取排班接口的真实班段时间({date}_bc_time,如 "09:00 ~ 18:00"),
而非异常记录的发生时段(begin_time ~ end_time);排班取不到时回退异常时段。
数据来源:
- 请假:report 层传入的请假记录(build_leave_set 只保留整日请假);
- 排班:data.hr_api.fetch_all_shift(按工号缓存,取请假日班段)。
"""
from ..config import logger
from ..data.hr_api import fetch_all_shift
from .abnormal_utils import (
_get, _to_date_str, _staff_name, _leave_type_name, build_leave_set,
_extract_day_shift, _shift_segment,
)
# 输出列(对应需求文档检查3)
OUTPUT_COLUMNS = [
"员工姓名", "工号", "请假日期", "请假类型", "请假天数", "异常类型", "班段",
"异常状态", "提示",
]
def run_check3(abnormal_confirmed, abnormal_open, leaves,
session, user_id, treecode, begin, end):
"""检查3:整日请假当日仍残留考勤异常 → 返回命中行列表。
Args:
abnormal_confirmed: 已确认异常(is_adjusted=2)记录列表。
abnormal_open: 未调整异常(is_adjusted=0)记录列表。
leaves: 全部请假记录(仅已备案的整日假参与索引)。
session / user_id / treecode: 底座注入的 HR 会话与用户信息。
begin / end: 排班查询月份范围 "YYYY-MM-DD"。
Returns:
命中行列表(每行为 OUTPUT_COLUMNS 对应字段的 dict)。
"""
rows = []
# 整日请假日期索引 {(code, date): leave_rec}
full_day_leave = build_leave_set(leaves, need_full_day=True)
if not full_day_leave:
logger.info("无整日请假记录,检查3跳过")
return rows
# 按工号缓存排班记录,避免重复请求
shift_cache = {}
# 异常并集(同一员工同一日期可能同时有未调整/已确认,各自输出一条便于核查)
for ab in list(abnormal_open) + list(abnormal_confirmed):
code = str(_get(ab, "base_code")).strip()
work_day = _to_date_str(_get(ab, "work_day"))
if not code or not work_day:
continue
leave_rec = full_day_leave.get((code, work_day))
if not leave_rec:
continue
# 拉取该员工排班(缓存),取请假日的真实排班班段时间
if code not in shift_cache:
shift_cache[code] = fetch_all_shift(session, user_id, code, begin, end, treecode)
shift_time = _extract_day_shift(shift_cache.get(code, []), work_day)["bc_time"]
is_adjusted = str(ab.get("is_adjusted", ""))
status = "确认异常" if is_adjusted == "2" else ("未调整" if is_adjusted == "0" else "异常")
hint = f"该员工{work_day}考勤状态存在异常"
rows.append({
"员工姓名": _staff_name(ab),
"工号": code,
"请假日期": work_day,
"请假类型": _leave_type_name(leave_rec),
"请假天数": _get(leave_rec, "leave_days"),
"异常类型": _get(ab, "abnormal"),
"班段": shift_time or _shift_segment(ab),
"异常状态": status,
"提示": hint,
})
return rows