361 lines
12 KiB
Plaintext
361 lines
12 KiB
Plaintext
{
|
||
"cells": [
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 1,
|
||
"id": "eb6a8154",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"import pandas as pd\n",
|
||
"df = pd.read_excel('./学生信息_最新.xlsx',dtype='str')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 5,
|
||
"id": "78f0cdaa",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"'<html>\\r\\n<head><title>404 Not Found</title></head>\\r\\n<body bgcolor=\"white\">\\r\\n<center><h1>404 Not Found</h1></center>\\r\\n<hr><center>nginx/1.4.0</center>\\r\\n</body>\\r\\n</html>\\r\\n'"
|
||
]
|
||
},
|
||
"execution_count": 5,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"get(url=f\"http://band.hxzhxy.cn/oauth/token?username=zhongwei&password=123456a&client_id=client&grant_type=password&client_secret=123456\").text"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 1,
|
||
"id": "d34b4562",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"from requests import get,post\n",
|
||
"import time\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",
|
||
"}"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 3,
|
||
"id": "80c5ff5c",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"name": "stderr",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"C:\\Users\\Administrator\\AppData\\Local\\Temp\\ipykernel_11244\\3332289157.py:1: DeprecationWarning: DataFrameGroupBy.apply operated on the grouping columns. This behavior is deprecated, and in a future version of pandas the grouping columns will be excluded from the operation. Either pass `include_groups=False` to exclude the groupings or explicitly select the grouping columns after groupby to silence this warning.\n",
|
||
" a = df.groupby(\"教室\").apply(lambda x:x[\"手环号\"].tolist())\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"a = df.groupby(\"教室\").apply(lambda x:x[\"手环号\"].tolist())"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "bd8942ac",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": []
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 4,
|
||
"id": "6756c409",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"doors = get(f\"https://band.hxzhxy.cn/door/lock/listLockPage?teamId=119&pageSize=60&pageNumber=0&value=&areaId=&tierId=®ionId=&bindType=&lockName=&type=2&mainTypeId=&sizeType=&lockType=&access_token={token}\").json()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 5,
|
||
"id": "11c5f395",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"doors_map ={}\n",
|
||
"for item in doors[\"data\"][\"content\"]:\n",
|
||
" doors_map[item[\"lockName\"]] = item[\"lockNo\"]"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 6,
|
||
"id": "ac4e8886",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"教室\n",
|
||
"2210 [0022796140, 0022753212, 0022796172, 310863721...\n",
|
||
"2211 [3108594513, 3108622273, 3108583137, 002303998...\n",
|
||
"2212 [3108445809, 3108464161, 3108415601, 310846636...\n",
|
||
"2213 [0022820892, 3108624769, 3108605505, 310846235...\n",
|
||
"2214 [3108599409, 3107632929, 3108571601, 002272249...\n",
|
||
"2311 [3108598753, 3108438913, 3108358785, 310839236...\n",
|
||
"2312 [3108631313, 0022702140, 3108584241, 002283212...\n",
|
||
"2313 [3108562849, 0022679980, 3108437249, 310843908...\n",
|
||
"2314 [3108415473, 3108462385, 0022752972, 310862931...\n",
|
||
"2510 [0022822732, 3108606273, 3108390481, 002279577...\n",
|
||
"2511 [3108388321, 0022704076, 3108582545, 002270244...\n",
|
||
"2512 [3108606081, 3108614401, 3108600385, 310844576...\n",
|
||
"2513 [3108440913, 3108683713, 3108588817, 310868209...\n",
|
||
"2514 [3108361393, 3108600401, 3108597553, 310860504...\n",
|
||
"dtype: object"
|
||
]
|
||
},
|
||
"execution_count": 6,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"a"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 7,
|
||
"id": "9c65d092",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"for key,value in a.items():\n",
|
||
" lockNo = doors_map.get(f'{key}前门',None)\n",
|
||
" addUserBand = \",\".join(value)\n"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 2,
|
||
"id": "4cae8da6",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"result =post(\"https://band.hxzhxy.cn/door/accredit/sendNews\",json={\"startTime\":\"25083115\",\"endTime\":\"28052815\",\"adminType\":\"55\",\"type\":\"01\",\"time\":[1756625633772,1843112033772],\"accountIp\":\"183.220.92.52\",\"accountName\":\"183.220.92.52\",\"lockNo\":\"181681774702\",\"serialNo\":\"868002345684294\",\"addAdminBand\":\"\",\"addUserBand\":\"3108624305\",\"removeBand\":\"\",\"doorAccreditIds\":\"\"},headers=header).text"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "aef76278",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"from datetime import datetime,timedelta\n",
|
||
"start = datetime.now().strftime(\"%y%m%d%H\")\n",
|
||
"end = (datetime.now()+ timedelta(days=365)).strftime(\"%y%m%d%H\")"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "ed36257e",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"('25091916', '26091916')"
|
||
]
|
||
},
|
||
"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": [
|
||
"start,end"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "673efe31",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"下发2512前门\n",
|
||
"参数lockNo:181681774855,serialNo:868002345684074,addUserBand:3108606081,3108614401,3108600385,3108445761,0022754844,3108629505,3108601713,3108590993,0022722508,3108586817,3108354753,3108586769,3108386177,3108359649,3108584129,3108356609,0022830300,3108637281,3108637185,3108605073,3108605345,3108632769,0022796108,3108595409,3108562881,3108614321,3108388129,3108603841,0022821084,3108359713,3108358529,3108460625,0023038412,3108466545,3108681873,3108396257,3108652497\n",
|
||
"{\"success\":true,\"msg\":\"操作成功\",\"code\":0,\"data\":null}\n"
|
||
]
|
||
},
|
||
{
|
||
"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": [
|
||
"# for key,value in a.items():\n",
|
||
"# lockNo = doors_map.get(f'{key}前门',None)\n",
|
||
"# addUserBand = \",\".join(value)\n",
|
||
"for key,value in a.items():\n",
|
||
" lockNo = doors_map.get(f'{key}前门',None)\n",
|
||
" addUserBand = \",\".join(value)\n",
|
||
" if key!='2512':continue\n",
|
||
" for item in doors[\"data\"][\"content\"]:\n",
|
||
" if item[\"lockName\"] == f'{key}前门':\n",
|
||
" print( f'下发{key}前门')\n",
|
||
" print(f\"参数lockNo:{lockNo},serialNo:{item['serialNo']},addUserBand:{addUserBand}\")\n",
|
||
" result =post(\"https://band.hxzhxy.cn/door/accredit/sendNews\",json={\"startTime\":\"25083115\",\"endTime\":\"28052815\",\"adminType\":\"55\",\"type\":\"01\",\"time\":[1756625633772,1843112033772],\"accountIp\":\"183.220.92.52\",\"accountName\":\"183.220.92.52\",\"lockNo\":lockNo,\"serialNo\":item[\"serialNo\"],\"addAdminBand\":\"\",\"addUserBand\":addUserBand,\"removeBand\":\"\",\"doorAccreditIds\":\"\"},headers=header).text\n",
|
||
" print(result)\n",
|
||
" # print(a)\n",
|
||
" time.sleep(10)\n",
|
||
" break\n",
|
||
" "
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 12,
|
||
"id": "c4e96b85",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"import tqdm"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 31,
|
||
"id": "96da8a5d",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"name": "stderr",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"100%|██████████| 52/52 [00:07<00:00, 7.22it/s]\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"data = get(f\"https://band.hxzhxy.cn/door/lock/listLockPage?teamId=119&pageSize=60&pageNumber=0&value=&areaId=&tierId=®ionId=&bindType=&lockName=&type=2&mainTypeId=&sizeType=&lockType=&access_token={token}\").json()\n",
|
||
"with tqdm.tqdm(total=len(data[\"data\"][\"content\"])) as pbar:\n",
|
||
" for item in data[\"data\"][\"content\"]:\n",
|
||
" if item[\"password\"] == \"12345687\" or item[\"password\"]==None: \n",
|
||
" pbar.update(1)\n",
|
||
" continue\n",
|
||
" post(\"https://band.hxzhxy.cn/door/password/send\",json={\"lockNos\":item[\"lockNo\"],\"serialNos\":item[\"serialNo\"],\"password\":\"12345687\",\"type\":\"04\",\"typeSend\":\"0\",\"accountIp\":\"183.220.91.181\",\"accountName\":\"183.220.91.181\",\"account\":\"5789\"},headers=header)\n",
|
||
" time.sleep(7)\n",
|
||
" pbar.update(1)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 33,
|
||
"id": "ee45017c",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"{'bandUserCount': 0, 'lockNo': '181681774855', 'teamId': 119, 'electric': 100, 'tierName': '5', 'doorName': '2512前门', 'ID': 723, 'lockType': 2, 'remark': None, 'mainType': '教室', 'type': '', 'password': '88888888', 'bandAdminCount': 4, 'remask': None, 'alias': '教学楼3-2门锁网关', 'createTime': 1755314698000, 'dongId': 28, 'genre': None, 'gateType': 1, 'dongName': '1栋', 'lockName': '2512前门', 'roomName': '2512', 'image': None, 'sizeType': 1, 'isPassword': 1, 'regionName': '无', 'areaId': 20, 'updateTime': None, 'version': None, 'serialNo': '868002345684074', 'opsTime': None, 'teamName': '2512', 'tierId': 64, 'doorId': 747, 'areaName': '教学楼', 'batteryType': None}\n",
|
||
"88888888\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"data = get(f\"https://band.hxzhxy.cn/door/lock/listLockPage?teamId=119&pageSize=60&pageNumber=0&value=&areaId=&tierId=®ionId=&bindType=&lockName=&type=2&mainTypeId=&sizeType=&lockType=&access_token={token}\").json()\n",
|
||
"for item in data[\"data\"][\"content\"]:\n",
|
||
" if item[\"password\"] != \"12345687\" and item[\"password\"]!=None:\n",
|
||
" print(item)\n",
|
||
" print(item['password'])"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 9,
|
||
"id": "cc3c500c",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"32"
|
||
]
|
||
},
|
||
"execution_count": 9,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"len(\"Xpaotongshutongwenzhongxue971001\")"
|
||
]
|
||
}
|
||
],
|
||
"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
|
||
}
|