Browse Source

1.0.5 update

xiaofei 10 months ago
parent
commit
2c5473f02a

+ 8 - 0
paper-library-business/src/main/java/com/qmth/paper/library/business/service/ExamStudentService.java

@@ -50,4 +50,12 @@ public interface ExamStudentService extends IService<ExamStudent> {
     List<ExamStudent> listByExamIdAndCourseCode(Long examId, String courseCode);
 
     ExamStudent saveExamStudentFromClient(ExamStudent examStudent);
+
+    /**
+     * 清除pdf文件(1.上传,2.纠错,3.旋转,4.清除数据,5.删除图片)
+     * @param studentId
+     */
+    void clearPdfFilePath(Long studentId);
+
+    boolean clearFilePath(Long studentId);
 }

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

@@ -78,7 +78,6 @@ public class ClientServiceImpl implements ClientService {
     @Transactional
     @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) {
-        Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
 
         if (Objects.isNull(frontFile) || frontFile.getSize() == 0) {
             throw ExceptionResultEnum.ERROR.exception("frontFile(正面图片)为空");
@@ -152,6 +151,8 @@ public class ClientServiceImpl implements ClientService {
 
                 // 更新批次号
                 basicBatchNumberService.updateBatchNo(paperScanTask.getExamId(), scanUserId, batchNo);
+                // 清除pdf文件记录
+                examStudentService.clearPdfFilePath(examStudent.getId());
             }
             return true;
 
@@ -205,7 +206,7 @@ public class ClientServiceImpl implements ClientService {
             return paperLibraryOtherService.save(paperLibraryOther);
         } catch (Exception e) {
             throw ExceptionResultEnum.ERROR.exception("保存图片失败:" + e.getMessage());
-        }  finally {
+        } finally {
             lockService.unlock(LockType.UPLOAD_OTHER_FILE, paperScanTaskId, fileTypeId);
         }
     }

+ 27 - 1
paper-library-business/src/main/java/com/qmth/paper/library/business/service/impl/ExamStudentServiceImpl.java

@@ -1,6 +1,6 @@
 package com.qmth.paper.library.business.service.impl;
 
-import cn.hutool.core.collection.ArrayIter;
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.boot.tools.excel.ExcelWriter;
 import com.qmth.boot.tools.excel.enums.ExcelType;
+import com.qmth.paper.library.business.bean.vo.FilePathVo;
 import com.qmth.paper.library.business.entity.PaperScanTask;
 import com.qmth.paper.library.business.mapper.ExamStudentMapper;
 import com.qmth.paper.library.business.service.*;
@@ -68,6 +69,8 @@ public class ExamStudentServiceImpl extends ServiceImpl<ExamStudentMapper, ExamS
     private PaperLibraryCommonService paperLibraryCommonService;
     @Resource
     private AsyncExamStudentImportService asyncExamStudentImportService;
+    @Resource
+    private FileUploadService fileUploadService;
 
     @Override
     public IPage<ExamStudent> findStudentPage(Long examId, String courseCode, String collegeName, String majorName, String clazzName, String queryParams, int pageNumber, int pageSize) {
@@ -410,4 +413,27 @@ public class ExamStudentServiceImpl extends ServiceImpl<ExamStudentMapper, ExamS
             return examStudent;
         }
     }
+
+    @Override
+    public void clearPdfFilePath(Long studentId) {
+        ExamStudent examStudent = this.getById(studentId);
+        try {
+            if (examStudent != null && StringUtils.isNotBlank(examStudent.getFilePath())) {
+                FilePathVo filePathVo = JSON.parseObject(examStudent.getFilePath(), FilePathVo.class);
+                if (this.clearFilePath(studentId)) {
+                    fileUploadService.deleteFile(filePathVo.getPath());
+                }
+            }
+        } catch (Exception e) {
+            log.error("清除pdf文件路径失败" + e.getMessage());
+        }
+    }
+
+    @Override
+    public boolean clearFilePath(Long studentId) {
+        UpdateWrapper<ExamStudent> updateWrapper = new UpdateWrapper<>();
+        updateWrapper.lambda().set(ExamStudent::getFilePath, null)
+                .eq(ExamStudent::getId, studentId);
+        return this.update(updateWrapper);
+    }
 }

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

@@ -290,8 +290,12 @@ public class PaperLibraryServiceImpl extends ServiceImpl<PaperLibraryMapper, Pap
         // 更新考生绑定数量
         if (paperLibrary.getStudentId() != null) {
             examStudentService.updateBindCount(paperLibrary.getStudentId());
+            // 清除pdf文件记录
+            examStudentService.clearPdfFilePath(paperLibrary.getStudentId());
         }
         examStudentService.updateBindCount(studentId);
+        // 清除pdf文件记录
+        examStudentService.clearPdfFilePath(studentId);
         return true;
     }
 
@@ -385,6 +389,8 @@ public class PaperLibraryServiceImpl extends ServiceImpl<PaperLibraryMapper, Pap
         }
         if (paperLibrary.getStudentId() != null) {
             examStudentService.updateBindCount(paperLibrary.getStudentId());
+            // 清除pdf文件记录
+            examStudentService.clearPdfFilePath(paperLibrary.getStudentId());
         }
         return this.removeById(paperLibraryId);
     }

+ 7 - 2
paper-library-business/src/main/java/com/qmth/paper/library/business/service/impl/PaperScanTaskServiceImpl.java

@@ -85,6 +85,11 @@ public class PaperScanTaskServiceImpl extends ServiceImpl<PaperScanTaskMapper, P
             UpdateWrapper<ExamStudent> updateWrapper = new UpdateWrapper<>();
             updateWrapper.lambda().set(ExamStudent::getBindCount, 0).in(ExamStudent::getId, studentIds);
             examStudentService.update(updateWrapper);
+
+            for (Long studentId : studentIds) {
+                // 清除pdf文件记录
+                examStudentService.clearPdfFilePath(studentId);
+            }
         }
         // 删除该任务扫描的的数据
         paperLibraryService.removeByPaperScanTaskId(paperScanTaskId);
@@ -227,7 +232,7 @@ public class PaperScanTaskServiceImpl extends ServiceImpl<PaperScanTaskMapper, P
             }
         }
 
+        // 清除pdf文件记录
+        examStudentService.clearPdfFilePath(studentId);
     }
-
-
 }

+ 11 - 0
paper-library-common/src/main/java/com/qmth/paper/library/common/entity/ExamStudent.java

@@ -100,6 +100,9 @@ public class ExamStudent extends BaseEntity implements Serializable {
     @ApiModelProperty(value = "可用状态(1:可用,0:不可用)")
     private Boolean enable;
 
+    @ApiModelProperty(value = "生成pdf的文件路径")
+    private String filePath;
+
     @TableField(exist = false)
     @ApiModelProperty(value = "导入文件中数据错误信息")
     private String errorMsg;
@@ -273,6 +276,14 @@ public class ExamStudent extends BaseEntity implements Serializable {
         this.enable = enable;
     }
 
+    public String getFilePath() {
+        return filePath;
+    }
+
+    public void setFilePath(String filePath) {
+        this.filePath = filePath;
+    }
+
     public String getErrorMsg() {
         return errorMsg;
     }