chore: 批量新增各类工具脚本与配置文件

1. 新增音频录制、下载、上传相关脚本
2. 新增数据库操作、API调用工具
3. 新增Excel数据处理脚本
4. 新增弱密码检测脚本
This commit is contained in:
2026-06-14 17:47:15 +08:00
parent aac9f5934d
commit 2d8c1ea8f9
46 changed files with 11644 additions and 829 deletions
File diff suppressed because one or more lines are too long
+30 -16
View File
@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 1,
"id": "d9c14718",
"metadata": {},
"outputs": [],
@@ -29,7 +29,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 2,
"id": "1673af54",
"metadata": {},
"outputs": [],
@@ -43,7 +43,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 3,
"id": "4cf83c82",
"metadata": {},
"outputs": [],
@@ -56,7 +56,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 4,
"id": "1790800e",
"metadata": {},
"outputs": [],
@@ -66,7 +66,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 5,
"id": "34f18ca5",
"metadata": {},
"outputs": [],
@@ -77,7 +77,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 6,
"id": "7cf83679",
"metadata": {},
"outputs": [
@@ -87,7 +87,7 @@
"0"
]
},
"execution_count": 23,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
@@ -120,17 +120,17 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 8,
"id": "e706bbb0",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<paho.mqtt.client.MQTTMessageInfo at 0x1b6a5f5e0c0>"
"<paho.mqtt.client.MQTTMessageInfo at 0x1f295d5cef0>"
]
},
"execution_count": 24,
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
@@ -146,10 +146,10 @@
"metadata": {},
"outputs": [],
"source": [
"for item in data[0:1]:\n",
"for item in data:\n",
" print(item)\n",
" mac=item[\"mac\"]\n",
" topic=f\"cmd/publicizeBanpai/08E60E75E09E/control\"\n",
" topic=f\"cmd/publicizeBanpai/{mac}/cmd\"\n",
" message={\n",
" \"type\":\"info\"\n",
" }\n",
@@ -158,17 +158,31 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 11,
"id": "3da280f9",
"metadata": {},
"outputs": [],
"source": [
"for item in data:\n",
" mac=item[\"mac\"]\n",
" topic=f\"cmd/publicizeBanpai/{mac}/cmd\"\n",
" message=\"reboot -p\"\n",
" client.publish(topic, message)\n"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "82403f63",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<paho.mqtt.client.MQTTMessageInfo at 0x1b6a5c2bec0>"
"<paho.mqtt.client.MQTTMessageInfo at 0x1f295d5c360>"
]
},
"execution_count": 31,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
@@ -204,7 +218,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "undefined.undefined.undefined"
"version": "3.12.4"
}
},
"nbformat": 4,
+29 -36
View File
@@ -1,42 +1,35 @@
from requests import get, post, put, delete
import random
from requests import get, post
import time
ip = "http://192.168.0.209:8100"
param = {
"username": "zhongwei",
"password": "123456a",
"client_id": "client",
"grant_type": "password",
"client_secret": "123456",
}
data = get(url=f"{ip}/oauth/token", params=param).json()
token = data["access_token"]
header = {
"content-type": "application/json",
"authorization": f"Bearer {token}",
}
teamId = 110
year = 2026
month = 3
# v1.jinrishici.com/all.json
def apiSentence():
data = get("https://v1.hitokoto.cn").json()
return data
data1 = get(f"{ip}/classAttend/screen/summary", headers=header, params={"teamId": teamId, "year": year, "month": month}).text
print("summary:", data1, end="\n\n")
data2 = get(f"{ip}/classAttend/screen/dailyTrend", headers=header, params={"teamId": teamId, "year": year, "month": month}).text
print("dailyTrend:", data2, end="\n\n")
def cat():
data = get("https://api.thecatapi.com/v1/images/search?size=full").json()
result = data[0]["url"]
return result
data3 = get(f"{ip}/classAttend/screen/statusPie", headers=header, params={"teamId": teamId, "year": year, "month": month}).text
print("statusPie:", data3, end="\n\n")
data4 = get(f"{ip}/classAttend/screen/gradeRanking", headers=header, params={"teamId": teamId, "year": year, "month": month}).text
print("gradeRanking:", data4, end="\n\n")
def dog():
data = get("https://api.thedogapi.com/v1/images/search?size=full").json()
result = data[0]["url"]
return result
def pic():
data = get("https://api.vvhan.com/api/bing?type=json&rand=sj").json()
result = data["data"]["url"]
return result
def randomPic():
func = random.choice([cat])
data = func()
return data
def getEmoji():
data = get("https://api.vvhan.com/api/emoji?type=json").json()
return data
def getShi():
data = post("http://v1.jinrishici.com/all.json").json()
return data
data5 = get(f"{ip}/classAttend/screen/studentRanking", headers=header, params={"teamId": teamId, "year": year, "month": month}).text
print("studentRanking:", data5, end="\n\n")
+35
View File
@@ -0,0 +1,35 @@
from requests import get,post
import time
ip = "http://192.168.0.209:8100"
param = {
"username": "zhongwei",
"password": "123456a",
"client_id": "client",
"grant_type": "password",
"client_secret": "123456",
}
data = get(url=f"{ip}/oauth/token",params=param).json()
token = data["access_token"]
header = {
"content-type": "application/json",
"authorization": f"Bearer {token}",
}
teamId=110
month=5
data1= get(f"{ip}/counseling/screen/stats",headers=header,params={"teamId":teamId,"year":2026,"month":month}).text
print(data1,end="\n\n")
data2=get(f"{ip}/counseling/screen/trend",headers=header,params={"teamId":teamId,"year":2026,"month":month}).text
print(data2,end="\n\n")
data3=get(f"{ip}/counseling/screen/statusDistribution",headers=header,params={"teamId":teamId,"year":2026,"month":month}).text
print(data3,end="\n\n")
data4=get(f"{ip}/counseling/screen/gradeStats",headers=header,params={"teamId":teamId,"year":2026,"month":month}).text
print(data4,end="\n\n")
data5=get(f"{ip}/counseling/screen/projectStats",headers=header,params={"teamId":teamId,"year":2026,"month":month}).text
print(data5,end="\n\n")
data6=get(f"{ip}/counseling/screen/completionStats",headers=header,params={"teamId":teamId,"year":2026,"month":month}).text
print(data6,end="\n\n")
File diff suppressed because one or more lines are too long
+17
View File
@@ -0,0 +1,17 @@
from requests import post
tem = post("http://11.1.1.106:8082/api",json={
"service_name": "operate_plate",
"data": [
{
"departName": "百仁",
"authType": 30000,
"plateNumber": "鄂A1234569",
"personName": "夏天乐测试",
"plateIdStr": "test-plate-id-001",
"opType": 1,
"beginTime": "2026-05-18 17:53:44",
"endTime": "2027-05-18 17:53:44"
}
]
}).text
print(tem)
@@ -0,0 +1,288 @@
from requests import get, post
from faker import Faker
import random
import time
import uuid
import json
from datetime import datetime, timedelta
fake = Faker('zh_CN')
ip = "http://band.hxzhxy.cn"
param = {
"username": "xtl",
"password": "xia123456",
"client_id": "client",
"grant_type": "password",
"client_secret": "123456",
}
def get_token():
data = get(url=f"{ip}/oauth/token", params=param).json()
return data["access_token"]
token = get_token()
header = {
"content-type": "application/json",
"authorization": f"Bearer {token}",
}
teamId = 106
def generate_leave_data(stu_id, stu_name, stu_no, grade_name, class_name, grade_id, class_id, phone=None):
leave_types = ["事假", "病假"]
leave_type = random.choice(leave_types)
is_cycle = random.choice([1, 2, 3])
begin_date = datetime.now() - timedelta(days=random.randint(0,15))
end_date = begin_date + timedelta(days=random.randint(0, 120))
begin_section = random.randint(1, 6)
end_section = random.randint(begin_section, 12)
leave_reasons = [
"身体不适,需要休息",
"家中有事需要处理",
"去医院检查身体",
"发烧感冒,需要就医",
"参加重要家庭活动",
"个人事务需要处理",
"肠胃不适,需要就医",
"头痛发热,请假休息",
"参加校外培训活动",
"家庭紧急事务",
]
disease_date = begin_date.strftime("%Y-%m-%d")
if is_cycle == 3:
week_days = ["周一", "周二", "周三", "周四", "周五"]
selected_day = random.choice(week_days)
sections = random.sample(range(1, 13), random.randint(2, 4))
sections.sort()
week_info = json.dumps({selected_day: ",".join(str(s) for s in sections)})
end_date = begin_date
else:
week_info = None
data = {
"stuId": str(stu_id),
"leaveType": leave_type,
"isCycle": is_cycle,
"leaveReason": random.choice(leave_reasons),
"beginDate": begin_date.strftime("%Y-%m-%d"),
"endDate": end_date.strftime("%Y-%m-%d"),
"beginSection": str(begin_section),
"endSection": str(end_section),
"diseaseDate": disease_date,
"symptom": "",
"fever": "",
"hospital": "",
"treatmentDate": "",
"imgUrl": "[]",
"weekInfo": week_info,
}
return data
def get_grade_list():
url = f"{ip}/uc/grade/listSelect/{teamId}?access_token={token}"
response = get(url, headers=header)
result = response.json()
if result.get('code') == 0:
return result.get('data', [])
return []
def get_class_list(grade_id):
url = f"{ip}/uc/class/listClass"
params = {
"access_token": token,
"teamId": teamId,
"gradeId": grade_id
}
response = get(url, params=params, headers=header)
result = response.json()
if result.get('code') == 0:
return result.get('data', [])
return []
def get_students_from_db(grade_id=None, class_id=None):
import pymysql
conn = pymysql.connect(
host='192.168.0.244',
port=3306,
user='root',
password='Abcd@123456',
database='school_server',
charset='utf8'
)
cursor = conn.cursor()
sql = """
SELECT s.id, s.stu_no, s.stu_name, s.phone,
g.grade_name, c.class_name
FROM student s
LEFT JOIN grade g ON s.grade_id = g.id
LEFT JOIN tclass c ON s.class_id = c.id
WHERE s.team_id = %s
"""
params = [str(teamId)]
if grade_id:
sql += " AND s.grade_id = %s"
params.append(grade_id)
if class_id:
sql += " AND s.class_id = %s"
params.append(class_id)
sql += " ORDER BY RAND() LIMIT 100"
cursor.execute(sql, params)
students = cursor.fetchall()
conn.close()
return students
def add_leave_record(leave_data):
url = f"{ip}/studentLeave/add"
leave_data["access_token"] = token
response = post(url, json=leave_data, headers=header)
return response.json()
def batch_add_leaves(count=10):
print(f"正在获取年级列表...")
grades = get_grade_list()
if not grades:
print("未获取到年级数据,请检查 teamId 或 token")
return
grade = random.choice(grades)
grade_id = grade.get('id', grade.get('gradeId'))
grade_name = grade.get('gradeName', grade.get('name', ''))
print(f"随机选择年级: {grade_name}")
print(f"正在获取 [{grade_name}] 的班级列表...")
classes = get_class_list(grade_id)
if not classes:
print("未获取到班级数据")
return
cls = random.choice(classes)
class_id = cls.get('id', cls.get('classId'))
class_name = cls.get('className', cls.get('name', ''))
print(f"随机选择班级: {class_name}")
print(f"\n正在从数据库获取 [{grade_name} {class_name}] 的学生数据...")
students = get_students_from_db(grade_id, class_id)
print(f"获取到 {len(students)} 名学生")
if not students:
print("未获取到学生数据,请检查数据库连接")
return
success_count = 0
fail_count = 0
for i in range(min(count, len(students))):
stu = students[i]
stu_id, stu_no, stu_name, phone, db_grade_name, db_class_name = stu
leave_data = generate_leave_data(
stu_id, stu_name, stu_no,
grade_name, class_name, grade_id, class_id, phone
)
print(f"\n[{i+1}/{min(count, len(students))}] 为学生 {stu_name}({stu_no}) 添加请假记录...")
print(f" 请假类型: {leave_data['leaveType']}")
print(f" 请假时间: {leave_data['beginDate']} ~ {leave_data['endDate']}")
print(f" 请假节次: 第{leave_data['beginSection']}节 ~ 第{leave_data['endSection']}")
print(f" 请假事由: {leave_data['leaveReason']}")
try:
result = add_leave_record(leave_data)
if result.get('code') == 0:
print(f" ✓ 添加成功")
success_count += 1
else:
print(f" ✗ 添加失败: {result.get('msg', '未知错误')}")
fail_count += 1
except Exception as e:
print(f" ✗ 请求异常: {e}")
fail_count += 1
time.sleep(0.5)
print(f"\n{'='*50}")
print(f"批量添加完成!")
print(f"成功: {success_count}")
print(f"失败: {fail_count}")
def generate_fake_students(count=20):
students = []
for i in range(count):
stu = {
"id": i + 1,
"stu_no": f"2024{str(i+1).zfill(4)}",
"stu_name": fake.name(),
"phone": fake.phone_number(),
"grade_name": random.choice(["初一", "初二", "初三", "高一", "高二", "高三"]),
"class_name": f"{random.randint(1, 10)}",
}
students.append(stu)
return students
def batch_add_leaves_with_fake_students(count=10):
print(f"使用 Faker 生成 {count} 条请假记录...")
students = generate_fake_students(count)
success_count = 0
fail_count = 0
for i, stu in enumerate(students):
leave_data = generate_leave_data(
stu['id'], stu['stu_name'], stu['stu_no'],
stu['grade_name'], stu['class_name'],
None, None, stu['phone']
)
print(f"\n[{i+1}/{count}] 为学生 {stu['stu_name']}({stu['stu_no']}) 添加请假记录...")
print(f" 请假类型: {leave_data['leaveType']}")
print(f" 请假时间: {leave_data['beginDate']} ~ {leave_data['endDate']}")
print(f" 请假节次: 第{leave_data['beginSection']}节 ~ 第{leave_data['endSection']}")
print(f" 请假事由: {leave_data['leaveReason']}")
try:
result = add_leave_record(leave_data)
if result.get('code') == 0:
print(f" ✓ 添加成功")
success_count += 1
else:
print(f" ✗ 添加失败: {result.get('msg', '未知错误')}")
fail_count += 1
except Exception as e:
print(f" ✗ 请求异常: {e}")
fail_count += 1
time.sleep(0.5)
print(f"\n{'='*50}")
print(f"批量添加完成!")
print(f"成功: {success_count}")
print(f"失败: {fail_count}")
if __name__ == "__main__":
print("="*50)
print("批量添加学生请假信息")
print("="*50)
print("1. 从数据库获取学生并添加请假记录")
print("2. 使用 Faker 生成虚拟学生并添加请假记录")
print("="*50)
choice = input("请选择模式 (1/2): ").strip()
count = int(input("请输入要生成的请假记录数量: ").strip() or "10")
if choice == "1":
batch_add_leaves(count)
elif choice == "2":
batch_add_leaves_with_fake_students(count)
else:
print("无效选择")
@@ -0,0 +1,288 @@
from requests import get, post
from faker import Faker
import random
import time
import uuid
import json
from datetime import datetime, timedelta
fake = Faker('zh_CN')
ip = "http://band.hxzhxy.cn"
param = {
"username": "xtl",
"password": "xia123456",
"client_id": "client",
"grant_type": "password",
"client_secret": "123456",
}
def get_token():
data = get(url=f"{ip}/oauth/token", params=param).json()
return data["access_token"]
token = get_token()
header = {
"content-type": "application/json",
"authorization": f"Bearer {token}",
}
teamId = 106
def generate_leave_data(stu_id, stu_name, stu_no, grade_name, class_name, grade_id, class_id, phone=None):
leave_types = ["事假", "病假"]
leave_type = random.choice(leave_types)
is_cycle = random.choice([1, 2, 3])
begin_date = datetime.now() - timedelta(days=random.randint(0,15))
end_date = begin_date + timedelta(days=random.randint(0, 120))
begin_section = random.randint(1, 6)
end_section = random.randint(begin_section, 12)
leave_reasons = [
"身体不适,需要休息",
"家中有事需要处理",
"去医院检查身体",
"发烧感冒,需要就医",
"参加重要家庭活动",
"个人事务需要处理",
"肠胃不适,需要就医",
"头痛发热,请假休息",
"参加校外培训活动",
"家庭紧急事务",
]
disease_date = begin_date.strftime("%Y-%m-%d")
if is_cycle == 3:
week_days = ["周一", "周二", "周三", "周四", "周五"]
selected_day = random.choice(week_days)
sections = random.sample(range(1, 13), random.randint(2, 4))
sections.sort()
week_info = json.dumps({selected_day: ",".join(str(s) for s in sections)})
end_date = begin_date
else:
week_info = None
data = {
"stuId": str(stu_id),
"leaveType": leave_type,
"isCycle": is_cycle,
"leaveReason": random.choice(leave_reasons),
"beginDate": begin_date.strftime("%Y-%m-%d"),
"endDate": end_date.strftime("%Y-%m-%d"),
"beginSection": str(begin_section),
"endSection": str(end_section),
"diseaseDate": disease_date,
"symptom": "",
"fever": "",
"hospital": "",
"treatmentDate": "",
"imgUrl": "[]",
"weekInfo": week_info,
}
return data
def get_grade_list():
url = f"{ip}/uc/grade/listSelect/{teamId}?access_token={token}"
response = get(url, headers=header)
result = response.json()
if result.get('code') == 0:
return result.get('data', [])
return []
def get_class_list(grade_id):
url = f"{ip}/uc/class/listClass"
params = {
"access_token": token,
"teamId": teamId,
"gradeId": grade_id
}
response = get(url, params=params, headers=header)
result = response.json()
if result.get('code') == 0:
return result.get('data', [])
return []
def get_students_from_db(grade_id=None, class_id=None):
import pymysql
conn = pymysql.connect(
host='100.64.0.36',
port=3306,
user='root',
password='@HXYD1109mysql',
database='school_server',
charset='utf8'
)
cursor = conn.cursor()
sql = """
SELECT s.id, s.stu_no, s.stu_name, s.phone,
g.grade_name, c.class_name
FROM student s
LEFT JOIN grade g ON s.grade_id = g.id
LEFT JOIN tclass c ON s.class_id = c.id
WHERE s.team_id = %s
"""
params = [str(teamId)]
if grade_id:
sql += " AND s.grade_id = %s"
params.append(grade_id)
if class_id:
sql += " AND s.class_id = %s"
params.append(class_id)
sql += " ORDER BY RAND() LIMIT 100"
cursor.execute(sql, params)
students = cursor.fetchall()
conn.close()
return students
def add_leave_record(leave_data):
url = f"{ip}/studentLeave/add"
leave_data["access_token"] = token
response = post(url, json=leave_data, headers=header)
return response.json()
def batch_add_leaves(count=10):
print(f"正在获取年级列表...")
grades = get_grade_list()
if not grades:
print("未获取到年级数据,请检查 teamId 或 token")
return
grade = random.choice(grades)
grade_id = grade.get('id', grade.get('gradeId'))
grade_name = grade.get('gradeName', grade.get('name', ''))
print(f"随机选择年级: {grade_name}")
print(f"正在获取 [{grade_name}] 的班级列表...")
classes = get_class_list(grade_id)
if not classes:
print("未获取到班级数据")
return
cls = random.choice(classes)
class_id = cls.get('id', cls.get('classId'))
class_name = cls.get('className', cls.get('name', ''))
print(f"随机选择班级: {class_name}")
print(f"\n正在从数据库获取 [{grade_name} {class_name}] 的学生数据...")
students = get_students_from_db(grade_id, class_id)
print(f"获取到 {len(students)} 名学生")
if not students:
print("未获取到学生数据,请检查数据库连接")
return
success_count = 0
fail_count = 0
for i in range(min(count, len(students))):
stu = students[i]
stu_id, stu_no, stu_name, phone, db_grade_name, db_class_name = stu
leave_data = generate_leave_data(
stu_id, stu_name, stu_no,
grade_name, class_name, grade_id, class_id, phone
)
print(f"\n[{i+1}/{min(count, len(students))}] 为学生 {stu_name}({stu_no}) 添加请假记录...")
print(f" 请假类型: {leave_data['leaveType']}")
print(f" 请假时间: {leave_data['beginDate']} ~ {leave_data['endDate']}")
print(f" 请假节次: 第{leave_data['beginSection']}节 ~ 第{leave_data['endSection']}")
print(f" 请假事由: {leave_data['leaveReason']}")
try:
result = add_leave_record(leave_data)
if result.get('code') == 0:
print(f" ✓ 添加成功")
success_count += 1
else:
print(f" ✗ 添加失败: {result.get('msg', '未知错误')}")
fail_count += 1
except Exception as e:
print(f" ✗ 请求异常: {e}")
fail_count += 1
time.sleep(0.5)
print(f"\n{'='*50}")
print(f"批量添加完成!")
print(f"成功: {success_count}")
print(f"失败: {fail_count}")
def generate_fake_students(count=20):
students = []
for i in range(count):
stu = {
"id": i + 1,
"stu_no": f"2024{str(i+1).zfill(4)}",
"stu_name": fake.name(),
"phone": fake.phone_number(),
"grade_name": random.choice(["初一", "初二", "初三", "高一", "高二", "高三"]),
"class_name": f"{random.randint(1, 10)}",
}
students.append(stu)
return students
def batch_add_leaves_with_fake_students(count=10):
print(f"使用 Faker 生成 {count} 条请假记录...")
students = generate_fake_students(count)
success_count = 0
fail_count = 0
for i, stu in enumerate(students):
leave_data = generate_leave_data(
stu['id'], stu['stu_name'], stu['stu_no'],
stu['grade_name'], stu['class_name'],
None, None, stu['phone']
)
print(f"\n[{i+1}/{count}] 为学生 {stu['stu_name']}({stu['stu_no']}) 添加请假记录...")
print(f" 请假类型: {leave_data['leaveType']}")
print(f" 请假时间: {leave_data['beginDate']} ~ {leave_data['endDate']}")
print(f" 请假节次: 第{leave_data['beginSection']}节 ~ 第{leave_data['endSection']}")
print(f" 请假事由: {leave_data['leaveReason']}")
try:
result = add_leave_record(leave_data)
if result.get('code') == 0:
print(f" ✓ 添加成功")
success_count += 1
else:
print(f" ✗ 添加失败: {result.get('msg', '未知错误')}")
fail_count += 1
except Exception as e:
print(f" ✗ 请求异常: {e}")
fail_count += 1
time.sleep(0.5)
print(f"\n{'='*50}")
print(f"批量添加完成!")
print(f"成功: {success_count}")
print(f"失败: {fail_count}")
if __name__ == "__main__":
print("="*50)
print("批量添加学生请假信息")
print("="*50)
print("1. 从数据库获取学生并添加请假记录")
print("2. 使用 Faker 生成虚拟学生并添加请假记录")
print("="*50)
choice = input("请选择模式 (1/2): ").strip()
count = int(input("请输入要生成的请假记录数量: ").strip() or "10")
if choice == "1":
batch_add_leaves(count)
elif choice == "2":
batch_add_leaves_with_fake_students(count)
else:
print("无效选择")
@@ -0,0 +1,128 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "318e7588",
"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": [
"from requests import get,post\n",
"import time\n",
"ip = \"http://192.168.0.244:8100\"\n",
"param = {\n",
" \"username\": \"jz97621\",\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",
"}"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3c046d8d",
"metadata": {},
"outputs": [
{
"ename": "ReadTimeout",
"evalue": "HTTPConnectionPool(host='192.168.0.209', port=8100): Read timed out. (read timeout=600)",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mTimeoutError\u001b[0m Traceback (most recent call last)",
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\urllib3\\connectionpool.py:534\u001b[0m, in \u001b[0;36mHTTPConnectionPool._make_request\u001b[1;34m(self, conn, method, url, body, headers, retries, timeout, chunked, response_conn, preload_content, decode_content, enforce_content_length)\u001b[0m\n\u001b[0;32m 533\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m--> 534\u001b[0m response \u001b[38;5;241m=\u001b[39m conn\u001b[38;5;241m.\u001b[39mgetresponse()\n\u001b[0;32m 535\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m (BaseSSLError, \u001b[38;5;167;01mOSError\u001b[39;00m) \u001b[38;5;28;01mas\u001b[39;00m e:\n",
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\urllib3\\connection.py:565\u001b[0m, in \u001b[0;36mHTTPConnection.getresponse\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 564\u001b[0m \u001b[38;5;66;03m# Get the response from http.client.HTTPConnection\u001b[39;00m\n\u001b[1;32m--> 565\u001b[0m httplib_response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28msuper\u001b[39m()\u001b[38;5;241m.\u001b[39mgetresponse()\n\u001b[0;32m 567\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n",
"File \u001b[1;32md:\\Anaconda3\\Lib\\http\\client.py:1428\u001b[0m, in \u001b[0;36mHTTPConnection.getresponse\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 1427\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m-> 1428\u001b[0m response\u001b[38;5;241m.\u001b[39mbegin()\n\u001b[0;32m 1429\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mConnectionError\u001b[39;00m:\n",
"File \u001b[1;32md:\\Anaconda3\\Lib\\http\\client.py:331\u001b[0m, in \u001b[0;36mHTTPResponse.begin\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 330\u001b[0m \u001b[38;5;28;01mwhile\u001b[39;00m \u001b[38;5;28;01mTrue\u001b[39;00m:\n\u001b[1;32m--> 331\u001b[0m version, status, reason \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_read_status()\n\u001b[0;32m 332\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m status \u001b[38;5;241m!=\u001b[39m CONTINUE:\n",
"File \u001b[1;32md:\\Anaconda3\\Lib\\http\\client.py:292\u001b[0m, in \u001b[0;36mHTTPResponse._read_status\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 291\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_read_status\u001b[39m(\u001b[38;5;28mself\u001b[39m):\n\u001b[1;32m--> 292\u001b[0m line \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mstr\u001b[39m(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mfp\u001b[38;5;241m.\u001b[39mreadline(_MAXLINE \u001b[38;5;241m+\u001b[39m \u001b[38;5;241m1\u001b[39m), \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124miso-8859-1\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m 293\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(line) \u001b[38;5;241m>\u001b[39m _MAXLINE:\n",
"File \u001b[1;32md:\\Anaconda3\\Lib\\socket.py:708\u001b[0m, in \u001b[0;36mSocketIO.readinto\u001b[1;34m(self, b)\u001b[0m\n\u001b[0;32m 707\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m--> 708\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_sock\u001b[38;5;241m.\u001b[39mrecv_into(b)\n\u001b[0;32m 709\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m timeout:\n",
"\u001b[1;31mTimeoutError\u001b[0m: timed out",
"\nThe above exception was the direct cause of the following exception:\n",
"\u001b[1;31mReadTimeoutError\u001b[0m Traceback (most recent call last)",
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\requests\\adapters.py:589\u001b[0m, in \u001b[0;36mHTTPAdapter.send\u001b[1;34m(self, request, stream, timeout, verify, cert, proxies)\u001b[0m\n\u001b[0;32m 588\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m--> 589\u001b[0m resp \u001b[38;5;241m=\u001b[39m conn\u001b[38;5;241m.\u001b[39murlopen(\n\u001b[0;32m 590\u001b[0m method\u001b[38;5;241m=\u001b[39mrequest\u001b[38;5;241m.\u001b[39mmethod,\n\u001b[0;32m 591\u001b[0m url\u001b[38;5;241m=\u001b[39murl,\n\u001b[0;32m 592\u001b[0m body\u001b[38;5;241m=\u001b[39mrequest\u001b[38;5;241m.\u001b[39mbody,\n\u001b[0;32m 593\u001b[0m headers\u001b[38;5;241m=\u001b[39mrequest\u001b[38;5;241m.\u001b[39mheaders,\n\u001b[0;32m 594\u001b[0m redirect\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m,\n\u001b[0;32m 595\u001b[0m assert_same_host\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m,\n\u001b[0;32m 596\u001b[0m preload_content\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m,\n\u001b[0;32m 597\u001b[0m decode_content\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m,\n\u001b[0;32m 598\u001b[0m retries\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mmax_retries,\n\u001b[0;32m 599\u001b[0m timeout\u001b[38;5;241m=\u001b[39mtimeout,\n\u001b[0;32m 600\u001b[0m chunked\u001b[38;5;241m=\u001b[39mchunked,\n\u001b[0;32m 601\u001b[0m )\n\u001b[0;32m 603\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m (ProtocolError, \u001b[38;5;167;01mOSError\u001b[39;00m) \u001b[38;5;28;01mas\u001b[39;00m err:\n",
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\urllib3\\connectionpool.py:841\u001b[0m, in \u001b[0;36mHTTPConnectionPool.urlopen\u001b[1;34m(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, preload_content, decode_content, **response_kw)\u001b[0m\n\u001b[0;32m 839\u001b[0m new_e \u001b[38;5;241m=\u001b[39m ProtocolError(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mConnection aborted.\u001b[39m\u001b[38;5;124m\"\u001b[39m, new_e)\n\u001b[1;32m--> 841\u001b[0m retries \u001b[38;5;241m=\u001b[39m retries\u001b[38;5;241m.\u001b[39mincrement(\n\u001b[0;32m 842\u001b[0m method, url, error\u001b[38;5;241m=\u001b[39mnew_e, _pool\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m, _stacktrace\u001b[38;5;241m=\u001b[39msys\u001b[38;5;241m.\u001b[39mexc_info()[\u001b[38;5;241m2\u001b[39m]\n\u001b[0;32m 843\u001b[0m )\n\u001b[0;32m 844\u001b[0m retries\u001b[38;5;241m.\u001b[39msleep()\n",
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\urllib3\\util\\retry.py:474\u001b[0m, in \u001b[0;36mRetry.increment\u001b[1;34m(self, method, url, response, error, _pool, _stacktrace)\u001b[0m\n\u001b[0;32m 473\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m read \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mFalse\u001b[39;00m \u001b[38;5;129;01mor\u001b[39;00m method \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_is_method_retryable(method):\n\u001b[1;32m--> 474\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m reraise(\u001b[38;5;28mtype\u001b[39m(error), error, _stacktrace)\n\u001b[0;32m 475\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m read \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n",
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\urllib3\\util\\util.py:39\u001b[0m, in \u001b[0;36mreraise\u001b[1;34m(tp, value, tb)\u001b[0m\n\u001b[0;32m 38\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m value\u001b[38;5;241m.\u001b[39mwith_traceback(tb)\n\u001b[1;32m---> 39\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m value\n\u001b[0;32m 40\u001b[0m \u001b[38;5;28;01mfinally\u001b[39;00m:\n",
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\urllib3\\connectionpool.py:787\u001b[0m, in \u001b[0;36mHTTPConnectionPool.urlopen\u001b[1;34m(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, preload_content, decode_content, **response_kw)\u001b[0m\n\u001b[0;32m 786\u001b[0m \u001b[38;5;66;03m# Make the request on the HTTPConnection object\u001b[39;00m\n\u001b[1;32m--> 787\u001b[0m response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_make_request(\n\u001b[0;32m 788\u001b[0m conn,\n\u001b[0;32m 789\u001b[0m method,\n\u001b[0;32m 790\u001b[0m url,\n\u001b[0;32m 791\u001b[0m timeout\u001b[38;5;241m=\u001b[39mtimeout_obj,\n\u001b[0;32m 792\u001b[0m body\u001b[38;5;241m=\u001b[39mbody,\n\u001b[0;32m 793\u001b[0m headers\u001b[38;5;241m=\u001b[39mheaders,\n\u001b[0;32m 794\u001b[0m chunked\u001b[38;5;241m=\u001b[39mchunked,\n\u001b[0;32m 795\u001b[0m retries\u001b[38;5;241m=\u001b[39mretries,\n\u001b[0;32m 796\u001b[0m response_conn\u001b[38;5;241m=\u001b[39mresponse_conn,\n\u001b[0;32m 797\u001b[0m preload_content\u001b[38;5;241m=\u001b[39mpreload_content,\n\u001b[0;32m 798\u001b[0m decode_content\u001b[38;5;241m=\u001b[39mdecode_content,\n\u001b[0;32m 799\u001b[0m \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mresponse_kw,\n\u001b[0;32m 800\u001b[0m )\n\u001b[0;32m 802\u001b[0m \u001b[38;5;66;03m# Everything went great!\u001b[39;00m\n",
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\urllib3\\connectionpool.py:536\u001b[0m, in \u001b[0;36mHTTPConnectionPool._make_request\u001b[1;34m(self, conn, method, url, body, headers, retries, timeout, chunked, response_conn, preload_content, decode_content, enforce_content_length)\u001b[0m\n\u001b[0;32m 535\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m (BaseSSLError, \u001b[38;5;167;01mOSError\u001b[39;00m) \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[1;32m--> 536\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_raise_timeout(err\u001b[38;5;241m=\u001b[39me, url\u001b[38;5;241m=\u001b[39murl, timeout_value\u001b[38;5;241m=\u001b[39mread_timeout)\n\u001b[0;32m 537\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m\n",
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\urllib3\\connectionpool.py:367\u001b[0m, in \u001b[0;36mHTTPConnectionPool._raise_timeout\u001b[1;34m(self, err, url, timeout_value)\u001b[0m\n\u001b[0;32m 366\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(err, SocketTimeout):\n\u001b[1;32m--> 367\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m ReadTimeoutError(\n\u001b[0;32m 368\u001b[0m \u001b[38;5;28mself\u001b[39m, url, \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mRead timed out. (read timeout=\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mtimeout_value\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m)\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 369\u001b[0m ) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01merr\u001b[39;00m\n\u001b[0;32m 371\u001b[0m \u001b[38;5;66;03m# See the above comment about EAGAIN in Python 3.\u001b[39;00m\n",
"\u001b[1;31mReadTimeoutError\u001b[0m: HTTPConnectionPool(host='192.168.0.209', port=8100): Read timed out. (read timeout=600)",
"\nDuring handling of the above exception, another exception occurred:\n",
"\u001b[1;31mReadTimeout\u001b[0m Traceback (most recent call last)",
"Cell \u001b[1;32mIn[2], line 2\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mrange\u001b[39m(\u001b[38;5;241m35\u001b[39m,\u001b[38;5;241m36\u001b[39m):\n\u001b[1;32m----> 2\u001b[0m post(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mip\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m/classAttendStu/createThisWeek\u001b[39m\u001b[38;5;124m\"\u001b[39m,headers\u001b[38;5;241m=\u001b[39mheader,params\u001b[38;5;241m=\u001b[39m{\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mplanId\u001b[39m\u001b[38;5;124m\"\u001b[39m:i},timeout\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m600\u001b[39m)\u001b[38;5;241m.\u001b[39mtext\n",
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\requests\\api.py:115\u001b[0m, in \u001b[0;36mpost\u001b[1;34m(url, data, json, **kwargs)\u001b[0m\n\u001b[0;32m 103\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mpost\u001b[39m(url, data\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m, json\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs):\n\u001b[0;32m 104\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124mr\u001b[39m\u001b[38;5;124;03m\"\"\"Sends a POST request.\u001b[39;00m\n\u001b[0;32m 105\u001b[0m \n\u001b[0;32m 106\u001b[0m \u001b[38;5;124;03m :param url: URL for the new :class:`Request` object.\u001b[39;00m\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 112\u001b[0m \u001b[38;5;124;03m :rtype: requests.Response\u001b[39;00m\n\u001b[0;32m 113\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[1;32m--> 115\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m request(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mpost\u001b[39m\u001b[38;5;124m\"\u001b[39m, url, data\u001b[38;5;241m=\u001b[39mdata, json\u001b[38;5;241m=\u001b[39mjson, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n",
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\requests\\api.py:59\u001b[0m, in \u001b[0;36mrequest\u001b[1;34m(method, url, **kwargs)\u001b[0m\n\u001b[0;32m 55\u001b[0m \u001b[38;5;66;03m# By using the 'with' statement we are sure the session is closed, thus we\u001b[39;00m\n\u001b[0;32m 56\u001b[0m \u001b[38;5;66;03m# avoid leaving sockets open which can trigger a ResourceWarning in some\u001b[39;00m\n\u001b[0;32m 57\u001b[0m \u001b[38;5;66;03m# cases, and look like a memory leak in others.\u001b[39;00m\n\u001b[0;32m 58\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m sessions\u001b[38;5;241m.\u001b[39mSession() \u001b[38;5;28;01mas\u001b[39;00m session:\n\u001b[1;32m---> 59\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m session\u001b[38;5;241m.\u001b[39mrequest(method\u001b[38;5;241m=\u001b[39mmethod, url\u001b[38;5;241m=\u001b[39murl, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n",
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\requests\\sessions.py:589\u001b[0m, in \u001b[0;36mSession.request\u001b[1;34m(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)\u001b[0m\n\u001b[0;32m 584\u001b[0m send_kwargs \u001b[38;5;241m=\u001b[39m {\n\u001b[0;32m 585\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtimeout\u001b[39m\u001b[38;5;124m\"\u001b[39m: timeout,\n\u001b[0;32m 586\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mallow_redirects\u001b[39m\u001b[38;5;124m\"\u001b[39m: allow_redirects,\n\u001b[0;32m 587\u001b[0m }\n\u001b[0;32m 588\u001b[0m send_kwargs\u001b[38;5;241m.\u001b[39mupdate(settings)\n\u001b[1;32m--> 589\u001b[0m resp \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39msend(prep, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39msend_kwargs)\n\u001b[0;32m 591\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m resp\n",
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\requests\\sessions.py:703\u001b[0m, in \u001b[0;36mSession.send\u001b[1;34m(self, request, **kwargs)\u001b[0m\n\u001b[0;32m 700\u001b[0m start \u001b[38;5;241m=\u001b[39m preferred_clock()\n\u001b[0;32m 702\u001b[0m \u001b[38;5;66;03m# Send the request\u001b[39;00m\n\u001b[1;32m--> 703\u001b[0m r \u001b[38;5;241m=\u001b[39m adapter\u001b[38;5;241m.\u001b[39msend(request, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[0;32m 705\u001b[0m \u001b[38;5;66;03m# Total elapsed time of the request (approximately)\u001b[39;00m\n\u001b[0;32m 706\u001b[0m elapsed \u001b[38;5;241m=\u001b[39m preferred_clock() \u001b[38;5;241m-\u001b[39m start\n",
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\requests\\adapters.py:635\u001b[0m, in \u001b[0;36mHTTPAdapter.send\u001b[1;34m(self, request, stream, timeout, verify, cert, proxies)\u001b[0m\n\u001b[0;32m 633\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m SSLError(e, request\u001b[38;5;241m=\u001b[39mrequest)\n\u001b[0;32m 634\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(e, ReadTimeoutError):\n\u001b[1;32m--> 635\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m ReadTimeout(e, request\u001b[38;5;241m=\u001b[39mrequest)\n\u001b[0;32m 636\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(e, _InvalidHeader):\n\u001b[0;32m 637\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m InvalidHeader(e, request\u001b[38;5;241m=\u001b[39mrequest)\n",
"\u001b[1;31mReadTimeout\u001b[0m: HTTPConnectionPool(host='192.168.0.209', port=8100): Read timed out. (read timeout=600)"
]
},
{
"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 i in range(35,36):\n",
" post(f\"{ip}/classAttendStu/createThisWeek\",headers=header,params={\"planId\":i},timeout=600).text"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "343a9e44",
"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
}
+774 -11
View File
@@ -2,24 +2,787 @@
"cells": [
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"id": "83d3f4d5",
"metadata": {},
"outputs": [],
"source": [
"from requests import get,post\n",
"import pandas as pd\n",
"import time\n",
"teamId = 19\n",
"ip = \"http://192.168.0.209:8100\"\n",
"param = {\n",
" \"username\": \"zhongwei\",\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",
"}"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "873025e5",
"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>。"
]
"data": {
"text/plain": [
"{'scrawlMaxSize': 10485760,\n",
" 'videoMaxSize': 104857600,\n",
" 'imageInsertAlign': 'none',\n",
" 'catcherMaxSize': 10485760,\n",
" 'snapscreenUrlPrefix': '',\n",
" 'videoActionName': 'video',\n",
" 'fileActionName': 'file',\n",
" 'imageCompressBorder': 5000,\n",
" 'imageManagerUrlPrefix': '',\n",
" 'imageManagerAllowFiles': ['.jpg', '.png', '.jpeg'],\n",
" 'scrawlUrlPrefix': '',\n",
" 'scrawlFieldName': 'file',\n",
" 'imageMaxSize': 10485760,\n",
" 'imageAllowFiles': ['.jpg', '.png', '.jpeg'],\n",
" 'snapscreenActionName': 'snap',\n",
" 'fileMaxSize': 104857600,\n",
" 'catcherActionName': 'catch',\n",
" 'fileFieldName': 'file',\n",
" 'fileManagerAllowFiles': ['.zip', '.pdf', '.doc'],\n",
" 'fileManagerActionName': 'listFile',\n",
" 'snapscreenInsertAlign': 'none',\n",
" 'fileUrlPrefix': '',\n",
" 'scrawlActionName': 'crawl',\n",
" 'imageManagerInsertAlign': 'none',\n",
" 'videoFieldName': 'file',\n",
" 'catcherLocalDomain': ['127.0.0.1', 'localhost'],\n",
" 'fileManagerListSize': 20,\n",
" 'imageActionName': 'image',\n",
" 'imageCompressEnable': True,\n",
" 'imageFieldName': 'file',\n",
" 'imageUrlPrefix': '',\n",
" 'videoUrlPrefix': '',\n",
" 'scrawlInsertAlign': 'none',\n",
" 'fileAllowFiles': ['.zip', '.pdf', '.doc'],\n",
" 'catcherUrlPrefix': '',\n",
" 'imageManagerListSize': 20,\n",
" 'catcherFieldName': 'source',\n",
" 'fileManagerUrlPrefix': '',\n",
" 'catcherAllowFiles': ['.jpg', '.png', '.jpeg'],\n",
" 'videoAllowFiles': ['.mp4'],\n",
" 'formulaConfig': {'imageUrlTemplate': 'https://r.latexeasy.com/image.svg?{}'},\n",
" 'imageManagerActionName': 'listImage'}"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.to_excel('重新分班模板 (4).xlsx',index=False)"
"get(f\"{ip}/uc/project/ueditor\",headers=header).json()\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c747c26d",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'success': True,\n",
" 'msg': '操作成功',\n",
" 'code': 0,\n",
" 'data': [{'id': 11365245,\n",
" 'stuName': '郭嘉欣',\n",
" 'serialNo': '0022681452',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': 1776050001000,\n",
" 'endTime': None,\n",
" 'intoState': 1,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8864,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': None},\n",
" {'id': 11365248,\n",
" 'stuName': '雷江昊然',\n",
" 'serialNo': '0022681580',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': None,\n",
" 'endTime': None,\n",
" 'intoState': None,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8867,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': None},\n",
" {'id': 11365267,\n",
" 'stuName': '吴梓萌',\n",
" 'serialNo': '0022722732',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': 1776036853000,\n",
" 'endTime': None,\n",
" 'intoState': 1,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8886,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': 1776036842000},\n",
" {'id': 11365241,\n",
" 'stuName': '程柏涵',\n",
" 'serialNo': '0022795772',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': 1776036329000,\n",
" 'endTime': None,\n",
" 'intoState': 1,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8860,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': 1776036336000},\n",
" {'id': 11365249,\n",
" 'stuName': '李然壹',\n",
" 'serialNo': '0022795964',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': 1776035905000,\n",
" 'endTime': None,\n",
" 'intoState': 1,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8868,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': 1776035899000},\n",
" {'id': 11365274,\n",
" 'stuName': '杨雨嘉',\n",
" 'serialNo': '0022799916',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': 1776036401000,\n",
" 'endTime': None,\n",
" 'intoState': 1,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8893,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': 1776036382000},\n",
" {'id': 11365238,\n",
" 'stuName': '蔡雨芮',\n",
" 'serialNo': '0022822732',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': 1776035453000,\n",
" 'endTime': None,\n",
" 'intoState': 1,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8857,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': 1776035468000},\n",
" {'id': 11365265,\n",
" 'stuName': '魏俊洁',\n",
" 'serialNo': '0022830076',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': 1776036331000,\n",
" 'endTime': None,\n",
" 'intoState': 1,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8884,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': 1776036311000},\n",
" {'id': 11365277,\n",
" 'stuName': '姚祉玲',\n",
" 'serialNo': '0022834044',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': 1776036142000,\n",
" 'endTime': None,\n",
" 'intoState': 1,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8896,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': 1776036135000},\n",
" {'id': 11365260,\n",
" 'stuName': '汪昊涵',\n",
" 'serialNo': '3107628753',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': None,\n",
" 'endTime': None,\n",
" 'intoState': None,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8879,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': None},\n",
" {'id': 11365244,\n",
" 'stuName': '郭佳',\n",
" 'serialNo': '3108354337',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': 1776035462000,\n",
" 'endTime': None,\n",
" 'intoState': 1,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8863,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': 1776035455000},\n",
" {'id': 11365270,\n",
" 'stuName': '徐文昊',\n",
" 'serialNo': '3108354417',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': 1776036866000,\n",
" 'endTime': None,\n",
" 'intoState': 1,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8889,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': 1776036861000},\n",
" {'id': 11367018,\n",
" 'stuName': '唐悠雯',\n",
" 'serialNo': '3108388513',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': None,\n",
" 'endTime': None,\n",
" 'intoState': None,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 10981,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': None},\n",
" {'id': 11365259,\n",
" 'stuName': '万梓涵',\n",
" 'serialNo': '3108390097',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': None,\n",
" 'endTime': None,\n",
" 'intoState': None,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8878,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': None},\n",
" {'id': 11365279,\n",
" 'stuName': '朱泓安',\n",
" 'serialNo': '3108390369',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': 1776036955000,\n",
" 'endTime': None,\n",
" 'intoState': 1,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8898,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': 1776036996000},\n",
" {'id': 11365240,\n",
" 'stuName': '陈峻鑫',\n",
" 'serialNo': '3108390481',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': 1776036695000,\n",
" 'endTime': None,\n",
" 'intoState': 1,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8859,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': 1776036686000},\n",
" {'id': 11365242,\n",
" 'stuName': '代晋铭',\n",
" 'serialNo': '3108415505',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': 1776047344000,\n",
" 'endTime': None,\n",
" 'intoState': 1,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8861,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': 1776047354000},\n",
" {'id': 11365257,\n",
" 'stuName': '唐裕康',\n",
" 'serialNo': '3108415697',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': 1776036869000,\n",
" 'endTime': None,\n",
" 'intoState': 1,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8876,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': 1776036873000},\n",
" {'id': 11365253,\n",
" 'stuName': '吕仕瑞',\n",
" 'serialNo': '3108435409',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': 1776035766000,\n",
" 'endTime': None,\n",
" 'intoState': 1,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8872,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': 1776036856000},\n",
" {'id': 11365255,\n",
" 'stuName': '彭雨绮',\n",
" 'serialNo': '3108435585',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': 1776036569000,\n",
" 'endTime': None,\n",
" 'intoState': 1,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8874,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': 1776036555000},\n",
" {'id': 11365256,\n",
" 'stuName': '孙婧琪',\n",
" 'serialNo': '3108441105',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': 1776036193000,\n",
" 'endTime': None,\n",
" 'intoState': 1,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8875,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': 1776036185000},\n",
" {'id': 11365258,\n",
" 'stuName': '涂凤扬',\n",
" 'serialNo': '3108442785',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': 1776036470000,\n",
" 'endTime': None,\n",
" 'intoState': 1,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8877,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': 1776036497000},\n",
" {'id': 11365246,\n",
" 'stuName': '何俊达',\n",
" 'serialNo': '3108460593',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': 1776036368000,\n",
" 'endTime': None,\n",
" 'intoState': 1,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8865,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': 1776036374000},\n",
" {'id': 11365271,\n",
" 'stuName': '徐梓轩',\n",
" 'serialNo': '3108464465',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': 1776035922000,\n",
" 'endTime': None,\n",
" 'intoState': 1,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8890,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': 1776035916000},\n",
" {'id': 11365278,\n",
" 'stuName': '张紫涵',\n",
" 'serialNo': '3108580737',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': 1776035797000,\n",
" 'endTime': None,\n",
" 'intoState': 1,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8897,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': 1776035794000},\n",
" {'id': 11365252,\n",
" 'stuName': '罗靖洁',\n",
" 'serialNo': '3108583121',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': None,\n",
" 'endTime': None,\n",
" 'intoState': None,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8871,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': None},\n",
" {'id': 11365261,\n",
" 'stuName': '王露静',\n",
" 'serialNo': '3108583313',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': 1776036402000,\n",
" 'endTime': None,\n",
" 'intoState': 1,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8880,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': 1776036386000},\n",
" {'id': 11365247,\n",
" 'stuName': '侯家鸿',\n",
" 'serialNo': '3108588801',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': 1776035778000,\n",
" 'endTime': None,\n",
" 'intoState': 1,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8866,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': 1776035778000},\n",
" {'id': 11365262,\n",
" 'stuName': '王洋梓桐',\n",
" 'serialNo': '3108598337',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': 1776059188000,\n",
" 'endTime': None,\n",
" 'intoState': 1,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8881,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': None},\n",
" {'id': 11365268,\n",
" 'stuName': '夏紫萱',\n",
" 'serialNo': '3108601489',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': 1776036824000,\n",
" 'endTime': None,\n",
" 'intoState': 1,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8887,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': 1776036812000},\n",
" {'id': 11365250,\n",
" 'stuName': '刘鸿维',\n",
" 'serialNo': '3108601841',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': 1776036278000,\n",
" 'endTime': None,\n",
" 'intoState': 1,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8869,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': 1776036308000},\n",
" {'id': 11365276,\n",
" 'stuName': '姚谊诚',\n",
" 'serialNo': '3108603729',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': None,\n",
" 'endTime': None,\n",
" 'intoState': None,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8895,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': 1776035945000},\n",
" {'id': 11365269,\n",
" 'stuName': '谢汶良',\n",
" 'serialNo': '3108605233',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': 1776036656000,\n",
" 'endTime': None,\n",
" 'intoState': 1,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8888,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': 1776036671000},\n",
" {'id': 11365273,\n",
" 'stuName': '杨佳颖',\n",
" 'serialNo': '3108606065',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': 1776036436000,\n",
" 'endTime': None,\n",
" 'intoState': 1,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8892,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': 1776036424000},\n",
" {'id': 11365239,\n",
" 'stuName': '曹雅莉',\n",
" 'serialNo': '3108606273',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': 1776036335000,\n",
" 'endTime': None,\n",
" 'intoState': 1,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8858,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': 1776036329000},\n",
" {'id': 11365251,\n",
" 'stuName': '刘蔚菘',\n",
" 'serialNo': '3108606433',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': 1776036055000,\n",
" 'endTime': None,\n",
" 'intoState': 1,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8870,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': 1776036089000},\n",
" {'id': 11365275,\n",
" 'stuName': '杨子涵',\n",
" 'serialNo': '3108607729',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': None,\n",
" 'endTime': None,\n",
" 'intoState': None,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8894,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': 1776036154000},\n",
" {'id': 11365243,\n",
" 'stuName': '符唐骏',\n",
" 'serialNo': '3108614209',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': 1776035795000,\n",
" 'endTime': None,\n",
" 'intoState': 1,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8862,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': 1776035802000},\n",
" {'id': 11365263,\n",
" 'stuName': '位云馨',\n",
" 'serialNo': '3108633697',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': None,\n",
" 'endTime': None,\n",
" 'intoState': None,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8882,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': None},\n",
" {'id': 11365266,\n",
" 'stuName': '吴琳楠',\n",
" 'serialNo': '3108635073',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': 1776036323000,\n",
" 'endTime': None,\n",
" 'intoState': 1,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8885,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': 1776036316000},\n",
" {'id': 11365272,\n",
" 'stuName': '杨丰瑞',\n",
" 'serialNo': '3108650865',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': 1776036330000,\n",
" 'endTime': None,\n",
" 'intoState': 1,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8891,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': 1776036322000},\n",
" {'id': 11365254,\n",
" 'stuName': '庞雨橦',\n",
" 'serialNo': '3108679985',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': 1776035795000,\n",
" 'endTime': None,\n",
" 'intoState': 1,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8873,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': 1776035786000},\n",
" {'id': 11365264,\n",
" 'stuName': '魏本杨',\n",
" 'serialNo': '3108682001',\n",
" 'gradeId': 126,\n",
" 'classId': 474,\n",
" 'startTime': None,\n",
" 'endTime': None,\n",
" 'intoState': None,\n",
" 'boarder': 2,\n",
" 'attendDate': 1776009600000,\n",
" 'stuId': 8883,\n",
" 'teamId': 119,\n",
" 'lockTime': None,\n",
" 'gateTime': None,\n",
" 'gateStartTime': None}]}"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"get(\n",
" f\"{ip}/classAttend/into/pre\",\n",
" headers=header,\n",
" params={\n",
" \"teamId\": 119,\n",
" \"dateTime\": 1776009600000,\n",
" \"teaName\": \"马靖\",\n",
" \"serial\": 9,\n",
" \"courseName\": \"26学部1班-班会\",\n",
" },\n",
").json()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3d80ee07",
"metadata": {},
"outputs": [],
"source": [
"attendDate: \"2026-04-13\"\n",
"classRoom: \"2510\"\n",
"color: \"#FB923C\"\n",
"courseName: \"26学部1班-班会\"\n",
"serial: \"第9节\"\n",
"serialnum: \"9\"\n",
"status: \"下节课\"\n",
"teaName: \"马靖\"\n",
"timeSlot: \"16:20-17:00\""
]
}
],
+27
View File
@@ -0,0 +1,27 @@
import pymysql
import snowflake
from faker import Faker
fake = Faker('zh_CN')
import random
# 创建数据库连接
conn = pymysql.connect(
host='11.1.1.5',
user='root',
password='@HXYD1109mysql',
database='school_server',
charset='utf8'
)
# 创建游标对象
cursor = conn.cursor()
def create_table(cursor,result):
data = []
for i in result:
list_list = list(i)
des=cursor.description # 获取表详情,字段名,长度,属性等
t = ",".join([item[0] for item in des])
table_head = t.split(',') # # 查询表列名 用,分割
dict_result = dict(zip(table_head, list_list)) # 打包为元组的列表 再转换为字典
data.append(dict_result) # 将字典添加到list_result中
return data
@@ -0,0 +1,216 @@
from requests import get
import time
import os
import pandas as pd
import tqdm
from datetime import datetime, timedelta
teamId = 19
ip = "http://band.hxzhxy.cn"
param = {
"username": "xtl",
"password": "xia123456",
"client_id": "client",
"grant_type": "password",
"client_secret": "123456",
}
data = get(url=f"{ip}/oauth/token", params=param).json()
token = data["access_token"]
header = {
"content-type": "application/json",
"authorization": f"Bearer {token}",
}
url = f"{ip}/pay/trads/findPayTtadsNews"
output_dir = r"e:\project\python\工具\智慧校园\本部\消费数据\24-26消费信息"
FIELD_MAP = {
"gradeName": "年级名称",
"termName": "交易地点",
"teamId": "团队ID",
"stuId": "学生ID",
"areaName": "设备区域名称",
"bagName": "交易账户",
"userNumb": "学号/工号",
"dealCount": "交易流水号/笔次",
"className": "班级名称",
"remark": "备注/充值类型",
"cardCode": "物理卡号",
"dealType": "消费方式",
"cardValue": "余额",
"userXm": "姓名",
"cardNo": "卡号",
"createDate": "入库时间",
"dealValue": "交易金额",
"recordType": "记录类型",
"id": "记录ID",
"recordId": "终端原始记录ID",
"userId": "用户唯一ID",
"dealTime": "交易时间"
}
OUTPUT_COLUMNS = list(FIELD_MAP.values())
def day_range(start_date, end_date):
current = start_date
while current <= end_date:
yield current
current += timedelta(days=1)
def month_range(start_date, end_date):
current = datetime(start_date.year, start_date.month, 1)
end_month = datetime(end_date.year, end_date.month, 1)
while current <= end_month:
yield current
if current.month == 12:
current = datetime(current.year + 1, 1, 1)
else:
current = datetime(current.year, current.month + 1, 1)
def to_timestamp_ms(dt):
return int(dt.timestamp() * 1000)
def fetch_day_records(day_dt):
day_start = datetime(day_dt.year, day_dt.month, day_dt.day, 0, 0, 0)
day_end = datetime(day_dt.year, day_dt.month, day_dt.day, 23, 59, 59)
begin_time = to_timestamp_ms(day_start)
end_time = to_timestamp_ms(day_end)
page_number = 0
page_size = 100
day_records = []
while True:
params = {
"teamId": teamId,
"pageNumber": page_number,
"pageSize": page_size,
"screen": 1,
"beginTime": begin_time,
"endTime": end_time,
"name": "",
"recordType": 1,
"termName": "",
"type": 1,
"classId": "",
"gradeId": ""
}
resp = get(url=url, params=params, headers=header, timeout=60)
resp.raise_for_status()
result = resp.json()
if not result.get("success"):
raise Exception(f"接口返回失败: {result}")
data = result.get("data") or {}
content = data.get("content") or []
total_pages = data.get("totalPages", 0)
total_elements = data.get("totalElements", 0)
day_records.extend(content)
print(
f"{day_dt.strftime('%Y-%m-%d')}{page_number + 1}/{max(total_pages, 1)} 页,"
f"当前页 {len(content)} 条,当天累计 {len(day_records)} 条,总计 {total_elements}"
)
page_number += 1
if page_number >= total_pages or total_pages == 0:
break
time.sleep(0.1)
return day_records
def parse_date(date_str):
return datetime.strptime(date_str, "%Y-%m-%d")
def convert_records_to_df(records):
rows = []
for record in records:
row = {}
for en_key, cn_key in FIELD_MAP.items():
row[cn_key] = record.get(en_key)
rows.append(row)
if not rows:
return pd.DataFrame(columns=OUTPUT_COLUMNS)
return pd.DataFrame(rows, columns=OUTPUT_COLUMNS)
def get_month_start_end(month_dt, start_date, end_date):
month_start = datetime(month_dt.year, month_dt.month, 1)
if month_dt.month == 12:
next_month = datetime(month_dt.year + 1, 1, 1)
else:
next_month = datetime(month_dt.year, month_dt.month + 1, 1)
month_end = next_month - timedelta(days=1)
if month_start < start_date:
month_start = start_date
if month_end > end_date:
month_end = end_date
return month_start, month_end
def save_month_excel(month_dt, records):
df = convert_records_to_df(records)
file_name = f"{month_dt.strftime('%Y%m')}_学生消费记录.xlsx"
file_path = os.path.join(output_dir, file_name)
df.to_excel(file_path, index=False)
return file_path, len(df)
def main():
print("开始拉取数据...")
start_date_str = os.getenv("START_DATE", "2024-01-01")
end_date_str = os.getenv("END_DATE", "2026-05-19")
start_date = parse_date(start_date_str)
end_date = parse_date(end_date_str)
all_month_list = list(month_range(start_date, end_date))
total_records = 0
success_months = 0
with tqdm.tqdm(all_month_list, desc="按月拉取消费记录") as month_pbar:
for month_dt in month_pbar:
try:
month_start, month_end = get_month_start_end(month_dt, start_date, end_date)
month_records = []
month_days = list(day_range(month_start, month_end))
for day_dt in month_days:
day_records = fetch_day_records(day_dt)
month_records.extend(day_records)
time.sleep(0.2)
file_path, count = save_month_excel(month_dt, month_records)
total_records += count
success_months += 1
month_pbar.set_postfix({
"month": month_dt.strftime("%Y-%m"),
"count": count,
"total": total_records
})
print(f"已输出: {file_path}")
except Exception as e:
print(f"{month_dt.strftime('%Y-%m')} 拉取失败: {e}")
print("\n完成")
print(f"成功月份: {success_months}")
print(f"总记录数: {total_records}")
print(f"输出目录: {output_dir}")
if __name__ == "__main__":
main()
@@ -0,0 +1,89 @@
import pandas as pd
import json
from datetime import datetime
# 读取Excel文件
file_path = r'e:\project\python\工具\智慧校园\本部\消费数据\2024学生.xlsx'
df = pd.read_excel(file_path)
print("=" * 80)
print("学生消费数据提取")
print("=" * 80)
# 1. 提取年级ID和班级ID(供用户查表)
grade_ids = sorted(df['gradeId'].unique().tolist())
class_ids = sorted(df['classId'].unique().tolist())
print(f"\n【年级ID列表】(共{len(grade_ids)}个):")
print(grade_ids)
print(f"\n【班级ID列表】(共{len(class_ids)}个):")
print(class_ids)
# 2. 提取学生消费信息
student_records = []
for _, row in df.iterrows():
record = {
'学号': str(row['stuNo']),
'姓名': row['stuName'],
'年级ID': row['gradeId'],
'班级ID': row['classId'],
'支付金额(元)': row['totalFee'] / 100, # 转换为元
'支付状态': '支付成功' if row['payState'] == 1 else '其他',
'创建时间': row['createTime'].strftime('%Y-%m-%d %H:%M:%S') if pd.notna(row['createTime']) else '',
'支付时间': row['payTime'].strftime('%Y-%m-%d %H:%M:%S') if pd.notna(row['payTime']) else '',
'物理卡号': str(row['serialNo']) if pd.notna(row['serialNo']) else '',
'teamId': row['teamId']
}
student_records.append(record)
# 3. 统计信息
print(f"\n【数据统计】")
print(f"总记录数: {len(student_records)}")
print(f"唯一学生数: {df['stuNo'].nunique()}")
print(f"总金额: {df['totalFee'].sum() / 100:.2f}")
# 4. 按年级统计
print(f"\n【按年级统计】")
grade_stats = df.groupby('gradeId').agg({
'stuNo': 'nunique',
'totalFee': 'sum'
}).reset_index()
grade_stats.columns = ['年级ID', '学生人数', '总金额(分)']
grade_stats['总金额(元)'] = grade_stats['总金额(分)'] / 100
print(grade_stats.to_string(index=False))
# 5. 按班级统计
print(f"\n【按班级统计】")
class_stats = df.groupby('classId').agg({
'stuNo': 'nunique',
'totalFee': 'sum'
}).reset_index()
class_stats.columns = ['班级ID', '学生人数', '总金额(分)']
class_stats['总金额(元)'] = class_stats['总金额(分)'] / 100
print(class_stats.to_string(index=False))
# 6. 保存详细记录到JSON
output_file = r'e:\project\python\工具\智慧校园\本部\消费数据\student_records.json'
with open(output_file, 'w', encoding='utf-8') as f:
json.dump(student_records, f, ensure_ascii=False, indent=2)
print(f"\n【输出文件】")
print(f"详细记录已保存到: {output_file}")
# 7. 保存ID映射表(等待用户补充年级和班级名称)
id_mapping = {
'grade_ids': grade_ids,
'class_ids': class_ids,
'note': '请查询数据库补充年级名称和班级名称'
}
id_mapping_file = r'e:\project\python\工具\智慧校园\本部\消费数据\id_mapping.json'
with open(id_mapping_file, 'w', encoding='utf-8') as f:
json.dump(id_mapping, f, ensure_ascii=False, indent=2)
print(f"ID映射表已保存到: {id_mapping_file}")
print("\n请查询数据库,告诉我以下ID对应的名称:")
print(f"年级ID: {grade_ids}")
print(f"班级ID: {class_ids}")
@@ -0,0 +1,25 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "72fd36ef",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "base",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python",
"version": "3.12.4"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
@@ -0,0 +1,38 @@
import pandas as pd
import json
# 读取Excel文件
df = pd.read_excel('e:/project/python/工具/智慧校园/本部/消费数据/2024学生.xlsx')
print("=== Excel文件基本信息 ===")
print(f"数据形状: {df.shape}")
print(f"\n列名: {df.columns.tolist()}")
print("\n=== 前10行数据 ===")
print(df.head(10))
print("\n=== 数据类型 ===")
print(df.dtypes)
# 提取唯一值
print("\n=== 唯一值统计 ===")
for col in df.columns:
unique_count = df[col].nunique()
print(f"{col}: {unique_count} 个唯一值")
if unique_count <= 20:
print(f" 值: {df[col].unique().tolist()}")
# 检查是否有年级和班级相关字段
grade_class_cols = [col for col in df.columns if any(keyword in col.lower() for keyword in ['年级', '班级', 'grade', 'class'])]
print(f"\n=== 年级/班级相关字段: {grade_class_cols} ===")
# 保存列名信息供后续使用
with open('e:/project/python/工具/智慧校园/本部/消费数据/excel_info.json', 'w', encoding='utf-8') as f:
info = {
'columns': df.columns.tolist(),
'shape': df.shape,
'sample_data': df.head(5).to_dict('records')
}
json.dump(info, f, ensure_ascii=False, indent=2)
print("\n=== 信息已保存到 excel_info.json ===")
@@ -0,0 +1,24 @@
import pandas as pd
import sys
# 读取Excel文件
file_path = r'e:\project\python\工具\智慧校园\本部\消费数据\2024学生.xlsx'
df = pd.read_excel(file_path)
print("数据形状:", df.shape)
print("\n列名:")
for i, col in enumerate(df.columns):
print(f"{i+1}. {col}")
print("\n前5行数据:")
print(df.head().to_string())
# 检查年级和班级相关字段
print("\n查找年级/班级相关字段...")
for col in df.columns:
if any(keyword in str(col) for keyword in ['年级', '班级', 'grade', 'class', 'Grade', 'Class']):
print(f"找到字段: {col}")
print(f"唯一值: {df[col].unique()[:10]}") # 只显示前10个唯一值
print("\n数据类型:")
print(df.dtypes)
@@ -0,0 +1,17 @@
import pandas as pd
# 读取年级表和班级表
grade_df = pd.read_excel(r'e:\project\python\工具\智慧校园\本部\消费数据\年级表.xlsx')
class_df = pd.read_excel(r'e:\project\python\工具\智慧校园\本部\消费数据\班级表.xlsx')
print("=== 年级表 ===")
print(f"形状: {grade_df.shape}")
print(f"列名: {grade_df.columns.tolist()}")
print("\n前10行:")
print(grade_df.head(10))
print("\n=== 班级表 ===")
print(f"形状: {class_df.shape}")
print(f"列名: {class_df.columns.tolist()}")
print("\n前10行:")
print(class_df.head(10))
@@ -0,0 +1,140 @@
import pandas as pd
from datetime import datetime
# 读取所有数据
print("正在读取数据...")
consumption_df = pd.read_excel(r'e:\project\python\工具\智慧校园\本部\消费数据\2024学生.xlsx')
grade_df = pd.read_excel(r'e:\project\python\工具\智慧校园\本部\消费数据\年级表.xlsx')
class_df = pd.read_excel(r'e:\project\python\工具\智慧校园\本部\消费数据\班级表.xlsx')
print(f"消费数据: {consumption_df.shape[0]} 条记录")
print(f"年级表: {grade_df.shape[0]} 个年级")
print(f"班级表: {class_df.shape[0]} 个班级")
# 创建年级ID到名称的映射
grade_map = dict(zip(grade_df['id'], grade_df['grade_name']))
# 创建班级ID到名称的映射
class_map = dict(zip(class_df['id'], class_df['class_name']))
# 创建班级ID到年级ID的映射(用于验证)
class_to_grade_map = dict(zip(class_df['id'], class_df['grade_id']))
print("\n正在处理消费数据...")
# 处理消费数据
processed_data = []
for _, row in consumption_df.iterrows():
grade_id = row['gradeId']
class_id = row['classId']
# 获取年级和班级名称
grade_name = grade_map.get(grade_id, f'未知年级({grade_id})')
class_name = class_map.get(class_id, f'未知班级({class_id})')
# 处理时间格式
create_time = row['createTime']
pay_time = row['payTime']
if pd.notna(create_time):
if isinstance(create_time, str):
create_time_str = create_time
else:
create_time_str = create_time.strftime('%Y-%m-%d %H:%M:%S')
else:
create_time_str = ''
if pd.notna(pay_time):
if isinstance(pay_time, str):
pay_time_str = pay_time
else:
pay_time_str = pay_time.strftime('%Y-%m-%d %H:%M:%S')
else:
pay_time_str = ''
# 处理支付状态
pay_state_map = {0: '确认中', 1: '支付成功', 2: '已取消', 3: '退款'}
pay_state = pay_state_map.get(row['payState'], f'未知状态({row["payState"]})')
# 处理充值状态
change_state_map = {0: '充值中', 1: '已取消', 2: '充值成功', 3: '充值失败'}
change_state = change_state_map.get(row['changeState'], f'未知状态({row["changeState"]})')
record = {
'学号': str(row['stuNo']),
'姓名': row['stuName'],
'年级ID': grade_id,
'年级名称': grade_name,
'班级ID': class_id,
'班级名称': class_name,
'支付金额(元)': row['totalFee'] / 100,
'支付状态': pay_state,
'充值状态': change_state,
'创建时间': create_time_str,
'支付时间': pay_time_str,
'物理卡号': str(int(row['serialNo'])) if pd.notna(row['serialNo']) else '',
'订单编号': row['outTradeNo'],
'微信订单号': row['transactionId'] if pd.notna(row['transactionId']) else '',
'支付手机号': str(row['wxPhone']),
'teamId': row['teamId']
}
processed_data.append(record)
# 创建DataFrame
result_df = pd.DataFrame(processed_data)
# 生成输出文件名
output_file = r'e:\project\python\工具\智慧校园\本部\消费数据\学生消费记录整理.xlsx'
# 写入Excel,使用多个sheet
with pd.ExcelWriter(output_file, engine='openpyxl') as writer:
# Sheet 1: 详细记录
result_df.to_excel(writer, sheet_name='详细记录', index=False)
# Sheet 2: 按年级汇总
grade_summary = result_df.groupby(['年级ID', '年级名称']).agg({
'学号': 'nunique',
'支付金额(元)': 'sum',
'姓名': 'count'
}).reset_index()
grade_summary.columns = ['年级ID', '年级名称', '学生人数', '总金额(元)', '消费笔数']
grade_summary = grade_summary.sort_values('年级ID')
grade_summary.to_excel(writer, sheet_name='按年级汇总', index=False)
# Sheet 3: 按班级汇总
class_summary = result_df.groupby(['班级ID', '班级名称', '年级名称']).agg({
'学号': 'nunique',
'支付金额(元)': 'sum',
'姓名': 'count'
}).reset_index()
class_summary.columns = ['班级ID', '班级名称', '年级名称', '学生人数', '总金额(元)', '消费笔数']
class_summary = class_summary.sort_values(['年级名称', '班级ID'])
class_summary.to_excel(writer, sheet_name='按班级汇总', index=False)
# Sheet 4: 按学生汇总
student_summary = result_df.groupby(['学号', '姓名', '年级名称', '班级名称']).agg({
'支付金额(元)': 'sum',
'创建时间': 'count'
}).reset_index()
student_summary.columns = ['学号', '姓名', '年级名称', '班级名称', '总金额(元)', '消费笔数']
student_summary = student_summary.sort_values(['年级名称', '班级名称', '学号'])
student_summary.to_excel(writer, sheet_name='按学生汇总', index=False)
print(f"\n✅ 数据整理完成!")
print(f"📁 输出文件: {output_file}")
print(f"\n📊 统计信息:")
print(f" - 总记录数: {len(result_df)}")
print(f" - 唯一学生数: {result_df['学号'].nunique()}")
print(f" - 总金额: {result_df['支付金额(元)'].sum():.2f}")
print(f"\n📋 Excel包含以下工作表:")
print(f" 1. 详细记录 - 所有消费明细")
print(f" 2. 按年级汇总 - 各年级消费统计")
print(f" 3. 按班级汇总 - 各班级消费统计")
print(f" 4. 按学生汇总 - 各学生消费统计")
# 显示年级分布
print(f"\n🏫 年级分布:")
grade_dist = result_df.groupby('年级名称')['学号'].nunique().sort_values(ascending=False)
for grade, count in grade_dist.items():
print(f" {grade}: {count}")
@@ -0,0 +1,309 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "318e7588",
"metadata": {},
"outputs": [],
"source": [
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3c046d8d",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'{\"success\":true,\"msg\":\"操作成功\",\"code\":0,\"data\":null}'"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "27c18f0a",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 2,
"id": "343a9e44",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[]\n"
]
}
],
"source": [
"grade_id = [110,120,124, 126,127,128, 114,119,129]\n",
"sql = f'''\n",
"select \n",
" mm.id,\n",
" mm.stu_no,\n",
" mm.stu_name,\n",
" bb.student_id,\n",
" mm.plan_id -- 这里直接显示 plan_id\n",
"from (\n",
" select \n",
" s.id,\n",
" s.stu_no,\n",
" s.stu_name,\n",
" a.plan_id -- 子查询把 plan_id 带出来\n",
" from student s \n",
" inner join class_attend_stu a on s.id = a.student_id\n",
" where s.grade_id in ({\",\".join(map(str,grade_id))}) \n",
" and a.plan_id=41\n",
" group by s.id, s.stu_no, s.stu_name, a.plan_id\n",
") mm \n",
"left join (\n",
" select DISTINCT c.student_id \n",
" from class_attend c \n",
" where c.attend_date BETWEEN '2026-05-25' and '2026-05-31' \n",
" and c.student_id in (\n",
" select DISTINCT a.student_id \n",
" from class_attend_stu a \n",
" where a.plan_id=41\n",
" )\n",
") bb on mm.id = bb.student_id \n",
"WHERE bb.student_id is null\n",
"'''\n",
"cursor.execute(sql)\n",
"result = cursor.fetchall()\n",
"data = create_table(cursor,result)\n",
"print(data)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "2584e86a",
"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",
"{\"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",
"{\"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",
"{\"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",
"{\"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",
"{\"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",
"{\"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",
"{\"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",
"{\"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",
"{\"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",
"{\"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",
"{\"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",
"{\"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",
"{\"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",
"{\"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",
"{\"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",
"{\"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",
"{\"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",
"{\"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",
"{\"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",
"{\"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",
"{\"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",
"{\"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",
"{\"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",
"{\"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",
"{\"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",
"{\"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",
"{\"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",
"{\"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",
"{\"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",
"{\"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",
"{\"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",
"{\"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",
"{\"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",
"{\"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 item in data:\n",
" res = post(f\"{ip}/classAttendStu/createThisWeekStu\",headers=header,params={\"stuId\":item[\"id\"],\"planId\":item[\"plan_id\"]},timeout=600).text\n",
" print(res)\n"
]
}
],
"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
}