Files
37duAutomation/app/service/hrbp/oa/resign_e_sign/downloads.py
T
puddy 1c74ec54f5 feat: 新增花名册查询导出、电子签状态补全与会话自愈能力
1. 新增OA电子签相关工具函数:补全签署状态、会话失效自愈、附件下载重试
2. 新增EHR花名册查询、导出、字典翻译全套API
3. 重构离职电子签审批流程,适配接口变更,补全电子签状态与附件源
4. 新增数据字典缓存与编码翻译能力
2026-09-05 18:35:46 +08:00

57 lines
2.0 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,
detail_url: str = None,
) -> Dict[str, str]:
"""
下载离职电子签签章附件(解除确认书/报酬支付确认)。
Args:
session: 已登录的 SessionPage 对象(已带登录 Cookie)
contract_file: getBusinessData 返回的 contract_file 字段(逗号分隔多个 fileId);
接口变更后该字段恒为空,需由 enrich_form_sign_status 从签署记录 file 字段补全
save_dir: 保存目录(默认离职电子签签章附件目录)
detail_url: 单据 SSO 详情链接,用于 EHR 会话失效时重建会话重试
Returns:
{文件名: 本地路径};无附件或全部失败返回空 dict(不抛异常)。
"""
files = get_fjk_file_list(session, contract_file, detail_url=detail_url)
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, detail_url=detail_url)
if path:
saved[f.get("fileName") or fid] = path
if not saved:
logger.warning("签章附件下载为空: contract_file=%s", contract_file)
return saved