|
@@ -3,6 +3,7 @@ package com.keao.edu.user.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.keao.edu.auth.api.entity.SysUser;
|
|
|
import com.keao.edu.common.dal.BaseDAO;
|
|
|
import com.keao.edu.common.enums.YesOrNoEnum;
|
|
|
import com.keao.edu.common.exception.BizException;
|
|
@@ -10,10 +11,7 @@ import com.keao.edu.common.page.PageInfo;
|
|
|
import com.keao.edu.common.service.impl.BaseServiceImpl;
|
|
|
import com.keao.edu.common.tenant.TenantContextHolder;
|
|
|
import com.keao.edu.user.api.entity.ExamRoom;
|
|
|
-import com.keao.edu.user.dao.ExamRegistrationDao;
|
|
|
-import com.keao.edu.user.dao.ExamRoomDao;
|
|
|
-import com.keao.edu.user.dao.ExamRoomStudentRelationDao;
|
|
|
-import com.keao.edu.user.dao.ExaminationBasicDao;
|
|
|
+import com.keao.edu.user.dao.*;
|
|
|
import com.keao.edu.user.dto.ExamRoomDto;
|
|
|
import com.keao.edu.user.dto.ExamRoomStatisticsDto;
|
|
|
import com.keao.edu.user.api.enums.ExamModeEnum;
|
|
@@ -45,6 +43,8 @@ public class ExamRoomServiceImpl extends BaseServiceImpl<Long, ExamRoom> impleme
|
|
|
private ExamRegistrationDao examRegistrationDao;
|
|
|
@Autowired
|
|
|
private ExaminationBasicDao examinationBasicDao;
|
|
|
+ @Autowired
|
|
|
+ private SysUserDao sysUserDao;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Long, ExamRoom> getDAO() {
|
|
@@ -118,8 +118,12 @@ public class ExamRoomServiceImpl extends BaseServiceImpl<Long, ExamRoom> impleme
|
|
|
if(Objects.isNull(er.getExamStartTime())||Objects.isNull(er.getExamEndTime())){
|
|
|
throw new BizException("请指定考试时间");
|
|
|
}
|
|
|
+ if(er.getExamStartTime().compareTo(er.getExamEndTime())>=0){
|
|
|
+ throw new BizException("考试时间异常");
|
|
|
+ }
|
|
|
examRooms.add(er);
|
|
|
}
|
|
|
+ checkRoomTeachers(examRooms);
|
|
|
examRoomDao.batchInsert(examRooms);
|
|
|
}
|
|
|
|
|
@@ -182,7 +186,11 @@ public class ExamRoomServiceImpl extends BaseServiceImpl<Long, ExamRoom> impleme
|
|
|
|
|
|
@Override
|
|
|
public void checkRoomTeachers(List<ExamRoom> examRooms) {
|
|
|
+ if(CollectionUtils.isEmpty(examRooms)){
|
|
|
+ throw new BizException("考场信息异常");
|
|
|
+ }
|
|
|
Set<String> days=new HashSet<>();
|
|
|
+ Map<Integer, List<ExamRoom>> teacherRoomMap = new HashMap<>();
|
|
|
for (ExamRoom examRoom : examRooms) {
|
|
|
if(Objects.nonNull(examRoom.getExamStartTime())){
|
|
|
days.add(DateUtil.dateToString(examRoom.getExamStartTime(), "yyyy-MM-dd"));
|
|
@@ -190,7 +198,60 @@ public class ExamRoomServiceImpl extends BaseServiceImpl<Long, ExamRoom> impleme
|
|
|
if(Objects.nonNull(examRoom.getExamEndTime())){
|
|
|
days.add(DateUtil.dateToString(examRoom.getExamEndTime(), "yyyy-MM-dd"));
|
|
|
}
|
|
|
+ if(Objects.nonNull(examRoom.getMainTeacherUserId())&&!teacherRoomMap.containsKey(examRoom.getMainTeacherUserId())){
|
|
|
+ List<ExamRoom> teacherExamRooms=new ArrayList<>();
|
|
|
+ teacherExamRooms.add(examRoom);
|
|
|
+ teacherRoomMap.put(examRoom.getMainTeacherUserId(), teacherExamRooms);
|
|
|
+ }else if(teacherRoomMap.containsKey(examRoom.getMainTeacherUserId())){
|
|
|
+ teacherRoomMap.get(examRoom.getMainTeacherUserId()).add(examRoom);
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(examRoom.getAssistantTeacherUserIdList())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String[] teacherStrIds = examRoom.getAssistantTeacherUserIdList().split(",");
|
|
|
+ for (String teacherStrId : teacherStrIds) {
|
|
|
+ if(!teacherRoomMap.containsKey(Integer.valueOf(teacherStrId))){
|
|
|
+ List<ExamRoom> teacherExamRooms=new ArrayList<>();
|
|
|
+ teacherExamRooms.add(examRoom);
|
|
|
+ teacherRoomMap.put(Integer.valueOf(teacherStrId), teacherExamRooms);
|
|
|
+ }else if(teacherRoomMap.containsKey(Integer.valueOf(teacherStrId))){
|
|
|
+ teacherRoomMap.get(Integer.valueOf(teacherStrId)).add(examRoom);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(CollectionUtils.isEmpty(days)){
|
|
|
+ throw new BizException("考场信息异常");
|
|
|
+ }
|
|
|
+ List<ExamRoom> withDays = examRoomDao.getWithDays(new ArrayList<>(days));
|
|
|
+ for (ExamRoom examRoom : withDays) {
|
|
|
+ if(teacherRoomMap.containsKey(examRoom.getMainTeacherUserId())){
|
|
|
+ teacherRoomMap.get(examRoom.getMainTeacherUserId()).add(examRoom);
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(examRoom.getAssistantTeacherUserIdList())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String[] teacherStrIds = examRoom.getAssistantTeacherUserIdList().split(",");
|
|
|
+ for (String teacherStrId : teacherStrIds) {
|
|
|
+ if(teacherRoomMap.containsKey(Integer.valueOf(teacherStrId))){
|
|
|
+ teacherRoomMap.get(Integer.valueOf(teacherStrId)).add(examRoom);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ for (Map.Entry<Integer, List<ExamRoom>> teacherRoomEntry : teacherRoomMap.entrySet()) {
|
|
|
+ List<ExamRoom> teacherRooms = teacherRoomEntry.getValue();
|
|
|
+ teacherRooms.sort(Comparator.comparing(ExamRoom::getExamStartTime));
|
|
|
+ for (int i = 0; i < teacherRooms.size(); i++) {
|
|
|
+ if(i==0){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ ExamRoom preExamRoom=teacherRooms.get(i-1);
|
|
|
+ ExamRoom currentExamRoom = teacherRooms.get(i);
|
|
|
+ if(preExamRoom.getExamEndTime().compareTo(currentExamRoom.getExamStartTime())>0){
|
|
|
+ SysUser sysUser = sysUserDao.get(teacherRoomEntry.getKey());
|
|
|
+ throw new BizException("{}教师时间存在冲突", sysUser.getRealName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|