本文主要是介绍Java项目:30 基于SpringBoot自习室座位预定系统,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
作者主页:舒克日记
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文中获取源码
项目介绍
功能设计
管理员
1、用户管理
管理员可以新增、删除管理员
管理员可以删除学生
2、自习室管理
管理员可以新增自习室、设置自习室的座位数量、开放时间,对自习室进行管理
管理员可以管理学生的预订情况、可以强制退订
3、学院班级管理
管理员可以新增、修改、删除学院、班级(实际上这部分数据应该来源于教务系统)
4、个人管理
管理员可以对自己信息进行修改
学生
1、自习室管理
学生可以查看自习室座位的预定情况并进行预定
学生可以查看自己的预定情况,并退订
2、个人信息管理
学生可以修改自己的用户信息
点击查看演示视频
环境要求
1.运行环境:最好是java jdk1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat7.x,8.X,9.x版本均可
4.硬件环境:windows7/8/10 4G内存以上;或者Mac OS;
5.是否Maven项目:是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven.项目
6.数据库:MySql5.7/8.0等版本均可;
技术栈
-
MySQL5.7
-
Idea2020.3
-
SpringBoot、Mybatis-plus、thymeleaf
-
layui、jquery、xadmin
使用说明
1.使用Navicati或者其它工具,在mysql中创建对应sq文件名称的数据库,并导入项目的sql文件;
2.使用IDEA/Eclipse/MyEclipse导入项目,修改配置,运行项目;
3.将项目中config-propertiesi配置文件中的数据库配置改为自己的配置,然后运行;
运行指导
idea导入源码空间站顶目教程说明(Vindows版)-ssm篇:
http://mtw.so/5MHvZq
源码地址:http://codegym.top
运行截图
前端界面
登录/注册页面
管理员界面
学生界面
代码
SeatServiceImpl
package com.cxs.service.impl;import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cxs.dto.ReservationSeatDTO;
import com.cxs.enums.ReservationMarkEnums;
import com.cxs.mapper.ClassroomMapper;
import com.cxs.mapper.ClazzMapper;
import com.cxs.mapper.SeatOrderMapper;
import com.cxs.mapper.StudentMapper;
import com.cxs.model.Classroom;
import com.cxs.model.Seat;
import com.cxs.model.SeatOrder;
import com.cxs.model.Student;
import com.cxs.service.SeatService;
import com.cxs.mapper.SeatMapper;
import com.cxs.sourceBo.ClazzBo;
import com.cxs.sourceBo.SeatBo;
import com.cxs.sourceBo.SeatOrderBo;
import com.cxs.vo.ReservationMarkVO;
import com.cxs.vo.Result;
import com.cxs.vo.SeatOrderDetailVO;
import com.cxs.vo.SeatOrderInfoVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;import java.lang.annotation.ElementType;
import java.time.DayOfWeek;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;/**
* @author DELL
* @description 针对表【t_seat(座位表)】的数据库操作Service实现
* @createDate 2023-11-28 10:44:22
*/
@Service
public class SeatServiceImpl extends ServiceImpl<SeatMapper, Seat>implements SeatService{@Autowiredprivate SeatMapper seatMapper;@Autowiredprivate ClassroomMapper classroomMapper;@Autowiredprivate SeatOrderMapper seatOrderMapper;@Autowiredprivate StudentMapper studentMapper;@Autowiredprivate ClazzMapper clazzMapper;@Overridepublic List<SeatOrderInfoVO> getSeatListInfo(Integer id, LocalDate date) {List<SeatOrderInfoVO> childList = new ArrayList<>();SeatBo bo = seatMapper.selectOrderInfoBySeatId(id, date);if (null == bo) {Seat seat = seatMapper.selectById(id);bo = new SeatBo();BeanUtils.copyProperties(seat, bo);}Classroom classroom = classroomMapper.selectById(bo.getClassroomId());int start = classroom.getOpenTimeStart().getHour();int end = classroom.getOpenTimeEnd().getHour();List<SeatOrder> orderList = bo.getOrderList();Map<String,SeatOrder> orderMap = CollectionUtils.isEmpty(orderList) ? new HashMap<>() : orderList.stream().collect(Collectors.toMap(SeatOrder::getReservationMark, Function.identity(), (o1, o2) -> o1));List<ReservationMarkVO> reservationMarkVOList = ReservationMarkEnums.getReservationMarkVOList(start, end);for (ReservationMarkVO reservationMarkVO : reservationMarkVOList) {SeatOrderInfoVO v = new SeatOrderInfoVO();v.setSeatId(bo.getId());v.setReservationMark(reservationMarkVO.getMark());v.setTimeRange(reservationMarkVO.getTimeRange());v.setSno(bo.getSeatNo());SeatOrder seatOrder = orderMap.get(reservationMarkVO.getMark());if (null != seatOrder) {v.setCreateTime(seatOrder.getCreateTime());v.setFlag(Boolean.TRUE);v.setId(seatOrder.getId());} else {v.setFlag(Boolean.FALSE);}childList.add(v);}return childList;}@Overridepublic void getSeatOrderInfo(Integer id, Result r) {if (null == id) {r.setCode(-1);r.setMsg("id不能为空");return;}SeatOrder seatOrder = seatOrderMapper.selectById(id);if (null == seatOrder) {r.setCode(-1);r.setMsg("预定不存在");return;}Seat seat = seatMapper.selectById(seatOrder.getSeatId());if (null == seat) {r.setCode(-1);r.setMsg("座位不存在");return;}Classroom classroom = classroomMapper.selectById(seat.getClassroomId());if (null == classroom) {r.setCode(-1);r.setMsg("自习室不存在");return;}Student student = studentMapper.selectById(seatOrder.getSno());ClazzBo info = clazzMapper.getClazzInfoByClazzId(student.getClazzId());List<ReservationMarkVO> reservationMarkVOList = ReservationMarkEnums.getReservationMarkVOList(classroom.getOpenTimeStart().getHour(), classroom.getOpenTimeEnd().getHour());Map<String, ReservationMarkVO> map = CollectionUtils.isEmpty(reservationMarkVOList) ? new HashMap<>() : reservationMarkVOList.stream().collect(Collectors.toMap(ReservationMarkVO::getMark, Function.identity(), (o1, o2) -> o1));SeatOrderDetailVO vo = new SeatOrderDetailVO();BeanUtils.copyProperties(seatOrder, vo);vo.setName(student.getName());vo.setPhone(student.getPhone());vo.setSex(student.getSex());ReservationMarkVO reservationMarkVO = map.get(seatOrder.getReservationMark());if (null != reservationMarkVO) {vo.setTimeRange(reservationMarkVO.getTimeRange());}vo.setCollageName(info.getGradeName());vo.setClazzName(info.getClazzName());r.setData(vo);}@Overridepublic void reservationSeat(ReservationSeatDTO dto, Integer sno, Result r) {LocalDate date = dto.getDate();LocalDate now = LocalDate.now();if (date.isBefore(now)) {r.setCode(-1);r.setMsg("该时间不可预约座位");return;}if (Duration.between(LocalDateTime.of(now, LocalTime.MIN), LocalDateTime.of(date, LocalTime.MIN)).toDays() > 7L) {r.setCode(-1);r.setMsg("仅支持预定一周内的座位");return;}LambdaQueryWrapper<SeatOrder> queryWrapper = new LambdaQueryWrapper<>();queryWrapper.eq(SeatOrder::getReservationMark, dto.getMark()).eq(SeatOrder::getDate, dto.getDate()).eq(SeatOrder::getSno, sno);List<SeatOrder> seatOrders = seatOrderMapper.selectList(queryWrapper);if (!CollectionUtils.isEmpty(seatOrders)) {r.setCode(-1);r.setMsg("预定失败,该时间段内您已进行预定座位,请按时去学习,把座位留给需要的同学,谢谢!");return;}Seat seat = seatMapper.selectById(dto.getSeatId());if (null == seat) {r.setCode(-1);r.setMsg("座位不存在");return;}Classroom classroom = classroomMapper.selectById(seat.getClassroomId());if (null == classroom) {r.setCode(-1);r.setMsg("自习室不存在");return;}Integer openType = classroom.getOpenType();// 0每天开放,1工作日开放2休息日开放DayOfWeek dayOfWeek = date.getDayOfWeek();if (openType == 0) {} else if (openType == 1) {if (dayOfWeek.equals(DayOfWeek.SATURDAY) || dayOfWeek.equals(DayOfWeek.SUNDAY)) {r.setCode(-1);r.setMsg(classroom.getName() + "自习室" + "仅工作日可定");return;}} else if (openType == 2) {if (!dayOfWeek.equals(DayOfWeek.SATURDAY) && !dayOfWeek.equals(DayOfWeek.SUNDAY)) {r.setCode(-1);r.setMsg(classroom.getName() + "自习室" + "仅休息日可定");return;}} else {r.setCode(-1);r.setMsg("自习室开放时间有误");return;}List<ReservationMarkVO> reservationMarkVOList = ReservationMarkEnums.getReservationMarkVOList(classroom.getOpenTimeStart().getHour(), classroom.getOpenTimeEnd().getHour());Map<String, ReservationMarkVO> map = CollectionUtils.isEmpty(reservationMarkVOList) ? new HashMap<>() : reservationMarkVOList.stream().collect(Collectors.toMap(ReservationMarkVO::getMark, Function.identity(), (o1, o2) -> o1));SeatOrder order = new SeatOrder();order.setSeatId(dto.getSeatId());order.setCreateTime(LocalDateTime.now());order.setDate(dto.getDate());ReservationMarkVO reservationMarkVO = map.get(dto.getMark());if (reservationMarkVO == null) {r.setCode(-1);r.setMsg("预约时间有误");return;}int hour = LocalDateTime.now().getHour();if (date.equals(now)) {if (reservationMarkVO.getStartTime() < hour) {r.setCode(-1);r.setMsg("当前时间不可预订,请选择其他时间预定");return;}}order.setReservationMark(dto.getMark());order.setStartTime(reservationMarkVO.getStartTime());order.setEndTime(reservationMarkVO.getEndTime());order.setSno(sno);int insert = seatOrderMapper.insert(order);if (insert != 1) {r.setCode(-1);r.setMsg("预约失败");return;}}
}
这篇关于Java项目:30 基于SpringBoot自习室座位预定系统的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!