Files
37duAutomation/tests/ocr.py
T
puddy 2daa1cd5a0 feat: 新增离职电子签流程审批功能,重构请假OCR业务逻辑
1.  新增离职电子签全流程校验:包括附件下载、PDF解析、表单与文书核验
2.  重构通用OCR模块,剥离业务逻辑到单独的请假附件检测模块
3.  新增PyMuPDF依赖用于PDF文本与扫描件OCR解析
4.  新增附件清单查询接口与离职附件检测工具类
2026-08-31 11:55:25 +08:00

43 lines
1.5 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 -*-
"""
OCR 附件检测测试入口。
通用图像识别见 app/utils/ocr.py,请假附件业务检测见
app/service/hrbp/oa/leave/attachment_check.py,本文件仅做导入与自测。
"""
import os
import sys
# 项目根目录 = tests 的上级目录,保证可导入 app 包
_PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if _PROJECT_ROOT not in sys.path:
sys.path.insert(0, _PROJECT_ROOT)
from app.service.hrbp.oa.leave.attachment_check import (
check_leave_attachment,
marriage_within_one_year,
extract_dates,
)
if __name__ == "__main__":
# 替换为你的附件路径,修改 leave_type 即可测试不同假期
test_path = r"D:\downloads\ocr_test_01.png"
print("病假检测(开启调试)")
result = check_leave_attachment(test_path, leave_type="sick", debug=True)
print(f"病假检测结果:{result}\n")
# 测试婚假检测 + 登记日期 1 年内
# result = check_leave_attachment("结婚证图片路径", leave_type="marriage", debug=True)
# print(f"婚假检测结果:{result}")
# ok, reg_date = marriage_within_one_year("结婚证图片路径", debug=True)
# print(f"登记日期:{reg_date},1年内:{ok}")
# 测试产检假检测
# result = check_leave_attachment("产检单图片路径", leave_type="maternity", debug=True)
# print(f"产检假检测结果:{result}")
# 日期提取单测
print("日期提取测试:", extract_dates("2025年5月20日登记,出生1998年3月2日,2025-05-20"))