Files
F6--/其它系统脚本/全配平台自动化.ipynb
T
2026-01-30 11:28:35 +08:00

170 lines
5.4 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'errcode': 0,\n",
" 'errmsg': 'ok',\n",
" 'access_token': 'aykNZ30YR-85Jy4xuHouhq2Vh7wLp2x_Xhvkk9Hj0uRF2e5TMdlAEX56ujdkgPByZM2oGwm36l9uPHWUV9ZRReCdp1gCzZakhq02b24zglwnTvaK2lBb6zK-_3EBH-zXXxKI-52KCqK3V_3DIAP1Ek7sPrisCp0PPKDOtG2vQ59Nv-c4ZzUmLNep3iaG63Ue4sNlmygXIx9vFD4nAe7q5Q',\n",
" 'expires_in': 7200}"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import requests\n",
"import json\n",
"token_api = 'https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=wwfe5ea400be3f1f4f&corpsecret=e0rSVmfog9EHzN_EoUhwistj3MwA1CfHHrEEVSZERYA'\n",
"res = requests.get(token_api)\n",
"token = res.json()\n",
"token"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'errcode': 0, 'errmsg': 'ok', 'userid': 'MaXing'}"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import requests\n",
"import json\n",
"token_api = 'https://qyapi.weixin.qq.com/cgi-bin/user/get_userid_by_email?access_token=aykNZ30YR-85Jy4xuHouhq2Vh7wLp2x_Xhvkk9Hj0uRF2e5TMdlAEX56ujdkgPByZM2oGwm36l9uPHWUV9ZRReCdp1gCzZakhq02b24zglwnTvaK2lBb6zK-_3EBH-zXXxKI-52KCqK3V_3DIAP1Ek7sPrisCp0PPKDOtG2vQ59Nv-c4ZzUmLNep3iaG63Ue4sNlmygXIx9vFD4nAe7q5Q'\n",
"data={\n",
" \"email\":\"maxing@f6qckj.wecom.work\",\n",
" \"email_type\":1\n",
"}\n",
"res = requests.post(token_api,json=data)\n",
"token = res.json()\n",
"token"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# 生成 token,参数不需要修改\n",
"def generateToken() -> str:\n",
" \"\"\" 生成 token \"\"\"\n",
"\n",
" token_api = 'https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=ID&corpsecret=SECRET'\n",
" res = requests.get(token_api)\n",
" token = res.json()['accessToken']\n",
"\n",
" return token\n",
"\n",
"\n",
"\"\"\" 处理流程开始 \"\"\"\n",
"# [正式]续约服务流程 —— 修改续约负责人 再进行转交 \n",
"FORMID = \"FORM-PE866MD1MJMU0WGLYRFLYEN5YN9L1I55Z7ZUK22\"\n",
"TOKEN = generateToken()\n",
"\n",
"df = pd.read_excel(r'C:\\Users\\admin\\Desktop\\待办转交及修改字段.xlsx',sheet_name='数据',dtype='string')\n",
"for i in range(len(df)):\n",
" a = df.loc[i,'实例ID']\n",
" b = df.loc[i,'修成ID']\n",
"\n",
" \"\"\" 函数功能:获取流程表单的审批记录 --F6客户服务 应用 \"\"\"\n",
" appType = \"APP_UYZ0KG6L0CCNV80GZ66O\"\n",
" systemToken = \"XA966F81JAJOFCVVVKO64E9MIIZV1EWE5SFMKJ2\"\n",
" userId = \"yida_pub_account\"\n",
"\n",
" api = f'https://api.dingtalk.com/v1.0/yida/processes/operationRecords?appType={appType}&systemToken={systemToken}&userId={userId}&language=zh_CN&processInstanceId={a}'\n",
"\n",
" headers = {\n",
" \"Content-Type\": \"application/json\",\n",
" \"x-acs-dingtalk-access-token\": TOKEN\n",
" }\n",
"\n",
" res = requests.get(api, headers=headers)\n",
" res_new = res.json()\n",
" records_new = res_new.get('result')\n",
"\n",
" records_new = [item for item in records_new if item.get('type') == \"TODO\"]\n",
" showName_new = records_new[0].get('showName')\n",
"\n",
" records_new = [item for item in records_new if item.get('type') == \"TODO\"]\n",
" taskId = records_new[0].get('taskId')\n",
"\n",
"\n",
"\n",
" \"\"\" 函数功能:转交审批节点 \"\"\"\n",
" api = f'https://api.dingtalk.com//v1.0/yida/tasks/redirect'\n",
"\n",
" headers = {\n",
" \"Content-Type\": \"application/json\",\n",
" \"x-acs-dingtalk-access-token\": TOKEN\n",
" }\n",
" payload = {\n",
" \"processInstanceId\" : a,\n",
" \"byManager\" : \"y\",\n",
" \"appType\" : \"APP_UYZ0KG6L0CCNV80GZ66O\",\n",
" \"systemToken\" : \"XA966F81JAJOFCVVVKO64E9MIIZV1EWE5SFMKJ2\",\n",
" \"language\": \"zh_CN\",\n",
" \"remark\" : \"转交(接口自动)\",\n",
" \"nowActionExecutorId\" : b,\n",
" \"userId\" : \"2268275546837446\",\n",
" \"taskId\" : int(taskId)\n",
" }\n",
"\n",
" res = requests.post(api, headers=headers, json=payload)\n",
" print(i,taskId,a,b,res.text)\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "F6processing",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.4"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "f83923c7d0b4d2e003073efbd633777fa3fd66b7578149f24f67f4796b9b3ac4"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}