宿舍是大学生学习与生活的主要场所之一,宿舍管理是高校学工管理事务中
尤为重要的一项。随着我国高校招生规模的进一步扩大,学生总体人数的不断增加,
宿舍管理工作变得愈加沉重和琐碎,学生宿舍信息的采集、汇总、统计与分析等各
项工作都面临诸多困难,传统的管理模式早已无法满足当前我国高校的管理需求了。
因此,迫切需要研究设计和开发一个新型的高校宿舍管理系统,以便更好地满足高
校宿舍管理工作的实际需求,方便宿管人员开展管理工作,提升管理水平,提高工
作效率,节约人力、物力,为广大学生群体提供更优质、高效的服务。
基于上述背景,本文设计并开发了一个高校宿舍管理系统。系统采用 B/S 架构,
后端基于 Java 语言和 SpringBoot 框架的方式进行了开发,前端则是使用 Layui 框
架,结合 HTML、JQuery、Ajax 等技术进行开发,并使用 MySQL 数据库对所有相关的
信息进行了存储。系统主要包括基本信息管理、离返校管理、宿舍分配管理、宿舍
日常管理、综合查询管理等五大功能模块,并根据学生、辅导员、宿舍管理员的使
用需求对这些功能进行了细化和实现。通过本系统能够方便、快捷地采集、查看、
统计相关的信息,并以图形化界面的方式展示出来,较好地满足了目标用户的需求,
提高了宿舍管理的水平,有利于我国推进高校学工管理真正实现信息化、科学化、
规范化的历史性进程。
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; @RequestMapping(value = "/cleanList") public String cleanList() { return "/dm/clean-list"; } @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()); // 查询 Listlist = dormService.findCleanInfoListByPage(ciVo); // 创建分页对象 PageInfo pageInfo = new PageInfo (list); // 按接口要求返回数据 DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList()); return data; } @ResponseBody @RequestMapping(value = "/clean/update") public String updateCleanInfo(CleanInfo ci) { System.out.println(ci); HashMap 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); } @ResponseBody @RequestMapping(value = "/clean/delete") public String deleteCleanInfo(String id) { System.out.println(id); HashMap 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); } @RequestMapping(value = "/clean/add.html") public String addCleanInfo() { return "/dm/clean-add"; } @ResponseBody @RequestMapping(value = "/clean/add") public String batchAddCleanInfo(HttpServletRequest request) { HashMap 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); } @RequestMapping(value = "/repairList") public String viewRepairList() { return "/dm/repair-list"; } @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 list = dormService.findRepairInfoListByPage(riVo); // 创建分页对象 PageInfo pageInfo = new PageInfo (list); // 按接口要求返回数据 DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList()); return data; } @RequestMapping(value = "/repair/detail.html") public String repairDetail() { return "/dm/repair-detail"; } @ResponseBody @RequestMapping(value = "/repair/export.action") public void exportToExcel(HttpServletRequest request, HttpServletResponse response) { HashMap 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 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); } @ResponseBody @RequestMapping(value = "/repair/edit") public String editRepairStatus(HttpServletRequest request) { HashMap 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); } @RequestMapping(value = "/buildroomList") public String viewBuildRoomList() { return "/dm/buildroom-list"; } @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(); } 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 list = dormService.findBuildRoomInfoListByPage(biVo); // 创建分页对象 PageInfo pageInfo = new PageInfo (list); // 按接口要求返回数据 DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList()); return data; } @ResponseBody @RequestMapping(value = "/buildroom/add") public String addBuildRoomInfo(BuildRoomInfo bi) { HashMap 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 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); } @ResponseBody @RequestMapping(value = "/buildroom/import.action") public String importExcel(@RequestParam("file") MultipartFile file) { HashMap map = new HashMap<>(); try { List 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); } @ResponseBody @RequestMapping(value = "/buildroom/update") public String updateBuildRoomInfo(BuildRoomInfo bi) { HashMap 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); } } @ResponseBody @RequestMapping(value = "/buildroom/delete") public String deleteBuildRoomInfo(String brcode) { System.out.println(brcode); HashMap 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"; } @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 list = dormService.findMessageListByPage(mbVo); // 创建分页对象 PageInfo pageInfo = new PageInfo (list); // 按接口要求返回数据 DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList()); return data; } @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 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); } @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 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); } @ResponseBody @RequestMapping(value = "/message/delete") public String deleteMessage(HttpServletRequest request) { HashMap map = new HashMap<>(); String params = request.getParameter("params"); System.out.println(params); try { if (StringUtils.isNotBlank(params)) { // 获取id数组 JSonArray jsonArray = JSONArray.parseArray(params); List 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); } @RequestMapping(value = "/stayinList") public String viewStayInfoList() { return "/dm/stayin-list"; } @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 list = dormService.findStayInfoListByPage(stVo); // 创建分页对象 PageInfo pageInfo = new PageInfo (list); // 按接口要求返回数据 DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList()); return data; } @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 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(); } } @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); } @RequestMapping(value = "/allocation/pre") public String preAllocateDorm() { return "/dm/pre-allocate"; } @ResponseBody @RequestMapping(value = "/room/list") public DataGridViewResult getFreeRoomList(BuildRoomInfoVo biVo) { System.out.println(biVo); // 设置分页信息 PageHelper.startPage(biVo.getPage(), biVo.getLimit()); // 查询 List list = dormService.findFreeRoomListByPage(biVo); // 创建分页对象 PageInfo pageInfo = new PageInfo (list); // 按接口要求返回数据 DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList()); return data; } @ResponseBody @RequestMapping(value = "/student/list") public DataGridViewResult getNotAllocateStudentList(StudentInfoVo siVo) { System.out.println(siVo); // 设置分页信息 PageHelper.startPage(siVo.getPage(), siVo.getLimit()); // 查询 List list = dormService.findNotAllocateStudentListByPage(siVo); // 创建分页对象 PageInfo pageInfo = new PageInfo (list); // 按接口要求返回数据 DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList()); return data; } @ResponseBody @RequestMapping(value = "/allocation/doAllocate") public String doAllocate(HttpServletRequest request) { HashMap 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); } @ResponseBody @RequestMapping(value = "/allocation/isEnough") public String judgeIsEnough() { HashMap 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); } @ResponseBody @RequestMapping(value = "/allocation/assignAll") public String assignAll() { HashMap 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); } @ResponseBody @RequestMapping(value = "/allocation/result") public DataGridViewResult viewAllocateResult(AllocationInfoVo aiVo) { // 设置分页信息 PageHelper.startPage(aiVo.getPage(), aiVo.getLimit()); // 查询 List list = dormService.viewAllocateResult(aiVo); // 创建分页对象 PageInfo pageInfo = new PageInfo(list); // 按接口要求返回数据 DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList()); return data; } @RequestMapping(value = "/allocation/list") public String allocationList() { return "/dm/allocation-list"; } @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 list = dormService.findAllocationInfoListByPage(aiVo); // 创建分页对象 PageInfo pageInfo = new PageInfo(list); // 按接口要求返回数据 DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList()); return data; } @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 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(); } } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)