- 新增websocket客户端和服务端实现 - 添加图片压缩工具和快速压缩脚本 - 实现学生信息处理相关API - 添加MQTT客户端和消息处理功能 - 更新.gitignore忽略更多文件类型 - 添加数据库操作工具和示例 - 实现多个测试脚本和工具类
15 KiB
15 KiB
In [ ]:
from requests import get,post
import time
import json
ip = "http://band.hxzhxy.cn"
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}",
}
# http://139.159.182.121:8092/card/findUser?bandNo=0269414644&controllerSN=233159158
data = get(f"https://band.hxzhxy.cn/card/listStuWithRule?gradeId=&classId=&screen=0¶m=&board=2&type=1¤tPage=1&pageNumber=0&pageSize=1000&pageTotal=593&teamId=110",headers=header).json()
stus2 = data["data"]["listData"]In [2]:
data = get(f"https://band.hxzhxy.cn/card/listStuWithRule?gradeId=&classId=&screen=0¶m=&board=2&type=1¤tPage=1&pageNumber=0&pageSize=1000&pageTotal=593&teamId=110",headers=header).json()
stus2 = data["data"]["listData"]In [3]:
import jsonIn [4]:
stus[0][1;31m---------------------------------------------------------------------------[0m [1;31mNameError[0m Traceback (most recent call last) Cell [1;32mIn[4], line 1[0m [1;32m----> 1[0m stus[[38;5;241m0[39m] [1;31mNameError[0m: name 'stus' is not defined
In [6]:
sns = [
{
"id": 12,
"serialNo": "233159161",
"teamId": 110,
"readHeadCount": 2,
"name": "1号通道",
"ip": "10.68.66.55",
"remark": "",
"online": 1,
"onlineTime": "2025-11-17 18:54:13",
"existingRules": [
{
"name": "全勤",
"id": 68,
"typeId": 155
},
{
"name": "学生临时规则-上晚自习",
"id": 69,
"typeId": 156
},
{
"name": "不上晚自习",
"id": 70,
"typeId": 157
}
]
},
{
"id": 16,
"serialNo": "233159158",
"teamId": 110,
"readHeadCount": 2,
"name": "2号道闸",
"ip": "10.68.66.56",
"remark": "",
"online": 1,
"onlineTime": "2025-11-17 18:54:14",
"existingRules": [
{
"name": "全勤",
"id": 68,
"typeId": 124
},
{
"name": "学生临时规则-上晚自习",
"id": 69,
"typeId": 125
},
{
"name": "不上晚自习",
"id": 70,
"typeId": 126
}
]
},
{
"id": 17,
"serialNo": "233159159",
"teamId": 110,
"readHeadCount": 2,
"name": "3号道闸",
"ip": "10.68.66.57",
"remark": "",
"online": 1,
"onlineTime": "2025-11-17 18:54:13",
"existingRules": [
{
"name": "学生临时规则-上晚自习",
"id": 69,
"typeId": 172
},
{
"name": "全勤",
"id": 68,
"typeId": 180
},
{
"name": "不上晚自习",
"id": 70,
"typeId": 183
}
]
},
{
"id": 18,
"serialNo": "233159157",
"teamId": 110,
"readHeadCount": 2,
"name": "4号道闸",
"ip": "10.68.66.58",
"remark": "",
"online": 1,
"onlineTime": "2025-11-17 18:54:13",
"existingRules": [
{
"name": "全勤",
"id": 68,
"typeId": 188
},
{
"name": "学生临时规则-上晚自习",
"id": 69,
"typeId": 189
},
{
"name": "不上晚自习",
"id": 70,
"typeId": 190
}
]
},
{
"id": 19,
"serialNo": "233159164",
"teamId": 110,
"readHeadCount": 2,
"name": "广告门",
"ip": "10.68.66.59",
"remark": "",
"online": 1,
"onlineTime": "2025-11-17 18:54:13",
"existingRules": [
{
"name": "全勤",
"id": 68,
"typeId": 191
},
{
"name": "学生临时规则-上晚自习",
"id": 69,
"typeId": 192
},
{
"name": "不上晚自习",
"id": 70,
"typeId": 193
}
]
}
]In [7]:
for sn in sns:
for stu in stus:
res = get( f"http://139.159.182.121:8092/card/findUser?bandNo={stu['手环号']}&controllerSN={sn['serialNo']}").json()
if res['success']:
result = json.loads(res['msg'])
flag = result['result']['success']
if flag:
pass
# print(f"{stu['姓名']} 有权限")
else:
print(f"{sn['name']} {stu['姓名']} 无权限")
1号通道 熊浩宇 无权限 1号通道 郭思垚 无权限 1号通道 雷林皓 无权限 1号通道 汪梓衡 无权限 1号通道 徐沐瑶 无权限 1号通道 方苇骐 无权限 2号道闸 熊浩宇 无权限 2号道闸 郭思垚 无权限 2号道闸 雷林皓 无权限 2号道闸 汪梓衡 无权限 2号道闸 方苇骐 无权限 3号道闸 熊浩宇 无权限 3号道闸 郭思垚 无权限 3号道闸 雷林皓 无权限 3号道闸 汪梓衡 无权限 3号道闸 徐沐瑶 无权限 3号道闸 方苇骐 无权限 4号道闸 熊浩宇 无权限 4号道闸 郭思垚 无权限 4号道闸 雷林皓 无权限 4号道闸 汪梓衡 无权限 4号道闸 徐沐瑶 无权限 4号道闸 方苇骐 无权限 广告门 熊浩宇 无权限 广告门 郭思垚 无权限 广告门 雷林皓 无权限 广告门 汪梓衡 无权限 广告门 徐沐瑶 无权限 广告门 方苇骐 无权限
In [31]:
import timeIn [32]:
while True:
data = get("https://www.hxzhxy.cn/hxyd-api/gate/card/list2?teamId=110&name=&screen=3&startDate=1763378175113&state=&endDate=1763378175113&type=0&gateNo=&pageSize=30&pageNumber=0&teaType=0&doorInfo=&access_token=e8ae9533-ebbe-4d14-8251-6a587ca40ac2").json()
for stu in data["data"]["content"]:
if stu["eventName"] !='正常刷卡开门':
print(stu['name'])
time.sleep(3)[1;31m在当前单元格或上一个单元格中执行代码时 Kernel 崩溃。 [1;31m请查看单元格中的代码,以确定故障的可能原因。 [1;31m单击<a href='https://aka.ms/vscodeJupyterKernelCrash'>此处</a>了解详细信息。 [1;31m有关更多详细信息,请查看 Jupyter <a href='command:jupyter.viewOutput'>log</a>。
In [21]:
len(list(stus))Out [21]:
251
In [22]:
251+38Out [22]:
289
In [17]:
for item in stus2:
if item["姓名"] in stus:
if item['晚自习']==2 :
tag='上晚自习'
else:
tag='不上晚自习'
print(f'{item["姓名"]} {tag}' )李翰玟 上晚自习 许睿 上晚自习 吕文轩 上晚自习 杨宇晨 上晚自习 赖馨玥 上晚自习 张成 上晚自习 佘锦宸 上晚自习 钟雅祺 上晚自习 罗凯玟 上晚自习 张翼然 上晚自习 贾玥彤 上晚自习 李晞彤 上晚自习 徐欣渝 上晚自习 王为 上晚自习 赖桔兴 上晚自习 龚跃鑫 上晚自习 郑好 上晚自习 苟恩瑞 上晚自习 顾子昂 上晚自习 符曾洋 上晚自习 吴嘉唐 上晚自习 张思雅 上晚自习 管子漩 上晚自习 张文杰 上晚自习 陈熙辰 上晚自习 代芸萱 上晚自习 刘星彤 上晚自习 肖茜茜 上晚自习 白益轩 上晚自习 冯靖 上晚自习 陈诗雨 上晚自习 周渤灵 上晚自习 李文斌 上晚自习 王震宇 上晚自习 王正豪 上晚自习 李漪诺 上晚自习 吴金龙 上晚自习 马鸿森 上晚自习
In [28]:
for sn in sns:
print(get(f"http://139.159.182.121:8092/card/getTime",params={"controllerSN":int(sn['serialNo'])}).text){"success":true,"msg":"操作成功","code":0,"data":null}
{"success":true,"msg":"操作成功","code":0,"data":null}
{"success":true,"msg":"操作成功","code":0,"data":null}
{"success":true,"msg":"操作成功","code":0,"data":null}
{"success":true,"msg":"操作成功","code":0,"data":null}