feat: 添加多个功能模块和工具脚本

- 新增websocket客户端和服务端实现
- 添加图片压缩工具和快速压缩脚本
- 实现学生信息处理相关API
- 添加MQTT客户端和消息处理功能
- 更新.gitignore忽略更多文件类型
- 添加数据库操作工具和示例
- 实现多个测试脚本和工具类
This commit is contained in:
2026-04-13 14:47:50 +08:00
parent 2cfd7c5a08
commit aac9f5934d
87 changed files with 216279 additions and 6519 deletions
+90 -71
View File
@@ -9,9 +9,10 @@
"source": [
"from requests import get,post\n",
"import time\n",
"import json\n",
"ip = \"http://band.hxzhxy.cn\"\n",
"param = {\n",
" \"username\": \"tangchao\",\n",
" \"username\": \"zhongwei\",\n",
" \"password\": \"123456a\",\n",
" \"client_id\": \"client\",\n",
" \"grant_type\": \"password\",\n",
@@ -22,14 +23,62 @@
"header = {\n",
" \"content-type\": \"application/json\",\n",
" \"authorization\": f\"Bearer {token}\",\n",
"}\n",
"teamId=110"
"}\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "87b0a73c",
"execution_count": 30,
"id": "e4f5ed31",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"9e6e0e24-67fd-4b7c-802a-b204ff4ca95c\n",
"{'success': True, 'msg': '操作成功', 'code': 0, 'data': {'id': 475, 'pwd': '{bcrypt}$2a$10$K7EdytUGmdkfGn.zvLlg3O62TV5hCptj83MGbweHK0jSw8kzZPZ2m', 'locked': False, 'enabled': True, 'role': {'id': 168, 'roleName': '鸿兴演示中学家长', 'description': None, 'priority': 10, 'createTime': 1622713421000, 'updateTime': 1659193585000, 'teamId': 106, 'type': 1}, 'teamId': 106, 'type': 3, 'authorities': [{'authority': '鸿兴演示中学家长'}], 'username': 'jz97621', 'password': '{bcrypt}$2a$10$K7EdytUGmdkfGn.zvLlg3O62TV5hCptj83MGbweHK0jSw8kzZPZ2m', 'accountNonExpired': True, 'accountNonLocked': True, 'credentialsNonExpired': True}}\n"
]
}
],
"source": [
"param={\n",
" \"username\": 17307283669,\n",
" \"password\": \"jz97621\",\n",
" \"client_id\": \"client\",\n",
" \"grant_type\": \"password\",\n",
" \"client_secret\": \"123456\",\n",
" \"login_type\": \"PHONE_USERNAME\"\n",
"}\n",
"token = get(\"https://band.hxzhxy.cn/oauth/token\",params=param).json()[\"access_token\"]\n",
"print(token)\n",
"data = get(f\"https://band.hxzhxy.cn/uc/account/current?access_token={token}\").json()\n",
"print(data)\n"
]
},
{
"cell_type": "code",
"execution_count": 33,
"id": "b9c253b1",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"fab765b1-46f0-4e2a-816b-ebdeb9d31cdf\n"
]
}
],
"source": [
"access_token=get(\"https://band.hxzhxy.cn/oauth/token?username=17307283669&password=2019240217HXYSZX&client_id=client&grant_type=password&client_secret=123456&login_type=PHONE_USERNAME\").json()[\"access_token\"]\n",
"print(access_token)"
]
},
{
"cell_type": "code",
"execution_count": 32,
"id": "9136ed38",
"metadata": {},
"outputs": [
{
@@ -38,90 +87,60 @@
"{'success': True,\n",
" 'msg': '操作成功',\n",
" 'code': 0,\n",
" 'data': {'id': 10914,\n",
" 'stuNo': '25040057',\n",
" 'stuName': '冯梓骏',\n",
" 'sex': 1,\n",
" 'classId': 499,\n",
" 'gradeId': 129,\n",
" 'seralNo': '3108683745',\n",
" 'score': 'A',\n",
" 'moralEducation': 'A',\n",
" 'userName': '25040057CDSPTSZXBRFX',\n",
" 'teamId': 110,\n",
" 'pid': None,\n",
" 'phone': None,\n",
" 'imgUrl': None,\n",
" 'openid': None,\n",
" 'boarder': 2,\n",
" 'wxPhone': '13540808459',\n",
" 'trust': 0,\n",
" 'userId': None,\n",
" 'stature': None,\n",
" 'weight': None,\n",
" 'wxPhones': None,\n",
" 'userIdse': None,\n",
" 'payUserId': '25082816140601002478',\n",
" 'payState': 3,\n",
" 'teaChild': 0,\n",
" 'openids': None,\n",
" 'casId': None,\n",
" 'board': 1,\n",
" 'chatOpenId': None,\n",
" 'chatOpenIds': None,\n",
" 'teamName': None,\n",
" 'gradeName': '2025级',\n",
" 'className': '导师11班',\n",
" 'sexName': None,\n",
" 'battery': None,\n",
" 'steps': None,\n",
" 'rank': None,\n",
" 'roleName': None,\n",
" 'sleepStart': None,\n",
" 'sleepEnd': None,\n",
" 'type': None,\n",
" 'setTime': None,\n",
" 'status': None,\n",
" 'userType': None,\n",
" 'sumLocation': None,\n",
" 'arkName': None}}"
" 'data': {'id': 5454,\n",
" 'pwd': '{bcrypt}$2a$10$I66PBUWdeoWYh/FcGfhB1O2T1a8NJOpFB8YVZtScmH3YO7tNzuSBm',\n",
" 'locked': False,\n",
" 'enabled': True,\n",
" 'role': {'id': 168,\n",
" 'roleName': '鸿兴演示中学家长',\n",
" 'description': None,\n",
" 'priority': 10,\n",
" 'createTime': 1622713421000,\n",
" 'updateTime': 1659193585000,\n",
" 'teamId': 106,\n",
" 'type': 1},\n",
" 'teamId': 106,\n",
" 'type': 3,\n",
" 'authorities': [{'authority': '鸿兴演示中学家长'}],\n",
" 'username': '2019240217HXYSZX',\n",
" 'password': '{bcrypt}$2a$10$I66PBUWdeoWYh/FcGfhB1O2T1a8NJOpFB8YVZtScmH3YO7tNzuSBm',\n",
" 'accountNonExpired': True,\n",
" 'accountNonLocked': True,\n",
" 'credentialsNonExpired': True}}"
]
},
"execution_count": 3,
"execution_count": 32,
"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": [
"get(f\"{ip}/uc/student/findBySerialNo\",params={\n",
" \"teamId\":teamId,\n",
" \"param\":\"3108683745\"\n",
"},headers=header).json()"
"get(f\"https://band.hxzhxy.cn/uc/account/current?access_token={access_token}\").json()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "96366a8b",
"id": "ffcb6b87",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"{'success': False, 'msg': '非法访问,没有认证', 'code': 10007, 'data': None}"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "base",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,74 @@
# %%
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&param=&board=&type=1&currentPage=1&pageNumber=0&pageSize=1000&pageTotal=593&teamId=110",headers=header).json()
stus2 = data["data"]["listData"]
# %%
incorrect_students = []
for stu in stus2:
night_study = stu['晚自习']
band_no = stu['手环号']
url = f"http://139.159.182.121:8092/card/findUser?bandNo={band_no}&controllerSN=233159164"
try:
response = get(url)
result = response.json()
if result.get('success') and result.get('msg'):
try:
msg_data = json.loads(result['msg'])
permissions = msg_data.get('result', {}).get('权限', [])
if permissions:
permission = permissions[0]
door1_time = permission.get('1号门控制时段', -1)
expected_time = 9 if night_study == 2 else 16
if door1_time != expected_time:
incorrect_students.append({
'姓名': stu.get('姓名', '未知'),
'手环号': band_no,
'晚自习': night_study,
'实际1号门控制时段': door1_time,
'应该的1号门控制时段': expected_time
})
except json.JSONDecodeError:
print(f"解析JSON失败: {result.get('msg')}")
else:
print(f"请求失败: {result}")
except Exception as e:
print(f"请求异常 {band_no}: {e}")
print("\n" + "="*80)
print("检测结果:")
print("="*80)
if incorrect_students:
print(f"\n发现 {len(incorrect_students)} 个学生权限配置不正确:\n")
for i, student in enumerate(incorrect_students, 1):
print(f"{i}. 姓名: {student['姓名']}, 手环号: {student['手环号']}")
print(f" 晚自习配置: {student['晚自习']} (2=上, 1=不上)")
print(f" 实际1号门控制时段: {student['实际1号门控制时段']}")
print(f" 应该的1号门控制时段: {student['应该的1号门控制时段']}")
print()
else:
print("\n所有学生权限配置正确!")
File diff suppressed because one or more lines are too long
+765
View File
@@ -0,0 +1,765 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from paho.mqtt import client as mqtt\n",
"import json\n",
"import time\n",
"from requests import get,post,delete"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"broker = '100.64.0.6'\n",
"# broker = '192.168.0.111'\n",
"ip = \"http://100.64.0.6:9008\"\n",
"port = 1883\n",
"topic = \"/python/mqtt\"\n",
"client_id = f'python-mqtt-demo'"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# MQTT客户端的回调函数\n",
"def on_connect(client, userdata, flags, rc):\n",
" print(\"Connected with result code \"+str(rc))\n",
" # 连接成功后订阅主题\n",
" # client.subscribe(\"#\")\n",
"\n",
"def on_message(client, userdata, msg):\n",
" print(msg.topic+\" \"+str(msg.payload))\n",
"\n",
"# 创建MQTT客户端实例\n",
"client = mqtt.Client(client_id=client_id)\n",
"\n",
"# 绑定回调函数\n",
"client.on_connect = on_connect\n",
"client.on_message = on_message\n",
"\n",
"# 连接到MQTT代理\n",
"client.connect(broker, port, 60)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<paho.mqtt.client.MQTTMessageInfo at 0x201f147c7c0>"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"client.publish(\"demo/python\", \"Hello World!\")"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"token = post(f\"{ip}/login\",json={\"username\":\"admin\",\"password\":\"admin123\"}).json()[\"token\"]"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"headers = {\"Authorization\":f\"Bearer {token}\"}"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"records = get(f\"{ip}/school/devices/listPage?temaId=19&groupId=0&pageNum=1&pageSize=40\",headers=headers).json()[\"data\"][\"records\"]"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"macs =[]\n",
"for item in records:\n",
" macs.append(item.get(\"machineCode\", \"\"))"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"#在线\n",
"onlines = []\n",
"offlines=[]\n",
"for item in records:\n",
" if item.get(\"online\",0)==1:\n",
" onlines.append(item['machineCode'])\n",
" else:\n",
" offlines.append(item['machineCode'])"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(onlines)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(offlines)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[{'machineCode': '20254c7802bd',\n",
" 'displayName': '七步洗手法',\n",
" 'ip': '192.168.8.10',\n",
" 'groupId': 1,\n",
" 'contentId': 86,\n",
" 'updateTime': '2025-10-28T09:15:36',\n",
" 'version': '1.0.50',\n",
" 'deviceName': '食堂门口',\n",
" 'groupName': '食堂',\n",
" 'createTime': '2025-10-26T08:58:36',\n",
" 'teamId': 19,\n",
" 'online': 0,\n",
" 'location': '食堂门口',\n",
" 'id': 'cade19b0-1f2d-4c9c-8289-c7741d56bb0b'},\n",
" {'machineCode': '20254c9856bf',\n",
" 'displayName': '七步洗手法',\n",
" 'ip': '192.168.8.3',\n",
" 'groupId': 30,\n",
" 'contentId': 86,\n",
" 'updateTime': '2025-10-28T10:34:34',\n",
" 'version': '1.0.50',\n",
" 'deviceName': '3楼一体机',\n",
" 'groupName': '教学楼',\n",
" 'createTime': '2025-10-12T17:58:33',\n",
" 'teamId': 19,\n",
" 'online': 1,\n",
" 'location': '3楼',\n",
" 'id': '9b876939-9258-4c87-a2f9-d4a61459e8ab'},\n",
" {'machineCode': '20254c823347',\n",
" 'displayName': '七步洗手法',\n",
" 'ip': '192.168.8.2',\n",
" 'groupId': 30,\n",
" 'contentId': 86,\n",
" 'updateTime': '2025-10-28T10:22:24',\n",
" 'version': '1.0.50',\n",
" 'deviceName': '2楼一体机',\n",
" 'groupName': '教学楼',\n",
" 'createTime': '2025-10-12T17:51:30',\n",
" 'teamId': 19,\n",
" 'online': 0,\n",
" 'location': '2楼',\n",
" 'id': '1c25761c-5917-4c2b-af42-f3cc258e6957'}]"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"records"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 升级"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<paho.mqtt.client.MQTTMessageInfo at 0x1b5acdeda90>"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"topic = \"common/publicizeTelevision/00e066fd87b1/ota/upgrade\"\n",
"client.publish(topic,\"1\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"for item in macs:\n",
" topic = f\"common/publicizeTelevision/{item}/ota/upgrade\"\n",
" client.publish(topic,\"1\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 看门狗"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0 00e066fd898e\n",
"1 000000000001\n",
"2 00e0b413c78b\n",
"3 00e066fd86c5\n",
"4 000000000000\n",
"5 00e066fd8711\n",
"6 00e066fd8782\n",
"7 00e066fd87b1\n",
"8 00e066fd898d\n",
"9 00e066fd8710\n",
"10 00e066fd87ad\n",
"11 00e066fd890b\n",
"12 00e066fd882d\n",
"13 00e066fd61fc\n",
"14 00e066fd8927\n",
"15 00e066fd898c\n",
"16 00e066fd890c\n",
"17 00e066fd86c4\n",
"18 00e066fd8981\n",
"19 00e066fd87af\n",
"20 00e066fd891f\n",
"21 000ec6431230\n",
"22 00e066fd8988\n",
"23 00e066fd8832\n",
"24 00e066fd870d\n",
"25 00e066fd8990\n",
"26 00e066fd883a\n",
"27 00e066fd882f\n",
"28 00e066fd87b4\n",
"29 00e066fd8989\n",
"30 00e066fd8986\n",
"31 00e066fd8797\n",
"32 00e066fd898b\n",
"33 00e066fd8931\n"
]
}
],
"source": [
"for item,index in enumerate(macs):\n",
" print(item,index)\n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# netsh interface ipv4 set address name=\"以太网\" source=static address=192.168.0.110 mask=255.255.255.0 gateway=192.168.0.1"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'00E066FD8782'"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"'00e066fd8782'.upper()"
]
},
{
"cell_type": "code",
"execution_count": 45,
"metadata": {},
"outputs": [],
"source": [
"for index,item in enumerate(macs):\n",
" time.sleep(1)\n",
" topic = f\"cmd/publicizeTelevision/{item}/dog\"\n",
" message = {\"name\":\"watchDog.exe\",\"url\":\"http://schoolserver.com:9008/common/download/app/watchDog.exe\",\"type\":\"down\"}\n",
" client.publish(topic,json.dumps(message,ensure_ascii=False))"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<paho.mqtt.client.MQTTMessageInfo at 0x2015292bfb0>"
]
},
"execution_count": 30,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"topic = f\"cmd/publicizeTelevision/000c290a0fcb/dog\"\n",
"message = {\"name\":\"watchDog.exe\",\"url\":\"http://schoolserver.com:9008/common/download/app/watchDog.exe\",\"type\":\"down\"}\n",
"client.publish(topic,json.dumps(message,ensure_ascii=False))"
]
},
{
"cell_type": "code",
"execution_count": 77,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"<>:3: SyntaxWarning: invalid escape sequence '\\S'\n",
"<>:3: SyntaxWarning: invalid escape sequence '\\S'\n",
"C:\\Users\\Administrator\\AppData\\Local\\Temp\\ipykernel_8436\\3533498662.py:3: SyntaxWarning: invalid escape sequence '\\S'\n",
" message = '''reg query \"HKLM\\SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Run\"'''\n"
]
}
],
"source": [
"for item in macs:\n",
" topic = f\"cmd/publicizeTelevision/{item}/cmd\"\n",
" message = '''reg query \"HKLM\\SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Run\"'''\n",
"\n",
" client.publish(topic,message)"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
"for item in macs:\n",
" topic = f\"cmd/publicizeTelevision/{item}/cmd\"\n",
" message = '''systeminfo'''\n",
" client.publish(topic,message)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# cmd"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"for item in macs:\n",
" topic = f\"cmd/televisionDog/{item.upper()}/ask\"\n",
" client.publish(topic,\"1\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'00E066FD8832'"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"'00e066fd8832'.upper()"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<paho.mqtt.client.MQTTMessageInfo at 0x20d4b920e00>"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"topic = f\"cmd/televisionDog/00E066FD8832/ask\"\n",
"client.publish(topic,\"1\")"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<paho.mqtt.client.MQTTMessageInfo at 0x21087171c60>"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# netsh interface ipv4 set address name=\"以太网\" source=static address=13.1.1.125 mask=255.255.255.0 gateway=13.1.1.1\n",
"# message = {\n",
"# \"common\":['netsh interface ipv4 set address name=\"以太网\" source=static address=13.1.1.119 mask=255.255.255.0 gateway=13.1.1.1','ping 13.1.1.1','shutdown /r /t 00']\n",
"# }\n",
"message = {\n",
" \"common\":['netsh interface ipv4 set address name=\"以太网\" source=static address=13.1.1.115 mask=255.255.255.0 gateway=13.1.1.1 & ping 13.1.1.1 & shutdown /r /t 00']\n",
"}\n",
"client.publish(\"cmd/televisionDog/00E066FD882D/common\",json.dumps(message, ensure_ascii=False))"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
"for item in macs:\n",
" topic = f\"cmd/televisionDog/{item.upper()}/common\"\n",
" message = {\n",
" \"common\":['''slmgr /skms 10.19.64.158 & slmgr /ato''']\n",
"}\n",
" client.publish(topic,json.dumps(message, ensure_ascii=False))"
]
},
{
"cell_type": "code",
"execution_count": 85,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"<>:4: SyntaxWarning: invalid escape sequence '\\S'\n",
"<>:4: SyntaxWarning: invalid escape sequence '\\S'\n",
"C:\\Users\\Administrator\\AppData\\Local\\Temp\\ipykernel_8436\\2368358595.py:4: SyntaxWarning: invalid escape sequence '\\S'\n",
" \"common\":['''reg query \"HKLM\\SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Run\"''']\n"
]
}
],
"source": [
"for item in macs:\n",
" topic = f\"cmd/televisionDog/{item.upper()}/common\"\n",
" message = {\n",
" \"common\":['''reg query \"HKLM\\SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Run\"''']\n",
"}\n",
" client.publish(topic,json.dumps(message, ensure_ascii=False))"
]
},
{
"cell_type": "code",
"execution_count": 90,
"metadata": {},
"outputs": [],
"source": [
"\n",
"for item in macs:\n",
" topic = f\"cmd/televisionDog/{item.upper()}/common\"\n",
" message = {\n",
" \"common\":[\"tasklist | findstr \\\"校宣机程序\\\"\"]\n",
"}\n",
" client.publish(topic,json.dumps(message, ensure_ascii=False))"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<paho.mqtt.client.MQTTMessageInfo at 0x201c062b510>"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"message = {\n",
" \"common\":[\"ping 13.1.1.124\"]\n",
"}\n",
"\n",
"client.publish(\"cmd/televisionDog/00E066FD898E/common\",json.dumps(message, ensure_ascii=False))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"macs =['00e066fd883a']"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
"data = {\"macs\":[\"00e0b413c78b\",\"00e066fd86c5\",\"00e066fd8711\",\"00e066fd8782\",\"00e066fd87b1\",\"00e066fd898d\",\"00e066fd8710\",\"00e066fd87ad\",\"00e066fd890b\",\"00e066fd882d\",\"00e066fd61fc\",\"00e066fd8927\",\"00e066fd898c\",\"00e066fd890c\",\"00e066fd86c4\",\"00e066fd8981\",\"00e066fd87af\",\"00e066fd891f\",\"000ec6431230\",\"00e066fd8988\",\"00e066fd8832\",\"00e066fd870d\",\"00e066fd8990\",\"00e066fd883a\",\"00e066fd882f\",\"00e066fd87b4\",\"00e066fd8989\",\"00e066fd8986\",\"00e066fd8797\",\"00e066fd898b\",\"00e066fd8931\"],\"ips\":[\"13.1.1.120\",\"13.1.1.119\",\"13.1.1.125\",\"13.1.1.124\",\"13.1.1.126\",\"13.1.1.131\",\"13.1.1.127\",\"13.1.1.129\",\"13.1.1.117\",\"13.1.1.180\",\"13.1.1.114\",\"13.1.1.116\",\"13.1.1.118\",\"13.1.1.104\",\"13.1.1.113\",\"13.1.1.139\",\"13.1.1.136\",\"13.1.1.111\",\"13.1.1.102\",\"13.1.1.108\",\"13.1.1.110\",\"13.1.1.132\",\"13.1.1.130\",\"13.1.1.122\",\"13.1.1.123\",\"13.1.1.112\",\"13.1.1.107\",\"13.1.1.109\",\"13.1.1.115\",\"13.1.1.105\",\"13.1.1.135\"]}"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [],
"source": [
"tem = []\n",
"for index,item in enumerate(data[\"macs\"]):\n",
" tem.append({\"mac\":item,\"ip\":data[\"ips\"][index]})"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[{'mac': '00e0b413c78b', 'ip': '13.1.1.120'},\n",
" {'mac': '00e066fd86c5', 'ip': '13.1.1.119'},\n",
" {'mac': '00e066fd8711', 'ip': '13.1.1.125'},\n",
" {'mac': '00e066fd8782', 'ip': '13.1.1.124'},\n",
" {'mac': '00e066fd87b1', 'ip': '13.1.1.126'},\n",
" {'mac': '00e066fd898d', 'ip': '13.1.1.131'},\n",
" {'mac': '00e066fd8710', 'ip': '13.1.1.127'},\n",
" {'mac': '00e066fd87ad', 'ip': '13.1.1.129'},\n",
" {'mac': '00e066fd890b', 'ip': '13.1.1.117'},\n",
" {'mac': '00e066fd882d', 'ip': '13.1.1.180'},\n",
" {'mac': '00e066fd61fc', 'ip': '13.1.1.114'},\n",
" {'mac': '00e066fd8927', 'ip': '13.1.1.116'},\n",
" {'mac': '00e066fd898c', 'ip': '13.1.1.118'},\n",
" {'mac': '00e066fd890c', 'ip': '13.1.1.104'},\n",
" {'mac': '00e066fd86c4', 'ip': '13.1.1.113'},\n",
" {'mac': '00e066fd8981', 'ip': '13.1.1.139'},\n",
" {'mac': '00e066fd87af', 'ip': '13.1.1.136'},\n",
" {'mac': '00e066fd891f', 'ip': '13.1.1.111'},\n",
" {'mac': '000ec6431230', 'ip': '13.1.1.102'},\n",
" {'mac': '00e066fd8988', 'ip': '13.1.1.108'},\n",
" {'mac': '00e066fd8832', 'ip': '13.1.1.110'},\n",
" {'mac': '00e066fd870d', 'ip': '13.1.1.132'},\n",
" {'mac': '00e066fd8990', 'ip': '13.1.1.130'},\n",
" {'mac': '00e066fd883a', 'ip': '13.1.1.122'},\n",
" {'mac': '00e066fd882f', 'ip': '13.1.1.123'},\n",
" {'mac': '00e066fd87b4', 'ip': '13.1.1.112'},\n",
" {'mac': '00e066fd8989', 'ip': '13.1.1.107'},\n",
" {'mac': '00e066fd8986', 'ip': '13.1.1.109'},\n",
" {'mac': '00e066fd8797', 'ip': '13.1.1.115'},\n",
" {'mac': '00e066fd898b', 'ip': '13.1.1.105'},\n",
" {'mac': '00e066fd8931', 'ip': '13.1.1.135'}]"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"tem"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#调整轮播间隔"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"for item in macs:\n",
" topic = f\"cmd/publicizeTelevision/{item}/setting\"\n",
" message = {\n",
" \"data\":60000\n",
" }\n",
"\n",
" client.publish(topic,json.dumps(message, ensure_ascii=False))"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['00e0220fa0e4', '20254c7802bd', '20254c9856bf', '20254c823347']"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"macs"
]
}
],
"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
}
@@ -0,0 +1,33 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "0b9fa088",
"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
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,469 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "853a3284",
"metadata": {},
"outputs": [],
"source": [
"from requests import get,post\n",
"import time\n",
"import json\n",
"ip = \"http://band.hxzhxy.cn\"\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",
"}\n",
"# http://139.159.182.121:8092/card/findUser?bandNo=0269414644&controllerSN=233159158\n",
"data = get(f\"https://band.hxzhxy.cn/card/listStuWithRule?gradeId=&classId=&screen=0&param=&board=2&type=1&currentPage=1&pageNumber=0&pageSize=1000&pageTotal=593&teamId=110\",headers=header).json()\n",
"stus2 = data[\"data\"][\"listData\"]"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "4bbd5102",
"metadata": {},
"outputs": [],
"source": [
"data = get(f\"https://band.hxzhxy.cn/card/listStuWithRule?gradeId=&classId=&screen=0&param=&board=2&type=1&currentPage=1&pageNumber=0&pageSize=1000&pageTotal=593&teamId=110\",headers=header).json()\n",
"stus2 = data[\"data\"][\"listData\"]"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "24f76d62",
"metadata": {},
"outputs": [],
"source": [
"import json"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "7fe5e94c",
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'stus' is not defined",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[1;32mIn[4], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m stus[\u001b[38;5;241m0\u001b[39m]\n",
"\u001b[1;31mNameError\u001b[0m: name 'stus' is not defined"
]
}
],
"source": [
"stus[0]"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "93cec8e3",
"metadata": {},
"outputs": [],
"source": [
"sns = [\n",
" {\n",
" \"id\": 12,\n",
" \"serialNo\": \"233159161\",\n",
" \"teamId\": 110,\n",
" \"readHeadCount\": 2,\n",
" \"name\": \"1号通道\",\n",
" \"ip\": \"10.68.66.55\",\n",
" \"remark\": \"\",\n",
" \"online\": 1,\n",
" \"onlineTime\": \"2025-11-17 18:54:13\",\n",
" \"existingRules\": [\n",
" {\n",
" \"name\": \"全勤\",\n",
" \"id\": 68,\n",
" \"typeId\": 155\n",
" },\n",
" {\n",
" \"name\": \"学生临时规则-上晚自习\",\n",
" \"id\": 69,\n",
" \"typeId\": 156\n",
" },\n",
" {\n",
" \"name\": \"不上晚自习\",\n",
" \"id\": 70,\n",
" \"typeId\": 157\n",
" }\n",
" ]\n",
" },\n",
" {\n",
" \"id\": 16,\n",
" \"serialNo\": \"233159158\",\n",
" \"teamId\": 110,\n",
" \"readHeadCount\": 2,\n",
" \"name\": \"2号道闸\",\n",
" \"ip\": \"10.68.66.56\",\n",
" \"remark\": \"\",\n",
" \"online\": 1,\n",
" \"onlineTime\": \"2025-11-17 18:54:14\",\n",
" \"existingRules\": [\n",
" {\n",
" \"name\": \"全勤\",\n",
" \"id\": 68,\n",
" \"typeId\": 124\n",
" },\n",
" {\n",
" \"name\": \"学生临时规则-上晚自习\",\n",
" \"id\": 69,\n",
" \"typeId\": 125\n",
" },\n",
" {\n",
" \"name\": \"不上晚自习\",\n",
" \"id\": 70,\n",
" \"typeId\": 126\n",
" }\n",
" ]\n",
" },\n",
" {\n",
" \"id\": 17,\n",
" \"serialNo\": \"233159159\",\n",
" \"teamId\": 110,\n",
" \"readHeadCount\": 2,\n",
" \"name\": \"3号道闸\",\n",
" \"ip\": \"10.68.66.57\",\n",
" \"remark\": \"\",\n",
" \"online\": 1,\n",
" \"onlineTime\": \"2025-11-17 18:54:13\",\n",
" \"existingRules\": [\n",
" {\n",
" \"name\": \"学生临时规则-上晚自习\",\n",
" \"id\": 69,\n",
" \"typeId\": 172\n",
" },\n",
" {\n",
" \"name\": \"全勤\",\n",
" \"id\": 68,\n",
" \"typeId\": 180\n",
" },\n",
" {\n",
" \"name\": \"不上晚自习\",\n",
" \"id\": 70,\n",
" \"typeId\": 183\n",
" }\n",
" ]\n",
" },\n",
" {\n",
" \"id\": 18,\n",
" \"serialNo\": \"233159157\",\n",
" \"teamId\": 110,\n",
" \"readHeadCount\": 2,\n",
" \"name\": \"4号道闸\",\n",
" \"ip\": \"10.68.66.58\",\n",
" \"remark\": \"\",\n",
" \"online\": 1,\n",
" \"onlineTime\": \"2025-11-17 18:54:13\",\n",
" \"existingRules\": [\n",
" {\n",
" \"name\": \"全勤\",\n",
" \"id\": 68,\n",
" \"typeId\": 188\n",
" },\n",
" {\n",
" \"name\": \"学生临时规则-上晚自习\",\n",
" \"id\": 69,\n",
" \"typeId\": 189\n",
" },\n",
" {\n",
" \"name\": \"不上晚自习\",\n",
" \"id\": 70,\n",
" \"typeId\": 190\n",
" }\n",
" ]\n",
" },\n",
" {\n",
" \"id\": 19,\n",
" \"serialNo\": \"233159164\",\n",
" \"teamId\": 110,\n",
" \"readHeadCount\": 2,\n",
" \"name\": \"广告门\",\n",
" \"ip\": \"10.68.66.59\",\n",
" \"remark\": \"\",\n",
" \"online\": 1,\n",
" \"onlineTime\": \"2025-11-17 18:54:13\",\n",
" \"existingRules\": [\n",
" {\n",
" \"name\": \"全勤\",\n",
" \"id\": 68,\n",
" \"typeId\": 191\n",
" },\n",
" {\n",
" \"name\": \"学生临时规则-上晚自习\",\n",
" \"id\": 69,\n",
" \"typeId\": 192\n",
" },\n",
" {\n",
" \"name\": \"不上晚自习\",\n",
" \"id\": 70,\n",
" \"typeId\": 193\n",
" }\n",
" ]\n",
" }\n",
" ]"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "3a35ac84",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1号通道 熊浩宇 无权限\n",
"1号通道 郭思垚 无权限\n",
"1号通道 雷林皓 无权限\n",
"1号通道 汪梓衡 无权限\n",
"1号通道 徐沐瑶 无权限\n",
"1号通道 方苇骐 无权限\n",
"2号道闸 熊浩宇 无权限\n",
"2号道闸 郭思垚 无权限\n",
"2号道闸 雷林皓 无权限\n",
"2号道闸 汪梓衡 无权限\n",
"2号道闸 方苇骐 无权限\n",
"3号道闸 熊浩宇 无权限\n",
"3号道闸 郭思垚 无权限\n",
"3号道闸 雷林皓 无权限\n",
"3号道闸 汪梓衡 无权限\n",
"3号道闸 徐沐瑶 无权限\n",
"3号道闸 方苇骐 无权限\n",
"4号道闸 熊浩宇 无权限\n",
"4号道闸 郭思垚 无权限\n",
"4号道闸 雷林皓 无权限\n",
"4号道闸 汪梓衡 无权限\n",
"4号道闸 徐沐瑶 无权限\n",
"4号道闸 方苇骐 无权限\n",
"广告门 熊浩宇 无权限\n",
"广告门 郭思垚 无权限\n",
"广告门 雷林皓 无权限\n",
"广告门 汪梓衡 无权限\n",
"广告门 徐沐瑶 无权限\n",
"广告门 方苇骐 无权限\n"
]
}
],
"source": [
"for sn in sns:\n",
" for stu in stus:\n",
" res = get( f\"http://139.159.182.121:8092/card/findUser?bandNo={stu['手环号']}&controllerSN={sn['serialNo']}\").json()\n",
" if res['success']:\n",
" result = json.loads(res['msg'])\n",
" flag = result['result']['success']\n",
" if flag:\n",
" pass\n",
" # print(f\"{stu['姓名']} 有权限\")\n",
" else:\n",
" print(f\"{sn['name']} {stu['姓名']} 无权限\")\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 31,
"id": "c7349202",
"metadata": {},
"outputs": [],
"source": [
"import time"
]
},
{
"cell_type": "code",
"execution_count": 32,
"id": "e7166b72",
"metadata": {},
"outputs": [
{
"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": [
"while True:\n",
" 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()\n",
" \n",
" for stu in data[\"data\"][\"content\"]:\n",
" if stu[\"eventName\"] !='正常刷卡开门':\n",
" print(stu['name'])\n",
" time.sleep(3)"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "700384c1",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"251"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(list(stus))"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "95aa8903",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"289"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"251+38"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "b7febbf5",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"李翰玟 上晚自习\n",
"许睿 上晚自习\n",
"吕文轩 上晚自习\n",
"杨宇晨 上晚自习\n",
"赖馨玥 上晚自习\n",
"张成 上晚自习\n",
"佘锦宸 上晚自习\n",
"钟雅祺 上晚自习\n",
"罗凯玟 上晚自习\n",
"张翼然 上晚自习\n",
"贾玥彤 上晚自习\n",
"李晞彤 上晚自习\n",
"徐欣渝 上晚自习\n",
"王为 上晚自习\n",
"赖桔兴 上晚自习\n",
"龚跃鑫 上晚自习\n",
"郑好 上晚自习\n",
"苟恩瑞 上晚自习\n",
"顾子昂 上晚自习\n",
"符曾洋 上晚自习\n",
"吴嘉唐 上晚自习\n",
"张思雅 上晚自习\n",
"管子漩 上晚自习\n",
"张文杰 上晚自习\n",
"陈熙辰 上晚自习\n",
"代芸萱 上晚自习\n",
"刘星彤 上晚自习\n",
"肖茜茜 上晚自习\n",
"白益轩 上晚自习\n",
"冯靖 上晚自习\n",
"陈诗雨 上晚自习\n",
"周渤灵 上晚自习\n",
"李文斌 上晚自习\n",
"王震宇 上晚自习\n",
"王正豪 上晚自习\n",
"李漪诺 上晚自习\n",
"吴金龙 上晚自习\n",
"马鸿森 上晚自习\n"
]
}
],
"source": [
"for item in stus2:\n",
" if item[\"姓名\"] in stus:\n",
" if item['晚自习']==2 :\n",
" tag='上晚自习'\n",
" else:\n",
" tag='不上晚自习'\n",
" print(f'{item[\"姓名\"]} {tag}' )"
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "f34f6606",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\"success\":true,\"msg\":\"操作成功\",\"code\":0,\"data\":null}\n",
"{\"success\":true,\"msg\":\"操作成功\",\"code\":0,\"data\":null}\n",
"{\"success\":true,\"msg\":\"操作成功\",\"code\":0,\"data\":null}\n",
"{\"success\":true,\"msg\":\"操作成功\",\"code\":0,\"data\":null}\n",
"{\"success\":true,\"msg\":\"操作成功\",\"code\":0,\"data\":null}\n"
]
}
],
"source": [
"for sn in sns:\n",
" print(get(f\"http://139.159.182.121:8092/card/getTime\",params={\"controllerSN\":int(sn['serialNo'])}).text)"
]
}
],
"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
}