|
@@ -1,38 +1,29 @@
|
|
|
package cn.com.qmth.examcloud.exchange.outer.api.provider.sydx;
|
|
|
|
|
|
-import cn.com.qmth.examcloud.commons.web.security.bean.User;
|
|
|
-import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
|
-import cn.com.qmth.examcloud.exchange.base.exception.NoSuchCourseLevelException;
|
|
|
-import cn.com.qmth.examcloud.exchange.base.exception.NoSuchExamException;
|
|
|
-import cn.com.qmth.examcloud.exchange.base.exception.SaveExamException;
|
|
|
-import cn.com.qmth.examcloud.exchange.base.exception.SaveExamStudentException;
|
|
|
-import cn.com.qmth.examcloud.exchange.base.response.FailureBaseResponse;
|
|
|
-import cn.com.qmth.examcloud.exchange.base.response.IBaseResponse;
|
|
|
-import cn.com.qmth.examcloud.exchange.base.response.SuccessBaseResponse;
|
|
|
-import cn.com.qmth.examcloud.exchange.dao.bean.ExamStudentImportDTO;
|
|
|
-import cn.com.qmth.examcloud.exchange.dao.bean.OutletExam;
|
|
|
-import cn.com.qmth.examcloud.exchange.dao.bean.OutletExamStudent;
|
|
|
-import cn.com.qmth.examcloud.exchange.outer.service.ExamStudentImportService;
|
|
|
-
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.slf4j.Logger;
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
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.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
-import java.util.List;
|
|
|
+import com.google.common.collect.Maps;
|
|
|
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
+import cn.com.qmth.examcloud.commons.web.security.bean.User;
|
|
|
+import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
|
+import cn.com.qmth.examcloud.examwork.api.ExamCloudService;
|
|
|
+import cn.com.qmth.examcloud.examwork.api.ExamStudentCloudService;
|
|
|
+import cn.com.qmth.examcloud.examwork.api.request.GetExamReq;
|
|
|
+import cn.com.qmth.examcloud.examwork.api.request.SaveExamStudentReq;
|
|
|
+import cn.com.qmth.examcloud.examwork.api.response.GetExamResp;
|
|
|
+import cn.com.qmth.examcloud.exchange.dao.bean.ExamStudentImportDTO;
|
|
|
+import cn.com.qmth.examcloud.exchange.dao.bean.OutletExam;
|
|
|
+import cn.com.qmth.examcloud.exchange.dao.bean.OutletExamStudent;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
/**
|
|
|
* 石油大学专用-接收考生数据接口
|
|
@@ -46,52 +37,49 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
@RequestMapping("${$rmp.cloud.exchange.outer}/sydx/import_exam_student_info")
|
|
|
public class StudentExamInfoController extends ControllerSupport {
|
|
|
|
|
|
- private static final Logger LOG = LoggerFactory.getLogger(StudentExamInfoController.class);
|
|
|
+ @Autowired
|
|
|
+ ExamCloudService examCloudService;
|
|
|
|
|
|
@Autowired
|
|
|
- private ExamStudentImportService examStudentImportService;
|
|
|
+ ExamStudentCloudService examStudentCloudService;
|
|
|
|
|
|
@ApiOperation(value = "石油大学使用:创建考试和导入学生")
|
|
|
@PostMapping
|
|
|
- public ResponseEntity<IBaseResponse> post(
|
|
|
- @RequestBody ExamStudentImportDTO examStudentImportDTO, HttpServletRequest request) {
|
|
|
+ public Map<String, Object> post(@RequestBody ExamStudentImportDTO examStudentImportDTO) {
|
|
|
|
|
|
tranTimes(examStudentImportDTO);
|
|
|
|
|
|
+ OutletExam exam = examStudentImportDTO.getExam();
|
|
|
+
|
|
|
User accessUser = getAccessUser();
|
|
|
- if (accessUser == null) {
|
|
|
- return new ResponseEntity<>(new FailureBaseResponse("检测到用户为空,请先登录", null),
|
|
|
- HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
- }
|
|
|
- try {
|
|
|
- LOG.info("请求参数是:" + JSON.toJSONString(examStudentImportDTO));
|
|
|
- } catch (Exception e) {
|
|
|
- }
|
|
|
Long rootOrgId = accessUser.getRootOrgId();
|
|
|
- if (rootOrgId == null) {
|
|
|
- return new ResponseEntity<>(HttpStatus.UNAUTHORIZED);
|
|
|
- }
|
|
|
- try {
|
|
|
- Long examId = examStudentImportService.save(accessUser.getUserToken(), rootOrgId,
|
|
|
- examStudentImportDTO);
|
|
|
- return new ResponseEntity<>(new SuccessBaseResponse("", examId), HttpStatus.OK);
|
|
|
- } catch (NoSuchCourseLevelException e) {
|
|
|
- LOG.error("课程级别不存在", e);
|
|
|
- return new ResponseEntity<>(new FailureBaseResponse("课程级别不存在", null),
|
|
|
- HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
- } catch (NoSuchExamException e) {
|
|
|
- LOG.error("考试不存在", e);
|
|
|
- return new ResponseEntity<>(new FailureBaseResponse("考试不存在", null),
|
|
|
- HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
- } catch (SaveExamException e) {
|
|
|
- LOG.error("创建考试失败", e);
|
|
|
- return new ResponseEntity<>(new FailureBaseResponse("创建考试失败,可能该考试名称已经存在", null),
|
|
|
- HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
- } catch (SaveExamStudentException e) {
|
|
|
- LOG.error("创建考生失败", e);
|
|
|
- return new ResponseEntity<>(new FailureBaseResponse("创建考生失败,可能该考生信息已经存在", null),
|
|
|
- HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+
|
|
|
+ GetExamReq req = new GetExamReq();
|
|
|
+ req.setName(exam.getName());
|
|
|
+ req.setRootOrgId(accessUser.getRootOrgId());
|
|
|
+ GetExamResp resp = examCloudService.getExam(req);
|
|
|
+ Long examId = resp.getId();
|
|
|
+ String examName = resp.getName();
|
|
|
+ List<OutletExamStudent> examStudentList = examStudentImportDTO.getExamStudentList();
|
|
|
+ for (OutletExamStudent cur : examStudentList) {
|
|
|
+ SaveExamStudentReq sReq = new SaveExamStudentReq();
|
|
|
+ sReq.setCourseCode(cur.getCourseCode());
|
|
|
+ sReq.setCourseLevel(cur.getCourseLevel());
|
|
|
+ sReq.setCourseName(cur.getCourseName());
|
|
|
+ sReq.setExamId(examId);
|
|
|
+ sReq.setExamName(examName);
|
|
|
+ sReq.setIdentityNumber(cur.getIdentityNumber());
|
|
|
+ sReq.setPaperType(cur.getPaperType());
|
|
|
+ sReq.setRootOrgId(rootOrgId);
|
|
|
+ sReq.setStudentCode(cur.getStudentCode());
|
|
|
+ sReq.setStudentName(cur.getName());
|
|
|
+ examStudentCloudService.saveExamStudent(sReq);
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
+ Map<String, Object> map = Maps.newHashMap();
|
|
|
+ map.put("success", true);
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -105,14 +93,14 @@ public class StudentExamInfoController extends ControllerSupport {
|
|
|
|
|
|
String beginTime = exam.getBeginTime();
|
|
|
if (StringUtils.isNotBlank(beginTime)) {
|
|
|
- beginTime = StringUtils.replace(beginTime, "Z", "");
|
|
|
+ beginTime = StringUtils.replace(beginTime, ".000Z", "");
|
|
|
beginTime = StringUtils.replace(beginTime, "T", " ");
|
|
|
exam.setBeginTime(beginTime);
|
|
|
}
|
|
|
|
|
|
String endTime = exam.getEndTime();
|
|
|
if (StringUtils.isNotBlank(endTime)) {
|
|
|
- endTime = StringUtils.replace(endTime, "Z", "");
|
|
|
+ endTime = StringUtils.replace(endTime, ".000Z", "");
|
|
|
endTime = StringUtils.replace(endTime, "T", " ");
|
|
|
exam.setEndTime(endTime);
|
|
|
}
|
|
@@ -127,14 +115,14 @@ public class StudentExamInfoController extends ControllerSupport {
|
|
|
}
|
|
|
String b = curExam.getBeginTime();
|
|
|
if (StringUtils.isNotBlank(b)) {
|
|
|
- b = StringUtils.replace(b, "Z", "");
|
|
|
+ b = StringUtils.replace(b, ".000Z", "");
|
|
|
b = StringUtils.replace(b, "T", " ");
|
|
|
curExam.setBeginTime(b);
|
|
|
}
|
|
|
|
|
|
String e = curExam.getEndTime();
|
|
|
if (StringUtils.isNotBlank(e)) {
|
|
|
- e = StringUtils.replace(e, "Z", "");
|
|
|
+ e = StringUtils.replace(e, ".000Z", "");
|
|
|
e = StringUtils.replace(e, "T", " ");
|
|
|
curExam.setEndTime(e);
|
|
|
}
|