|
@@ -1,18 +1,18 @@
|
|
package cn.com.qmth.examcloud.exchange.outer.api.controller.sydx;
|
|
package cn.com.qmth.examcloud.exchange.outer.api.controller.sydx;
|
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
-import java.util.Map;
|
|
|
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
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.http.HttpStatus;
|
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
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 com.google.common.collect.Lists;
|
|
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.common.dto.core.enums.CourseLevel;
|
|
import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
@@ -33,6 +33,7 @@ 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.GetExamResp;
|
|
import cn.com.qmth.examcloud.examwork.api.response.SaveExamStudentResp;
|
|
import cn.com.qmth.examcloud.examwork.api.response.SaveExamStudentResp;
|
|
import cn.com.qmth.examcloud.exchange.outer.api.controller.sydx.bean.ExamStudentImportDTO;
|
|
import cn.com.qmth.examcloud.exchange.outer.api.controller.sydx.bean.ExamStudentImportDTO;
|
|
|
|
+import cn.com.qmth.examcloud.exchange.outer.api.controller.sydx.bean.FailureRecordDomain;
|
|
import cn.com.qmth.examcloud.exchange.outer.api.controller.sydx.bean.OutletExam;
|
|
import cn.com.qmth.examcloud.exchange.outer.api.controller.sydx.bean.OutletExam;
|
|
import cn.com.qmth.examcloud.exchange.outer.api.controller.sydx.bean.OutletExamStudent;
|
|
import cn.com.qmth.examcloud.exchange.outer.api.controller.sydx.bean.OutletExamStudent;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -67,7 +68,7 @@ public class StudentExamInfoController extends ControllerSupport {
|
|
*/
|
|
*/
|
|
@ApiOperation(value = "石油大学使用:创建考试和导入学生")
|
|
@ApiOperation(value = "石油大学使用:创建考试和导入学生")
|
|
@PostMapping
|
|
@PostMapping
|
|
- public Map<String, Object> post(@RequestBody ExamStudentImportDTO examStudentImportDTO) {
|
|
|
|
|
|
+ public ResponseEntity<?> post(@RequestBody ExamStudentImportDTO examStudentImportDTO) {
|
|
|
|
|
|
tranTimes(examStudentImportDTO);
|
|
tranTimes(examStudentImportDTO);
|
|
|
|
|
|
@@ -105,6 +106,8 @@ public class StudentExamInfoController extends ControllerSupport {
|
|
List<OutletExamStudent> examStudentList = examStudentImportDTO.getExamStudentList();
|
|
List<OutletExamStudent> examStudentList = examStudentImportDTO.getExamStudentList();
|
|
|
|
|
|
List<Long> examStudentIdList = Lists.newArrayList();
|
|
List<Long> examStudentIdList = Lists.newArrayList();
|
|
|
|
+ List<FailureRecordDomain> failureRecordList = Lists.newArrayList();
|
|
|
|
+
|
|
for (OutletExamStudent cur : examStudentList) {
|
|
for (OutletExamStudent cur : examStudentList) {
|
|
|
|
|
|
SaveStudentReq saveStudentReq = new SaveStudentReq();
|
|
SaveStudentReq saveStudentReq = new SaveStudentReq();
|
|
@@ -117,8 +120,7 @@ public class StudentExamInfoController extends ControllerSupport {
|
|
saveStudentReq.setRootOrgId(rootOrgId);
|
|
saveStudentReq.setRootOrgId(rootOrgId);
|
|
saveStudentReq.setStudentCode(cur.getStudentCode());
|
|
saveStudentReq.setStudentCode(cur.getStudentCode());
|
|
|
|
|
|
- SaveStudentResp saveStudentResp = studentCloudService
|
|
|
|
- .saveStudent(saveStudentReq);
|
|
|
|
|
|
+ SaveStudentResp saveStudentResp = studentCloudService.saveStudent(saveStudentReq);
|
|
|
|
|
|
Long studentId = saveStudentResp.getStudentId();
|
|
Long studentId = saveStudentResp.getStudentId();
|
|
|
|
|
|
@@ -140,15 +142,39 @@ public class StudentExamInfoController extends ControllerSupport {
|
|
sReq.setStudentName(cur.getName());
|
|
sReq.setStudentName(cur.getName());
|
|
sReq.setPaperType("O");
|
|
sReq.setPaperType("O");
|
|
sReq.setRemark(cur.getRemark());
|
|
sReq.setRemark(cur.getRemark());
|
|
- SaveExamStudentResp savedExamStudent = examStudentCloudService.saveExamStudent(sReq);
|
|
|
|
- ExamStudentBean examStudentBean = savedExamStudent.getExamStudentBean();
|
|
|
|
- examStudentIdList.add(examStudentBean.getId());
|
|
|
|
|
|
+ try {
|
|
|
|
+ SaveExamStudentResp savedExamStudent = examStudentCloudService
|
|
|
|
+ .saveExamStudent(sReq);
|
|
|
|
+ ExamStudentBean examStudentBean = savedExamStudent.getExamStudentBean();
|
|
|
|
+ examStudentIdList.add(examStudentBean.getId());
|
|
|
|
+ } catch (StatusException e) {
|
|
|
|
+ FailureRecordDomain fr = new FailureRecordDomain();
|
|
|
|
+ fr.setCode(e.getCode());
|
|
|
|
+ fr.setDesc(e.getDesc());
|
|
|
|
+ fr.setCourseCode(cur.getCourseCode());
|
|
|
|
+ fr.setCourseLevel(cur.getCourseLevel());
|
|
|
|
+ fr.setCourseName(cur.getCourseName());
|
|
|
|
+ fr.setIdentityNumber(cur.getIdentityNumber());
|
|
|
|
+ fr.setStudentCode(cur.getStudentCode());
|
|
|
|
+ failureRecordList.add(fr);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ FailureRecordDomain fr = new FailureRecordDomain();
|
|
|
|
+ fr.setCode("EX-210001");
|
|
|
|
+ fr.setDesc(e.getMessage());
|
|
|
|
+ fr.setCourseCode(cur.getCourseCode());
|
|
|
|
+ fr.setCourseLevel(cur.getCourseLevel());
|
|
|
|
+ fr.setCourseName(cur.getCourseName());
|
|
|
|
+ fr.setIdentityNumber(cur.getIdentityNumber());
|
|
|
|
+ fr.setStudentCode(cur.getStudentCode());
|
|
|
|
+ failureRecordList.add(fr);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
- Map<String, Object> map = Maps.newHashMap();
|
|
|
|
- map.put("success", true);
|
|
|
|
- map.put("examStudentIdList", examStudentIdList);
|
|
|
|
- return map;
|
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(failureRecordList)) {
|
|
|
|
+ return new ResponseEntity<Object>(failureRecordList, HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
|
+ } else {
|
|
|
|
+ return new ResponseEntity<Object>(examStudentIdList, HttpStatus.OK);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|