Przeglądaj źródła

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

wangliang 2 lat temu
rodzic
commit
ec25d0000c

+ 28 - 1
themis-business/src/main/java/com/qmth/themis/business/entity/TEStudent.java

@@ -5,12 +5,13 @@ import com.baomidou.mybatisplus.annotation.TableField;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.qmth.themis.business.base.BaseEntity;
-import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.enums.GenderEnum;
 import com.qmth.themis.business.util.UidUtil;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
+import java.util.Objects;
+
 /**
  * @Description: 学生档案
  * @Param:
@@ -141,4 +142,30 @@ public class TEStudent extends BaseEntity {
     public void setGender(GenderEnum gender) {
         this.gender = gender;
     }
+
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        TEStudent teStudent = (TEStudent) o;
+        return orgId.equals(teStudent.orgId) && identity.equals(teStudent.identity);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(orgId, identity);
+    }
+
+    @Override
+    public String toString() {
+        return "TEStudent{" +
+                "orgId=" + orgId +
+                ", identity='" + identity + '\'' +
+                '}';
+    }
 }

+ 10 - 2
themis-business/src/main/java/com/qmth/themis/business/forkjoin/ExamStudentImportForkJoin.java

@@ -85,6 +85,8 @@ public class ExamStudentImportForkJoin extends RecursiveTask<Set<String>> {
 
             List<TEExamStudent> teExamStudentInsertList = new ArrayList<>();
             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++) {
@@ -143,9 +145,15 @@ public class ExamStudentImportForkJoin extends RecursiveTask<Set<String>> {
                 teStudent.setMobileNumber(examStudentImportDto.getMobileNumber());
                 teStudent.setName(examStudentImportDto.getName());
                 if (teStudentExists) {
-                    teStudentInsertList.add(teStudent);
+                    if (!teStudentInsertMap.containsKey(teStudent.toString())) {
+                        teStudentInsertMap.put(teStudent.toString(), teStudent);
+                        teStudentInsertList.add(teStudent);
+                    }
                 } else {
-                    teStudentUpdateList.add(teStudent);
+                    if (!teStudentUpdateMap.containsKey(teStudent.toString())) {
+                        teStudentUpdateMap.put(teStudent.toString(), teStudent);
+                        teStudentUpdateList.add(teStudent);
+                    }
                 }
 
                 ExamCourseCacheBean examCourseCacheBean = teExamCourseService.getExamCourseCacheBean(teExamStudent.getExamId(), teExamStudent.getCourseCode());