|
@@ -2,20 +2,31 @@ package cn.com.qmth.examcloud.core.examwork.api.provider;
|
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
|
+import javax.transaction.Transactional;
|
|
|
|
+
|
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
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.util.BeanCopierUtil;
|
|
|
|
import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.CourseCloudService;
|
|
import cn.com.qmth.examcloud.core.basic.api.OrgCloudService;
|
|
import cn.com.qmth.examcloud.core.basic.api.OrgCloudService;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.StudentCloudService;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.bean.CourseBean;
|
|
import cn.com.qmth.examcloud.core.basic.api.bean.OrgBean;
|
|
import cn.com.qmth.examcloud.core.basic.api.bean.OrgBean;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.bean.StudentBean;
|
|
import cn.com.qmth.examcloud.core.basic.api.request.GetOrgReq;
|
|
import cn.com.qmth.examcloud.core.basic.api.request.GetOrgReq;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.request.GetStudentReq;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.request.SaveCourseReq;
|
|
import cn.com.qmth.examcloud.core.basic.api.response.GetOrgResp;
|
|
import cn.com.qmth.examcloud.core.basic.api.response.GetOrgResp;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.response.GetStudentResp;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.response.SaveCourseResp;
|
|
|
|
+import cn.com.qmth.examcloud.core.examwork.dao.ExamRepo;
|
|
import cn.com.qmth.examcloud.core.examwork.dao.ExamStudentRepo;
|
|
import cn.com.qmth.examcloud.core.examwork.dao.ExamStudentRepo;
|
|
-import cn.com.qmth.examcloud.core.examwork.dao.bean.ExamStudentDTO;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.core.examwork.dao.entity.Exam;
|
|
import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamStudent;
|
|
import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamStudent;
|
|
import cn.com.qmth.examcloud.core.examwork.service.impl.ExamStudentService;
|
|
import cn.com.qmth.examcloud.core.examwork.service.impl.ExamStudentService;
|
|
import cn.com.qmth.examcloud.examwork.api.ExamStudentCloudService;
|
|
import cn.com.qmth.examcloud.examwork.api.ExamStudentCloudService;
|
|
@@ -28,21 +39,31 @@ import cn.com.qmth.examcloud.examwork.api.request.SaveExamStudentReq;
|
|
* @company QMTH
|
|
* @company QMTH
|
|
* @description ExamStudentProvider.java
|
|
* @description ExamStudentProvider.java
|
|
*/
|
|
*/
|
|
|
|
+@Transactional
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("${$rmp.cloud.examwork}" + "examStudent")
|
|
@RequestMapping("${$rmp.cloud.examwork}" + "examStudent")
|
|
public class ExamStudentCloudServiceProvider extends ControllerSupport
|
|
public class ExamStudentCloudServiceProvider extends ControllerSupport
|
|
implements
|
|
implements
|
|
ExamStudentCloudService {
|
|
ExamStudentCloudService {
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ ExamRepo examRepo;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
OrgCloudService orgCloudService;
|
|
OrgCloudService orgCloudService;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
ExamStudentService examStudentService;
|
|
ExamStudentService examStudentService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ StudentCloudService studentCloudService;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
ExamStudentRepo examStudentRepo;
|
|
ExamStudentRepo examStudentRepo;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ CourseCloudService courseCloudService;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void saveExamStudent(SaveExamStudentReq req) {
|
|
public void saveExamStudent(SaveExamStudentReq req) {
|
|
|
|
|
|
@@ -55,6 +76,25 @@ public class ExamStudentCloudServiceProvider extends ControllerSupport
|
|
throw new StatusException("E-100001", "rootOrgId is wrong");
|
|
throw new StatusException("E-100001", "rootOrgId is wrong");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ Exam exam = null;
|
|
|
|
+ Long examId = req.getExamId();
|
|
|
|
+ if (null == examId) {
|
|
|
|
+ String examName = req.getExamName();
|
|
|
|
+ if (StringUtils.isBlank(examName)) {
|
|
|
|
+ throw new StatusException("E-100002", "examId & examName are both blank");
|
|
|
|
+ }
|
|
|
|
+ List<Exam> examList = examRepo.findByNameAndRootOrgId(examName, rootOrgId);
|
|
|
|
+ if (CollectionUtils.isEmpty(examList)) {
|
|
|
|
+ throw new StatusException("E-100005", "考试不存在");
|
|
|
|
+ }
|
|
|
|
+ if (1 < examList.size()) {
|
|
|
|
+ throw new StatusException("E-100005", "考试名称对应多个考试");
|
|
|
|
+ }
|
|
|
|
+ exam = examList.get(0);
|
|
|
|
+ } else {
|
|
|
|
+ exam = examRepo.findOne(examId);
|
|
|
|
+ }
|
|
|
|
+
|
|
String studentCode = req.getStudentCode();
|
|
String studentCode = req.getStudentCode();
|
|
String identityNumber = req.getIdentityNumber();
|
|
String identityNumber = req.getIdentityNumber();
|
|
|
|
|
|
@@ -65,27 +105,45 @@ public class ExamStudentCloudServiceProvider extends ControllerSupport
|
|
if (StringUtils.isBlank(identityNumber)) {
|
|
if (StringUtils.isBlank(identityNumber)) {
|
|
throw new StatusException("E-100003", "identityNumber is null");
|
|
throw new StatusException("E-100003", "identityNumber is null");
|
|
}
|
|
}
|
|
|
|
+ GetStudentReq getStudentReq = new GetStudentReq();
|
|
|
|
+ getStudentReq.setRootOrgId(rootOrgId);
|
|
|
|
+ getStudentReq.setStudentCode(studentCode);
|
|
|
|
+ getStudentReq.setIdentityNumber(identityNumber);
|
|
|
|
+ GetStudentResp getStudentResp = studentCloudService.getStudent(getStudentReq);
|
|
|
|
|
|
- ExamStudentDTO examStudentDto = new ExamStudentDTO();
|
|
|
|
- examStudentDto.setExamId(req.getExamId());
|
|
|
|
- examStudentDto.setCourseCode(req.getCourseCode());
|
|
|
|
- examStudentDto.setIdentityNumber(req.getIdentityNumber());
|
|
|
|
- List<ExamStudent> examStudents = examStudentService.getAllExamStudent(examStudentDto);
|
|
|
|
- if (examStudents != null && examStudents.size() > 0) {
|
|
|
|
- ExamStudent examStudentOld = examStudents.get(0);
|
|
|
|
- // 更新相关的姓名、学习中心、专业
|
|
|
|
- // examStudentOld.setName(examStudentReq.getStudentName());
|
|
|
|
- // examStudentOld.setOrgId(examStudentReq.getOrgId());
|
|
|
|
- // examStudentOld.setOrgCode(examStudentReq.getOrgCode());
|
|
|
|
- // examStudentOld.setOrgName(examStudentReq.getOrgName());
|
|
|
|
- // examStudentOld.setRootOrgId(examStudentReq.getRootOrgId());
|
|
|
|
- // examStudentOld.setSpecialtyName(examStudentReq.getSpecialtyName());
|
|
|
|
- examStudentRepo.save(examStudentOld);
|
|
|
|
- } else {
|
|
|
|
- ExamStudent examStudent = BeanCopierUtil.copyProperties(req, ExamStudent.class);
|
|
|
|
- examStudent.setFinished(false);
|
|
|
|
- examStudentRepo.save(examStudent);
|
|
|
|
|
|
+ StudentBean studentInfo = getStudentResp.getStudentInfo();
|
|
|
|
+
|
|
|
|
+ String courseCode = req.getCourseCode();
|
|
|
|
+ String courseName = req.getCourseName();
|
|
|
|
+ String courseLevel = req.getCourseLevel();
|
|
|
|
+
|
|
|
|
+ SaveCourseReq saveCourseReq = new SaveCourseReq();
|
|
|
|
+ saveCourseReq.setCourseCode(courseCode);
|
|
|
|
+ saveCourseReq.setCourseName(courseName);
|
|
|
|
+ saveCourseReq.setCourseLevel(courseLevel);
|
|
|
|
+ saveCourseReq.setRootOrgId(rootOrgId);
|
|
|
|
+
|
|
|
|
+ SaveCourseResp saveCourseResp = courseCloudService.saveCourse(saveCourseReq);
|
|
|
|
+ CourseBean courseBean = saveCourseResp.getCourseBean();
|
|
|
|
+
|
|
|
|
+ List<ExamStudent> examStudentList = examStudentRepo.findByExamIdAndStudentIdAndCourseCode(
|
|
|
|
+ exam.getId(), studentInfo.getId(), courseBean.getCode());
|
|
|
|
+
|
|
|
|
+ if (CollectionUtils.isNotEmpty(examStudentList)) {
|
|
|
|
+ examStudentRepo.deleteInBatch(examStudentList);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ ExamStudent examStudent = new ExamStudent();
|
|
|
|
+ examStudent.setName(studentInfo.getName());
|
|
|
|
+ examStudent.setRootOrgId(rootOrgId);
|
|
|
|
+ examStudent.setCourseCode(courseCode);
|
|
|
|
+ examStudent.setCourseName(courseName);
|
|
|
|
+ examStudent.setCourseLevel(courseBean.getLevel());
|
|
|
|
+ examStudent.setExam(exam);
|
|
|
|
+ examStudent.setPaperType(req.getPaperType());
|
|
|
|
+
|
|
|
|
+ examStudentRepo.save(examStudent);
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|