|
@@ -185,16 +185,16 @@ public class ExamStudentService {
|
|
|
* @param examStudent
|
|
|
* @return
|
|
|
*/
|
|
|
- public ExamStudent saveExamStudent(ExamStudent examStudent)throws Exception{
|
|
|
+ public ExamStudent saveExamStudent(String token,ExamStudent examStudent)throws Exception{
|
|
|
checkExamStudent(examStudent);
|
|
|
- return saveStudent(examStudent);
|
|
|
+ return saveStudent(token,examStudent);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 导入考试学生
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<ExcelError> importExamStudent(Long examId, InputStream inputStream) {
|
|
|
+ public List<ExcelError> importExamStudent(String token,Long examId, InputStream inputStream) {
|
|
|
log.info("导入考生开始");
|
|
|
Exam exam = examRepo.findOne(examId);
|
|
|
List<ExcelError> excelErrors = new ArrayList<ExcelError>();
|
|
@@ -211,13 +211,13 @@ public class ExamStudentService {
|
|
|
ExamStudentDTO dto = (ExamStudentDTO) obj;
|
|
|
dto.setRootOrgId(exam.getOrgId());
|
|
|
dto.setExam(exam);
|
|
|
- ExcelError error = importCheck(dto);
|
|
|
+ ExcelError error = importCheck(token,dto);
|
|
|
if (error == null) {
|
|
|
examStudents.add(examStudentAssembler.toDomain(dto));
|
|
|
}
|
|
|
int stu_num = examStudents.size();
|
|
|
if (stu_num % 5000 == 0) {
|
|
|
- saveStudentList(examStudents);
|
|
|
+ saveStudentList(token,examStudents);
|
|
|
log.info("已导入"+stu_num+"条数据");
|
|
|
}
|
|
|
return error;
|
|
@@ -225,21 +225,21 @@ public class ExamStudentService {
|
|
|
|
|
|
});
|
|
|
int stu_num = examStudents.size();
|
|
|
- saveStudentList(examStudents);
|
|
|
+ saveStudentList(token,examStudents);
|
|
|
log.info("已导入"+stu_num+"条数据");
|
|
|
log.info("导入考生结束");
|
|
|
return excelErrors;
|
|
|
}
|
|
|
|
|
|
|
|
|
- private void saveStudentList(List<ExamStudent> examStudents) {
|
|
|
+ private void saveStudentList(String token,List<ExamStudent> examStudents) {
|
|
|
for (ExamStudent examStudent : examStudents) {
|
|
|
- saveStudent(examStudent);
|
|
|
+ saveStudent(token,examStudent);
|
|
|
}
|
|
|
examStudents.removeAll(examStudents);
|
|
|
}
|
|
|
|
|
|
- private ExamStudent saveStudent(ExamStudent examStudent){
|
|
|
+ private ExamStudent saveStudent(String token,ExamStudent examStudent){
|
|
|
if(examStudent.getStudentId() == null){
|
|
|
Student student = new Student();
|
|
|
student.setIdentityNumber(examStudent.getIdentityNumber());
|
|
@@ -253,16 +253,16 @@ public class ExamStudentService {
|
|
|
user.setType(UserType.STUDENT);
|
|
|
user.setRootOrgId(examStudent.getRootOrgId());
|
|
|
student.setUser(user);
|
|
|
- student = studentService.addStudent(student);
|
|
|
+ student = studentService.addStudent(token,student);
|
|
|
examStudent.setStudentId(student.getId());
|
|
|
}else{
|
|
|
- Student student = studentService.getStudent(examStudent.getStudentId());
|
|
|
+ Student student = studentService.getStudent(token,examStudent.getStudentId());
|
|
|
student.setOrgId(examStudent.getOrgId());
|
|
|
student.setName(examStudent.getName());
|
|
|
student.setRootOrgId(examStudent.getRootOrgId());
|
|
|
student.setStudentCode(examStudent.getStudentCode());
|
|
|
student.setIdentityNumber(examStudent.getIdentityNumber());
|
|
|
- studentService.updateStudent(student);
|
|
|
+ studentService.updateStudent(token,student);
|
|
|
}
|
|
|
examStudent.setFinished(false);
|
|
|
examStudent.setGraduated(false);
|
|
@@ -295,7 +295,7 @@ public class ExamStudentService {
|
|
|
* @param dto
|
|
|
* @return
|
|
|
*/
|
|
|
- public ExcelError importCheck(ExamStudentDTO dto){
|
|
|
+ public ExcelError importCheck(String token,ExamStudentDTO dto){
|
|
|
if(StringUtils.isEmpty(dto.getName())){
|
|
|
return new ExcelError("姓名不能为空");
|
|
|
}
|
|
@@ -325,13 +325,13 @@ public class ExamStudentService {
|
|
|
// }
|
|
|
// dto.setSpecialtyName(specialty.getName());
|
|
|
|
|
|
- Course course = courseService.findByOrgIdAndCode(dto.getRootOrgId(), dto.getCourseCode());
|
|
|
+ Course course = courseService.findByOrgIdAndCode(token,dto.getRootOrgId(), dto.getCourseCode());
|
|
|
if(course == null || !course.getEnable()){
|
|
|
return new ExcelError("课程不存在/被禁用");
|
|
|
}
|
|
|
dto.setCourseLevel(course.getLevel().toString());
|
|
|
dto.setCourseName(course.getName());
|
|
|
- Org org = orgService.findByParentIdAndCode(dto.getRootOrgId(), dto.getOrgCode());
|
|
|
+ Org org = orgService.findByParentIdAndCode(token,dto.getRootOrgId(), dto.getOrgCode());
|
|
|
if(org == null || !org.getEnable()){
|
|
|
return new ExcelError("学习中心不存在/禁用");
|
|
|
}
|