Files
37duAutomation/tests/hrbp/test_07_confirm_abnormal.py
T
puddy 3862bbfab2 feat: 新增OA工作沟通推送模块,优化考勤异常查询逻辑与钉钉推送能力
1. 新增OA工作沟通推送全流程模块:
   - 实现人员搜索、多附件上传、工作沟通提交完整链路
   - 提供一键推送入口send_work_communication,支持多接收人、富文本与多类型沟通
   - 补充配套配置常量与接口封装
   - 添加抓包调试脚本与完整需求/开发文档

2. 考勤异常处理模块重构:
   - 将默认查询范围从「当月」改为「上周(周一~周日)」
   - 统一app/影刀版的日期范围计算逻辑
   - 新增班段合成、请假日期修复逻辑,优化导出报表字段
   - 更新需求文档与开发文档,同步功能变更

3. 钉钉推送工具优化:
   - 修复窗口激活逻辑,避免批量推送时抢焦点导致窗口失焦
   - 新增安全点击与鼠标状态兜底,防止左键卡死
   - 优化搜索与会话打开流程,提升稳定性
2026-08-25 17:08:44 +08:00

114 lines
4.5 KiB
Python

# -*- coding: utf-8 -*-
"""
@Module: tests.hrbp.test_07_confirm_abnormal
@FileName: test_07_confirm_abnormal.py
@Author: 小布丁
@CreateTime: 2026-08-24
@Description: 周考勤异常「确认异常」功能测试:
拉取上周未调整异常 → 展示列表供人工挑选一条 → 确认无误后调用确认接口提交
→ 重查验证该条已从「未调整」列表消失。
注意:确认异常为真实写操作(type=1 自动确认异常),提交后无法撤销,
请务必人工核对所选记录无误后再确认。
@Version: 1.0.0
"""
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))
from tests.hrbp._helpers import setup_logging, get_logger # noqa: E402
setup_logging()
logger = get_logger("tests.hrbp.test_07_confirm_abnormal")
def fetch_unadjusted():
"""构建会话并拉取当月未调整考勤异常,返回 (session, data)。"""
from app.service.hrbp.ehr.attendance.attendance_abnormal import (
build_hr_session,
_validate_session,
fetch_all_attendance_abnormal,
last_week_range,
IS_ADJUSTED,
)
session = build_hr_session()
session, user_id, treecode = _validate_session(session)
begin, end = last_week_range()
logger.info("查询范围:%s ~ %s,状态:未调整(%s)", begin, end, IS_ADJUSTED)
data = fetch_all_attendance_abnormal(session, user_id, treecode, begin, end, IS_ADJUSTED)
return session, data
def show_list(data):
"""按行展示未调整异常,返回序号 → abnormal_id 的映射。"""
print("\n===== 上周未调整考勤异常清单 =====")
print(f"{'序号':<4}{'abnormal_id':<34}{'工号':<10}{'姓名':<10}{'日期':<12}{'班次':<10}{'异常类型':<14}{'时长'}")
for i, it in enumerate(data, 1):
print(
f"{i:<4}{str(it.get('abnormal_id', '')):<34}"
f"{str(it.get('base_code', '')):<10}{str(it.get('STAFF_NAME', '')):<10}"
f"{str(it.get('work_day', '')):<12}{str(it.get('bc_name', '')):<10}"
f"{str(it.get('abnormal', '')):<14}{str(it.get('abnormal_minute', '') or 0)}"
)
print(f"共 {len(data)} 条\n")
return {i: it.get("abnormal_id") for i, it in enumerate(data, 1)}
def main():
session, data = fetch_unadjusted()
if not data:
logger.warning("上周无未调整考勤异常,无需测试")
return
mapping = show_list(data)
raw = input("请输入要确认的异常序号(Enter 取消):").strip()
if not raw:
logger.info("已取消,未提交任何确认")
return
try:
idx = int(raw)
except ValueError:
logger.error("输入无效:%s", raw)
return
if idx not in mapping:
logger.error("序号 %d 不在清单范围内", idx)
return
abnormal_id = mapping[idx]
logger.warning("即将对 abnormal_id=%s 调用确认接口(type=1,真实提交,不可撤销)", abnormal_id)
again = input("再次确认无误?输入 y 提交,其他取消:").strip().lower()
if again != "y":
logger.info("已取消,未提交")
return
from app.service.hrbp.ehr.attendance.attendance_abnormal import confirm_abnormal
result = confirm_abnormal(abnormal_id, session=session)
logger.info("确认接口返回:%s", result)
if result.get("state") != "1":
logger.error("确认失败:%s", result.get("meg") or result)
return
# 重查验证:该条应从「未调整」列表消失
_, data_after = fetch_unadjusted()
remaining = [it for it in data_after if str(it.get("abnormal_id", "")) == str(abnormal_id)]
if remaining:
logger.error("验证失败:abnormal_id=%s 仍在未调整列表中", abnormal_id)
else:
logger.info("[通过] abnormal_id=%s 已确认成功,不再出现在未调整列表(剩余 %d 条)",
abnormal_id, len(data_after))
# 影刀单文件版静态就绪校验(不发起真实请求)
import importlib
yingdao = importlib.import_module("yingdao.hr.attendance_abnormal")
assert callable(yingdao.confirm_abnormal), "影刀版缺少 confirm_abnormal"
assert callable(yingdao.adjust_abnormal), "影刀版缺少 adjust_abnormal"
assert yingdao.ATTENDANCE_ADJUST_URL.endswith("KqCountAbnormal.mc"), "影刀版确认接口地址异常"
logger.info("[通过] 影刀单文件版 confirm_abnormal 已就绪(未发请求)")
if __name__ == "__main__":
main()