作者主页:Java毕设网
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
一、相关文档
宿舍是大学生学习与生活的主要场所之一,宿舍管理是高校学工管理事务中尤为重要的一项。随着我国高校招生规模的进一步扩大,学生总体人数的不断增加,宿舍管理工作变得愈加沉重和琐碎,学生宿舍信息的采集、汇总、统计与分析等各项工作都面临诸多困难,传统的管理模式早已无法满足当前我国高校的管理需求了。因此,迫切需要研究设计和开发一个新型的高校宿舍管理系统,以便更好地满足高校宿舍管理工作的实际需求,方便宿管人员开展管理工作,提升管理水平,提高工作效率,节约人力、物力,为广大学生群体提供更优质、高效的服务。基于上述背景,本文设计并开发了一个高校宿舍管理系统。系统采用 B/S 架构,后端基于 Java 语言和 SpringBoot 框架的方式进行了开发,前端则是使用 Layui 框架,结合 HTML、JQuery、Ajax 等技术进行开发,并使用 MySQL 数据库对所有相关的信息进行了存储。系统主要包括基本信息管理、离返校管理、宿舍分配管理、宿舍日常管理、综合查询管理等五大功能模块,并根据学生、辅导员、宿舍管理员的使用需求对这些功能进行了细化和实现。通过本系统能够方便、快捷地采集、查看、统计相关的信息,并以图形化界面的方式展示出来,较好地满足了目标用户的需求,提高了宿舍管理的水平,有利于我国推进高校学工管理真正实现信息化、科学化、规范化的历史性进程。
二、项目介绍
通过对宿舍管理工作中相关业务流程的调研和分析,确定了系统的功能主要有:
(1)基本信息管理
基本信息分为学生信息和宿舍信息两部分,其功能是负责维护这些信息,对它们进行增删查改等操作。
(2)宿舍分配管理
根据给定的宿舍信息与学生信息,按照一定的规则自动地给还未分配宿舍的学生分配宿舍,学生可在该宿舍内自选床位,最终的宿舍分配信息可以以文件形式(如 Excel 表格)导出。
(3)宿舍日常管理
主要包括卫生管理、报修管理、留言管理等。卫生管理:记录并维护卫生检查信息。报修管理:添加、查看、修改报修单信息。留言管理:包括发布公告、失物招领、普通留言以及对这些信息的维护。
(4)离返校管理
对节假日学生的去向、寒暑假学生的留校以及返校登记信息进行统计及管理,并以图表形式呈现统计信息。
(5)综合查询管理
包括查找学生信息、各楼栋/专业的学生宿舍分配情况、卫生检查情况、学生离返校及留校信息、指定类型的留言、查看宿舍成员等
三、环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目
6.数据库:MySql 5.7/8.0等版本均可;
四、技术栈
HTML+CSS+JavaScript+mysql+SpringBoot+LayUI
五、使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中application.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,在浏览器中输入http://localhost:8081 访问
六、运行截图
七、相关代码
学生管理控制器
@Controller
@RequestMapping("/student")
public class StudentController {
@Resource
private StudentService studentService;
/**
* 我的卫生检查记录界面
*
* @return
*/
@RequestMapping(value = "/viewMyCleanInfo")
public String viewMyCleanInfo() {
return "/student/clean-list";
}
/**
* 查询我的宿舍卫生检查记录
*
* @param ciVo 分页信息
* @param request 用于获取session中的uid
* @return
*/
@ResponseBody
@RequestMapping(value = "/clean/list")
public DataGridViewResult findMyCleanInfoListByPage(CleanInfoVo ciVo, HttpServletRequest request) {
// 获取学号
String uid = (String) request.getSession().getAttribute("uid");
ciVo.setStuid(uid);
// 设置分页信息
PageHelper.startPage(ciVo.getPage(), ciVo.getLimit());
// 查询
List<CleanInfo> list = studentService.findMyCleanInfoListByPage(ciVo);
// 创建分页对象
PageInfo<CleanInfo> pageInfo = new PageInfo<CleanInfo>(list);
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
/**
* 我的报修界面
*
* @return
*/
@RequestMapping(value = "/viewMyRepairInfo")
public String viewMyRepairInfo() {
return "/student/repair-list";
}
/**
* 查询我的宿舍的报修记录
*
* @param riVo 分页信息
* @param request 用于获取session中的uid
* @return
*/
@ResponseBody
@RequestMapping(value = "/repair/list")
public DataGridViewResult findMyRepairInfoListByPage(RepairInfoVo riVo, HttpServletRequest request) {
// 获取学号
String uid = (String) request.getSession().getAttribute("uid");
riVo.setStuid(uid);
// 设置分页信息
PageHelper.startPage(riVo.getPage(), riVo.getLimit());
// 查询
List<RepairInfo> list = studentService.findMyRepairInfoListByPage(riVo);
// 创建分页对象
PageInfo<RepairInfo> pageInfo = new PageInfo<RepairInfo>(list);
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
/**
* 提交报修单
*
* @param ri
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/repair/add")
public String addRepairInfo(RepairInfo ri, HttpServletRequest request) {
HashMap<String, Object> map = new HashMap<>();
String stuid = (String) request.getSession().getAttribute("uid");
ri.setStuid(stuid);
// 报修提交时间
Date date = new Date();
DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
ri.setSubtime(format.format(date));
System.out.println(ri);
// 去执行添加操作
int result = studentService.addRepairInfo(ri);
if (result > 0) {
map.put("success", true);
map.put("msg", "添加成功");
} else {
map.put("success", false);
map.put("msg", "添加失败");
}
return JSON.toJSONString(map);
}
/**
* 修改报修单
*
* @param ri
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/repair/update")
public String updateRepairInfo(RepairInfo ri, HttpServletRequest request) {
HashMap<String, Object> map = new HashMap<>();
System.out.println(ri);
// 判断这是不是自己的提交的报修单
String stuid = (String) request.getSession().getAttribute("uid");
if (!stuid.equals(ri.getStuid())) {
map.put("success", false);
map.put("msg", "只能修改自己提交的报修单!");
return JSON.toJSONString(map);
}
int result = studentService.updateRepairInfo(ri);
if (result > 0) {
map.put("success", true);
map.put("msg", "修改成功!");
} else {
map.put("success", false);
map.put("msg", "修改失败!");
}
return JSON.toJSONString(map);
}
/**
* 我的宿舍界面
*
* @return
*/
@RequestMapping(value = "/viewMyDormInfo")
public String viewMyDormInfo() {
return "/student/myDorm";
}
/**
* 查看留言板
*
* @return
*/
@RequestMapping(value = "/viewMessageBoard")
public String viewMessageBoard() {
return "/student/messageboard";
}
@ResponseBody
@RequestMapping(value = "/message/list")
public String findMessageListByPage(HttpServletRequest request) {
HashMap<String, Object> map = new HashMap<>();
try {
// 获取id,用来查找所在宿舍区
String uid = (String) request.getSession().getAttribute("uid");
// 获取当前页
Integer curr = Integer.parseInt(request.getParameter("curr"));
// 获取页面size
Integer limit = Integer.parseInt(request.getParameter("limit"));
// 获取信息类型
Integer type = Integer.parseInt(request.getParameter("type"));
// 起始行数
Integer start = (curr - 1) * limit;
List<MessageBoard> list = studentService.findMessageListByPage(uid, start, limit, type);
// 总行数
Integer count = studentService.findMessageCount(type);
// 总页数
Integer total = (count - 1) / limit + 1;
map.put("success", true);
map.put("count", count);
map.put("total", total);
map.put("curr", curr);
map.put("limit", limit);
map.put("data", list);
System.out.println(JSON.toJSONString(map));
return JSON.toJSONString(map);
} catch (Exception e) {
e.printStackTrace();
map.put("success", false);
map.put("msg", "系统错误!");
return JSON.toJSONString(map);
}
}
/**
* 查看我的留言
*
* @return
*/
@RequestMapping(value = "viewMyMessage")
public String viewMyMessage() {
return "/student/my-message";
}
/**
* 查看我的留言
*
* @param mbVo
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/message/my")
public DataGridViewResult myMessage(MessageBoardVo mbVo, HttpServletRequest request) {
String uname = (String) request.getSession().getAttribute("uname");
mbVo.setAnnouncer(uname);
// 设置分页信息
PageHelper.startPage(mbVo.getPage(), mbVo.getLimit());
// 查询
List<MessageBoard> list = studentService.findMyMessage(mbVo);
// 创建分页对象
PageInfo<MessageBoard> pageInfo = new PageInfo<MessageBoard>(list);
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
/**
* 发布留言
*
* @param mb
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/message/add")
public String addMessage(MessageBoard mb, HttpServletRequest request) {
String uname = (String) request.getSession().getAttribute("uname");
mb.setAnnouncer(uname);
HashMap<String, Object> map = new HashMap<>();
int result = studentService.addMessage(mb);
if (result > 0) {
map.put("success", true);
map.put("msg", "添加成功!");
} else {
map.put("success", false);
map.put("msg", "添加失败!");
}
return JSON.toJSONString(map);
}
/**
* 批量删除留言
*
* @param request 获取前端传来的id数组
* @return
*/
@ResponseBody
@RequestMapping(value = "/message/delete")
public String deleteMessage(HttpServletRequest request) {
HashMap<String, Object> map = new HashMap<>();
String params = request.getParameter("params");
System.out.println(params);
try {
if (StringUtils.isNotBlank(params)) {
// 获取id数组
JSONArray jsonArray = JSONArray.parseArray(params);
List<Integer> list = new ArrayList<>();
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject obj = jsonArray.getJSONObject(i);
Integer id = (Integer) obj.get("id");
list.add(id);
}
boolean result = studentService.deleteMessage(list);
if (result) {
map.put("success", true);
map.put("msg", "删除成功!");
} else {
map.put("success", false);
map.put("msg", "删除失败!");
}
}
} catch (Exception e) {
e.printStackTrace();
map.put("success", false);
map.put("msg", "删除失败!");
}
return JSON.toJSONString(map);
}
/**
* 查看学生基本信息
*
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/basic/info")
public String viewStudentInfo(HttpServletRequest request) {
HashMap<String, Object> map = new HashMap<>();
String stuid = (String) request.getSession().getAttribute("uid");
if (StringUtils.isNotBlank(stuid)) {
StudentInfo si = studentService.findStudentInfoByStuid(stuid);
if (si != null) {
map.put("success", true);
map.put("data", si);
} else {
map.put("success", false);
map.put("msg", "系统错误:不存在该用户!");
}
}
return JSON.toJSONString(map);
}
/**
* 更改基本信息
*
* @param si
* @return
*/
@ResponseBody
@RequestMapping(value = "/basic/update")
public String updateStudentInfo(StudentInfo si) {
HashMap<String, Object> map = new HashMap<>();
System.out.println(si);
int result = studentService.updateStudentInfo(si);
if (result > 0) {
map.put("success", true);
map.put("msg", "保存成功!");
} else {
map.put("success", false);
map.put("msg", "保存失败!");
}
return JSON.toJSONString(map);
}
@RequestMapping(value = "/leave/register")
public String myLeaveInfo() {
return "/student/leave-info";
}
/**
* 查找我的离校登记记录
*
* @param liVo
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/leave/list")
public DataGridViewResult findMyLeaveInfoByPage(LeaveInfoVo liVo, HttpServletRequest request) {
String stuid = (String) request.getSession().getAttribute("uid");
liVo.setStuid(stuid);
System.out.println(liVo);
// 设置分页信息
PageHelper.startPage(liVo.getPage(), liVo.getLimit());
// 查询
List<LeaveInfo> list = studentService.findMyLeaveInfoByPage(liVo);
// 创建分页对象
PageInfo<LeaveInfo> pageInfo = new PageInfo<LeaveInfo>(list);
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
/**
* 添加离校登记记录
*
* @param li
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/leave/add")
public String addMyLeaveInfo(LeaveInfo li, HttpServletRequest request) {
HashMap<String, Object> map = new HashMap<>();
String stuid = (String) request.getSession().getAttribute("uid");
li.setStuid(stuid);
System.out.println(li);
int result = studentService.addMyLeaveInfo(li);
if (result > 0) {
map.put("success", true);
map.put("msg", "登记成功!");
} else {
map.put("success", false);
map.put("msg", "登记失败,请稍后再试!");
}
return JSON.toJSONString(map);
}
/**
* 修改离校登记记录
*
* @param li
* @return
*/
@ResponseBody
@RequestMapping(value = "/leave/update")
public String updateMyLeaveInfo(LeaveInfo li) {
HashMap<String, Object> map = new HashMap<>();
System.out.println(li);
int result = studentService.updateMyLeaveInfo(li);
if (result > 0) {
map.put("success", true);
map.put("msg", "更改成功!");
} else {
map.put("success", false);
map.put("msg", "更改失败,请稍后再试!");
}
return JSON.toJSONString(map);
}
/**
* 留校申请
*
* @return
*/
@RequestMapping(value = "/stayin/apply")
public String myStayInfo() {
return "/student/stayin-apply";
}
/**
* 查看自己的留校申请
*
* @param siVo
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/stayin/list")
public DataGridViewResult findMyStayInfoListByPage(StayInfoVo siVo, HttpServletRequest request) {
String stuid = (String) request.getSession().getAttribute("uid");
siVo.setStuid(stuid);
System.out.println(siVo);
// 设置分页信息
PageHelper.startPage(siVo.getPage(), siVo.getLimit());
// 查询
List<StayInfo> list = studentService.findMyStayInfoListByPage(siVo);
// 创建分页对象
PageInfo<StayInfo> pageInfo = new PageInfo<StayInfo>(list);
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
/**
* 上传图片
*
* @param file
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/stayin/uploadImage")
public String uploadOpinionImage(MultipartFile file, HttpServletRequest request) {
HashMap<String, Object> map = new HashMap<>();
HashMap<String, Object> data = new HashMap<>();
try {
if (file != null) {
String stuid = (String) request.getSession().getAttribute("uid");
String originalFilename = file.getOriginalFilename();
Date date = new Date();
String fileName = date.getTime() + "-" + originalFilename;
// 类路径
// String classPath = ResourceUtils.getURL("classpath:").getPath();
// windows系统设置
String classPath = "D:/file";
// Mac系统设置
// String classPath = "/Users/hanmeng/Desktop/upload";
// 父路径
String src = "/upload/stayin/"; // + stuid + "/";
File directory = new File(classPath, src);
if (!directory.exists()) {
directory.mkdir();
}
// 文件名
String imagePath = directory.getPath() + "/" + fileName;
System.out.println(imagePath);
file.transferTo(new File(imagePath));
data.put("src", src + fileName);
map.put("code", 0);
map.put("msg", "上传成功!");
map.put("data", data);
return JSON.toJSONString(map);
} else {
map.put("code", -1);
map.put("msg", "请选择图片!");
return JSON.toJSONString(map);
}
} catch (Exception e) {
e.printStackTrace();
map.put("code", -1);
map.put("msg", "上传失败,请稍后重试!");
return JSON.toJSONString(map);
}
}
/**
* 提交留校申请
*
* @param si
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/stayin/add")
public String addStayInfo(StayInfo si, HttpServletRequest request) {
HashMap<String, Object> map = new HashMap<>();
String stuid = (String) request.getSession().getAttribute("uid");
si.setStuid(stuid);
System.out.println(si);
int result = studentService.addMyStayInfo(si);
if (result > 0) {
map.put("success", true);
map.put("msg", "提交申请成功");
} else {
map.put("success", false);
map.put("msg", "提交申请失败,请稍后重试!");
}
return JSON.toJSONString(map);
}
/**
* 修改留校申请信息
*
* @param si
* @return
*/
@ResponseBody
@RequestMapping(value = "/stayin/update")
public String updateMyStayInfo(StayInfo si) {
HashMap<String, Object> map = new HashMap<>();
System.out.println(si);
int result = studentService.updateMyStayInfo(si);
if (result > 0) {
map.put("success", true);
map.put("msg", "修改成功!");
} else {
map.put("success", false);
map.put("msg", "修改失败,请稍后再试!");
}
return JSON.toJSONString(map);
}
/**
* 查看我的返校信息
*
* @return
*/
@RequestMapping(value = "/viewMyBackInfo")
public String viewMyBackToScInfo() {
return "/student/back-info";
}
/**
* 查找我的返校登记记录
*
* @param bsVo
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/back/list")
public DataGridViewResult findMyBackInfoByPage(BackToScInfoVo bsVo, HttpServletRequest request) {
String stuid = (String) request.getSession().getAttribute("uid");
bsVo.setStuid(stuid);
System.out.println(bsVo);
// 设置分页信息
PageHelper.startPage(bsVo.getPage(), bsVo.getLimit());
// 查询
List<BackToScInfo> list = studentService.findMyBackInfoByPage(bsVo);
// 创建分页对象
PageInfo<BackToScInfo> pageInfo = new PageInfo<BackToScInfo>(list);
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
/**
* 添加返校登记记录
*
* @param bs
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/back/add")
public String addMyBackInfo(BackToScInfo bs, HttpServletRequest request) {
HashMap<String, Object> map = new HashMap<>();
String stuid = (String) request.getSession().getAttribute("uid");
bs.setStuid(stuid);
System.out.println(bs);
int result = studentService.addMyBackInfo(bs);
if (result > 0) {
map.put("success", true);
map.put("msg", "提交成功!");
} else {
map.put("success", false);
map.put("msg", "提交失败,请稍后再试!");
}
return JSON.toJSONString(map);
}
/**
* 修改返校登记记录
*
* @param bs
* @return
*/
@ResponseBody
@RequestMapping(value = "/back/update")
public String updateMyBackInfo(BackToScInfo bs) {
HashMap<String, Object> map = new HashMap<>();
System.out.println(bs);
int result = studentService.updateMyBackInfo(bs);
if (result > 0) {
map.put("success", true);
map.put("msg", "更改成功!");
} else {
map.put("success", false);
map.put("msg", "更改失败,请稍后再试!");
}
return JSON.toJSONString(map);
}
/**
* 密码设置
*
* @return
*/
@RequestMapping(value = "/setting")
public String passwordSetting() {
return "password-setting";
}
@RequestMapping(value = "/myDormitoryInfo")
public String viewMyDormitoryInfo() {
return "/student/my-dormitory";
}
/**
* 查看自己宿舍信息
*
* @param aiVo
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/mydorm/list")
public DataGridViewResult findMyDormitoryInfoListByPage(AllocationInfoVo aiVo, HttpServletRequest request) {
String stuid = (String) request.getSession().getAttribute("uid");
aiVo.setStuid(stuid);
System.out.println(aiVo);
// 设置分页信息
PageHelper.startPage(aiVo.getPage(), aiVo.getLimit());
// 查询
List<AllocationInfo> list = studentService.findMyDormitoryInfoListByPage(aiVo);
// 创建分页对象
PageInfo<AllocationInfo> pageInfo = new PageInfo<AllocationInfo>(list);
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
/**
* 判断是否已经选择床位了
*
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/mydorm/isChoosed")
public String isChooseBed(HttpServletRequest request) {
HashMap<String, Object> map = new HashMap<>();
String stuid = (String) request.getSession().getAttribute("uid");
boolean status = studentService.isChooseBed(stuid);
map.put("status", status);
return JSON.toJSONString(map);
}
/**
* 提交选择的床位号
*
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/mydorm/chooseBed")
public String chooseBed(HttpServletRequest request) {
HashMap<String, Object> map = new HashMap<>();
String stuid = (String) request.getSession().getAttribute("uid");
String bed = request.getParameter("bed");
if (StringUtils.isNotBlank(bed)) {
int bedNum = Integer.parseInt(bed);
// 提交床位号
int result = studentService.chooseBed(stuid, bedNum);
if (result > 0) {
map.put("success", true);
map.put("msg", "选择成功!");
} else {
map.put("success", false);
map.put("msg", "选择失败!");
}
return JSON.toJSONString(map);
} else {
map.put("success", false);
map.put("msg", "床位号不能为空!");
return JSON.toJSONString(map);
}
}
/**
* 查找已经选择了的床位
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/mydorm/alreadyBeds")
public String findAlreadyChooseBeds(HttpServletRequest request) {
HashMap<String, Object> map = new HashMap<>();
String stuid = (String) request.getSession().getAttribute("uid");
List<Integer> list = studentService.findAlreadyChooseBeds(stuid);
map.put("beds", list);
return JSON.toJSONString(map);
}
}
教师管理控制器
@Controller
@RequestMapping("/teacher")
public class TeacherController {
@Resource
private TeacherService teacherService;
@RequestMapping(value = "/viewAllocationInfo")
public String allocationList() {
return "/teacher/allocation-list";
}
/**
* 查询宿舍分配信息
* 查询条件:专业/年级
*
* @param aiVo
* @return
*/
@ResponseBody
@RequestMapping(value = "/allocation/list")
public DataGridViewResult findAllocationInfoList(AllocationInfoVo aiVo, HttpServletRequest request) {
// 获取session中的专业和年级
String dept = (String) request.getSession().getAttribute("dept");
String grade = (String) request.getSession().getAttribute("grade");
if (StringUtils.isNotBlank(dept)) {
aiVo.setStudept(dept);
}
if (StringUtils.isNotBlank(grade)) {
aiVo.setStugrade(grade);
}
System.out.println(aiVo);
// 设置分页信息
PageHelper.startPage(aiVo.getPage(), aiVo.getLimit());
// 查询
List<AllocationInfo> list = teacherService.findAllocationInfoListByPage(aiVo);
// 创建分页对象
PageInfo<AllocationInfo> pageInfo = new PageInfo<AllocationInfo>(list);
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
/**
* 添加宿舍分配信息
*
* @param ai
* @return
*/
@ResponseBody
@RequestMapping(value = "/allocation/add")
public String addAllocationInfo(AllocationInfo ai) {
HashMap<String, Object> map = new HashMap<>();
int result = teacherService.addAllocationInfo(ai);
if (result > 0) {
map.put("success", true);
map.put("msg", "添加成功!");
} else {
map.put("success", false);
map.put("msg", "添加失败!");
}
return JSON.toJSONString(map);
}
/**
* 更改宿舍分配信息
*
* @param ai
* @return
*/
@ResponseBody
@RequestMapping(value = "/allocation/update")
public String updateAllocationInfo(AllocationInfo ai) {
HashMap<String, Object> map = new HashMap<>();
int result = teacherService.updateAllocationInfo(ai);
if (result > 0) {
map.put("success", true);
map.put("msg", "更改成功!");
} else {
map.put("success", false);
map.put("msg", "更改失败!");
}
return JSON.toJSONString(map);
}
/**
* 删除宿舍分配信息
*
* @param stuid
* @return
*/
@ResponseBody
@RequestMapping(value = "/allocation/delete")
public String deleteAllocationInfo(String stuid) {
HashMap<String, Object> map = new HashMap<>();
int result = teacherService.deleteAllocationInfo(stuid);
if (result > 0) {
map.put("success", true);
map.put("msg", "删除成功!");
} else {
map.put("success", false);
map.put("msg", "删除失败!");
}
return JSON.toJSONString(map);
}
/**
* 导出宿舍分配信息列表(excel格式)
*
* @param request 用来获取缓存中的attribute
* @param response 输出文件流
*/
@ResponseBody
@RequestMapping(value = "/allocation/export.action")
public void exportAllocationInfoToExcel(HttpServletRequest request, HttpServletResponse response) {
HashMap<String, Object> map = new HashMap<>();
response.reset();// 清除缓存
String studept = (String) request.getSession().getAttribute("dept");
String grade = (String) request.getSession().getAttribute("grade");
System.out.println("studept" + studept);
System.out.println("grade" + grade);
// 查找宿舍分配信息列表
List<AllocationInfo> list = teacherService.exportByDept(studept, grade);
// 拼接excel表名
StringBuffer filenamebuffer = new StringBuffer();
if (StringUtils.isNotBlank(studept)) {
filenamebuffer.append(studept);
filenamebuffer.append("-");
}
if (StringUtils.isNotBlank(grade)) {
filenamebuffer.append(grade);
filenamebuffer.append("-");
}
filenamebuffer.append("宿舍分配表");
String filename = filenamebuffer.toString();
try {
ExcelUtils.writeExcel(filename, response, list, AllocationInfo.class);
map.put("success", true);
map.put("mag", "导出成功!");
} catch (Exception e) {
e.printStackTrace();
map.put("success", false);
map.put("mag", "导出失败!");
}
// return JSON.toJSONString(map);
}
@RequestMapping(value = "/viewStudentInfo")
public String studentList() {
return "/teacher/student-list";
}
/**
* 获取学生信息列表
*
* @param si
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/student/list")
public DataGridViewResult findStudentInfoList(StudentInfoVo si, HttpServletRequest request) {
// 获取教师所负责的专业和年级,年级对应学号
String studept = (String) request.getSession().getAttribute("dept");
String grade = (String) request.getSession().getAttribute("grade");
if (StringUtils.isNotBlank(studept)) {
si.setStudept(studept);
}
// 如果学号为空,则教师负责的年级作为学号的前缀条件
if (StringUtils.isBlank(si.getStuid())) {
if (StringUtils.isNotBlank(grade)) {
si.setStuid(grade);
}
}
System.out.println(si);
// 设置分页信息
PageHelper.startPage(si.getPage(), si.getLimit());
// 查询
List<StudentInfo> list = teacherService.findStudentInfoListByPage(si);
// 创建分页对象
PageInfo<StudentInfo> pageInfo = new PageInfo<StudentInfo>(list);
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
/**
* 添加学生信息
*
* @param si
* @return
*/
@ResponseBody
@RequestMapping(value = "/student/add")
public String addStudentInfo(StudentInfo si) {
HashMap<String, Object> map = new HashMap<>();
String grade = si.getStuid().substring(0, 4);
si.setStugrade(grade);
System.out.println(grade);
int result = teacherService.addStudentInfo(si);
if (result > 0) {
map.put("success", true);
map.put("msg", "添加成功!");
} else {
map.put("success", false);
map.put("msg", "添加失败!");
}
return JSON.toJSONString(map);
}
/**
* 更改学生信息
*
* @param si
* @return
*/
@ResponseBody
@RequestMapping(value = "/student/update")
public String updateStudentInfo(StudentInfo si) {
HashMap<String, Object> map = new HashMap<>();
int result = teacherService.updateStudentInfo(si);
if (result > 0) {
map.put("success", true);
map.put("msg", "更改成功!");
} else {
map.put("success", false);
map.put("msg", "更改失败!");
}
return JSON.toJSONString(map);
}
/**
* 删除学生信息
*
* @param stuid
* @return
*/
@ResponseBody
@RequestMapping(value = "/student/delete")
public String deleteaddStudentInfo(String stuid) {
HashMap<String, Object> map = new HashMap<>();
int result = teacherService.deleteStudentInfo(stuid);
if (result > 0) {
map.put("success", true);
map.put("msg", "删除成功!");
} else {
map.put("success", false);
map.put("msg", "删除失败!");
}
return JSON.toJSONString(map);
}
/**
* 导入学生信息
*
* @param file excel表格
* @return
*/
@ResponseBody
@RequestMapping(value = "/student/import.action")
public String importExcel(@RequestParam("file") MultipartFile file) {
HashMap<String, Object> map = new HashMap<>();
try {
List<StudentInfo> list = ExcelUtils.readExcel("", StudentInfo.class, file);
for (int i = 0; i < list.size(); i++) {
String grade = list.get(i).getStuid().substring(0, 4);
list.get(i).setStugrade(grade);
System.out.println(grade);
}
boolean result = teacherService.batchInsert(list);
if (result) {
map.put("code", 200);
map.put("msg", "导入成功!");
map.put("data", null);
} else {
map.put("code", 500);
map.put("msg", "导入失败!");
map.put("data", null);
}
} catch (Exception e) {
e.printStackTrace();
map.put("code", 500);
map.put("msg", "导入失败,请检查文件内容是否正确。");
map.put("data", null);
}
return JSON.toJSONString(map);
}
/**
* 查看卫生检查情况
*
* @return
*/
@RequestMapping(value = "/viewCleanInfo")
public String viewCleanInfo() {
return "/teacher/clean-list";
}
/**
* 专业班级卫生检查信息
*
* @param ciVo
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/clean/list")
public DataGridViewResult findCleanInfoListByPage(CleanInfoVo ciVo, HttpServletRequest request) {
// 获取session中的专业和年级
String dept = (String) request.getSession().getAttribute("dept");
String grade = (String) request.getSession().getAttribute("grade");
if (StringUtils.isNotBlank(dept)) {
ciVo.setStudept(dept);
}
if (StringUtils.isNotBlank(grade)) {
ciVo.setStuid(grade);
}
System.out.println(ciVo);
// 设置分页信息
PageHelper.startPage(ciVo.getPage(), ciVo.getLimit());
// 查询
List<CleanInfoVo> list = teacherService.findCleanInfoListByPage(ciVo);
// 创建分页对象
PageInfo<CleanInfoVo> pageInfo = new PageInfo<CleanInfoVo>(list);
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
@RequestMapping(value = "/viewLeaveInfo")
public String viewLeaveInfo() {
return "/teacher/leave-info";
}
@ResponseBody
@RequestMapping(value = "/leave/list")
public DataGridViewResult findLeaveInfoByPage(LeaveInfoVo liVo, HttpServletRequest request) {
// 专业和年级
String dept = (String) request.getSession().getAttribute("dept");
String grade = (String) request.getSession().getAttribute("grade");
if (StringUtils.isNotBlank(dept)) {
liVo.setStudept(dept);
}
if (StringUtils.isNotBlank(grade)) {
liVo.setStugrade(grade);
}
System.out.println(liVo);
// 设置分页信息
PageHelper.startPage(liVo.getPage(), liVo.getLimit());
// 查询
List<LeaveInfo> list = teacherService.findLeaveInfoListByPage(liVo);
// 创建分页对象
PageInfo<LeaveInfo> pageInfo = new PageInfo<LeaveInfo>(list);
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
@ResponseBody
@RequestMapping(value = "/leave/delete")
public String batchDeleteLeaveInfo(HttpServletRequest request) {
HashMap<String, Object> map = new HashMap<>();
String params = request.getParameter("params");
try {
if (StringUtils.isBlank(params)) {
map.put("success", false);
map.put("msg", "请选择要删除的行!");
return JSON.toJSONString(map);
}
boolean result = teacherService.batchDeleteLeaveInfo(params);
if (result) {
map.put("success", true);
map.put("msg", "删除成功!");
} else {
map.put("success", false);
map.put("msg", "系统错误,请稍后再试!");
}
} catch (Exception e) {
e.printStackTrace();
map.put("success", false);
map.put("msg", "系统错误,请稍后再试!");
}
return JSON.toJSONString(map);
}
/**
* 将学生去向信息导出到Excel中
*
* @param request
* @param response
*/
@ResponseBody
@RequestMapping(value = "/leave/export.action")
public void exportLeaveInfoToExcel(HttpServletRequest request, HttpServletResponse response) {
response.reset();// 清除缓存
String studept = (String) request.getSession().getAttribute("dept");
String stugrade = (String) request.getSession().getAttribute("grade");
// 查找学生登记信息
List<LeaveInfo> list = teacherService.exportLeaveInfo(studept, stugrade);
// 拼接excel表名
StringBuffer filenamebuffer = new StringBuffer();
if (StringUtils.isNotBlank(studept)) {
filenamebuffer.append(studept);
filenamebuffer.append("-");
}
if (StringUtils.isNotBlank(stugrade)) {
filenamebuffer.append(stugrade);
filenamebuffer.append("级-");
}
filenamebuffer.append("节假日去向表");
String filename = filenamebuffer.toString();
try {
ExcelUtils.writeExcel(filename, response, list, LeaveInfo.class);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 获取饼状图的数据
*
* @return
*/
@ResponseBody
@RequestMapping(value = "/leave/echartsData")
public String getLeaveInfoEchartsData(HttpServletRequest request) {
String studept = (String) request.getSession().getAttribute("dept");
String stugrade = (String) request.getSession().getAttribute("grade");
HashMap<String, Object> map = teacherService.getLeaveInfoEchartsData(studept, stugrade);
String result = JSON.toJSONString(map);
System.out.println(result);
return result;
}
/**
* 留校管理
*
* @return
*/
@RequestMapping(value = "/stayinManage")
public String stayinManege() {
return "/teacher/stayin-manage";
}
/**
* 留校申请列表
*
* @param siVo
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/stayin/list")
public DataGridViewResult findStayInfoListByPage(StayInfoVo siVo, HttpServletRequest request) {
String studept = (String) request.getSession().getAttribute("dept");
String stugrade = (String) request.getSession().getAttribute("grade");
if (StringUtils.isNotBlank(studept)) {
siVo.setStudept(studept);
}
if (StringUtils.isNotBlank(stugrade)) {
siVo.setStugrade(stugrade);
}
System.out.println(siVo);
// 设置分页信息
PageHelper.startPage(siVo.getPage(), siVo.getLimit());
// 查询
List<StayInfo> list = teacherService.findStayInfoListByPage(siVo);
// 创建分页对象
PageInfo<StayInfo> pageInfo = new PageInfo<StayInfo>(list);
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
/**
* 审批学生留校申请
*
* @param si
* @return
*/
@ResponseBody
@RequestMapping(value = "/stayin/approve")
public String approveStayInfo(StayInfo si) {
HashMap<String, Object> map = new HashMap<>();
System.out.println(si);
int result = teacherService.approveStayInfo(si);
if (result > 0) {
map.put("success", true);
map.put("msg", "审批成功");
} else {
map.put("success", false);
map.put("msg", "审批失败,请稍后再试!");
}
return JSON.toJSONString(map);
}
/**
* 导出学生留校申请信息
*
* @param request
* @param response
*/
@ResponseBody
@RequestMapping(value = "/stayin/export.action")
public void exportStayInfoToExcel(HttpServletRequest request, HttpServletResponse response) {
response.reset();// 清除缓存
String studept = (String) request.getSession().getAttribute("dept");
String stugrade = (String) request.getSession().getAttribute("grade");
// 查找学生登记信息
List<StayInfo> list = teacherService.exportStayInfo(studept, stugrade);
// 拼接excel表名
StringBuffer filenamebuffer = new StringBuffer();
if (StringUtils.isNotBlank(studept)) {
filenamebuffer.append(studept);
filenamebuffer.append("-");
}
if (StringUtils.isNotBlank(stugrade)) {
filenamebuffer.append(stugrade);
filenamebuffer.append("级-");
}
filenamebuffer.append("留校申请表");
String filename = filenamebuffer.toString();
try {
ExcelUtils.writeExcel(filename, response, list, StayInfo.class);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 获取留校申请中的统计数据
*
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/stayin/echartsData")
public String getStayInfoEchartsData(HttpServletRequest request) {
String studept = (String) request.getSession().getAttribute("dept");
String stugrade = (String) request.getSession().getAttribute("grade");
JSONObject data = teacherService.getStayInfoEchartsData(studept, stugrade);
System.out.println(JSON.toJSONString(data));
return JSON.toJSONString(data);
}
@RequestMapping(value = "/backManage")
public String backManage() {
return "/teacher/back-manage";
}
/**
* 查找学生返校信息
*
* @param bsVo
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/back/list")
public DataGridViewResult findBackToScInfoListByPage(BackToScInfoVo bsVo, HttpServletRequest request) {
String studept = (String) request.getSession().getAttribute("dept");
String stugrade = (String) request.getSession().getAttribute("grade");
if (StringUtils.isNotBlank(studept)) {
bsVo.setStudept(studept);
}
if (StringUtils.isNotBlank(stugrade)) {
bsVo.setStugrade(stugrade);
}
System.out.println(bsVo);
// 设置分页信息
PageHelper.startPage(bsVo.getPage(), bsVo.getLimit());
// 查询
List<BackToScInfo> list = teacherService.findBackToScInfoListByPage(bsVo);
// 创建分页对象
PageInfo<BackToScInfo> pageInfo = new PageInfo<BackToScInfo>(list);
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
/**
* 导出学生返校登记信息
*
* @param request
* @param response
*/
@ResponseBody
@RequestMapping(value = "/back/export.action")
public void exportBackToScInfoToExcel(HttpServletRequest request, HttpServletResponse response) {
response.reset();// 清除缓存
String studept = (String) request.getSession().getAttribute("dept");
String stugrade = (String) request.getSession().getAttribute("grade");
// 查找学生登记信息
List<BackToScInfo> list = teacherService.exportBackToScInfo(studept, stugrade);
// 拼接excel表名
StringBuffer filenamebuffer = new StringBuffer();
if (StringUtils.isNotBlank(studept)) {
filenamebuffer.append(studept);
filenamebuffer.append("-");
}
if (StringUtils.isNotBlank(stugrade)) {
filenamebuffer.append(stugrade);
filenamebuffer.append("级-");
}
filenamebuffer.append("返校登记表");
String filename = filenamebuffer.toString();
try {
ExcelUtils.writeExcel(filename, response, list, BackToScInfo.class);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 获取返校登记的统计数据
*
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/back/echartsData")
public String getBackToScInfoEchartsData(HttpServletRequest request) {
String studept = (String) request.getSession().getAttribute("dept");
String stugrade = (String) request.getSession().getAttribute("grade");
JSONObject data = teacherService.getBackToScInfoEchartsData(studept, stugrade);
System.out.println(JSON.toJSONString(data));
return JSON.toJSONString(data);
}
/**
* 查看基本信息(老师/宿管员)
*
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/basic/info")
public String viewStudentInfo(HttpServletRequest request) {
HashMap<String, Object> map = new HashMap<>();
String uid = (String) request.getSession().getAttribute("uid");
if (StringUtils.isNotBlank(uid)) {
Users users = teacherService.findUsersByUid(uid);
if (users != null) {
map.put("success", true);
map.put("data", users);
} else {
map.put("success", false);
map.put("msg", "系统错误:不存在该用户!");
}
}
return JSON.toJSONString(map);
}
/**
* 更改基本信息
*
* @param users
* @return
*/
@ResponseBody
@RequestMapping(value = "/basic/update")
public String updateUsers(Users users) {
HashMap<String, Object> map = new HashMap<>();
System.out.println(users);
int result = teacherService.updateUsers(users);
if (result > 0) {
map.put("success", true);
map.put("msg", "保存成功!");
} else {
map.put("success", false);
map.put("msg", "保存失败!");
}
return JSON.toJSONString(map);
}
}