haogh 10 bulan lalu
induk
melakukan
d739fc1054

+ 2 - 0
paper-library-business/src/main/java/com/qmth/paper/library/business/mapper/PaperLibraryMapper.java

@@ -34,4 +34,6 @@ public interface PaperLibraryMapper extends BaseMapper<PaperLibrary> {
     List<ScanStatExportResult> listScanStatExport(@Param("schoolId") Long schoolId, @Param("scanDateStr") String scanDateStr, @Param("userId") Long userId);
     List<ScanStatExportResult> listScanStatExport(@Param("schoolId") Long schoolId, @Param("scanDateStr") String scanDateStr, @Param("userId") Long userId);
 
 
     List<String> listBatchNo(@Param("studentId") Long studentId);
     List<String> listBatchNo(@Param("studentId") Long studentId);
+
+    int getStudentMaxSequence(@Param("paperScanTaskId") Long paperScanTaskId, @Param("studentId") Long studentId);
 }
 }

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

@@ -14,7 +14,7 @@ public interface ClientService {
 
 
     void checkPrivilege(Long userId);
     void checkPrivilege(Long userId);
 
 
-    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);
+    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, Integer studentPaperNo);
 
 
     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);
 
 

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

@@ -46,7 +46,7 @@ public interface PaperLibraryCommonService {
     Map<String, Object> saveTask(MultipartFile file, TaskTypeEnum taskTypeEnum);
     Map<String, Object> saveTask(MultipartFile file, TaskTypeEnum taskTypeEnum);
     Map<String, Object> saveTask(MultipartFile file, Long examId, TaskTypeEnum taskTypeEnum);
     Map<String, Object> saveTask(MultipartFile file, Long examId, TaskTypeEnum taskTypeEnum);
 
 
-    PathSequenceVo saveLibraryFile(PaperScanTask paperScanTask, ExamStudent examStudent, UploadFileEnum uploadFileEnum, MultipartFile... files);
+    PathSequenceVo saveLibraryFile(PaperScanTask paperScanTask, ExamStudent examStudent, UploadFileEnum uploadFileEnum, int studentSequence, MultipartFile... files);
 
 
     PathSequenceVo saveLibraryOtherFile(PaperScanTask paperScanTask, UploadFileEnum uploadFileEnum, String fileNamePrefix, String classRoomName, MultipartFile... files);
     PathSequenceVo saveLibraryOtherFile(PaperScanTask paperScanTask, UploadFileEnum uploadFileEnum, String fileNamePrefix, String classRoomName, MultipartFile... files);
 
 

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

@@ -49,4 +49,6 @@ public interface PaperLibraryService extends IService<PaperLibrary> {
     boolean rotatePictureUpload(Long paperLibraryId, boolean isFront, Integer rotate);
     boolean rotatePictureUpload(Long paperLibraryId, boolean isFront, Integer rotate);
 
 
     Map<String, Object> pdfGenerate(DownLoadPaperParams params);
     Map<String, Object> pdfGenerate(DownLoadPaperParams params);
+
+    int getStudentMaxSequence(Long paperScanTaskId, Long studentId);
 }
 }

+ 8 - 3
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 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) {
+    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,Integer studentPaperNo) {
 
 
         if (Objects.isNull(frontFile) || frontFile.getSize() == 0) {
         if (Objects.isNull(frontFile) || frontFile.getSize() == 0) {
             throw ExceptionResultEnum.ERROR.exception("frontFile(正面图片)为空");
             throw ExceptionResultEnum.ERROR.exception("frontFile(正面图片)为空");
@@ -129,10 +129,15 @@ public class ClientServiceImpl implements ClientService {
 //                examStudentService.save(examStudent);
 //                examStudentService.save(examStudent);
             }
             }
             paperLibrary.setStudentId(examStudent.getId());
             paperLibrary.setStudentId(examStudent.getId());
+            //考生图片序号
+            int studentMaxSequence = paperLibraryService.getStudentMaxSequence(paperScanTaskId, examStudent.getId());
+            int studentSequence = studentMaxSequence + studentPaperNo;
+            paperLibrary.setSequence(studentSequence);
             // 保存图片,生成路径
             // 保存图片,生成路径
-            PathSequenceVo pathSequenceVo = paperLibraryCommonService.saveLibraryFile(paperScanTask, examStudent, UploadFileEnum.IMAGE, frontFile, versoFile);
+            PathSequenceVo pathSequenceVo = paperLibraryCommonService.saveLibraryFile(paperScanTask, examStudent, UploadFileEnum.IMAGE, studentSequence, frontFile, versoFile);
             paperLibrary.setPath(pathSequenceVo.getPath());
             paperLibrary.setPath(pathSequenceVo.getPath());
-            paperLibrary.setSequence(pathSequenceVo.getSequence());
+
+
             paperLibrary.setBindResult(recognitionVo.getBindResult());
             paperLibrary.setBindResult(recognitionVo.getBindResult());
             paperLibrary.setRecognizeResult(recognitionVo.getRecognizeResult());
             paperLibrary.setRecognizeResult(recognitionVo.getRecognizeResult());
             paperLibraryService.save(paperLibrary);
             paperLibraryService.save(paperLibrary);

+ 3 - 2
paper-library-business/src/main/java/com/qmth/paper/library/business/service/impl/PaperLibraryCommonServiceImpl.java

@@ -298,7 +298,7 @@ public class PaperLibraryCommonServiceImpl implements PaperLibraryCommonService
     }
     }
 
 
     @Override
     @Override
