|
@@ -15,6 +15,9 @@ import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Maps;
|
|
|
|
|
|
import cn.com.qmth.examcloud.common.dto.core.enums.CourseLevel;
|
|
|
+import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
|
+import cn.com.qmth.examcloud.commons.base.util.DateUtil;
|
|
|
+import cn.com.qmth.examcloud.commons.base.util.DateUtil.DatePatterns;
|
|
|
import cn.com.qmth.examcloud.commons.web.security.bean.User;
|
|
|
import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.StudentCloudService;
|
|
@@ -24,6 +27,7 @@ import cn.com.qmth.examcloud.examwork.api.ExamCloudService;
|
|
|
import cn.com.qmth.examcloud.examwork.api.ExamStudentCloudService;
|
|
|
import cn.com.qmth.examcloud.examwork.api.bean.ExamStudentBean;
|
|
|
import cn.com.qmth.examcloud.examwork.api.request.GetExamReq;
|
|
|
+import cn.com.qmth.examcloud.examwork.api.request.SaveExamReq;
|
|
|
import cn.com.qmth.examcloud.examwork.api.request.SaveExamStudentReq;
|
|
|
import cn.com.qmth.examcloud.examwork.api.response.GetExamResp;
|
|
|
import cn.com.qmth.examcloud.examwork.api.response.SaveExamStudentResp;
|
|
@@ -53,6 +57,13 @@ public class StudentExamInfoController extends ControllerSupport {
|
|
|
@Autowired
|
|
|
ExamStudentCloudService examStudentCloudService;
|
|
|
|
|
|
+ /**
|
|
|
+ * 方法注释
|
|
|
+ *
|
|
|
+ * @author WANGWEI
|
|
|
+ * @param examStudentImportDTO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@ApiOperation(value = "石油大学使用:创建考试和导入学生")
|
|
|
@PostMapping
|
|
|
public Map<String, Object> post(@RequestBody ExamStudentImportDTO examStudentImportDTO) {
|
|
@@ -67,7 +78,26 @@ public class StudentExamInfoController extends ControllerSupport {
|
|
|
GetExamReq req = new GetExamReq();
|
|
|
req.setName(exam.getName());
|
|
|
req.setRootOrgId(accessUser.getRootOrgId());
|
|
|
- GetExamResp resp = examCloudService.getExam(req);
|
|
|
+ GetExamResp resp = null;
|
|
|
+ try {
|
|
|
+ resp = examCloudService.getExam(req);
|
|
|
+ } catch (StatusException e) {
|
|
|
+ if (e.getCode().equals("E-002002")) {
|
|
|
+ SaveExamReq saveExamReq = new SaveExamReq();
|
|
|
+ saveExamReq.setBeginTime(DateUtil.parse(exam.getBeginTime(), DatePatterns.ISO));
|
|
|
+ saveExamReq.setDuration(exam.getDuration());
|
|
|
+ saveExamReq.setEndTime(DateUtil.parse(exam.getEndTime(), DatePatterns.ISO));
|
|
|
+ saveExamReq.setExamType(exam.getExamType().name());
|
|
|
+ saveExamReq.setName(exam.getName());
|
|
|
+ saveExamReq.setRemark(exam.getRemark());
|
|
|
+ saveExamReq.setRootOrgId(rootOrgId);
|
|
|
+ examCloudService.saveExam(saveExamReq);
|
|
|
+ resp = examCloudService.getExam(req);
|
|
|
+ } else {
|
|
|
+ throw e;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
Long examId = resp.getId();
|
|
|
String examName = resp.getName();
|
|
|
List<OutletExamStudent> examStudentList = examStudentImportDTO.getExamStudentList();
|