Compare commits

...

2 Commits

Author SHA1 Message Date
panda f212bd6a12 异常回访提交 2025-10-24 09:22:19 +08:00
panda d9d52df726 异常回访提交 2025-10-23 17:09:06 +08:00
7 changed files with 41745 additions and 23 deletions
+40
View File
@@ -286,6 +286,7 @@ class NewExceptionTask:
NGV_data_id = None
reason = None
create_exception =None
create_date = None
# 获取关联数据
for NGV_Data in self.NGV_data_list:
# NGV_Data = NGV_Data.get("data")
@@ -299,6 +300,8 @@ class NewExceptionTask:
logger.info(f"获取关联数据成功:{NGV_data_id}, {province_name}, {city_name}, {area_name}")
# 是否生成异常待办
create_exception = NGV_Data.get("_widget_1758769279995")
# 获取上线日期(文本)
create_date = NGV_Data.get("_widget_1734062123176")
# 判断门店原因
# if reason in ["门店倒闭", "门店转让", "加盟其他连锁","切换竞品","虚拟门店","重新开户","已退款","二套系统"]:
@@ -307,6 +310,43 @@ class NewExceptionTask:
# 判断是否继续生成异常待办
if create_exception == "":
continue
# 新增:检查 create_date_str 是否存在且有效
if not create_date:
logger.warning("上线日期为空,跳过该记录")
continue
# 定义可能的日期格式(灵活应对不同格式)
date_formats = [
"%Y-%m-%d %H:%M:%S", # 含时间
"%Y-%m-%d", # 仅日期
"%Y/%m/%d",
"%Y/%m/%d %H:%M:%S"
]
parsed_date = None
for fmt in date_formats:
try:
parsed_date = datetime.datetime.strptime(create_date.strip(), fmt).date()
logger.debug(f"使用格式 {fmt} 成功解析日期: {parsed_date}")
break
except ValueError:
continue
if parsed_date is None:
logger.error(f"无法解析上线日期: '{create_date}',支持的格式: %Y-%m-%d, %Y-%m-%d %H:%M:%S 等")
continue # 解析失败,跳过
# 使用解析后的日期进行判断
now_date = datetime.date.today()
delta = now_date - parsed_date
days_diff = delta.days
if days_diff > 30:
logger.info(f"上线日期 {parsed_date} 超过30天({days_diff}天),生成待办")
# ✅ 继续后续待办创建逻辑
else:
logger.info(f"上线日期 {parsed_date} 在30天内,跳过处理")
continue
if not NGV_data_id:
+3 -1
View File
@@ -139,11 +139,12 @@ class CommonModule:
# 获取指定天数前的日期
now_time = datetime.now()
target_time = now_time + timedelta(days=-days_back)
target_date_id = int(target_time.strftime('%Y%m%d')) # 获取目标日期
# sql语句查询
sql = f"""SELECT * FROM "public"."holo_ads_dataservice_saas_org_health_warning" WHERE "pt" = '{target_date_id}' and "org_type" = '一般';"""
sql = f"""-- SELECT * FROM "public"."holo_ads_dataservice_saas_org_health_warning" WHERE "pt" = '{target_date_id}' and "org_type" = '一般';"""
# 执行语句并获取结果集
cursor.execute(sql)
@@ -165,6 +166,7 @@ class CommonModule:
cursor.close()
conn.close()
return data_yichang
except Exception as e:
File diff suppressed because it is too large Load Diff
+40
View File
@@ -0,0 +1,40 @@
## 获取多条数据
```python
from api import API
api_instance =API()
payload = {"api_key": "6694d3c4fcb69ca9a111a6c4",
"entry_id": "6769204a1902c9341340a1bc",
}
staff_id = api_instance.entry_data_list(payload)
```
## 创建多条数据
```python
from api import API
api_instance =API()
payload_dict = {}
payload_dict.update({
"_widget_1734590278279": {"value": row["group_name"]}, # 公司名称
"_widget_1735112931760": {"value": row["id_own_group"]}, # 公司id
"_widget_1735112931761": {"value": row["id_own_org"]}, # 门店id
"_widget_1734590278281": {"value": row['org_name']}, # 门店名称
)
routine_follow_up_payload = {
"api_key": "675b900991ad2491c69389ca",
"entry_id": "675b9c63925cd404038a6b86",
"is_start_workflow": "true", # 是否启动流程
"data": payload_dict,
}
res = api_instance.data_batch_create(routine_follow_up_payload)
```
## 删除单条
```python
from api import API
api_instance =API()
delete_data = {"api_key": Config.EFFICIENT_CAR_PICKUP_APP_ID,
"entry_id": Config.EFFICIENT_CAR_PICKUP_CUSTOMER_HISTORY_ID,
"data_id": row["数据id"]}
api_instance.entry_data_delete(delete_data)
```
+2
View File
@@ -16,3 +16,5 @@
2025-09-26 13:52:38,421 - ngv更新.py - error_task_logger - ERROR - NGV更新数据执行时发生异常: [Errno 13] Permission denied: 'output\\only_in_temp_jdy.csv'
2025-09-26 17:42:51,517 - ngv更新.py - error_task_logger - ERROR - NGV更新数据执行时发生异常: [Errno 13] Permission denied: 'output\\only_in_temp_jdy.csv'
2025-09-26 17:54:44,808 - ngv更新.py - error_task_logger - ERROR - NGV更新数据执行时发生异常: 'org_code'
2025-10-23 17:50:48,142 - 异常回访排查.py - error_task_logger - ERROR - 异常服务待办派发执行时发生异常: 'NoneType' object has no attribute 'astype'
2025-10-23 17:51:08,065 - 异常回访排查.py - error_task_logger - ERROR - 异常服务待办派发执行时发生异常: 'NoneType' object has no attribute 'astype'
+15
View File
@@ -1059,3 +1059,18 @@
2025-10-15 15:14:12,294 - 4281365028.py - task_logger - INFO - 数据加载完成
2025-10-15 15:14:36,032 - 4281365028.py - task_logger - INFO - 时间转换完成
2025-10-15 15:14:36,045 - 4281365028.py - task_logger - INFO - 人员转换完成
2025-10-23 17:35:15,845 - api.py - task_logger - WARNING - 请求异常: HTTPSConnectionPool(host='api.jiandaoyun.com', port=443): Read timed out. (read timeout=10), 将重新请求
2025-10-23 17:35:28,869 - api.py - task_logger - INFO - 获取了3670条数据
2025-10-23 17:35:29,318 - api.py - task_logger - INFO - 获取了146条数据
2025-10-23 17:39:08,288 - api.py - task_logger - INFO - 获取了42941条数据
2025-10-23 17:39:30,025 - api.py - task_logger - INFO - 获取了4044条数据
2025-10-23 17:39:30,702 - 异常回访排查.py - task_logger - INFO - 开始运行SaaS异常回访
2025-10-23 17:39:30,857 - common_module.py - task_logger - INFO - 任务状态发送成功: {'data': {'creator': {'name': 'F6汽车科技', 'username': '#admin', 'status': 1, 'type': 0}, 'updater': {'name': 'F6汽车科技', 'username': '#admin', 'status': 1, 'type': 0}, 'deleter': None, 'createTime': '2025-10-23T09:39:31.658Z', 'updateTime': '2025-10-23T09:39:31.658Z', 'deleteTime': None, '_widget_1744873387500': '2025-10-23T00:00:00.000Z', '_widget_1743644977694': '异常服务待办派发', '_widget_1744873387501': '2025-10-23T09:35:00.000Z', '_widget_1744873387502': '2025-10-23T09:39:30.000Z', '_widget_1744873387504': '270', '_id': '68f9f7d31a14fafa3c3d62cb', 'appId': '6694d3c4fcb69ca9a111a6c4', 'entryId': '67ede908eb9c22261016466e'}}
2025-10-23 17:42:50,287 - api.py - task_logger - INFO - 获取了146条数据
2025-10-23 17:42:50,288 - 3381905813.py - task_logger - INFO - 数据加载完成
2025-10-23 17:43:17,224 - 3381905813.py - task_logger - INFO - 时间转换完成
2025-10-23 17:43:17,245 - 3381905813.py - task_logger - INFO - 人员转换完成
2025-10-23 17:46:55,514 - 异常回访排查.py - task_logger - INFO - 开始运行SaaS异常回访
2025-10-23 17:46:55,662 - common_module.py - task_logger - INFO - 任务状态发送成功: {'data': {'creator': {'name': 'F6汽车科技', 'username': '#admin', 'status': 1, 'type': 0}, 'updater': {'name': 'F6汽车科技', 'username': '#admin', 'status': 1, 'type': 0}, 'deleter': None, 'createTime': '2025-10-23T09:46:56.461Z', 'updateTime': '2025-10-23T09:46:56.461Z', 'deleteTime': None, '_widget_1744873387500': '2025-10-23T00:00:00.000Z', '_widget_1743644977694': '异常服务待办派发', '_widget_1744873387501': '2025-10-23T09:46:55.000Z', '_widget_1744873387502': '2025-10-23T09:46:55.000Z', '_widget_1744873387504': '0', '_id': '68f9f99039b7e0a47e88475b', 'appId': '6694d3c4fcb69ca9a111a6c4', 'entryId': '67ede908eb9c22261016466e'}}
2025-10-23 17:50:48,282 - common_module.py - task_logger - INFO - 任务错误发生成功: {'data': {'creator': {'name': 'F6汽车科技', 'username': '#admin', 'status': 1, 'type': 0}, 'updater': {'name': 'F6汽车科技', 'username': '#admin', 'status': 1, 'type': 0}, 'deleter': None, 'createTime': '2025-10-23T09:50:49.086Z', 'updateTime': '2025-10-23T09:50:49.086Z', 'deleteTime': None, '_widget_1744873387500': '2025-10-23T00:00:00.000Z', '_widget_1743644977694': '异常服务待办派发', '_widget_1744873387501': '2025-10-23T09:50:48.000Z', '_widget_1744873387502': '2025-10-23T09:50:48.000Z', '_widget_1744873387504': '0', '_widget_1754981992215': "'NoneType' object has no attribute 'astype'", '_id': '68f9fa7990af7e45f306b10a', 'appId': '6694d3c4fcb69ca9a111a6c4', 'entryId': '689ae65da00c17578e27cd74'}}
2025-10-23 17:51:08,186 - common_module.py - task_logger - INFO - 任务错误发生成功: {'data': {'creator': {'name': 'F6汽车科技', 'username': '#admin', 'status': 1, 'type': 0}, 'updater': {'name': 'F6汽车科技', 'username': '#admin', 'status': 1, 'type': 0}, 'deleter': None, 'createTime': '2025-10-23T09:51:08.994Z', 'updateTime': '2025-10-23T09:51:08.994Z', 'deleteTime': None, '_widget_1744873387500': '2025-10-23T00:00:00.000Z', '_widget_1743644977694': '异常服务待办派发', '_widget_1744873387501': '2025-10-23T09:51:07.000Z', '_widget_1744873387502': '2025-10-23T09:51:08.000Z', '_widget_1744873387504': '1', '_widget_1754981992215': "'NoneType' object has no attribute 'astype'", '_id': '68f9fa8c90af7e45f306bd1b', 'appId': '6694d3c4fcb69ca9a111a6c4', 'entryId': '689ae65da00c17578e27cd74'}}
+30 -22
View File
@@ -526,8 +526,8 @@
{
"metadata": {
"ExecuteTime": {
"end_time": "2025-10-15T07:14:36.277142Z",
"start_time": "2025-10-15T07:14:11.975620Z"
"end_time": "2025-10-23T09:43:17.547186Z",
"start_time": "2025-10-23T09:42:48.434237Z"
}
},
"cell_type": "code",
@@ -583,8 +583,9 @@
" self.load_all_data()\n",
" logger.info(f\"数据加载完成\")\n",
"\n",
" data_NGV_j = common_module.get_ngv_details(days_back=2)\n",
" data_NGV_j1 = common_module.get_ngv_details(days_back=3)\n",
" data_NGV_j = common_module.get_ngv_details(days_back=1)\n",
" data_NGV_j.to_csv(os.path.join(output_dir, f\"data_NGV_j.csv\"), index=False)\n",
" data_NGV_j1 = common_module.get_ngv_details(days_back=2)\n",
"\n",
" # 找出在 data_NGV_j 中存在但在 data_NGV_j1 中不存在的 data_id\n",
" unique_data_ids = data_NGV_j[~data_NGV_j['org_code'].isin(data_NGV_j1['org_code'])]\n",
@@ -642,7 +643,7 @@
" # all_data = [self.row_to_dict(row, self.field_mapping) for index, row in data_NGV_j1.iterrows()] # 前两天的全部数据\n",
" # all_data = [self.row_to_dict(row, self.field_mapping) for index, row in data_NGV_j.iterrows()] # 前一天的全部数据\n",
" all_data = [self.row_to_dict(row, self.field_mapping) for index, row in filtered_df.iterrows()] # 增量数据\n",
" filtered_df.to_csv(output_dir + \"\\\\filtered_df.csv\", index=False)\n",
" # filtered_df.to_csv(output_dir + \"\\\\filtered_df.csv\", index=False)\n",
"\n",
"\n",
" #\n",
@@ -779,92 +780,99 @@
],
"id": "6ce49b7686e91712",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"dfc264b77bee3205aaf2099572a46c57\n",
"已获取 100 条数据\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001B[92m2025-10-15 15:14:12,293 - api.py - task_logger - INFO - 获取了145条数据\u001B[0m\n"
"\u001B[92m2025-10-23 17:42:50,287 - api.py - task_logger - INFO - 获取了146条数据\u001B[0m\n",
"\u001B[92m2025-10-23 17:42:50,288 - 3381905813.py - task_logger - INFO - 数据加载完成\u001B[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"已获取 100 条数据\n",
"已获取 145 条数据\n"
"已获取 146 条数据\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001B[92m2025-10-15 15:14:12,294 - 4281365028.py - task_logger - INFO - 数据加载完成\u001B[0m\n",
"C:\\Users\\zy187\\AppData\\Local\\Temp\\ipykernel_5028\\4281365028.py:76: SettingWithCopyWarning: \n",
"C:\\Users\\zy187\\AppData\\Local\\Temp\\ipykernel_24808\\3381905813.py:77: SettingWithCopyWarning: \n",
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
"Try using .loc[row_indexer,col_indexer] = value instead\n",
"\n",
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
" filtered_df[col + '_date'] = (\n",
"C:\\Users\\zy187\\AppData\\Local\\Temp\\ipykernel_5028\\4281365028.py:76: SettingWithCopyWarning: \n",
"C:\\Users\\zy187\\AppData\\Local\\Temp\\ipykernel_24808\\3381905813.py:77: SettingWithCopyWarning: \n",
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
"Try using .loc[row_indexer,col_indexer] = value instead\n",
"\n",
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
" filtered_df[col + '_date'] = (\n",
"C:\\Users\\zy187\\AppData\\Local\\Temp\\ipykernel_5028\\4281365028.py:76: SettingWithCopyWarning: \n",
"C:\\Users\\zy187\\AppData\\Local\\Temp\\ipykernel_24808\\3381905813.py:77: SettingWithCopyWarning: \n",
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
"Try using .loc[row_indexer,col_indexer] = value instead\n",
"\n",
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
" filtered_df[col + '_date'] = (\n",
"C:\\Users\\zy187\\AppData\\Local\\Temp\\ipykernel_5028\\4281365028.py:76: SettingWithCopyWarning: \n",
"C:\\Users\\zy187\\AppData\\Local\\Temp\\ipykernel_24808\\3381905813.py:77: SettingWithCopyWarning: \n",
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
"Try using .loc[row_indexer,col_indexer] = value instead\n",
"\n",
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
" filtered_df[col + '_date'] = (\n",
"C:\\Users\\zy187\\AppData\\Local\\Temp\\ipykernel_5028\\4281365028.py:76: SettingWithCopyWarning: \n",
"C:\\Users\\zy187\\AppData\\Local\\Temp\\ipykernel_24808\\3381905813.py:77: SettingWithCopyWarning: \n",
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
"Try using .loc[row_indexer,col_indexer] = value instead\n",
"\n",
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
" filtered_df[col + '_date'] = (\n",
"C:\\Users\\zy187\\AppData\\Local\\Temp\\ipykernel_5028\\4281365028.py:76: SettingWithCopyWarning: \n",
"C:\\Users\\zy187\\AppData\\Local\\Temp\\ipykernel_24808\\3381905813.py:77: SettingWithCopyWarning: \n",
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
"Try using .loc[row_indexer,col_indexer] = value instead\n",
"\n",
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
" filtered_df[col + '_date'] = (\n",
"\u001B[92m2025-10-15 15:14:36,032 - 4281365028.py - task_logger - INFO - 时间转换完成\u001B[0m\n",
"C:\\Users\\zy187\\AppData\\Local\\Temp\\ipykernel_5028\\4281365028.py:102: SettingWithCopyWarning: \n",
"\u001B[92m2025-10-23 17:43:17,224 - 3381905813.py - task_logger - INFO - 时间转换完成\u001B[0m\n",
"C:\\Users\\zy187\\AppData\\Local\\Temp\\ipykernel_24808\\3381905813.py:103: SettingWithCopyWarning: \n",
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
"Try using .loc[row_indexer,col_indexer] = value instead\n",
"\n",
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
" filtered_df[col + \"_staff_id\"] = staff_ids\n",
"C:\\Users\\zy187\\AppData\\Local\\Temp\\ipykernel_5028\\4281365028.py:102: SettingWithCopyWarning: \n",
"C:\\Users\\zy187\\AppData\\Local\\Temp\\ipykernel_24808\\3381905813.py:103: SettingWithCopyWarning: \n",
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
"Try using .loc[row_indexer,col_indexer] = value instead\n",
"\n",
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
" filtered_df[col + \"_staff_id\"] = staff_ids\n",
"C:\\Users\\zy187\\AppData\\Local\\Temp\\ipykernel_5028\\4281365028.py:102: SettingWithCopyWarning: \n",
"C:\\Users\\zy187\\AppData\\Local\\Temp\\ipykernel_24808\\3381905813.py:103: SettingWithCopyWarning: \n",
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
"Try using .loc[row_indexer,col_indexer] = value instead\n",
"\n",
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
" filtered_df[col + \"_staff_id\"] = staff_ids\n",
"C:\\Users\\zy187\\AppData\\Local\\Temp\\ipykernel_5028\\4281365028.py:102: SettingWithCopyWarning: \n",
"C:\\Users\\zy187\\AppData\\Local\\Temp\\ipykernel_24808\\3381905813.py:103: SettingWithCopyWarning: \n",
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
"Try using .loc[row_indexer,col_indexer] = value instead\n",
"\n",
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
" filtered_df[col + \"_staff_id\"] = staff_ids\n",
"\u001B[92m2025-10-15 15:14:36,045 - 4281365028.py - task_logger - INFO - 人员转换完成\u001B[0m\n"
"\u001B[92m2025-10-23 17:43:17,245 - 3381905813.py - task_logger - INFO - 人员转换完成\u001B[0m\n"
]
}
],
"execution_count": 2
"execution_count": 1
}
],
"metadata": {