当前位置:   article > 正文

Java项目:SpringBoot高校宿舍管理系统_高校住宿管理系统

高校住宿管理系统

作者主页: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 访问 

六、运行截图

​​​

七、相关代码

学生管理控制器

  1. @Controller
  2. @RequestMapping("/student")
  3. public class StudentController {
  4. @Resource
  5. private StudentService studentService;
  6. /**
  7. * 我的卫生检查记录界面
  8. *
  9. * @return
  10. */
  11. @RequestMapping(value = "/viewMyCleanInfo")
  12. public String viewMyCleanInfo() {
  13. return "/student/clean-list";
  14. }
  15. /**
  16. * 查询我的宿舍卫生检查记录
  17. *
  18. * @param ciVo 分页信息
  19. * @param request 用于获取session中的uid
  20. * @return
  21. */
  22. @ResponseBody
  23. @RequestMapping(value = "/clean/list")
  24. public DataGridViewResult findMyCleanInfoListByPage(CleanInfoVo ciVo, HttpServletRequest request) {
  25. // 获取学号
  26. String uid = (String) request.getSession().getAttribute("uid");
  27. ciVo.setStuid(uid);
  28. // 设置分页信息
  29. PageHelper.startPage(ciVo.getPage(), ciVo.getLimit());
  30. // 查询
  31. List<CleanInfo> list = studentService.findMyCleanInfoListByPage(ciVo);
  32. // 创建分页对象
  33. PageInfo<CleanInfo> pageInfo = new PageInfo<CleanInfo>(list);
  34. // 按接口要求返回数据
  35. DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
  36. return data;
  37. }
  38. /**
  39. * 我的报修界面
  40. *
  41. * @return
  42. */
  43. @RequestMapping(value = "/viewMyRepairInfo")
  44. public String viewMyRepairInfo() {
  45. return "/student/repair-list";
  46. }
  47. /**
  48. * 查询我的宿舍的报修记录
  49. *
  50. * @param riVo 分页信息
  51. * @param request 用于获取session中的uid
  52. * @return
  53. */
  54. @ResponseBody
  55. @RequestMapping(value = "/repair/list")
  56. public DataGridViewResult findMyRepairInfoListByPage(RepairInfoVo riVo, HttpServletRequest request) {
  57. // 获取学号
  58. String uid = (String) request.getSession().getAttribute("uid");
  59. riVo.setStuid(uid);
  60. // 设置分页信息
  61. PageHelper.startPage(riVo.getPage(), riVo.getLimit());
  62. // 查询
  63. List<RepairInfo> list = studentService.findMyRepairInfoListByPage(riVo);
  64. // 创建分页对象
  65. PageInfo<RepairInfo> pageInfo = new PageInfo<RepairInfo>(list);
  66. // 按接口要求返回数据
  67. DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
  68. return data;
  69. }
  70. /**
  71. * 提交报修单
  72. *
  73. * @param ri
  74. * @param request
  75. * @return
  76. */
  77. @ResponseBody
  78. @RequestMapping(value = "/repair/add")
  79. public String addRepairInfo(RepairInfo ri, HttpServletRequest request) {
  80. HashMap<String, Object> map = new HashMap<>();
  81. String stuid = (String) request.getSession().getAttribute("uid");
  82. ri.setStuid(stuid);
  83. // 报修提交时间
  84. Date date = new Date();
  85. DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
  86. ri.setSubtime(format.format(date));
  87. System.out.println(ri);
  88. // 去执行添加操作
  89. int result = studentService.addRepairInfo(ri);
  90. if (result > 0) {
  91. map.put("success", true);
  92. map.put("msg", "添加成功");
  93. } else {
  94. map.put("success", false);
  95. map.put("msg", "添加失败");
  96. }
  97. return JSON.toJSONString(map);
  98. }
  99. /**
  100. * 修改报修单
  101. *
  102. * @param ri
  103. * @param request
  104. * @return
  105. */
  106. @ResponseBody
  107. @RequestMapping(value = "/repair/update")
  108. public String updateRepairInfo(RepairInfo ri, HttpServletRequest request) {
  109. HashMap<String, Object> map = new HashMap<>();
  110. System.out.println(ri);
  111. // 判断这是不是自己的提交的报修单
  112. String stuid = (String) request.getSession().getAttribute("uid");
  113. if (!stuid.equals(ri.getStuid())) {
  114. map.put("success", false);
  115. map.put("msg", "只能修改自己提交的报修单!");
  116. return JSON.toJSONString(map);
  117. }
  118. int result = studentService.updateRepairInfo(ri);
  119. if (result > 0) {
  120. map.put("success", true);
  121. map.put("msg", "修改成功!");
  122. } else {
  123. map.put("success", false);
  124. map.put("msg", "修改失败!");
  125. }
  126. return JSON.toJSONString(map);
  127. }
  128. /**
  129. * 我的宿舍界面
  130. *
  131. * @return
  132. */
  133. @RequestMapping(value = "/viewMyDormInfo")
  134. public String viewMyDormInfo() {
  135. return "/student/myDorm";
  136. }
  137. /**
  138. * 查看留言板
  139. *
  140. * @return
  141. */
  142. @RequestMapping(value = "/viewMessageBoard")
  143. public String viewMessageBoard() {
  144. return "/student/messageboard";
  145. }
  146. @ResponseBody
  147. @RequestMapping(value = "/message/list")
  148. public String findMessageListByPage(HttpServletRequest request) {
  149. HashMap<String, Object> map = new HashMap<>();
  150. try {
  151. // 获取id,用来查找所在宿舍区
  152. String uid = (String) request.getSession().getAttribute("uid");
  153. // 获取当前页
  154. Integer curr = Integer.parseInt(request.getParameter("curr"));
  155. // 获取页面size
  156. Integer limit = Integer.parseInt(request.getParameter("limit"));
  157. // 获取信息类型
  158. Integer type = Integer.parseInt(request.getParameter("type"));
  159. // 起始行数
  160. Integer start = (curr - 1) * limit;
  161. List<MessageBoard> list = studentService.findMessageListByPage(uid, start, limit, type);
  162. // 总行数
  163. Integer count = studentService.findMessageCount(type);
  164. // 总页数
  165. Integer total = (count - 1) / limit + 1;
  166. map.put("success", true);
  167. map.put("count", count);
  168. map.put("total", total);
  169. map.put("curr", curr);
  170. map.put("limit", limit);
  171. map.put("data", list);
  172. System.out.println(JSON.toJSONString(map));
  173. return JSON.toJSONString(map);
  174. } catch (Exception e) {
  175. e.printStackTrace();
  176. map.put("success", false);
  177. map.put("msg", "系统错误!");
  178. return JSON.toJSONString(map);
  179. }
  180. }
  181. /**
  182. * 查看我的留言
  183. *
  184. * @return
  185. */
  186. @RequestMapping(value = "viewMyMessage")
  187. public String viewMyMessage() {
  188. return "/student/my-message";
  189. }
  190. /**
  191. * 查看我的留言
  192. *
  193. * @param mbVo
  194. * @param request
  195. * @return
  196. */
  197. @ResponseBody
  198. @RequestMapping(value = "/message/my")
  199. public DataGridViewResult myMessage(MessageBoardVo mbVo, HttpServletRequest request) {
  200. String uname = (String) request.getSession().getAttribute("uname");
  201. mbVo.setAnnouncer(uname);
  202. // 设置分页信息
  203. PageHelper.startPage(mbVo.getPage(), mbVo.getLimit());
  204. // 查询
  205. List<MessageBoard> list = studentService.findMyMessage(mbVo);
  206. // 创建分页对象
  207. PageInfo<MessageBoard> pageInfo = new PageInfo<MessageBoard>(list);
  208. // 按接口要求返回数据
  209. DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
  210. return data;
  211. }
  212. /**
  213. * 发布留言
  214. *
  215. * @param mb
  216. * @param request
  217. * @return
  218. */
  219. @ResponseBody
  220. @RequestMapping(value = "/message/add")
  221. public String addMessage(MessageBoard mb, HttpServletRequest request) {
  222. String uname = (String) request.getSession().getAttribute("uname");
  223. mb.setAnnouncer(uname);
  224. HashMap<String, Object> map = new HashMap<>();
  225. int result = studentService.addMessage(mb);
  226. if (result > 0) {
  227. map.put("success", true);
  228. map.put("msg", "添加成功!");
  229. } else {
  230. map.put("success", false);
  231. map.put("msg", "添加失败!");
  232. }
  233. return JSON.toJSONString(map);
  234. }
  235. /**
  236. * 批量删除留言
  237. *
  238. * @param request 获取前端传来的id数组
  239. * @return
  240. */
  241. @ResponseBody
  242. @RequestMapping(value = "/message/delete")
  243. public String deleteMessage(HttpServletRequest request) {
  244. HashMap<String, Object> map = new HashMap<>();
  245. String params = request.getParameter("params");
  246. System.out.println(params);
  247. try {
  248. if (StringUtils.isNotBlank(params)) {
  249. // 获取id数组
  250. JSONArray jsonArray = JSONArray.parseArray(params);
  251. List<Integer> list = new ArrayList<>();
  252. for (int i = 0; i < jsonArray.size(); i++) {
  253. JSONObject obj = jsonArray.getJSONObject(i);
  254. Integer id = (Integer) obj.get("id");
  255. list.add(id);
  256. }
  257. boolean result = studentService.deleteMessage(list);
  258. if (result) {
  259. map.put("success", true);
  260. map.put("msg", "删除成功!");
  261. } else {
  262. map.put("success", false);
  263. map.put("msg", "删除失败!");
  264. }
  265. }
  266. } catch (Exception e) {
  267. e.printStackTrace();
  268. map.put("success", false);
  269. map.put("msg", "删除失败!");
  270. }
  271. return JSON.toJSONString(map);
  272. }
  273. /**
  274. * 查看学生基本信息
  275. *
  276. * @param request
  277. * @return
  278. */
  279. @ResponseBody
  280. @RequestMapping(value = "/basic/info")
  281. public String viewStudentInfo(HttpServletRequest request) {
  282. HashMap<String, Object> map = new HashMap<>();
  283. String stuid = (String) request.getSession().getAttribute("uid");
  284. if (StringUtils.isNotBlank(stuid)) {
  285. StudentInfo si = studentService.findStudentInfoByStuid(stuid);
  286. if (si != null) {
  287. map.put("success", true);
  288. map.put("data", si);
  289. } else {
  290. map.put("success", false);
  291. map.put("msg", "系统错误:不存在该用户!");
  292. }
  293. }
  294. return JSON.toJSONString(map);
  295. }
  296. /**
  297. * 更改基本信息
  298. *
  299. * @param si
  300. * @return
  301. */
  302. @ResponseBody
  303. @RequestMapping(value = "/basic/update")
  304. public String updateStudentInfo(StudentInfo si) {
  305. HashMap<String, Object> map = new HashMap<>();
  306. System.out.println(si);
  307. int result = studentService.updateStudentInfo(si);
  308. if (result > 0) {
  309. map.put("success", true);
  310. map.put("msg", "保存成功!");
  311. } else {
  312. map.put("success", false);
  313. map.put("msg", "保存失败!");
  314. }
  315. return JSON.toJSONString(map);
  316. }
  317. @RequestMapping(value = "/leave/register")
  318. public String myLeaveInfo() {
  319. return "/student/leave-info";
  320. }
  321. /**
  322. * 查找我的离校登记记录
  323. *
  324. * @param liVo
  325. * @param request
  326. * @return
  327. */
  328. @ResponseBody
  329. @RequestMapping(value = "/leave/list")
  330. public DataGridViewResult findMyLeaveInfoByPage(LeaveInfoVo liVo, HttpServletRequest request) {
  331. String stuid = (String) request.getSession().getAttribute("uid");
  332. liVo.setStuid(stuid);
  333. System.out.println(liVo);
  334. // 设置分页信息
  335. PageHelper.startPage(liVo.getPage(), liVo.getLimit());
  336. // 查询
  337. List<LeaveInfo> list = studentService.findMyLeaveInfoByPage(liVo);
  338. // 创建分页对象
  339. PageInfo<LeaveInfo> pageInfo = new PageInfo<LeaveInfo>(list);
  340. // 按接口要求返回数据
  341. DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
  342. return data;
  343. }
  344. /**
  345. * 添加离校登记记录
  346. *
  347. * @param li
  348. * @param request
  349. * @return
  350. */
  351. @ResponseBody
  352. @RequestMapping(value = "/leave/add")
  353. public String addMyLeaveInfo(LeaveInfo li, HttpServletRequest request) {
  354. HashMap<String, Object> map = new HashMap<>();
  355. String stuid = (String) request.getSession().getAttribute("uid");
  356. li.setStuid(stuid);
  357. System.out.println(li);
  358. int result = studentService.addMyLeaveInfo(li);
  359. if (result > 0) {
  360. map.put("success", true);
  361. map.put("msg", "登记成功!");
  362. } else {
  363. map.put("success", false);
  364. map.put("msg", "登记失败,请稍后再试!");
  365. }
  366. return JSON.toJSONString(map);
  367. }
  368. /**
  369. * 修改离校登记记录
  370. *
  371. * @param li
  372. * @return
  373. */
  374. @ResponseBody
  375. @RequestMapping(value = "/leave/update")
  376. public String updateMyLeaveInfo(LeaveInfo li) {
  377. HashMap<String, Object> map = new HashMap<>();
  378. System.out.println(li);
  379. int result = studentService.updateMyLeaveInfo(li);
  380. if (result > 0) {
  381. map.put("success", true);
  382. map.put("msg", "更改成功!");
  383. } else {
  384. map.put("success", false);
  385. map.put("msg", "更改失败,请稍后再试!");
  386. }
  387. return JSON.toJSONString(map);
  388. }
  389. /**
  390. * 留校申请
  391. *
  392. * @return
  393. */
  394. @RequestMapping(value = "/stayin/apply")
  395. public String myStayInfo() {
  396. return "/student/stayin-apply";
  397. }
  398. /**
  399. * 查看自己的留校申请
  400. *
  401. * @param siVo
  402. * @param request
  403. * @return
  404. */
  405. @ResponseBody
  406. @RequestMapping(value = "/stayin/list")
  407. public DataGridViewResult findMyStayInfoListByPage(StayInfoVo siVo, HttpServletRequest request) {
  408. String stuid = (String) request.getSession().getAttribute("uid");
  409. siVo.setStuid(stuid);
  410. System.out.println(siVo);
  411. // 设置分页信息
  412. PageHelper.startPage(siVo.getPage(), siVo.getLimit());
  413. // 查询
  414. List<StayInfo> list = studentService.findMyStayInfoListByPage(siVo);
  415. // 创建分页对象
  416. PageInfo<StayInfo> pageInfo = new PageInfo<StayInfo>(list);
  417. // 按接口要求返回数据
  418. DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
  419. return data;
  420. }
  421. /**
  422. * 上传图片
  423. *
  424. * @param file
  425. * @param request
  426. * @return
  427. */
  428. @ResponseBody
  429. @RequestMapping(value = "/stayin/uploadImage")
  430. public String uploadOpinionImage(MultipartFile file, HttpServletRequest request) {
  431. HashMap<String, Object> map = new HashMap<>();
  432. HashMap<String, Object> data = new HashMap<>();
  433. try {
  434. if (file != null) {
  435. String stuid = (String) request.getSession().getAttribute("uid");
  436. String originalFilename = file.getOriginalFilename();
  437. Date date = new Date();
  438. String fileName = date.getTime() + "-" + originalFilename;
  439. // 类路径
  440. // String classPath = ResourceUtils.getURL("classpath:").getPath();
  441. // windows系统设置
  442. String classPath = "D:/file";
  443. // Mac系统设置
  444. // String classPath = "/Users/hanmeng/Desktop/upload";
  445. // 父路径
  446. String src = "/upload/stayin/"; // + stuid + "/";
  447. File directory = new File(classPath, src);
  448. if (!directory.exists()) {
  449. directory.mkdir();
  450. }
  451. // 文件名
  452. String imagePath = directory.getPath() + "/" + fileName;
  453. System.out.println(imagePath);
  454. file.transferTo(new File(imagePath));
  455. data.put("src", src + fileName);
  456. map.put("code", 0);
  457. map.put("msg", "上传成功!");
  458. map.put("data", data);
  459. return JSON.toJSONString(map);
  460. } else {
  461. map.put("code", -1);
  462. map.put("msg", "请选择图片!");
  463. return JSON.toJSONString(map);
  464. }
  465. } catch (Exception e) {
  466. e.printStackTrace();
  467. map.put("code", -1);
  468. map.put("msg", "上传失败,请稍后重试!");
  469. return JSON.toJSONString(map);
  470. }
  471. }
  472. /**
  473. * 提交留校申请
  474. *
  475. * @param si
  476. * @param request
  477. * @return
  478. */
  479. @ResponseBody
  480. @RequestMapping(value = "/stayin/add")
  481. public String addStayInfo(StayInfo si, HttpServletRequest request) {
  482. HashMap<String, Object> map = new HashMap<>();
  483. String stuid = (String) request.getSession().getAttribute("uid");
  484. si.setStuid(stuid);
  485. System.out.println(si);
  486. int result = studentService.addMyStayInfo(si);
  487. if (result > 0) {
  488. map.put("success", true);
  489. map.put("msg", "提交申请成功");
  490. } else {
  491. map.put("success", false);
  492. map.put("msg", "提交申请失败,请稍后重试!");
  493. }
  494. return JSON.toJSONString(map);
  495. }
  496. /**
  497. * 修改留校申请信息
  498. *
  499. * @param si
  500. * @return
  501. */
  502. @ResponseBody
  503. @RequestMapping(value = "/stayin/update")
  504. public String updateMyStayInfo(StayInfo si) {
  505. HashMap<String, Object> map = new HashMap<>();
  506. System.out.println(si);
  507. int result = studentService.updateMyStayInfo(si);
  508. if (result > 0) {
  509. map.put("success", true);
  510. map.put("msg", "修改成功!");
  511. } else {
  512. map.put("success", false);
  513. map.put("msg", "修改失败,请稍后再试!");
  514. }
  515. return JSON.toJSONString(map);
  516. }
  517. /**
  518. * 查看我的返校信息
  519. *
  520. * @return
  521. */
  522. @RequestMapping(value = "/viewMyBackInfo")
  523. public String viewMyBackToScInfo() {
  524. return "/student/back-info";
  525. }
  526. /**
  527. * 查找我的返校登记记录
  528. *
  529. * @param bsVo
  530. * @param request
  531. * @return
  532. */
  533. @ResponseBody
  534. @RequestMapping(value = "/back/list")
  535. public DataGridViewResult findMyBackInfoByPage(BackToScInfoVo bsVo, HttpServletRequest request) {
  536. String stuid = (String) request.getSession().getAttribute("uid");
  537. bsVo.setStuid(stuid);
  538. System.out.println(bsVo);
  539. // 设置分页信息
  540. PageHelper.startPage(bsVo.getPage(), bsVo.getLimit());
  541. // 查询
  542. List<BackToScInfo> list = studentService.findMyBackInfoByPage(bsVo);
  543. // 创建分页对象
  544. PageInfo<BackToScInfo> pageInfo = new PageInfo<BackToScInfo>(list);
  545. // 按接口要求返回数据
  546. DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
  547. return data;
  548. }
  549. /**
  550. * 添加返校登记记录
  551. *
  552. * @param bs
  553. * @param request
  554. * @return
  555. */
  556. @ResponseBody
  557. @RequestMapping(value = "/back/add")
  558. public String addMyBackInfo(BackToScInfo bs, HttpServletRequest request) {
  559. HashMap<String, Object> map = new HashMap<>();
  560. String stuid = (String) request.getSession().getAttribute("uid");
  561. bs.setStuid(stuid);
  562. System.out.println(bs);
  563. int result = studentService.addMyBackInfo(bs);
  564. if (result > 0) {
  565. map.put("success", true);
  566. map.put("msg", "提交成功!");
  567. } else {
  568. map.put("success", false);
  569. map.put("msg", "提交失败,请稍后再试!");
  570. }
  571. return JSON.toJSONString(map);
  572. }
  573. /**
  574. * 修改返校登记记录
  575. *
  576. * @param bs
  577. * @return
  578. */
  579. @ResponseBody
  580. @RequestMapping(value = "/back/update")
  581. public String updateMyBackInfo(BackToScInfo bs) {
  582. HashMap<String, Object> map = new HashMap<>();
  583. System.out.println(bs);
  584. int result = studentService.updateMyBackInfo(bs);
  585. if (result > 0) {
  586. map.put("success", true);
  587. map.put("msg", "更改成功!");
  588. } else {
  589. map.put("success", false);
  590. map.put("msg", "更改失败,请稍后再试!");
  591. }
  592. return JSON.toJSONString(map);
  593. }
  594. /**
  595. * 密码设置
  596. *
  597. * @return
  598. */
  599. @RequestMapping(value = "/setting")
  600. public String passwordSetting() {
  601. return "password-setting";
  602. }
  603. @RequestMapping(value = "/myDormitoryInfo")
  604. public String viewMyDormitoryInfo() {
  605. return "/student/my-dormitory";
  606. }
  607. /**
  608. * 查看自己宿舍信息
  609. *
  610. * @param aiVo
  611. * @param request
  612. * @return
  613. */
  614. @ResponseBody
  615. @RequestMapping(value = "/mydorm/list")
  616. public DataGridViewResult findMyDormitoryInfoListByPage(AllocationInfoVo aiVo, HttpServletRequest request) {
  617. String stuid = (String) request.getSession().getAttribute("uid");
  618. aiVo.setStuid(stuid);
  619. System.out.println(aiVo);
  620. // 设置分页信息
  621. PageHelper.startPage(aiVo.getPage(), aiVo.getLimit());
  622. // 查询
  623. List<AllocationInfo> list = studentService.findMyDormitoryInfoListByPage(aiVo);
  624. // 创建分页对象
  625. PageInfo<AllocationInfo> pageInfo = new PageInfo<AllocationInfo>(list);
  626. // 按接口要求返回数据
  627. DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
  628. return data;
  629. }
  630. /**
  631. * 判断是否已经选择床位了
  632. *
  633. * @param request
  634. * @return
  635. */
  636. @ResponseBody
  637. @RequestMapping(value = "/mydorm/isChoosed")
  638. public String isChooseBed(HttpServletRequest request) {
  639. HashMap<String, Object> map = new HashMap<>();
  640. String stuid = (String) request.getSession().getAttribute("uid");
  641. boolean status = studentService.isChooseBed(stuid);
  642. map.put("status", status);
  643. return JSON.toJSONString(map);
  644. }
  645. /**
  646. * 提交选择的床位号
  647. *
  648. * @param request
  649. * @return
  650. */
  651. @ResponseBody
  652. @RequestMapping(value = "/mydorm/chooseBed")
  653. public String chooseBed(HttpServletRequest request) {
  654. HashMap<String, Object> map = new HashMap<>();
  655. String stuid = (String) request.getSession().getAttribute("uid");
  656. String bed = request.getParameter("bed");
  657. if (StringUtils.isNotBlank(bed)) {
  658. int bedNum = Integer.parseInt(bed);
  659. // 提交床位号
  660. int result = studentService.chooseBed(stuid, bedNum);
  661. if (result > 0) {
  662. map.put("success", true);
  663. map.put("msg", "选择成功!");
  664. } else {
  665. map.put("success", false);
  666. map.put("msg", "选择失败!");
  667. }
  668. return JSON.toJSONString(map);
  669. } else {
  670. map.put("success", false);
  671. map.put("msg", "床位号不能为空!");
  672. return JSON.toJSONString(map);
  673. }
  674. }
  675. /**
  676. * 查找已经选择了的床位
  677. * @param request
  678. * @return
  679. */
  680. @ResponseBody
  681. @RequestMapping(value = "/mydorm/alreadyBeds")
  682. public String findAlreadyChooseBeds(HttpServletRequest request) {
  683. HashMap<String, Object> map = new HashMap<>();
  684. String stuid = (String) request.getSession().getAttribute("uid");
  685. List<Integer> list = studentService.findAlreadyChooseBeds(stuid);
  686. map.put("beds", list);
  687. return JSON.toJSONString(map);
  688. }
  689. }

