瀏覽代碼

1.0.5 update

xiaofei 9 月之前
父節點
當前提交
ec78fcdef7

+ 1 - 1
paper-library-business/src/main/java/com/qmth/paper/library/business/service/PaperLibraryService.java

@@ -34,7 +34,7 @@ public interface PaperLibraryService extends IService<PaperLibrary> {
 
     void removeByPaperScanTaskId(Long paperScanTaskId);
 
-    boolean rebind(Long paperLibraryId, Long studentId);
+    boolean rebind(List<Long> paperLibraryIds, Long studentId);
 
     int countByStudentId(Long studentId);
 

+ 43 - 39
paper-library-business/src/main/java/com/qmth/paper/library/business/service/impl/PaperLibraryServiceImpl.java

@@ -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;
     }
 

+ 3 - 3
paper-library/src/main/java/com/qmth/paper/library/api/DocManageController.java

@@ -129,9 +129,9 @@ public class DocManageController {
     @ApiOperation(value = "重新绑定")
     @PostMapping("/rebind")
     @ApiResponses({@ApiResponse(code = 200, message = "查询成功", response = Result.class)})
-    public Result rebind(@ApiParam(value = "图片ID", required = true) @RequestParam Long paperLibraryId,
-                         @ApiParam(value = "考生ID", required = true) @RequestParam() Long studentId) {
-        return ResultUtil.ok(paperLibraryService.rebind(paperLibraryId, studentId));
+    public Result rebind(@ApiParam(value = "图片ID", required = true) @RequestParam List<Long> paperLibraryIds,
+                         @ApiParam(value = "考生ID", required = true) @RequestParam Long studentId) {
+        return ResultUtil.ok(paperLibraryService.rebind(paperLibraryIds, studentId));
     }
 
     @ApiOperation(value = "其它文件详情")