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

54 lines
1.8 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 -*-
"""
@Module: hrbp.oa.resign_e_sign.downloads
@FileName: downloads.py
@Author: 小布丁
@CreateTime: 2026-08-31
@Description: 离职电子签签章附件下载。
电子签全部完成后,按 getBusinessData 的 contract_file(逗号分隔 fileId)
调 getFjkByIds 获取附件清单(解除确认书/报酬支付确认等),
再逐个经 fjkFileDownload.mob 下载到本地,供后续解析校验/归档。
@Version: 1.0.0
"""
from typing import Dict
from app.utils.logger import get_logger
from app.service.hrbp.oa.common.config import RESIGN_ATTACHMENT_SAVE_DIR
from app.service.hrbp.oa.common.oa_api.flow import (
get_fjk_file_list,
download_attachment,
)
logger = get_logger(__name__)
def download_contract_files(
session,
contract_file: str,
save_dir: str = RESIGN_ATTACHMENT_SAVE_DIR,
) -> Dict[str, str]:
"""
下载离职电子签签章附件(解除确认书/报酬支付确认)。
Args:
session: 已登录的 SessionPage 对象(已带登录 Cookie)
contract_file: getBusinessData 返回的 contract_file 字段(逗号分隔多个 fileId)
save_dir: 保存目录(默认离职电子签签章附件目录)
Returns:
{文件名: 本地路径};无附件或全部失败返回空 dict(不抛异常)。
"""
files = get_fjk_file_list(session, contract_file)
saved: Dict[str, str] = {}
for f in files:
fid = (f.get("id") or "").strip()
if not fid:
continue
path = download_attachment(session, fid, save_dir)
if path:
saved[f.get("fileName") or fid] = path
if not saved:
logger.warning("签章附件下载为空: contract_file=%s", contract_file)
return saved