From b6335b9902fdc7501cf3a2906a03b75303b2ec30 Mon Sep 17 00:00:00 2001 From: z66 <1415243231@qq.com> Date: Mon, 15 Dec 2025 10:56:00 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=8F=E9=94=80=E5=95=86=E6=96=B0=E7=AD=BE?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=8D=95=E8=A1=A8=E5=8D=95=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back_ground_module/logs/error_task.log | 24 ++++ .../new_dealer_service_order_to_bi.py | 5 +- test/json.json | 122 +++++++++++++++--- test/宜搭测算通知.ipynb | 99 ++++++++++++++ test/宜搭测算通知.py | 26 ++++ yd_api.py | 6 +- 6 files changed, 258 insertions(+), 24 deletions(-) create mode 100644 test/宜搭测算通知.ipynb create mode 100644 test/宜搭测算通知.py diff --git a/back_ground_module/logs/error_task.log b/back_ground_module/logs/error_task.log index 7b0be55..d1a4b6d 100644 --- a/back_ground_module/logs/error_task.log +++ b/back_ground_module/logs/error_task.log @@ -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: '业务人员' diff --git a/back_ground_module/new_dealer_service_order_to_bi.py b/back_ground_module/new_dealer_service_order_to_bi.py index 07f3aa2..b67ada8 100644 --- a/back_ground_module/new_dealer_service_order_to_bi.py +++ b/back_ground_module/new_dealer_service_order_to_bi.py @@ -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 "") diff --git a/test/json.json b/test/json.json index 3bd2061..ab70c11 100644 --- a/test/json.json +++ b/test/json.json @@ -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" + } + ] +} \ No newline at end of file diff --git a/test/宜搭测算通知.ipynb b/test/宜搭测算通知.ipynb new file mode 100644 index 0000000..e02b14e --- /dev/null +++ b/test/宜搭测算通知.ipynb @@ -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= 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})...")