|
@@ -225,61 +225,67 @@ public class DataUploadService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public ExcelError handle(Object obj) {
|
|
public ExcelError handle(Object obj) {
|
|
- StudentDTO dto = (StudentDTO) obj;
|
|
|
|
|
|
+ try {
|
|
|
|
+ StudentDTO dto = (StudentDTO) obj;
|
|
|
|
|
|
- String examNumber = dto.getExamNumber();
|
|
|
|
- //如果没有设置区域代码,用准考证前2位作为区域代码
|
|
|
|
- String areaCode = null;
|
|
|
|
- if (dto.getAreaCode() == null || dto.getAreaCode().isEmpty()) {
|
|
|
|
- areaCode = examNumber.substring(0, 2);
|
|
|
|
- dto.setAreaCode(areaCode);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- long isExist = examQuestionRepo.countByWorkIdAndAreaCode(workId, dto.getAreaCode());
|
|
|
|
- if (isExist == 0) {
|
|
|
|
- for (Subject subject : Subject.values()) {
|
|
|
|
- ExamQuestion question = new ExamQuestion(dto.getAreaCode(), subject, workId, dto.getAreaName());
|
|
|
|
- examQuestionRepo.save(question);
|
|
|
|
|
|
+ String examNumber = dto.getExamNumber();
|
|
|
|
+ //如果没有设置区域代码,用准考证前2位作为区域代码
|
|
|
|
+ String areaCode = null;
|
|
|
|
+ if (dto.getAreaCode() == null || dto.getAreaCode().isEmpty()) {
|
|
|
|
+ areaCode = examNumber.substring(0, 2);
|
|
|
|
+ dto.setAreaCode(areaCode);
|
|
}
|
|
}
|
|
- }
|
|
|
|
- Student student = studentRepo.findByWorkIdAndExamNumber(workId, dto.getExamNumber());
|
|
|
|
- if (student == null && !isAbsent) {
|
|
|
|
- student = new Student(dto.getName(), dto.getExamNumber(), dto.getAreaName(), dto.getAreaCode(),
|
|
|
|
- workId, dto.getExamRoom(), dto.getSourceName());
|
|
|
|
- if (!checkObjFieldIsNotNull(student)) {
|
|
|
|
- throw new RuntimeException("考生信息缺失");
|
|
|
|
|
|
+
|
|
|
|
+ long isExist = examQuestionRepo.countByWorkIdAndAreaCode(workId, dto.getAreaCode());
|
|
|
|
+ if (isExist == 0) {
|
|
|
|
+ for (Subject subject : Subject.values()) {
|
|
|
|
+ ExamQuestion question = new ExamQuestion(dto.getAreaCode(), subject, workId, dto.getAreaName());
|
|
|
|
+ examQuestionRepo.save(question);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- studentRepo.save(student);
|
|
|
|
- } else if (student != null) {
|
|
|
|
- if (isAbsent) {
|
|
|
|
- student.setAbsent(isAbsent);
|
|
|
|
- student.setUploadStatus("SX:0,SC:0,SM:0");
|
|
|
|
|
|
+ Student student = studentRepo.findByWorkIdAndExamNumber(workId, dto.getExamNumber());
|
|
|
|
+ if (student == null && !isAbsent) {
|
|
|
|
+ student = new Student(dto.getName(), dto.getExamNumber(), dto.getAreaName(), dto.getAreaCode(),
|
|
|
|
+ workId, dto.getExamRoom(), dto.getSourceName());
|
|
|
|
+ if (!checkObjFieldIsNotNull(student)) {
|
|
|
|
+ throw new RuntimeException("考生信息缺失");
|
|
|
|
+ }
|
|
|
|
+ studentRepo.save(student);
|
|
|
|
+ } else if (student != null) {
|
|
|
|
+ if (isAbsent) {
|
|
|
|
+ student.setAbsent(isAbsent);
|
|
|
|
+ student.setUploadStatus("SX:0,SC:0,SM:0");
|
|
|
|
|
|
- /**
|
|
|
|
- * 查询该考生所有paper,若paper无任务则删除,有任务就保留
|
|
|
|
- */
|
|
|
|
- List<Paper> papers = paperRepo.findByWorkIdAndExamNumber(workId, student.getExamNumber());
|
|
|
|
- if (!papers.isEmpty()) {
|
|
|
|
- for (Paper paper : papers) {
|
|
|
|
- Long count = markTaskRepo.countByPaperId(paper.getId());
|
|
|
|
- if (count == 0) {
|
|
|
|
- paperRepo.delete(paper);
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 查询该考生所有paper,若paper无任务则删除,有任务就保留
|
|
|
|
+ */
|
|
|
|
+ List<Paper> papers = paperRepo.findByWorkIdAndExamNumber(workId, student.getExamNumber());
|
|
|
|
+ if (!papers.isEmpty()) {
|
|
|
|
+ for (Paper paper : papers) {
|
|
|
|
+ Long count = markTaskRepo.countByPaperId(paper.getId());
|
|
|
|
+ if (count == 0) {
|
|
|
|
+ paperRepo.delete(paper);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ student.setName(dto.getName());
|
|
|
|
+ student.setAreaCode(dto.getAreaCode());
|
|
|
|
+ student.setAreaName(dto.getAreaName());
|
|
|
|
+ student.setExamRoom(dto.getExamRoom());
|
|
|
|
+ student.setSourceName(dto.getSourceName());
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
- student.setName(dto.getName());
|
|
|
|
- student.setAreaCode(dto.getAreaCode());
|
|
|
|
- student.setAreaName(dto.getAreaName());
|
|
|
|
- student.setExamRoom(dto.getExamRoom());
|
|
|
|
- student.setSourceName(dto.getSourceName());
|
|
|
|
- }
|
|
|
|
- if (!checkObjFieldIsNotNull(student)) {
|
|
|
|
- throw new RuntimeException("考生信息缺失");
|
|
|
|
|
|
+ if (!checkObjFieldIsNotNull(student)) {
|
|
|
|
+ throw new RuntimeException("考生信息缺失");
|
|
|
|
+ }
|
|
|
|
+ studentRepo.save(student);
|
|
}
|
|
}
|
|
- studentRepo.save(student);
|
|
|
|
|
|
+ return null;
|
|
|
|
+ } catch (RuntimeException e) {
|
|
|
|
+ ExcelError excelError = new ExcelError();
|
|
|
|
+ excelError.setExcelErrorType(e.getMessage());
|
|
|
|
+ return excelError;
|
|
}
|
|
}
|
|
- return null;
|
|
|
|
}
|
|
}
|
|
});
|
|
});
|
|
return excelErrors;
|
|
return excelErrors;
|