|
@@ -3,6 +3,12 @@ package cn.com.qmth.examcloud.core.examwork.service.impl;
|
|
|
import java.io.File;
|
|
|
import java.util.List;
|
|
|
|
|
|
+import javax.persistence.CacheRetrieveMode;
|
|
|
+import javax.persistence.EntityManager;
|
|
|
+import javax.persistence.EntityManagerFactory;
|
|
|
+import javax.persistence.PersistenceUnit;
|
|
|
+import javax.persistence.Query;
|
|
|
+
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
@@ -51,6 +57,9 @@ public class ExamStudentImportServiceImpl implements ExamStudentImportService {
|
|
|
@Autowired
|
|
|
ExamStudentCloudService examStudentCloudService;
|
|
|
|
|
|
+ @PersistenceUnit
|
|
|
+ private EntityManagerFactory entityManagerFactory;
|
|
|
+
|
|
|
@Override
|
|
|
public void importExamStudent(File file, String fileName, Long rootOrgId, Long examId) {
|
|
|
Workbook workBook = ExcelParser.getWorkBook(file, fileName);
|
|
@@ -104,7 +113,15 @@ public class ExamStudentImportServiceImpl implements ExamStudentImportService {
|
|
|
}
|
|
|
|
|
|
private void saveExamStudents(Long batchId) {
|
|
|
- List<ExamStudentTempEntity> list = examStudentTempRepo.findRight(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 "
|
|
|
+ + "and s.courseId is not null and s.batchId=:batchId", ExamStudentTempEntity.class);
|
|
|
+ query.setHint("javax.persistence.cache.retrieveMode", CacheRetrieveMode.BYPASS);
|
|
|
+ query.setParameter("batchId", batchId);
|
|
|
+
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ List<ExamStudentTempEntity> list = query.getResultList();
|
|
|
|
|
|
for (ExamStudentTempEntity examStudent : list) {
|
|
|
|