xiaofei преди 1 година
родител
ревизия
da9f63353a

+ 2 - 2
paper-library-business/pom.xml

@@ -4,7 +4,7 @@
     <modelVersion>4.0.0</modelVersion>
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.qmth.paper.library.business</groupId>
     <groupId>com.qmth.paper.library.business</groupId>
     <artifactId>paper-library-business</artifactId>
     <artifactId>paper-library-business</artifactId>
-    <version>1.0.3</version>
+    <version>1.0.4</version>
     <build>
     <build>
         <plugins>
         <plugins>
             <plugin>
             <plugin>
@@ -22,7 +22,7 @@
     <parent>
     <parent>
         <groupId>com.qmth.paper.library.service</groupId>
         <groupId>com.qmth.paper.library.service</groupId>
         <artifactId>paper-library-service</artifactId>
         <artifactId>paper-library-service</artifactId>
-        <version>1.0.3</version>
+        <version>1.0.4</version>
     </parent>
     </parent>
 
 
     <dependencies>
     <dependencies>

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

@@ -40,7 +40,7 @@ public interface ExamStudentService extends IService<ExamStudent> {
 
 
     void updateBindCount(Long studentId);
     void updateBindCount(Long studentId);
 
 
-    void removeByExamId(Long examId);
+    void removeByExamIdAndCourseCode(Long examId, String courseCode);
 
 
     int countByExamIdAndCourseCode(Long examId, String courseCode);
     int countByExamIdAndCourseCode(Long examId, String courseCode);
 }
 }

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

@@ -38,5 +38,5 @@ public interface PaperLibraryService extends IService<PaperLibrary> {
 
 
     int countByStudentId(Long studentId);
     int countByStudentId(Long studentId);
 
 
-    int countByExamId(Long examId);
+    int countByPaperScanTaskId(Long paperScanTaskId);
 }
 }

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

@@ -6,9 +6,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
 import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
 import com.qmth.paper.library.business.bean.result.SelectResult;
 import com.qmth.paper.library.business.bean.result.SelectResult;
 import com.qmth.paper.library.business.entity.ExamCourse;
 import com.qmth.paper.library.business.entity.ExamCourse;
+import com.qmth.paper.library.business.entity.PaperLibrary;
 import com.qmth.paper.library.business.entity.PaperScanTask;
 import com.qmth.paper.library.business.entity.PaperScanTask;
 import com.qmth.paper.library.business.mapper.ExamCourseMapper;
 import com.qmth.paper.library.business.mapper.ExamCourseMapper;
 import com.qmth.paper.library.business.service.ExamCourseService;
 import com.qmth.paper.library.business.service.ExamCourseService;
+import com.qmth.paper.library.business.service.PaperLibraryService;
 import com.qmth.paper.library.business.service.PaperScanTaskService;
 import com.qmth.paper.library.business.service.PaperScanTaskService;
 import com.qmth.paper.library.common.entity.ExamStudent;
 import com.qmth.paper.library.common.entity.ExamStudent;
 import com.qmth.paper.library.common.enums.ExceptionResultEnum;
 import com.qmth.paper.library.common.enums.ExceptionResultEnum;
@@ -35,6 +37,8 @@ public class ExamCourseServiceImpl extends MppServiceImpl<ExamCourseMapper, Exam
 
 
     @Resource
     @Resource
     private PaperScanTaskService paperScanTaskService;
     private PaperScanTaskService paperScanTaskService;
+    @Resource
+    private PaperLibraryService paperLibraryService;
 
 
     @Transactional
     @Transactional
     @Override
     @Override
