|
@@ -145,12 +145,15 @@ public class ExamStudentService {
|
|
|
*/
|
|
|
public List<ExcelError> importExamStudent(Long examId, InputStream inputStream) {
|
|
|
Exam exam = examRepo.findOne(examId);
|
|
|
+ List<ExcelError> excelErrors = new ArrayList<ExcelError>();
|
|
|
if(exam == null){
|
|
|
- new RuntimeException("请先创建考试");
|
|
|
+ ExcelError excelError = new ExcelError(1,"请先创建考试");
|
|
|
+ excelErrors.add(excelError);
|
|
|
+ return excelErrors;
|
|
|
}
|
|
|
List<ExamStudent> examStudents = new ArrayList<ExamStudent>();
|
|
|
ExcelReader excelReader = new ExcelReader(ExamStudentDTO.class);
|
|
|
- List<ExcelError> excelErrors = excelReader.reader(inputStream, new ExcelReaderHandle() {
|
|
|
+ excelErrors = excelReader.reader(inputStream, new ExcelReaderHandle() {
|
|
|
@Override
|
|
|
public ExcelError handle(Object obj) {
|
|
|
ExamStudentDTO dto = (ExamStudentDTO) obj;
|
|
@@ -205,16 +208,16 @@ public class ExamStudentService {
|
|
|
* @return
|
|
|
*/
|
|
|
public ExcelError importCheck(ExamStudentDTO dto){
|
|
|
- if(dto.getName()==null){
|
|
|
+ if(StringUtils.isEmpty(dto.getName())){
|
|
|
return new ExcelError("姓名不能为空");
|
|
|
}
|
|
|
- if(dto.getStudentCode()==null||dto.getIdentityNumber()==null){
|
|
|
+ if(StringUtils.isEmpty(dto.getStudentCode())||StringUtils.isEmpty(dto.getIdentityNumber())){
|
|
|
return new ExcelError("学号或身份证号不能为空");
|
|
|
}
|
|
|
- if(dto.getCourseCode()==null){
|
|
|
+ if(StringUtils.isEmpty(dto.getCourseCode())){
|
|
|
return new ExcelError("课程代码不能为空");
|
|
|
}
|
|
|
- if(dto.getOrgCode()==null){
|
|
|
+ if(StringUtils.isEmpty(dto.getOrgCode())){
|
|
|
return new ExcelError("学习中心代码不能为空");
|
|
|
}
|
|
|
Course course = courseService.findByOrgIdAndCode(dto.getRootOrgId(), dto.getCourseCode());
|
|
@@ -228,8 +231,21 @@ public class ExamStudentService {
|
|
|
return new ExcelError("学习中心不存在/禁用");
|
|
|
}
|
|
|
dto.setOrgId(org.getId());
|
|
|
+ stuCheck(dto);
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
+ public void stuCheck(ExamStudentDTO dto){
|
|
|
+ ExamStudent examStudent = null;
|
|
|
+ if(!StringUtils.isEmpty(dto.getIdentityNumber())) {
|
|
|
+ examStudent = examStudentRepo.findFirstByExamId(dto.getExam().getId(), dto.getCourseCode(), dto.getIdentityNumber());
|
|
|
+ }else{
|
|
|
+ examStudent = examStudentRepo.findFirstByExamId(dto.getExam().getId(), dto.getCourseCode(), dto.getStudentCode());
|
|
|
+ }
|
|
|
+ if(examStudent != null){
|
|
|
+ dto.setId(examStudent.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 照片检验
|