wangwei 7 роки тому
батько
коміт
265b452390

+ 11 - 3
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/impl/ExamStudentImportServiceImpl.java

@@ -127,7 +127,7 @@ public class ExamStudentImportServiceImpl implements ExamStudentImportService {
 
 		examStudentTempRepo.processExamStudentTemp(batchId);
 
-		saveExamStudents(batchId);
+		saveExamStudents(failRecords, batchId);
 
 		delete(batchId);
 
@@ -250,7 +250,7 @@ public class ExamStudentImportServiceImpl implements ExamStudentImportService {
 		transaction.commit();
 	}
 
-	private void saveExamStudents(Long batchId) {
+	private void saveExamStudents(List<Map<String, Object>> failRecords, Long batchId) {
 		EntityManager em = entityManagerFactory.createEntityManager();
 		Query query = em.createQuery("select s from ExamStudentTempEntity s where "
 				+ "s.name is not null and s.orgId is not null and s.identityNumber is not null "
@@ -265,8 +265,16 @@ public class ExamStudentImportServiceImpl implements ExamStudentImportService {
 
 			try {
 				saveExamStudent(examStudent);
+			} catch (StatusException e) {
+				Map<String, Object> map = Maps.newHashMap();
+				map.put("lineNum", examStudent.getLineNum());
+				map.put("msg", e.getDesc());
+				failRecords.add(map);
 			} catch (Exception e) {
-				e.printStackTrace();
+				Map<String, Object> map = Maps.newHashMap();
+				map.put("lineNum", examStudent.getLineNum());
+				map.put("msg", e.getMessage());
+				failRecords.add(map);
 			}
 		}
 	}