|
@@ -1,57 +1,113 @@
|
|
package cn.com.qmth.examcloud.exchange.outer.api.provider.swufe;
|
|
package cn.com.qmth.examcloud.exchange.outer.api.provider.swufe;
|
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
-
|
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
|
-
|
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
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.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.web.security.bean.User;
|
|
import cn.com.qmth.examcloud.commons.web.security.bean.User;
|
|
import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
-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.SuccessBaseResponse;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.StudentCloudService;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.request.InsertOrUpdateStudentReq;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.response.InsertOrUpdateStudentResp;
|
|
|
|
+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.SaveExamStudentReq;
|
|
|
|
+import cn.com.qmth.examcloud.examwork.api.response.GetExamResp;
|
|
|
|
+import cn.com.qmth.examcloud.examwork.api.response.SaveExamStudentResp;
|
|
import cn.com.qmth.examcloud.exchange.dao.bean.StudentInfoReq;
|
|
import cn.com.qmth.examcloud.exchange.dao.bean.StudentInfoReq;
|
|
-import cn.com.qmth.examcloud.exchange.outer.service.StudentInfoService;
|
|
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
- * @author chenken
|
|
|
|
- * @date 2018年5月7日 下午4:30:29
|
|
|
|
- * @company QMTH
|
|
|
|
|
|
+ * @author chenken
|
|
|
|
+ * @date 2018年5月7日 下午4:30:29
|
|
|
|
+ * @company QMTH
|
|
* @description StudentInfoController.java
|
|
* @description StudentInfoController.java
|
|
*/
|
|
*/
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("${$rmp.cloud.exchange.outer}/studentInfo")
|
|
@RequestMapping("${$rmp.cloud.exchange.outer}/studentInfo")
|
|
-public class StudentInfoController extends ControllerSupport{
|
|
|
|
-
|
|
|
|
|
|
+public class StudentInfoController extends ControllerSupport {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ StudentCloudService studentCloudService;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
- private StudentInfoService studentInfoService;
|
|
|
|
-
|
|
|
|
|
|
+ ExamCloudService examCloudService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ ExamStudentCloudService examStudentCloudService;
|
|
|
|
+
|
|
@ApiOperation(value = "保存学生信息")
|
|
@ApiOperation(value = "保存学生信息")
|
|
@PostMapping
|
|
@PostMapping
|
|
- public ResponseEntity<?> saveStudentInfo(@RequestBody List<StudentInfoReq> studentInfoReqs,HttpServletRequest request){
|
|
|
|
|
|
+ public Map<String, Object> saveStudentInfo(@RequestBody List<StudentInfoReq> studentInfoReqs) {
|
|
User accessUser = getAccessUser();
|
|
User accessUser = getAccessUser();
|
|
- if(accessUser == null){
|
|
|
|
- return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("检测到用户为空,请先登录"), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
|
- }
|
|
|
|
- try {
|
|
|
|
- studentInfoService.saveStudentInfo(studentInfoReqs, accessUser.getUserToken(), accessUser.getRootOrgId());
|
|
|
|
- return new ResponseEntity<SuccessBaseResponse>(new SuccessBaseResponse("创建成功",null),HttpStatus.OK);
|
|
|
|
- } catch (SaveExamStudentException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse(e.getMessage()), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("调用失败"), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
|
|
|
+ Long rootOrgId = accessUser.getRootOrgId();
|
|
|
|
+
|
|
|
|
+ List<Long> examStudentIdList = Lists.newArrayList();
|
|
|
|
+ for (StudentInfoReq cur : studentInfoReqs) {
|
|
|
|
+
|
|
|
|
+ GetExamReq req = new GetExamReq();
|
|
|
|
+ req.setName(cur.getExamName());
|
|
|
|
+ req.setRootOrgId(rootOrgId);
|
|
|
|
+ GetExamResp resp = null;
|
|
|
|
+ try {
|
|
|
|
+ resp = examCloudService.getExam(req);
|
|
|
|
+ } catch (StatusException e) {
|
|
|
|
+ throw e;
|
|
|
|
+ }
|
|
|
|
+ Long examId = resp.getId();
|
|
|
|
+ String examName = resp.getName();
|
|
|
|
+
|
|
|
|
+ InsertOrUpdateStudentReq saveStudentReq = new InsertOrUpdateStudentReq();
|
|
|
|
+ saveStudentReq.setIdentityNumber(cur.getIdentityNumber());
|
|
|
|
+ saveStudentReq.setName(cur.getStudentName());
|
|
|
|
+ saveStudentReq.setOrgCode(cur.getOrgCode());
|
|
|
|
+ saveStudentReq.setOrgId(cur.getOrgId());
|
|
|
|
+ saveStudentReq.setOrgName(cur.getOrgName());
|
|
|
|
+ saveStudentReq.setRootOrgId(rootOrgId);
|
|
|
|
+ saveStudentReq.setStudentCode(cur.getStudentCode());
|
|
|
|
+
|
|
|
|
+ InsertOrUpdateStudentResp insertOrUpdateStudentResp = studentCloudService
|
|
|
|
+ .insertOrUpdateStudent(saveStudentReq);
|
|
|
|
+
|
|
|
|
+ Long studentId = insertOrUpdateStudentResp.getStudentId();
|
|
|
|
+
|
|
|
|
+ SaveExamStudentReq sReq = new SaveExamStudentReq();
|
|
|
|
+ sReq.setCourseLevel(cur.getCourseLevel());
|
|
|
|
+
|
|
|
|
+ CourseLevel courseLevel = CourseLevel.getCourseLevel(cur.getCourseLevel());
|
|
|
|
+ String courseCode = courseLevel.getAbbreviate() + cur.getCourseCode();
|
|
|
|
+ sReq.setCourseCode(courseCode);
|
|
|
|
+
|
|
|
|
+ sReq.setCourseName(cur.getCourseName());
|
|
|
|
+ sReq.setExamId(examId);
|
|
|
|
+ sReq.setStudentId(studentId);
|
|
|
|
+ sReq.setExamName(examName);
|
|
|
|
+ sReq.setIdentityNumber(cur.getIdentityNumber());
|
|
|
|
+ sReq.setPaperType(cur.getPaperType());
|
|
|
|
+ sReq.setRootOrgId(rootOrgId);
|
|
|
|
+ sReq.setStudentCode(cur.getStudentCode());
|
|
|
|
+ sReq.setStudentName(cur.getStudentName());
|
|
|
|
+ SaveExamStudentResp savedExamStudent = examStudentCloudService.saveExamStudent(sReq);
|
|
|
|
+ ExamStudentBean examStudentBean = savedExamStudent.getExamStudentBean();
|
|
|
|
+ examStudentIdList.add(examStudentBean.getId());
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ Map<String, Object> map = Maps.newHashMap();
|
|
|
|
+ map.put("success", true);
|
|
|
|
+ map.put("examStudentIdList", examStudentIdList);
|
|
|
|
+ return map;
|
|
}
|
|
}
|
|
-
|
|
|
|
-}
|
|
|
|
|
|
|
|
|
|
+}
|