xiaofei vor 8 Monaten
Ursprung
Commit
49f62c179f

+ 11 - 0
paper-library-business/src/main/java/com/qmth/paper/library/business/entity/PaperLibraryOther.java

@@ -36,6 +36,9 @@ public class PaperLibraryOther extends BaseEntity implements Serializable {
     @ApiModelProperty(value = "文件类型ID")
     @ApiModelProperty(value = "文件类型ID")
     private Long fileTypeId;
     private Long fileTypeId;
 
 
+    @ApiModelProperty(value = "批次号")
+    private String batchNo;
+
     public Long getPaperScanTaskId() {
     public Long getPaperScanTaskId() {
         return paperScanTaskId;
         return paperScanTaskId;
     }
     }
@@ -68,6 +71,14 @@ public class PaperLibraryOther extends BaseEntity implements Serializable {
         this.fileTypeId = fileTypeId;
         this.fileTypeId = fileTypeId;
     }
     }
 
 
+    public String getBatchNo() {
+        return batchNo;
+    }
+
+    public void setBatchNo(String batchNo) {
+        this.batchNo = batchNo;
+    }
+
     @Override
     @Override
     public String toString() {
     public String toString() {
         return "PaperLibraryOther{" +
         return "PaperLibraryOther{" +

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

@@ -16,7 +16,7 @@ public interface ClientService {
 
 
     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);
     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, String batchNo, Integer studentPaperNo);
 
 
     boolean updateCount(Long paperScanTaskId, Long examId, Long studentId, Long scanUserId, String batchNo);
     boolean updateCount(Long paperScanTaskId, Long examId, Long studentId, Long scanUserId, String batchNo);
 }
 }

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

@@ -15,5 +15,5 @@ public interface PaperLibraryOtherService extends IService<PaperLibraryOther> {
 
 
     void removeByPaperScanTaskId(Long paperScanTaskId);
     void removeByPaperScanTaskId(Long paperScanTaskId);
 
 
-    int getMaxSequence(Long paperScanTaskId, Long fileTypeId);
+    int getMaxSequence(Long paperScanTaskId, Long fileTypeId, Long userId, String batchNo);
 }
 }

+ 11 - 6
paper-library-business/src/main/java/com/qmth/paper/library/business/service/impl/ClientServiceImpl.java

@@ -1,7 +1,6 @@
 package com.qmth.paper.library.business.service.impl;
 package com.qmth.paper.library.business.service.impl;
 
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.qmth.paper.library.business.bean.vo.PathSequenceVo;
 import com.qmth.paper.library.business.bean.vo.PathSequenceVo;
 import com.qmth.paper.library.business.bean.vo.RecognitionResultVo;
 import com.qmth.paper.library.business.bean.vo.RecognitionResultVo;
 import com.qmth.paper.library.business.entity.PaperLibrary;
 import com.qmth.paper.library.business.entity.PaperLibrary;
@@ -12,12 +11,14 @@ import com.qmth.paper.library.common.contant.SystemConstant;
 import com.qmth.paper.library.common.entity.BasicFileType;
 import com.qmth.paper.library.common.entity.BasicFileType;
 import com.qmth.paper.library.common.entity.ExamStudent;
 import com.qmth.paper.library.common.entity.ExamStudent;
 import com.qmth.paper.library.common.entity.SysPrivilege;
 import com.qmth.paper.library.common.entity.SysPrivilege;
+import com.qmth.paper.library.common.entity.SysUser;
 import com.qmth.paper.library.common.enums.ExceptionResultEnum;
 import com.qmth.paper.library.common.enums.ExceptionResultEnum;
 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.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.SysPrivilegeService;
 import com.qmth.paper.library.common.service.SysPrivilegeService;
+import com.qmth.paper.library.common.service.SysUserService;
 import com.qmth.paper.library.common.util.ServletUtil;
 import com.qmth.paper.library.common.util.ServletUtil;
 import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.commons.lang3.time.DateFormatUtils;
 import org.apache.commons.lang3.time.DateFormatUtils;
@@ -43,6 +44,8 @@ public class ClientServiceImpl implements ClientService {
     @Resource
     @Resource
     private SysPrivilegeService sysPrivilegeService;
     private SysPrivilegeService sysPrivilegeService;
     @Resource
     @Resource
+    private SysUserService sysUserService;
+    @Resource
     private PaperLibraryService paperLibraryService;
     private PaperLibraryService paperLibraryService;
     @Resource
     @Resource
     private PaperLibraryOtherService paperLibraryOtherService;
     private PaperLibraryOtherService paperLibraryOtherService;
@@ -80,7 +83,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,
     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) {
+                              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(正面图片)为空");
@@ -163,8 +166,9 @@ public class ClientServiceImpl implements ClientService {
     }
     }
 
 
     @Override
     @Override
