|
@@ -79,36 +79,39 @@ public class ExamStudentServiceImpl extends ServiceImpl<ExamStudentMapper, ExamS
|
|
@Override
|
|
@Override
|
|
public void saveBasicStudent(ExamStudent examStudent) {
|
|
public void saveBasicStudent(ExamStudent examStudent) {
|
|
SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
|
+ if (StringUtils.isBlank(examStudent.getStudentCode())) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("学号必填");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isBlank(examStudent.getCourseCode())) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("课程代码必填");
|
|
|
|
+ }
|
|
// 验证
|
|
// 验证
|
|
ExamStudent byStudentCode = this.getByExamIdAndCourseCodeAndStudentCode(examStudent.getExamId(), examStudent.getCourseCode(), examStudent.getStudentCode());
|
|
ExamStudent byStudentCode = this.getByExamIdAndCourseCodeAndStudentCode(examStudent.getExamId(), examStudent.getCourseCode(), examStudent.getStudentCode());
|
|
if (examStudent.getId() == null) {
|
|
if (examStudent.getId() == null) {
|
|
- if (StringUtils.isBlank(examStudent.getStudentCode())) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("学号必填");
|
|
|
|
|
|
+ if (StringUtils.isBlank(examStudent.getCourseName())) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("课程名称必填");
|
|
|
|
+ }
|
|
|
|
+ if (byStudentCode != null) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(String.format("学号[%s]在课程%s(%s)下已存在", examStudent.getStudentCode(), examStudent.getCourseName(), examStudent.getCourseCode()));
|
|
}
|
|
}
|
|
// 学号去掉空格
|
|
// 学号去掉空格
|
|
examStudent.setStudentCode(StringUtils.deleteWhitespace(examStudent.getStudentCode()));
|
|
examStudent.setStudentCode(StringUtils.deleteWhitespace(examStudent.getStudentCode()));
|
|
if (StringUtils.isBlank(examStudent.getStudentName())) {
|
|
if (StringUtils.isBlank(examStudent.getStudentName())) {
|
|
throw ExceptionResultEnum.ERROR.exception("姓名必填");
|
|
throw ExceptionResultEnum.ERROR.exception("姓名必填");
|
|
}
|
|
}
|
|
- if (StringUtils.isBlank(examStudent.getCourseCode())) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("课程代码必填");
|
|
|
|
- }
|
|
|
|
// 课程代码去掉空格
|
|
// 课程代码去掉空格
|
|
examStudent.setCourseCode(StringUtils.deleteWhitespace(examStudent.getCourseCode()));
|
|
examStudent.setCourseCode(StringUtils.deleteWhitespace(examStudent.getCourseCode()));
|
|
- if (StringUtils.isBlank(examStudent.getCourseName())) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("课程名称必填");
|
|
|
|
- }
|
|
|
|
// 课程名称去掉空格
|
|
// 课程名称去掉空格
|
|
examStudent.setCourseName(StringUtils.deleteWhitespace(examStudent.getCourseName()));
|
|
examStudent.setCourseName(StringUtils.deleteWhitespace(examStudent.getCourseName()));
|
|
|
|
|
|
// 校验是否设置了存储方式
|
|
// 校验是否设置了存储方式
|
|
SimpleObject recognitionTypeSimpleObject = commonCacheService.getSysSetting(sysUser.getSchoolId()).get(SysSettingConstant.RECOGNITION_TYPE);
|
|
SimpleObject recognitionTypeSimpleObject = commonCacheService.getSysSetting(sysUser.getSchoolId()).get(SysSettingConstant.RECOGNITION_TYPE);
|
|
if (StringUtils.isBlank(recognitionTypeSimpleObject.getValue())) {
|
|
if (StringUtils.isBlank(recognitionTypeSimpleObject.getValue())) {
|
|
- throw ExceptionResultEnum.ERROR.exception("识别方式未设置");
|
|
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("识别方式未设置,请联系管理员设置");
|
|
}
|
|
}
|
|
SimpleObject storeTypeSimpleObject = commonCacheService.getSysSetting(sysUser.getSchoolId()).get(SysSettingConstant.STORE_TYPE);
|
|
SimpleObject storeTypeSimpleObject = commonCacheService.getSysSetting(sysUser.getSchoolId()).get(SysSettingConstant.STORE_TYPE);
|
|
if (StringUtils.isBlank(storeTypeSimpleObject.getValue())) {
|
|
if (StringUtils.isBlank(storeTypeSimpleObject.getValue())) {
|
|
- throw ExceptionResultEnum.ERROR.exception("文件存储方式未设置");
|
|
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("文件存储方式未设置,请联系管理员设置");
|
|
}
|
|
}
|
|
RecognitionTypeEnum recognitionType = RecognitionTypeEnum.valueOf(recognitionTypeSimpleObject.getValue());
|
|
RecognitionTypeEnum recognitionType = RecognitionTypeEnum.valueOf(recognitionTypeSimpleObject.getValue());
|
|
StoreTypeEnum storeType = StoreTypeEnum.valueOf(storeTypeSimpleObject.getValue());
|
|
StoreTypeEnum storeType = StoreTypeEnum.valueOf(storeTypeSimpleObject.getValue());
|
|
@@ -118,9 +121,7 @@ public class ExamStudentServiceImpl extends ServiceImpl<ExamStudentMapper, ExamS
|
|
if (StoreTypeEnum.CLASS.equals(storeType) && StringUtils.isBlank(examStudent.getClassName())) {
|
|
if (StoreTypeEnum.CLASS.equals(storeType) && StringUtils.isBlank(examStudent.getClassName())) {
|
|
throw ExceptionResultEnum.ERROR.exception("班级必填");
|
|
throw ExceptionResultEnum.ERROR.exception("班级必填");
|
|
}
|
|
}
|
|
- if (byStudentCode != null) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception(String.format("学号[%s]在课程%s(%s)下已存在", examStudent.getStudentCode(), examStudent.getCourseName(), examStudent.getCourseCode()));
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
examStudent.setId(SystemConstant.getDbUuid());
|
|
examStudent.setId(SystemConstant.getDbUuid());
|
|
examStudent.setSchoolId(sysUser.getSchoolId());
|
|
examStudent.setSchoolId(sysUser.getSchoolId());
|
|
examStudent.setCreateId(sysUser.getId());
|
|
examStudent.setCreateId(sysUser.getId());
|
|
@@ -153,7 +154,6 @@ public class ExamStudentServiceImpl extends ServiceImpl<ExamStudentMapper, ExamS
|
|
examStudent.setUpdateTime(System.currentTimeMillis());
|
|
examStudent.setUpdateTime(System.currentTimeMillis());
|
|
this.updateById(examStudent);
|
|
this.updateById(examStudent);
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -344,4 +344,70 @@ public class ExamStudentServiceImpl extends ServiceImpl<ExamStudentMapper, ExamS
|
|
.eq(ExamStudent::getCourseCode, courseCode);
|
|
.eq(ExamStudent::getCourseCode, courseCode);
|
|
return this.list(queryWrapper);
|
|
return this.list(queryWrapper);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ExamStudent saveExamStudentFromClient(ExamStudent examStudent) {
|
|
|
|
+ SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
|
+ if (StringUtils.isBlank(examStudent.getStudentCode())) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("学号必填");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isBlank(examStudent.getCourseCode())) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("课程代码必填");
|
|
|
|
+ }
|
|
|
|
+ // 验证
|
|
|
|
+ ExamStudent byStudentCode = this.getByExamIdAndCourseCodeAndStudentCode(examStudent.getExamId(), examStudent.getCourseCode(), examStudent.getStudentCode());
|
|
|
|
+ if (byStudentCode != null) {
|
|
|
|
+ return byStudentCode;
|
|
|
|
+ } else {
|
|
|
|
+ if (StringUtils.isBlank(examStudent.getCourseName())) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("课程名称必填");
|
|
|
|
+ }
|
|
|
|
+ // 学号去掉空格
|
|
|
|
+ examStudent.setStudentCode(StringUtils.deleteWhitespace(examStudent.getStudentCode()));
|
|
|
|
+ if (StringUtils.isBlank(examStudent.getStudentName())) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("姓名必填");
|
|
|
|
+ }
|
|
|
|
+ // 课程代码去掉空格
|
|
|
|
+ examStudent.setCourseCode(StringUtils.deleteWhitespace(examStudent.getCourseCode()));
|
|
|
|
+ // 课程名称去掉空格
|
|
|
|
+ examStudent.setCourseName(StringUtils.deleteWhitespace(examStudent.getCourseName()));
|
|
|
|
+
|
|
|
|
+ // 校验是否设置了存储方式
|
|
|
|
+ SimpleObject recognitionTypeSimpleObject = commonCacheService.getSysSetting(sysUser.getSchoolId()).get(SysSettingConstant.RECOGNITION_TYPE);
|
|
|
|
+ if (StringUtils.isBlank(recognitionTypeSimpleObject.getValue())) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("识别方式未设置,请联系管理员设置");
|
|
|
|
+ }
|
|
|
|
+ SimpleObject storeTypeSimpleObject = commonCacheService.getSysSetting(sysUser.getSchoolId()).get(SysSettingConstant.STORE_TYPE);
|
|
|
|
+ if (StringUtils.isBlank(storeTypeSimpleObject.getValue())) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("文件存储方式未设置,请联系管理员设置");
|
|
|
|
+ }
|
|
|
|
+ RecognitionTypeEnum recognitionType = RecognitionTypeEnum.valueOf(recognitionTypeSimpleObject.getValue());
|
|
|
|
+ StoreTypeEnum storeType = StoreTypeEnum.valueOf(storeTypeSimpleObject.getValue());
|
|
|
|
+ if (StoreTypeEnum.ROOM.equals(storeType) && StringUtils.isBlank(examStudent.getExamRoom())) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("考场必填");
|
|
|
|
+ }
|
|
|
|
+ if (StoreTypeEnum.CLASS.equals(storeType) && StringUtils.isBlank(examStudent.getClassName())) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("班级必填");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ examStudent.setId(SystemConstant.getDbUuid());
|
|
|
|
+ examStudent.setSchoolId(sysUser.getSchoolId());
|
|
|
|
+ examStudent.setCreateId(sysUser.getId());
|
|
|
|
+ examStudent.setCreateTime(System.currentTimeMillis());
|
|
|
|
+
|
|
|
|
+ // 考场去掉空格
|
|
|
|
+ examStudent.setExamRoom(StringUtils.isNotBlank(examStudent.getExamRoom()) ? StringUtils.deleteWhitespace(examStudent.getExamRoom()) : null);
|
|
|
|
+ // 班级去掉空格
|
|
|
|
+ examStudent.setClassName(StringUtils.isNotBlank(examStudent.getClassName()) ? StringUtils.deleteWhitespace(examStudent.getClassName()) : null);
|
|
|
|
+ boolean save = this.save(examStudent);
|
|
|
|
+
|
|
|
|
+ if (save) {
|
|
|
|
+ // 保存课程
|
|
|
|
+ examCourseService.saveStudentCourse(examStudent.getExamId(), examStudent);
|
|
|
|
+ // 保存任务(存在则更新考生数量)
|
|
|
|
+ paperScanTaskService.addScanTask(examStudent.getExamId(), recognitionType, storeType, examStudent);
|
|
|
|
+ }
|
|
|
|
+ return examStudent;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|