@@ -43,8 +47,9 @@ public class ExamCourseServiceImpl extends MppServiceImpl<ExamCourseMapper, Exam
         List<ExamCourse> examCourses = new ArrayList<>();
         List<ExamCourse> examCourses = new ArrayList<>();
         for (Map.Entry<String, String> entry : stringMap.entrySet()) {
         for (Map.Entry<String, String> entry : stringMap.entrySet()) {
             PaperScanTask paperScanTask = paperScanTaskService.getByExamIdAndCourseCode(examId, entry.getKey());
             PaperScanTask paperScanTask = paperScanTaskService.getByExamIdAndCourseCode(examId, entry.getKey());
-            if (paperScanTask != null) {
-                throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)]已创建扫描任务,不能导入该课程考生,请手动添加", entry.getValue(), entry.getKey()));
+            // 校验是否已扫描
+            if (paperScanTask != null && paperLibraryService.countByPaperScanTaskId(paperScanTask.getId()) > 0) {
+                throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)]已开始扫描,导入失败。请清除扫描数据后重试", entry.getValue(), entry.getKey()));
             }
             }
             examCourses.add(new ExamCourse(examId, entry.getKey(), entry.getValue()));
             examCourses.add(new ExamCourse(examId, entry.getKey(), entry.getValue()));
         }
         }

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

@@ -186,10 +186,6 @@ public class ExamStudentServiceImpl extends ServiceImpl<ExamStudentMapper, ExamS
         RecognitionTypeEnum recognitionType = RecognitionTypeEnum.valueOf(recognitionTypeSimpleObject.getValue());
         RecognitionTypeEnum recognitionType = RecognitionTypeEnum.valueOf(recognitionTypeSimpleObject.getValue());
         StoreTypeEnum storeType = StoreTypeEnum.valueOf(storeTypeSimpleObject.getValue());
         StoreTypeEnum storeType = StoreTypeEnum.valueOf(storeTypeSimpleObject.getValue());
 
 
-        // 校验是否已扫描
-        if (paperLibraryService.countByExamId(examId) > 0) {
-            throw ExceptionResultEnum.ERROR.exception("已开始扫描,导入失败。请清除扫描数据后重试");
-        }
         try {
         try {
             ExcelReader excelReader = ExcelReader.create(ExcelType.XLSX, file.getInputStream(), 0);
             ExcelReader excelReader = ExcelReader.create(ExcelType.XLSX, file.getInputStream(), 0);
             List<ExamStudent> basicStudentList = excelReader.getObjectList(ExamStudent.class);
             List<ExamStudent> basicStudentList = excelReader.getObjectList(ExamStudent.class);
@@ -198,7 +194,10 @@ public class ExamStudentServiceImpl extends ServiceImpl<ExamStudentMapper, ExamS
             // 保存课程
             // 保存课程
             List<ExamCourse> examCourses = examCourseService.saveBatchStudentCourse(examId, basicStudentList);
             List<ExamCourse> examCourses = examCourseService.saveBatchStudentCourse(examId, basicStudentList);
             // 新建任务
             // 新建任务
-            paperScanTaskService.addBatchScanTask(examId, recognitionType, storeType, examCourses,  basicStudentList);
+            paperScanTaskService.addBatchScanTask(examId, recognitionType, storeType, examCourses, basicStudentList);
+            for (ExamCourse examCourse : examCourses) {
+                this.removeByExamIdAndCourseCode(examId, examCourse.getCourseCode());
+            }
             // 保存学生
             // 保存学生
             this.saveBatch(basicStudentList);
             this.saveBatch(basicStudentList);
         } catch (IOException e) {
         } catch (IOException e) {
@@ -217,9 +216,10 @@ public class ExamStudentServiceImpl extends ServiceImpl<ExamStudentMapper, ExamS
     }
     }
 
 
     @Override
     @Override
-    public void removeByExamId(Long examId) {
+    public void removeByExamIdAndCourseCode(Long examId, String courseCode) {
         QueryWrapper<ExamStudent> queryWrapper = new QueryWrapper<>();
         QueryWrapper<ExamStudent> queryWrapper = new QueryWrapper<>();
-        queryWrapper.lambda().eq(ExamStudent::getExamId, examId);
+        queryWrapper.lambda().eq(ExamStudent::getExamId, examId)
+                .eq(ExamStudent::getCourseCode, courseCode);
         this.remove(queryWrapper);
         this.remove(queryWrapper);
     }
     }
 
 

+ 4 - 12
paper-library-business/src/main/java/com/qmth/paper/library/business/service/impl/PaperLibraryServiceImpl.java

