feat(xq0037): 升级调动改签离职电子签流程优化数据范围与逻辑
- 调整台账导出范围为近三月、筛选时间为近4天 - 将名单表从「本月发起名单」统一改为「已发起名单」 - 新增三类人员群提醒、分页查询流程优化 - 修复单位名称匹配逻辑,新增选项集获取 - 替换COM写入为openpyxl避免时区问题
This commit is contained in:
@@ -38,7 +38,8 @@ from .xq35_step2_sign_new_contract import ( # noqa: E402
|
||||
_aitable_request, _build_query_params, _encode_common_query,
|
||||
_build_like_condition, _request_retry)
|
||||
from .step2_transfer_initiate import _hr_session # noqa: E402
|
||||
from .step3_transfer_todo import _log # noqa: E402
|
||||
from .step3_transfer_todo import ( # noqa: E402
|
||||
WORKFORM_FORM_ID, _log, get_business_data)
|
||||
from .step4_transfer_esign import query_sign_status # noqa: E402
|
||||
from .step5_transfer_aitable import _ms_day, RECORDS_LIST_URL # noqa: E402
|
||||
|
||||
@@ -54,6 +55,10 @@ FIELD_LEAVE_DONE = "是否完成离职签署"
|
||||
FIELD_NEW_DONE = "是否完成新合同签署"
|
||||
SIGN_DONE = "2" # 电子签状态编码:1=签署中 2=已完成
|
||||
|
||||
# WeProcess 分页遍历(流程反查不再受单页条数截断)
|
||||
WF_PAGE_SIZE = 100
|
||||
MAX_WF_PAGES = 50
|
||||
|
||||
# 试算开关:True=试算(只打印,不回填);False=实跑回填
|
||||
DRY_RUN = False
|
||||
|
||||
@@ -117,22 +122,40 @@ def _triple_done(triple):
|
||||
return all(t == SIGN_DONE for t in triple)
|
||||
|
||||
|
||||
def find_running_flow(session, name, code):
|
||||
"""运行中「改签离职电子签」流程按姓名(标题含)+ 工号兜底匹配 -> businessKey。"""
|
||||
params = {
|
||||
"version": "", "PACKAGE_ID": "cq37du", "process_type": "",
|
||||
"defProcessType": "", "struId": "", "rootId": "cq37du", "taskIds": "",
|
||||
"title": "改签离职电子签", "state": "", "startTime": "", "endTime": "",
|
||||
"sortType": "desc", "sortName": "CREATE_TIME",
|
||||
"commonQuery": "[]", "start": "0", "pageNo": "1", "pageSize": "100",
|
||||
}
|
||||
resp = _request_retry(
|
||||
"POST", f"{HR_BASE_URL}/RedseaPlatform/WeProcess.mc?method=getProcessAndData",
|
||||
session, data=params)
|
||||
for r in resp.json().get("datas") or []:
|
||||
title = str(r.get("title") or "")
|
||||
if name in title:
|
||||
def find_running_flow(session, code, name):
|
||||
"""运行中「改签离职电子签」流程按表单工号精确匹配 -> businessKey。
|
||||
|
||||
分页遍历运行中流程(每页 WF_PAGE_SIZE=100,上限 MAX_WF_PAGES 页),先用标题
|
||||
「{姓名}-改签离职电子签」粗筛(低开销),再读流程表单业务数据按 base_code
|
||||
精确确认(防重名误伤:重名同事的流程不会误判成本人的流程)。
|
||||
表单读取失败无法排除时按本人流程处理(返回该 businessKey),避免误入
|
||||
「流程已办结」分支造成提前回填。
|
||||
"""
|
||||
key = f"{(name or '').strip()}-改签离职电子签"
|
||||
for page in range(MAX_WF_PAGES):
|
||||
params = {
|
||||
"version": "", "PACKAGE_ID": "cq37du", "process_type": "",
|
||||
"defProcessType": "", "struId": "", "rootId": "cq37du", "taskIds": "",
|
||||
"title": "改签离职电子签", "state": "", "startTime": "", "endTime": "",
|
||||
"sortType": "desc", "sortName": "CREATE_TIME",
|
||||
"commonQuery": "[]",
|
||||
"start": str(page * WF_PAGE_SIZE), "pageNo": str(page + 1),
|
||||
"pageSize": str(WF_PAGE_SIZE),
|
||||
}
|
||||
resp = _request_retry(
|
||||
"POST", f"{HR_BASE_URL}/RedseaPlatform/WeProcess.mc?method=getProcessAndData",
|
||||
session, data=params)
|
||||
rows = resp.json().get("datas") or []
|
||||
for r in rows:
|
||||
if key not in str(r.get("title") or ""):
|
||||
continue
|
||||
biz = get_business_data(session, str(r.get("businessKey") or ""), WORKFORM_FORM_ID)
|
||||
biz_code = str(biz.get("base_code") or "").strip()
|
||||
if biz and biz_code and biz_code != str(code).strip():
|
||||
continue # 标题含重名但工号不符:重名同事的流程,跳过
|
||||
return str(r.get("businessKey") or "")
|
||||
if len(rows) < WF_PAGE_SIZE:
|
||||
break
|
||||
return ""
|
||||
|
||||
|
||||
@@ -166,7 +189,7 @@ def check_one(session, row):
|
||||
# 旧合同仍在生效中(改签未生效)-> 流程反查签署三状态
|
||||
notes.append("生效中Tab为旧合同(起始{})".format(
|
||||
old_rows[0].get("hr_staff_contract.contract_start_date")))
|
||||
biz = find_running_flow(session, name, code)
|
||||
biz = find_running_flow(session, code, name)
|
||||
if biz:
|
||||
st = query_sign_status(session, biz)
|
||||
triple = (str(st.get("is_initiate_sign") or ""),
|
||||
@@ -181,7 +204,7 @@ def check_one(session, row):
|
||||
else:
|
||||
# 生效中既无旧也无新:查待生效 tab(新合同签署中/签完未生效)
|
||||
notes.append("生效中Tab无合同行")
|
||||
biz = find_running_flow(session, name, code)
|
||||
biz = find_running_flow(session, code, name)
|
||||
if biz:
|
||||
st = query_sign_status(session, biz)
|
||||
triple = (str(st.get("is_initiate_sign") or ""),
|
||||
|
||||
Reference in New Issue
Block a user