first commit
This commit is contained in:
@@ -0,0 +1,155 @@
|
||||
# %%
|
||||
import pymysql
|
||||
import snowflake
|
||||
import random
|
||||
|
||||
# 创建数据库连接
|
||||
connection = pymysql.connect(
|
||||
host="192.168.0.244",
|
||||
user="root",
|
||||
password="Abcd@123456",
|
||||
database="qy_school",
|
||||
charset="utf8",
|
||||
)
|
||||
# 创建游标对象
|
||||
cursor = connection.cursor()
|
||||
sql = "select * from student"
|
||||
cursor.execute(sql)
|
||||
result = cursor.fetchall()
|
||||
|
||||
# %%
|
||||
sql = "select * from student"
|
||||
cursor.execute(sql)
|
||||
result = cursor.fetchall()
|
||||
|
||||
# %%
|
||||
ids = []
|
||||
for item in result:
|
||||
id = item[0]
|
||||
ids.append(id)
|
||||
ids = [
|
||||
9130,
|
||||
9131,
|
||||
9132,
|
||||
9133,
|
||||
9134,
|
||||
9121,
|
||||
9135,
|
||||
9136,
|
||||
9137,
|
||||
9138,
|
||||
9139,
|
||||
9140,
|
||||
9141,
|
||||
9142,
|
||||
9143,
|
||||
9122,
|
||||
9123,
|
||||
9144,
|
||||
9145,
|
||||
9146,
|
||||
9147,
|
||||
9148,
|
||||
9149,
|
||||
9124,
|
||||
9125,
|
||||
9150,
|
||||
9151,
|
||||
9152,
|
||||
9153,
|
||||
9154,
|
||||
9126,
|
||||
9155,
|
||||
9156,
|
||||
9127,
|
||||
9157,
|
||||
9158,
|
||||
9159,
|
||||
9160,
|
||||
9161,
|
||||
9162,
|
||||
9163,
|
||||
9164,
|
||||
9129,
|
||||
9128,
|
||||
9165,
|
||||
]
|
||||
|
||||
# %%
|
||||
random.choices(ids, k=4)
|
||||
|
||||
# %%
|
||||
sql = "select * from t_camera"
|
||||
cursor.execute(sql)
|
||||
camera = cursor.fetchall()
|
||||
channels = []
|
||||
|
||||
# %%
|
||||
for item in camera:
|
||||
channels.append(item[17])
|
||||
|
||||
# %%
|
||||
channels
|
||||
|
||||
# %%
|
||||
import uuid
|
||||
|
||||
# %%
|
||||
from requests import get, post
|
||||
import time
|
||||
from datetime import datetime
|
||||
|
||||
ip = "http://192.168.0.209:8101"
|
||||
param = {
|
||||
"username": "tangchao",
|
||||
"password": "123456a",
|
||||
"client_id": "client",
|
||||
"grant_type": "password",
|
||||
"client_secret": "123456",
|
||||
}
|
||||
data = get(
|
||||
url=f"http://band.hxzhxy.cn/oauth/token?username=zhongwei&password=123456a&client_id=client&grant_type=password&client_secret=123456"
|
||||
).json()
|
||||
token = data["access_token"]
|
||||
header = {
|
||||
"content-type": "application/json",
|
||||
"authorization": f"Bearer {token}",
|
||||
}
|
||||
|
||||
|
||||
# %%
|
||||
|
||||
# %%
|
||||
times = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
count = random.randint(1, 4)
|
||||
channel = random.choice(channels)
|
||||
data = {
|
||||
"batch_info": {
|
||||
"batch_id": str(uuid.uuid4()),
|
||||
"detected_image_path": "",
|
||||
"total_faces": count,
|
||||
"cameraid": "camera_001",
|
||||
"cameracode": "CAM001",
|
||||
},
|
||||
"results": None,
|
||||
}
|
||||
child = []
|
||||
for item in random.choices(ids, k=count):
|
||||
tem = {
|
||||
"sim": "0.876",
|
||||
"simFaceurl": "",
|
||||
"baseFacesurl": "",
|
||||
"faceBaseid": "",
|
||||
"name": "",
|
||||
"sex": "",
|
||||
"empid": f"{item}",
|
||||
"telephone": "",
|
||||
"remark": "",
|
||||
"channel": f"{channel}",
|
||||
"ename": "Face",
|
||||
"cname": "人脸比对",
|
||||
"createtime": times,
|
||||
}
|
||||
child.append(tem)
|
||||
data["results"] = child
|
||||
post(f"{ip}/ai/stuface/receive", json=data, headers=header).text
|
||||
@@ -0,0 +1,42 @@
|
||||
from requests import get, post, put, delete
|
||||
import random
|
||||
|
||||
|
||||
# v1.jinrishici.com/all.json
|
||||
def apiSentence():
|
||||
data = get("https://v1.hitokoto.cn").json()
|
||||
return data
|
||||
|
||||
|
||||
def cat():
|
||||
data = get("https://api.thecatapi.com/v1/images/search?size=full").json()
|
||||
result = data[0]["url"]
|
||||
return result
|
||||
|
||||
|
||||
def dog():
|
||||
data = get("https://api.thedogapi.com/v1/images/search?size=full").json()
|
||||
result = data[0]["url"]
|
||||
return result
|
||||
|
||||
|
||||
def pic():
|
||||
data = get("https://api.vvhan.com/api/bing?type=json&rand=sj").json()
|
||||
result = data["data"]["url"]
|
||||
return result
|
||||
|
||||
|
||||
def randomPic():
|
||||
func = random.choice([cat, dog, pic])
|
||||
data = func()
|
||||
return data
|
||||
|
||||
|
||||
def getEmoji():
|
||||
data = get("https://api.vvhan.com/api/emoji?type=json").json()
|
||||
return data
|
||||
|
||||
|
||||
def getShi():
|
||||
data = post("http://v1.jinrishici.com/all.json").json()
|
||||
return data
|
||||
@@ -0,0 +1,90 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "23e41b24",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from requests import get,post\n",
|
||||
"import time\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\"http://band.hxzhxy.cn/oauth/token?username=zhongwei&password=123456a&client_id=client&grant_type=password&client_secret=123456\").json()\n",
|
||||
"token = data[\"access_token\"]\n",
|
||||
"header = {\n",
|
||||
" \"content-type\": \"application/json\",\n",
|
||||
" \"authorization\": f\"Bearer {token}\",\n",
|
||||
"}"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"id": "5cba7a19",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from faker import Faker\n",
|
||||
"fake = Faker('zh_CN')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"id": "0df311dc",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"'刘想'"
|
||||
]
|
||||
},
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"fake.name()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "3f35dc8b",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"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": 5
|
||||
}
|
||||
+295
@@ -0,0 +1,295 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 15,
|
||||
"id": "37a75901",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from requests import get,post\n",
|
||||
"import time\n",
|
||||
"from datetime import datetime\n",
|
||||
"import random\n",
|
||||
"from faker import Faker\n",
|
||||
"fake = Faker('zh_CN')\n",
|
||||
"\n",
|
||||
"ip = \"http://192.168.0.205: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,
|
||||
"id": "a7d2614d",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"<Response [200]>"
|
||||
]
|
||||
},
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"id": "d4b6c72d",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"tem1 = {\n",
|
||||
"\"计算机科学与技术系\": [\"计算机科学与技术\", \"人工智能\", \"网络工程\", \"信息安全\"],\n",
|
||||
"\"电子信息工程系\": [\"电子信息工程\", \"通信工程\", \"微电子科学与工程\", \"物联网工程\"],\n",
|
||||
"\"工商管理系\": [\"工商管理\", \"市场营销\", \"会计学\", \"人力资源管理\"],\n",
|
||||
"\"汉语言文学系\": [\"汉语言文学\", \"汉语国际教育\", \"秘书学\", \"古典文献学\"],\n",
|
||||
"\"数学与应用数学系\": [\"数学与应用数学\", \"信息与计算科学\", \"统计学\", \"应用统计学\"],\n",
|
||||
"\"机械工程系\": [\"机械设计制造及其自动化\", \"机械电子工程\", \"工业设计\", \"车辆工程\"],\n",
|
||||
"\"护理学系\": [\"护理学\", \"助产学\", \"康复治疗学\", \"健康服务与管理\"],\n",
|
||||
"\"美术系\": [\"美术学\", \"视觉传达设计\", \"环境设计\", \"产品设计\"],\n",
|
||||
"\"英语系\": [\"英语\", \"翻译\", \"商务英语\", \"英语教育\"]\n",
|
||||
"}"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"id": "f64ccb9d",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"系 = list(tem1.keys())"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"id": "4ada0b6f",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"for item in 系:\n",
|
||||
" post(f\"{ip}/department/add\",json={\"isTrusted\":True,\"departmentName\":item,\"teamId\":106},headers=header)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"id": "01d61cd2",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"\n",
|
||||
"data = get(f\"{ip}/department/listPage?teamId=106&page=1&pageSize=15&pageNumber=1&sortField=create_time&sortOrder=asc\",headers=header).json()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"id": "6229db05",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"{'success': True,\n",
|
||||
" 'msg': '操作成功',\n",
|
||||
" 'code': 0,\n",
|
||||
" 'data': {'records': [{'id': 6,\n",
|
||||
" 'departmentName': '计算机科学与技术系',\n",
|
||||
" 'departmentDescription': None,\n",
|
||||
" 'teamId': 106,\n",
|
||||
" 'createTime': 1760930235000},\n",
|
||||
" {'id': 7,\n",
|
||||
" 'departmentName': '电子信息工程系',\n",
|
||||
" 'departmentDescription': None,\n",
|
||||
" 'teamId': 106,\n",
|
||||
" 'createTime': 1760930235000},\n",
|
||||
" {'id': 8,\n",
|
||||
" 'departmentName': '工商管理系',\n",
|
||||
" 'departmentDescription': None,\n",
|
||||
" 'teamId': 106,\n",
|
||||
" 'createTime': 1760930235000},\n",
|
||||
" {'id': 9,\n",
|
||||
" 'departmentName': '汉语言文学系',\n",
|
||||
" 'departmentDescription': None,\n",
|
||||
" 'teamId': 106,\n",
|
||||
" 'createTime': 1760930235000},\n",
|
||||
" {'id': 10,\n",
|
||||
" 'departmentName': '数学与应用数学系',\n",
|
||||
" 'departmentDescription': None,\n",
|
||||
" 'teamId': 106,\n",
|
||||
" 'createTime': 1760930235000},\n",
|
||||
" {'id': 11,\n",
|
||||
" 'departmentName': '机械工程系',\n",
|
||||
" 'departmentDescription': None,\n",
|
||||
" 'teamId': 106,\n",
|
||||
" 'createTime': 1760930235000},\n",
|
||||
" {'id': 12,\n",
|
||||
" 'departmentName': '护理学系',\n",
|
||||
" 'departmentDescription': None,\n",
|
||||
" 'teamId': 106,\n",
|
||||
" 'createTime': 1760930235000},\n",
|
||||
" {'id': 13,\n",
|
||||
" 'departmentName': '美术系',\n",
|
||||
" 'departmentDescription': None,\n",
|
||||
" 'teamId': 106,\n",
|
||||
" 'createTime': 1760930235000},\n",
|
||||
" {'id': 14,\n",
|
||||
" 'departmentName': '英语系',\n",
|
||||
" 'departmentDescription': None,\n",
|
||||
" 'teamId': 106,\n",
|
||||
" 'createTime': 1760930235000},\n",
|
||||
" {'id': 5,\n",
|
||||
" 'departmentName': '测试系',\n",
|
||||
" 'departmentDescription': None,\n",
|
||||
" 'teamId': 106,\n",
|
||||
" 'createTime': 1760930084000},\n",
|
||||
" {'id': 4,\n",
|
||||
" 'departmentName': '工程系3',\n",
|
||||
" 'departmentDescription': '111',\n",
|
||||
" 'teamId': 106,\n",
|
||||
" 'createTime': 1754041837000},\n",
|
||||
" {'id': 3,\n",
|
||||
" 'departmentName': '测试',\n",
|
||||
" 'departmentDescription': '1',\n",
|
||||
" 'teamId': 106,\n",
|
||||
" 'createTime': 1749464015000},\n",
|
||||
" {'id': 2,\n",
|
||||
" 'departmentName': '餐饮系',\n",
|
||||
" 'departmentDescription': '11',\n",
|
||||
" 'teamId': 106,\n",
|
||||
" 'createTime': 1749463271000},\n",
|
||||
" {'id': 1,\n",
|
||||
" 'departmentName': '维修系',\n",
|
||||
" 'departmentDescription': '1111',\n",
|
||||
" 'teamId': 106,\n",
|
||||
" 'createTime': 1749463235000}],\n",
|
||||
" 'total': 14,\n",
|
||||
" 'size': 15,\n",
|
||||
" 'current': 1,\n",
|
||||
" 'orders': [{'column': 'create_time', 'asc': False}],\n",
|
||||
" 'optimizeCountSql': True,\n",
|
||||
" 'hitCount': False,\n",
|
||||
" 'countId': None,\n",
|
||||
" 'maxLimit': None,\n",
|
||||
" 'searchCount': True,\n",
|
||||
" 'pages': 1}}"
|
||||
]
|
||||
},
|
||||
"execution_count": 14,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"data"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "55259610",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"{'departmentId': 6, 'majorId': 244483, 'majorName': '计算机科学与技术', 'departmentName': '计算机科学与技术系', 'teamId': 106}\n",
|
||||
"{'departmentId': 6, 'majorId': 631014, 'majorName': '人工智能', 'departmentName': '计算机科学与技术系', 'teamId': 106}\n",
|
||||
"{'departmentId': 6, 'majorId': 625683, 'majorName': '网络工程', 'departmentName': '计算机科学与技术系', 'teamId': 106}\n",
|
||||
"{'departmentId': 6, 'majorId': 195171, 'majorName': '信息安全', 'departmentName': '计算机科学与技术系', 'teamId': 106}\n",
|
||||
"{'departmentId': 7, 'majorId': 592554, 'majorName': '电子信息工程', 'departmentName': '电子信息工程系', 'teamId': 106}\n",
|
||||
"{'departmentId': 7, 'majorId': 696480, 'majorName': '通信工程', 'departmentName': '电子信息工程系', 'teamId': 106}\n",
|
||||
"{'departmentId': 7, 'majorId': 811129, 'majorName': '微电子科学与工程', 'departmentName': '电子信息工程系', 'teamId': 106}\n",
|
||||
"{'departmentId': 7, 'majorId': 679800, 'majorName': '物联网工程', 'departmentName': '电子信息工程系', 'teamId': 106}\n",
|
||||
"{'departmentId': 8, 'majorId': 615112, 'majorName': '工商管理', 'departmentName': '工商管理系', 'teamId': 106}\n",
|
||||
"{'departmentId': 8, 'majorId': 648476, 'majorName': '市场营销', 'departmentName': '工商管理系', 'teamId': 106}\n",
|
||||
"{'departmentId': 8, 'majorId': 365596, 'majorName': '会计学', 'departmentName': '工商管理系', 'teamId': 106}\n",
|
||||
"{'departmentId': 8, 'majorId': 410010, 'majorName': '人力资源管理', 'departmentName': '工商管理系', 'teamId': 106}\n",
|
||||
"{'departmentId': 9, 'majorId': 179179, 'majorName': '汉语言文学', 'departmentName': '汉语言文学系', 'teamId': 106}\n",
|
||||
"{'departmentId': 9, 'majorId': 992185, 'majorName': '汉语国际教育', 'departmentName': '汉语言文学系', 'teamId': 106}\n",
|
||||
"{'departmentId': 9, 'majorId': 474472, 'majorName': '秘书学', 'departmentName': '汉语言文学系', 'teamId': 106}\n",
|
||||
"{'departmentId': 9, 'majorId': 135227, 'majorName': '古典文献学', 'departmentName': '汉语言文学系', 'teamId': 106}\n",
|
||||
"{'departmentId': 10, 'majorId': 157669, 'majorName': '数学与应用数学', 'departmentName': '数学与应用数学系', 'teamId': 106}\n",
|
||||
"{'departmentId': 10, 'majorId': 594595, 'majorName': '信息与计算科学', 'departmentName': '数学与应用数学系', 'teamId': 106}\n",
|
||||
"{'departmentId': 10, 'majorId': 511729, 'majorName': '统计学', 'departmentName': '数学与应用数学系', 'teamId': 106}\n",
|
||||
"{'departmentId': 10, 'majorId': 685860, 'majorName': '应用统计学', 'departmentName': '数学与应用数学系', 'teamId': 106}\n",
|
||||
"{'departmentId': 11, 'majorId': 930995, 'majorName': '机械设计制造及其自动化', 'departmentName': '机械工程系', 'teamId': 106}\n",
|
||||
"{'departmentId': 11, 'majorId': 904085, 'majorName': '机械电子工程', 'departmentName': '机械工程系', 'teamId': 106}\n",
|
||||
"{'departmentId': 11, 'majorId': 839268, 'majorName': '工业设计', 'departmentName': '机械工程系', 'teamId': 106}\n",
|
||||
"{'departmentId': 11, 'majorId': 320346, 'majorName': '车辆工程', 'departmentName': '机械工程系', 'teamId': 106}\n",
|
||||
"{'departmentId': 12, 'majorId': 323085, 'majorName': '护理学', 'departmentName': '护理学系', 'teamId': 106}\n",
|
||||
"{'departmentId': 12, 'majorId': 149095, 'majorName': '助产学', 'departmentName': '护理学系', 'teamId': 106}\n",
|
||||
"{'departmentId': 12, 'majorId': 829054, 'majorName': '康复治疗学', 'departmentName': '护理学系', 'teamId': 106}\n",
|
||||
"{'departmentId': 12, 'majorId': 899144, 'majorName': '健康服务与管理', 'departmentName': '护理学系', 'teamId': 106}\n",
|
||||
"{'departmentId': 13, 'majorId': 378621, 'majorName': '美术学', 'departmentName': '美术系', 'teamId': 106}\n",
|
||||
"{'departmentId': 13, 'majorId': 339644, 'majorName': '视觉传达设计', 'departmentName': '美术系', 'teamId': 106}\n",
|
||||
"{'departmentId': 13, 'majorId': 840319, 'majorName': '环境设计', 'departmentName': '美术系', 'teamId': 106}\n",
|
||||
"{'departmentId': 13, 'majorId': 728411, 'majorName': '产品设计', 'departmentName': '美术系', 'teamId': 106}\n",
|
||||
"{'departmentId': 14, 'majorId': 328338, 'majorName': '英语', 'departmentName': '英语系', 'teamId': 106}\n",
|
||||
"{'departmentId': 14, 'majorId': 194601, 'majorName': '翻译', 'departmentName': '英语系', 'teamId': 106}\n",
|
||||
"{'departmentId': 14, 'majorId': 299315, 'majorName': '商务英语', 'departmentName': '英语系', 'teamId': 106}\n",
|
||||
"{'departmentId': 14, 'majorId': 210269, 'majorName': '英语教育', 'departmentName': '英语系', 'teamId': 106}\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"for item in data[\"data\"][\"records\"]:\n",
|
||||
" if item[\"departmentName\"] in 系:\n",
|
||||
" for item2 in tem1[item[\"departmentName\"]]:\n",
|
||||
" id = item[\"id\"]\n",
|
||||
" name = item[\"departmentName\"]\n",
|
||||
" post(f\"{ip}/major/add\",json={\"departmentId\":id,\"majorId\":random.randint(100000,999999),\"majorName\":item2,\"departmentName\":name,\"teamId\":106},headers=header)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "b60b65d7",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"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": 5
|
||||
}
|
||||
+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