xiaofei 11 сар өмнө
parent
commit
73ceb17680

+ 9 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/importFile/BasicExamStudentImport.java

@@ -48,6 +48,7 @@ public class BasicExamStudentImport {
     private List<CodeNameEnableDisabledValue> extendFieldList = new ArrayList<>();
     @ApiModelProperty("错误信息")
     private String errorMsg;
+    private int rowIndex;
 
     public String getCourseCode() {
         return courseCode;
@@ -208,4 +209,12 @@ public class BasicExamStudentImport {
     public void setErrorMsg(String errorMsg) {
         this.errorMsg = errorMsg;
     }
+
+    public int getRowIndex() {
+        return rowIndex;
+    }
+
+    public void setRowIndex(int rowIndex) {
+        this.rowIndex = rowIndex;
+    }
 }

+ 34 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/ImportLogicServiceImpl.java

@@ -131,6 +131,8 @@ public class ImportLogicServiceImpl implements ImportLogicService {
         boolean needPaperNumber = (basicSchool.getHasPaperNumber() != null && basicSchool.getHasPaperNumber()) || ExamModelEnum.MODEL4.equals(basicExam.getExamModel());
 
         Map<String, Long> basicCourseIdMap = new HashMap<>();
+        // 课程学号唯一
+        List<String> courseCodeStudentCodeList = new ArrayList<>();
         // 是否有错误提示
         boolean hasError = false;
 
@@ -210,6 +212,14 @@ public class ImportLogicServiceImpl implements ImportLogicService {
                 }
             }
 
+            // 校验课程学号唯一
+            String courseCodeStudentCode = basicExamStudentImport.getCourseCode()+basicExamStudentImport.getStudentCode();
+            if(courseCodeStudentCodeList.contains(courseCodeStudentCode)){
+                stringJoiner.add("课程代码[" + basicExamStudentImport.getCourseCode() + "]已存在学号["+basicExamStudentImport.getStudentCode()+"]的考生数据");
+            } else{
+                courseCodeStudentCodeList.add(courseCodeStudentCode);
+            }
+
             if (basicExamStudent.getCourseId() != null) {
                 if (courseIdStudentCodeMap.containsKey(basicExamStudent.getCourseId() + SystemConstant.HYPHEN + basicExamStudent.getStudentCode())) {
                     basicExamStudent.setId(courseIdStudentCodeMap.get(basicExamStudent.getCourseId() + SystemConstant.HYPHEN + basicExamStudent.getStudentCode()));
@@ -296,6 +306,9 @@ public class ImportLogicServiceImpl implements ImportLogicService {
         Map<String, BasicCourse> courseCodeNameInBasicCourseMap = new HashMap<>();
         List<BasicCourse> basicCourseList = basicCourseService.list(new QueryWrapper<BasicCourse>().lambda().eq(BasicCourse::getSchoolId, schoolId));
         basicCourseList.forEach(e -> courseCodeNameInBasicCourseMap.put(e.getTeachingRoomId().toString().concat(e.getCode()), e));
+
+        // 课程学号唯一
+        List<String> courseCodeStudentCodeList = new ArrayList<>();
         // 是否有错误提示
         boolean hasError = false;
 
@@ -404,6 +417,14 @@ public class ImportLogicServiceImpl implements ImportLogicService {
                 }
             }
 
+            // 校验课程学号唯一
+            String courseCodeStudentCode = basicExamStudentImport.getCourseCode()+basicExamStudentImport.getStudentCode();
+            if(courseCodeStudentCodeList.contains(courseCodeStudentCode)){
+                stringJoiner.add("课程代码[" + basicExamStudentImport.getCourseCode() + "]已存在学号["+basicExamStudentImport.getStudentCode()+"]的考生数据");
+            } else{
+                courseCodeStudentCodeList.add(courseCodeStudentCode);
+            }
+
             if (stringJoiner.toString().length() > 0) {
                 basicExamStudentImport.setErrorMsg(stringJoiner.toString());
             }
@@ -460,8 +481,10 @@ public class ImportLogicServiceImpl implements ImportLogicService {
 
             basicExamStudentParseDto.setColumnNames(columnNames);
 
+            AtomicInteger i = new AtomicInteger(2);
             dataMapList.forEach(m -> {
                 BasicExamStudentImport basicExamStudentImport = new BasicExamStudentImport();
+                basicExamStudentImport.setRowIndex(i.getAndIncrement());
                 Class<BasicExamStudentImport> aClass = (Class<BasicExamStudentImport>) basicExamStudentImport.getClass();
                 for (Map.Entry<String, String> entry : m.entrySet()) {
                     // 必填字段
@@ -1055,6 +1078,9 @@ public class ImportLogicServiceImpl implements ImportLogicService {
         Map<String, BasicExamStudent> courseIdStudentCodeMap = basicExamStudentList.stream().collect(Collectors.toMap(k -> k.getCourseId() + SystemConstant.HYPHEN + k.getStudentCode(), e -> e));
 
         Map<String, Long> basicCourseIdMap = new HashMap<>();
+
+        // 课程学号唯一
+        List<String> courseCodeStudentCodeList = new ArrayList<>();
         // 是否有错误提示
         boolean hasError = false;
 
@@ -1128,6 +1154,14 @@ public class ImportLogicServiceImpl implements ImportLogicService {
                 }
             }
 
+            // 校验课程学号唯一
+            String courseCodeStudentCode = basicExamStudentImport.getCourseCode()+basicExamStudentImport.getStudentCode();
+            if(courseCodeStudentCodeList.contains(courseCodeStudentCode)){
+                stringJoiner.add("课程代码[" + basicExamStudentImport.getCourseCode() + "]已存在学号["+basicExamStudentImport.getStudentCode()+"]的考生数据");
+            } else{
+                courseCodeStudentCodeList.add(courseCodeStudentCode);
+            }
+
             if (stringJoiner.toString().length() > 0) {
                 basicExamStudentImport.setErrorMsg(stringJoiner.toString());
             }