@@ -274,18 +274,10 @@ public class PaperLibraryServiceImpl extends ServiceImpl<PaperLibraryMapper, Pap
     }
     }
 
 
     @Override
     @Override
-    public int countByExamId(Long examId) {
-        List<PaperScanTask> paperScanTaskList = paperScanTaskService.listByExamId(examId);
-        for (PaperScanTask paperScanTask : paperScanTaskList) {
-            QueryWrapper<PaperLibrary> queryWrapper = new QueryWrapper<>();
-            queryWrapper.lambda().eq(PaperLibrary::getPaperScanTaskId, paperScanTask.getId());
-            int count = this.count(queryWrapper);
-            if (count > 0) {
-                return count;
-            }
-        }
-        return 0;
-
+    public int countByPaperScanTaskId(Long paperScanTaskId) {
+        QueryWrapper<PaperLibrary> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(PaperLibrary::getPaperScanTaskId, paperScanTaskId);
+        return this.count(queryWrapper);
     }
     }
 
 
 }
 }

+ 2 - 2
paper-library-common/pom.xml

@@ -4,13 +4,13 @@
     <modelVersion>4.0.0</modelVersion>
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.qmth.paper.library.common</groupId>
     <groupId>com.qmth.paper.library.common</groupId>
     <artifactId>paper-library-common</artifactId>
     <artifactId>paper-library-common</artifactId>
-    <version>1.0.3</version>
+    <version>1.0.4</version>
     <packaging>jar</packaging>
     <packaging>jar</packaging>
 
 
     <parent>
     <parent>
         <groupId>com.qmth.paper.library.service</groupId>
         <groupId>com.qmth.paper.library.service</groupId>
         <artifactId>paper-library-service</artifactId>
         <artifactId>paper-library-service</artifactId>
-        <version>1.0.3</version>
+        <version>1.0.4</version>
     </parent>
     </parent>
 
 
     <dependencies>
     <dependencies>

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

@@ -183,7 +183,7 @@ CREATE TABLE IF NOT EXISTS `exam_student` (
   `update_id` bigint DEFAULT NULL COMMENT '更新人id',
   `update_id` bigint DEFAULT NULL COMMENT '更新人id',
   `update_time` bigint DEFAULT NULL COMMENT '更新时间',
   `update_time` bigint DEFAULT NULL COMMENT '更新时间',
   PRIMARY KEY (`id`) USING BTREE,
   PRIMARY KEY (`id`) USING BTREE,
-  UNIQUE KEY `idx_1` (`exam_id`,`course_code`,`student_code`) USING BTREE
+  KEY `idx_1` (`exam_id`,`course_code`,`student_code`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='学校id';
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='学校id';
 
 
 -- ----------------------------
 -- ----------------------------

+ 2 - 2
paper-library/pom.xml

@@ -4,13 +4,13 @@
     <modelVersion>4.0.0</modelVersion>
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.qmth.paper.library</groupId>
     <groupId>com.qmth.paper.library</groupId>
     <artifactId>paper-library</artifactId>
     <artifactId>paper-library</artifactId>
-    <version>1.0.3</version>
+    <version>1.0.4</version>
     <packaging>jar</packaging>
     <packaging>jar</packaging>
 
 
     <parent>
     <parent>
         <groupId>com.qmth.paper.library.service</groupId>
         <groupId>com.qmth.paper.library.service</groupId>
         <artifactId>paper-library-service</artifactId>
         <artifactId>paper-library-service</artifactId>
-        <version>1.0.3</version>
+        <version>1.0.4</version>
     </parent>
     </parent>
 
 
     <dependencies>
     <dependencies>

+ 1 - 1
pom.xml

@@ -4,7 +4,7 @@
     <modelVersion>4.0.0</modelVersion>
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.qmth.paper.library.service</groupId>
     <groupId>com.qmth.paper.library.service</groupId>
     <artifactId>paper-library-service</artifactId>
     <artifactId>paper-library-service</artifactId>
-    <version>1.0.3</version>
+    <version>1.0.4</version>
     <packaging>pom</packaging>
     <packaging>pom</packaging>
 
 
     <modules>
     <modules>