摘 要:宿舍是大学生学习与生活的主要场所之一,宿舍管理是高校学工管理事务中
尤为重要的一项。随着我国高校招生规模的进一步扩大,学生总体人数的不断增加,
宿舍管理工作变得愈加沉重和琐碎,学生宿舍信息的采集、汇总、统计与分析等各
项工作都面临诸多困难,传统的管理模式早已无法满足当前我国高校的管理需求了。
因此,迫切需要研究设计和开发一个新型的高校宿舍管理系统,以便更好地满足高
校宿舍管理工作的实际需求,方便宿管人员开展管理工作,提升管理水平,提高工
作效率,节约人力、物力,为广大学生群体提供更优质、高效的服务。
基于上述背景,本文设计并开发了一个高校宿舍管理系统。系统采用 B/S 架构,
后端基于 Java 语言和 SpringBoot 框架的方式进行了开发,前端则是使用 Layui 框
架,结合 HTML、JQuery、Ajax 等技术进行开发,并使用 MySQL 数据库对所有相关的
信息进行了存储。系统主要包括基本信息管理、离返校管理、宿舍分配管理、宿舍
日常管理、综合查询管理等五大功能模块,并根据学生、辅导员、宿舍管理员的使
用需求对这些功能进行了细化和实现。通过本系统能够方便、快捷地采集、查看、
统计相关的信息,并以图形化界面的方式展示出来,较好地满足了目标用户的需求,
提高了宿舍管理的水平,有利于我国推进高校学工管理真正实现信息化、科学化、
规范化的历史性进程。
关键词:宿舍管理;SpringBoot;宿舍分配;管理系统
系统演示视频:
springboot mybatis大学生校园宿舍管理系统源码含文档
一、相关研究现状和发展趋势
1.1 国外研究现状
国外关于学生宿舍管理系统的研究起步比较早,在上世纪九十年代,美国的
Kenneth C.Green 教授第一次提出“Campus Computing”(校园信息化)的理念,
并在同年开展了针对美国的高校的信息化研究项目“Campus Computing Project”
[1]。随后,随着计算机技术的飞速发展,校园信息化技术被推广应用到高校的各个
领域,其中最为广泛的要数教学、科研、管理等领域。
目前,国外高校在宿舍管理上已经拥有了相当成熟的经验,这方面的技术也发
展得比较成熟,拥有一套较为完善的信息化开发和研究框架[2]。欧美多数高校都建
立有自己的宿舍管理系统,由专门的开发团队对本校的系统进行开发、升级和维护,
采用的技术也比较先进,许多新兴技术都得到了实施应用。比如生物特征识别技术
的使用,其中最常见的为人脸识别技术[3],高校事先将学生的人脸信息录入到系统
中,学生进出宿舍楼只需要站在机器前刷一下脸;也有部分高校采取另一种模式—
—指纹识别技术来进行身份认证[4],学生只需要在指纹识别器上按一下即可,整个
过程几秒钟不到,方便快捷,有效避免了校外人员乱入的现象。并且有电子监控设
备全天候、全方位监控宿舍周边环境,对学生的生命及财产安全起到了极大的保护
作用,一旦发生异常情况,监控中心会根据具体情况统一调度、高度处理。此外,
美国的宿舍管理十分人性化,可以提供自助洗衣和娱乐室等各种服务[5-6]。
填写报修单:
package com.usc.lzh.doms.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.usc.lzh.doms.entity.Users;
import com.usc.lzh.doms.service.IndexService;
import com.usc.lzh.doms.service.MenuService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;
@Controller
@RequestMapping("/")
public class IndexController {
@Resource
private IndexService indexService;
@Resource
private MenuService menuService;
public String index() {
return "index";
}
@RequestMapping(value = "/login.html")
public String toLogin() {
return "/login";
}
@RequestMapping(value = "/home.html")
public String home() {
return "/home";
}
/**
* 验证登录
*
* @param re 前端返回的参数
* @param session 将用户信息添加到session中
* @return
*/
@ResponseBody
@RequestMapping(value = "/login.action")
public String loginAction(@RequestBody Map<String, String> re, HttpSession session) {
String uid = re.get("username");
String upwd = re.get("password");
Integer utype = Integer.parseInt(re.get("type"));
System.out.println(utype);
Users user = indexService.findUserByuId(uid, upwd, utype);
Map<String, Object> map = new HashMap<>();
if (user != null) {
session.setAttribute("uid", uid);
session.setAttribute("uname", user.getUname());
session.setAttribute("utype", utype);
// 如果是教师或宿管员,还要把他们负责的部门(专业年级/宿舍楼)记下
if (utype == 1) {
session.setAttribute("dept", user.getDept());
session.setAttribute("grade", user.getGrade());
} else if (utype == 2) {
session.setAttribute("brarea", user.getBrarea());
session.setAttribute("brbid", user.getBrbid());
}
map.put("type", "success");
} else {
map.put("type", "error");
}
return JSON.toJSONString(map);
}
/**
* 退出登录
*
* @param session
* @return 返回到登录界面
*/
@RequestMapping(value = "/logout.action")
public String logout(HttpSession session) {
// 清空session中的属性
session.removeAttribute("uid");
session.removeAttribute("uname");
session.removeAttribute("utype");
//让session无效
session.invalidate();
return "redirect:/login";
}
@ResponseBody
@RequestMapping(value = "/api/loadMenuList")
public String loadMenuList(HttpSession session) {
Integer utype = (Integer) session.getAttribute("utype");
String initJson = menuService.loadMenuList(utype);
System.out.println(initJson);
return initJson;
}
/**
* 基本资料
*
* @param session
* @return
*/
@RequestMapping(value = "/basic-info.html")
public String setBasicInfo(HttpSession session) {
Integer utype = (Integer) session.getAttribute("utype");
// 是学生则返回学生的界面
if (utype == 0) {
return "/student/basic-info";
} else {
return "/basic-info";
}
}
/**
* 修改密码
*
* @return
*/
@RequestMapping(value = "/password-setting.html")
public String setPassword() {
return "/password-setting";
}
@ResponseBody
@RequestMapping(value = "/updatePassword.action")
public String updatePassword(HttpServletRequest request) {
HashMap<String, Object> map = new HashMap<>();
String uid = (String) request.getSession().getAttribute("uid");
Integer utype = (Integer) request.getSession().getAttribute("utype");
String param = request.getParameter("param");
System.out.println(param);
try {
if (StringUtils.isNotBlank(param)) {
JSONObject obj = JSONObject.parseObject(param);
String old_password = (String) obj.get("old_password");
String new_password = (String) obj.get("new_password");
int result = indexService.updatePassword(uid, utype, old_password, new_password);
switch (result) {
case -1:
map.put("success", false);
map.put("msg", "系统出错,修改失败!");
break;
case 0:
map.put("success", false);
map.put("msg", "旧密码不正确!");
break;
case 1:
map.put("success", true);
map.put("msg", "修改成功!");
}
return JSON.toJSONString(map);
}
} catch (Exception e) {
e.printStackTrace();
map.put("success", false);
map.put("msg", "系统出错,修改失败!");
}
return JSON.toJSONString(map);
}
}
国内研究现状
自 CERNET 项目启动以来,许多高校开始重视自身的数字化发展。目前为止,90%
以上的高校建立了自己的校园网,部分实力雄厚的高校已经开发出基于本校特色的
信息化管理系统[7],如教务管理系统、图书管理系统和学生管理系统等。但在宿舍
管理方面,许多高校还未应用信息化的管理模式,大部分还是使用传统的手工管理
模式[8],这种方式需要耗费大量的人力、物力,从而导致工作效率低下、且容易出
错。针对宿舍管理工作中遇到的这些困境,有许多学者对此进行了大量的研究,从
不同学校的实际情况出发,利用不同的软件技术和软件方法开发出了一批宿舍管理
系统[9]。
从宿舍管理的业务功能角度出发,蒋维昱[10]设计并实现了学生宿舍管理系统,
提供了宿舍分配管理、财产管理、安全管理、水电网服务、卫生检查和假期宿舍管
理等业务功能操作模块,基本满足了宿舍的日常管理需求,大大缓解了宿管人员的
工作压力,提高了他们的工作效率。从宿舍管理的安全性角度出发,解秀叶[11]设计
了门禁管理系统,对学生进出宿舍进行监控和详细记录,并且该系统还可以对学生
的进出记录进行统计分析,自动生成考勤报表,减轻了宿管人员的工作量;刘九畅
[12]
则采用人脸识别技术,使用 OpenCV 技术将摄像头拍摄的人像信息载入系统程序,结
合卷积神经网络算法实现人脸识别功能,在一定程度上限制了外来人员非法乱入,
保障学生的人身和财产安全。从宿舍管理的人性化角度出发,曹雪雪[13-14]设计和实
现了基于学生个性的宿舍分配管理系统,提供两种方案为学生分配宿舍,第一种方
案采用 Kmeans 聚类算法与贪心算法相结合的分配算法,将作息习惯、生活习惯、性
格特点相似的学生安排到同一宿舍,第二种则是将选择权交给学生,学生可以通过
查看每个宿舍已入住学生的个性信息,自主选择宿舍和室友,这样的设计充分尊重
了新时代学生的个性化需求,减少了宿舍矛盾的发生,体现了高校以人为本的思想。
由于目前国内针对学生宿舍管理这一块还没有统一的标准,不同学者设计出来
的系统也是五花八门的。在软件架构的选择上,有基于 C/S 模式[15]的,B/S 模式
[16]
的,或者二者相结合[17]的;而且采用的开发技术也不尽相同,如基于 JSP 技术[18]、
基于.NET 技术[19]、基于 UML 建模技术[20]等等。这些技术的有效使用,为高校提供了
丰富的宿舍管理系统,满足了宿舍管理工作的实际需求,极大地方便了宿管人员开
展工作,提高了他们的工作效率。
1.3 发展趋势
知网上关于宿舍管理的研究,总计有 4301 篇中文文献,近 20 年研究趋势如图
1.1 所示,研究热度总体上呈上升趋势。
图 1.1 宿舍管理中文文献年度发表趋势图
通过研究发现,随着数字化校园建设进程的推进,高校宿舍管理系统实现了从
无到有,从功能单一到逐渐多样化的发展历程,管理模式正由人工管理向信息化管
理转变,对宿舍管理系统的设计,也逐渐趋向于可视化、对象化和网络化[21]。对于
高校而言,开发一个科学、稳定、高效的系统是提高其管理水平的必然趋势。以目
前的情况来看,我国的宿舍管理系统大多局限于对住宿信息、卫生情况、晚归考勤
等信息的统计分析,基本满足了宿舍日常管理的需求,但相较于国外的多功能、智
能化、人性化管理,仍有不小的差距,在提高管理质量和服务水平的道路上还有很
长的路要走,因此,宿舍管理系统的设计与开发还存在着很大的研究空间。
package com.usc.lzh.doms.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.usc.lzh.doms.entity.*;
import com.usc.lzh.doms.service.DorMService;
import com.usc.lzh.doms.utils.MyStringUtil;
import com.usc.lzh.doms.utils.DataGridViewResult;
import com.usc.lzh.doms.utils.ExcelUtils;
import com.usc.lzh.doms.vo.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.alibaba.fastjson.JSON;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.SimpleDateFormat;
import java.util.*;
@Controller
@RequestMapping("/dm")
public class DorMController {
@Resource
private DorMService dormService;
/**
* 卫生检查列表
*
* @return
*/
@RequestMapping(value = "/cleanList")
public String cleanList() {
return "/dm/clean-list";
}
/**
* 查看卫生检查情况
*
* @param ciVo
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/clean/list")
public DataGridViewResult findCleanInfoList(CleanInfoVo ciVo, HttpServletRequest request) {
// 获取宿管员管理的宿舍区和楼栋号,拼接成brcode
String brarea = (String) request.getSession().getAttribute("brarea");
String brbid = (String) request.getSession().getAttribute("brbid");
String brcode = MyStringUtil.getBrcode(brarea, brbid, "");
if (StringUtils.isNotBlank(brcode)) {
ciVo.setBrcode(brcode);
}
System.out.println(ciVo);
// 设置分页信息
PageHelper.startPage(ciVo.getPage(), ciVo.getLimit());
// 查询
List<CleanInfo> list = dormService.findCleanInfoListByPage(ciVo);
// 创建分页对象
PageInfo<CleanInfo> pageInfo = new PageInfo<CleanInfo>(list);
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
/**
* 更改卫生检查信息
*
* @param ci
* @return
*/
@ResponseBody
@RequestMapping(value = "/clean/update")
public String updateCleanInfo(CleanInfo ci) {
System.out.println(ci);
HashMap<String, Object> map = new HashMap<>();
int result = dormService.updateCleanInfo(ci);
if (result > 0) {
map.put("success", true);
map.put("msg", "更改成功!");
} else {
map.put("success", false);
map.put("msg", "更改失败!");
}
return JSON.toJSONString(map);
}
/**
* 删除卫生检查记录
*
* @param id
* @return
*/
@ResponseBody
@RequestMapping(value = "/clean/delete")
public String deleteCleanInfo(String id) {
System.out.println(id);
HashMap<String, Object> map = new HashMap<>();
int result = dormService.deleteCleanInfo(id);
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 = "/clean/add.html")
public String addCleanInfo() {
return "/dm/clean-add";
}
/**
* 批量添加卫生检查记录
*
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/clean/add")
public String batchAddCleanInfo(HttpServletRequest request) {
HashMap<String, Object> map = new HashMap<>();
String params = request.getParameter("params");
String checker = (String) request.getSession().getAttribute("uname");
try {
boolean result = dormService.batchInsertCleanInfo(params, checker);
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);
}
/**
* 学生报修列表
*
* @return
*/
@RequestMapping(value = "/repairList")
public String viewRepairList() {
return "/dm/repair-list";
}
/**
* 查找该宿管员负责的楼栋下的报修信息
*
* @param riVo
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/repair/list")
public DataGridViewResult findRepairInfoList(RepairInfoVo riVo, HttpServletRequest request) {
// 拼接brcode
String brarea = (String) request.getSession().getAttribute("brarea");
String brbid = (String) request.getSession().getAttribute("brbid");
if (StringUtils.isBlank(brarea)) {
brarea = riVo.getBrarea();
}
if (StringUtils.isBlank(brbid)) {
brbid = riVo.getBrbid();
}
String brcode = MyStringUtil.getBrcode(brarea, brbid, "");
if (StringUtils.isNotBlank(brcode)) {
riVo.setBrcode(brcode);
}
System.out.println(riVo);
// 设置分页信息
PageHelper.startPage(riVo.getPage(), riVo.getLimit());
// 查询
List<RepairInfo> list = dormService.findRepairInfoListByPage(riVo);
// 创建分页对象
PageInfo<RepairInfo> pageInfo = new PageInfo<RepairInfo>(list);
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
/**
* 查看报修详情
*
* @return
*/
@RequestMapping(value = "/repair/detail.html")
public String repairDetail() {
return "/dm/repair-detail";
}
/**
* 导出报修数据
*
* @param request
* @param response
*/
@ResponseBody
@RequestMapping(value = "/repair/export.action")
public void exportToExcel(HttpServletRequest request, HttpServletResponse response) {
HashMap<String, Object> map = new HashMap<>();
response.reset();// 清除缓存
// 获取宿管员管理的宿舍区和楼栋号,拼接成brcode
String brarea = (String) request.getSession().getAttribute("brarea");
String brbid = (String) request.getSession().getAttribute("brbid");
String brcode = MyStringUtil.getBrcode(brarea, brbid, "");
String status = request.getParameter("status");
System.out.println("status" + status);
System.out.println("brcode" + brcode);
// 根据条件查找报修列表
List<RepairInfo> list = dormService.exportRepairInfo(brcode, status);
// 拼接excel表名
StringBuffer filenamebuffer = new StringBuffer();
if (StringUtils.isNotBlank(brcode)) {
filenamebuffer.append(brcode);
filenamebuffer.append("-");
}
filenamebuffer.append("报修表");
String filename = filenamebuffer.toString();
try {
ExcelUtils.writeExcel(filename, response, list, RepairInfo.class);
map.put("success", true);
map.put("msg", "导出成功!");
System.out.println(JSON.toJSONString(map));
} catch (Exception e) {
e.printStackTrace();
map.put("success", false);
map.put("msg", "导出失败!");
}
// return JSON.toJSONString(map);
}
/**
* 批量更改报修状态
*
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/repair/edit")
public String editRepairStatus(HttpServletRequest request) {
HashMap<String, Object> map = new HashMap<>();
String params = request.getParameter("params");
if (StringUtils.isNotBlank(params)) {
boolean result = dormService.batchEditRepairStatus(params);
if (result) {
map.put("success", true);
map.put("msg", "更改成功!");
return JSON.toJSONString(map);
} else {
map.put("success", false);
map.put("msg", "更改失败!");
return JSON.toJSONString(map);
}
}
map.put("success", false);
map.put("msg", "更改失败!请选择要更改的行。");
return JSON.toJSONString(map);
}
/**
* 学生报修列表
*
* @return
*/
@RequestMapping(value = "/buildroomList")
public String viewBuildRoomList() {
return "/dm/buildroom-list";
}
/**
* 查看宿舍信息
*
* @param biVo
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/buildroom/list")
public DataGridViewResult findBuildRoomInfo(BuildRoomInfoVo biVo, HttpServletRequest request) {
// 拼接brcode
String brarea = (String) request.getSession().getAttribute("brarea");
if (StringUtils.isBlank(brarea)) {
brarea = biVo.getBrarea();
}
/*
* 如果管理员负责具体的一栋楼,则只能查询本栋楼有关的宿舍信息;
* 如果是负责一个区,则可以查询这个区下所有楼的宿舍信息
* session中没有brbid说明是负责一个区的,此时按照用户输入的楼栋数来进行查询
*/
String brbid = (String) request.getSession().getAttribute("brbid");
if (StringUtils.isBlank(brbid)) {
brbid = biVo.getBrbid();
}
String brrid = biVo.getBrrid();
String brcode = MyStringUtil.getBrcode(brarea, brbid, brrid);
if (StringUtils.isNotBlank(brcode)) {
biVo.setBrcode(brcode);
}
System.out.println(biVo);
// 设置分页信息
PageHelper.startPage(biVo.getPage(), biVo.getLimit());
// 查询
List<RepairInfo> list = dormService.findBuildRoomInfoListByPage(biVo);
// 创建分页对象
PageInfo<RepairInfo> pageInfo = new PageInfo<RepairInfo>(list);
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
/**
* 单个添加宿舍信息
*
* @param bi
* @return
*/
@ResponseBody
@RequestMapping(value = "/buildroom/add")
public String addBuildRoomInfo(BuildRoomInfo bi) {
HashMap<String, Object> map = new HashMap<>();
// 拼接brcode,如果brcode是空,说明宿舍信息错误了
String brarea = bi.getBrarea();
String brbid = bi.getBrbid();
String brrid = bi.getBrrid();
String brcode = MyStringUtil.getBrcode(brarea, brbid, brrid);
if (StringUtils.isBlank(brcode)) {
map.put("success", false);
map.put("msg", "添加失败!宿舍信息错误!");
return JSON.toJSONString(map);
}
// 计算空余数
Integer free = bi.getVolume() - bi.getPeople();
if (free < 0) {
map.put("success", false);
map.put("msg", "添加失败!入住数不能大于床位数!");
return JSON.toJSONString(map);
}
bi.setBrcode(brcode);
bi.setFree(free);
System.out.println(bi);
List<BuildRoomInfo> list = new ArrayList<>();
list.add(bi);
boolean result = dormService.addBuildRoomInfo(list);
if (result) {
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 = "/buildroom/import.action")
public String importExcel(@RequestParam("file") MultipartFile file) {
HashMap<String, Object> map = new HashMap<>();
try {
List<BuildRoomInfo> list = ExcelUtils.readExcel("", BuildRoomInfo.class, file);
// 拼接brcode和计算空余数
for (int i = 0; i < list.size(); i++) {
String brarea = list.get(i).getBrarea();
String brbid = list.get(i).getBrbid();
String brrid = list.get(i).getBrrid();
String brcode = MyStringUtil.getBrcode(brarea, brbid, brrid);
Integer free = list.get(i).getVolume() - list.get(i).getPeople();
list.get(i).setBrcode(brcode);
list.get(i).setFree(free);
}
boolean result = dormService.addBuildRoomInfo(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);
}
/**
* 更改宿舍信息
*
* @param bi
* @return
*/
@ResponseBody
@RequestMapping(value = "/buildroom/update")
public String updateBuildRoomInfo(BuildRoomInfo bi) {
HashMap<String, Object> map = new HashMap<>();
try {
// 如果入住数小于等于床位数,则执行更新操作,否则返回提示
Integer free = bi.getVolume() - bi.getPeople();
if (free >= 0) {
bi.setFree(free);
System.out.println(bi);
int result = dormService.updateBuildRoomInfo(bi);
// 返回值大于0表示成功执行了更改操作,小于0表示发生了异常
if (result > 0) {
map.put("success", true);
map.put("msg", "更改成功!");
return JSON.toJSONString(map);
} else {
map.put("success", false);
map.put("msg", "更改失败!");
return JSON.toJSONString(map);
}
} else {
map.put("success", false);
map.put("msg", "更改失败!入住数不能大于床位数!");
return JSON.toJSONString(map);
}
} catch (Exception e) {
e.printStackTrace();
map.put("success", false);
map.put("msg", "更改失败!");
return JSON.toJSONString(map);
}
}
/**
* 删除宿舍信息
*
* @param brcode
* @return
*/
@ResponseBody
@RequestMapping(value = "/buildroom/delete")
public String deleteBuildRoomInfo(String brcode) {
System.out.println(brcode);
HashMap<String, Object> map = new HashMap<>();
int result = dormService.deleteBuildRoomInfo(brcode);
if (result > 0) {
map.put("success", true);
map.put("msg", "删除成功!");
} else {
map.put("success", false);
map.put("msg", "删除失败!");
}
return JSON.toJSONString(map);
}
@RequestMapping(value = "/messageList")
public String viewMessageBoard() {
return "/dm/message-list";
}
/**
* 公告管理、失物招领
*
* @param mbVo
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/message/list")
public DataGridViewResult findMessageList(MessageBoardVo mbVo, HttpServletRequest request) {
// 获取当前管理员的管理区域
// 如果管理员负责众多楼栋,则按查询条件的宿舍区和楼栋来查,否则只能查他所负责的楼栋的公告信息
String brarea = (String) request.getSession().getAttribute("brarea");
String brbid = (String) request.getSession().getAttribute("brbid");
if (StringUtils.isBlank(brarea)) {
brarea = mbVo.getBrarea();
}
if (StringUtils.isBlank(brbid)) {
brbid = mbVo.getBrbid();
}
String brcode = MyStringUtil.getBrcode(brarea, brbid, "");
mbVo.setBrcode(brcode);
System.out.println(mbVo);
// 设置分页信息
PageHelper.startPage(mbVo.getPage(), mbVo.getLimit());
// 查询
List<MessageBoard> list = dormService.findMessageListByPage(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) {
// announcer是管理员的uname
String uname = (String) request.getSession().getAttribute("uname");
mb.setAnnouncer(uname);
HashMap<String, Object> map = new HashMap<>();
int result = dormService.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 mb
* @return
*/
@ResponseBody
@RequestMapping(value = "/message/update")
public String updateMessage(MessageBoard mb) {
// 拼接brcode
String brcode = MyStringUtil.getBrcode(mb.getBrarea(), mb.getBrbid(), "");
mb.setBrcode(brcode);
System.out.println(mb);
HashMap<String, Object> map = new HashMap<>();
int result = dormService.updateMessage(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");
System.out.println(id);
list.add(id);
}
boolean result = dormService.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);
}
/**
* 留校信息列表
*
* @return
*/
@RequestMapping(value = "/stayinList")
public String viewStayInfoList() {
return "/dm/stayin-list";
}
/**
* 查找留校信息列表
*
* @param stVo
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/stayin/list")
public DataGridViewResult findStayInfoListByPage(StayInfoVo stVo, HttpServletRequest request) {
String brarea = (String) request.getSession().getAttribute("brarea");
String brbid = (String) request.getSession().getAttribute("brbid");
if (StringUtils.isNotBlank(brarea)) {
stVo.setBrarea(brarea);
}
if (StringUtils.isNotBlank(brbid)) {
stVo.setBrbid(brbid);
}
System.out.println(stVo);
// 设置分页信息
PageHelper.startPage(stVo.getPage(), stVo.getLimit());
// 查询
List<StayInfo> list = dormService.findStayInfoListByPage(stVo);
// 创建分页对象
PageInfo<StayInfo> pageInfo = new PageInfo<StayInfo>(list);
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
/**
* 导出学生留校信息
*
* @param request
* @param response
*/
@ResponseBody
@RequestMapping(value = "/stayin/export.action")
public void exportStayInfoToExcel(HttpServletRequest request, HttpServletResponse response) {
response.reset();// 清除缓存
String brarea = (String) request.getSession().getAttribute("brarea");
String brbid = (String) request.getSession().getAttribute("brbid");
// 查找学生登记信息
List<StayInfo> list = dormService.exportStayInfo(brarea, brbid);
// 拼接excel表名
StringBuffer filenamebuffer = new StringBuffer();
if (StringUtils.isNotBlank(brarea)) {
filenamebuffer.append(brarea);
filenamebuffer.append("-");
}
if (StringUtils.isNotBlank(brbid)) {
filenamebuffer.append(brbid);
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 brarea = (String) request.getSession().getAttribute("brarea");
String brbid = (String) request.getSession().getAttribute("brbid");
JSONObject data = dormService.getStayInfoEchartsData(brarea, brbid);
System.out.println(JSON.toJSONString(data));
return JSON.toJSONString(data);
}
/**
* 预分配宿舍界面
*
* @return
*/
@RequestMapping(value = "/allocation/pre")
public String preAllocateDorm() {
return "/dm/pre-allocate";
}
/**
* 查找空余寝室
*
* @param biVo
* @return
*/
@ResponseBody
@RequestMapping(value = "/room/list")
public DataGridViewResult getFreeRoomList(BuildRoomInfoVo biVo) {
System.out.println(biVo);
// 设置分页信息
PageHelper.startPage(biVo.getPage(), biVo.getLimit());
// 查询
List<BuildRoomInfo> list = dormService.findFreeRoomListByPage(biVo);
// 创建分页对象
PageInfo<BuildRoomInfo> pageInfo = new PageInfo<BuildRoomInfo>(list);
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
/**
* 查找未分配寝室的学生
*
* @param siVo
* @return
*/
@ResponseBody
@RequestMapping(value = "/student/list")
public DataGridViewResult getNotAllocateStudentList(StudentInfoVo siVo) {
System.out.println(siVo);
// 设置分页信息
PageHelper.startPage(siVo.getPage(), siVo.getLimit());
// 查询
List<StudentInfo> list = dormService.findNotAllocateStudentListByPage(siVo);
// 创建分页对象
PageInfo<StudentInfo> pageInfo = new PageInfo<StudentInfo>(list);
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
@ResponseBody
@RequestMapping(value = "/allocation/doAllocate")
public String doAllocate(HttpServletRequest request) {
HashMap<String, Object> map = new HashMap<>();
String room = request.getParameter("room");
String student = request.getParameter("student");
System.out.println(room);
System.out.println(student);
map.put("msg", "接受到数据");
return JSON.toJSONString(map);
}
/**
* 判断床位数够不够
*
* @return
*/
@ResponseBody
@RequestMapping(value = "/allocation/isEnough")
public String judgeIsEnough() {
HashMap<String, Object> map = new HashMap<>();
boolean enough = dormService.judgeIsEnough();
if (enough) {
map.put("success", true);
} else {
map.put("success", false);
map.put("msg", "床位数不够,请先添加空余宿舍信息!");
}
return JSON.toJSONString(map);
}
/**
* 全部分配
*
* @return
*/
@ResponseBody
@RequestMapping(value = "/allocation/assignAll")
public String assignAll() {
HashMap<String, Object> map = new HashMap<>();
boolean success = dormService.doAssignAll();
if (success) {
map.put("success", true);
map.put("msg", "分配完毕,分配结果显示在当前页面下方。");
} else {
map.put("success", false);
map.put("msg", "分配失败!");
}
return JSON.toJSONString(map);
}
/**
* 显示分配结果
*
* @param aiVo
* @return
*/
@ResponseBody
@RequestMapping(value = "/allocation/result")
public DataGridViewResult viewAllocateResult(AllocationInfoVo aiVo) {
// 设置分页信息
PageHelper.startPage(aiVo.getPage(), aiVo.getLimit());
// 查询
List<AllocationInfo> list = dormService.viewAllocateResult(aiVo);
// 创建分页对象
PageInfo<AllocationInfo> pageInfo = new PageInfo<AllocationInfo>(list);
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
/**
* 宿舍分配列表
*
* @return
*/
@RequestMapping(value = "/allocation/list")
public String allocationList() {
return "/dm/allocation-list";
}
/**
* 查询宿舍分配信息
* 查询条件:专业/年级
*
* @param aiVo
* @return
*/
@ResponseBody
@RequestMapping(value = "/allocation/info")
public DataGridViewResult findAllocationInfoList(AllocationInfoVo aiVo, HttpServletRequest request) {
String brarea = (String) request.getSession().getAttribute("brarea");
String brbid = (String) request.getSession().getAttribute("brbid");
if (StringUtils.isNotBlank(brarea)) {
aiVo.setBrarea(brarea);
}
if (StringUtils.isNotBlank(brbid)) {
aiVo.setBrbid(brbid);
}
System.out.println(aiVo);
// 设置分页信息
PageHelper.startPage(aiVo.getPage(), aiVo.getLimit());
// 查询
List<AllocationInfo> list = dormService.findAllocationInfoListByPage(aiVo);
// 创建分页对象
PageInfo<AllocationInfo> pageInfo = new PageInfo<AllocationInfo>(list);
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
/**
* 导出学生宿舍分配信息
*
* @param request
* @param response
*/
@ResponseBody
@RequestMapping(value = "/allocation/export.action")
public void exportAllocationInfoToExcel(HttpServletRequest request, HttpServletResponse response) {
response.reset();// 清除缓存
String brarea = (String) request.getSession().getAttribute("brarea");
String brbid = (String) request.getSession().getAttribute("brbid");
// 查找宿舍分配信息
List<AllocationInfo> list = dormService.exportAllocationInfo(brarea, brbid);
// 拼接excel表名
StringBuffer filenamebuffer = new StringBuffer();
if (StringUtils.isNotBlank(brarea)) {
filenamebuffer.append(brarea);
filenamebuffer.append("-");
}
if (StringUtils.isNotBlank(brbid)) {
filenamebuffer.append(brbid);
filenamebuffer.append("栋-");
}
filenamebuffer.append("学生宿舍分配名单");
String filename = filenamebuffer.toString();
try {
ExcelUtils.writeExcel(filename, response, list, AllocationInfo.class);
} catch (Exception e) {
e.printStackTrace();
}
}
}
package com.usc.lzh.doms.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.usc.lzh.doms.entity.*;
import com.usc.lzh.doms.service.TeacherService;
import com.usc.lzh.doms.utils.DataGridViewResult;
import com.usc.lzh.doms.utils.ExcelUtils;
import com.usc.lzh.doms.vo.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* 教师对应的控制器
*/
@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);
}
}
参考文献
[1] 陈惠芬.高校学生宿舍服务平台设计与实现[D].华侨大学,2018.
[2] 谢欣伲.基于Android的高校学生公寓管理系统设计与实现[D].湖南大学,2015.
[3] 傅昌世.浙江理工大学学生宿舍管理系统的研究与分析[D].云南大学,2015.
[4] 孙赟,孔钦.基于Spring+Extjs的高校住宿管理系统的设计与实现[J].电子技术与软件工
程,2016(24):63-65.
[5] Xin Jia Wang,Qing Jiang Li. Application of Computer and Information Technology in
the Dormitory Management[J]. Advanced Materials Research,2014,3472.
[6] Zhao Kai. Design and Analysis of Campus Dormitory Management System Based on Java[J].
The Frontiers of Society, Science and Technology,2020,2(17).
[7] 袁英.民办高校学生宿舍管理系统的研究与分析[D].云南大学,2016.
[8] 张璨.学生宿舍管理系统的设计与实现[D].厦门大学,2014.
[9] 罗艺荣.学生宿舍管理系统的设计与实现[D].厦门大学,2013.
[10] 蒋维昱.学生宿舍管理系统的分析与设计[D].云南大学,2012.
[11] 解秀叶.学生宿舍门禁管理系统的设计与实现[D].中国海洋大学,2012.
[12] 刘九畅.基于人脸识别技术校园宿管系统的设计与实现[D].南京航空大学,2019.
[13] 曹雪雪.基于学生个性的宿舍分配管理系统设计与实现[D].杭州电子科技大学,2018.
[14] 曹雪雪.基于贪心算法的智能宿舍分配方法[J].计算机与现代化,2018(01):23-26+31.
[15] 谢之凯,王琳.基于C/S结构的高校宿舍管理系统设计与实现[J].科技信息,2011(16):
629+631.
[16] 谢红标,徐争前.基于Web的智能化宿舍管理系统的设计与实现[J].计算机时代,2007年第
6期:47-48.
[17] 李达.基于B/S和C/S混合模式的四川建院宿舍管理系统设计与实现[D].电子科技大学,
2011.
[18] 李珊.基于JSP的高校学生公寓管理系统的设计与实现[J].中国管理信息化,2019,22(12):
123-124.
[19] 王慧.基于.NET的学生公寓管理系统的设计与实现[D].华东师范大学,2009.
[20] 吴洲.基于UML的高校宿舍管理系统设计与实现[J].工业控制计算机,2010,23(06):97-98.
[21] 伍柏赪.基于S2SH框架的高校宿舍管理系统设计与实现[D].长沙理工大学,2017.
package com.usc.lzh.doms.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.usc.lzh.doms.entity.*;
import com.usc.lzh.doms.service.StudentService;
import com.usc.lzh.doms.utils.DataGridViewResult;
import com.usc.lzh.doms.vo.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@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 path = ResourceUtils.getURL("classpath:").getPath();
String classPath = "C:/Users/Administrator.SC-202003272235/Desktop/bishe/doms/target/classes/static";
// 父路径
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<>();
try{
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);
}
}catch (Exception e){
e.printStackTrace();
}
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);
}
}