|
@@ -1,19 +1,30 @@
|
|
|
package com.xjrsoft.module.room.service.impl;
|
|
|
|
|
|
+import cn.dev33.satoken.stp.StpUtil;
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
import com.xjrsoft.module.room.dto.DistributeClassPageDto;
|
|
|
+import com.xjrsoft.module.room.dto.DistributeRoomBedDto;
|
|
|
import com.xjrsoft.module.room.dto.DistributeRoomBedPageDto;
|
|
|
import com.xjrsoft.module.room.dto.RoomBedPageDto;
|
|
|
+import com.xjrsoft.module.room.entity.Room;
|
|
|
import com.xjrsoft.module.room.entity.RoomBed;
|
|
|
import com.xjrsoft.module.room.mapper.RoomBedMapper;
|
|
|
+import com.xjrsoft.module.room.mapper.RoomMapper;
|
|
|
import com.xjrsoft.module.room.service.IRoomBedService;
|
|
|
import com.xjrsoft.module.room.vo.DistributeClassPageVo;
|
|
|
import com.xjrsoft.module.room.vo.DistributeRoomBedPageVo;
|
|
|
import com.xjrsoft.module.room.vo.RoomBedPageVo;
|
|
|
+import com.xjrsoft.module.room.vo.RoomBedVo;
|
|
|
+import com.xjrsoft.module.room.vo.RoomClassCountVo;
|
|
|
+import com.xjrsoft.module.student.dto.DistributeStudentDto;
|
|
|
+import com.xjrsoft.module.student.mapper.BaseStudentMapper;
|
|
|
+import com.xjrsoft.module.student.vo.StudentInfoVo;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -25,7 +36,9 @@ import java.util.List;
|
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
|
public class RoomBedServiceImpl extends MPJBaseServiceImpl<RoomBedMapper, RoomBed> implements IRoomBedService {
|
|
|
+ private final RoomMapper roomMapper;
|
|
|
private final RoomBedMapper roomBedMapper;
|
|
|
+ private final BaseStudentMapper baseStudentMapper;
|
|
|
@Override
|
|
|
public Page<RoomBedPageVo> getPage(Page<RoomBedPageVo> page, RoomBedPageDto dto) {
|
|
|
Page<RoomBedPageVo> result = roomBedMapper.getPage(page, dto);
|
|
@@ -51,4 +64,51 @@ public class RoomBedServiceImpl extends MPJBaseServiceImpl<RoomBedMapper, RoomBe
|
|
|
public Page<DistributeRoomBedPageVo> getDistributeRoomBedInfo(Page<DistributeRoomBedPageVo> page, DistributeRoomBedPageDto dto) {
|
|
|
return roomBedMapper.getDistributeRoomBedInfo(page, dto);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean distributeRoomBed(DistributeRoomBedDto dto) {
|
|
|
+ //查询出所有床位信息
|
|
|
+ List<RoomBedVo> bedInfoList = roomBedMapper.getBedInfo(dto.getRoomIds());
|
|
|
+
|
|
|
+ Room room = roomMapper.selectById(dto.getRoomIds().get(0));
|
|
|
+ String gender = room.getGender();
|
|
|
+ Integer genderNumber = null;
|
|
|
+ if("SB10001".equals(gender)){
|
|
|
+ genderNumber = 1;
|
|
|
+ }else if("SB10002".equals(gender)){
|
|
|
+ genderNumber = 2;
|
|
|
+ }
|
|
|
+
|
|
|
+ Date modifyDate = new Date();
|
|
|
+ Long modifyUserId = StpUtil.getLoginIdAsLong();
|
|
|
+
|
|
|
+ //查询每个班的学生,修改床位信息
|
|
|
+ int i = 0;
|
|
|
+ for (Long classId : dto.getClassIds()) {
|
|
|
+ DistributeStudentDto classDto = new DistributeStudentDto();
|
|
|
+ classDto.setClassId(classId);
|
|
|
+ classDto.setGender(genderNumber);
|
|
|
+ List<StudentInfoVo> studentList = baseStudentMapper.getClassStudent(classDto);
|
|
|
+ for (StudentInfoVo studentInfoVo : studentList) {
|
|
|
+ RoomBedVo roomBedVo = bedInfoList.get(i);
|
|
|
+ RoomBed roomBed = BeanUtil.toBean(roomBedVo, RoomBed.class);
|
|
|
+ roomBed.setStudentUserId(studentInfoVo.getUserId());
|
|
|
+ roomBed.setModifyDate(modifyDate);
|
|
|
+ roomBed.setModifyUserId(modifyUserId);
|
|
|
+ roomBedMapper.updateById(roomBed);
|
|
|
+ i ++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询每个寝室住入的班级数量,大于2的设置为混合寝室
|
|
|
+ List<RoomClassCountVo> classCountVoList = roomMapper.getRoomClassCount(dto.getRoomIds());
|
|
|
+ for (RoomClassCountVo roomClassCountVo : classCountVoList) {
|
|
|
+ if(roomClassCountVo.getClassCount() > 1){
|
|
|
+ Room updRoom = roomMapper.selectById(roomClassCountVo.getId());
|
|
|
+ updRoom.setIsMax(1);
|
|
|
+ roomMapper.updateById(updRoom);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|