-    public boolean otherUpload(Long paperScanTaskId, MultipartFile frontFile, String frontMd5, MultipartFile versoFile, String versoMd5, Long fileTypeId, String classRoomName) {
+    public boolean otherUpload(Long paperScanTaskId, MultipartFile frontFile, String frontMd5, MultipartFile versoFile, String versoMd5, Long fileTypeId, String classRoomName, String batchNo, Integer studentPaperNo) {
         Long userId = Long.valueOf(ServletUtil.getRequestHeaderUserId().toString());
         Long userId = Long.valueOf(ServletUtil.getRequestHeaderUserId().toString());
+        SysUser sysUser = sysUserService.getById(userId);
         if (Objects.isNull(frontFile) || frontFile.getSize() == 0) {
         if (Objects.isNull(frontFile) || frontFile.getSize() == 0) {
             throw ExceptionResultEnum.ERROR.exception("frontFile(正面图片)为空");
             throw ExceptionResultEnum.ERROR.exception("frontFile(正面图片)为空");
         }
         }
@@ -189,6 +193,7 @@ public class ClientServiceImpl implements ClientService {
             PaperLibraryOther paperLibraryOther = new PaperLibraryOther();
             PaperLibraryOther paperLibraryOther = new PaperLibraryOther();
             paperLibraryOther.setId(SystemConstant.getDbUuid());
             paperLibraryOther.setId(SystemConstant.getDbUuid());
             paperLibraryOther.setPaperScanTaskId(paperScanTaskId);
             paperLibraryOther.setPaperScanTaskId(paperScanTaskId);
+            paperLibraryOther.setBatchNo(batchNo);
             paperLibraryOther.setCreateId(userId);
             paperLibraryOther.setCreateId(userId);
             paperLibraryOther.setCreateTime(System.currentTimeMillis());
             paperLibraryOther.setCreateTime(System.currentTimeMillis());
 
 
@@ -198,10 +203,10 @@ public class ClientServiceImpl implements ClientService {
             }
             }
             paperLibraryOther.setFileTypeId(fileTypeId);
             paperLibraryOther.setFileTypeId(fileTypeId);
 
 
-            int maxSequence = paperLibraryOtherService.getMaxSequence(paperScanTaskId, fileTypeId);
-            paperLibraryOther.setSequence(maxSequence);
+            int maxSequence = paperLibraryOtherService.getMaxSequence(paperScanTaskId, fileTypeId, userId, batchNo);
+            paperLibraryOther.setSequence(maxSequence + studentPaperNo);
             // 保存图片,生成路径
             // 保存图片,生成路径
-            PathSequenceVo pathSequenceVo = paperLibraryCommonService.saveLibraryOtherFile(paperScanTask, UploadFileEnum.IMAGE, basicFileType.getName() + maxSequence, classRoomName, frontFile, versoFile);
+            PathSequenceVo pathSequenceVo = paperLibraryCommonService.saveLibraryOtherFile(paperScanTask, UploadFileEnum.IMAGE, basicFileType.getName() + "-" + sysUser.getLoginName() + "-" + paperLibraryOther.getSequence(), classRoomName, frontFile, versoFile);
             paperLibraryOther.setPath(pathSequenceVo.getPath());
             paperLibraryOther.setPath(pathSequenceVo.getPath());
 
 
             return paperLibraryOtherService.save(paperLibraryOther);
             return paperLibraryOtherService.save(paperLibraryOther);

+ 5 - 3
paper-library-business/src/main/java/com/qmth/paper/library/business/service/impl/PaperLibraryOtherServiceImpl.java

@@ -34,19 +34,21 @@ public class PaperLibraryOtherServiceImpl extends ServiceImpl<PaperLibraryOtherM
     }
     }
 
 
     @Override
     @Override
