|
@@ -976,7 +976,6 @@ public class BatchServiceImpl extends ServiceImpl<BatchDao, BatchEntity> impleme
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
public AnswerPackageSave batchPackageSave(AnswerPackageDomain domain, User user) {
|
|
|
BatchEntity batch = checkBatchStatus(getById(domain.getBatchId()));
|
|
|
ExamEntity exam = examService.getById(batch.getExamId());
|
|
@@ -1025,19 +1024,27 @@ public class BatchServiceImpl extends ServiceImpl<BatchDao, BatchEntity> impleme
|
|
|
List<OmrGroupEntity> gs = omrGroupService.findByExamIdAndSubjectCodeAndFixed(exam.getId(),
|
|
|
domain.getSubjectCode(),true);
|
|
|
|
|
|
+ Map<String,List<StudentPaperEntity>> studentPaperMap = this.savePaperBatch(batch,user,answerCard.getNumber(),answerPackageStudentMap,studentMap);
|
|
|
+ this.deleteRelation(studentMap);
|
|
|
+ this.saveAndUpdateStudent(batch,user,studentMap,studentPaperMap);
|
|
|
+
|
|
|
+ return AnswerPackageSave.create(studentMap.size(),batch.getStatus());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public Map<String, List<StudentPaperEntity>> savePaperBatch(BatchEntity batch, User user,Integer cardNumber, Map<String, AnswerPackageStudent> answerPackageStudentMap, Map<String, StudentEntity> studentMap){
|
|
|
+ Map<String, List<StudentPaperEntity>> result = new HashMap<>();
|
|
|
for (String examNumber:studentMap.keySet()) {
|
|
|
AnswerPackageStudent answerPackageStudent = answerPackageStudentMap.get(examNumber);
|
|
|
StudentEntity student = studentMap.get(examNumber);
|
|
|
- boolean studentAssigned = false;
|
|
|
List<StudentPaperEntity> studentPaperList = new ArrayList<>();
|
|
|
for (AnswerPaper answerPaper : answerPackageStudent.getPapers()) {
|
|
|
- // 验证page数量
|
|
|
- answerPaper.answerCardValidate(answerCard);
|
|
|
Integer paperNumber = answerPaper.getNumber();
|
|
|
PaperEntity paper = findOrCreatePaper(batch, student, paperNumber, user);
|
|
|
// 设置paper属性
|
|
|
paper.setExamId(batch.getExamId());
|
|
|
- paper.setCardNumber(answerCard.getNumber());
|
|
|
+ paper.setCardNumber(cardNumber);
|
|
|
paper.setNumber(paperNumber);
|
|
|
paper.setMismatch(false);
|
|
|
paper.setQuestionFilled(false);
|
|
@@ -1048,36 +1055,57 @@ public class BatchServiceImpl extends ServiceImpl<BatchDao, BatchEntity> impleme
|
|
|
paperService.savePaperAndPages(paper, answerPaper.buildPageList(null));
|
|
|
// 记录paper与batch关联关系
|
|
|
batchPaperService.update(batch, paper, student.getId(), paperNumber, false);
|
|
|
- // 创建student与paper的关联关系
|
|
|
studentPaperList.add(new StudentPaperEntity(student.getId(), paperNumber, paper.getId()));
|
|
|
- studentAssigned = studentAssigned || paper.getAssigned();
|
|
|
- // 不开启实时审核,或者当前批次无需审核,直接更新考生扫描状态
|
|
|
-// if (VerifyStatus.CANCEL.equals(batch.getVerifyStatus()) || exam.getEnableSyncVerify() == null
|
|
|
-// || !exam.getEnableSyncVerify()) {
|
|
|
- concurrentService.getReadWriteLock(LockType.STUDENT + "-" + student.getId()).writeLock().lock();
|
|
|
- try {
|
|
|
-// studentService.updateStudentAndPaper(user, student.getId(), studentPaperList);
|
|
|
- // 更新绑定关系
|
|
|
- studentPaper(student, studentPaperList);
|
|
|
- // 更新考生状态
|
|
|
- studentService.updateStudentByPaper(user, student.getId(), false);
|
|
|
- //识别对照
|
|
|
- for (OmrGroupEntity g : gs) {
|
|
|
- concurrentService.getReadWriteLock(LockType.OMR_GROUP + "-" + g.getId()).readLock().lock();
|
|
|
- omrTaskService.deleteByStudentIdAndGroupId(g.getId(), student.getId(),false);
|
|
|
- List<OmrTaskEntity> list = omrTaskService.buildTask(g, student.getId());
|
|
|
- if (list != null && !list.isEmpty()) {
|
|
|
- omrTaskService.saveBatch(list);
|
|
|
- }
|
|
|
- concurrentService.getReadWriteLock(LockType.OMR_GROUP + "-" + g.getId()).readLock().unlock();
|
|
|
+ }
|
|
|
+ result.put(examNumber,studentPaperList);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void deleteRelation(Map<String, StudentEntity> studentMap) {
|
|
|
+ for (StudentEntity student: studentMap.values()) {
|
|
|
+ studentPaperService.removeByStudentId(student.getId());
|
|
|
+ omrTaskService.deleteByStudentIdAndGroupId(student.getId(),null,false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void saveAndUpdateStudent(BatchEntity batch, User user,Map<String, StudentEntity> studentMap,Map<String, List<StudentPaperEntity>> studentPaperMap) {
|
|
|
+ List<OmrGroupEntity> gs = omrGroupService.findByExamIdAndSubjectCode(batch.getExamId(),
|
|
|
+ batch.getSubjectCode());
|
|
|
+ int assignedCount = 0;
|
|
|
+ String province =null;
|
|
|
+ String campusCode = null;
|
|
|
+ String examSite = null;
|
|
|
+ String examRoom = null ;
|
|
|
+ for (StudentEntity student:studentMap.values()) {
|
|
|
+ province = student.getProvince();
|
|
|
+ campusCode = student.getCampusCode();
|
|
|
+ examSite = student.getExamSite();
|
|
|
+ examRoom = student.getExamRoom();
|
|
|
+ concurrentService.getReadWriteLock(LockType.STUDENT + "-" + student.getId()).writeLock().lock();
|
|
|
+ try {
|
|
|
+ // 更新绑定关系
|
|
|
+ studentPaperService.saveOrUpdateBatchByMultiId(studentPaperMap.get(student.getExamNumber()));
|
|
|
+ // 更新考生状态
|
|
|
+ student = studentService.updateStudentByPaper(user, student.getId(), false);
|
|
|
+ if(student.getAssigned()){
|
|
|
+ assignedCount++;
|
|
|
+ }
|
|
|
+ //识别对照
|
|
|
+ for (OmrGroupEntity g : gs) {
|
|
|
+ if(g.getFixed()){
|
|
|
+ List<OmrTaskEntity> list = omrTaskService.buildTask(g, student.getId());
|
|
|
+ if (list != null && !list.isEmpty()) {
|
|
|
+ omrTaskService.saveBatch(list);
|
|
|
}
|
|
|
- } finally {
|
|
|
- concurrentService.getReadWriteLock(LockType.STUDENT + "-" + student.getId()).writeLock().unlock();
|
|
|
}
|
|
|
-// }
|
|
|
- }
|
|
|
- if(studentAssigned){
|
|
|
- assignedCount++;
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ concurrentService.getReadWriteLock(LockType.STUDENT + "-" + student.getId()).writeLock().unlock();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1097,28 +1125,15 @@ public class BatchServiceImpl extends ServiceImpl<BatchDao, BatchEntity> impleme
|
|
|
lw.eq(BatchEntity::getSubjectCode, batch.getSubjectCode());
|
|
|
lw.eq(BatchEntity::getPackageCode, batch.getPackageCode());
|
|
|
this.update(lw);
|
|
|
-
|
|
|
// 更新考场扫描状态
|
|
|
ExamRoomScannedQuery req = new ExamRoomScannedQuery();
|
|
|
- req.setExamId(exam.getId());
|
|
|
- req.setSubjectCode(domain.getSubjectCode());
|
|
|
- req.setProvince(ss.get(0).getProvince());
|
|
|
- req.setCampusCode(ss.get(0).getCampusCode());
|
|
|
- req.setExamSite(ss.get(0).getExamSite());
|
|
|
- req.setExamRoom(ss.get(0).getExamRoom());
|
|
|
+ req.setExamId(batch.getExamId());
|
|
|
+ req.setSubjectCode(batch.getSubjectCode());
|
|
|
+ req.setProvince(province);
|
|
|
+ req.setCampusCode(campusCode);
|
|
|
+ req.setExamSite(examSite);
|
|
|
+ req.setExamRoom(examRoom);
|
|
|
examRoomService.modifyByStudentScan(req);
|
|
|
-
|
|
|
- return AnswerPackageSave.create(findStudentCountByBatch(batch.getId()),batch.getStatus());
|
|
|
}
|
|
|
|
|
|
- private void studentPaper(StudentEntity student, List<StudentPaperEntity> studentPaperList) {
|
|
|
- List<StudentPaperEntity> list= studentPaperService.findByStudentId(student.getId());
|
|
|
- if(list.isEmpty() || list.size() == studentPaperList.size()){
|
|
|
- // 保存绑定关系
|
|
|
- studentPaperService.saveOrUpdateBatchByMultiId(studentPaperList);
|
|
|
- }else{
|
|
|
- studentPaperService.removeByStudentId(student.getId());
|
|
|
- studentPaperService.saveOrUpdateBatchByMultiId(studentPaperList);
|
|
|
- }
|
|
|
- }
|
|
|
}
|