|
|
@@ -550,10 +550,16 @@ public class RoomBedServiceImpl extends MPJBaseServiceImpl<RoomBedMapper, RoomBe
|
|
|
List<String> girlStudents = new ArrayList<>();
|
|
|
//需要清空床位的学生
|
|
|
List<AdjustStudentBedDto> todoStudents = new ArrayList<>();
|
|
|
+
|
|
|
+ Map<Long, Long> bedStudentMap = new HashMap<>();
|
|
|
+ Map<Long, String> studentNameMap = new HashMap<>();
|
|
|
for (AdjustStudentBedDto dto : dtoList) {
|
|
|
if(dto.getStudentUserId() != null && dto.getBedId() != null){
|
|
|
+ bedStudentMap.put(dto.getBedId(), dto.getStudentUserId());
|
|
|
//查询学生的性别
|
|
|
XjrUser xjrUser = xjrUserMapper.selectById(dto.getStudentUserId());
|
|
|
+ studentNameMap.put(dto.getStudentUserId(), xjrUser.getName());
|
|
|
+
|
|
|
String studentGender = xjrUser.getGender();
|
|
|
|
|
|
RoomBed roomBedInfo = roomBedMapper.selectById(dto.getBedId());
|
|
|
@@ -570,9 +576,19 @@ public class RoomBedServiceImpl extends MPJBaseServiceImpl<RoomBedMapper, RoomBe
|
|
|
todoStudents.add(dto);
|
|
|
}
|
|
|
}
|
|
|
+ //存被安排了多个床位的学生
|
|
|
+ List<String> moreBedStudents = new ArrayList<>();
|
|
|
+ for (Map.Entry<Long, Long> entry : bedStudentMap.entrySet()) {
|
|
|
+ Long value = entry.getValue();
|
|
|
+
|
|
|
+ if (bedStudentMap.entrySet().stream().filter(e -> e.getValue().equals(value)).count() > 1) {
|
|
|
+ moreBedStudents.add(studentNameMap.get(value));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//存这次处理过的寝室,查看是否需要设置为混合寝室
|
|
|
List<Long> roomIds = new ArrayList<>();
|
|
|
- if(boyStudents.isEmpty() && girlStudents.isEmpty()){
|
|
|
+ if(boyStudents.isEmpty() && girlStudents.isEmpty() && moreBedStudents.isEmpty()){
|
|
|
for (AdjustStudentBedDto todoStudent : todoStudents) {
|
|
|
//先清空原来的床位
|
|
|
UpdateWrapper<RoomBed> updateWrapper = new UpdateWrapper<>();
|
|
|
@@ -618,7 +634,15 @@ public class RoomBedServiceImpl extends MPJBaseServiceImpl<RoomBedMapper, RoomBe
|
|
|
}
|
|
|
girlMsg += "被分配到女生寝室";
|
|
|
|
|
|
- throw new MyException(boyMsg + ";" + girlMsg);
|
|
|
+ String moreBedMsg = "学生";
|
|
|
+ for (int i = 0; i < moreBedStudents.size(); i ++){
|
|
|
+ if(i > 0){
|
|
|
+ moreBedMsg += "、";
|
|
|
+ }
|
|
|
+ moreBedMsg += moreBedStudents.get(i);
|
|
|
+ }
|
|
|
+ moreBedMsg += "被分配多个床位";
|
|
|
+ throw new MyException(boyMsg + ";" + girlMsg + ";" + moreBedMsg);
|
|
|
}
|
|
|
return true;
|
|
|
}
|