Эх сурвалжийг харах

导入考生时学生不能重复BUG修复

wangliang 2 жил өмнө
parent
commit
dfd2580387

+ 4 - 8
themis-business/src/main/java/com/qmth/themis/business/forkjoin/ExamStudentImportForkJoin.java

@@ -87,8 +87,6 @@ public class ExamStudentImportForkJoin extends RecursiveTask<Set<String>> {
             List<TEExamStudent> teExamStudentUpdateList = new ArrayList<>();
             Map<String, TEStudent> teStudentInsertMap = new HashMap<>();
             Map<String, TEStudent> teStudentUpdateMap = new HashMap<>();
-            List<TEStudent> teStudentInsertList = new ArrayList<>();
-            List<TEStudent> teStudentUpdateList = new ArrayList<>();
             for (int i = start; i <= end; i++) {
                 ExamStudentImportDto examStudentImportDto = (ExamStudentImportDto) list.get(i);
                 if (Objects.equals(modeEnum, ExamModeEnum.TOGETHER)) {
@@ -147,12 +145,10 @@ public class ExamStudentImportForkJoin extends RecursiveTask<Set<String>> {
                 if (teStudentExists) {
                     if (!teStudentInsertMap.containsKey(teStudent.toString())) {
                         teStudentInsertMap.put(teStudent.toString(), teStudent);
-                        teStudentInsertList.add(teStudent);
                     }
                 } else {
                     if (!teStudentUpdateMap.containsKey(teStudent.toString())) {
                         teStudentUpdateMap.put(teStudent.toString(), teStudent);
-                        teStudentUpdateList.add(teStudent);
                     }
                 }
 
@@ -170,11 +166,11 @@ public class ExamStudentImportForkJoin extends RecursiveTask<Set<String>> {
                     teExamStudentUpdateList.add(teExamStudent);
                 }
             }
-            if (!CollectionUtils.isEmpty(teStudentInsertList)) {
-                teStudentService.saveBatch(teStudentInsertList);
+            if (!CollectionUtils.isEmpty(teStudentInsertMap)) {
+                teStudentService.saveBatch(teStudentInsertMap.values());
             }
-            if (!CollectionUtils.isEmpty(teStudentUpdateList)) {
-                teStudentService.updateBatchById(teStudentUpdateList);
+            if (!CollectionUtils.isEmpty(teStudentUpdateMap)) {
+                teStudentService.updateBatchById(teStudentUpdateMap.values());
             }
             if (!CollectionUtils.isEmpty(teExamStudentInsertList)) {
                 teExamStudentService.saveBatch(teExamStudentInsertList);