package com.example.springboot.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.springboot.common.JudgeBedName;
import com.example.springboot.entity.AdjustRoom;
import com.example.springboot.entity.DormRoom;
import com.example.springboot.mapper.DormRoomMapper;
import com.example.springboot.service.DormRoomService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import static com.example.springboot.common.CalPeopleNum.calNum;
@Service
public class DormRoomImpl extends ServiceImpl<DormRoomMapper, DormRoom> implements DormRoomService {
@Resource
private DormRoomMapper dormRoomMapper;
/**
* 首页顶部:空宿舍统计
*/
@Override
public int notFullRoom() {
QueryWrapper<DormRoom> qw = new QueryWrapper<>();
qw.lt("current_capacity", 4);
int notFullRoomNum = Math.toIntExact(dormRoomMapper.selectCount(qw));
return notFullRoomNum;
}
/**
* 添加房间
*/
@Override
public int addNewRoom(DormRoom dormRoom) {
int insert = dormRoomMapper.insert(dormRoom);
return insert;
}
/**
* 查找房间
*/
@Override
public Page find(Integer pageNum, Integer pageSize, String search) {
Page page = new Page<>(pageNum, pageSize);
QueryWrapper<DormRoom> qw = new QueryWrapper<>();
qw.like("Dormroom_id", search);
Page roomPage = dormRoomMapper.selectPage(page, qw);
return roomPage;
}
/**
* 更新房间
*/
@Override
public int updateNewRoom(DormRoom dormRoom) {
int i = dormRoomMapper.updateById(dormRoom);
return i;
}
/**
* 删除房间
*/
@Override
public int deleteRoom(Integer dormRoomId) {
int i = dormRoomMapper.deleteById(dormRoomId);
return i;
}
/**
* 删除床位上的学生信息
*/
@Override
public int deleteBedInfo(String bedName, Integer dormRoomId, int calCurrentNum) {
UpdateWrapper updateWrapper = new UpdateWrapper();
updateWrapper.eq("dormroom_id", dormRoomId);
updateWrapper.set(bedName, null);
updateWrapper.set("current_capacity", calCurrentNum - 1);
int update = dormRoomMapper.update(null, updateWrapper);
return update;
}
/**
* 床位信息,查询该学生是否已由床位
*/
@Override
public DormRoom judgeHadBed(String username) {
QueryWrapper qw = new QueryWrapper();
qw.eq("first_bed", username);
qw.or();
qw.eq("second_bed", username);
qw.or();
qw.eq("third_bed", username);
qw.or();
qw.eq("fourth_bed", username);
DormRoom dormRoom = dormRoomMapper.selectOne(qw);
return dormRoom;
}
/**
* 主页 住宿人数
*/
@Override
public Long selectHaveRoomStuNum() {
QueryWrapper<DormRoom> qw1 = new QueryWrapper<>();
qw1.isNotNull("first_bed");
Long first_bed = dormRoomMapper.selectCount(qw1);
QueryWrapper<DormRoom> qw2 = new QueryWrapper<>();
qw2.isNotNull("second_bed");
Long second_bed = dormRoomMapper.selectCount(qw2);
QueryWrapper<DormRoom> qw3 = new QueryWrapper<>();
qw3.isNotNull("third_bed");
Long third_bed = dormRoomMapper.selectCount(qw3);
QueryWrapper<DormRoom> qw4 = new QueryWrapper<>();
qw4.isNotNull("fourth_bed");
Long fourth_bed = dormRoomMapper.selectCount(qw4);
Long count = first_bed + second_bed + third_bed + fourth_bed;
return count;
}
/**
* 获取每栋宿舍学生总人数
*/
@Override
public Long getEachBuildingStuNum(int dormBuildId) {
QueryWrapper<DormRoom> qw1 = new QueryWrapper<>();
qw1.eq("dormbuild_id", dormBuildId);
qw1.isNotNull("first_bed");
Long first_bed = dormRoomMapper.selectCount(qw1);
QueryWrapper<DormRoom> qw2 = new QueryWrapper<>();
qw2.eq("dormbuild_id", dormBuildId);
qw2.isNotNull("second_bed");
Long second_bed = dormRoomMapper.selectCount(qw2);
QueryWrapper<DormRoom> qw3 = new QueryWrapper<>();
qw3.eq("dormbuild_id", dormBuildId);
qw3.isNotNull("third_bed");
Long third_bed = dormRoomMapper.selectCount(qw3);
QueryWrapper<DormRoom> qw4 = new QueryWrapper<>();
qw4.eq("dormbuild_id", dormBuildId);
qw4.isNotNull("fourth_bed");
Long fourth_bed = dormRoomMapper.selectCount(qw4);
Long count = first_bed + second_bed + third_bed + fourth_bed;
return count;
}
/**
* 根据调宿申请表对房间表内的学生床位进行调整
*/
@Override
public int adjustRoomUpdate(AdjustRoom adjustRoom) {
//调宿人
String username = adjustRoom.getUsername();
//当前房间号
int currentRoomId = adjustRoom.getCurrentRoomId();
//当前床位名称
String currentBedName = JudgeBedName.getBedName(adjustRoom.getCurrentBedId());
//目标房间号
int towardsRoomId = adjustRoom.getTowardsRoomId();
//目标目标房间号
String towardsBedName = JudgeBedName.getBedName(adjustRoom.getTowardsBedId());
QueryWrapper qw = new QueryWrapper();
qw.eq("dormroom_id", currentRoomId);
qw.isNotNull(currentBedName);
DormRoom dormRoom1 = dormRoomMapper.selectOne(qw);
if (dormRoom1 == null) {
return -2;
}
int currentCapacity1 = calNum(dormRoom1);
UpdateWrapper uw1 = new UpdateWrapper();
uw1.eq("dormroom_id", currentRoomId);
uw1.set(currentBedName, null);
uw1.set("current_capacity", currentCapacity1 - 1);
int result1 = dormRoomMapper.update(null, uw1);
DormRoom dormRoom2 = dormRoomMapper.selectById(towardsRoomId);
int currentCapacity2 = calNum(dormRoom2);
if (result1 == 1) {
UpdateWrapper uw2 = new UpdateWrapper();
uw2.eq("dormroom_id", towardsRoomId);
uw2.set(towardsBedName, username);
uw2.set("current_capacity", currentCapacity2 + 1);
int result2 = dormRoomMapper.update(null, uw2);
return result2;
}
return -1;
}
/**
* 检查该房间是否满了
*/
@Override
public DormRoom checkRoomState(Integer dormRoomId) {
QueryWrapper qw = new QueryWrapper();
qw.eq("dormroom_id", dormRoomId);
qw.lt("current_capacity", 4);
DormRoom dormRoom = dormRoomMapper.selectOne(qw);
return dormRoom;
}
/**
* 检查该房间是否存在
*/
@Override
public DormRoom checkRoomExist(Integer dormRoomId) {
DormRoom dormRoom = dormRoomMapper.selectById(dormRoomId);
return dormRoom;
}
/**
* 检查床位是否有人
*/
@Override
public DormRoom checkBedState(Integer dormRoomId, int bedNum) {
QueryWrapper qw = new QueryWrapper();
qw.eq("dormroom_id", dormRoomId);
qw.isNull(JudgeBedName.getBedName(bedNum));
DormRoom dormRoom = dormRoomMapper.selectOne(qw);
return dormRoom;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
毕业设计-高校宿舍管理系统(springboot,vue)
共433个文件
xml:192个
java:112个
vue:44个
需积分: 1 1 下载量 170 浏览量
2023-02-08
23:43:32
上传
评论 1
收藏 2.36MB ZIP 举报
温馨提示
毕业设计 高校宿舍管理系统 毕业设计 高校宿舍管理系统 本系统功能包括:权限管理,菜单管理,项目运行宿舍管理,学生管理,班级管理,宿舍楼管理,各项记录(归寝记录,维修记录,请假记录,晚归记录),各项系统管理(用户管理,角色管理,菜单管理)等功能 #### 软件架构 1. 前端:Vue3、Element-Plus、Axios、ECharts、wangEditor 2. 后端:SpringBoot、Mybatis-Plus #### 安装教程 1. 选择进入demo项目 2. cd vue 3. npm install
资源推荐
资源详情
资源评论
收起资源包目录
毕业设计-高校宿舍管理系统(springboot,vue) (433个子文件)
Home.css 1KB
Home.css 1KB
SelfInfo.css 617B
SelfInfo.css 617B
RoomInfo.css 492B
RoomInfo.css 492B
Login.css 203B
Login.css 203B
global.css 183B
global.css 183B
MyRoomInfo.css 58B
MyRoomInfo.css 58B
.gitignore 395B
.gitignore 395B
.gitignore 278B
.gitignore 278B
.gitignore 246B
.gitignore 246B
index.html 593B
index.html 593B
favicon.ico 4KB
favicon.ico 4KB
demo.iml 336B
demo.iml 336B
DormRoomImpl.java 7KB
DormRoomImpl.java 7KB
DormRoomController.java 6KB
DormRoomController.java 6KB
FileController.java 5KB
FileController.java 5KB
StudentController.java 3KB
StudentController.java 3KB
RepairController.java 3KB
RepairController.java 3KB
DormManagerController.java 3KB
DormManagerController.java 3KB
DormBuildController.java 3KB
DormBuildController.java 3KB
StudentServiceImpl.java 3KB
StudentServiceImpl.java 3KB
AdjustRoomController.java 2KB
AdjustRoomController.java 2KB
NoticeController.java 2KB
NoticeController.java 2KB
RepairServiceImpl.java 2KB
RepairServiceImpl.java 2KB
DormManagerServiceImpl.java 2KB
DormManagerServiceImpl.java 2KB
VisitorController.java 2KB
VisitorController.java 2KB
DormBuildImpl.java 2KB
DormBuildImpl.java 2KB
NoticeServiceImpl.java 2KB
NoticeServiceImpl.java 2KB
AdjustRoomServiceImpl.java 2KB
AdjustRoomServiceImpl.java 2KB
VisitorServiceImpl.java 2KB
VisitorServiceImpl.java 2KB
AdminController.java 1KB
AdminController.java 1KB
DormRoomService.java 1KB
DormRoomService.java 1KB
MainController.java 1KB
MainController.java 1KB
AdminServiceImpl.java 1KB
AdminServiceImpl.java 1KB
CorsConfig.java 1016B
CorsConfig.java 1016B
AdjustRoom.java 1015B
AdjustRoom.java 1015B
DormRoom.java 969B
DormRoom.java 969B
Student.java 958B
Student.java 958B
Repair.java 937B
Repair.java 937B
DormManager.java 907B
DormManager.java 907B
Result.java 906B
Result.java 906B
MyBatisPlusConfig.java 898B
MyBatisPlusConfig.java 898B
Admin.java 890B
Admin.java 890B
Visitor.java 877B
Visitor.java 877B
StudentService.java 761B
StudentService.java 761B
Notice.java 753B
Notice.java 753B
DormBuild.java 740B
DormBuild.java 740B
RepairService.java 687B
RepairService.java 687B
DormManagerService.java 686B
DormManagerService.java 686B
DormBuildService.java 632B
DormBuildService.java 632B
NoticeService.java 613B
NoticeService.java 613B
共 433 条
- 1
- 2
- 3
- 4
- 5
资源评论
资料小助手
- 粉丝: 277
- 资源: 49
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 暴风电视 50X4 ECHO 屏V500DJ6-QE1(T4) 机编60000AM7902 屏参30173301 V1.0.35
- 《Java语言编程基础立体化实用教程》1-5+学生成绩删除功能.ppt
- WinQSB 64位 v3.5正式版
- 《AI硬件与Pyhthon编程实践》04基于计算机视觉的物体形状检测写字字帖.ppt
- 利用逻辑门verlog 和嵌入式C语言开发课题
- 仿传奇MA游戏官网社区Discuz模板
- 《AI硬件与Pyhthon编程实践》03计算机视觉与颜色追踪写字字帖.ppt
- 12121212ewqewqeqwe
- VSCodeUserSetup-x64-1.75.1.exe.zip
- 《MySQL+8.0数据库管理与应用》第2章+数据库与表.ppt
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功