简道云成员id与字段监控分离

This commit is contained in:
z66
2025-08-28 11:03:46 +08:00
parent 5879eb7842
commit 2840d4871a
6 changed files with 951 additions and 169 deletions
+17 -9
View File
@@ -122,6 +122,7 @@
"} # 衡时数据库链接配置-mysql\n",
"table_name = \"thailand_store_data_email\" # 请替换为实际的表名\n",
"# table_name = \"yida_process_time_statistics\"\n",
"\n",
"# 连接\n",
"connection = mysql.connector.connect(\n",
" host=HS_DB_Config[\"host\"],\n",
@@ -130,12 +131,12 @@
" database=HS_DB_Config[\"database\"]\n",
")\n",
"\n",
"print(f\"成功连接 {HS_DB_Config[\"database\"]}\")\n",
"print(f\"成功连接 {HS_DB_Config['database']}\")\n",
"cursor = connection.cursor()\n",
"\n",
"# 读取Excel文件\n",
"df = pd.read_excel(\n",
" r\"C:\\Users\\Administrator.DESKTOP-7IC2USJ\\Downloads\\门店日使用数据Workshops_Daily_Usage_Data_20250805101517.xlsx\",\n",
" r\"C:\\Users\\Administrator.DESKTOP-7IC2USJ\\Downloads\\门店日使用数据Workshop's_Daily_Usage_Data_20250805101517.xlsx\",\n",
" sheet_name=\"Sheet1\")\n",
"\n",
"# 处理空值 - 将NaN/NaT/空字符串统一转为None\n",
@@ -146,16 +147,23 @@
"placeholders = ', '.join(['%s'] * len(df.columns))\n",
"insert_query = f\"INSERT INTO {table_name} ({columns}) VALUES ({placeholders})\"\n",
"\n",
"# 批量插入数据\n",
"# 批量插入数据,每次1000条\n",
"records = [tuple(row) for row in df.values]\n",
"cursor.executemany(insert_query, records)\n",
"connection.commit()\n",
"batch_size = 1000\n",
"total_records = len(records)\n",
"inserted_count = 0\n",
"\n",
"print(f\"成功导入 {cursor.rowcount} 条记录到 {table_name} 表\")\n",
"for i in range(0, total_records, batch_size):\n",
" batch = records[i:i+batch_size]\n",
" cursor.executemany(insert_query, batch)\n",
" connection.commit()\n",
" inserted_count += len(batch)\n",
" print(f\"已成功导入 {inserted_count}/{total_records} 条记录\")\n",
"\n",
"print(f\"总共成功导入 {inserted_count} 条记录到 {table_name} 表\")\n",
"\n",
"cursor.close()\n",
"\n",
"connection.close()\n"
"connection.close()"
],
"id": "a98f8dd324b53eeb",
"outputs": [
@@ -407,7 +415,7 @@
{
"metadata": {},
"cell_type": "markdown",
"source": "## 删除区间数据",
"source": "### 删除区间数据",
"id": "8192d432b3f65bc2"
},
{
+2
View File
@@ -22,3 +22,5 @@
2025-08-20 16:48:57,997 - 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-08-20T08:48:55.784Z', 'updateTime': '2025-08-20T08:48:55.784Z', 'deleteTime': None, '_widget_1744873387500': '2025-08-20T00:00:00.000Z', '_widget_1743644977694': '非标业绩提报转BI', '_widget_1744873387501': '2025-08-20T08:48:57.000Z', '_widget_1744873387502': '2025-08-20T08:48:57.000Z', '_widget_1744873387504': '0', '_id': '68a58bf734f6e13aec32ca2a', 'appId': '6694d3c4fcb69ca9a111a6c4', 'entryId': '67ede908eb9c22261016466e'}}
2025-08-20 16:58:28,211 - api.py - task_logger - INFO - 已获取 8 条数据
2025-08-20 16:58:29,045 - 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-08-20T08:58:26.821Z', 'updateTime': '2025-08-20T08:58:26.821Z', 'deleteTime': None, '_widget_1744873387500': '2025-08-20T00:00:00.000Z', '_widget_1743644977694': '非标业绩提报转BI', '_widget_1744873387501': '2025-08-20T08:58:28.000Z', '_widget_1744873387502': '2025-08-20T08:58:28.000Z', '_widget_1744873387504': '0', '_id': '68a58e326435007d9a859fa2', 'appId': '6694d3c4fcb69ca9a111a6c4', 'entryId': '67ede908eb9c22261016466e'}}
2025-08-27 11:11:22,356 - api.py - task_logger - INFO - 已获取 1 条数据
2025-08-27 11:11:49,228 - api.py - task_logger - INFO - 已获取 1 条数据
+202
View File
@@ -0,0 +1,202 @@
{
"cells": [
{
"metadata": {},
"cell_type": "markdown",
"source": "## 外部成员结构",
"id": "a58995e7e8657dce"
},
{
"cell_type": "code",
"id": "initial_id",
"metadata": {
"collapsed": true,
"ExecuteTime": {
"end_time": "2025-08-27T03:11:49.414114Z",
"start_time": "2025-08-27T03:11:49.016794Z"
}
},
"source": [
"from api import API\n",
"\n",
"api_instance = API()\n",
"\n",
"payload = {\n",
" \"api_key\": \"6694d3c4fcb69ca9a111a6c4\",\n",
" \"entry_id\": \"68ae76ddedae9bffae06a911\",\n",
"}\n",
"df = api_instance.entry_data_list(payload, replace=True)\n",
"print(df)"
],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001B[92m2025-08-27 11:11:49,228 - api.py - task_logger - INFO - 已获取 1 条数据\u001B[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"进行了替换\n",
"{'data': [{'creator': {'name': 'F6汽车科技', 'username': '#admin', 'status': 1, 'type': 0}, 'updater': {'name': 'F6汽车科技', 'username': '#admin', 'status': 1, 'type': 0}, 'deleter': None, 'createTime': '2025-08-27T03:09:49.522Z', 'updateTime': '2025-08-27T03:09:49.522Z', 'deleteTime': None, '成员单选': {'name': '申晨', 'username': 'R-688c8ba43678deccfcb5c386-jdy-jv71cd380jlj', 'status': 1, 'type': 2, 'departments': [-979913651]}, '成员多选': [{'name': '申晨', 'username': 'R-688c8ba43678deccfcb5c386-jdy-jv71cd380jlj', 'status': 1, 'type': 2, 'departments': [-979913651]}, {'name': '张阳', 'username': '4210192048793363', 'status': 1, 'type': 0, 'departments': [449008196], 'integrate_id': '4210192048793363'}], '_id': '68ae76fd74ad62855e55e195', 'appId': '6694d3c4fcb69ca9a111a6c4', 'entryId': '68ae76ddedae9bffae06a911'}]}\n"
]
}
],
"execution_count": 2
},
{
"metadata": {},
"cell_type": "markdown",
"source": "## 向表格内写入外部成员",
"id": "e311761d3eff6179"
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2025-08-27T03:13:40.574272Z",
"start_time": "2025-08-27T03:13:40.428525Z"
}
},
"cell_type": "code",
"source": [
"from api import API\n",
"\n",
"api_instance = API()\n",
"payload = {\n",
" \"api_key\": \"6694d3c4fcb69ca9a111a6c4\",\n",
" \"entry_id\": \"68ae76ddedae9bffae06a911\",\n",
" \"data\":{\"_widget_1756264157512\":{\"value\":\"R-688c8ba43678deccfcb5c386-jdy-jv71cd380jlj\"}}\n",
"}\n",
"dict = api_instance.data_batch_create(payload)\n",
"\n",
"print(dict)"
],
"id": "80256c669800af2f",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'data': {'creator': {'name': 'F6汽车科技', 'username': '#admin', 'status': 1, 'type': 0}, 'updater': {'name': 'F6汽车科技', 'username': '#admin', 'status': 1, 'type': 0}, 'deleter': None, 'createTime': '2025-08-27T03:13:40.349Z', 'updateTime': '2025-08-27T03:13:40.349Z', 'deleteTime': None, '_widget_1756264157512': {'name': '申晨', 'username': 'R-688c8ba43678deccfcb5c386-jdy-jv71cd380jlj', 'status': 1, 'type': 2, 'departments': [-979913651]}, '_widget_1756264157513': [], '_id': '68ae77e44b356b9bc83e338d', 'appId': '6694d3c4fcb69ca9a111a6c4', 'entryId': '68ae76ddedae9bffae06a911'}}\n"
]
}
],
"execution_count": 3
},
{
"metadata": {},
"cell_type": "markdown",
"source": "## 获取关联企业",
"id": "714a210b956fe262"
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2025-08-27T03:16:34.842344Z",
"start_time": "2025-08-27T03:16:34.456948Z"
}
},
"cell_type": "code",
"source": [
"import requests\n",
"import json\n",
"\n",
"url = \"https://api.jiandaoyun.com/api/v5/corp/guest/department/list\"\n",
"\n",
"headers = {\n",
" 'Authorization': 'Bearer qygHulymo1fekJk4CIZyNKjyQAzG8CFN',\n",
" 'Content-Type': 'application/json'\n",
"}\n",
"response = requests.post(url, headers=headers)\n",
"print(response.json())\n",
"dept_list = response.json().get(\"dept_list\",[])\n",
"for dept in dept_list:\n",
" print(dept.get(\"name\"))"
],
"id": "d14ea7a6ab8b00dc",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'dept_list': [{'dept_no': -12, 'name': 'CASTROL LIMITED', 'type': 2, 'status': 1}, {'dept_no': -979913650, 'name': '曹伟手机号注册所处公司', 'type': 2, 'status': 1}, {'dept_no': -979913651, 'name': '申晨', 'type': 2, 'status': 1}]}\n"
]
}
],
"execution_count": 5
},
{
"metadata": {},
"cell_type": "markdown",
"source": "## 获取关联企业对接人",
"id": "28355f7a1f5b7a3a"
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2025-08-27T03:19:09.922520Z",
"start_time": "2025-08-27T03:19:09.839699Z"
}
},
"cell_type": "code",
"source": [
"import requests\n",
"import json\n",
"url = \"https://api.jiandaoyun.com/api/v5/corp/guest/user/list\"\n",
"\n",
"\n",
"headers = {\n",
" 'Authorization': 'Bearer qygHulymo1fekJk4CIZyNKjyQAzG8CFN',\n",
" 'Content-Type': 'application/json'\n",
"}\n",
"\n",
"response = requests.post(url, headers=headers)\n",
"all_data = []\n",
"member_list = response.json().get(\"member_list\",[])\n",
"for member in member_list:\n",
" name = member.get(\"name\")\n",
" username = member.get(\"username\") # 用户id\n",
" all_data.append({\"name\":name,\"username\":username})\n"
],
"id": "11fd29cc47185320",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"sylvia7203@gmail.com\n",
"金鹏测试\n",
"曹伟手机号注册\n",
"葡萄\n",
"申晨\n"
]
}
],
"execution_count": 7
}
],
"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
}