Răsfoiți Sursa

1.0.5 优化

haogh 10 luni în urmă
părinte
comite
0489803e85

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

@@ -14,7 +14,9 @@ public interface ClientService {
 
 
     void checkPrivilege(Long userId);
     void checkPrivilege(Long userId);
 
 
-    boolean pictureUpload(Long paperScanTaskId, String studentCode, Integer x, Integer y, Integer width, Integer height, Integer rotate, MultipartFile frontFile, String frontMd5, MultipartFile versoFile, String versoMd5, Long scanUserId, String batchNo);
+    Long pictureUpload(Long paperScanTaskId, String studentCode, Integer x, Integer y, Integer width, Integer height, Integer rotate, MultipartFile frontFile, String frontMd5, MultipartFile versoFile, String versoMd5, Long scanUserId, String batchNo);
 
 
     boolean otherUpload(Long paperScanTaskId, MultipartFile frontFile, String frontMd5, MultipartFile versoFile, String versoMd5, Long fileTypeId, String classRoomName);
     boolean otherUpload(Long paperScanTaskId, MultipartFile frontFile, String frontMd5, MultipartFile versoFile, String versoMd5, Long fileTypeId, String classRoomName);
+
+    boolean updateCount(Long paperScanTaskId, Long examId, Long studentId, Long scanUserId, String batchNo);
 }
 }

+ 20 - 5
paper-library-business/src/main/java/com/qmth/paper/library/business/service/impl/ClientServiceImpl.java

