refactor: 重构HRBP公共层与业务模块,整理废弃资源

1.  迁移并统一HR会话、配置、API等公共能力至hrbp/common层,实现ehr/oa模块复用
2.  删除captcha_debug调试用图片资源与旧session_manager文件
3.  重构考勤异常处理模块,补充分级逻辑与导出优化
4.  新增OA/HR多套API封装模块与配套文档
5.  移除旧通用接口规划文档,补充完整需求与开发文档
This commit is contained in:
2026-08-14 15:48:15 +08:00
parent 3a8571d995
commit 831845f970
57 changed files with 4276 additions and 1905 deletions
@@ -0,0 +1,100 @@
# -*- coding: utf-8 -*-
"""
@Module: hrbp.oa.common.oa_api
@FileName: attendance.py
@Description: 排班 HTML 与考勤打卡明细接口。
@Version: 1.0.0
"""
from typing import List, Dict, Any
from app.utils.logger import get_logger
try:
from DrissionPage import SessionPage
except ImportError:
SessionPage = None
from app.service.hrbp.oa.common.config import PAIBAN_URL, KQ_DATA_URL
from app.service.hrbp.oa.common.oa_api.base import oa_request_json
logger = get_logger(__name__)
def get_attendance_html(
session: SessionPage,
staff_id: str,
year: int,
month: int
) -> str:
"""
获取指定员工某月的排班 HTML。
Args:
session: 已登录的 SessionPage 对象
staff_id: 员工 UUID
year: 年份(如 2026)
month: 月份(1-12)
Returns:
排班表格的 HTML 字符串(从返回 JSON 的 caleHtml 字段提取)
Raises:
RuntimeError: 请求失败或响应异常
"""
url = f"{PAIBAN_URL}?method=geRenPaibanByMonth"
data = {
"type": "2",
"staffId": staff_id,
"year": str(year),
"month": str(month)
}
logger.info("获取排班: %s %d-%02d", staff_id, year, month)
json_data = oa_request_json(session, "POST", url, data, "排班")
if json_data.get("success") != "true":
raise RuntimeError(f"排班接口返回失败: {json_data}")
html = json_data.get("caleHtml")
if not html:
raise RuntimeError("排班接口未返回 caleHtml 字段")
return html
def get_attendance_records(
session: SessionPage,
staff_id: str,
start_date: str,
end_date: str
) -> List[Dict[str, Any]]:
"""
查询员工某时间段的原始打卡明细。
Args:
session: 已登录的 SessionPage 对象
staff_id: 员工 UUID
start_date: 查询起始日期 "YYYY-MM-DD"
end_date: 查询结束日期 "YYYY-MM-DD"
Returns:
打卡记录列表(接口返回的 jsonList,每条含 kq_time / status / time_order 等)
- status: "1"=上班打卡, "5"=下班打卡, "6"=重复打卡
- time_order: "1"=上班时段, "2"=下班时段
Raises:
RuntimeError: 请求失败或响应异常
"""
params = {
"staff_id": staff_id,
"rootId": "",
"countId": "",
"bc_date": start_date,
"bc_date_end": end_date,
"begin": start_date,
"end": end_date,
}
logger.info("获取打卡明细: staff_id=%s, %s 至 %s", staff_id, start_date, end_date)
json_data = oa_request_json(session, "GET", KQ_DATA_URL, params, "考勤打卡")
records = json_data.get("jsonList", [])
logger.info("打卡明细返回 %d 条", len(records))
return records