79 lines
3.6 KiB
Python
79 lines
3.6 KiB
Python
from api import API
|
|
import pandas as pd
|
|
import ast
|
|
import traceback
|
|
api_instance = API()
|
|
|
|
## 下次运行测试单人转交
|
|
""" 处理流程开始 """
|
|
FORMID = "FORM-L89662816B04LXH893M4K50Q7MIZ1SVQI08ALU2" # 新签节点化服务待办
|
|
TOKEN = api_instance.generateToken()
|
|
|
|
df = pd.read_excel(r"C:\Users\hp_z66\Desktop\钉钉文件\(流程)续约服务流程_20260129144824.xlsx",
|
|
sheet_name='30天', dtype='string')
|
|
for i in range(len(df)): # 注意:没有从1开始
|
|
# for i in range(3): # 注意:没有从1开始
|
|
try:
|
|
|
|
processInstanceId = df.loc[i, '实例ID']
|
|
nowActionExecutorId = df.loc[i, '区域客成+小六-新'] # 需要注意多个转交人通过,切割,单个为int id # 注意修改
|
|
|
|
nowActionExecutorId_list =None
|
|
|
|
if nowActionExecutorId != "":
|
|
nowActionExecutorId = str(nowActionExecutorId)
|
|
print(nowActionExecutorId)
|
|
|
|
# 使用 split 按逗号分割字符串为列表
|
|
try:
|
|
# 如果已经是 list(比如从 JSON 加载后变成 list),直接使用
|
|
if isinstance(nowActionExecutorId, list):
|
|
nowActionExecutorId_list = nowActionExecutorId
|
|
else:
|
|
# 否则按逗号分割字符串
|
|
nowActionExecutorId_list = nowActionExecutorId.strip().split(',')
|
|
|
|
# 可选:去除每个元素两端空格
|
|
# nowActionExecutorId_list = [x.strip() for x in nowActionExecutorId_list]
|
|
|
|
except Exception as e:
|
|
print(e)
|
|
pass
|
|
|
|
res_new = api_instance.get_approval_records(token=TOKEN, processInstanceId=processInstanceId)
|
|
records_new = res_new.get("result")
|
|
print(records_new)
|
|
|
|
# records_new = [item for item in records_new if item.get('type') == "TODO"]
|
|
# showName_new = records_new[0].get('showName') # 获取路径节点名称
|
|
|
|
records_new = [item for item in records_new if item.get('type') == "TODO"]
|
|
record_new = records_new[0]
|
|
j = 0
|
|
if nowActionExecutorId_list and len(nowActionExecutorId_list) > 1:
|
|
# 多个提交人
|
|
print('多个提交人')
|
|
for item in record_new.get('domainList'):
|
|
taskId = item.get('taskId')
|
|
# print(i, taskId, processInstanceId, nowActionExecutorId_list[j])
|
|
res_new2 = api_instance.transfer_approvel_node(token=TOKEN, processInstanceId=processInstanceId,
|
|
nowActionExecutorId=nowActionExecutorId_list[j],
|
|
taskId=taskId)
|
|
j += 1
|
|
print(i, taskId, processInstanceId, nowActionExecutorId_list[j], res_new2.text)
|
|
# break
|
|
else:
|
|
print('单个提交人')
|
|
# 单个提交人
|
|
taskId = records_new[0].get('taskId')
|
|
print(i, taskId, processInstanceId, nowActionExecutorId_list)
|
|
res_new2 = api_instance.transfer_approvel_node(token=TOKEN, processInstanceId=processInstanceId,
|
|
nowActionExecutorId=nowActionExecutorId, taskId=taskId)
|
|
|
|
print(i, taskId, processInstanceId, nowActionExecutorId, res_new2.text)
|
|
else:
|
|
print(i, "无提交人")
|
|
except Exception as e:
|
|
print(f"发生异常: {e}")
|
|
# print("详细信息:")
|
|
# traceback.print_exception(type(e), e, e.__traceback__) |