|
@@ -10,6 +10,7 @@ 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.api.entity.ExamRoomStudentRelation;
|
|
|
+import com.keao.edu.user.api.enums.ExamModeEnum;
|
|
|
import com.keao.edu.user.dao.*;
|
|
|
import com.keao.edu.user.dto.ExamRoomStudentRelationDto;
|
|
|
import com.keao.edu.user.entity.*;
|
|
@@ -62,68 +63,82 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
|
|
|
- public void addStudentForRoom(Long examRoomId, String studentIdsStr) {
|
|
|
+ public void addStudentForRoom(Long examRoomId, String registIdsStr) {
|
|
|
if(Objects.isNull(examRoomId)){
|
|
|
throw new BizException("请指定教室");
|
|
|
}
|
|
|
- if(StringUtils.isBlank(studentIdsStr)){
|
|
|
- throw new BizException("请指定学员");
|
|
|
+ if(StringUtils.isBlank(registIdsStr)){
|
|
|
+ throw new BizException("请指定学员报名编号");
|
|
|
}
|
|
|
ExamRoom examRoom = examRoomDao.lockRoom(examRoomId);
|
|
|
if(Objects.isNull(examRoom)){
|
|
|
throw new BizException("教室不存在");
|
|
|
}
|
|
|
- ExamLocation examLocation = examLocationDao.get(examRoom.getExamLocationId());
|
|
|
+ ExamLocation examLocation = null;
|
|
|
+ if(ExamModeEnum.OFFLINE.equals(examRoom.getExamMode())){
|
|
|
+ examLocation = examLocationDao.get(examRoom.getExamLocationId());
|
|
|
+ if(Objects.isNull(examLocation)){
|
|
|
+ throw new BizException("考点信息错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
List<ExamRoomStudentRelation> studentsWithExamRoom = examRoomStudentRelationDao.findStudentsWithExamRoom(examRoomId);
|
|
|
- Set<Integer> existStudentIds = studentsWithExamRoom.stream().map(ExamRoomStudentRelation::getStudentId).collect(Collectors.toSet());
|
|
|
- String[] studentIds = studentIdsStr.split(",");
|
|
|
+ Set<Long> existRegistIds = studentsWithExamRoom.stream().map(ExamRoomStudentRelation::getExamRegistrationId).collect(Collectors.toSet());
|
|
|
|
|
|
- List<ExamRegistration> examRegistrations = examRegistrationDao.getWithExamAndStudents(examRoom.getExaminationBasicId(), Arrays.asList(studentIds).stream().map(e -> Integer.valueOf(e)).collect(Collectors.toList()));
|
|
|
- Map<Integer, ExamRegistration> studentRegistMap = examRegistrations.stream().collect(Collectors.toMap(ExamRegistration::getStudentId, e -> e));
|
|
|
+ String[] registIds = registIdsStr.split(",");
|
|
|
+
|
|
|
+ List<ExamRegistration> examRegistrations = examRegistrationDao.getRegists(Arrays.asList(registIds).stream().map(e -> Long.valueOf(e)).collect(Collectors.toList()));
|
|
|
+ Map<Integer, ExamRegistration> studentRegistMap = examRegistrations.stream().collect(Collectors.toMap(ExamRegistration::getId, e -> e));
|
|
|
|
|
|
List<ExamRoomStudentRelation> examRoomStudentRelations=new ArrayList<>();
|
|
|
List<StudentExamResult> studentExamResults=new ArrayList<>();
|
|
|
List<ExamCertification> examCertifications=new ArrayList<>();
|
|
|
- for (String studentId : studentIds) {
|
|
|
- if(existStudentIds.contains(Integer.valueOf(studentId))){
|
|
|
+ for (String registId : registIds) {
|
|
|
+ if(existRegistIds.contains(Long.valueOf(registId))){
|
|
|
continue;
|
|
|
}
|
|
|
- ExamRegistration examRegistration = studentRegistMap.get(Integer.valueOf(studentId));
|
|
|
+ ExamRegistration examRegistration = studentRegistMap.get(Integer.valueOf(registId));
|
|
|
if(Objects.isNull(examRegistration)){
|
|
|
throw new BizException("学员信息错误");
|
|
|
}
|
|
|
|
|
|
ExamRoomStudentRelation e=new ExamRoomStudentRelation();
|
|
|
+ e.setExamRegistrationId(Long.valueOf(registId));
|
|
|
e.setExaminationBasicId(examRoom.getExaminationBasicId());
|
|
|
e.setExamRoomId(examRoom.getId());
|
|
|
- e.setStudentId(Integer.valueOf(studentId));
|
|
|
+ e.setStudentId(examRegistration.getStudentId());
|
|
|
e.setTenantId(TenantContextHolder.getTenantId());
|
|
|
examRoomStudentRelations.add(e);
|
|
|
|
|
|
StudentExamResult ser = new StudentExamResult();
|
|
|
+ ser.setExamRegistrationId(examRegistration.getId().longValue());
|
|
|
ser.setExaminationBasicId(examRoom.getExaminationBasicId());
|
|
|
- ser.setStudentId(Integer.valueOf(studentId));
|
|
|
+ ser.setStudentId(examRegistration.getStudentId());
|
|
|
ser.setIsFinishedExam(0);
|
|
|
ser.setConfirmStatus(0);
|
|
|
ser.setTenantId(TenantContextHolder.getTenantId());
|
|
|
studentExamResults.add(ser);
|
|
|
|
|
|
ExamCertification ec=new ExamCertification();
|
|
|
+ ec.setExamRegistrationId(examRegistration.getId().longValue());
|
|
|
ec.setExaminationBasicId(examRoom.getExaminationBasicId());
|
|
|
- ec.setStudentId(Integer.valueOf(studentId));
|
|
|
+ ec.setStudentId(examRegistration.getStudentId());
|
|
|
ec.setCardNo(String.valueOf(idGeneratorService.generatorId()));
|
|
|
ec.setSubjectId(examRegistration.getSubjectId());
|
|
|
ec.setLevel(examRegistration.getLevel());
|
|
|
ec.setExamStartTime(examRoom.getExamStartTime());
|
|
|
ec.setExamEndTime(examRoom.getExamEndTime());
|
|
|
- ec.setExamAddress(examLocation.getAddress());
|
|
|
+ if(ExamModeEnum.OFFLINE.equals(examRoom.getExamMode())){
|
|
|
+ ec.setExamAddress(examLocation.getAddress());
|
|
|
+ }
|
|
|
ec.setTenantId(TenantContextHolder.getTenantId());
|
|
|
examCertifications.add(ec);
|
|
|
}
|
|
|
if(!CollectionUtils.isEmpty(examRoomStudentRelations)){
|
|
|
examRoomStudentRelationDao.batchInsert(examRoomStudentRelations);
|
|
|
examTeacherSalaryService.teacherSalarySettlementWithExam(examRoom.getExaminationBasicId());
|
|
|
+ examRoom.setExamRoomStudentNum(examRoom.getExamRoomStudentNum()+examRoomStudentRelations.size());
|
|
|
+ examRoomDao.update(examRoom);
|
|
|
}
|
|
|
if(!CollectionUtils.isEmpty(studentExamResults)){
|
|
|
studentExamResultDao.batchInsert(studentExamResults);
|
|
@@ -167,10 +182,25 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
|
|
|
|
|
|
@Override
|
|
|
public PageInfo<ExamRoomStudentRelationDto> findExamRoomStudents(ExamRoomStudentRelationQueryInfo queryInfo) {
|
|
|
+ if(Objects.nonNull(queryInfo.getInRoom())&&Objects.isNull(queryInfo.getExamRoomId())){
|
|
|
+ throw new BizException("请指定考场");
|
|
|
+ }
|
|
|
+
|
|
|
PageInfo<ExamRoomStudentRelationDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
|
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
MapUtil.populateMap(params, queryInfo);
|
|
|
|
|
|
+ if(Objects.nonNull(queryInfo.getExamRoomId())){
|
|
|
+ ExamRoom examRoom = examRoomDao.get(queryInfo.getExamRoomId());
|
|
|
+ if(Objects.isNull(examRoom)){
|
|
|
+ throw new BizException("考场不存在");
|
|
|
+ }
|
|
|
+ if(!examRoom.getExaminationBasicId().equals(queryInfo.getExamId())){
|
|
|
+ throw new BizException("考场信息异常");
|
|
|
+ }
|
|
|
+ params.put("subjectIds", examRoom.getSubjectIdList());
|
|
|
+ }
|
|
|
+
|
|
|
List<Integer> nextLevelOrganIds = organizationService.getChildOrganIds(queryInfo.getOrganId(), true);
|
|
|
params.put("organIds", nextLevelOrganIds);
|
|
|
|
|
@@ -180,12 +210,12 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
|
|
|
pageInfo.setTotal(count);
|
|
|
params.put("offset", pageInfo.getOffset());
|
|
|
dataList = examRoomStudentRelationDao.findExamRoomStudents(params);
|
|
|
- List<Integer> studentIds = dataList.stream().map(ExamRoomStudentRelationDto::getStudentId).collect(Collectors.toList());
|
|
|
+ List<Integer> studentIds = dataList.stream().map(e->e.getExamRegistration().getStudentId()).collect(Collectors.toList());
|
|
|
List<Integer> subjectIds = dataList.stream().map(e->e.getExamRegistration().getSubjectId()).collect(Collectors.toList());
|
|
|
Map<Integer, String> studentIdNameMap = this.getMap("sys_user", "id_", "real_name_", studentIds, Integer.class, String.class);
|
|
|
Map<Integer, String> subjectIdNameMap = this.getMap("subject", "id_", "name_", subjectIds, Integer.class, String.class);
|
|
|
for (ExamRoomStudentRelationDto e : dataList) {
|
|
|
- e.setStudentInfo(new SysUser(e.getStudentId(),studentIdNameMap.get(e.getStudentId())));
|
|
|
+ e.setStudentInfo(new SysUser(e.getStudentId(),studentIdNameMap.get(e.getExamRegistration().getStudentId())));
|
|
|
e.setSubject(new Subject(e.getExamRegistration().getSubjectId(), subjectIdNameMap.get(e.getExamRegistration().getSubjectId())));
|
|
|
}
|
|
|
}
|