-    public PathSequenceVo saveLibraryFile(PaperScanTask paperScanTask, ExamStudent examStudent, UploadFileEnum uploadFileEnum, MultipartFile... files) {
+    public PathSequenceVo saveLibraryFile(PaperScanTask paperScanTask, ExamStudent examStudent, UploadFileEnum uploadFileEnum, int studentSequence, MultipartFile... files) {
         BasicSchool basicSchool = basicSchoolService.getById(paperScanTask.getSchoolId());
         BasicSchool basicSchool = basicSchoolService.getById(paperScanTask.getSchoolId());
         BasicExam basicExam = basicExamService.getById(paperScanTask.getExamId());
         BasicExam basicExam = basicExamService.getById(paperScanTask.getExamId());
         BasicSemester basicSemester = basicSemesterService.getById(basicExam.getSemesterId());
         BasicSemester basicSemester = basicSemesterService.getById(basicExam.getSemesterId());
@@ -317,7 +317,8 @@ public class PaperLibraryCommonServiceImpl implements PaperLibraryCommonService
         String sequenceStr = String.valueOf(sequence);
         String sequenceStr = String.valueOf(sequence);
         try {
         try {
             int idx = 1;
             int idx = 1;
-            String prefix = examStudent.getStudentCode() + "-" + sequenceStr;
+//            String prefix = examStudent.getStudentCode() + "-" + sequenceStr;
+            String prefix = examStudent.getStudentCode() + "-" + studentSequence;
             for (MultipartFile file : files) {
             for (MultipartFile file : files) {
                 String fileName = file.getOriginalFilename();
                 String fileName = file.getOriginalFilename();
                 String suffix = fileName.substring(fileName.lastIndexOf("."));
                 String suffix = fileName.substring(fileName.lastIndexOf("."));

+ 5 - 0
paper-library-business/src/main/java/com/qmth/paper/library/business/service/impl/PaperLibraryServiceImpl.java

@@ -466,4 +466,9 @@ public class PaperLibraryServiceImpl extends ServiceImpl<PaperLibraryMapper, Pap
         return map;
         return map;
     }
     }
 
 
+    @Override
+    public int getStudentMaxSequence(Long paperScanTaskId, Long studentId) {
+        return  baseMapper.getStudentMaxSequence(paperScanTaskId, studentId);
+    }
+
 }
 }

+ 4 - 0
paper-library-business/src/main/resources/mapper/PaperLibraryMapper.xml

@@ -122,4 +122,8 @@
         select distinct pl.batch_no from paper_library pl where student_id=#{studentId}
         select distinct pl.batch_no from paper_library pl where student_id=#{studentId}
     </select>
     </select>
 
 
+    <select id="getStudentMaxSequence" resultType="java.lang.Integer">
+        select ifnull(max(sequence),0) from paper_library where paper_scan_task_id=#{paperScanTaskId} and student_id=#{studentId}
+    </select>
+
 </mapper>
 </mapper>

+ 2 - 1
paper-library-common/src/main/java/com/qmth/paper/library/common/lock/LockType.java

@@ -11,7 +11,8 @@ public enum LockType {
     STUDENT_PDF_GENERATE("考生试卷pdf生成"),
     STUDENT_PDF_GENERATE("考生试卷pdf生成"),
     UPDATE_BATCH_NO("更新批次号"),
     UPDATE_BATCH_NO("更新批次号"),
     UPDATE_STUDENT_PICTURE_COUNT("更新考生图片数量"),
     UPDATE_STUDENT_PICTURE_COUNT("更新考生图片数量"),
-    UPDATE_SCAN_PAPER_COUNT("更新扫描任务学生数量和图片数量");
+    UPDATE_SCAN_PAPER_COUNT("更新扫描任务学生数量和图片数量"),
+    GET_MAX_SEQUENCE("获取考生最大的图片序号");
 
 
     private String name;
     private String name;
 
 

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

@@ -119,9 +119,17 @@ public class ClientController {
                                 @ApiParam(value = "背面图片", required = true) @RequestParam MultipartFile versoFile,
                                 @ApiParam(value = "背面图片", required = true) @RequestParam MultipartFile versoFile,
                                 @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) {
-        Long studentId = clientService.pictureUpload(paperScanTaskId, studentCode, x, y, width, height, rotate, frontFile, frontMd5, versoFile, versoMd5,
-                scanUserId, batchNo);
+                                @ApiParam(value = "批次号", required = true) @RequestParam String batchNo,
+                                @ApiParam(value = "图片序号", required = true) @RequestParam Integer studentPaperNo) {
+        Long studentId;
+        try {
+            lockService.waitlock(LockType.GET_MAX_SEQUENCE, paperScanTaskId, studentCode);
+            studentId = clientService.pictureUpload(paperScanTaskId, studentCode, x, y, width, height, rotate, frontFile, frontMd5, versoFile, versoMd5,
+                    scanUserId, batchNo, studentPaperNo);
+        } finally {
+            lockService.unlock(LockType.GET_MAX_SEQUENCE, paperScanTaskId, studentCode);
+        }
+
         PaperScanTask task = paperScanTaskService.getById(paperScanTaskId);
         PaperScanTask task = paperScanTaskService.getById(paperScanTaskId);
         try {
         try {
             lockService.waitlock(LockType.UPDATE_SCAN_PAPER_COUNT, paperScanTaskId);
             lockService.waitlock(LockType.UPDATE_SCAN_PAPER_COUNT, paperScanTaskId);