@@ -79,7 +79,7 @@ public class ClientServiceImpl implements ClientService {
 
 
     @Transactional
     @Transactional
     @Override
     @Override
-    public boolean pictureUpload(Long paperScanTaskId, String studentCode, Integer x, Integer y, Integer width, Integer height, Integer rotate, MultipartFile frontFile, String frontMd5, MultipartFile versoFile, String versoMd5, Long scanUserId, String batchNo) {
+    public Long pictureUpload(Long paperScanTaskId, String studentCode, Integer x, Integer y, Integer width, Integer height, Integer rotate, MultipartFile frontFile, String frontMd5, MultipartFile versoFile, String versoMd5, Long scanUserId, String batchNo) {
 
 
         if (Objects.isNull(frontFile) || frontFile.getSize() == 0) {
         if (Objects.isNull(frontFile) || frontFile.getSize() == 0) {
             throw ExceptionResultEnum.ERROR.exception("frontFile(正面图片)为空");
             throw ExceptionResultEnum.ERROR.exception("frontFile(正面图片)为空");
@@ -135,8 +135,9 @@ public class ClientServiceImpl implements ClientService {
             paperLibrary.setSequence(pathSequenceVo.getSequence());
             paperLibrary.setSequence(pathSequenceVo.getSequence());
             paperLibrary.setBindResult(recognitionVo.getBindResult());
             paperLibrary.setBindResult(recognitionVo.getBindResult());
             paperLibrary.setRecognizeResult(recognitionVo.getRecognizeResult());
             paperLibrary.setRecognizeResult(recognitionVo.getRecognizeResult());
-            boolean save = paperLibraryService.save(paperLibrary);
-            if (save) {
+            paperLibraryService.save(paperLibrary);
+            // 在controller层调用更新和添加锁
+/*            if (save) {
                 // 统计考生数量
                 // 统计考生数量
 //                int studentCount = examStudentService.countByExamIdAndCourseCode(examStudent.getExamId(), examStudent.getCourseCode());
 //                int studentCount = examStudentService.countByExamIdAndCourseCode(examStudent.getExamId(), examStudent.getCourseCode());
                 // 更新扫描任务扫描考生数量、扫描图片数量
                 // 更新扫描任务扫描考生数量、扫描图片数量
@@ -147,8 +148,8 @@ public class ClientServiceImpl implements ClientService {
                 basicBatchNumberService.updateBatchNo(paperScanTask.getExamId(), scanUserId, batchNo);
                 basicBatchNumberService.updateBatchNo(paperScanTask.getExamId(), scanUserId, batchNo);
                 // 清除pdf文件记录
                 // 清除pdf文件记录
                 examStudentService.clearPdfFilePath(examStudent.getId());
                 examStudentService.clearPdfFilePath(examStudent.getId());
-            }
-            return true;
+            }*/
+            return examStudent.getId();
 
 
         } catch (Exception e) {
         } catch (Exception e) {
             throw ExceptionResultEnum.ERROR.exception("保存图片失败:" + e.getMessage());
             throw ExceptionResultEnum.ERROR.exception("保存图片失败:" + e.getMessage());
@@ -204,4 +205,18 @@ public class ClientServiceImpl implements ClientService {
             lockService.unlock(LockType.UPLOAD_OTHER_FILE, paperScanTaskId, fileTypeId);
             lockService.unlock(LockType.UPLOAD_OTHER_FILE, paperScanTaskId, fileTypeId);
         }
         }
     }
     }
+
+    @Transactional
+    @Override
+    public boolean updateCount(Long paperScanTaskId, Long examId, Long studentId, Long scanUserId, String batchNo) {
+        // 更新扫描任务扫描考生数量、扫描图片数量
+        paperScanTaskService.updateScanCount(paperScanTaskId);
+        // 更新考生绑定图片数量
+        examStudentService.updateBindCount(studentId);
+        // 更新批次号
+        basicBatchNumberService.updateBatchNo(examId, scanUserId, batchNo);
+        // 清除pdf文件记录
+        examStudentService.clearPdfFilePath(studentId);
+        return true;
+    }
 }
 }

+ 16 - 17
paper-library-business/src/main/java/com/qmth/paper/library/business/service/impl/PaperScanTaskServiceImpl.java

@@ -21,7 +21,6 @@ import com.qmth.paper.library.common.enums.RecognitionTypeEnum;
 import com.qmth.paper.library.common.enums.StoreTypeEnum;
 import com.qmth.paper.library.common.enums.StoreTypeEnum;
 import com.qmth.paper.library.common.enums.UploadFileEnum;
 import com.qmth.paper.library.common.enums.UploadFileEnum;
 import com.qmth.paper.library.common.lock.LockService;
 import com.qmth.paper.library.common.lock.LockService;
-import com.qmth.paper.library.common.lock.LockType;
 import com.qmth.paper.library.common.service.BasicSchoolService;
 import com.qmth.paper.library.common.service.BasicSchoolService;
 import com.qmth.paper.library.common.service.BasicSemesterService;
 import com.qmth.paper.library.common.service.BasicSemesterService;
 import com.qmth.paper.library.common.util.FileStoreUtil;
 import com.qmth.paper.library.common.util.FileStoreUtil;
@@ -239,21 +238,21 @@ public class PaperScanTaskServiceImpl extends ServiceImpl<PaperScanTaskMapper, P
 
 
     @Override
     @Override
     public void updateScanCount(Long paperScanTaskId) {
     public void updateScanCount(Long paperScanTaskId) {
-        try {
-            lockService.waitlock(LockType.UPDATE_SCAN_PAPER_COUNT, paperScanTaskId);
-//            // 统计扫描张数
-//            int scanCount = paperLibraryService.countScanCount(paperScanTaskId);
-//            // 统计扫描学生数
-//            int scanStudentCount = paperLibraryService.countScanStudentCount(paperScanTaskId);
-//            // 总扫描数
-//            UpdateWrapper<PaperScanTask> updateWrapper = new UpdateWrapper<>();
-//            updateWrapper.lambda().set(PaperScanTask::getScanStudentCount, scanStudentCount)
-//                    .set(PaperScanTask::getScanCount, scanCount)
-//                    .eq(PaperScanTask::getId, paperScanTaskId);
-//            this.update(updateWrapper);
-            this.baseMapper.updateScanCount(paperScanTaskId);
-        } finally {
-            lockService.unlock(LockType.UPDATE_SCAN_PAPER_COUNT, paperScanTaskId);
-        }
+//        try {
+//            lockService.waitlock(LockType.UPDATE_SCAN_PAPER_COUNT, paperScanTaskId);
+            // 统计扫描张数
+            int scanCount = paperLibraryService.countScanCount(paperScanTaskId);
+            // 统计扫描学生数
+            int scanStudentCount = paperLibraryService.countScanStudentCount(paperScanTaskId);
+            // 总扫描数
+            UpdateWrapper<PaperScanTask> updateWrapper = new UpdateWrapper<>();
+            updateWrapper.lambda().set(PaperScanTask::getScanStudentCount, scanStudentCount)
+                    .set(PaperScanTask::getScanCount, scanCount)
+                    .eq(PaperScanTask::getId, paperScanTaskId);
+            this.update(updateWrapper);
+//            this.baseMapper.updateScanCount(paperScanTaskId);
+//        } finally {
+//            lockService.unlock(LockType.UPDATE_SCAN_PAPER_COUNT, paperScanTaskId);
+//        }
     }
     }
 }
 }

