|
@@ -263,56 +263,60 @@ public class PaperLibraryServiceImpl extends ServiceImpl<PaperLibraryMapper, Pap
|
|
|
|
|
|
@Transactional
|
|
|
@Override
|
|
|
- public boolean rebind(Long paperLibraryId, Long studentId) {
|
|
|
- PaperLibrary paperLibrary = this.getById(paperLibraryId);
|
|
|
- if (paperLibrary == null) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("图片数据不存在");
|
|
|
- }
|
|
|
+ public boolean rebind(List<Long> paperLibraryIds, Long studentId) {
|
|
|
ExamStudent student = examStudentService.getById(studentId);
|
|
|
PaperScanTask task = paperScanTaskService.getByExamIdAndCourseCode(student.getExamId(), student.getCourseCode());
|
|
|
if (Objects.isNull(task)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("考生找不到扫描任务");
|
|
|
}
|
|
|
|
|
|
- // 自己绑定自己,直接返回
|
|
|
- if (paperLibrary.getStudentId() != null && paperLibrary.getStudentId().equals(studentId)) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- PathSequenceVo pathSequenceVo = null;
|
|
|
- try {
|
|
|
- // 将图片复制到学号目录下,并删除原图片
|
|
|
- pathSequenceVo = copyImageToStudentCode(paperLibrary, task, studentId, UploadFileEnum.IMAGE);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("纠错操作复制图片失败");
|
|
|
- throw ExceptionResultEnum.ERROR.exception("纠错失败");
|
|
|
- }
|
|
|
+ for (Long paperLibraryId : paperLibraryIds) {
|
|
|
+ PaperLibrary paperLibrary = this.getById(paperLibraryId);
|
|
|
+ if (paperLibrary == null) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("图片数据不存在");
|
|
|
+ }
|
|
|
|
|
|
- // 更新绑定考生ID
|
|
|
- UpdateWrapper<PaperLibrary> updateWrapper = new UpdateWrapper<>();
|
|
|
- LambdaUpdateWrapper<PaperLibrary> lambda = updateWrapper.lambda();
|
|
|
- lambda.set(PaperLibrary::getStudentId, studentId);
|
|
|
- lambda.set(PaperLibrary::getPaperScanTaskId, task.getId());
|
|
|
- if (pathSequenceVo != null) {
|
|
|
- lambda.set(PaperLibrary::getPath, pathSequenceVo.getPath());
|
|
|
- lambda.set(PaperLibrary::getSequence, pathSequenceVo.getSequence());
|
|
|
- }
|
|
|
- lambda.eq(PaperLibrary::getId, paperLibraryId);
|
|
|
- this.update(updateWrapper);
|
|
|
- // 更新考生绑定数量
|
|
|
- if (paperLibrary.getStudentId() != null) {
|
|
|
- examStudentService.updateBindCount(paperLibrary.getStudentId());
|
|
|
- // 清除pdf文件记录
|
|
|
- examStudentService.clearPdfFilePath(paperLibrary.getStudentId());
|
|
|
+ // 自己绑定自己,直接返回
|
|
|
+ if (paperLibrary.getStudentId() != null && paperLibrary.getStudentId().equals(studentId)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ PathSequenceVo pathSequenceVo;
|
|
|
+ try {
|
|
|
+ // 将图片复制到学号目录下,并删除原图片
|
|
|
+ pathSequenceVo = copyImageToStudentCode(paperLibrary, task, studentId, UploadFileEnum.IMAGE);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("纠错操作复制图片失败");
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("纠错失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新绑定考生ID
|
|
|
+ UpdateWrapper<PaperLibrary> updateWrapper = new UpdateWrapper<>();
|
|
|
+ LambdaUpdateWrapper<PaperLibrary> lambda = updateWrapper.lambda();
|
|
|
+ lambda.set(PaperLibrary::getStudentId, studentId);
|
|
|
+ lambda.set(PaperLibrary::getPaperScanTaskId, task.getId());
|
|
|
+ if (pathSequenceVo != null) {
|
|
|
+ lambda.set(PaperLibrary::getPath, pathSequenceVo.getPath());
|
|
|
+ lambda.set(PaperLibrary::getSequence, pathSequenceVo.getSequence());
|
|
|
+ }
|
|
|
+ lambda.eq(PaperLibrary::getId, paperLibraryId);
|
|
|
+ this.update(updateWrapper);
|
|
|
+ // 更新考生绑定数量
|
|
|
+ if (paperLibrary.getStudentId() != null) {
|
|
|
+ examStudentService.updateBindCount(paperLibrary.getStudentId());
|
|
|
+ // 清除pdf文件记录
|
|
|
+ examStudentService.clearPdfFilePath(paperLibrary.getStudentId());
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新扫描任务扫描考生数量、扫描图片数量
|
|
|
+ paperScanTaskService.updateScanCount(paperLibrary.getPaperScanTaskId());
|
|
|
+ if(!task.getId().equals(paperLibrary.getPaperScanTaskId())) {
|
|
|
+ paperScanTaskService.updateScanCount(task.getId());
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
examStudentService.updateBindCount(studentId);
|
|
|
// 清除pdf文件记录
|
|
|
examStudentService.clearPdfFilePath(studentId);
|
|
|
-
|
|
|
- //更新扫描任务扫描考生数量、扫描图片数量
|
|
|
- paperScanTaskService.updateScanCount(paperLibrary.getPaperScanTaskId());
|
|
|
- if(!task.getId().equals(paperLibrary.getPaperScanTaskId())) {
|
|
|
- paperScanTaskService.updateScanCount(task.getId());
|
|
|
- }
|
|
|
return true;
|
|
|
}
|
|
|
|