Browse Source

1.0.4 优化联调bug

xiaofei 1 year ago
parent
commit
c30914b726

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

@@ -109,6 +109,7 @@ public class ClientServiceImpl implements ClientService {
             paperLibrary.setCreateTime(System.currentTimeMillis());
             // 校验是否存在,不存在创建考生并绑定上
             ExamStudent examStudent = examStudentService.getByExamIdAndCourseCodeAndStudentCode(paperScanTask.getExamId(), paperScanTask.getCourseCode(), recognitionVo.getBindResult());
+            int studentCount = paperScanTask.getStudentCount();
             if (examStudent == null) {
                 BasicExam basicExam = basicExamService.getById(paperScanTask.getExamId());
                 examStudent = new ExamStudent(schoolId, basicExam.getSemesterId(), basicExam.getId(), paperScanTask.getCourseCode(), paperScanTask.getCourseName(), recognitionVo.getBindResult(), studentCode, true, true);
@@ -118,7 +119,10 @@ public class ClientServiceImpl implements ClientService {
                 if (StoreTypeEnum.CLASS.equals(paperScanTask.getStoreType())) {
                     examStudent.setClassName(studentCode);
                 }
-                examStudentService.save(examStudent);
+                boolean save = examStudentService.save(examStudent);
+                if (save) {
+                    studentCount = examStudentService.countByExamIdAndCourseCode(examStudent.getExamId(), examStudent.getCourseCode());
+                }
             }
             paperLibrary.setStudentId(examStudent.getId());
             // 保存图片,生成路径
@@ -135,7 +139,8 @@ public class ClientServiceImpl implements ClientService {
                 int scanStudentCount = paperLibraryService.countScanStudentCount(paperScanTaskId);
                 // 总扫描数
                 UpdateWrapper<PaperScanTask> updateWrapper = new UpdateWrapper<>();
-                updateWrapper.lambda().set(PaperScanTask::getScanStudentCount, scanStudentCount)
+                updateWrapper.lambda().eq(PaperScanTask::getStudentCount, studentCount)
+                        .set(PaperScanTask::getScanStudentCount, scanStudentCount)
                         .set(PaperScanTask::getScanCount, scanCount)
                         .eq(PaperScanTask::getId, paperScanTaskId);
                 paperScanTaskService.update(updateWrapper);

+ 4 - 4
paper-library-business/src/main/java/com/qmth/paper/library/business/templete/service/impl/TaskLogicServiceImpl.java

@@ -142,13 +142,13 @@ public class TaskLogicServiceImpl implements TaskLogicService {
 //                        String priPhoneNumber = primaryCell.getPhoneNumber();
                         String priOrgName = primaryCell.getOrgName();
                         if (!Objects.equals(priName, name)) {
-                            throw ExceptionResultEnum.ERROR.exception("【用户名】 :" + loginName + "的用户存在不同的名称");
+                            throw ExceptionResultEnum.ERROR.exception("用户名[" + loginName + "]的用户存在不同的名称");
                         }
 //                        if (!Objects.equals(priPhoneNumber, phoneNumber)) {
 //                            throw ExceptionResultEnum.ERROR.exception("【账号】 :" + loginName + "的用户存在不同的手机号");
 //                        }
                         if (!Objects.equals(priOrgName, orgName)) {
-                            throw ExceptionResultEnum.ERROR.exception("【用户名】 :" + loginName + "的用户存在不同的组织架构");
+                            throw ExceptionResultEnum.ERROR.exception("用户名[" + loginName + "]的用户存在不同的组织架构");
                         }
                         String priRoleName = primaryCell.getRoleName();
                         if (SystemConstant.strNotNull(roleName)) {
@@ -162,10 +162,10 @@ public class TaskLogicServiceImpl implements TaskLogicService {
 
                     excelErrorTemp.addAll(ExcelUtil.checkExcelField(sysUserImportDto, y, i));
                     if (Objects.isNull(loginName) || loginName.length() > 30 || !loginName.matches(SystemConstant.REGULAR_EXPRESSION_OF_CODE)) {
-                        excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[账号]不符合输入规范"));
+                        excelErrorTemp.add(new ExcelError(y + 1, "第" + (i + 1) + "个sheet第" + (y + 1) + "行[账号]不符合输入规范,不为输入中文"));
                     }
                     if (Objects.isNull(name) || name.length() > 30) {
-                        excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[姓名]不符合输入规范"));
+                        excelErrorTemp.add(new ExcelError(y + 1, "第" + (i + 1) + "个sheet第" + (y + 1) + "行[姓名]不符合输入规范"));
                     }
 //                    if (Objects.nonNull(phoneNumber) && !phoneNumber.matches(SystemConstant.REGULAR_EXPRESSION_OF_PHONE)) {
 //                        excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[电话号码]不符合输入规范"));

+ 5 - 5
paper-library-common/src/main/java/com/qmth/paper/library/common/service/impl/TBTaskServiceImpl.java

@@ -91,11 +91,11 @@ public class TBTaskServiceImpl extends ServiceImpl<TBTaskMapper, TBTask> impleme
                 JSONObject jsonObject = JSON.parseObject(importFilePath, JSONObject.class);
                 record.setImportFilePath(libraryCommonService.preViewPath(jsonObject.getString(SystemConstant.PATH), jsonObject.getString(SystemConstant.UPLOAD_TYPE), jsonObject.getString(SystemConstant.TYPE), false));
             }
-            String txtFilePath = record.getTxtFilePath();
-            if (StringUtils.isNotBlank(txtFilePath)) {
-                JSONObject jsonObject = JSON.parseObject(txtFilePath, JSONObject.class);
-                record.setTxtFilePath(libraryCommonService.preViewPath(jsonObject.getString(SystemConstant.PATH), jsonObject.getString(SystemConstant.UPLOAD_TYPE), jsonObject.getString(SystemConstant.TYPE), false));
-            }
+//            String txtFilePath = record.getTxtFilePath();
+//            if (StringUtils.isNotBlank(txtFilePath)) {
+//                JSONObject jsonObject = JSON.parseObject(txtFilePath, JSONObject.class);
+//                record.setTxtFilePath(libraryCommonService.preViewPath(jsonObject.getString(SystemConstant.PATH), jsonObject.getString(SystemConstant.UPLOAD_TYPE), jsonObject.getString(SystemConstant.TYPE), false));
+//            }
             String exportFilePath = record.getExportFilePath();
             if (StringUtils.isNotBlank(exportFilePath)) {
                 JSONObject jsonObject = JSON.parseObject(exportFilePath, JSONObject.class);

+ 3 - 0
paper-library-common/src/main/java/com/qmth/paper/library/common/util/FileStoreUtil.java

@@ -267,6 +267,9 @@ public class FileStoreUtil {
                 for (File listFile : file.listFiles()) {
                     deleteFile(listFile.getPath());
                 }
+                if(file.isDirectory() && file.listFiles().length == 0){
+                    file.delete();
+                }
             }
         }
         return true;

+ 1 - 0
paper-library-common/src/main/resources/mapper/TBTaskMapper.xml

@@ -14,6 +14,7 @@
             tbt.import_file_path importFilePath,
             tbt.export_file_path exportFilePath,
             tbt.txt_file_path txtFilePath,
+            tbt.summary,
             tbt.`remark`,
             tbt.create_time as createTime,
             tbt.create_id as createId,

+ 28 - 0
paper-library/src/test/java/com/qmth/paper/library/FileTest.java

@@ -0,0 +1,28 @@
+package com.qmth.paper.library;
+
+import java.io.File;
+
+public class FileTest {
+    public static void main(String[] args) {
+//        File file = new File("/Users/xiaofei/qmth/temporary/paperlibrary/file-temp/image/test-school-1");
+        File file = new File("/Users/xiaofei/qmth/temporary/paperlibrary/file-temp/image/test-school-1");
+        deleteFile(file.getPath());
+    }
+
+    public static boolean deleteFile(String dirName) {
+        File file = new File(dirName);
+        if (file.exists()) {
+            if (file.isFile()) {
+//                file.delete();
+            } else {
+                for (File listFile : file.listFiles()) {
+                    deleteFile(listFile.getPath());
+                }
+                if(file.isDirectory() && file.listFiles().length == 0){
+                    file.delete();
+                }
+            }
+        }
+        return true;
+    }
+}