|
@@ -4,6 +4,7 @@ import java.io.File;
|
|
import java.util.Calendar;
|
|
import java.util.Calendar;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
import javax.persistence.CacheRetrieveMode;
|
|
import javax.persistence.CacheRetrieveMode;
|
|
import javax.persistence.EntityManager;
|
|
import javax.persistence.EntityManager;
|
|
@@ -21,6 +22,7 @@ import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
|
|
+import com.google.common.collect.Maps;
|
|
|
|
|
|
import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
import cn.com.qmth.examcloud.commons.base.helpers.poi.ExcelParser;
|
|
import cn.com.qmth.examcloud.commons.base.helpers.poi.ExcelParser;
|
|
@@ -80,7 +82,7 @@ public class ExamStudentImportServiceImpl implements ExamStudentImportService {
|
|
long batchId = System.currentTimeMillis();
|
|
long batchId = System.currentTimeMillis();
|
|
|
|
|
|
ExamStudentImportResult result = new ExamStudentImportResult();
|
|
ExamStudentImportResult result = new ExamStudentImportResult();
|
|
- List<String> failRecords = Lists.newArrayList();
|
|
|
|
|
|
+ List<Map<String, Object>> failRecords = Lists.newArrayList();
|
|
result.setFailRecords(failRecords);
|
|
result.setFailRecords(failRecords);
|
|
|
|
|
|
for (int i = 0; i < lineList.size(); i++) {
|
|
for (int i = 0; i < lineList.size(); i++) {
|
|
@@ -135,7 +137,7 @@ public class ExamStudentImportServiceImpl implements ExamStudentImportService {
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
- private void findError(List<String> failRecords, long batchId) {
|
|
|
|
|
|
+ private void findError(List<Map<String, Object>> failRecords, long batchId) {
|
|
EntityManager em = entityManagerFactory.createEntityManager();
|
|
EntityManager em = entityManagerFactory.createEntityManager();
|
|
Query query = em.createQuery("select s from ExamStudentTempEntity s where "
|
|
Query query = em.createQuery("select s from ExamStudentTempEntity s where "
|
|
+ "s.batchId=:batchId and (s.orgId is null or s.courseId is null) order by s.lineNum",
|
|
+ "s.batchId=:batchId and (s.orgId is null or s.courseId is null) order by s.lineNum",
|
|
@@ -149,7 +151,6 @@ public class ExamStudentImportServiceImpl implements ExamStudentImportService {
|
|
for (ExamStudentTempEntity cur : errorList) {
|
|
for (ExamStudentTempEntity cur : errorList) {
|
|
boolean hasError = false;
|
|
boolean hasError = false;
|
|
StringBuilder sb = new StringBuilder();
|
|
StringBuilder sb = new StringBuilder();
|
|
- sb.append("第" + cur.getLineNum() + "行");
|
|
|
|
if (null == cur.getOrgId()) {
|
|
if (null == cur.getOrgId()) {
|
|
sb.append(" 学习中心不存在或禁用");
|
|
sb.append(" 学习中心不存在或禁用");
|
|
hasError = true;
|
|
hasError = true;
|
|
@@ -160,16 +161,18 @@ public class ExamStudentImportServiceImpl implements ExamStudentImportService {
|
|
}
|
|
}
|
|
|
|
|
|
if (hasError) {
|
|
if (hasError) {
|
|
- failRecords.add(sb.toString());
|
|
|
|
|
|
+ Map<String, Object> map = Maps.newHashMap();
|
|
|
|
+ map.put("lineNum", cur.getLineNum());
|
|
|
|
+ map.put("msg", sb.toString());
|
|
|
|
+ failRecords.add(map);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- public boolean hasError(List<String> failRecords, ExamStudentTempEntity entity) {
|
|
|
|
|
|
+ public boolean hasError(List<Map<String, Object>> failRecords, ExamStudentTempEntity entity) {
|
|
boolean hasError = false;
|
|
boolean hasError = false;
|
|
StringBuilder sb = new StringBuilder();
|
|
StringBuilder sb = new StringBuilder();
|
|
- sb.append("第" + entity.getLineNum() + "行");
|
|
|
|
|
|
|
|
String name = entity.getName();
|
|
String name = entity.getName();
|
|
if (StringUtils.isBlank(name)) {
|
|
if (StringUtils.isBlank(name)) {
|
|
@@ -222,7 +225,10 @@ public class ExamStudentImportServiceImpl implements ExamStudentImportService {
|
|
}
|
|
}
|
|
|
|
|
|
if (hasError) {
|
|
if (hasError) {
|
|
- failRecords.add(sb.toString());
|
|
|
|
|
|
+ Map<String, Object> map = Maps.newHashMap();
|
|
|
|
+ map.put("lineNum", entity.getLineNum());
|
|
|
|
+ map.put("msg", sb.toString());
|
|
|
|
+ failRecords.add(map);
|
|
}
|
|
}
|
|
|
|
|
|
return hasError;
|
|
return hasError;
|