经销商新签服务单表单字段更新
This commit is contained in:
@@ -6,3 +6,27 @@ Traceback (most recent call last):
|
||||
prepared_df['g_month_percentage'] = (pd.to_numeric(data_NGV_j['g_month_percentage'], errors='coerce')
|
||||
^^^^^^^^^^
|
||||
NameError: name 'data_NGV_j' is not defined
|
||||
2025-12-15 10:53:08,519 - log_config.py - error_task_logger - ERROR - 经销商新签服务单转BI任务执行失败: '业务人员'
|
||||
Traceback (most recent call last):
|
||||
File "D:\ProgramTools\anaconda3\envs\saas\Lib\site-packages\pandas\core\indexes\base.py", line 3812, in get_loc
|
||||
return self._engine.get_loc(casted_key)
|
||||
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
|
||||
File "pandas/_libs/index.pyx", line 167, in pandas._libs.index.IndexEngine.get_loc
|
||||
File "pandas/_libs/index.pyx", line 196, in pandas._libs.index.IndexEngine.get_loc
|
||||
File "pandas/_libs/hashtable_class_helper.pxi", line 7088, in pandas._libs.hashtable.PyObjectHashTable.get_item
|
||||
File "pandas/_libs/hashtable_class_helper.pxi", line 7096, in pandas._libs.hashtable.PyObjectHashTable.get_item
|
||||
KeyError: '业务人员'
|
||||
|
||||
The above exception was the direct cause of the following exception:
|
||||
|
||||
Traceback (most recent call last):
|
||||
File "D:\Idea Project\SaaS_V1.7\back_ground_module\new_dealer_service_order_to_bi.py", line 198, in main
|
||||
df = self.data_process()
|
||||
File "D:\Idea Project\SaaS_V1.7\back_ground_module\new_dealer_service_order_to_bi.py", line 83, in data_process
|
||||
df[col] = df[col].map(lambda x: x.get("name", "") if isinstance(x, dict) else "")
|
||||
~~^^^^^
|
||||
File "D:\ProgramTools\anaconda3\envs\saas\Lib\site-packages\pandas\core\frame.py", line 4107, in __getitem__
|
||||
indexer = self.columns.get_loc(key)
|
||||
File "D:\ProgramTools\anaconda3\envs\saas\Lib\site-packages\pandas\core\indexes\base.py", line 3819, in get_loc
|
||||
raise KeyError(key) from err
|
||||
KeyError: '业务人员'
|
||||
|
||||
@@ -42,7 +42,8 @@ class NewDealerServiceOrderToBI:
|
||||
'系统到期时间': '_widget_1741165503709', '开通状态': '_widget_1741165503714',
|
||||
'销售负责人': '_widget_1741165503716', '运营顾问': '_widget_1741165503718',
|
||||
'运营专家': '_widget_1741165503719', '区域经理': '_widget_1741165503717',
|
||||
'业务人员': '_widget_1741165503721', '是否设置经营范围': '_widget_1742200372555',
|
||||
# '业务人员': '_widget_1741165503721'
|
||||
'是否设置经营范围': '_widget_1742200372555',
|
||||
'不设置经营范围原因': '_widget_1742268351775', '是否建群': '_widget_1742200372553',
|
||||
'不建群原因': '_widget_1742268351776', '是否设置备货清单': '_widget_1742200372634',
|
||||
'不设置备货清单原因': '_widget_1742268351778', '是否设置报价': '_widget_1742260928184',
|
||||
@@ -76,7 +77,7 @@ class NewDealerServiceOrderToBI:
|
||||
df.columns = [reverse_mapping.get(col, col) for col in df.columns]
|
||||
|
||||
# 2.成员字段取值
|
||||
user_columns = ["提交人", "销售负责人", "区域经理", "业务人员", "运营顾问", "运营专家"]
|
||||
user_columns = ["提交人", "销售负责人", "区域经理", "运营顾问", "运营专家"]
|
||||
|
||||
for col in user_columns:
|
||||
df[col] = df[col].map(lambda x: x.get("name", "") if isinstance(x, dict) else "")
|
||||
|
||||
+103
-19
@@ -1,20 +1,104 @@
|
||||
{
|
||||
'app_id': '6694d3c4fcb69ca9a111a6c4',
|
||||
'form_id': '693778ee287cfdcc2df85ece',
|
||||
'form_title': '流程表单结构测试',
|
||||
'instance_id': '6937daf6f6e57cd3179c53c0',
|
||||
'url': 'https://dingtalk.jiandaoyun.com/workflow/process_instance/6937daf6f6e57cd3179c53c0',
|
||||
'update_time': '2025-12-09T08:17:36.460Z',
|
||||
'create_time': '2025-12-09T08:16:54.409Z',
|
||||
'finish_time': '2025-12-09T08:17:36.460Z',
|
||||
'status': 1,
|
||||
'creator': {
|
||||
'username': '#admin',
|
||||
'name': 'F6汽车科技',
|
||||
'type': 0,
|
||||
'status': 1,
|
||||
'integrate_id': '#admin'
|
||||
},
|
||||
'tasks': [],
|
||||
'result': 1
|
||||
}
|
||||
"result": [
|
||||
{
|
||||
"processInstanceId": "fa83e004-64d5-40a8-b2a9-122cc24a548f",
|
||||
"operateTimeGMT": "2025-02-28T09:07Z",
|
||||
"showName": "提交申请",
|
||||
"operateType": "NEW_PROCESS",
|
||||
"remark": "",
|
||||
"taskHoldTimeGMT": 0,
|
||||
"type": "HISTORY",
|
||||
"operatorName": "宜搭平台",
|
||||
"actionExit": "submit",
|
||||
"operatorUserId": "yida_pub_account",
|
||||
"activityId": "sid-restartevent",
|
||||
"size": 1,
|
||||
"dataId": 52359309345,
|
||||
"domainList": [],
|
||||
"operatorDisplayName": "宜搭平台",
|
||||
"action": "提交申请",
|
||||
"taskId": "null",
|
||||
"operatorPhotoUrl": "//img.alicdn.com/tfs/TB1mKVJSpXXXXcwaXXXXXXXXXXX-78-80.jpg"
|
||||
},
|
||||
{
|
||||
"processInstanceId": "fa83e004-64d5-40a8-b2a9-122cc24a548f",
|
||||
"operateTimeGMT": "2025-03-18T10:14Z",
|
||||
"showName": "120天联系情况",
|
||||
"operateType": "EXECUTE_TASK_NORMAL",
|
||||
"remark": "提交",
|
||||
"taskHoldTimeGMT": 0,
|
||||
"type": "HISTORY",
|
||||
"operatorName": "孟祥宇",
|
||||
"actionExit": "agree",
|
||||
"operatorUserId": "224616673723465569",
|
||||
"activityId": "sid-6470221a-82ec-4bdd-a873-245ee47a5605",
|
||||
"size": 1,
|
||||
"dataId": 53850072345,
|
||||
"domainList": [],
|
||||
"operatorDisplayName": "孟祥宇",
|
||||
"action": "提交",
|
||||
"taskId": "52359293348",
|
||||
"operatorPhotoUrl": "https://static.dingtalk.com/media/lADPDh0cUUaSfHrNAvDNAnA_624_752.jpg"
|
||||
},
|
||||
{
|
||||
"processInstanceId": "fa83e004-64d5-40a8-b2a9-122cc24a548f",
|
||||
"operateTimeGMT": "2025-04-01T14:08Z",
|
||||
"showName": "60天联系情况",
|
||||
"operateType": "EXECUTE_TASK_NORMAL",
|
||||
"remark": "系统提交",
|
||||
"taskHoldTimeGMT": 0,
|
||||
"type": "HISTORY",
|
||||
"operatorName": "魏子淇",
|
||||
"actionExit": "agree",
|
||||
"operatorUserId": "195159084238961158",
|
||||
"activityId": "sid-ab6374fd-7580-66d5-1628-6b0666bb38ff",
|
||||
"size": 1,
|
||||
"dataId": 55294608170,
|
||||
"domainList": [],
|
||||
"operatorDisplayName": "魏子淇",
|
||||
"action": "提交",
|
||||
"taskId": "53850072349",
|
||||
"operatorPhotoUrl": "https://static.dingtalk.com/media/lADPD2sQvHoyUEbNAtHNAtA_720_721.jpg"
|
||||
},
|
||||
{
|
||||
"processInstanceId": "fa83e004-64d5-40a8-b2a9-122cc24a548f",
|
||||
"operateTimeGMT": "2025-04-01T14:08Z",
|
||||
"showName": "30天联系情况",
|
||||
"operateType": "EXECUTE_TASK_NORMAL",
|
||||
"remark": "系统提交",
|
||||
"taskHoldTimeGMT": 0,
|
||||
"type": "HISTORY",
|
||||
"operatorName": "魏子淇",
|
||||
"actionExit": "agree",
|
||||
"operatorUserId": "195159084238961158",
|
||||
"activityId": "sid-e5928800-154e-4e20-6019-1364274afc49",
|
||||
"size": 1,
|
||||
"dataId": 55294609293,
|
||||
"domainList": [],
|
||||
"operatorDisplayName": "魏子淇",
|
||||
"action": "提交",
|
||||
"taskId": "55294608175",
|
||||
"operatorPhotoUrl": "https://static.dingtalk.com/media/lADPD2sQvHoyUEbNAtHNAtA_720_721.jpg"
|
||||
},
|
||||
{
|
||||
"processInstanceId": "fa83e004-64d5-40a8-b2a9-122cc24a548f",
|
||||
"operateTimeGMT": "2025-04-01T14:08Z",
|
||||
"showName": "0天处理情况",
|
||||
"operateType": "EXECUTE_TASK_NORMAL",
|
||||
"remark": "系统提交",
|
||||
"taskHoldTimeGMT": 0,
|
||||
"type": "HISTORY",
|
||||
"operatorName": "魏子淇",
|
||||
"actionExit": "agree",
|
||||
"operatorUserId": "195159084238961158",
|
||||
"activityId": "sid-ba12125f-bc3a-2663-ebf0-43b5aeb8c32c",
|
||||
"size": 1,
|
||||
"dataId": 55294558885,
|
||||
"domainList": [],
|
||||
"operatorDisplayName": "魏子淇",
|
||||
"action": "同意",
|
||||
"taskId": "55294609301",
|
||||
"operatorPhotoUrl": "https://static.dingtalk.com/media/lADPD2sQvHoyUEbNAtHNAtA_720_721.jpg"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"metadata": {},
|
||||
"cell_type": "markdown",
|
||||
"source": "## 宜搭流程",
|
||||
"id": "4af5abaa2a1a175f"
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"id": "initial_id",
|
||||
"metadata": {
|
||||
"collapsed": true,
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-12-11T06:35:48.340503Z",
|
||||
"start_time": "2025-12-11T06:35:10.459870Z"
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"import pandas as pd\n",
|
||||
"from yd_api import YDAPI\n",
|
||||
"from tqdm.notebook import tqdm\n",
|
||||
"\n",
|
||||
"yd_api_instance = YDAPI()\n",
|
||||
"\n",
|
||||
"token = yd_api_instance.generateToken()\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"df = pd.read_excel(r\"C:\\Users\\zy187\\Desktop\\流程续约服务数据合并情况总表.xlsx\",sheet_name=\"总表\")\n",
|
||||
"\n",
|
||||
"all_data = []\n",
|
||||
"for index,row in tqdm(df.iterrows(),total=len(df)):\n",
|
||||
" id = row[\"实例ID\"]\n",
|
||||
" res = yd_api_instance.get_approval_records(token = token,processInstanceId = id)\n",
|
||||
" result_list = res[\"result\"]\n",
|
||||
" for result in result_list:\n",
|
||||
" result[\"实例ID\"] = id\n",
|
||||
" all_data.append(result)\n",
|
||||
" break\n",
|
||||
"\n",
|
||||
"df1 = pd.DataFrame(all_data)\n",
|
||||
"\n",
|
||||
"df2 = pd.merge(df,df1,on=\"实例ID\",how=\"left\")\n",
|
||||
"df2.to_excel(r\"C:\\Users\\zy187\\Desktop\\结果.xlsx\")\n",
|
||||
"\n",
|
||||
"\n"
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
" 0%| | 0/13252 [00:00<?, ?it/s]"
|
||||
],
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"version_major": 2,
|
||||
"version_minor": 0,
|
||||
"model_id": "8986e952c720411e9ab60948965b830d"
|
||||
}
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data",
|
||||
"jetTransient": {
|
||||
"display_id": null
|
||||
}
|
||||
}
|
||||
],
|
||||
"execution_count": 1
|
||||
},
|
||||
{
|
||||
"metadata": {},
|
||||
"cell_type": "code",
|
||||
"outputs": [],
|
||||
"execution_count": null,
|
||||
"source": "",
|
||||
"id": "41dfeeb730400c9b"
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 2
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython2",
|
||||
"version": "2.7.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import pandas as pd
|
||||
from yd_api import YDAPI
|
||||
from tqdm import tqdm
|
||||
|
||||
yd_api_instance = YDAPI()
|
||||
|
||||
token = yd_api_instance.generateToken()
|
||||
|
||||
df = pd.read_excel(r"C:\Users\zy187\Desktop\流程续约服务数据合并情况总表.xlsx",sheet_name="总表")
|
||||
|
||||
all_data = []
|
||||
for index,row in tqdm(df.iterrows(),total=len(df)):
|
||||
id = row["实例ID"]
|
||||
res = yd_api_instance.get_approval_records(token = token,processInstanceId = id)
|
||||
result_list = res["result"]
|
||||
for result in result_list:
|
||||
result["实例ID"] = id
|
||||
all_data.append(result)
|
||||
|
||||
|
||||
df1 = pd.DataFrame(all_data)
|
||||
|
||||
df2 = pd.merge(df,df1,on="实例ID",how="left")
|
||||
df2.to_excel(r"C:\Users\zy187\Desktop\结果.xlsx")
|
||||
|
||||
|
||||
@@ -100,14 +100,14 @@ class YDAPI:
|
||||
"userId": "yida_pub_account", # 超级管理员账号
|
||||
"language": "zh_CN",
|
||||
}
|
||||
|
||||
while True:
|
||||
if attempt >= max_retries:
|
||||
print(f"请求失败,已达最大重试次数 {max_retries},跳过本次请求")
|
||||
break
|
||||
|
||||
try:
|
||||
res = requests.get(api, headers=headers)
|
||||
res.raise_for_status() # 如果响应状态码不是2xx,则抛出HTTPError
|
||||
res = requests.get(api, headers=headers, params=formData)
|
||||
|
||||
return res.json()
|
||||
except (requests.exceptions.RequestException, Exception) as e:
|
||||
print(f"请求出现异常: {e}, 正在重试({attempt + 1}/{max_retries})...")
|
||||
|
||||
Reference in New Issue
Block a user