教师管理控制器

  1. @Controller
  2. @RequestMapping("/teacher")
  3. public class TeacherController {
  4. @Resource
  5. private TeacherService teacherService;
  6. @RequestMapping(value = "/viewAllocationInfo")
  7. public String allocationList() {
  8. return "/teacher/allocation-list";
  9. }
  10. /**
  11. * 查询宿舍分配信息
  12. * 查询条件:专业/年级
  13. *
  14. * @param aiVo
  15. * @return
  16. */
  17. @ResponseBody
  18. @RequestMapping(value = "/allocation/list")
  19. public DataGridViewResult findAllocationInfoList(AllocationInfoVo aiVo, HttpServletRequest request) {
  20. // 获取session中的专业和年级
  21. String dept = (String) request.getSession().getAttribute("dept");
  22. String grade = (String) request.getSession().getAttribute("grade");
  23. if (StringUtils.isNotBlank(dept)) {
  24. aiVo.setStudept(dept);
  25. }
  26. if (StringUtils.isNotBlank(grade)) {
  27. aiVo.setStugrade(grade);
  28. }
  29. System.out.println(aiVo);
  30. // 设置分页信息
  31. PageHelper.startPage(aiVo.getPage(), aiVo.getLimit());
  32. // 查询
  33. List<AllocationInfo> list = teacherService.findAllocationInfoListByPage(aiVo);
  34. // 创建分页对象
  35. PageInfo<AllocationInfo> pageInfo = new PageInfo<AllocationInfo>(list);
  36. // 按接口要求返回数据
  37. DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
  38. return data;
  39. }
  40. /**
  41. * 添加宿舍分配信息
  42. *
  43. * @param ai
  44. * @return
  45. */
  46. @ResponseBody
  47. @RequestMapping(value = "/allocation/add")
  48. public String addAllocationInfo(AllocationInfo ai) {
  49. HashMap<String, Object> map = new HashMap<>();
  50. int result = teacherService.addAllocationInfo(ai);
  51. if (result > 0) {
  52. map.put("success", true);
  53. map.put("msg", "添加成功!");
  54. } else {
  55. map.put("success", false);
  56. map.put("msg", "添加失败!");
  57. }
  58. return JSON.toJSONString(map);
  59. }
  60. /**
  61. * 更改宿舍分配信息
  62. *
  63. * @param ai
  64. * @return
  65. */
  66. @ResponseBody
  67. @RequestMapping(value = "/allocation/update")
  68. public String updateAllocationInfo(AllocationInfo ai) {
  69. HashMap<String, Object> map = new HashMap<>();
  70. int result = teacherService.updateAllocationInfo(ai);
  71. if (result > 0) {
  72. map.put("success", true);
  73. map.put("msg", "更改成功!");
  74. } else {
  75. map.put("success", false);
  76. map.put("msg", "更改失败!");
  77. }
  78. return JSON.toJSONString(map);
  79. }
  80. /**
  81. * 删除宿舍分配信息
  82. *
  83. * @param stuid
  84. * @return
  85. */
  86. @ResponseBody
  87. @RequestMapping(value = "/allocation/delete")
  88. public String deleteAllocationInfo(String stuid) {
  89. HashMap<String, Object> map = new HashMap<>();
  90. int result = teacherService.deleteAllocationInfo(stuid);
  91. if (result > 0) {
  92. map.put("success", true);
  93. map.put("msg", "删除成功!");
  94. } else {
  95. map.put("success", false);
  96. map.put("msg", "删除失败!");
  97. }
  98. return JSON.toJSONString(map);
  99. }
  100. /**
  101. * 导出宿舍分配信息列表(excel格式)
  102. *
  103. * @param request 用来获取缓存中的attribute
  104. * @param response 输出文件流
  105. */
  106. @ResponseBody
  107. @RequestMapping(value = "/allocation/export.action")
  108. public void exportAllocationInfoToExcel(HttpServletRequest request, HttpServletResponse response) {
  109. HashMap<String, Object> map = new HashMap<>();
  110. response.reset();// 清除缓存
  111. String studept = (String) request.getSession().getAttribute("dept");
  112. String grade = (String) request.getSession().getAttribute("grade");
  113. System.out.println("studept" + studept);
  114. System.out.println("grade" + grade);
  115. // 查找宿舍分配信息列表
  116. List<AllocationInfo> list = teacherService.exportByDept(studept, grade);
  117. // 拼接excel表名
  118. StringBuffer filenamebuffer = new StringBuffer();
  119. if (StringUtils.isNotBlank(studept)) {
  120. filenamebuffer.append(studept);
  121. filenamebuffer.append("-");
  122. }
  123. if (StringUtils.isNotBlank(grade)) {
  124. filenamebuffer.append(grade);
  125. filenamebuffer.append("-");
  126. }
  127. filenamebuffer.append("宿舍分配表");
  128. String filename = filenamebuffer.toString();
  129. try {
  130. ExcelUtils.writeExcel(filename, response, list, AllocationInfo.class);
  131. map.put("success", true);
  132. map.put("mag", "导出成功!");
  133. } catch (Exception e) {
  134. e.printStackTrace();
  135. map.put("success", false);
  136. map.put("mag", "导出失败!");
  137. }
  138. // return JSON.toJSONString(map);
  139. }
  140. @RequestMapping(value = "/viewStudentInfo")
  141. public String studentList() {
  142. return "/teacher/student-list";
  143. }
  144. /**
  145. * 获取学生信息列表
  146. *
  147. * @param si
  148. * @param request
  149. * @return
  150. */
  151. @ResponseBody
  152. @RequestMapping(value = "/student/list")
  153. public DataGridViewResult findStudentInfoList(StudentInfoVo si, HttpServletRequest request) {
  154. // 获取教师所负责的专业和年级,年级对应学号
  155. String studept = (String) request.getSession().getAttribute("dept");
  156. String grade = (String) request.getSession().getAttribute("grade");
  157. if (StringUtils.isNotBlank(studept)) {
  158. si.setStudept(studept);
  159. }
  160. // 如果学号为空,则教师负责的年级作为学号的前缀条件
  161. if (StringUtils.isBlank(si.getStuid())) {
  162. if (StringUtils.isNotBlank(grade)) {
  163. si.setStuid(grade);
  164. }
  165. }
  166. System.out.println(si);
  167. // 设置分页信息
  168. PageHelper.startPage(si.getPage(), si.getLimit());
  169. // 查询
  170. List<StudentInfo> list = teacherService.findStudentInfoListByPage(si);
  171. // 创建分页对象
  172. PageInfo<StudentInfo> pageInfo = new PageInfo<StudentInfo>(list);
  173. // 按接口要求返回数据
  174. DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
  175. return data;
  176. }
  177. /**
  178. * 添加学生信息
  179. *
  180. * @param si
  181. * @return
  182. */
  183. @ResponseBody
  184. @RequestMapping(value = "/student/add")
  185. public String addStudentInfo(StudentInfo si) {
  186. HashMap<String, Object> map = new HashMap<>();
  187. String grade = si.getStuid().substring(0, 4);
  188. si.setStugrade(grade);
  189. System.out.println(grade);
  190. int result = teacherService.addStudentInfo(si);
  191. if (result > 0) {
  192. map.put("success", true);
  193. map.put("msg", "添加成功!");
  194. } else {
  195. map.put("success", false);
  196. map.put("msg", "添加失败!");
  197. }
  198. return JSON.toJSONString(map);
  199. }
  200. /**
  201. * 更改学生信息
  202. *
  203. * @param si
  204. * @return
  205. */
  206. @ResponseBody
  207. @RequestMapping(value = "/student/update")
  208. public String updateStudentInfo(StudentInfo si) {
  209. HashMap<String, Object> map = new HashMap<>();
  210. int result = teacherService.updateStudentInfo(si);
  211. if (result > 0) {
  212. map.put("success", true);
  213. map.put("msg", "更改成功!");
  214. } else {
  215. map.put("success", false);
  216. map.put("msg", "更改失败!");
  217. }
  218. return JSON.toJSONString(map);
  219. }
  220. /**
  221. * 删除学生信息
  222. *
  223. * @param stuid
  224. * @return
  225. */
  226. @ResponseBody
  227. @RequestMapping(value = "/student/delete")
  228. public String deleteaddStudentInfo(String stuid) {
  229. HashMap<String, Object> map = new HashMap<>();
  230. int result = teacherService.deleteStudentInfo(stuid);
  231. if (result > 0) {
  232. map.put("success", true);
  233. map.put("msg", "删除成功!");
  234. } else {
  235. map.put("success", false);
  236. map.put("msg", "删除失败!");
  237. }
  238. return JSON.toJSONString(map);
  239. }
  240. /**
  241. * 导入学生信息
  242. *
  243. * @param file excel表格
  244. * @return
  245. */
  246. @ResponseBody
  247. @RequestMapping(value = "/student/import.action")
  248. public String importExcel(@RequestParam("file") MultipartFile file) {
  249. HashMap<String, Object> map = new HashMap<>();
  250. try {
  251. List<StudentInfo> list = ExcelUtils.readExcel("", StudentInfo.class, file);
  252. for (int i = 0; i < list.size(); i++) {
  253. String grade = list.get(i).getStuid().substring(0, 4);
  254. list.get(i).setStugrade(grade);
  255. System.out.println(grade);
  256. }
  257. boolean result = teacherService.batchInsert(list);
  258. if (result) {
  259. map.put("code", 200);
  260. map.put("msg", "导入成功!");
  261. map.put("data", null);
  262. } else {
  263. map.put("code", 500);
  264. map.put("msg", "导入失败!");
  265. map.put("data", null);
  266. }
  267. } catch (Exception e) {
  268. e.printStackTrace();
  269. map.put("code", 500);
  270. map.put("msg", "导入失败,请检查文件内容是否正确。");
  271. map.put("data", null);
  272. }
  273. return JSON.toJSONString(map);
  274. }
  275. /**
  276. * 查看卫生检查情况
  277. *
  278. * @return
  279. */
  280. @RequestMapping(value = "/viewCleanInfo")
  281. public String viewCleanInfo() {
  282. return "/teacher/clean-list";
  283. }
  284. /**
  285. * 专业班级卫生检查信息
  286. *
  287. * @param ciVo
  288. * @param request
  289. * @return
  290. */
  291. @ResponseBody
  292. @RequestMapping(value = "/clean/list")
  293. public DataGridViewResult findCleanInfoListByPage(CleanInfoVo ciVo, HttpServletRequest request) {
  294. // 获取session中的专业和年级
  295. String dept = (String) request.getSession().getAttribute("dept");
  296. String grade = (String) request.getSession().getAttribute("grade");
  297. if (StringUtils.isNotBlank(dept)) {
  298. ciVo.setStudept(dept);
  299. }
  300. if (StringUtils.isNotBlank(grade)) {
  301. ciVo.setStuid(grade);
  302. }
  303. System.out.println(ciVo);
  304. // 设置分页信息
  305. PageHelper.startPage(ciVo.getPage(), ciVo.getLimit());
  306. // 查询
  307. List<CleanInfoVo> list = teacherService.findCleanInfoListByPage(ciVo);
  308. // 创建分页对象
  309. PageInfo<CleanInfoVo> pageInfo = new PageInfo<CleanInfoVo>(list);
  310. // 按接口要求返回数据
  311. DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
  312. return data;
  313. }
  314. @RequestMapping(value = "/viewLeaveInfo")
  315. public String viewLeaveInfo() {
  316. return "/teacher/leave-info";
  317. }
  318. @ResponseBody
  319. @RequestMapping(value = "/leave/list")
  320. public DataGridViewResult findLeaveInfoByPage(LeaveInfoVo liVo, HttpServletRequest request) {
  321. // 专业和年级
  322. String dept = (String) request.getSession().getAttribute("dept");
  323. String grade = (String) request.getSession().getAttribute("grade");
  324. if (StringUtils.isNotBlank(dept)) {
  325. liVo.setStudept(dept);
  326. }
  327. if (StringUtils.isNotBlank(grade)) {
  328. liVo.setStugrade(grade);
  329. }
  330. System.out.println(liVo);
  331. // 设置分页信息
  332. PageHelper.startPage(liVo.getPage(), liVo.getLimit());
  333. // 查询
  334. List<LeaveInfo> list = teacherService.findLeaveInfoListByPage(liVo);
  335. // 创建分页对象
  336. PageInfo<LeaveInfo> pageInfo = new PageInfo<LeaveInfo>(list);
  337. // 按接口要求返回数据
  338. DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
  339. return data;
  340. }
  341. @ResponseBody
  342. @RequestMapping(value = "/leave/delete")
  343. public String batchDeleteLeaveInfo(HttpServletRequest request) {
  344. HashMap<String, Object> map = new HashMap<>();
  345. String params = request.getParameter("params");
  346. try {
  347. if (StringUtils.isBlank(params)) {
  348. map.put("success", false);
  349. map.put("msg", "请选择要删除的行!");
  350. return JSON.toJSONString(map);
  351. }
  352. boolean result = teacherService.batchDeleteLeaveInfo(params);
  353. if (result) {
  354. map.put("success", true);
  355. map.put("msg", "删除成功!");
  356. } else {
  357. map.put("success", false);
  358. map.put("msg", "系统错误,请稍后再试!");
  359. }
  360. } catch (Exception e) {
  361. e.printStackTrace();
  362. map.put("success", false);
  363. map.put("msg", "系统错误,请稍后再试!");
  364. }
  365. return JSON.toJSONString(map);
  366. }
  367. /**
  368. * 将学生去向信息导出到Excel中
  369. *
  370. * @param request
  371. * @param response
  372. */
  373. @ResponseBody
  374. @RequestMapping(value = "/leave/export.action")
  375. public void exportLeaveInfoToExcel(HttpServletRequest request, HttpServletResponse response) {
  376. response.reset();// 清除缓存
  377. String studept = (String) request.getSession().getAttribute("dept");
  378. String stugrade = (String) request.getSession().getAttribute("grade");
  379. // 查找学生登记信息
  380. List<LeaveInfo> list = teacherService.exportLeaveInfo(studept, stugrade);
  381. // 拼接excel表名
  382. StringBuffer filenamebuffer = new StringBuffer();
  383. if (StringUtils.isNotBlank(studept)) {
  384. filenamebuffer.append(studept);
  385. filenamebuffer.append("-");
  386. }
  387. if (StringUtils.isNotBlank(stugrade)) {
  388. filenamebuffer.append(stugrade);
  389. filenamebuffer.append("级-");
  390. }
  391. filenamebuffer.append("节假日去向表");
  392. String filename = filenamebuffer.toString();
  393. try {
  394. ExcelUtils.writeExcel(filename, response, list, LeaveInfo.class);
  395. } catch (Exception e) {
  396. e.printStackTrace();
  397. }
  398. }
  399. /**
  400. * 获取饼状图的数据
  401. *
  402. * @return
  403. */
  404. @ResponseBody
  405. @RequestMapping(value = "/leave/echartsData")
  406. public String getLeaveInfoEchartsData(HttpServletRequest request) {
  407. String studept = (String) request.getSession().getAttribute("dept");
  408. String stugrade = (String) request.getSession().getAttribute("grade");
  409. HashMap<String, Object> map = teacherService.getLeaveInfoEchartsData(studept, stugrade);
  410. String result = JSON.toJSONString(map);
  411. System.out.println(result);
  412. return result;
  413. }
  414. /**
  415. * 留校管理
  416. *
  417. * @return
  418. */
  419. @RequestMapping(value = "/stayinManage")
  420. public String stayinManege() {
  421. return "/teacher/stayin-manage";
  422. }
  423. /**
  424. * 留校申请列表
  425. *
  426. * @param siVo
  427. * @param request
  428. * @return
  429. */
  430. @ResponseBody
  431. @RequestMapping(value = "/stayin/list")
  432. public DataGridViewResult findStayInfoListByPage(StayInfoVo siVo, HttpServletRequest request) {
  433. String studept = (String) request.getSession().getAttribute("dept");
  434. String stugrade = (String) request.getSession().getAttribute("grade");
  435. if (StringUtils.isNotBlank(studept)) {
  436. siVo.setStudept(studept);
  437. }
  438. if (StringUtils.isNotBlank(stugrade)) {
  439. siVo.setStugrade(stugrade);
  440. }
  441. System.out.println(siVo);
  442. // 设置分页信息
  443. PageHelper.startPage(siVo.getPage(), siVo.getLimit());
  444. // 查询
  445. List<StayInfo> list = teacherService.findStayInfoListByPage(siVo);
  446. // 创建分页对象
  447. PageInfo<StayInfo> pageInfo = new PageInfo<StayInfo>(list);
  448. // 按接口要求返回数据
  449. DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
  450. return data;
  451. }
  452. /**
  453. * 审批学生留校申请
  454. *
  455. * @param si
  456. * @return
  457. */
  458. @ResponseBody
  459. @RequestMapping(value = "/stayin/approve")
  460. public String approveStayInfo(StayInfo si) {
  461. HashMap<String, Object> map = new HashMap<>();
  462. System.out.println(si);
  463. int result = teacherService.approveStayInfo(si);
  464. if (result > 0) {
  465. map.put("success", true);
  466. map.put("msg", "审批成功");
  467. } else {
  468. map.put("success", false);
  469. map.put("msg", "审批失败,请稍后再试!");
  470. }
  471. return JSON.toJSONString(map);
  472. }
  473. /**
  474. * 导出学生留校申请信息
  475. *
  476. * @param request
  477. * @param response
  478. */
  479. @ResponseBody
  480. @RequestMapping(value = "/stayin/export.action")
  481. public void exportStayInfoToExcel(HttpServletRequest request, HttpServletResponse response) {
  482. response.reset();// 清除缓存
  483. String studept = (String) request.getSession().getAttribute("dept");
  484. String stugrade = (String) request.getSession().getAttribute("grade");
  485. // 查找学生登记信息
  486. List<StayInfo> list = teacherService.exportStayInfo(studept, stugrade);
  487. // 拼接excel表名
  488. StringBuffer filenamebuffer = new StringBuffer();
  489. if (StringUtils.isNotBlank(studept)) {
  490. filenamebuffer.append(studept);
  491. filenamebuffer.append("-");
  492. }
  493. if (StringUtils.isNotBlank(stugrade)) {
  494. filenamebuffer.append(stugrade);
  495. filenamebuffer.append("级-");
  496. }
  497. filenamebuffer.append("留校申请表");
  498. String filename = filenamebuffer.toString();
  499. try {
  500. ExcelUtils.writeExcel(filename, response, list, StayInfo.class);
  501. } catch (Exception e) {
  502. e.printStackTrace();
  503. }
  504. }
  505. /**
  506. * 获取留校申请中的统计数据
  507. *
  508. * @param request
  509. * @return
  510. */
  511. @ResponseBody
  512. @RequestMapping(value = "/stayin/echartsData")
  513. public String getStayInfoEchartsData(HttpServletRequest request) {
  514. String studept = (String) request.getSession().getAttribute("dept");
  515. String stugrade = (String) request.getSession().getAttribute("grade");
  516. JSONObject data = teacherService.getStayInfoEchartsData(studept, stugrade);
  517. System.out.println(JSON.toJSONString(data));
  518. return JSON.toJSONString(data);
  519. }
  520. @RequestMapping(value = "/backManage")
  521. public String backManage() {
  522. return "/teacher/back-manage";
  523. }
  524. /**
  525. * 查找学生返校信息
  526. *
  527. * @param bsVo
  528. * @param request
  529. * @return
  530. */
  531. @ResponseBody
  532. @RequestMapping(value = "/back/list")
  533. public DataGridViewResult findBackToScInfoListByPage(BackToScInfoVo bsVo, HttpServletRequest request) {
  534. String studept = (String) request.getSession().getAttribute("dept");
  535. String stugrade = (String) request.getSession().getAttribute("grade");
  536. if (StringUtils.isNotBlank(studept)) {
  537. bsVo.setStudept(studept);
  538. }
  539. if (StringUtils.isNotBlank(stugrade)) {
  540. bsVo.setStugrade(stugrade);
  541. }
  542. System.out.println(bsVo);
  543. // 设置分页信息
  544. PageHelper.startPage(bsVo.getPage(), bsVo.getLimit());
  545. // 查询
  546. List<BackToScInfo> list = teacherService.findBackToScInfoListByPage(bsVo);
  547. // 创建分页对象
  548. PageInfo<BackToScInfo> pageInfo = new PageInfo<BackToScInfo>(list);
  549. // 按接口要求返回数据
  550. DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
  551. return data;
  552. }
  553. /**
  554. * 导出学生返校登记信息
  555. *
  556. * @param request
  557. * @param response
  558. */
  559. @ResponseBody
  560. @RequestMapping(value = "/back/export.action")
  561. public void exportBackToScInfoToExcel(HttpServletRequest request, HttpServletResponse response) {
  562. response.reset();// 清除缓存
  563. String studept = (String) request.getSession().getAttribute("dept");
  564. String stugrade = (String) request.getSession().getAttribute("grade");
  565. // 查找学生登记信息
  566. List<BackToScInfo> list = teacherService.exportBackToScInfo(studept, stugrade);
  567. // 拼接excel表名
  568. StringBuffer filenamebuffer = new StringBuffer();
  569. if (StringUtils.isNotBlank(studept)) {
  570. filenamebuffer.append(studept);
  571. filenamebuffer.append("-");
  572. }
  573. if (StringUtils.isNotBlank(stugrade)) {
  574. filenamebuffer.append(stugrade);
  575. filenamebuffer.append("级-");
  576. }
  577. filenamebuffer.append("返校登记表");
  578. String filename = filenamebuffer.toString();
  579. try {
  580. ExcelUtils.writeExcel(filename, response, list, BackToScInfo.class);
  581. } catch (Exception e) {
  582. e.printStackTrace();
  583. }
  584. }
  585. /**
  586. * 获取返校登记的统计数据
  587. *
  588. * @param request
  589. * @return
  590. */
  591. @ResponseBody
  592. @RequestMapping(value = "/back/echartsData")
  593. public String getBackToScInfoEchartsData(HttpServletRequest request) {
  594. String studept = (String) request.getSession().getAttribute("dept");
  595. String stugrade = (String) request.getSession().getAttribute("grade");
  596. JSONObject data = teacherService.getBackToScInfoEchartsData(studept, stugrade);
  597. System.out.println(JSON.toJSONString(data));
  598. return JSON.toJSONString(data);
  599. }
  600. /**
  601. * 查看基本信息(老师/宿管员)
  602. *
  603. * @param request
  604. * @return
  605. */
  606. @ResponseBody
  607. @RequestMapping(value = "/basic/info")
  608. public String viewStudentInfo(HttpServletRequest request) {
  609. HashMap<String, Object> map = new HashMap<>();
  610. String uid = (String) request.getSession().getAttribute("uid");
  611. if (StringUtils.isNotBlank(uid)) {
  612. Users users = teacherService.findUsersByUid(uid);
  613. if (users != null) {
  614. map.put("success", true);
  615. map.put("data", users);
  616. } else {
  617. map.put("success", false);
  618. map.put("msg", "系统错误:不存在该用户!");
  619. }
  620. }
  621. return JSON.toJSONString(map);
  622. }
  623. /**
  624. * 更改基本信息
  625. *
  626. * @param users
  627. * @return
  628. */
  629. @ResponseBody
  630. @RequestMapping(value = "/basic/update")
  631. public String updateUsers(Users users) {
  632. HashMap<String, Object> map = new HashMap<>();
  633. System.out.println(users);
  634. int result = teacherService.updateUsers(users);
  635. if (result > 0) {
  636. map.put("success", true);
  637. map.put("msg", "保存成功!");
  638. } else {
  639. map.put("success", false);
  640. map.put("msg", "保存失败!");
  641. }
  642. return JSON.toJSONString(map);
  643. }
  644. }

八、如果也想学习本系统,下面领取。关注并回复:095springboot

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/598764
推荐阅读
相关标签
  

闽ICP备14008679号