|
@@ -4,23 +4,25 @@ import com.keao.edu.auth.api.entity.SysUser;
|
|
import com.keao.edu.common.dal.BaseDAO;
|
|
import com.keao.edu.common.dal.BaseDAO;
|
|
import com.keao.edu.common.exception.BizException;
|
|
import com.keao.edu.common.exception.BizException;
|
|
import com.keao.edu.common.page.PageInfo;
|
|
import com.keao.edu.common.page.PageInfo;
|
|
|
|
+import com.keao.edu.common.service.IdGeneratorService;
|
|
import com.keao.edu.common.service.impl.BaseServiceImpl;
|
|
import com.keao.edu.common.service.impl.BaseServiceImpl;
|
|
import com.keao.edu.common.tenant.TenantContextHolder;
|
|
import com.keao.edu.common.tenant.TenantContextHolder;
|
|
import com.keao.edu.user.api.entity.ExamRoom;
|
|
import com.keao.edu.user.api.entity.ExamRoom;
|
|
-import com.keao.edu.user.dao.ExamRoomDao;
|
|
|
|
-import com.keao.edu.user.dao.ExamRoomStudentRelationDao;
|
|
|
|
-import com.keao.edu.user.dao.StudentExamResultDao;
|
|
|
|
|
|
+import com.keao.edu.user.dao.*;
|
|
import com.keao.edu.user.dto.ExamRoomStudentRelationDto;
|
|
import com.keao.edu.user.dto.ExamRoomStudentRelationDto;
|
|
import com.keao.edu.user.api.entity.ExamRoomStudentRelation;
|
|
import com.keao.edu.user.api.entity.ExamRoomStudentRelation;
|
|
-import com.keao.edu.user.entity.StudentExamResult;
|
|
|
|
-import com.keao.edu.user.entity.Subject;
|
|
|
|
|
|
+import com.keao.edu.user.entity.*;
|
|
import com.keao.edu.user.page.ExamRoomStudentRelationQueryInfo;
|
|
import com.keao.edu.user.page.ExamRoomStudentRelationQueryInfo;
|
|
|
|
+import com.keao.edu.user.service.ExamCertificationService;
|
|
import com.keao.edu.user.service.ExamRoomStudentRelationService;
|
|
import com.keao.edu.user.service.ExamRoomStudentRelationService;
|
|
|
|
+import com.keao.edu.user.service.ExamTeacherSalaryService;
|
|
import com.keao.edu.user.service.OrganizationService;
|
|
import com.keao.edu.user.service.OrganizationService;
|
|
import com.keao.edu.util.collection.MapUtil;
|
|
import com.keao.edu.util.collection.MapUtil;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Isolation;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -37,6 +39,16 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
|
|
private OrganizationService organizationService;
|
|
private OrganizationService organizationService;
|
|
@Autowired
|
|
@Autowired
|
|
private StudentExamResultDao studentExamResultDao;
|
|
private StudentExamResultDao studentExamResultDao;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ExamCertificationDao examCertificationDao;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ExamLocationDao examLocationDao;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IdGeneratorService idGeneratorService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ExamRegistrationDao examRegistrationDao;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ExamTeacherSalaryService examTeacherSalaryService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public BaseDAO<Long, ExamRoomStudentRelation> getDAO() {
|
|
public BaseDAO<Long, ExamRoomStudentRelation> getDAO() {
|
|
@@ -49,6 +61,7 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
+ @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
|
|
public void addStudentForRoom(Long examRoomId, String studentIdsStr) {
|
|
public void addStudentForRoom(Long examRoomId, String studentIdsStr) {
|
|
if(Objects.isNull(examRoomId)){
|
|
if(Objects.isNull(examRoomId)){
|
|
throw new BizException("请指定教室");
|
|
throw new BizException("请指定教室");
|
|
@@ -56,19 +69,31 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
|
|
if(StringUtils.isBlank(studentIdsStr)){
|
|
if(StringUtils.isBlank(studentIdsStr)){
|
|
throw new BizException("请指定学员");
|
|
throw new BizException("请指定学员");
|
|
}
|
|
}
|
|
- ExamRoom examRoom = examRoomDao.get(examRoomId);
|
|
|
|
|
|
+ ExamRoom examRoom = examRoomDao.lockRoom(examRoomId);
|
|
if(Objects.isNull(examRoom)){
|
|
if(Objects.isNull(examRoom)){
|
|
throw new BizException("教室不存在");
|
|
throw new BizException("教室不存在");
|
|
}
|
|
}
|
|
|
|
+ ExamLocation examLocation = examLocationDao.get(examRoom.getExamLocationId());
|
|
|
|
+
|
|
List<ExamRoomStudentRelation> studentsWithExamRoom = examRoomStudentRelationDao.findStudentsWithExamRoom(examRoomId);
|
|
List<ExamRoomStudentRelation> studentsWithExamRoom = examRoomStudentRelationDao.findStudentsWithExamRoom(examRoomId);
|
|
Set<Integer> existStudentIds = studentsWithExamRoom.stream().map(ExamRoomStudentRelation::getStudentId).collect(Collectors.toSet());
|
|
Set<Integer> existStudentIds = studentsWithExamRoom.stream().map(ExamRoomStudentRelation::getStudentId).collect(Collectors.toSet());
|
|
String[] studentIds = studentIdsStr.split(",");
|
|
String[] studentIds = studentIdsStr.split(",");
|
|
|
|
+
|
|
|
|
+ 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));
|
|
|
|
+
|
|
List<ExamRoomStudentRelation> examRoomStudentRelations=new ArrayList<>();
|
|
List<ExamRoomStudentRelation> examRoomStudentRelations=new ArrayList<>();
|
|
List<StudentExamResult> studentExamResults=new ArrayList<>();
|
|
List<StudentExamResult> studentExamResults=new ArrayList<>();
|
|
|
|
+ List<ExamCertification> examCertifications=new ArrayList<>();
|
|
for (String studentId : studentIds) {
|
|
for (String studentId : studentIds) {
|
|
if(existStudentIds.contains(Integer.valueOf(studentId))){
|
|
if(existStudentIds.contains(Integer.valueOf(studentId))){
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
+ ExamRegistration examRegistration = studentRegistMap.get(Integer.valueOf(studentId));
|
|
|
|
+ if(Objects.isNull(examRegistration)){
|
|
|
|
+ throw new BizException("学员信息错误");
|
|
|
|
+ }
|
|
|
|
+
|
|
ExamRoomStudentRelation e=new ExamRoomStudentRelation();
|
|
ExamRoomStudentRelation e=new ExamRoomStudentRelation();
|
|
e.setExaminationBasicId(examRoom.getExaminationBasicId());
|
|
e.setExaminationBasicId(examRoom.getExaminationBasicId());
|
|
e.setExamRoomId(examRoom.getId());
|
|
e.setExamRoomId(examRoom.getId());
|
|
@@ -83,13 +108,29 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
|
|
ser.setConfirmStatus(false);
|
|
ser.setConfirmStatus(false);
|
|
ser.setTenantId(TenantContextHolder.getTenantId().toString());
|
|
ser.setTenantId(TenantContextHolder.getTenantId().toString());
|
|
studentExamResults.add(ser);
|
|
studentExamResults.add(ser);
|
|
|
|
+
|
|
|
|
+ ExamCertification ec=new ExamCertification();
|
|
|
|
+ ec.setExaminationBasicId(examRoom.getExaminationBasicId());
|
|
|
|
+ ec.setStudentId(Integer.valueOf(studentId));
|
|
|
|
+ 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());
|
|
|
|
+ ec.setTenantId(TenantContextHolder.getTenantId().toString());
|
|
|
|
+ examCertifications.add(ec);
|
|
}
|
|
}
|
|
if(!CollectionUtils.isEmpty(examRoomStudentRelations)){
|
|
if(!CollectionUtils.isEmpty(examRoomStudentRelations)){
|
|
examRoomStudentRelationDao.batchInsert(examRoomStudentRelations);
|
|
examRoomStudentRelationDao.batchInsert(examRoomStudentRelations);
|
|
|
|
+ examTeacherSalaryService.teacherSalarySettlementWithExam(examRoom.getExaminationBasicId());
|
|
}
|
|
}
|
|
if(!CollectionUtils.isEmpty(studentExamResults)){
|
|
if(!CollectionUtils.isEmpty(studentExamResults)){
|
|
studentExamResultDao.batchInsert(studentExamResults);
|
|
studentExamResultDao.batchInsert(studentExamResults);
|
|
}
|
|
}
|
|
|
|
+ if(!CollectionUtils.isEmpty(examCertifications)){
|
|
|
|
+ examCertificationDao.batchInsert(examCertifications);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|