|
@@ -2,30 +2,44 @@ package com.xjrsoft.module.room.service.impl;
|
|
|
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
+import com.github.yulichang.toolkit.MPJWrappers;
|
|
|
+import com.xjrsoft.common.enums.DeleteMark;
|
|
|
+import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
+import com.xjrsoft.module.base.entity.BaseClass;
|
|
|
+import com.xjrsoft.module.base.mapper.BaseClassMapper;
|
|
|
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.entity.RoomBedRecord;
|
|
|
import com.xjrsoft.module.room.mapper.RoomBedMapper;
|
|
|
+import com.xjrsoft.module.room.mapper.RoomBedRecordMapper;
|
|
|
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.DistributeResultClassVo;
|
|
|
+import com.xjrsoft.module.room.vo.DistributeResultListVo;
|
|
|
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.entity.BaseStudent;
|
|
|
+import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
|
|
|
import com.xjrsoft.module.student.mapper.BaseStudentMapper;
|
|
|
-import com.xjrsoft.module.student.vo.StudentInfoVo;
|
|
|
+import com.xjrsoft.module.teacher.entity.XjrUser;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @title: 寝室床位
|
|
@@ -39,6 +53,8 @@ public class RoomBedServiceImpl extends MPJBaseServiceImpl<RoomBedMapper, RoomBe
|
|
|
private final RoomMapper roomMapper;
|
|
|
private final RoomBedMapper roomBedMapper;
|
|
|
private final BaseStudentMapper baseStudentMapper;
|
|
|
+ private final BaseClassMapper baseClassMapper;
|
|
|
+ private final RoomBedRecordMapper roomBedRecordMapper;
|
|
|
@Override
|
|
|
public Page<RoomBedPageVo> getPage(Page<RoomBedPageVo> page, RoomBedPageDto dto) {
|
|
|
Page<RoomBedPageVo> result = roomBedMapper.getPage(page, dto);
|
|
@@ -84,12 +100,27 @@ public class RoomBedServiceImpl extends MPJBaseServiceImpl<RoomBedMapper, RoomBe
|
|
|
|
|
|
//查询每个班的学生,修改床位信息
|
|
|
int i = 0;
|
|
|
+ Map<Long, Integer> classDistributeBedNumber = new HashMap<>();
|
|
|
+ Map<Long, Integer> classStudent = new HashMap<>();
|
|
|
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) {
|
|
|
+ List<BaseStudent> studentList = baseStudentMapper.selectList(
|
|
|
+ MPJWrappers.<BaseStudent>lambdaJoin()
|
|
|
+ .select(BaseStudent::getUserId)
|
|
|
+ .eq(BaseClass::getId, classId)
|
|
|
+ .eq(XjrUser::getGender, genderNumber)
|
|
|
+ .eq(BaseStudentSchoolRoll::getStduyStatus, "FB3001")
|
|
|
+ .eq(BaseStudent::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ .eq(XjrUser::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ .innerJoin(XjrUser.class, XjrUser::getId, BaseStudent::getUserId)
|
|
|
+ .leftJoin(BaseStudentSchoolRoll.class, BaseStudentSchoolRoll::getUserId, BaseStudent::getUserId)
|
|
|
+ .leftJoin(BaseClass.class, BaseClass::getId, BaseStudentSchoolRoll::getClassId)
|
|
|
+ );
|
|
|
+ //已分配床位数
|
|
|
+ int distributeBedNumber = 0;
|
|
|
+ for (BaseStudent studentInfoVo : studentList) {
|
|
|
+ if(i >= bedInfoList.size()){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
RoomBedVo roomBedVo = bedInfoList.get(i);
|
|
|
RoomBed roomBed = BeanUtil.toBean(roomBedVo, RoomBed.class);
|
|
|
roomBed.setStudentUserId(studentInfoVo.getUserId());
|
|
@@ -97,8 +128,18 @@ public class RoomBedServiceImpl extends MPJBaseServiceImpl<RoomBedMapper, RoomBe
|
|
|
roomBed.setModifyUserId(modifyUserId);
|
|
|
roomBedMapper.updateById(roomBed);
|
|
|
i ++;
|
|
|
+ distributeBedNumber ++;
|
|
|
+
|
|
|
}
|
|
|
+ classDistributeBedNumber.put(classId, distributeBedNumber);
|
|
|
+ classStudent.put(classId, studentList.size());
|
|
|
}
|
|
|
+ //插入记录表 room_bed_record
|
|
|
+ classStudent.forEach((classId, studentCount)->{
|
|
|
+ RoomBedRecord record = new RoomBedRecord();
|
|
|
+// record.setClassId();
|
|
|
+// roomBedRecordMapper.insert();
|
|
|
+ });
|
|
|
|
|
|
//查询每个寝室住入的班级数量,大于2的设置为混合寝室
|
|
|
List<RoomClassCountVo> classCountVoList = roomMapper.getRoomClassCount(dto.getRoomIds());
|
|
@@ -111,4 +152,28 @@ public class RoomBedServiceImpl extends MPJBaseServiceImpl<RoomBedMapper, RoomBe
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<DistributeResultClassVo> getDistributeResult(DistributeRoomBedDto dto) {
|
|
|
+ List<DistributeResultListVo> list = roomBedMapper.getDistributeResult(dto);
|
|
|
+ List<BaseClass> classList = baseClassMapper.selectList(
|
|
|
+ Wrappers.lambdaQuery(BaseClass.class).in(BaseClass::getId, dto.getClassIds())
|
|
|
+ .select(BaseClass.class, x -> VoToColumnUtil.fieldsToColumns(BaseClass.class).contains(x.getProperty()))
|
|
|
+ );
|
|
|
+ List<DistributeResultClassVo> result = new ArrayList<>();
|
|
|
+ for (BaseClass baseClass : classList) {
|
|
|
+ DistributeResultClassVo classVo = new DistributeResultClassVo();
|
|
|
+ classVo.setClassName(baseClass.getName());
|
|
|
+ List<DistributeResultListVo> studentList = new ArrayList<>();
|
|
|
+ for (DistributeResultListVo listVo : list) {
|
|
|
+ if(listVo.getClassId() == null || !listVo.getClassId().equals(baseClass.getId().toString())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ studentList.add(listVo);
|
|
|
+ }
|
|
|
+ classVo.setStudentList(studentList);
|
|
|
+ result.add(classVo);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|