+ 18 - 1
paper-library/src/main/java/com/qmth/paper/library/api/ClientController.java

@@ -5,8 +5,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.qmth.boot.api.annotation.Aac;
 import com.qmth.boot.api.annotation.Aac;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.paper.library.business.bean.params.ClientLoginParam;
 import com.qmth.paper.library.business.bean.params.ClientLoginParam;
+import com.qmth.paper.library.business.entity.PaperScanTask;
 import com.qmth.paper.library.business.service.ClientService;
 import com.qmth.paper.library.business.service.ClientService;
 import com.qmth.paper.library.business.service.ExamStudentService;
 import com.qmth.paper.library.business.service.ExamStudentService;
+import com.qmth.paper.library.business.service.PaperScanTaskService;
 import com.qmth.paper.library.common.bean.result.LoginResult;
 import com.qmth.paper.library.common.bean.result.LoginResult;
 import com.qmth.paper.library.common.contant.ApiPrefixConstant;
 import com.qmth.paper.library.common.contant.ApiPrefixConstant;
 import com.qmth.paper.library.common.entity.BasicSchool;
 import com.qmth.paper.library.common.entity.BasicSchool;
@@ -14,6 +16,8 @@ import com.qmth.paper.library.common.entity.ExamStudent;
 import com.qmth.paper.library.common.entity.SysUser;
 import com.qmth.paper.library.common.entity.SysUser;
 import com.qmth.paper.library.common.enums.AppSourceEnum;
 import com.qmth.paper.library.common.enums.AppSourceEnum;
 import com.qmth.paper.library.common.enums.ExceptionResultEnum;
 import com.qmth.paper.library.common.enums.ExceptionResultEnum;
+import com.qmth.paper.library.common.lock.LockService;
+import com.qmth.paper.library.common.lock.LockType;
 import com.qmth.paper.library.common.service.BasicBatchNumberService;
 import com.qmth.paper.library.common.service.BasicBatchNumberService;
 import com.qmth.paper.library.common.service.BasicSchoolService;
 import com.qmth.paper.library.common.service.BasicSchoolService;
 import com.qmth.paper.library.common.service.LibraryCommonService;
 import com.qmth.paper.library.common.service.LibraryCommonService;
@@ -54,6 +58,10 @@ public class ClientController {
     private ExamStudentService examStudentService;
     private ExamStudentService examStudentService;
     @Resource
     @Resource
     private LibraryCommonService libraryCommonService;
     private LibraryCommonService libraryCommonService;
+    @Resource
+    private PaperScanTaskService paperScanTaskService;
+    @Resource
+    private LockService lockService;
 
 
     /**
     /**
      * 登录
      * 登录
@@ -112,7 +120,16 @@ public class ClientController {
                                 @ApiParam(value = "背面图片md5", required = true) @RequestParam String versoMd5,
                                 @ApiParam(value = "背面图片md5", required = true) @RequestParam String versoMd5,
                                 @ApiParam(value = "采集用户ID", required = true) @RequestParam Long scanUserId,
                                 @ApiParam(value = "采集用户ID", required = true) @RequestParam Long scanUserId,
                                 @ApiParam(value = "批次号", required = true) @RequestParam String batchNo) {
                                 @ApiParam(value = "批次号", required = true) @RequestParam String batchNo) {
-        return ResultUtil.ok(clientService.pictureUpload(paperScanTaskId, studentCode, x, y, width, height, rotate, frontFile, frontMd5, versoFile, versoMd5, scanUserId, batchNo));
+        Long studentId = clientService.pictureUpload(paperScanTaskId, studentCode, x, y, width, height, rotate, frontFile, frontMd5, versoFile, versoMd5,
+                scanUserId, batchNo);
+        PaperScanTask task = paperScanTaskService.getById(paperScanTaskId);
+        try {
+            lockService.waitlock(LockType.UPDATE_SCAN_PAPER_COUNT, paperScanTaskId);
+            clientService.updateCount(paperScanTaskId, task.getExamId(), studentId, scanUserId, batchNo);
+        } finally {
+            lockService.unlock(LockType.UPDATE_SCAN_PAPER_COUNT, paperScanTaskId);
+        }
+        return ResultUtil.ok();
     }
     }
 
 
     @ApiOperation(value = "上传其它图片")
     @ApiOperation(value = "上传其它图片")