一、系统开发平台............................................................................................................ 3
二、数据库规划............................................................................................................... 4
2.1 任务陈述............................................................................................................ 4
2.2 任务目标............................................................................................................ 4
三、系统定义................................................................................................................... 6
3.1 系统边界............................................................................................................ 6
3.2 用户视图............................................................................................................ 8
四、需求分析................................................................................................................... 9
4.1 用户需求说明................................................................................................... 10
4.1.1 数据需求............................................................................................... 10
4.1.2 事务需求............................................................................................... 10
4.2 系统需求说明................................................................................................... 12
五、数据库逻辑设计...................................................................................................... 13
5.1 ER图:............................................................................................................. 13
5.2 数据字典........................................................................................................... 14
六、数据库物理设计...................................................................................................... 16
6.1 索引.................................................................................................................. 16
6.2 安全机制.......................................................................................................... 17
七、应用程序设计.......................................................................................................... 17
7.1 功能模块.......................................................................................................... 17
7.2 界面设计.......................................................................................................... 19
7.3 事务设计........................................................................................................... 77
八、测试和运行............................................................................................................ 114
九、总结...................................................................................................................... 171
9.1 系统优点......................................................................................................... 171
9.2 系统不足......................................................................................................... 172
9.3 系统改进......................................................................................................... 172
9.4 经验与收获...................................................................................................... 172
附. 参考文献............................................................................................................... 172
随着我校逐级扩招,学生越来越多,学生公寓楼房越来越多,宿管人员越来越多。随着高校后勤社会化改革,学生住宿条件得到了很大改善,宿舍内的贵重设施、电器等越来越多,宿舍安排上打破了原来按专业班级强制集中住宿的限制,可供学生选择的余地也越来越大;同学们可以根据自己的合理要求申请调换宿舍,同时,由于学生越来越多,学生宿舍也越来越多,宿舍内硬件出现的故障也自然会增多。至今为止,某某大学故障报修仍为仍共笔录上报,不仅物业得知学生需求的速度慢,甚至有时还会出现物业错漏报修的问题,导致学生的住宿体验变差。对于学生人际交往逐渐增多,学生之间在没有联系方式的情况下想要知道一个同学在哪一个宿舍只能通过打听等不准确不确切的方式获得,十分的不便。对于班内同学逐个分发物品时,也必须知道班内的每一个同学所在宿舍号,因此,对于班内同学的宿舍情况也是一项需求。且某某大学宿管查宿舍卫生也只是纸面记录,且学生们根本不知道宿舍的卫生检查情况,所以对于这一方面也有疏漏。宿舍同学们作息习惯的不同,很可能导致影响其他同学的休息,由于不好意思开口,挂在‘表白墙’又很难达到效果且有暴露其他宿舍的隐私和损坏名誉问题,所以对于同学们对于其他宿舍的意见反馈也是一件需求。
1.1 开发平台简介
本项目开发的学生公寓管理系统采用B-S架构,使用基于phthon的技术开发路线,使用Django后端开发MVT框架,连接起数据库与前端,实现交互。
1.2 开发语言:Python
用python更加易于使用和阅读,并且python丰富的包十分便于开发;python的编程方法也更少限制,丰富成熟的基于python的后端开发框架也更便于我们使用开发。
1.3 开发工具:Navicat for Mysql、VS2019、Pycharm
利用如上的开发工具,可以十分便捷的进行Web开发。
1.4 数据库: MySQL 5.7
MySQL是业界领先的开源数据库,在开源产品中具有仅次于Apache服务器的市场占有率。本数据库开放源代码,具有免费使用,比较稳定的特点,适合于小型系统的持久性存储。
1.5 操作系统:Microsoft Windows 10
学生公寓管理系统是学生公寓管理不可缺少的部分,它的应用会使学生以及宿管的工作变得十分便利。随着青岛校区扩招学生的增多以及宿舍硬件的使用年数逐渐变多,越来越多的问题也不断出现,对于学生公寓的管理不仅宿管任务加重,学生们对于宿舍问题的需求也逐渐增多。有了学生公寓管理系统,以上出现的问题会在一定程度上得到解决。
该项目所设计的学生公寓管理系统包括:
学生用户:
个人信息页、班级信息情况页、宿舍查询页、卫生管理页、报修系统页、投诉系统页、访问申请页、离校登记页。
由于宿管需要对卫生管理进行信息同步,所以需要管理员身份的专属系统,管理员身份的页有查询宿舍信息页以及卫生管理页、故障报修页、访问审批页、个人信息页。如此,管理员可以将卫生检查的结果发送给各个同学,也可以查询各个宿舍的情况、查看宿舍报修情况。同学们可以自行进行故障报修、对个别宿舍进行不满的匿名建议、查看班级宿舍信息、查看指定同学姓名的宿舍信息、查看个人信息、审批故障以及访问信息等。因此宿管用户包括以下页面
宿管用户:
个人信息页、宿舍查询页、卫生管理页、宿舍反馈页、访问审批页、故障审批页。
模块 |
功能 |
个人信息 |
查看个人的基本信息 |
班级情况 |
班级的所有成员宿舍信息可以查看 |
宿舍查询 |
查找具体个人的宿舍信息,学号、姓名。宿管可以根据学号、姓名或者宿舍直接查询,权限比学生高 |
卫生管理 |
宿管更新检查结果,学生查看结果,学生页面留有以往的检查结果 |
投诉系统 |
匿名反馈意见给指定宿舍,指定宿舍会有记录,只能自己宿舍人员看到。宿管可以发送警告内容到指定宿舍,警告信息会特别提示。 |
报修系统 |
宿管阿姨受理报修信息。学生上报报修信息。学生会有保修信息的反馈 |
访问申请 |
学生访问非自己所在的公寓楼需要申请,对应宿舍楼的宿管需要审批。 |
离校邓丽 |
学生离校进行系统登记,对应宿舍楼的宿管可以看到自己宿舍楼学生的离校登记信息。 |
系统边界描述数据库系统和企业信息系统的其他部分的接口,是信息系统内部构成元素与外部有联系实体之间的信息关系的描述与分割。它并不需要在它们之间划一条物理边界,而只需要弄清它们之间信息输入与输出的分割。
支持学生学号登录、管理员账号登录,即只支持宿舍管理员以及学生使用。
查询、以宿舍号为索引的宿舍信息。
更新、将卫生结果发给各个宿舍各个同学
更新、回复同学们的报修情况
查询、更新个人基本信息
更新、给指定宿舍告以警告信息
更新、对无权限进入的外宿舍楼访问者提交的访问申请进行审批
查看自己管理的宿舍楼的学生离校信息
查询、个人信息
查询、以姓名为索引查询宿舍信息
查看自己所在班级的人员信息
查询、查看以往的卫生检查结果
更新、投诉宿舍的投诉信息
更新、上报报修信息
更新、查询访问信息,查看访问信息受理情况。
更新、填写离校登记信息,查看历史登记记录
学生公寓管理系统功能一览:
1、学生(宿管)基本信息;
学生学号sid、学生姓名sname、学生性别sex、学生年龄age、学生班级、学生宿舍楼id、学生宿舍id、学生学院信息、学生户籍、学生身份证号、学生手机号、学生邮箱、学生专业信息
2、班级基本信息:
学生总人数、男生人数、女生人数、所有学生住宿信息
3、卫生检查基本信息:
历史卫生考核记录、考核各项分数、宿舍id、宿舍楼id
4、访问申请基本信息:
历史访问申请记录、访问人姓名、访问人学号、访问人宿舍楼id、访问人宿舍id、访问人目标宿舍楼id、访问人申请事由、访问人访问时间、管理员审批状态、宿管历史审批记录
5、故障报修基本信息:
历史报修记录、申报人姓名、申报人学号、申报人宿舍楼id、申报人宿舍id、故障信息、宿管审批状态、宿管回复信息、宿管历史审批记录
6、匿名提醒基本信息:
宿舍楼id、宿舍号id、匿名提醒内容、宿管阿姨警告内容
7、离校登记基本信息:
学生学号、学生姓名、宿舍楼id、宿舍号id、离校理由、离校时间、返校时间。
学生学号、学生姓名、学生宿舍号、学生班级
宿管:地面整洁、厕所卫生、窗户卫生、异味杂物、厕所卫生、物品整齐分数
提醒目标宿舍id、匿名提醒信息
访问目标宿舍楼信息、访问理由、访问时间
宿管:访问审批结果
上报宿舍、故障信息
宿管:回复备注、审批结果
上报离校信息。
3、数据查看:
管理员用户视图下:
学生用户视图下
该学生公寓管理系统需要较强的数据处理功能,理论上应该能够容纳上万人的数据资料,并且在搜索方面理应具有较快的响应速度,能够处理多方面的数据请求。系统能够有效的处理各种异常,具有较好的健壮性。
4.2.1 初始数据库大小
①30条左右学生信息
②共5个 左右宿舍楼
4.2.1 安全性
①只有登录才能使用
②每个用户只能看到权限范围内的学生信息
③学生只能看到自己宿舍的故障报修、自己的访问申请
④学生只能看到自己宿舍的匿名提醒、卫生信息
5.2.1 从数据字典中抽取出来的系统实体描述:
学生信息表
宿管信息表
学生匿名反馈信息表
宿管警告信息表
学生卫生成绩表
学生历史卫生成绩表
学生访问申请信息表
学生故障报修信息表
数据库中的索引:
表名 |
主键 |
索引 |
stu |
sid |
1、`sid` 2、`dorm_id`, `dorm_building_id` |
manager |
mid |
1、`mid` 2、`mid`, `mdorm` |
Mfback |
num |
`dorm_id`, `dorm_building_id` |
fback |
num |
`dorm_id`, `dorm_building_id` |
Score |
`dorm_id`, `dorm_building_id` |
`dorm_id`, `dorm_building_id` |
Historyscore |
num |
`dorm_building_id`, `dorm_id` |
Svisit |
num |
`target`, `ac` |
Wrong |
num |
`dorm_id`, `dorm_building_id` |
Leave |
num |
1、`sid` 2、`dorm_building_id` |
解释:对应于学生信息的索引建立,由于每次用到学生的个人信息都是从sid开始寻找(主键确保唯一查找),所以建立sid的索引可以加快所有功能涉及到用到stu对应信息的视图查询速度;对于其他所有的`dorm_id`, `dorm_building_id`索引的建立,由于每一个功能的实现(查询修改)都是建立在`dorm_id`, `dorm_building_id`基础上的,这也是学生公寓的特点,因此建立`dorm_id`, `dorm_building_id`索引可以大大加快所有功能的增删改查速度。
6.2.1 系统安全
1、学生用户的注册只有系统中有了对应的学号才能进行注册,否则会提示是否是某某大学的学生:
2、对于所有输入异常,如空白输入(未输入)、学号不满12位注册、其他功能未选择宿舍楼id、宿舍id、时间都会有相应的异常处理。
6.2.2 数据安全
1、登陆界面输入的账号密码信息只有到了数据库内系统设计者(我)才能看到,其他所有信息也只有系统设计者才能进行无条件修改,数据不会被随意更改。
2、个人信息中学号身份证号宿舍号等不可动数据无论宿管还是学生都无条件修改,只有系统设计者才能更改,确保数据不会被学生或宿管更改而出现bug。
3、对于匿名提醒或申请访问或故障处理宿管与学生的信息处理之间确保了原子性,
该学生公寓管理系统共有查看修改个人信息、查看班级信息、查询宿舍信息、查询卫生信息、查看更新匿名提醒信息、查看更新访问申请信息、查看更新故障报修信息七个功能模块,其中分为两个不同的系统用户系统,对应不同的页面。宿管无查看班级信息功能,但是在审批等其他功能有着更高级的权限,符合现实要求。具体实现如下
7.1.1 病人住院
1、查看修改个人信息:
① 检测登陆状态
② 检测登陆账户
③ 判断登陆账户类型(学生、宿管)
2、查看班级信息
① 检测登陆状态
② 检测登陆账户
4、查看更新匿名提醒信息
① 检测登陆状态
② 检测登陆账户
5、查看更新访问申请
① 检测登陆状态
② 检测登陆账户
7、查看更新离校登记信息
① 检测登陆状态
② 检测登陆账户
④(学生)展示所有离校登记的信息,上报新的离校登记信息。(宿管)查看所有本宿舍楼的离校登记信息。
⑤(学生)要进行离校登记,则必须选择时间和填写理由,其中离校时间必须小于返校时间,否则登记失败,不上传数据,进行异常处理。
⑥更新对应数据库信息
⑦更新页面信息
7.2.1 登录界面
3、查看卫生信息
① 检测登陆状态
② 检测登陆账户
6、查看更新故障报修信息
① 检测登陆状态
② 检测登陆账户
配账号。用户在登录界面输入用户名和密码,经过系统验证后会根据账号类型进入学生或管理员界面。
学生注册
.
学生账号
管理员账号
7.2.2 登陆后的页面操作:
默认首先显示个人信息页面:
宿管页面:
学生页面:
7.2.3宿舍查询页面
下面是学生的宿舍查询页面,比宿管要缺少一项按照宿舍号查询的权限
下面是宿管的查询页面,权限高于学生,有三项查询方式:
7.2.4 学生专属的班级信息查询:
显示男女人数、显示班级总人数、展示所有班级成员信息
7.2.5 卫生信息页面
学生页面:
宿管页面,可以选择宿舍号进行打分
7.2.6 宿舍反馈(警告)
宿管页面,可以向指定宿舍发送警告内容,可选择的宿舍号已经过滤到所管理的宿舍楼
学生页面:可查看收到的私信以及宿管的警告,可匿名向指定宿舍发送提醒私信,可选择的宿舍号已经过滤到所住的宿舍楼
7.2.7访问申请、审批:
学生页面,可进行审批,查看历史申请及通过状态
宿管页面,展示需要处理的审批单和已经审批过的审批单
7.2.8 宿舍故障上报、审批
学生页面,可进行审批,查看历史申请及通过状态
宿管页面,展示需要处理的审批单和已经审批过的审批单
7.2.8 离校登记
学生页面:登记离校信息、展示历史登记信息
宿管页面:查看本宿舍楼的离校登记信息
7.2.9 退出登录
返回登录页面
该系统中,稍微复杂的查询利用sql进行raw查询,其他简单的增删改查利用filter和.save以及.delete完成。
7.3.1 登录注册事务
有关于登录注册时的查询判断增删如下:
def to_login(request):
num = Logininfo.objects.filter().count()
if num >= 1:
u = Logininfo.objects.filter()
u.delete()
return render(request, 'login.html')
def to_reg(request):
return render(request, 'register.html')
def judge_login(request):
u = request.POST.get("user", '')
p = request.POST.get("pwd", '')
msg = "请正确输入账号密码"
if u and p:
c = Stu_Idpwd.objects.filter(sid=u, password=p).count()
if c >= 1:
state = Logininfo(id=u, password=p)
state.save()
if len(u) < 12:
c = Logininfo.objects.filter().count()
if c >= 1:
u = Logininfo.objects.get()
infodb = Manager.objects.get(mid=u.id)
else:
msg = "请先登录!"
return render(request, 'login.html', locals())
return render(request, 'manageinfo.html', locals())
infodb = Stu.objects.get(sid=u)
return render(request, 'info.html', locals())
else:
msg = "账号或密码错误!"
return render(request, 'login.html', locals())
else:
return render(request, 'login.html', locals())
def judge_reg(request):
u = request.GET.get("user", '')
p = request.GET.get("pwd", '')
msg = ""
if u and p:
c = Stu_Idpwd.objects.filter(sid=u).count()
if c >= 1:
msg = "账号已存在,如忘记密码,请联系系统管理员"
return render(request, 'register.html', locals())
else:
cc = Stu.objects.filter(sid=u).count()
if cc >= 1:
msg = "注册成功"
newaccount = Stu_Idpwd(sid=u, password=p)
newaccount.save()
return render(request, 'login.html', locals())
else:
msg = "系统没有您的学号,请确认您是否是山大学生"
return render(request, 'register.html', locals())
else:
return render(request, 'register.html', locals())
7.3.2 个人信息事务
def info(request):
c = Logininfo.objects.filter().count()
if c >= 1:
u = Logininfo.objects.get()
infodb = Stu.objects.get(sid=u.id)
else:
msg = "请先登录!"
return render(request, 'login.html', locals())
return render(request, 'info.html', locals())
def infomove(request):
c = Logininfo.objects.filter().count()
if c >= 1:
u = Logininfo.objects.get()
infodb = Stu.objects.get(sid=u.id)
newphone = request.GET.get('phone', '')
newemail = request.GET.get('ema', '')
if newemail or newphone:
if newemail:
infodb.email = newemail
infodb.save()
if newphone:
infodb.phone = newphone
infodb.save()
infomsg = "修改成功!"
else:
infomsg = "请正确填写手机号或邮箱!"
return render(request, 'info.html', locals())
else:
msg = "请先登录!"
return render(request, 'login.html', locals())
def minfomove(request):
c = Logininfo.objects.filter().count()
if c >= 1:
u = Logininfo.objects.get()
infodb = Manager.objects.get(mid=u.id)
newphone = request.GET.get('phone', '')
newemail = request.GET.get('ema', '')
if newemail or newphone:
if newemail:
infodb.email = newemail
infodb.save()
if newphone:
infodb.phone = newphone
infodb.save()
infomsg = "修改成功!"
else:
infomsg = "请正确填写手机号或邮箱!"
return render(request, 'manageinfo.html', locals())
else:
msg = "请先登录!"
return render(request, 'login.html', locals())
7.3.3 班级信息事务
def classs(request):
c = Logininfo.objects.filter().count()
if c < 1:
msg = "请先登录!"
return render(request, 'login.html', locals())
else:
num = Logininfo.objects.get()
classinfo = Stu.objects.get(sid=num.id)
membercount = Stu.objects.filter(classs=classinfo.classs).count()
mancount = Stu.objects.filter(classs=classinfo.classs, sex='男').count()
womancount = membercount - mancount
allmember = Stu.objects.filter(classs=classinfo.classs)
return render(request, 'classs.html', locals())
7.3.4 宿舍查询事务
def dormSearch(request):
c = Logininfo.objects.filter().count()
if c < 1:
msg = "请先登录!"
return render(request, 'login.html', locals())
return render(request, 'dormSearch.html', locals())
def search(request):
c = Logininfo.objects.filter().count()
if c < 1:
msg = "请先登录!"
return render(request, 'login.html', locals())
else:
name = request.GET.get('searchname', '')
ssid = request.GET.get('searchsid', '')
sdormnum = Stu.objects.filter(sname=name).count()
siddormnum = Stu.objects.filter(sid=ssid).count()
msg = " "
if siddormnum >= 1:
sdorm = Stu.objects.filter(sid=ssid)
elif sdormnum >= 1:
sdorm = Stu.objects.filter(sname=name)
else:
msg = "请输入姓名或学号!"
return render(request, 'dormSearch.html', locals())
def managedormsearch(request):
c = Logininfo.objects.filter().count()
if c < 1:
msg = "请先登录!"
return render(request, 'login.html', locals())
else:
now = Logininfo.objects.get()
nowinfo = Manager.objects.get(mid=now.id)
sql = "select distinct sid,dorm_id from stu where dorm_building_id = %s"
dorminfo = Stu.objects.raw(sql, [nowinfo.mdorm])
listmm = []
for m in dorminfo:
if m.dorm_id not in listmm:
listmm.append(m.dorm_id)
dormid = request.GET.get('dormid', '')
name = request.GET.get('searchname', '')
ssid = request.GET.get('searchsid', '')
dormidnum = Stu.objects.filter(dorm_id=dormid, dorm_building_id=nowinfo.mdorm).count()
sdormnum = Stu.objects.filter(sname=name).count()
siddormnum = Stu.objects.filter(sid=ssid).count()
msg = " "
if dormidnum >= 1:
sdorm = Stu.objects.filter(dorm_id=dormid, dorm_building_id=nowinfo.mdorm)
elif siddormnum >= 1:
sdorm = Stu.objects.filter(sid=ssid)
elif sdormnum >= 1:
sdorm = Stu.objects.filter(sname=name, dorm_building_id=nowinfo.mdorm)
else:
msg = "请输入宿舍号或姓名或学号!"
return render(request, 'managedormsearch.html', locals())
7.3.5 卫生信息事务
def day(request):
c = Logininfo.objects.filter().count()
if c >= 1:
num = Logininfo.objects.get()
dorminfo = Stu.objects.get(sid=num.id)
sdorm_id = dorminfo.dorm_id
sbuil_id = dorminfo.dorm_building_id
lii = dict()
lii['dorm_building_id'] = sbuil_id
lii['dorm_id'] = sdorm_id
ct = Score.objects.filter(**lii).count()
if ct < 1:
newscore = Score(dorm_building_id=sbuil_id, dorm_id=sdorm_id, ground=0, bathroom=0, tidness=0, smell=0,
windows=0)
newscore.save()
dormscore = Score.objects.filter(**lii)[0]
hsc = Historyscore.objects.filter(**lii).count()
if hsc >= 1:
oldscore = Historyscore.objects.filter(**lii)
else:
msg = "请先登录!"
return render(request, 'login.html', locals())
return render(request, 'dormClean.html', locals())
def manageday(request):
c = Logininfo.objects.filter().count()
if c < 1:
msg = "请先登录!"
return render(request, 'login.html', locals())
else:
now = Logininfo.objects.get()
nowinfo = Manager.objects.get(mid=now.id)
sql = "select distinct sid,dorm_id from stu where dorm_building_id = %s"
dorminfo = Stu.objects.raw(sql, [nowinfo.mdorm])
listmm = []
for m in dorminfo:
if m.dorm_id not in listmm:
listmm.append(m.dorm_id)
return render(request, 'manageday.html', locals())
def managedaysubmit(request):
c = Logininfo.objects.filter().count()
if c < 1:
msg = "请先登录!"
return render(request, 'login.html', locals())
else:
now = Logininfo.objects.get()
nowinfo = Manager.objects.get(mid=now.id)
sql = "select distinct sid,dorm_id from stu where dorm_building_id = %s"
dorminfo = Stu.objects.raw(sql, [nowinfo.mdorm])
listmm = []
for m in dorminfo:
if m.dorm_id not in listmm:
listmm.append(m.dorm_id)
d = request.GET.get('dormid', '')
g = request.GET.get('ground', '')
b = request.GET.get('bathroom', '')
w = request.GET.get('windows', '')
t = request.GET.get('tidness', '')
s = request.GET.get('smell', '')
if d and g and b and w and t and s:
oldnum = Score.objects.filter(dorm_building_id=nowinfo.mdorm, dorm_id=d).count()
if oldnum >= 1:
old = Score.objects.get(dorm_building_id=nowinfo.mdorm, dorm_id=d)
tohistory = Historyscore(dorm_building_id=old.dorm_building_id, dorm_id=old.dorm_id, ground=old.ground,
bathroom=old.bathroom, tidness=old.tidness, smell=old.smell,
windows=old.windows)
tohistory.save()
old = Score.objects.get(dorm_building_id=nowinfo.mdorm, dorm_id=d).delete()
newscore = Score(dorm_building_id=nowinfo.mdorm, dorm_id=d, ground=g, bathroom=b, tidness=t, smell=s,
windows=w)
newscore.save()
msg = "打分数据上传成功!"
else:
msg = "请选择宿舍并且正确打分!"
return render(request, 'manageday.html', locals())
7.3.6 宿舍反馈事务
def errorr(request):
c = Logininfo.objects.filter().count()
if c < 1:
msg = "请先登录!"
return render(request, 'login.html', locals())
else:
num = Logininfo.objects.get()
nowinfo = Stu.objects.get(sid=num.id)
sql = "select distinct sid,dorm_id from stu where dorm_building_id = %s"
dorminfo = Stu.objects.raw(sql, [nowinfo.dorm_building_id])
listmm = []
for m in dorminfo:
if m.dorm_id not in listmm:
listmm.append(m.dorm_id)
fbinfocount = Fback.objects.filter(dorm_id=nowinfo.dorm_id, dorm_building_id=nowinfo.dorm_building_id).count()
mfbinfocount = Mfback.objects.filter(dorm_id=nowinfo.dorm_id, dorm_building_id=nowinfo.dorm_building_id).count()
if fbinfocount >= 1:
fbmsg = ""
feedbinfo = Fback.objects.filter(dorm_id=nowinfo.dorm_id, dorm_building_id=nowinfo.dorm_building_id)
else:
fbmsg = "当前没有收到同学的投诉信息哦"
if mfbinfocount >= 1:
mfbmsg = "以下是来自宿管的警告!"
mfeedbinfo = Mfback.objects.filter(dorm_id=nowinfo.dorm_id, dorm_building_id=nowinfo.dorm_building_id)
else:
mfbmsg = "当前没有收到来自宿管的警告哦"
return render(request, 'errorr.html', locals())
def feedback(request):
c = Logininfo.objects.filter().count()
if c < 1:
msg = "请先登录!"
return render(request, 'login.html', locals())
else:
num = Logininfo.objects.get()
nowinfo = Stu.objects.get(sid=num.id)
sql = "select distinct sid,dorm_id from stu where dorm_building_id = %s"
dorminfo = Stu.objects.raw(sql, [nowinfo.dorm_building_id])
listmm = []
for m in dorminfo:
if m.dorm_id not in listmm:
listmm.append(m.dorm_id)
fbinfocount = Fback.objects.filter(dorm_id=nowinfo.dorm_id, dorm_building_id=nowinfo.dorm_building_id).count()
if fbinfocount >= 1:
fbmsg = ""
feedbinfo = Fback.objects.filter(dorm_id=nowinfo.dorm_id, dorm_building_id=nowinfo.dorm_building_id)
else:
fbmsg = "当前没有收到投诉信息哦"
mfbinfocount = Mfback.objects.filter(dorm_id=nowinfo.dorm_id, dorm_building_id=nowinfo.dorm_building_id).count()
if mfbinfocount >= 1:
mfbmsg = "以下是来自宿管的警告!"
mfeedbinfo = Mfback.objects.filter(dorm_id=nowinfo.dorm_id, dorm_building_id=nowinfo.dorm_building_id)
else:
mfbmsg = "当前没有收到来自宿管的警告哦"
dormid = request.GET.get('dormid', '')
judge = request.GET.get('message', '')
if judge:
dbmsg = request.GET.get('message', '')
dormnum = request.GET.get('dormid', '')
dormbuildid = nowinfo.dorm_building_id
newmsg = Fback(dorm_id=dormid, dorm_building_id=dormbuildid, fbinfo=dbmsg)
newmsg.save()
msg = "消息已发送"
else:
msg = "请正确填写消息"
return render(request, 'errorr.html', locals())
def managefeedback(request):
c = Logininfo.objects.filter().count()
if c < 1:
msg = "请先登录!"
return render(request, 'login.html', locals())
else:
num = Logininfo.objects.get()
nowinfo = Manager.objects.get(mid=num.id)
sql = "select distinct sid,dorm_id from stu where dorm_building_id = %s"
dorminfo = Stu.objects.raw(sql, [nowinfo.mdorm])
listmm = []
for m in dorminfo:
if m.dorm_id not in listmm:
listmm.append(m.dorm_id)
dormid = request.GET.get('dormid', '')
judge = request.GET.get('message', '')
if judge:
dbmsg = request.GET.get('message', '')
dormnum = request.GET.get('dormid', '')
dormbuildid = nowinfo.dorm_building_id
newmsg = Mfback(dorm_id=dormid, dorm_building_id=dormbuildid, mfbinfo=dbmsg)
newmsg.save()
msg = "警告已送达"
else:
msg = "请选择宿舍并填写消息"
return render(request, 'manageerror.html', locals())
def manageerror(request):
c = Logininfo.objects.filter().count()
if c < 1:
msg = "请先登录!"
return render(request, 'login.html', locals())
else:
num = Logininfo.objects.get()
nowinfo = Manager.objects.get(mid=num.id)
sql = "select distinct sid,dorm_id from stu where dorm_building_id = %s"
dorminfo = Stu.objects.raw(sql, [nowinfo.mdorm])
listmm = []
for m in dorminfo:
if m.dorm_id not in listmm:
listmm.append(m.dorm_id)
msg = ""
return render(request, 'manageerror.html', locals())
7.3.7 访问审批事务
def visit(request):
c = Logininfo.objects.filter().count()
if c < 1:
msg = "请先登录!"
return render(request, 'login.html', locals())
else:
num = Logininfo.objects.get()
nowinfo = Stu.objects.get(sid=num.id)
sql = "select sid,dorm_building_id from stu where dorm_building_id != %s"
dorminfo = Stu.objects.raw(sql, [nowinfo.dorm_building_id])
listmm = []
for m in dorminfo:
if m.dorm_building_id not in listmm:
listmm.append(m.dorm_building_id)
dormid = request.GET.get('dormid', '')
judge = request.GET.get('message', '')
if judge:
dbmsg = request.GET.get('message', '')
dormnum = request.GET.get('dormid', '')
visitTime = request.GET.get('time', '')
newmsg = Svisit(time=visitTime, target=dormnum, why=dbmsg, sno=nowinfo.sid, sname=nowinfo.sname, ac=0,
dorm_building_id=nowinfo.dorm_building_id, dorm_id=nowinfo.dorm_id)
newmsg.save()
msg = "请求单已送达"
else:
msg = "请正确填写"
reqnum = Svisit.objects.filter(sno=nowinfo.sid).count()
if reqnum >= 1:
reqform = Svisit.objects.filter(sno=nowinfo.sid)
fbmsg = ''
else:
fbmsg = '您还没有上交过请求'
return render(request, 'visit.html', locals())
def visitt(request):
c = Logininfo.objects.filter().count()
if c < 1:
msg = "请先登录!"
return render(request, 'login.html', locals())
else:
num = Logininfo.objects.get()
nowinfo = Stu.objects.get(sid=num.id)
sql = "select sid,dorm_building_id from stu where dorm_building_id != %s"
dorminfo = Stu.objects.raw(sql, [nowinfo.dorm_building_id])
listmm = []
for m in dorminfo:
if m.dorm_building_id not in listmm:
listmm.append(m.dorm_building_id)
dormid = request.GET.get('dormid', '')
judge = request.GET.get('message', '')
reqnum = Svisit.objects.filter(sno=nowinfo.sid).count()
if reqnum >= 1:
reqform = Svisit.objects.filter(sno=nowinfo.sid)
fbmsg = ''
else:
fbmsg = '您还没有上交过请求'
return render(request, 'visit.html', locals())
def mvisit(request):
c = Logininfo.objects.filter().count()
if c < 1:
msg = "请先登录!"
return render(request, 'login.html', locals())
else:
now = Logininfo.objects.get()
nowinfo = Manager.objects.get(mid=now.id)
waitinfonum = Svisit.objects.filter(ac=0, target=nowinfo.mdorm).count()
sql = "select * from svisit where target = %s and ac != 0"
alreadyinfo = Svisit.objects.raw(sql, [nowinfo.mdorm])
if alreadyinfo:
hvmsg = ""
else:
hvmsg = "您还没有处理过申请信息"
if waitinfonum < 1:
vmsg = "当前没有需要处理的申请"
else:
waitinfo = Svisit.objects.filter(ac=0, target=nowinfo.mdorm)[0]
stuinfo = Stu.objects.get(sid=waitinfo.sno)
return render(request, 'managevisit.html', locals())
def mvisitt(request):
c = Logininfo.objects.filter().count()
if c < 1:
msg = "请先登录!"
return render(request, 'login.html', locals())
else:
now = Logininfo.objects.get()
nowinfo = Manager.objects.get(mid=now.id)
waitinfo = Svisit.objects.filter(ac=0, target=nowinfo.mdorm)[0]
res = request.GET.get('res', '')
waitinfo.ac = res
waitinfo.save()
waitinfonum = Svisit.objects.filter(ac=0, target=nowinfo.mdorm).count()
if waitinfonum < 1:
vmsg = "当前没有需要处理的申请"
else:
waitinfo = Svisit.objects.filter(ac=0, target=nowinfo.mdorm)[0]
stuinfo = Stu.objects.get(sid=waitinfo.sno)
sql = "select * from svisit where target = %s and ac != 0"
alreadyinfo = Svisit.objects.raw(sql, [nowinfo.mdorm])
if alreadyinfo:
hvmsg = ""
else:
hvmsg = "您还没有处理过申请信息"
return render(request, 'managevisit.html', locals())
7.3.7 故障报修事务
def wrong(request):
c = Logininfo.objects.filter().count()
if c < 1:
msg = "请先登录!"
return render(request, 'login.html', locals())
else:
num = Logininfo.objects.get()
nowinfo = Stu.objects.get(sid=num.id)
sql = "select sid,dorm_building_id from stu where dorm_building_id != %s"
dorminfo = Stu.objects.raw(sql, [nowinfo.dorm_building_id])
listmm = []
for m in dorminfo:
if m.dorm_building_id not in listmm:
listmm.append(m.dorm_building_id)
dormid = request.GET.get('dormid', '')
judge = request.GET.get('message', '')
if judge:
dbmsg = request.GET.get('message', '')
newmsg = Wrong(dorm_building_id=nowinfo.dorm_building_id, dorm_id=nowinfo.dorm_id, wronginfo=dbmsg,
sid=nowinfo.sid, sname=nowinfo.sname, ac=0)
newmsg.save()
msg = "故障单已送达"
else:
msg = "请正确填写"
reqnum = Wrong.objects.filter(dorm_id=nowinfo.dorm_id, dorm_building_id=nowinfo.dorm_building_id).count()
if reqnum >= 1:
reqform = Wrong.objects.filter(dorm_id=nowinfo.dorm_id, dorm_building_id=nowinfo.dorm_building_id)
fbmsg = ''
else:
fbmsg = '您的宿舍还没有上交过故障信息'
return render(request, 'wrong.html', locals())
def wrongg(request):
c = Logininfo.objects.filter().count()
if c < 1:
msg = "请先登录!"
return render(request, 'login.html', locals())
else:
num = Logininfo.objects.get()
nowinfo = Stu.objects.get(sid=num.id)
sql = "select sid,dorm_building_id from stu where dorm_building_id != %s"
dorminfo = Stu.objects.raw(sql, [nowinfo.dorm_building_id])
listmm = []
for m in dorminfo:
if m.dorm_building_id not in listmm:
listmm.append(m.dorm_building_id)
dormid = request.GET.get('dormid', '')
judge = request.GET.get('message', '')
reqnum = Wrong.objects.filter(dorm_id=nowinfo.dorm_id, dorm_building_id=nowinfo.dorm_building_id).count()
if reqnum >= 1:
reqform = Wrong.objects.filter(dorm_id=nowinfo.dorm_id, dorm_building_id=nowinfo.dorm_building_id)
fbmsg = ''
else:
fbmsg = '您的宿舍还没有上交过请求'
return render(request, 'wrong.html', locals())
def mwrong(request):
c = Logininfo.objects.filter().count()
if c < 1:
msg = "请先登录!"
return render(request, 'login.html', locals())
else:
now = Logininfo.objects.get()
nowinfo = Manager.objects.get(mid=now.id)
waitinfonum = Wrong.objects.filter(ac=0, dorm_building_id=nowinfo.mdorm).count()
sql = "select * from wrong where dorm_building_id = %s and ac != 0"
alreadyinfo = Wrong.objects.raw(sql, [nowinfo.mdorm])
if alreadyinfo:
hvmsg = ""
else:
hvmsg = "您还没有处理过申请信息"
if waitinfonum < 1:
vmsg = "当前没有需要处理的申请"
else:
waitinfo = Wrong.objects.filter(ac=0, dorm_building_id=nowinfo.mdorm)[0]
stuinfo = Stu.objects.get(sid=waitinfo.sid)
return render(request, 'managewrong.html', locals())
def mwrongg(request):
c = Logininfo.objects.filter().count()
if c < 1:
msg = "请先登录!"
return render(request, 'login.html', locals())
else:
now = Logininfo.objects.get()
nowinfo = Manager.objects.get(mid=now.id)
waitinfo = Wrong.objects.filter(ac=0, dorm_building_id=nowinfo.mdorm)[0]
res = request.GET.get('res', '')
mes = request.GET.get('message', '')
waitinfo.ac = res
waitinfo.reply = mes
waitinfo.save()
waitinfonum = Wrong.objects.filter(ac=0, dorm_building_id=nowinfo.mdorm).count()
if waitinfonum < 1:
vmsg = "当前没有需要处理的申请"
else:
waitinfo = Wrong.objects.filter(ac=0, dorm_building_id=nowinfo.mdorm)[0]
stuinfo = Stu.objects.get(sid=waitinfo.sid)
sql = "select * from wrong where dorm_building_id = %s and ac != 0"
alreadyinfo = Wrong.objects.raw(sql, [nowinfo.mdorm])
if alreadyinfo:
hvmsg = ""
else:
hvmsg = "您还没有处理过申请信息"
return render(request, 'managewrong.html', locals())
7.3.8 离校登记事务
def leavee(request) :
c = Logininfo.objects.filter().count()
if c < 1 :
msg = "请先登录!"
return render(request, 'login.html', locals())
else :
num = Logininfo.objects.get()
nowinfo = Stu.objects.get(sid = num.id)
reqnum = Leave.objects.filter(sid = nowinfo.sid).count()
if reqnum >= 1 :
reqform = Leave.objects.filter(sid = nowinfo.sid)
fbmsg = ''
else:
fbmsg = '您还没有过离校登记'
return render(request, 'leave.html', locals())
def leave(request) :
c = Logininfo.objects.filter().count()
if c < 1 :
msg = "请先登录!"
return render(request, 'login.html', locals())
else :
num = Logininfo.objects.get()
nowinfo = Stu.objects.get(sid = num.id)
judge = request.GET.get('message', '')
bbtime = request.GET.get('btime', '')
eetime = request.GET.get('etime', '')
if eetimeand bbtimeand judge:
if eetime >= bbtime :
newmsg = Leave(btime = bbtime, etime = eetime, why = judge, sid = nowinfo.sid, sname = nowinfo.sname,
dorm_building_id = nowinfo.dorm_building_id, dorm_id = nowinfo.dorm_id)
newmsg.save()
msg = "报备成功!"
else:
lmsg = "返校时间必须大于离校时间!"
else:
msg = "请正确填写"
reqnum = Leave.objects.filter(sid = nowinfo.sid).count()
if reqnum >= 1 :
reqform = Leave.objects.filter(sid = nowinfo.sid)
fbmsg = ''
else:
fbmsg = '您还没有上交过请求'
return render(request, 'leave.html', locals())
def mleave(request) :
c = Logininfo.objects.filter().count()
if c < 1 :
msg = "请先登录!"
return render(request, 'login.html', locals())
else :
m = Logininfo.objects.get()
minfo = Manager.objects.get(mid = m.id)
num = Leave.objects.filter(dorm_building_id = minfo.mdorm).count()
if num < 1 :
msg = "您管理的宿舍楼目前还没有学生进行离校登记过哦"
else:
msg = ""
allmember = Leave.objects.filter(dorm_building_id = minfo.mdorm)
return render(request, 'mleave.html', locals())