|
|
@@ -11,6 +11,7 @@ import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
import com.github.yulichang.toolkit.MPJWrappers;
|
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
import com.xjrsoft.common.enums.DeleteMark;
|
|
|
+import com.xjrsoft.common.enums.GenderDictionaryEnum;
|
|
|
import com.xjrsoft.common.exception.MyException;
|
|
|
import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
import com.xjrsoft.module.base.entity.BaseClass;
|
|
|
@@ -421,20 +422,15 @@ public class RoomBedServiceImpl extends MPJBaseServiceImpl<RoomBedMapper, RoomBe
|
|
|
|
|
|
@Override
|
|
|
public List<AdjustBedClassPageVo> getClassStudetBed(AdjustClassPageDto dto) {
|
|
|
- List<BaseClass> classList = baseClassMapper.selectList(
|
|
|
- new QueryWrapper<BaseClass>().lambda()
|
|
|
- .eq(BaseClass::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
- .eq(ObjectUtil.isNotNull(dto.getClassId()), BaseClass::getId, dto.getClassId())
|
|
|
- .eq(ObjectUtil.isNotNull(dto.getGradeId()), BaseClass::getGradeId, dto.getGradeId())
|
|
|
- );
|
|
|
+ List<AdjustBedClassPageVo> classList = roomBedMapper.getClassTeacherInfo(dto);
|
|
|
List<AdjustBedClassPageVo> result = new ArrayList<>();
|
|
|
List<AdjustBedClassStudentPageVo> allStudent = roomBedMapper.getClassStudetBed(dto);
|
|
|
|
|
|
//查询缴费状态
|
|
|
DistributeRoomBedDto distributeRoomBedDto = new DistributeRoomBedDto();
|
|
|
List<Long> classIds = new ArrayList<>();
|
|
|
- for (BaseClass baseClass : classList) {
|
|
|
- classIds.add(baseClass.getId());
|
|
|
+ for (AdjustBedClassPageVo baseClass : classList) {
|
|
|
+ classIds.add(Long.parseLong(baseClass.getId()));
|
|
|
}
|
|
|
distributeRoomBedDto.setClassIds(classIds);
|
|
|
List<StudentPayStatusVo> studentPayStatusVoList = roomBedMapper.getStudentPayStatus(distributeRoomBedDto);
|
|
|
@@ -446,7 +442,7 @@ public class RoomBedServiceImpl extends MPJBaseServiceImpl<RoomBedMapper, RoomBe
|
|
|
}
|
|
|
payStatusMap.put(statusVo.getId(), payStatus);
|
|
|
}
|
|
|
- for (BaseClass classOne : classList) {
|
|
|
+ for (AdjustBedClassPageVo classOne : classList) {
|
|
|
List<AdjustBedClassStudentPageVo> studentList = new ArrayList<>();
|
|
|
for (AdjustBedClassStudentPageVo adjustBedClassStudentPageVo : allStudent) {
|
|
|
if(!classOne.getId().toString().equals(adjustBedClassStudentPageVo.getClassId())){
|
|
|
@@ -538,4 +534,93 @@ public class RoomBedServiceImpl extends MPJBaseServiceImpl<RoomBedMapper, RoomBe
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 1、先做性别校验,如果学生性别和入住寝室的性别不一致,不进行数据保存并返回学生的姓名到前端
|
|
|
+ * 2、参数中可能存在学生id不为空,床位id为空的,根据学生id清空学生相应的床位信息
|
|
|
+ * 3、如果一个学生被安排了多个床位,需要新增提示
|
|
|
+ * @param dtoList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean adjustBedBatch(List<AdjustStudentBedDto> dtoList) {
|
|
|
+ //存分配到女生寝室的男生名字
|
|
|
+ List<String> boyStudents = new ArrayList<>();
|
|
|
+ //存分配到男生寝室的女生名字
|
|
|
+ List<String> girlStudents = new ArrayList<>();
|
|
|
+ //需要清空床位的学生
|
|
|
+ List<AdjustStudentBedDto> todoStudents = new ArrayList<>();
|
|
|
+ for (AdjustStudentBedDto dto : dtoList) {
|
|
|
+ if(dto.getStudentUserId() != null && dto.getBedId() != null){
|
|
|
+ //查询学生的性别
|
|
|
+ XjrUser xjrUser = xjrUserMapper.selectById(dto.getStudentUserId());
|
|
|
+ String studentGender = xjrUser.getGender();
|
|
|
+
|
|
|
+ RoomBed roomBedInfo = roomBedMapper.selectById(dto.getBedId());
|
|
|
+ Room room = roomMapper.selectById(roomBedInfo.getRoomId());
|
|
|
+ if(!room.getGender().equals(studentGender)){
|
|
|
+ if(GenderDictionaryEnum.MALE.getCode().equals(room.getGender())){//男生
|
|
|
+ boyStudents.add(xjrUser.getName());
|
|
|
+ }else if(GenderDictionaryEnum.FEMALE.getCode().equals(room.getGender())){//女生
|
|
|
+ girlStudents.add(xjrUser.getName());
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //校验通过
|
|
|
+ todoStudents.add(dto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //存这次处理过的寝室,查看是否需要设置为混合寝室
|
|
|
+ List<Long> roomIds = new ArrayList<>();
|
|
|
+ if(boyStudents.isEmpty() && girlStudents.isEmpty()){
|
|
|
+ for (AdjustStudentBedDto todoStudent : todoStudents) {
|
|
|
+ //先清空原来的床位
|
|
|
+ UpdateWrapper<RoomBed> updateWrapper = new UpdateWrapper<>();
|
|
|
+ updateWrapper.eq("student_user_id", todoStudent.getStudentUserId());
|
|
|
+ updateWrapper.setSql("student_user_id = null");
|
|
|
+ updateWrapper.setSql("is_check_in = 0");
|
|
|
+ List<RoomBed> roomBedList = roomBedMapper.selectList(new QueryWrapper<RoomBed>().lambda().eq(RoomBed::getStudentUserId, todoStudent.getStudentUserId()));
|
|
|
+ for (RoomBed roomBed : roomBedList) {
|
|
|
+ roomBedMapper.update(roomBed, updateWrapper);
|
|
|
+ roomIds.add(roomBed.getRoomId());
|
|
|
+ }
|
|
|
+ //再把学生保存到新的床位
|
|
|
+ roomBedMapper.updateById(new RoomBed(){{
|
|
|
+ setId(todoStudent.getBedId());
|
|
|
+ setStudentUserId(todoStudent.getStudentUserId());
|
|
|
+ }});
|
|
|
+ }
|
|
|
+ //如果寝室的人是多个班级,将混合寝室改为是
|
|
|
+ List<RoomClassCountVo> classCountVoList = roomMapper.getRoomClassCount(roomIds);
|
|
|
+ for (RoomClassCountVo roomClassCountVo : classCountVoList) {
|
|
|
+ if(roomClassCountVo.getClassCount() > 1){
|
|
|
+ Room updRoom = roomMapper.selectById(roomClassCountVo.getId());
|
|
|
+ updRoom.setIsMax(1);
|
|
|
+ roomMapper.updateById(updRoom);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ String boyMsg = "学生";
|
|
|
+ for (int i = 0; i < boyStudents.size(); i ++){
|
|
|
+ if(i > 0){
|
|
|
+ boyMsg += "、";
|
|
|
+ }
|
|
|
+ boyMsg += boyStudents.get(i);
|
|
|
+ }
|
|
|
+ boyMsg += "被分配到女生寝室";
|
|
|
+
|
|
|
+ String girlMsg = "学生";
|
|
|
+ for (int i = 0; i < girlStudents.size(); i ++){
|
|
|
+ if(i > 0){
|
|
|
+ girlMsg += "、";
|
|
|
+ }
|
|
|
+ girlMsg += girlStudents.get(i);
|
|
|
+ }
|
|
|
+ girlMsg += "被分配到女生寝室";
|
|
|
+
|
|
|
+ throw new MyException(boyMsg + ";" + girlMsg);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
}
|