feat(hrbp.oa): 新增离职电子签流程审核模块
完成离职电子签全流程开发,包括: 1. 新增模块目录与基础初始化文件 2. 实现表单解析、校验逻辑、审批入口与报告生成 3. 扩展通知模块兼容离职电子签场景,新增未完成待跟进统计 4. 补充接口文档与示例代码
This commit is contained in:
@@ -1,2 +1,288 @@
|
||||
|
||||
<div class="wf-select-people"><div class="modal-header" style="height: 46px; padding: 12px; background: rgb(248, 248, 248); color: rgb(51, 51, 51);"><button type="button" class="close" style="opacity: 1;">×</button> <!----> <h4 class="modal-title" style="font-size: 16px;"> 经营中心负责人 </h4></div> <div style="max-height: 300px; overflow: auto;"><div><div class="wf-select-people-body"><div><div class="activity-content"><div class="activity-item" style="margin: 5px 0px 5px 15px;"><label style="display: none;"></label></div> <!----></div></div> <div class="people-content" style="clear: both; padding-bottom: 0px; overflow: inherit;"><div class="people-item" style="height: auto;"><input type="radio" struid="47564779-7a9f-11ec-b449-000c296f9469" class="people-input" value="348627b7-14ea-4a25-a99f-cf898a0ce048"> <div class="people-display" style="position: unset;"><div class="people-display-div"><div class="people-img"><img src="/RedseaPlatform/skins/images/48nosex.png"></div></div> <div class="people-display-div-border"></div> <div class="userName" style="text-align: center; color: rgb(112, 128, 144); font-size: 12px; margin-top: 80px;"> 张亮 </div> <div class="ok-circle"><i class="glyphicon glyphicon-ok-sign"></i></div> <!----> <div class="_top"></div></div></div> <!----> <div class="clearfix" style="clear: both;"></div></div></div></div></div> <div style="height: 12px;"></div> <div class="modal-footer" style="padding: 8px 15px 5px;"><button class="btn btn-default btn-sm">取消</button> <button class="btn btn-primary btn-sm">确定</button></div></div>
|
||||
请求 URL
|
||||
https://hr.37du.co/RedseaPlatform/WorkformEngine.mc?method=getBusinessDate
|
||||
请求方法
|
||||
POST
|
||||
businessKey=bpmf69a3651bd624894b0527d52323d2577&formId=10a0b2ce-1b42-4576-97fa-974df67bad39
|
||||
{
|
||||
"state" : "1",
|
||||
"meg" : "处理成功",
|
||||
"des" : "",
|
||||
"result" : {
|
||||
"base_code" : "37022119",
|
||||
"belong_unit_org_name" : "金色印象事业部",
|
||||
"belong_unit_stru_id" : "0bcdedeb-e592-11ee-b449-000c296f9469",
|
||||
"contract_deadline" : "12",
|
||||
"contract_end_date" : "2027-07-31",
|
||||
"contract_file" : "",
|
||||
"contract_start_date" : "2026-08-01",
|
||||
"contract_type" : "0",
|
||||
"contract_type_template" : "3cd64878-0261-4ebc-ae03-e2d68bfca8cc,95d5c603-a9e3-4ae4-b48c-927aeeed6128,b269d6d6-51ff-4da9-bb0a-8a615890385d",
|
||||
"current_contract_id" : "d7ec411d-cb5c-11f0-a7d9-000c296f9469",
|
||||
"end_date2" : "2026-08-01",
|
||||
"end_time" : "2027-08-01",
|
||||
"ext_is_initiate_sign" : "",
|
||||
"ext_leave_template" : "a2a41822-32ae-4007-84f7-e95aecdcb081,078df1ce-ad35-44cf-849c-dcbab32af4bc",
|
||||
"ext_org_sign_status" : "",
|
||||
"ext_push_time" : "2026-08-20",
|
||||
"ext_staff_sign_status" : "",
|
||||
"ext_technician_code" : "",
|
||||
"file" : "",
|
||||
"first_type_id" : "9d73c973-919a-4a26-a692-664bcb8fef02",
|
||||
"idcard" : "511623200311056533",
|
||||
"identity" : "1",
|
||||
"is_new_sign" : "1",
|
||||
"leaveoffice_time" : "2026-07-31",
|
||||
"leaveoffice_type" : "ext_8",
|
||||
"main_id" : "bpmf69a3651bd624894b0527d52323d2577",
|
||||
"mobile_phone" : "19950986716",
|
||||
"move_id" : "",
|
||||
"org_full_path" : "集团-金色印象事业部-第一大区-金色印象重庆第一经营中心-第四片区-石油路PLUS会馆-接待组",
|
||||
"post_name" : "接待员",
|
||||
"post_no" : "232",
|
||||
"post_org_name" : "接待员",
|
||||
"si_area" : "e5e14ddb-9a0e-11f1-a7d9-000c296f9469",
|
||||
"staff_id" : "0f8a5181-e812-4bf9-b082-ac06343f1f1d",
|
||||
"staff_name" : "夏礼广",
|
||||
"treaty_type" : "1",
|
||||
"trigger_type" : "2"
|
||||
},
|
||||
"total" : "",
|
||||
"jsonList" : null,
|
||||
"viewMapper" : null,
|
||||
"record" : false
|
||||
}
|
||||
是否已发起电子签字典
|
||||
"hr_staff_contract.is_initiate_sign" : [ {
|
||||
"code" : "1",
|
||||
"name" : "已发起",
|
||||
"codeType" : "hr_staff_contract.is_initiate_sign",
|
||||
"parentCode" : "",
|
||||
"description" : "",
|
||||
"operator" : "张宝塔",
|
||||
"operatTime" : "2026-08-18 17:56:07",
|
||||
"inUse" : "1",
|
||||
"char1" : "",
|
||||
"char2" : "",
|
||||
"num1" : 1,
|
||||
"num2" : 0.0,
|
||||
"operatorName" : null,
|
||||
"groupName" : null,
|
||||
"codeTypeName" : null,
|
||||
"groupId" : null,
|
||||
"fullPathCode" : null,
|
||||
"fullPathName" : null,
|
||||
"createTime" : null,
|
||||
"oldCode" : null
|
||||
}, {
|
||||
"code" : "0",
|
||||
"name" : "未发起",
|
||||
"codeType" : "hr_staff_contract.is_initiate_sign",
|
||||
"parentCode" : "",
|
||||
"description" : "",
|
||||
"operator" : "张宝塔",
|
||||
"operatTime" : "2026-08-18 17:56:07",
|
||||
"inUse" : "1",
|
||||
"char1" : "",
|
||||
"char2" : "",
|
||||
"num1" : 2,
|
||||
"num2" : 0.0,
|
||||
"operatorName" : null,
|
||||
"groupName" : null,
|
||||
"codeTypeName" : null,
|
||||
"groupId" : null,
|
||||
"fullPathCode" : null,
|
||||
"fullPathName" : null,
|
||||
"createTime" : null,
|
||||
"oldCode" : null
|
||||
}, {
|
||||
"code" : "2",
|
||||
"name" : "已完成",
|
||||
"codeType" : "hr_staff_contract.is_initiate_sign",
|
||||
"parentCode" : "",
|
||||
"description" : "",
|
||||
"operator" : "张宝塔",
|
||||
"operatTime" : "2026-08-18 17:56:07",
|
||||
"inUse" : "1",
|
||||
"char1" : "",
|
||||
"char2" : "",
|
||||
"num1" : 3,
|
||||
"num2" : 1.0,
|
||||
"operatorName" : null,
|
||||
"groupName" : null,
|
||||
"codeTypeName" : null,
|
||||
"groupId" : null,
|
||||
"fullPathCode" : null,
|
||||
"fullPathName" : null,
|
||||
"createTime" : null,
|
||||
"oldCode" : null
|
||||
}, {
|
||||
"code" : "3",
|
||||
"name" : "已撤销",
|
||||
"codeType" : "hr_staff_contract.is_initiate_sign",
|
||||
"parentCode" : "",
|
||||
"description" : "",
|
||||
"operator" : "张宝塔",
|
||||
"operatTime" : "2026-08-18 17:56:07",
|
||||
"inUse" : "1",
|
||||
"char1" : "",
|
||||
"char2" : "",
|
||||
"num1" : 4,
|
||||
"num2" : 1.0,
|
||||
"operatorName" : null,
|
||||
"groupName" : null,
|
||||
"codeTypeName" : null,
|
||||
"groupId" : null,
|
||||
"fullPathCode" : null,
|
||||
"fullPathName" : null,
|
||||
"createTime" : null,
|
||||
"oldCode" : null
|
||||
}, {
|
||||
"code" : "5",
|
||||
"name" : "已过期",
|
||||
"codeType" : "hr_staff_contract.is_initiate_sign",
|
||||
"parentCode" : "",
|
||||
"description" : "",
|
||||
"operator" : "张宝塔",
|
||||
"operatTime" : "2026-08-18 17:56:07",
|
||||
"inUse" : "1",
|
||||
"char1" : "",
|
||||
"char2" : "",
|
||||
"num1" : 5,
|
||||
"num2" : 1.0,
|
||||
"operatorName" : null,
|
||||
"groupName" : null,
|
||||
"codeTypeName" : null,
|
||||
"groupId" : null,
|
||||
"fullPathCode" : null,
|
||||
"fullPathName" : null,
|
||||
"createTime" : null,
|
||||
"oldCode" : null
|
||||
}, {
|
||||
"code" : "7",
|
||||
"name" : "已拒签",
|
||||
"codeType" : "hr_staff_contract.is_initiate_sign",
|
||||
"parentCode" : "",
|
||||
"description" : "",
|
||||
"operator" : "张宝塔",
|
||||
"operatTime" : "2026-08-18 17:56:07",
|
||||
"inUse" : "1",
|
||||
"char1" : "",
|
||||
"char2" : "",
|
||||
"num1" : 6,
|
||||
"num2" : 1.0,
|
||||
"operatorName" : null,
|
||||
"groupName" : null,
|
||||
"codeTypeName" : null,
|
||||
"groupId" : null,
|
||||
"fullPathCode" : null,
|
||||
"fullPathName" : null,
|
||||
"createTime" : null,
|
||||
"oldCode" : null
|
||||
}, {
|
||||
"code" : "8",
|
||||
"name" : "已作废",
|
||||
"codeType" : "hr_staff_contract.is_initiate_sign",
|
||||
"parentCode" : "",
|
||||
"description" : "",
|
||||
"operator" : "张宝塔",
|
||||
"operatTime" : "2026-08-18 17:56:07",
|
||||
"inUse" : "1",
|
||||
"char1" : "",
|
||||
"char2" : "",
|
||||
"num1" : 7,
|
||||
"num2" : 0.0,
|
||||
"operatorName" : null,
|
||||
"groupName" : null,
|
||||
"codeTypeName" : null,
|
||||
"groupId" : null,
|
||||
"fullPathCode" : null,
|
||||
"fullPathName" : null,
|
||||
"createTime" : null,
|
||||
"oldCode" : null
|
||||
}
|
||||
员工签署状态/企业签署状态字典
|
||||
"esign_sigin_state" : [ {
|
||||
"code" : "1",
|
||||
"name" : "签署中",
|
||||
"codeType" : "esign_sigin_state",
|
||||
"parentCode" : "",
|
||||
"description" : "",
|
||||
"operator" : "张宝塔",
|
||||
"operatTime" : "2026-08-18 17:56:07",
|
||||
"inUse" : "1",
|
||||
"char1" : "",
|
||||
"char2" : "",
|
||||
"num1" : 1,
|
||||
"num2" : 0,
|
||||
"operatorName" : null,
|
||||
"groupName" : null,
|
||||
"codeTypeName" : null,
|
||||
"groupId" : null,
|
||||
"fullPathCode" : null,
|
||||
"fullPathName" : null,
|
||||
"createTime" : null,
|
||||
"oldCode" : null
|
||||
}, {
|
||||
"code" : "2",
|
||||
"name" : "已完成",
|
||||
"codeType" : "esign_sigin_state",
|
||||
"parentCode" : "",
|
||||
"description" : "",
|
||||
"operator" : "张宝塔",
|
||||
"operatTime" : "2026-08-18 17:56:07",
|
||||
"inUse" : "1",
|
||||
"char1" : "",
|
||||
"char2" : "",
|
||||
"num1" : 2,
|
||||
"num2" : 0,
|
||||
"operatorName" : null,
|
||||
"groupName" : null,
|
||||
"codeTypeName" : null,
|
||||
"groupId" : null,
|
||||
"fullPathCode" : null,
|
||||
"fullPathName" : null,
|
||||
"createTime" : null,
|
||||
"oldCode" : null
|
||||
}, {
|
||||
"code" : "3",
|
||||
"name" : "未完成",
|
||||
"codeType" : "esign_sigin_state",
|
||||
"parentCode" : "",
|
||||
"description" : "",
|
||||
"operator" : "张宝塔",
|
||||
"operatTime" : "2026-08-18 17:56:07",
|
||||
"inUse" : "1",
|
||||
"char1" : "",
|
||||
"char2" : "",
|
||||
"num1" : 3,
|
||||
"num2" : 0,
|
||||
"operatorName" : null,
|
||||
"groupName" : null,
|
||||
"codeTypeName" : null,
|
||||
"groupId" : null,
|
||||
"fullPathCode" : null,
|
||||
"fullPathName" : null,
|
||||
"createTime" : null,
|
||||
"oldCode" : null
|
||||
}, {
|
||||
"code" : "4",
|
||||
"name" : "已作废",
|
||||
"codeType" : "esign_sigin_state",
|
||||
"parentCode" : "",
|
||||
"description" : "",
|
||||
"operator" : "张宝塔",
|
||||
"operatTime" : "2026-08-18 17:56:07",
|
||||
"inUse" : "1",
|
||||
"char1" : "",
|
||||
"char2" : "",
|
||||
"num1" : 4,
|
||||
"num2" : 0,
|
||||
"operatorName" : null,
|
||||
"groupName" : null,
|
||||
"codeTypeName" : null,
|
||||
"groupId" : null,
|
||||
"fullPathCode" : null,
|
||||
"fullPathName" : null,
|
||||
"createTime" : null,
|
||||
"oldCode" : null
|
||||
} ]
|
||||
@@ -102,20 +102,21 @@ def build_push_summary(results: list, subject: str = "") -> str:
|
||||
rejected = [r for r in results if r.get("decision") == "校验不通过未处理"]
|
||||
review = [r for r in results if r.get("decision") == "人工复核"]
|
||||
overdue = [r for r in results if r.get("decision") == "超期"]
|
||||
pending = [r for r in results if r.get("decision") == "未完成"]
|
||||
abnormal = [r for r in results if r.get("decision") == "异常"]
|
||||
failed = [r for r in results if r.get("decision") == "失败"]
|
||||
|
||||
if not passed and not rejected and not review and not overdue and not abnormal:
|
||||
if not passed and not rejected and not review and not overdue and not pending and not abnormal:
|
||||
return ""
|
||||
|
||||
def _item(r):
|
||||
# 兼容请假(leave_info/假期类型)与加班(overtime_info/加班类型)
|
||||
info = r.get("leave_info") or r.get("overtime_info") or {}
|
||||
title = r.get("title", "") or info.get("请假人员") or info.get("加班人员") or "未知"
|
||||
# 兼容请假(leave_info/假期类型)、加班(overtime_info/加班类型)与离职电子签(resign_info/员工姓名)
|
||||
info = r.get("leave_info") or r.get("overtime_info") or r.get("resign_info") or {}
|
||||
title = r.get("title", "") or info.get("请假人员") or info.get("加班人员") or info.get("员工姓名") or "未知"
|
||||
vtype = info.get("假期类型") or info.get("加班类型") or ""
|
||||
return f"{title}-{vtype}" if vtype else title
|
||||
|
||||
all_pass = (not rejected and not review and not overdue and not abnormal and not failed)
|
||||
all_pass = (not rejected and not review and not overdue and not pending and not abnormal and not failed)
|
||||
|
||||
lines = []
|
||||
if all_pass:
|
||||
@@ -148,6 +149,11 @@ def build_push_summary(results: list, subject: str = "") -> str:
|
||||
for r in overdue:
|
||||
lines.append(_item(r))
|
||||
lines.append(f"处理原因:{r.get('note') or r.get('error') or '未知'}")
|
||||
if pending:
|
||||
lines.append(f"未完成待跟进 {len(pending)} 条,分别是:")
|
||||
for r in pending:
|
||||
lines.append(_item(r))
|
||||
lines.append(f"原因:{r.get('note') or r.get('error') or '未知'}")
|
||||
if abnormal:
|
||||
lines.append(f"审批异常 {len(abnormal)} 条,分别是:")
|
||||
for r in abnormal:
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
@Module: hrbp.oa.resign_e_sign
|
||||
@FileName: __init__.py
|
||||
@Author: 小布丁
|
||||
@CreateTime: 2026-08-20
|
||||
@Description: 离职电子签流程审核模块:解析 -> 校验(三态均已完成才同意)-> 报告
|
||||
@Version: 1.0.0
|
||||
"""
|
||||
@@ -0,0 +1,106 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
@Module: hrbp.oa.resign_e_sign.parser
|
||||
@FileName: parser.py
|
||||
@Author: 小布丁
|
||||
@CreateTime: 2026-08-20
|
||||
@Description: 离职电子签流程表单解析模块(解析 WorkformEngine 返回的 result,提取电子签三状态及员工信息)
|
||||
@Version: 1.0.0
|
||||
"""
|
||||
|
||||
from typing import Any, Dict
|
||||
|
||||
from app.utils.logger import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
# 是否已发起电子签字典(hr_staff_contract.is_initiate_sign)
|
||||
INITIATE_SIGN_MAP = {
|
||||
"0": "未发起",
|
||||
"1": "已发起",
|
||||
"2": "已完成",
|
||||
"3": "已撤销",
|
||||
"5": "已过期",
|
||||
"7": "已拒签",
|
||||
"8": "已作废",
|
||||
}
|
||||
|
||||
# 员工/企业签署状态字典(esign_sigin_state)
|
||||
SIGN_STATE_MAP = {
|
||||
"1": "签署中",
|
||||
"2": "已完成",
|
||||
"3": "未完成",
|
||||
"4": "已作废",
|
||||
}
|
||||
|
||||
# 电子签三状态均须等于该编码(已完成)才同意
|
||||
SIGN_DONE_CODE = "2"
|
||||
|
||||
|
||||
def _sign_name(mapping: Dict[str, str], code: Any) -> str:
|
||||
"""将状态编码转换为名称;空值返回空串,未知编码原样返回。"""
|
||||
if code is None or str(code).strip() == "":
|
||||
return ""
|
||||
return mapping.get(str(code).strip(), str(code))
|
||||
|
||||
|
||||
def parse_resign_e_sign_form(result: Dict[str, Any]) -> Dict[str, Any]:
|
||||
"""
|
||||
解析离职电子签表单数据,提取关键字段。
|
||||
|
||||
Args:
|
||||
result: WorkformEngine 返回的 result 字典(即 doc['formData'])
|
||||
|
||||
Returns:
|
||||
包含离职电子签关键字段的字典(中文键名),三个电子签状态同时保留编码与名称
|
||||
"""
|
||||
is_initiate = result.get("ext_is_initiate_sign")
|
||||
staff_state = result.get("ext_staff_sign_status")
|
||||
org_state = result.get("ext_org_sign_status")
|
||||
|
||||
return {
|
||||
"员工姓名": result.get("staff_name"),
|
||||
"工号": result.get("base_code"),
|
||||
"身份证号": result.get("idcard"),
|
||||
"所属事业部": result.get("belong_unit_org_name"),
|
||||
"组织架构": result.get("org_full_path"),
|
||||
"岗位": result.get("post_name"),
|
||||
"离职日期": result.get("leaveoffice_time"),
|
||||
"手机号": result.get("mobile_phone"),
|
||||
"合同类型": result.get("contract_type"),
|
||||
"合同开始日期": result.get("contract_start_date"),
|
||||
"合同结束日期": result.get("contract_end_date"),
|
||||
"是否已发起电子签编码": is_initiate,
|
||||
"是否已发起电子签": _sign_name(INITIATE_SIGN_MAP, is_initiate),
|
||||
"员工签署状态编码": staff_state,
|
||||
"员工签署状态": _sign_name(SIGN_STATE_MAP, staff_state),
|
||||
"企业签署状态编码": org_state,
|
||||
"企业签署状态": _sign_name(SIGN_STATE_MAP, org_state),
|
||||
}
|
||||
|
||||
|
||||
# ---------- 使用示例(测试用) ----------
|
||||
if __name__ == "__main__":
|
||||
from app.utils.logger import setup_logging
|
||||
setup_logging()
|
||||
|
||||
# 示例 result(WorkformEngine 返回的 result 字段,见 aa.md)
|
||||
sample_result = {
|
||||
"base_code": "37022119",
|
||||
"belong_unit_org_name": "金色印象事业部",
|
||||
"ext_is_initiate_sign": "2",
|
||||
"ext_org_sign_status": "2",
|
||||
"ext_staff_sign_status": "2",
|
||||
"idcard": "511623200311056533",
|
||||
"leaveoffice_time": "2026-07-31",
|
||||
"mobile_phone": "19950986716",
|
||||
"org_full_path": "集团-金色印象事业部-第一大区-金色印象重庆第一经营中心-第四片区-石油路PLUS会馆-接待组",
|
||||
"post_name": "接待员",
|
||||
"staff_name": "夏礼广",
|
||||
}
|
||||
|
||||
parsed = parse_resign_e_sign_form(sample_result)
|
||||
logger.info("===== 离职电子签信息解析结果 =====")
|
||||
for key, value in parsed.items():
|
||||
logger.info("%s: %s", key, value)
|
||||
@@ -0,0 +1,127 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
@Module: hrbp.oa.resign_e_sign.reporter
|
||||
@FileName: reporter.py
|
||||
@Author: 小布丁
|
||||
@CreateTime: 2026-08-20
|
||||
@Description: 离职电子签流程报告模块。
|
||||
校验结果分两组:通过(已同意)/ 未完成(不管,待后续流转)。
|
||||
输出清单:
|
||||
《离职电子签未完成待跟进清单》:员工姓名、电子签三状态、详情页链接
|
||||
通过名单的简短汇总由 common.notify.build_push_summary 生成并推送钉钉。
|
||||
@Version: 1.0.0
|
||||
"""
|
||||
|
||||
from typing import Any, Dict, List
|
||||
|
||||
|
||||
def _name(r: Dict[str, Any]) -> str:
|
||||
"""员工姓名:优先取表单里的员工姓名,缺失时回退到发起人。"""
|
||||
info = r.get("resign_info", {}) or {}
|
||||
return info.get("员工姓名") or r.get("creator") or "未知"
|
||||
|
||||
|
||||
def _format_detail(info: Dict[str, Any]) -> str:
|
||||
"""将 resign_info 字典格式化为易读的明细行。"""
|
||||
fields = [
|
||||
("员工姓名", "员工姓名"),
|
||||
("工号", "工号"),
|
||||
("所属事业部", "所属事业部"),
|
||||
("组织架构", "组织架构"),
|
||||
("岗位", "岗位"),
|
||||
("离职日期", "离职日期"),
|
||||
("合同类型", "合同类型"),
|
||||
("合同开始日期", "合同开始日期"),
|
||||
("合同结束日期", "合同结束日期"),
|
||||
("是否已发起电子签", "是否已发起电子签"),
|
||||
("员工签署状态", "员工签署状态"),
|
||||
("企业签署状态", "企业签署状态"),
|
||||
]
|
||||
parts = []
|
||||
for key, label in fields:
|
||||
val = info.get(key)
|
||||
if val is not None and val != "" and val != "无":
|
||||
parts.append(f"{label}={val}")
|
||||
return " | ".join(parts)
|
||||
|
||||
|
||||
def generate_report(results: List[Dict[str, Any]]) -> str:
|
||||
"""
|
||||
生成离职电子签审批报告:汇总行 + 每条明细 + 未完成待跟进清单(+处理失败/异常)。
|
||||
|
||||
Args:
|
||||
results: validate_doc 返回的校验结果列表,decision ∈ {通过/未完成/失败/异常}
|
||||
|
||||
Returns:
|
||||
报告文本
|
||||
"""
|
||||
passed = [r for r in results if r.get("decision") == "通过"]
|
||||
pending = [r for r in results if r.get("decision") == "未完成"]
|
||||
abnormal = [r for r in results if r.get("decision") == "异常"]
|
||||
failed = [r for r in results if r.get("decision") == "失败"]
|
||||
|
||||
summary = f"共 {len(results)} 单:通过 {len(passed)},未完成待跟进 {len(pending)}"
|
||||
if abnormal:
|
||||
summary += f",审批异常 {len(abnormal)}"
|
||||
if failed:
|
||||
summary += f",处理失败 {len(failed)}"
|
||||
|
||||
lines = [
|
||||
"离职电子签审批报告",
|
||||
"=" * 60,
|
||||
summary,
|
||||
"",
|
||||
]
|
||||
|
||||
# ----- 明细清单(所有审批单的完整数据) -----
|
||||
lines.append("【审批明细】")
|
||||
for i, r in enumerate(results, 1):
|
||||
info = r.get("resign_info", {}) or {}
|
||||
decision = r.get("decision", "未知")
|
||||
note = r.get("note") or r.get("error") or ""
|
||||
lines.append(f" #{i} {_name(r)}({info.get('工号', '')})-> {decision}")
|
||||
detail = _format_detail(info)
|
||||
if detail:
|
||||
lines.append(f" {detail}")
|
||||
if note:
|
||||
lines.append(f" 备注: {note}")
|
||||
if r.get("审批动作"):
|
||||
lines.append(f" 审批动作: {r['审批动作']}({r.get('审批结果', '')})")
|
||||
lines.append("")
|
||||
|
||||
# ----- 未完成(不管)待跟进清单 -----
|
||||
if pending:
|
||||
lines.append("《离职电子签未完成待跟进清单》")
|
||||
lines.append("(电子签未全部完成,机器不处理,待后续流转/人工跟进)")
|
||||
for i, r in enumerate(pending, 1):
|
||||
info = r.get("resign_info", {}) or {}
|
||||
note = r.get("note") or ""
|
||||
url = r.get("detail_url") or "无"
|
||||
lines.append(
|
||||
f"{i}. 员工姓名: {_name(r)} | "
|
||||
f"发起: {info.get('是否已发起电子签', '未知')} | "
|
||||
f"员工: {info.get('员工签署状态', '未知')} | "
|
||||
f"企业: {info.get('企业签署状态', '未知')} | "
|
||||
f"原因: {note} | 详情页链接: {url}"
|
||||
)
|
||||
lines.append("")
|
||||
|
||||
# ----- 处理失败 -----
|
||||
if failed:
|
||||
lines.append("【处理失败】")
|
||||
for i, r in enumerate(failed, 1):
|
||||
lines.append(f"{i}. {_name(r)} | {r.get('title', '')} | 错误: {r.get('error', '')}")
|
||||
lines.append("")
|
||||
|
||||
# ----- 审批异常(审批提交失败,需人工跟进) -----
|
||||
if abnormal:
|
||||
lines.append("《离职电子签审批异常待人工确认清单》")
|
||||
lines.append("(机器已出结论但审批提交未成功,OA 中状态未变,待人工跟进处理)")
|
||||
for i, r in enumerate(abnormal, 1):
|
||||
reason = r.get("note") or r.get("error") or ""
|
||||
url = r.get("detail_url") or "无"
|
||||
action = r.get("审批动作") or "-"
|
||||
lines.append(f"{i}. 员工姓名: {_name(r)} | 审批动作: {action} | 原因: {reason} | 详情页链接: {url}")
|
||||
lines.append("")
|
||||
|
||||
return "\n".join(lines)
|
||||
@@ -0,0 +1,22 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
@Module: hrbp.oa.resign_e_sign.resign_e_sign_approval
|
||||
@FileName: resign_e_sign_approval.py
|
||||
@Author: 小布丁
|
||||
@CreateTime: 2026-08-20
|
||||
@Description: 离职电子签流程审核入口(审批引擎见 common/approval_flow.py,校验规则见 validator.py,报告见 reporter.py)
|
||||
@Version: 1.0.0
|
||||
"""
|
||||
|
||||
from app.service.hrbp.oa.common.approval_flow import run_flow
|
||||
from app.service.hrbp.oa.resign_e_sign.validator import validate_doc
|
||||
from app.service.hrbp.oa.resign_e_sign.reporter import generate_report
|
||||
|
||||
|
||||
def main() -> None:
|
||||
"""离职电子签流程审核:登录 -> 查待办 -> 解析SSO -> 获取表单 -> 校验 -> 报告"""
|
||||
run_flow(subject="离职电子签流程", validate_doc=validate_doc, generate_report=generate_report)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,87 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
@Module: hrbp.oa.resign_e_sign.validator
|
||||
@FileName: validator.py
|
||||
@Author: 小布丁
|
||||
@CreateTime: 2026-08-20
|
||||
@Description: 离职电子签流程校验模块(审批决策两态:通过 / 未完成)。
|
||||
规则(见 aa.md):进入详情取三个电子签状态字段,三者均为"已完成"才同意,
|
||||
否则不处理("不管"),留给后续待办继续流转。
|
||||
- 是否已发起电子签 ext_is_initiate_sign(hr_staff_contract.is_initiate_sign)
|
||||
- 员工签署状态 ext_staff_sign_status(esign_sigin_state)
|
||||
- 企业签署状态 ext_org_sign_status(esign_sigin_state)
|
||||
@Version: 1.0.0
|
||||
"""
|
||||
|
||||
from typing import Any, Dict
|
||||
|
||||
from app.utils.logger import get_logger
|
||||
from app.service.hrbp.oa.resign_e_sign.parser import (
|
||||
parse_resign_e_sign_form,
|
||||
SIGN_DONE_CODE,
|
||||
)
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
def _is_done(value: Any) -> bool:
|
||||
"""判断电子签状态编码是否为已完成(编码为字符串 "2")。"""
|
||||
return value is not None and str(value).strip() == SIGN_DONE_CODE
|
||||
|
||||
|
||||
def validate_doc(doc: Dict[str, Any], session: Any) -> Dict[str, Any]:
|
||||
"""
|
||||
校验单张离职电子签单据,返回审批决策。
|
||||
|
||||
流程:
|
||||
1. 解析表单数据,提取电子签三状态与员工信息
|
||||
2. 三者均已完成 -> 通过(同意);否则 -> 未完成(不管)
|
||||
|
||||
Args:
|
||||
doc: 单据信息,含基本信息(title/creator/time/detail_url)
|
||||
和审批引擎已获取的 taskId/businessKey/formId/formData(表单详情)
|
||||
session: 已登录的 SessionPage 对象(本流程无需额外接口,保留参数以适配公共引擎签名)
|
||||
|
||||
Returns:
|
||||
校验结果,包含审批决策及详细信息
|
||||
"""
|
||||
form_data = doc.get("formData", {}) or {}
|
||||
resign_info = parse_resign_e_sign_form(form_data)
|
||||
|
||||
is_initiate = form_data.get("ext_is_initiate_sign")
|
||||
staff_state = form_data.get("ext_staff_sign_status")
|
||||
org_state = form_data.get("ext_org_sign_status")
|
||||
|
||||
result: Dict[str, Any] = {
|
||||
"title": doc.get("title", ""),
|
||||
"creator": doc.get("creator", ""),
|
||||
"time": doc.get("time", ""),
|
||||
"detail_url": doc.get("detail_url", ""),
|
||||
"decision": "未完成",
|
||||
"note": "",
|
||||
"resign_info": resign_info,
|
||||
}
|
||||
|
||||
def _label(value: Any, mapping_name: str) -> str:
|
||||
"""取状态名称,缺失时回退为原始值/未知,便于人工判断。"""
|
||||
return resign_info.get(mapping_name) or (str(value).strip() if value is not None else "未知")
|
||||
|
||||
if all(_is_done(v) for v in (is_initiate, staff_state, org_state)):
|
||||
result["decision"] = "通过"
|
||||
result["note"] = (
|
||||
"审批通过(是否已发起电子签/员工签署状态/企业签署状态均为已完成)"
|
||||
)
|
||||
else:
|
||||
result["decision"] = "未完成"
|
||||
result["note"] = (
|
||||
f"电子签未全部完成,暂不处理(是否已发起电子签: {_label(is_initiate, '是否已发起电子签')},"
|
||||
f"员工签署状态: {_label(staff_state, '员工签署状态')},"
|
||||
f"企业签署状态: {_label(org_state, '企业签署状态')})"
|
||||
)
|
||||
logger.info(
|
||||
"未完成单据[%s] %s: 发起=%s, 员工=%s, 企业=%s",
|
||||
doc.get("title", ""), resign_info.get("员工姓名", ""),
|
||||
is_initiate, staff_state, org_state,
|
||||
)
|
||||
|
||||
return result
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user