Files
2025-10-20 12:32:18 +08:00

156 lines
2.5 KiB
Python

# %%
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