first commit
This commit is contained in:
+269
@@ -0,0 +1,269 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pymysql\n",
|
||||
"import snowflake\n",
|
||||
"from faker import Faker\n",
|
||||
"fake = Faker('zh_CN')\n",
|
||||
"import random\n",
|
||||
"# 创建数据库连接\n",
|
||||
"connection = pymysql.connect(\n",
|
||||
"host='192.168.0.244',\n",
|
||||
"user='root',\n",
|
||||
"password='Abcd@123456',\n",
|
||||
"database='qy_school',\n",
|
||||
"charset='utf8'\n",
|
||||
")\n",
|
||||
"# 创建游标对象\n",
|
||||
"cursor = connection.cursor()\n",
|
||||
"sql=\"select * from student\"\n",
|
||||
"cursor.execute(sql)\n",
|
||||
"result=cursor.fetchall()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"sql=\"select * from student\"\n",
|
||||
"cursor.execute(sql)\n",
|
||||
"result=cursor.fetchall()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# ids = []\n",
|
||||
"# for item in result:\n",
|
||||
"# id = item[0]\n",
|
||||
"# ids.append(id)\n",
|
||||
"ids = [9131, 9135, 9139, 9140, 9141, 9142, 9151]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"sql = \"select * from t_camera\"\n",
|
||||
"cursor.execute(sql)\n",
|
||||
"camera=cursor.fetchall()\n",
|
||||
"channels = []"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"for item in camera:\n",
|
||||
" channels.append(item[17])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"'dffa5eac-49aa-48d2-a6c1-deedbff0b46a'"
|
||||
]
|
||||
},
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import uuid\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 18,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from requests import get,post\n",
|
||||
"import time\n",
|
||||
"from datetime import datetime\n",
|
||||
"\n",
|
||||
"ip = \"http://192.168.0.209:8101\"\n",
|
||||
"param = {\n",
|
||||
" \"username\": \"tangchao\",\n",
|
||||
" \"password\": \"123456a\",\n",
|
||||
" \"client_id\": \"client\",\n",
|
||||
" \"grant_type\": \"password\",\n",
|
||||
" \"client_secret\": \"123456\",\n",
|
||||
"}\n",
|
||||
"data = get(url=f\"{ip}/oauth/token\",params=param).json()\n",
|
||||
"token = data[\"access_token\"]\n",
|
||||
"header = {\n",
|
||||
" \"content-type\": \"application/json\",\n",
|
||||
" \"authorization\": f\"Bearer {token}\",\n",
|
||||
"}\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"'{\"success\":true,\"msg\":\"操作成功\",\"code\":0,\"data\":null}'"
|
||||
]
|
||||
},
|
||||
"execution_count": 21,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
},
|
||||
{
|
||||
"ename": "",
|
||||
"evalue": "",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[1;31m在当前单元格或上一个单元格中执行代码时 Kernel 崩溃。\n",
|
||||
"\u001b[1;31m请查看单元格中的代码,以确定故障的可能原因。\n",
|
||||
"\u001b[1;31m单击<a href='https://aka.ms/vscodeJupyterKernelCrash'>此处</a>了解详细信息。\n",
|
||||
"\u001b[1;31m有关更多详细信息,请查看 Jupyter <a href='command:jupyter.viewOutput'>log</a>。"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"times = datetime.now().strftime('%Y-%m-%d %H:%M:%S')\n",
|
||||
"count = random.randint(1, 4)\n",
|
||||
"channel = random.choice(channels)\n",
|
||||
"data = {\n",
|
||||
" \"batch_info\": {\n",
|
||||
" \"batch_id\": str(uuid.uuid4()),\n",
|
||||
" \"detected_image_path\":\"\",\n",
|
||||
" \"total_faces\": count,\n",
|
||||
" \"cameraid\": \"camera_001\",\n",
|
||||
" \"cameracode\": \"CAM001\"\n",
|
||||
" },\n",
|
||||
" \"results\":None\n",
|
||||
" }\n",
|
||||
"child = []\n",
|
||||
"for item in random.choices(ids, k=count):\n",
|
||||
" tem = {\n",
|
||||
" \"sim\": \"0.876\",\n",
|
||||
" \"simFaceurl\": \"\",\n",
|
||||
" \"baseFacesurl\": \"\",\n",
|
||||
" \"faceBaseid\": \"\",\n",
|
||||
" \"name\": \"\",\n",
|
||||
" \"sex\": \"\",\n",
|
||||
" \"empid\": f\"{item}\",\n",
|
||||
" \"telephone\": \"\",\n",
|
||||
" \"remark\": \"\",\n",
|
||||
" \"channel\": f\"{channel}\",\n",
|
||||
" \"ename\": \"Face\",\n",
|
||||
" \"cname\": \"人脸比对\",\n",
|
||||
" \"createtime\": times\n",
|
||||
" }\n",
|
||||
" child.append(tem)\n",
|
||||
"data[\"results\"] = child\n",
|
||||
"post(f\"{ip}/ai/stuface/receive\",json=data,headers=header).text"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 68,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"{'batch_info': {'batch_id': '6a6e425b-e3b5-46d8-8b53-4aa9f2f75fac',\n",
|
||||
" 'detected_image_path': 'https://cdn2.thedogapi.com/images/lQH1NRsGE.jpg',\n",
|
||||
" 'total_faces': 3,\n",
|
||||
" 'cameraid': 'camera_001',\n",
|
||||
" 'cameracode': 'CAM001'},\n",
|
||||
" 'results': [{'sim': '0.876',\n",
|
||||
" 'simFaceurl': '',\n",
|
||||
" 'baseFacesurl': '',\n",
|
||||
" 'faceBaseid': '',\n",
|
||||
" 'name': '',\n",
|
||||
" 'sex': '',\n",
|
||||
" 'empid': '9146',\n",
|
||||
" 'telephone': '',\n",
|
||||
" 'remark': '',\n",
|
||||
" 'channel': '12',\n",
|
||||
" 'ename': 'Face',\n",
|
||||
" 'cname': '人脸比对',\n",
|
||||
" 'createtime': '2025-10-14 19:05:30'},\n",
|
||||
" {'sim': '0.876',\n",
|
||||
" 'simFaceurl': '',\n",
|
||||
" 'baseFacesurl': '',\n",
|
||||
" 'faceBaseid': '',\n",
|
||||
" 'name': '',\n",
|
||||
" 'sex': '',\n",
|
||||
" 'empid': '9121',\n",
|
||||
" 'telephone': '',\n",
|
||||
" 'remark': '',\n",
|
||||
" 'channel': '12',\n",
|
||||
" 'ename': 'Face',\n",
|
||||
" 'cname': '人脸比对',\n",
|
||||
" 'createtime': '2025-10-14 19:05:30'},\n",
|
||||
" {'sim': '0.876',\n",
|
||||
" 'simFaceurl': '',\n",
|
||||
" 'baseFacesurl': '',\n",
|
||||
" 'faceBaseid': '',\n",
|
||||
" 'name': '',\n",
|
||||
" 'sex': '',\n",
|
||||
" 'empid': '9132',\n",
|
||||
" 'telephone': '',\n",
|
||||
" 'remark': '',\n",
|
||||
" 'channel': '12',\n",
|
||||
" 'ename': 'Face',\n",
|
||||
" 'cname': '人脸比对',\n",
|
||||
" 'createtime': '2025-10-14 19:05:30'}]}"
|
||||
]
|
||||
},
|
||||
"execution_count": 68,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"data"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "base",
|
||||
"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.12.4"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
||||
Reference in New Issue
Block a user