|
@@ -1,16 +1,5 @@
|
|
|
package com.qmth.teachcloud.mark.service.impl;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
-import javax.validation.constraints.NotNull;
|
|
|
-
|
|
|
-import org.apache.commons.collections4.CollectionUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
-
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
@@ -25,19 +14,19 @@ import com.qmth.teachcloud.mark.bean.papermigrate.PaperMigrateVo;
|
|
|
import com.qmth.teachcloud.mark.bean.scananswer.StudentPaperVo;
|
|
|
import com.qmth.teachcloud.mark.bean.scanpaper.PaperVo;
|
|
|
import com.qmth.teachcloud.mark.dto.mark.score.StudentPaperDetailDto;
|
|
|
-import com.qmth.teachcloud.mark.entity.MarkStudent;
|
|
|
-import com.qmth.teachcloud.mark.entity.ScanAnswerCard;
|
|
|
-import com.qmth.teachcloud.mark.entity.ScanPaper;
|
|
|
-import com.qmth.teachcloud.mark.entity.ScanPaperPage;
|
|
|
-import com.qmth.teachcloud.mark.entity.ScanStudentPaper;
|
|
|
+import com.qmth.teachcloud.mark.entity.*;
|
|
|
import com.qmth.teachcloud.mark.enums.LockType;
|
|
|
import com.qmth.teachcloud.mark.mapper.ScanPaperMapper;
|
|
|
-import com.qmth.teachcloud.mark.service.MarkStudentService;
|
|
|
-import com.qmth.teachcloud.mark.service.ScanAnswerCardService;
|
|
|
-import com.qmth.teachcloud.mark.service.ScanAnswerCardSubjectService;
|
|
|
-import com.qmth.teachcloud.mark.service.ScanPaperPageService;
|
|
|
-import com.qmth.teachcloud.mark.service.ScanPaperService;
|
|
|
-import com.qmth.teachcloud.mark.service.ScanStudentPaperService;
|
|
|
+import com.qmth.teachcloud.mark.service.*;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import javax.validation.constraints.NotNull;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -49,205 +38,206 @@ import com.qmth.teachcloud.mark.service.ScanStudentPaperService;
|
|
|
*/
|
|
|
@Service
|
|
|
public class ScanPaperServiceImpl extends ServiceImpl<ScanPaperMapper, ScanPaper> implements ScanPaperService {
|
|
|
- @Autowired
|
|
|
- private ScanAnswerCardService answerCardService;
|
|
|
- @Autowired
|
|
|
- private ScanPaperPageService paperPageService;
|
|
|
- @Autowired
|
|
|
- private MarkStudentService markStudentService;
|
|
|
- @Autowired
|
|
|
- private ConcurrentService concurrentService;
|
|
|
- @Autowired
|
|
|
- private ScanStudentPaperService scanStudentPaperService;
|
|
|
- @Autowired
|
|
|
- private ScanAnswerCardSubjectService scanAnswerCardSubjectService;
|
|
|
+ @Autowired
|
|
|
+ private ScanAnswerCardService answerCardService;
|
|
|
+ @Autowired
|
|
|
+ private ScanPaperPageService paperPageService;
|
|
|
+ @Autowired
|
|
|
+ private MarkStudentService markStudentService;
|
|
|
+ @Autowired
|
|
|
+ private ConcurrentService concurrentService;
|
|
|
+ @Autowired
|
|
|
+ private ScanStudentPaperService scanStudentPaperService;
|
|
|
+ @Autowired
|
|
|
+ private ScanAnswerCardSubjectService scanAnswerCardSubjectService;
|
|
|
|
|
|
- /**
|
|
|
- * 全量更新paper和所属的page集合,并刷新paper相关属性
|
|
|
- *
|
|
|
- * @param paper
|
|
|
- * @param pages
|
|
|
- */
|
|
|
- @Override
|
|
|
- @Transactional
|
|
|
- public void savePaperAndPages(@NotNull ScanPaper paper, @NotNull List<ScanPaperPage> pages) {
|
|
|
- // 与卡格式校验
|
|
|
- ScanAnswerCard answerCard = answerCardService.findByExamAndNumber(paper.getExamId(), paper.getCardNumber());
|
|
|
- if (answerCard == null) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("卡格式不存在, cardNumber=" + paper.getCardNumber());
|
|
|
- }
|
|
|
- if (pages.size() != (answerCard.getSinglePage() ? 1 : 2)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("paper.page数量与卡格式不符, cardNumber=" + paper.getCardNumber());
|
|
|
- }
|
|
|
- // 更新paper属性
|
|
|
- paper.setPageCount(pages.size());
|
|
|
- paper.setQuestionFilled(false);
|
|
|
- // 判断是否客观题已填涂
|
|
|
- for (ScanPaperPage page : pages) {
|
|
|
- paper.setQuestionFilled(paper.getQuestionFilled() || page.isQuestionFilled());
|
|
|
- }
|
|
|
- // 保存paper数据
|
|
|
- saveOrUpdate(paper);
|
|
|
- for (ScanPaperPage page : pages) {
|
|
|
- // FIXME
|
|
|
- // 验证原图与裁切图已上传
|
|
|
+ /**
|
|
|
+ * 全量更新paper和所属的page集合,并刷新paper相关属性
|
|
|
+ *
|
|
|
+ * @param paper
|
|
|
+ * @param pages
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void savePaperAndPages(@NotNull ScanPaper paper, @NotNull List<ScanPaperPage> pages) {
|
|
|
+ // 与卡格式校验
|
|
|
+ ScanAnswerCard answerCard = answerCardService.findByExamAndNumber(paper.getExamId(), paper.getCardNumber());
|
|
|
+ if (answerCard == null) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("卡格式不存在, cardNumber=" + paper.getCardNumber());
|
|
|
+ }
|
|
|
+ if (pages.size() != (answerCard.getSinglePage() ? 1 : 2)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("paper.page数量与卡格式不符, cardNumber=" + paper.getCardNumber());
|
|
|
+ }
|
|
|
+ // 更新paper属性
|
|
|
+ paper.setPageCount(pages.size());
|
|
|
+ paper.setQuestionFilled(false);
|
|
|
+ // 判断是否客观题已填涂
|
|
|
+ for (ScanPaperPage page : pages) {
|
|
|
+ paper.setQuestionFilled(paper.getQuestionFilled() || page.isQuestionFilled());
|
|
|
+ }
|
|
|
+ // 保存paper数据
|
|
|
+ saveOrUpdate(paper);
|
|
|
+ for (ScanPaperPage page : pages) {
|
|
|
+ // FIXME
|
|
|
+ // 验证原图与裁切图已上传
|
|
|
// if (!fileStore.exist(page.getSheetPath())) {
|
|
|
// throw ExceptionResultEnum.ERROR.exception("原图不存在:" + page.getSheetPath());
|
|
|
// }
|
|
|
- page.setPaperId(paper.getId());
|
|
|
- }
|
|
|
- // 保存page数据
|
|
|
- paperPageService.saveOrUpdateBatch(pages);
|
|
|
- }
|
|
|
+ page.setPaperId(paper.getId());
|
|
|
+ }
|
|
|
+ // 保存page数据
|
|
|
+ paperPageService.saveOrUpdateBatch(pages);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getAssignedCount(Long examId, Boolean checked) {
|
|
|
+ QueryWrapper<ScanPaper> wrapper = new QueryWrapper<>();
|
|
|
+ LambdaQueryWrapper<ScanPaper> lw = wrapper.lambda();
|
|
|
+ lw.eq(ScanPaper::getExamId, examId);
|
|
|
+ lw.eq(ScanPaper::getAssigned, true);
|
|
|
+ if (checked != null) {
|
|
|
+ lw.eq(ScanPaper::getAssignConfirmed, checked);
|
|
|
+ }
|
|
|
+ return baseMapper.selectCount(wrapper);
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public int getAssignedCount(Long examId, Boolean checked) {
|
|
|
- QueryWrapper<ScanPaper> wrapper = new QueryWrapper<>();
|
|
|
- LambdaQueryWrapper<ScanPaper> lw = wrapper.lambda();
|
|
|
- lw.eq(ScanPaper::getExamId, examId);
|
|
|
- lw.eq(ScanPaper::getAssigned, true);
|
|
|
- if (checked != null) {
|
|
|
- lw.eq(ScanPaper::getAssignConfirmed, checked);
|
|
|
- }
|
|
|
- return baseMapper.selectCount(wrapper);
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public List<StudentPaperDetailDto> listStudentPaperDetail(Long studentId) {
|
|
|
+ return this.baseMapper.listStudentPaperDetail(studentId);
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public List<StudentPaperDetailDto> listStudentPaperDetail(Long studentId) {
|
|
|
- return this.baseMapper.listStudentPaperDetail(studentId);
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public int getCountByExamAndCardNumber(Long examId, Integer number) {
|
|
|
+ LambdaQueryWrapper<ScanPaper> lw = new LambdaQueryWrapper<>();
|
|
|
+ lw.eq(ScanPaper::getExamId, examId);
|
|
|
+ lw.eq(ScanPaper::getCardNumber, number);
|
|
|
+ return this.count(lw);
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public int getCountByExamAndCardNumber(Long examId, Integer number) {
|
|
|
- LambdaQueryWrapper<ScanPaper> lw = new LambdaQueryWrapper<>();
|
|
|
- lw.eq(ScanPaper::getExamId, examId);
|
|
|
- lw.eq(ScanPaper::getCardNumber, number);
|
|
|
- return this.count(lw);
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public List<PaperVo> findStudentPaper(Long studentId) {
|
|
|
+ return baseMapper.findStudentPaper(studentId);
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public List<PaperVo> findStudentPaper(Long studentId) {
|
|
|
- return baseMapper.findStudentPaper(studentId);
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public List<StudentPaperVo> listByStudentIds(List<Long> paramList) {
|
|
|
+ return baseMapper.listByStudentIds(paramList);
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public List<StudentPaperVo> listByStudentIds(List<Long> paramList) {
|
|
|
- return baseMapper.listByStudentIds(paramList);
|
|
|
- }
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public PaperMigrateVo paperMigrate(SysUser user, PaperMigrateDomain domain) {
|
|
|
+ // 查找修改paper
|
|
|
+ ScanPaper paper = getById(domain.getPaperId());
|
|
|
+ if (paper == null) {
|
|
|
+ throw new ParameterException("题卡信息未找到, paperId=" + domain.getPaperId());
|
|
|
+ }
|
|
|
+ // 查找目标考生
|
|
|
+ MarkStudent student = markStudentService.findByExamIdAndCoursePaperIdAndStudentCode(domain.getExamId(),
|
|
|
+ domain.getCoursePaperId(), domain.getStudentCode());
|
|
|
+ if (student == null) {
|
|
|
+ throw new ParameterException("考生信息未找到");
|
|
|
+ }
|
|
|
+ // 目标考生已扫描时,输入卡格式需要保持一致
|
|
|
+ if (student.getCardNumber() != null && !student.getCardNumber().equals(domain.getCardNumber())) {
|
|
|
+ throw new ParameterException("卡格式与目标考生不一致");
|
|
|
+ }
|
|
|
+ // 校验卡格式
|
|
|
+ ScanAnswerCard answerCard = answerCardService.findByExamAndNumber(domain.getExamId(), domain.getCardNumber());
|
|
|
+ if (answerCard == null) {
|
|
|
+ throw new ParameterException("卡格式信息未找到");
|
|
|
+ }
|
|
|
+ // 验证卡格式所属科目
|
|
|
+ boolean allowSubject = scanAnswerCardSubjectService.checkSubject(answerCard.getExamId(), answerCard.getNumber(),
|
|
|
+ student.getCoursePaperId());
|
|
|
+ if (!allowSubject) {
|
|
|
+ throw new ParameterException("卡格式与考生科目不一致");
|
|
|
+ }
|
|
|
+ // cardNumber或paperNumber有变化,都需要重新识别
|
|
|
+ if ((!paper.getNumber().equals(domain.getPaperNumber())
|
|
|
+ || !paper.getCardNumber().equals(domain.getCardNumber()))
|
|
|
+ && CollectionUtils.isEmpty(domain.getPages())) {
|
|
|
+ throw new ParameterException("卡格式有变化需要重新识别, pages信息不能为空");
|
|
|
+ }
|
|
|
+ // 指定paper现有绑定考生
|
|
|
+ MarkStudent previousStudent = null;
|
|
|
+ ScanStudentPaper previousStudentPaper = scanStudentPaperService.findByPaperId(domain.getPaperId());
|
|
|
+ if (previousStudentPaper != null) {
|
|
|
+ // 考生没变,张数也没变
|
|
|
+ if (previousStudentPaper.getStudentId().equals(student.getId())
|
|
|
+ && previousStudentPaper.getPaperIndex().equals(domain.getPaperNumber())) {
|
|
|
+ throw new ParameterException("该题卡已绑定该考生");
|
|
|
+ }
|
|
|
+ // 考生ID变了才需要获取原考生
|
|
|
+ if (!previousStudentPaper.getStudentId().equals(student.getId())) {
|
|
|
+ previousStudent = markStudentService.getById(previousStudentPaper.getStudentId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (previousStudent != null) {
|
|
|
+ concurrentService.getReadWriteLock(LockType.STUDENT + "-" + previousStudent.getId()).writeLock().lock();
|
|
|
+ }
|
|
|
+ concurrentService.getReadWriteLock(LockType.STUDENT + "-" + student.getId()).writeLock().lock();
|
|
|
+ try {
|
|
|
+ if (previousStudentPaper != null) {
|
|
|
+ // 解绑paper和原有考生
|
|
|
+ if (previousStudent != null) {
|
|
|
+ List<ScanStudentPaper> studentPaperList = scanStudentPaperService
|
|
|
+ .findByStudentId(previousStudent.getId()).stream()
|
|
|
+ .filter(entity -> !entity.getPaperId().equals(previousStudentPaper.getPaperId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ markStudentService.updateStudentAndPaper(user, previousStudent.getId(), studentPaperList);
|
|
|
+ }
|
|
|
+ // 考生没变,直接解绑paper
|
|
|
+ else {
|
|
|
+ scanStudentPaperService.removeByStudentIdAndPaperId(previousStudentPaper.getStudentId(),
|
|
|
+ previousStudentPaper.getPaperId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 更新paper属性
|
|
|
+ paper.setCardNumber(domain.getCardNumber());
|
|
|
+ paper.setNumber(domain.getPaperNumber());
|
|
|
+ // 修改的paper强制置为人工绑定
|
|
|
+ paper.setAssigned(true);
|
|
|
+ // 原有mismatch标记需要清除
|
|
|
+ paper.setMismatch(false);
|
|
|
+ paper.setUpdaterId(user.getId());
|
|
|
+ paper.setUpdateTime(System.currentTimeMillis());
|
|
|
+ if (CollectionUtils.isNotEmpty(domain.getPages())) {
|
|
|
+ // 重新识别时更新所有page
|
|
|
+ List<ScanPaperPage> pages = new ArrayList<>();
|
|
|
+ for (PaperMigratePage page : domain.getPages()) {
|
|
|
+ pages.add(page.update(paperPageService.findPaperIdAndIndex(paper.getId(), page.getIndex())));
|
|
|
+ }
|
|
|
+ savePaperAndPages(paper, pages);
|
|
|
+ } else {
|
|
|
+ saveOrUpdate(paper);
|
|
|
+ }
|
|
|
+ // 查找目标考生现有绑定paper
|
|
|
+ boolean exist = false;
|
|
|
+ List<ScanStudentPaper> currentStudentPaperList = scanStudentPaperService.findByStudentId(student.getId());
|
|
|
+ for (ScanStudentPaper current : currentStudentPaperList) {
|
|
|
+ if (current.getPaperIndex().equals(paper.getNumber())) {
|
|
|
+ exist = true;
|
|
|
+ updateMismatch(current.getPaperId(), true);
|
|
|
+ current.setPaperId(paper.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!exist) {
|
|
|
+ currentStudentPaperList.add(new ScanStudentPaper(student.getId(), paper.getNumber(), paper.getId()));
|
|
|
+ }
|
|
|
+ // 更新目标考生状态
|
|
|
+ markStudentService.updateStudentAndPaper(user, student.getId(), currentStudentPaperList);
|
|
|
+ // 返回数据结果
|
|
|
+ return PaperMigrateVo.create(domain.getPaperId());
|
|
|
+ } finally {
|
|
|
+ concurrentService.getReadWriteLock(LockType.STUDENT + "-" + student.getId()).writeLock().unlock();
|
|
|
+ if (previousStudent != null) {
|
|
|
+ concurrentService.getReadWriteLock(LockType.STUDENT + "-" + previousStudent.getId()).writeLock()
|
|
|
+ .unlock();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- @Transactional
|
|
|
- @Override
|
|
|
- public PaperMigrateVo paperMigrate(SysUser user, PaperMigrateDomain domain) {
|
|
|
- // 查找修改paper
|
|
|
- ScanPaper paper = getById(domain.getPaperId());
|
|
|
- if (paper == null) {
|
|
|
- throw new ParameterException("题卡信息未找到, paperId=" + domain.getPaperId());
|
|
|
- }
|
|
|
- // 查找目标考生
|
|
|
- MarkStudent student = markStudentService.findByExamIdAndCoursePaperIdAndStudentCode(domain.getExamId(),
|
|
|
- domain.getCoursePaperId(), domain.getStudentCode());
|
|
|
- if (student == null) {
|
|
|
- throw new ParameterException("考生信息未找到");
|
|
|
- }
|
|
|
- // 目标考生已扫描时,输入卡格式需要保持一致
|
|
|
- if (student.getCardNumber() != null && !student.getCardNumber().equals(domain.getCardNumber())) {
|
|
|
- throw new ParameterException("卡格式与目标考生不一致");
|
|
|
- }
|
|
|
- // 校验卡格式
|
|
|
- ScanAnswerCard answerCard = answerCardService.findByExamAndNumber(domain.getExamId(), domain.getCardNumber());
|
|
|
- if (answerCard == null) {
|
|
|
- throw new ParameterException("卡格式信息未找到");
|
|
|
- }
|
|
|
- // 验证卡格式所属科目
|
|
|
- boolean allowSubject = scanAnswerCardSubjectService.checkSubject(answerCard.getExamId(), answerCard.getNumber(),
|
|
|
- student.getCoursePaperId());
|
|
|
- if (!allowSubject) {
|
|
|
- throw new ParameterException("卡格式与考生科目不一致");
|
|
|
- }
|
|
|
- // cardNumber或paperNumber有变化,都需要重新识别
|
|
|
- if ((!paper.getNumber().equals(domain.getPaperNumber())
|
|
|
- || !paper.getCardNumber().equals(domain.getCardNumber()))
|
|
|
- && CollectionUtils.isEmpty(domain.getPages())) {
|
|
|
- throw new ParameterException("卡格式有变化需要重新识别, pages信息不能为空");
|
|
|
- }
|
|
|
- // 指定paper现有绑定考生
|
|
|
- MarkStudent previousStudent = null;
|
|
|
- ScanStudentPaper previousStudentPaper = scanStudentPaperService.findByPaperId(domain.getPaperId());
|
|
|
- if (previousStudentPaper != null) {
|
|
|
- // 考生没变,张数也没变
|
|
|
- if (previousStudentPaper.getStudentId().equals(student.getId())
|
|
|
- && previousStudentPaper.getPaperIndex().equals(domain.getPaperNumber())) {
|
|
|
- throw new ParameterException("该题卡已绑定该考生");
|
|
|
- }
|
|
|
- // 考生ID变了才需要获取原考生
|
|
|
- if (!previousStudentPaper.getStudentId().equals(student.getId())) {
|
|
|
- previousStudent = markStudentService.getById(previousStudentPaper.getStudentId());
|
|
|
- }
|
|
|
- }
|
|
|
- if (previousStudent != null) {
|
|
|
- concurrentService.getReadWriteLock(LockType.STUDENT + "-" + previousStudent.getId()).writeLock().lock();
|
|
|
- }
|
|
|
- concurrentService.getReadWriteLock(LockType.STUDENT + "-" + student.getId()).writeLock().lock();
|
|
|
- try {
|
|
|
- if (previousStudentPaper != null) {
|
|
|
- // 解绑paper和原有考生
|
|
|
- if (previousStudent != null) {
|
|
|
- List<ScanStudentPaper> studentPaperList = scanStudentPaperService
|
|
|
- .findByStudentId(previousStudent.getId()).stream()
|
|
|
- .filter(entity -> !entity.getPaperId().equals(previousStudentPaper.getPaperId()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- markStudentService.updateStudentAndPaper(user, previousStudent.getId(), studentPaperList);
|
|
|
- }
|
|
|
- // 考生没变,直接解绑paper
|
|
|
- else {
|
|
|
- scanStudentPaperService.removeByStudentIdAndPaperId(previousStudentPaper.getStudentId(),
|
|
|
- previousStudentPaper.getPaperId());
|
|
|
- }
|
|
|
- }
|
|
|
- // 更新paper属性
|
|
|
- paper.setCardNumber(domain.getCardNumber());
|
|
|
- paper.setNumber(domain.getPaperNumber());
|
|
|
- // 修改的paper强制置为人工绑定
|
|
|
- paper.setAssigned(true);
|
|
|
- // 原有mismatch标记需要清除
|
|
|
- paper.setMismatch(false);
|
|
|
- paper.setUpdaterId(user.getId());
|
|
|
- paper.setUpdateTime(System.currentTimeMillis());
|
|
|
- if (CollectionUtils.isNotEmpty(domain.getPages())) {
|
|
|
- // 重新识别时更新所有page
|
|
|
- List<ScanPaperPage> pages = new ArrayList<>();
|
|
|
- for (PaperMigratePage page : domain.getPages()) {
|
|
|
- pages.add(page.update(paperPageService.findPaperIdAndIndex(paper.getId(), page.getIndex())));
|
|
|
- }
|
|
|
- savePaperAndPages(paper, pages);
|
|
|
- } else {
|
|
|
- saveOrUpdate(paper);
|
|
|
- }
|
|
|
- // 查找目标考生现有绑定paper
|
|
|
- boolean exist = false;
|
|
|
- List<ScanStudentPaper> currentStudentPaperList = scanStudentPaperService.findByStudentId(student.getId());
|
|
|
- for (ScanStudentPaper current : currentStudentPaperList) {
|
|
|
- if (current.getPaperIndex().equals(paper.getNumber())) {
|
|
|
- exist = true;
|
|
|
- updateMismatch(current.getPaperId(), true);
|
|
|
- current.setPaperId(paper.getId());
|
|
|
- }
|
|
|
- }
|
|
|
- if (!exist) {
|
|
|
- currentStudentPaperList.add(new ScanStudentPaper(student.getId(), paper.getNumber(), paper.getId()));
|
|
|
- }
|
|
|
- // 更新目标考生状态
|
|
|
- markStudentService.updateStudentAndPaper(user, student.getId(), currentStudentPaperList);
|
|
|
- // 返回数据结果
|
|
|
- return PaperMigrateVo.create(domain.getPaperId());
|
|
|
- } finally {
|
|
|
- concurrentService.getReadWriteLock(LockType.STUDENT + "-" + student.getId()).writeLock().unlock();
|
|
|
- if (previousStudent != null) {
|
|
|
- concurrentService.getReadWriteLock(LockType.STUDENT + "-" + previousStudent.getId()).writeLock()
|
|
|
- .unlock();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public boolean updateMismatch(Long id, boolean mismatch) {
|
|
@@ -256,4 +246,16 @@ public class ScanPaperServiceImpl extends ServiceImpl<ScanPaperMapper, ScanPaper
|
|
|
lw.eq(ScanPaper::getId, id);
|
|
|
return this.update(lw);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean isScanByExamIdAndPaperNumber(Long examId, String paperNumber) {
|
|
|
+ List<ScanAnswerCard> scanAnswerCardList = answerCardService.listByExamIdAndPaperNumber(examId, paperNumber);
|
|
|
+ for (ScanAnswerCard scanAnswerCard : scanAnswerCardList) {
|
|
|
+ int countByExamAndCardNumber = this.getCountByExamAndCardNumber(examId, scanAnswerCard.getNumber());
|
|
|
+ if (countByExamAndCardNumber > 0) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|