Files
python----/达州/数据填充.ipynb
T
admin aac9f5934d feat: 添加多个功能模块和工具脚本
- 新增websocket客户端和服务端实现
- 添加图片压缩工具和快速压缩脚本
- 实现学生信息处理相关API
- 添加MQTT客户端和消息处理功能
- 更新.gitignore忽略更多文件类型
- 添加数据库操作工具和示例
- 实现多个测试脚本和工具类
2026-04-13 14:47:50 +08:00

967 lines
34 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"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.244: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": 6,
"id": "d4b6c72d",
"metadata": {},
"outputs": [],
"source": [
"tem1 = {\n",
"\"计算机科学与技术系\": [\"计算机科学与技术\", \"人工智能\", \"网络工程\", \"信息安全\"],\n",
"\"电子信息工程系\": [\"电子信息工程\", \"通信工程\", \"微电子科学与工程\", \"物联网工程\"],\n",
"\"工商管理系\": [\"工商管理\", \"市场营销\", \"会计学\", \"人力资源管理\"],\n",
"\"汉语言文学系\": [\"汉语言文学\", \"汉语国际教育\", \"秘书学\", \"古典文献学\"],\n",
"\"数学与应用数学系\": [\"数学与应用数学\", \"信息与计算科学\", \"统计学\", \"应用统计学\"],\n",
"\"机械工程系\": [\"机械设计制造及其自动化\", \"机械电子工程\", \"工业设计\", \"车辆工程\"],\n",
"\"护理学系\": [\"护理学\", \"助产学\", \"康复治疗学\", \"健康服务与管理\"],\n",
"\"美术系\": [\"美术学\", \"视觉传达设计\", \"环境设计\", \"产品设计\"],\n",
"\"英语系\": [\"英语\", \"翻译\", \"商务英语\", \"英语教育\"]\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "f64ccb9d",
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'tem1' 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[2], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m 系 \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mlist\u001b[39m(tem1\u001b[38;5;241m.\u001b[39mkeys())\n",
"\u001b[1;31mNameError\u001b[0m: name 'tem1' is not defined"
]
}
],
"source": [
"系 = list(tem1.keys())"
]
},
{
"cell_type": "code",
"execution_count": null,
"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": 3,
"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": 4,
"id": "6229db05",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'success': True,\n",
" 'msg': '操作成功',\n",
" 'code': 0,\n",
" 'data': {'records': [{'id': 6,\n",
" 'departmentName': '计算机科学与技术系',\n",
" 'departmentDescription': '计算机的',\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': 2,\n",
" 'departmentName': '餐饮系',\n",
" 'departmentDescription': '11',\n",
" 'teamId': 106,\n",
" 'createTime': 1749463271000}],\n",
" 'total': 10,\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": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "55259610",
"metadata": {},
"outputs": [],
"source": [
"#添加专业\n",
"# 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": 5,
"id": "b60b65d7",
"metadata": {},
"outputs": [],
"source": [
"## 生成学生信息"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "7ab6d1c6",
"metadata": {},
"outputs": [],
"source": [
"专业 = get(f\"{ip}/major/listPage?teamId=106&page=1&pageSize=100&pageNumber=1&sortField=create_time&sortOrder=asc\",headers=header).json()[\"data\"][\"records\"]"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "3a8f90af",
"metadata": {},
"outputs": [],
"source": [
"majorIds = []\n",
"for item in 专业:\n",
" majorIds.append(item[\"majorId\"])"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "35f6fbba",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['140994',\n",
" '848077',\n",
" '666307',\n",
" '464529',\n",
" '203487',\n",
" '189202',\n",
" '159665',\n",
" '514092',\n",
" '501779',\n",
" '553372',\n",
" '554162',\n",
" '613728',\n",
" '619038',\n",
" '661639',\n",
" '142319',\n",
" '702267',\n",
" '716495',\n",
" '842584',\n",
" '139202',\n",
" '851166',\n",
" '862940',\n",
" '872075',\n",
" '201351',\n",
" '488641',\n",
" '484741',\n",
" '461449',\n",
" '413654',\n",
" '412789',\n",
" '367403',\n",
" '330883',\n",
" '319840',\n",
" '309697',\n",
" '298126',\n",
" '295472',\n",
" '251625',\n",
" '237899',\n",
" 'E0001']"
]
},
"execution_count": 10,
"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": [
"majorIds"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "15630d27",
"metadata": {},
"outputs": [],
"source": [
"\n",
"stuNo = random.choices(range(20240001,20242),k=2500)\n"
]
},
{
"cell_type": "code",
"execution_count": 79,
"id": "bb29e32c",
"metadata": {},
"outputs": [],
"source": [
"for id in stuNo:\n",
" sex = random.choice([\"1\",\"2\"])\n",
" if sex==\"1\":\n",
" name = fake.name_male()\n",
" else:\n",
" name = fake.name_female()\n",
" classId= random.choice([674,675,676,689,690])\n",
" student = {\"boarder\":\"1\",\"stuNo\":id,\"stuName\":name,\"sex\":sex,\"teamId\":106,\"gradeId\":322,\"classId\":classId,\"seralNo\":None,\"score\":None,\"moralEducation\":None,\"userName\":None,\"pid\":None,\"majorId\":random.choice(majorIds),\"majorName\":None,\"phone\":None,\"imgUrl\":None,\"accountIp\":\"192.168.0.111\",\"accountName\":\"NRSKKLYXDQTXUTJ\",\"trust\":0,\"teaChild\":0}\n",
" post(f\"{ip}/uc/student/add\",json=student,headers=header)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "34d5a804",
"metadata": {},
"outputs": [],
"source": [
"#添加栋\n",
"# for i in range(3,21):\n",
"# post(f\"{ip}/lock/dong/add\",json={\"dongName\":f\"{i}栋\",\"teamId\":106,\"areaId\": 21},headers=header).text"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "4cf9e4c4",
"metadata": {},
"outputs": [],
"source": [
"#获取栋\n",
"栋 = get(f\"{ip}/lock/dong/list?teamId=106&areaId=21\",headers=header).json()[\"data\"]"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "d3c81066",
"metadata": {},
"outputs": [],
"source": [
"栋ID = [ i[\"id\"] for i in 栋]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c534c969",
"metadata": {},
"outputs": [],
"source": [
"#添加楼层\n",
"# for id in 栋ID:\n",
"# for i in range(1,11):\n",
"# post(f\"{ip}/lock/tier/add\",json={\"teamId\":106,\"dongId\":id,\"areaName\":\"\",\"areaRemask\":\"\",\"areaId\":21,\"tierName\":f\"第{i}层\"},headers=header)\n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "75111a27",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'吉林'"
]
},
"execution_count": 63,
"metadata": {},
"output_type": "execute_result"
}
],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "def78553",
"metadata": {},
"outputs": [],
"source": [
"#添加区域\n",
"# for 栋id in 栋ID:\n",
"# 层s = get(f\"{ip}/lock/tier/list?teamId=106&dongId={栋id}&areaId=21\",headers=header).json()[\"data\"]\n",
"# 层ids = [i[\"id\"] for i in 层s]\n",
"# for 层id in 层ids:\n",
"# for i in range(1,5):\n",
"# post(f\"{ip}/lock/region/add\",json={\"teamId\":106,\"dongId\":栋id,\"areaName\":\"\",\"areaRemask\":\"\",\"areaId\":21,\"tierId\":层id,\"regionName\":f\"{fake.province()[:-1]}区\"},headers=header)"
]
},
{
"cell_type": "code",
"execution_count": 66,
"id": "5a3c5d5a",
"metadata": {},
"outputs": [],
"source": [
"dongInfo = []\n",
"for 栋id in 栋ID:\n",
" data = {\"dongId\":栋id,\"tier\":None}\n",
" 层s = get(f\"{ip}/lock/tier/list?teamId=106&dongId={栋id}&areaId=21\",headers=header).json()[\"data\"]\n",
" tem = []\n",
" for 层 in 层s:\n",
" tem层 = {\"tierId\":层[\"id\"]}\n",
" 区域s = get(f\"{ip}/lock/region/list?teamId=106&areaId=21&dongId={栋id}&tierId={层[\"id\"]}\",headers=header).json()[\"data\"]\n",
" regionIds = [i[\"id\"] for i in 区域s]\n",
" tem层[\"region\"] = regionIds\n",
" tem.append(tem层)\n",
" data[\"tier\"] = tem\n",
" dongInfo.append(data)\n",
" \n",
" \n",
" # 层ids = [{\"tierId\":i[\"id\"]} for i in 层s]\n",
" # data[\"tier\"] = 层ids"
]
},
{
"cell_type": "code",
"execution_count": 67,
"id": "846f7f61",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[{'dongId': 50,\n",
" 'tier': [{'tierId': 51, 'region': [4, 3, 2, 1]},\n",
" {'tierId': 52, 'region': [8, 7, 6, 5]},\n",
" {'tierId': 53, 'region': [12, 11, 10, 9]},\n",
" {'tierId': 54, 'region': [16, 15, 14, 13]},\n",
" {'tierId': 55, 'region': [20, 19, 18, 17]},\n",
" {'tierId': 56, 'region': [24, 23, 22, 21]},\n",
" {'tierId': 57, 'region': [28, 27, 26, 25]},\n",
" {'tierId': 58, 'region': [32, 31, 30, 29]},\n",
" {'tierId': 59, 'region': [36, 35, 34, 33]},\n",
" {'tierId': 60, 'region': [40, 39, 38, 37]}]},\n",
" {'dongId': 49,\n",
" 'tier': [{'tierId': 61, 'region': [44, 43, 42, 41]},\n",
" {'tierId': 62, 'region': [48, 47, 46, 45]},\n",
" {'tierId': 63, 'region': [52, 51, 50, 49]},\n",
" {'tierId': 64, 'region': [56, 55, 54, 53]},\n",
" {'tierId': 65, 'region': [60, 59, 58, 57]},\n",
" {'tierId': 66, 'region': [64, 63, 62, 61]},\n",
" {'tierId': 67, 'region': [68, 67, 66, 65]},\n",
" {'tierId': 68, 'region': [72, 71, 70, 69]},\n",
" {'tierId': 69, 'region': [76, 75, 74, 73]},\n",
" {'tierId': 70, 'region': [80, 79, 78, 77]}]},\n",
" {'dongId': 48,\n",
" 'tier': [{'tierId': 71, 'region': [84, 83, 82, 81]},\n",
" {'tierId': 72, 'region': [88, 87, 86, 85]},\n",
" {'tierId': 73, 'region': [92, 91, 90, 89]},\n",
" {'tierId': 74, 'region': [96, 95, 94, 93]},\n",
" {'tierId': 75, 'region': [100, 99, 98, 97]},\n",
" {'tierId': 76, 'region': [104, 103, 102, 101]},\n",
" {'tierId': 77, 'region': [108, 107, 106, 105]},\n",
" {'tierId': 78, 'region': [112, 111, 110, 109]},\n",
" {'tierId': 79, 'region': [116, 115, 114, 113]},\n",
" {'tierId': 80, 'region': [120, 119, 118, 117]}]},\n",
" {'dongId': 47,\n",
" 'tier': [{'tierId': 81, 'region': [124, 123, 122, 121]},\n",
" {'tierId': 82, 'region': [128, 127, 126, 125]},\n",
" {'tierId': 83, 'region': [132, 131, 130, 129]},\n",
" {'tierId': 84, 'region': [136, 135, 134, 133]},\n",
" {'tierId': 85, 'region': [140, 139, 138, 137]},\n",
" {'tierId': 86, 'region': [144, 143, 142, 141]},\n",
" {'tierId': 87, 'region': [148, 147, 146, 145]},\n",
" {'tierId': 88, 'region': [152, 151, 150, 149]},\n",
" {'tierId': 89, 'region': [156, 155, 154, 153]},\n",
" {'tierId': 90, 'region': [160, 159, 158, 157]}]},\n",
" {'dongId': 46,\n",
" 'tier': [{'tierId': 91, 'region': [164, 163, 162, 161]},\n",
" {'tierId': 92, 'region': [168, 167, 166, 165]},\n",
" {'tierId': 93, 'region': [172, 171, 170, 169]},\n",
" {'tierId': 94, 'region': [176, 175, 174, 173]},\n",
" {'tierId': 95, 'region': [180, 179, 178, 177]},\n",
" {'tierId': 96, 'region': [184, 183, 182, 181]},\n",
" {'tierId': 97, 'region': [188, 187, 186, 185]},\n",
" {'tierId': 98, 'region': [192, 191, 190, 189]},\n",
" {'tierId': 99, 'region': [196, 195, 194, 193]},\n",
" {'tierId': 100, 'region': [200, 199, 198, 197]}]},\n",
" {'dongId': 45,\n",
" 'tier': [{'tierId': 101, 'region': [204, 203, 202, 201]},\n",
" {'tierId': 102, 'region': [208, 207, 206, 205]},\n",
" {'tierId': 103, 'region': [212, 211, 210, 209]},\n",
" {'tierId': 104, 'region': [216, 215, 214, 213]},\n",
" {'tierId': 105, 'region': [220, 219, 218, 217]},\n",
" {'tierId': 106, 'region': [224, 223, 222, 221]},\n",
" {'tierId': 107, 'region': [228, 227, 226, 225]},\n",
" {'tierId': 108, 'region': [232, 231, 230, 229]},\n",
" {'tierId': 109, 'region': [236, 235, 234, 233]},\n",
" {'tierId': 110, 'region': [240, 239, 238, 237]}]},\n",
" {'dongId': 44,\n",
" 'tier': [{'tierId': 111, 'region': [244, 243, 242, 241]},\n",
" {'tierId': 112, 'region': [248, 247, 246, 245]},\n",
" {'tierId': 113, 'region': [252, 251, 250, 249]},\n",
" {'tierId': 114, 'region': [256, 255, 254, 253]},\n",
" {'tierId': 115, 'region': [260, 259, 258, 257]},\n",
" {'tierId': 116, 'region': [264, 263, 262, 261]},\n",
" {'tierId': 117, 'region': [268, 267, 266, 265]},\n",
" {'tierId': 118, 'region': [272, 271, 270, 269]},\n",
" {'tierId': 119, 'region': [276, 275, 274, 273]},\n",
" {'tierId': 120, 'region': [280, 279, 278, 277]}]},\n",
" {'dongId': 43,\n",
" 'tier': [{'tierId': 121, 'region': [284, 283, 282, 281]},\n",
" {'tierId': 122, 'region': [288, 287, 286, 285]},\n",
" {'tierId': 123, 'region': [292, 291, 290, 289]},\n",
" {'tierId': 124, 'region': [296, 295, 294, 293]},\n",
" {'tierId': 125, 'region': [300, 299, 298, 297]},\n",
" {'tierId': 126, 'region': [304, 303, 302, 301]},\n",
" {'tierId': 127, 'region': [308, 307, 306, 305]},\n",
" {'tierId': 128, 'region': [312, 311, 310, 309]},\n",
" {'tierId': 129, 'region': [316, 315, 314, 313]},\n",
" {'tierId': 130, 'region': [320, 319, 318, 317]}]},\n",
" {'dongId': 42,\n",
" 'tier': [{'tierId': 131, 'region': [324, 323, 322, 321]},\n",
" {'tierId': 132, 'region': [328, 327, 326, 325]},\n",
" {'tierId': 133, 'region': [332, 331, 330, 329]},\n",
" {'tierId': 134, 'region': [336, 335, 334, 333]},\n",
" {'tierId': 135, 'region': [340, 339, 338, 337]},\n",
" {'tierId': 136, 'region': [344, 343, 342, 341]},\n",
" {'tierId': 137, 'region': [348, 347, 346, 345]},\n",
" {'tierId': 138, 'region': [352, 351, 350, 349]},\n",
" {'tierId': 139, 'region': [356, 355, 354, 353]},\n",
" {'tierId': 140, 'region': [360, 359, 358, 357]}]},\n",
" {'dongId': 41,\n",
" 'tier': [{'tierId': 141, 'region': [364, 363, 362, 361]},\n",
" {'tierId': 142, 'region': [368, 367, 366, 365]},\n",
" {'tierId': 143, 'region': [372, 371, 370, 369]},\n",
" {'tierId': 144, 'region': [376, 375, 374, 373]},\n",
" {'tierId': 145, 'region': [380, 379, 378, 377]},\n",
" {'tierId': 146, 'region': [384, 383, 382, 381]},\n",
" {'tierId': 147, 'region': [388, 387, 386, 385]},\n",
" {'tierId': 148, 'region': [392, 391, 390, 389]},\n",
" {'tierId': 149, 'region': [396, 395, 394, 393]},\n",
" {'tierId': 150, 'region': [400, 399, 398, 397]}]},\n",
" {'dongId': 40,\n",
" 'tier': [{'tierId': 151, 'region': [404, 403, 402, 401]},\n",
" {'tierId': 152, 'region': [408, 407, 406, 405]},\n",
" {'tierId': 153, 'region': [412, 411, 410, 409]},\n",
" {'tierId': 154, 'region': [416, 415, 414, 413]},\n",
" {'tierId': 155, 'region': [420, 419, 418, 417]},\n",
" {'tierId': 156, 'region': [424, 423, 422, 421]},\n",
" {'tierId': 157, 'region': [428, 427, 426, 425]},\n",
" {'tierId': 158, 'region': [432, 431, 430, 429]},\n",
" {'tierId': 159, 'region': [436, 435, 434, 433]},\n",
" {'tierId': 160, 'region': [440, 439, 438, 437]}]},\n",
" {'dongId': 39,\n",
" 'tier': [{'tierId': 161, 'region': [444, 443, 442, 441]},\n",
" {'tierId': 162, 'region': [448, 447, 446, 445]},\n",
" {'tierId': 163, 'region': [452, 451, 450, 449]},\n",
" {'tierId': 164, 'region': [456, 455, 454, 453]},\n",
" {'tierId': 165, 'region': [460, 459, 458, 457]},\n",
" {'tierId': 166, 'region': [464, 463, 462, 461]},\n",
" {'tierId': 167, 'region': [468, 467, 466, 465]},\n",
" {'tierId': 168, 'region': [472, 471, 470, 469]},\n",
" {'tierId': 169, 'region': [476, 475, 474, 473]},\n",
" {'tierId': 170, 'region': [480, 479, 478, 477]}]},\n",
" {'dongId': 38,\n",
" 'tier': [{'tierId': 171, 'region': [484, 483, 482, 481]},\n",
" {'tierId': 172, 'region': [488, 487, 486, 485]},\n",
" {'tierId': 173, 'region': [492, 491, 490, 489]},\n",
" {'tierId': 174, 'region': [496, 495, 494, 493]},\n",
" {'tierId': 175, 'region': [500, 499, 498, 497]},\n",
" {'tierId': 176, 'region': [504, 503, 502, 501]},\n",
" {'tierId': 177, 'region': [508, 507, 506, 505]},\n",
" {'tierId': 178, 'region': [512, 511, 510, 509]},\n",
" {'tierId': 179, 'region': [516, 515, 514, 513]},\n",
" {'tierId': 180, 'region': [520, 519, 518, 517]}]},\n",
" {'dongId': 37,\n",
" 'tier': [{'tierId': 181, 'region': [524, 523, 522, 521]},\n",
" {'tierId': 182, 'region': [528, 527, 526, 525]},\n",
" {'tierId': 183, 'region': [532, 531, 530, 529]},\n",
" {'tierId': 184, 'region': [536, 535, 534, 533]},\n",
" {'tierId': 185, 'region': [540, 539, 538, 537]},\n",
" {'tierId': 186, 'region': [544, 543, 542, 541]},\n",
" {'tierId': 187, 'region': [548, 547, 546, 545]},\n",
" {'tierId': 188, 'region': [552, 551, 550, 549]},\n",
" {'tierId': 189, 'region': [556, 555, 554, 553]},\n",
" {'tierId': 190, 'region': [560, 559, 558, 557]}]},\n",
" {'dongId': 36,\n",
" 'tier': [{'tierId': 191, 'region': [564, 563, 562, 561]},\n",
" {'tierId': 192, 'region': [568, 567, 566, 565]},\n",
" {'tierId': 193, 'region': [572, 571, 570, 569]},\n",
" {'tierId': 194, 'region': [576, 575, 574, 573]},\n",
" {'tierId': 195, 'region': [580, 579, 578, 577]},\n",
" {'tierId': 196, 'region': [584, 583, 582, 581]},\n",
" {'tierId': 197, 'region': [588, 587, 586, 585]},\n",
" {'tierId': 198, 'region': [592, 591, 590, 589]},\n",
" {'tierId': 199, 'region': [596, 595, 594, 593]},\n",
" {'tierId': 200, 'region': [600, 599, 598, 597]}]},\n",
" {'dongId': 35,\n",
" 'tier': [{'tierId': 201, 'region': [604, 603, 602, 601]},\n",
" {'tierId': 202, 'region': [608, 607, 606, 605]},\n",
" {'tierId': 203, 'region': [612, 611, 610, 609]},\n",
" {'tierId': 204, 'region': [616, 615, 614, 613]},\n",
" {'tierId': 205, 'region': [620, 619, 618, 617]},\n",
" {'tierId': 206, 'region': [624, 623, 622, 621]},\n",
" {'tierId': 207, 'region': [628, 627, 626, 625]},\n",
" {'tierId': 208, 'region': [632, 631, 630, 629]},\n",
" {'tierId': 209, 'region': [636, 635, 634, 633]},\n",
" {'tierId': 210, 'region': [640, 639, 638, 637]}]},\n",
" {'dongId': 34,\n",
" 'tier': [{'tierId': 211, 'region': [644, 643, 642, 641]},\n",
" {'tierId': 212, 'region': [648, 647, 646, 645]},\n",
" {'tierId': 213, 'region': [652, 651, 650, 649]},\n",
" {'tierId': 214, 'region': [656, 655, 654, 653]},\n",
" {'tierId': 215, 'region': [660, 659, 658, 657]},\n",
" {'tierId': 216, 'region': [664, 663, 662, 661]},\n",
" {'tierId': 217, 'region': [668, 667, 666, 665]},\n",
" {'tierId': 218, 'region': [672, 671, 670, 669]},\n",
" {'tierId': 219, 'region': [676, 675, 674, 673]},\n",
" {'tierId': 220, 'region': [680, 679, 678, 677]}]},\n",
" {'dongId': 33,\n",
" 'tier': [{'tierId': 221, 'region': [684, 683, 682, 681]},\n",
" {'tierId': 222, 'region': [688, 687, 686, 685]},\n",
" {'tierId': 223, 'region': [692, 691, 690, 689]},\n",
" {'tierId': 224, 'region': [696, 695, 694, 693]},\n",
" {'tierId': 225, 'region': [700, 699, 698, 697]},\n",
" {'tierId': 226, 'region': [704, 703, 702, 701]},\n",
" {'tierId': 227, 'region': [708, 707, 706, 705]},\n",
" {'tierId': 228, 'region': [712, 711, 710, 709]},\n",
" {'tierId': 229, 'region': [716, 715, 714, 713]},\n",
" {'tierId': 230, 'region': [720, 719, 718, 717]}]},\n",
" {'dongId': 32,\n",
" 'tier': [{'tierId': 231, 'region': [724, 723, 722, 721]},\n",
" {'tierId': 232, 'region': [728, 727, 726, 725]},\n",
" {'tierId': 233, 'region': [732, 731, 730, 729]},\n",
" {'tierId': 234, 'region': [736, 735, 734, 733]},\n",
" {'tierId': 235, 'region': [740, 739, 738, 737]},\n",
" {'tierId': 236, 'region': [744, 743, 742, 741]},\n",
" {'tierId': 237, 'region': [748, 747, 746, 745]},\n",
" {'tierId': 238, 'region': [752, 751, 750, 749]},\n",
" {'tierId': 239, 'region': [756, 755, 754, 753]},\n",
" {'tierId': 240, 'region': [760, 759, 758, 757]}]},\n",
" {'dongId': 31,\n",
" 'tier': [{'tierId': 50, 'region': [764, 763, 762, 761]},\n",
" {'tierId': 242, 'region': [768, 767, 766, 765]},\n",
" {'tierId': 243, 'region': [772, 771, 770, 769]},\n",
" {'tierId': 244, 'region': [776, 775, 774, 773]},\n",
" {'tierId': 245, 'region': [780, 779, 778, 777]},\n",
" {'tierId': 246, 'region': [784, 783, 782, 781]},\n",
" {'tierId': 247, 'region': [788, 787, 786, 785]},\n",
" {'tierId': 248, 'region': [792, 791, 790, 789]},\n",
" {'tierId': 249, 'region': [796, 795, 794, 793]},\n",
" {'tierId': 250, 'region': [800, 799, 798, 797]}]}]"
]
},
"execution_count": 67,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dongInfo"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "34ea2246",
"metadata": {},
"outputs": [],
"source": [
"#添加宿舍\n",
"# for i in range(600):\n",
"# tem = random.choice(dongInfo)\n",
"# if tem[\"dongId\"] %2==0:\n",
"# sex = 1\n",
"# else:\n",
"# sex = 2\n",
"# dongId = tem[\"dongId\"]\n",
"# tier = random.choice(tem[\"tier\"])\n",
"# tierId = tier[\"tierId\"]\n",
"# regionId = random.choice(tier[\"region\"])\n",
"# info = {\"sex\":sex,\"dormNum\":random.randint(4,6),\"areaId\":21,\"dongId\":dongId,\"tierId\":tierId,\"regionId\":regionId,\"dormName\":fake.city_name(),\"dormCount\":0,\"teamId\":106}\n",
" \n",
"# post(f\"{ip}/dorm/info/add\",json=info,headers=header)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6d590b17",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'淑兰市'"
]
},
"execution_count": 40,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# fake.city()"
]
},
{
"cell_type": "code",
"execution_count": 81,
"id": "42f833e8",
"metadata": {},
"outputs": [],
"source": [
"#绑定学生\n",
"data = get(f\"{ip}/uc/student/pageInfo?teamId=106&type=0&pageSize=2500&pageNumber=0&orderDirection=asc\",headers=header).json()[\"data\"][\"content\"]"
]
},
{
"cell_type": "code",
"execution_count": 82,
"id": "ba31521b",
"metadata": {},
"outputs": [],
"source": [
"random.shuffle(data)"
]
},
{
"cell_type": "code",
"execution_count": 94,
"id": "550d43af",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'id': 11382,\n",
" 'stuNo': '20257831',\n",
" 'stuName': '曾鹏',\n",
" 'sex': 2,\n",
" 'classId': 676,\n",
" 'gradeId': 322,\n",
" 'seralNo': None,\n",
" 'score': None,\n",
" 'moralEducation': None,\n",
" 'userName': '20257831DZSZYGJZX',\n",
" 'teamId': 106,\n",
" 'pid': None,\n",
" 'phone': None,\n",
" 'imgUrl': None,\n",
" 'openid': None,\n",
" 'boarder': 1,\n",
" 'wxPhone': None,\n",
" 'trust': 0,\n",
" 'userId': None,\n",
" 'stature': None,\n",
" 'weight': None,\n",
" 'wxPhones': None,\n",
" 'userIdse': None,\n",
" 'payUserId': None,\n",
" 'payState': 0,\n",
" 'teaChild': 0,\n",
" 'openids': None,\n",
" 'casId': None,\n",
" 'board': None,\n",
" 'chatOpenId': None,\n",
" 'chatOpenIds': None,\n",
" 'majorId': '842584',\n",
" 'majorName': '数学与应用数学',\n",
" 'teamName': '达州市职业高级中学',\n",
" 'gradeName': '2025级',\n",
" 'className': '3班',\n",
" 'sexName': '女',\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': 1,\n",
" 'sumLocation': None,\n",
" 'arkName': None,\n",
" 'departmentName': '数学与应用数学系',\n",
" 'departmentId': 10}"
]
},
"execution_count": 94,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data[0]"
]
},
{
"cell_type": "code",
"execution_count": 83,
"id": "bfb6f1b2",
"metadata": {},
"outputs": [],
"source": [
"bedinfo = get(f\"{ip}/dorm/bed/pageList?page=1&pageSize=3000&teamId=106&pageNumber=1\",headers=header).json()[\"data\"][\"records\"]"
]
},
{
"cell_type": "code",
"execution_count": 86,
"id": "ca3139c8",
"metadata": {},
"outputs": [],
"source": [
"random.shuffle(bedinfo)"
]
},
{
"cell_type": "code",
"execution_count": 88,
"id": "cbc60a07",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'id': 1987,\n",
" 'dormId': 408,\n",
" 'stuId': None,\n",
" 'areaName': '达州校区',\n",
" 'dongName': '3栋',\n",
" 'tierName': '第8层',\n",
" 'regionName': '广东区',\n",
" 'majorName': None,\n",
" 'departmentName': None,\n",
" 'dormName': '济南',\n",
" 'sex': None,\n",
" 'stuNo': None,\n",
" 'stuName': None,\n",
" 'gradeName': None,\n",
" 'className': None,\n",
" 'dormSex': 2,\n",
" 'intoState': None,\n",
" 'intoTime': None,\n",
" 'status': None,\n",
" 'stuState': None}"
]
},
"execution_count": 88,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"bedinfo[1]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "74075b1d",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'id': 196, 'dormId': 46, 'stuId': None, 'areaName': '达州校区', 'dongName': '20栋', 'tierName': '第1层', 'regionName': '江西区', 'majorName': None, 'departmentName': None, 'dormName': '34567', 'sex': None, 'stuNo': None, 'stuName': None, 'gradeName': None, 'className': None, 'dormSex': 2, 'intoState': None, 'intoTime': None, 'status': None, 'stuState': None}\n"
]
}
],
"source": [
"for item in bedinfo:\n",
" if item[\"id\"] == 196:\n",
" print(item)\n",
" break"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "57a00874",
"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": [
"#绑定学生与寝室\n",
"# for i in range(len(data)):\n",
"# # bind = {\"id\":data[i][\"id\"],\"dormId\":bedinfo[i][\"dormId\"],\"stuId\":data[i][\"stuNo\"]}\n",
"# bind = {\"id\":bedinfo[i][\"id\"],\"dormId\":bedinfo[i][\"dormId\"],\"stuId\":data[i][\"id\"]}\n",
"# # print(bind)\n",
"# post(f\"{ip}/dorm/bed/update\",headers=header,json=bind)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "29ec939f",
"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
}