feat(hrbp): 完成HRBP加班审批系统全链路开发
新增: 1. 新增依赖包chinese_calendar,完善.gitignore会话存储配置 2. 新增完整测试套件与项目初始化文件 3. 实现延时/休息日/法定假日加班审批规则(参考aa.md文档) 4. 新增排班、打卡、请假数据获取与解析工具 5. 完善会话管理与持久化存储逻辑 6. 实现格式化审批报告生成功能 修改: 1. 调整请假校验函数签名以传入会话对象 2. 更新审批流程调用逻辑适配新校验函数 3. 重构cookie存储路径与目录创建逻辑 4. 优化日志输出级别与调试信息
This commit is contained in:
@@ -4,18 +4,46 @@
|
||||
@FileName: reporter.py
|
||||
@Author: 小布丁
|
||||
@CreateTime: 2026-08-05 21:35
|
||||
@Description: 加班流程报告模块,生成审批报告
|
||||
@Version: 1.0.0
|
||||
@Description: 加班流程报告模块,生成审批报告(详细数据版,供自测阶段人工复核)
|
||||
@Version: 1.3.0
|
||||
"""
|
||||
|
||||
from typing import Any, Dict, List
|
||||
|
||||
|
||||
def _format_detail(idx: int, r: Dict[str, Any]) -> str:
|
||||
"""
|
||||
格式化单条记录的详细信息:展示全部解析数据,最后是判断结果。
|
||||
所有键值对左对齐,方便人工逐项核对。
|
||||
"""
|
||||
info = r.get("overtime_info", {}) or {}
|
||||
|
||||
# 收集全部要展示的键值对:先数据,后判断结果
|
||||
items: List[tuple] = list(info.items())
|
||||
items.append(("审批结果", r.get("decision", "")))
|
||||
if r.get("note"):
|
||||
items.append(("说明", r.get("note", "")))
|
||||
if r.get("error"):
|
||||
items.append(("错误", r.get("error", "")))
|
||||
|
||||
max_key = max((len(k) for k, _ in items), default=0)
|
||||
|
||||
lines = [
|
||||
f"#{idx} 申请人: {r.get('creator', '')} | {r.get('title', '')}",
|
||||
"-" * 60,
|
||||
]
|
||||
for key, value in items:
|
||||
lines.append(f" {key:<{max_key}} : {value}")
|
||||
lines.append("-" * 60)
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def generate_report(results: List[Dict[str, Any]]) -> str:
|
||||
"""
|
||||
根据校验结果生成加班审批报告。
|
||||
根据校验结果生成加班审批报告(详细数据版)。
|
||||
|
||||
TODO: 按实际报告格式完善(与请假报告不同,含加班时长等字段)。
|
||||
每条记录展示全部解析数据(人员、日期、起止时间、时长、排班、打卡、
|
||||
申报天数、计算结果等),最后是审批结果和说明,供自测阶段人工复核。
|
||||
|
||||
Args:
|
||||
results: validate_doc 返回的校验结果列表
|
||||
@@ -23,7 +51,32 @@ def generate_report(results: List[Dict[str, Any]]) -> str:
|
||||
Returns:
|
||||
报告文本
|
||||
"""
|
||||
lines = ["加班审批报告", "=" * 30]
|
||||
for r in results:
|
||||
lines.append(f"{r.get('creator', '')} | {r.get('title', '')} | {r.get('decision', '')}")
|
||||
return "\n".join(lines)
|
||||
passed = [r for r in results if r.get("decision") == "通过"]
|
||||
rejected = [r for r in results if r.get("decision") == "不通过"]
|
||||
failed = [r for r in results if r.get("decision") == "失败"]
|
||||
|
||||
lines = [
|
||||
"加班审批报告",
|
||||
"=" * 60,
|
||||
f"共 {len(results)} 单:通过 {len(passed)},不通过 {len(rejected)},处理失败 {len(failed)}",
|
||||
"",
|
||||
]
|
||||
|
||||
if rejected:
|
||||
lines.append("【审批未通过名单】")
|
||||
for i, r in enumerate(rejected, 1):
|
||||
lines.append(_format_detail(i, r))
|
||||
lines.append("")
|
||||
|
||||
if passed:
|
||||
lines.append("【审批通过名单】")
|
||||
for i, r in enumerate(passed, 1):
|
||||
lines.append(_format_detail(i, r))
|
||||
lines.append("")
|
||||
|
||||
if failed:
|
||||
lines.append("【处理失败】")
|
||||
for i, r in enumerate(failed, 1):
|
||||
lines.append(_format_detail(i, r))
|
||||
|
||||
return "\n".join(lines)
|
||||
Reference in New Issue
Block a user