-    public int getMaxSequence(Long paperScanTaskId, Long fileTypeId) {
+    public int getMaxSequence(Long paperScanTaskId, Long fileTypeId, Long userId, String batchNo) {
         try {
         try {
             lockService.waitlock(LockType.GET_OTHER_SEQUENCE, paperScanTaskId, fileTypeId);
             lockService.waitlock(LockType.GET_OTHER_SEQUENCE, paperScanTaskId, fileTypeId);
             QueryWrapper<PaperLibraryOther> queryWrapper = new QueryWrapper<>();
             QueryWrapper<PaperLibraryOther> queryWrapper = new QueryWrapper<>();
             queryWrapper.lambda().eq(PaperLibraryOther::getPaperScanTaskId, paperScanTaskId)
             queryWrapper.lambda().eq(PaperLibraryOther::getPaperScanTaskId, paperScanTaskId)
                     .eq(PaperLibraryOther::getFileTypeId, fileTypeId)
                     .eq(PaperLibraryOther::getFileTypeId, fileTypeId)
+                    .eq(PaperLibraryOther::getCreateId, userId)
+                    .ne(PaperLibraryOther::getBatchNo, batchNo)
                     .orderByDesc(PaperLibraryOther::getSequence)
                     .orderByDesc(PaperLibraryOther::getSequence)
                     .last(" limit 1");
                     .last(" limit 1");
             PaperLibraryOther paperLibraryOther = this.getOne(queryWrapper);
             PaperLibraryOther paperLibraryOther = this.getOne(queryWrapper);
             if (paperLibraryOther == null || paperLibraryOther.getSequence() == null) {
             if (paperLibraryOther == null || paperLibraryOther.getSequence() == null) {
-                return 1;
+                return 0;
             } else {
             } else {
-                return paperLibraryOther.getSequence().intValue() + 1;
+                return paperLibraryOther.getSequence().intValue();
             }
             }
         } catch (Exception e) {
         } catch (Exception e) {
             throw ExceptionResultEnum.ERROR.exception("获取批次号失败:" + e.getMessage());
             throw ExceptionResultEnum.ERROR.exception("获取批次号失败:" + e.getMessage());

+ 1 - 0
paper-library/install/mysql/init/paper_library_db.sql

@@ -273,6 +273,7 @@ CREATE TABLE IF NOT EXISTS `paper_library_other` (
   `update_id` bigint(20) DEFAULT NULL COMMENT '更新人',
   `update_id` bigint(20) DEFAULT NULL COMMENT '更新人',
   `update_time` bigint(20) DEFAULT NULL COMMENT '更新时间',
   `update_time` bigint(20) DEFAULT NULL COMMENT '更新时间',
   `file_type_id` bigint(20) DEFAULT NULL COMMENT '文件类型ID',
   `file_type_id` bigint(20) DEFAULT NULL COMMENT '文件类型ID',
+  `batch_no` VARCHAR(45) DEFAULT NULL COMMENT '批次号',
   PRIMARY KEY (`id`) USING BTREE,
   PRIMARY KEY (`id`) USING BTREE,
   KEY `idx_1` (`paper_scan_task_id`,`file_type_id`)
   KEY `idx_1` (`paper_scan_task_id`,`file_type_id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='图片库';
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='图片库';

+ 4 - 1
paper-library/install/mysql/upgrade/1.0.5.sql

@@ -121,4 +121,7 @@ UPDATE paper_library p,paper_scan_task t SET p.school_id=t.school_id WHERE p.pap
 UPDATE paper_library SET create_date=date_format( FROM_UNIXTIME( create_time / 1000 ), '%Y-%m-%d');
 UPDATE paper_library SET create_date=date_format( FROM_UNIXTIME( create_time / 1000 ), '%Y-%m-%d');
 
 
 ALTER TABLE `paper_library` ADD INDEX `idx_4` (`create_id` ASC) ,ADD INDEX `idx_5` (`create_date` ASC) ;
 ALTER TABLE `paper_library` ADD INDEX `idx_4` (`create_id` ASC) ,ADD INDEX `idx_5` (`create_date` ASC) ;
-ALTER TABLE `paper_library` ADD INDEX `idx_6`(`school_id`,`create_id`,`create_date`,`student_id`) ;
+ALTER TABLE `paper_library` ADD INDEX `idx_6`(`school_id`,`create_id`,`create_date`,`student_id`) ;
+
+ALTER TABLE `paper_library_other` ADD COLUMN `batch_no` VARCHAR(45) NULL COMMENT '批次号' AFTER `file_type_id`;
+update paper_library_other set batch_no = UNIX_TIMESTAMP(NOW())*1000 where batch_no is null;

+ 4 - 2
paper-library/src/main/java/com/qmth/paper/library/api/ClientController.java

@@ -149,8 +149,10 @@ 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 fileTypeId,
                               @ApiParam(value = "文件类型ID", required = true) @RequestParam Long fileTypeId,
-                              @ApiParam(value = "考场/班级的名称") @RequestParam(required = false) String classRoomName) {
-        return ResultUtil.ok(clientService.otherUpload(paperScanTaskId, frontFile, frontMd5, versoFile, versoMd5, fileTypeId, classRoomName));
+                              @ApiParam(value = "考场/班级的名称") @RequestParam(required = false) String classRoomName,
+                              @ApiParam(value = "批次号") @RequestParam(required = false) String batchNo,
+                              @ApiParam(value = "扫描图片序号(批次下从1开始)") @RequestParam(required = false) Integer studentPaperNo) {
+        return ResultUtil.ok(clientService.otherUpload(paperScanTaskId, frontFile, frontMd5, versoFile, versoMd5, fileTypeId, classRoomName, batchNo, studentPaperNo));
     }
     }
 
 
     @ApiOperation(value = "根据学号获取考生信息")
     @ApiOperation(value = "根据学号获取考生信息")