|
@@ -1,408 +1,408 @@
|
|
|
-package cn.com.qmth.examcloud.core.examwork.api.provider;
|
|
|
-
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Iterator;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-import javax.persistence.criteria.Predicate;
|
|
|
-
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.data.domain.Page;
|
|
|
-import org.springframework.data.domain.PageRequest;
|
|
|
-import org.springframework.data.domain.Pageable;
|
|
|
-import org.springframework.data.domain.Sort;
|
|
|
-import org.springframework.data.domain.Sort.Direction;
|
|
|
-import org.springframework.data.jpa.domain.Specification;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
-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 com.google.common.collect.Lists;
|
|
|
-
|
|
|
-import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
|
-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.StudentCloudService;
|
|
|
-import cn.com.qmth.examcloud.core.basic.api.bean.OrgBean;
|
|
|
-import cn.com.qmth.examcloud.core.basic.api.request.GetOrgReq;
|
|
|
-import cn.com.qmth.examcloud.core.basic.api.response.GetOrgResp;
|
|
|
-import cn.com.qmth.examcloud.core.examwork.dao.ExamCourseRelationRepo;
|
|
|
-import cn.com.qmth.examcloud.core.examwork.dao.ExamPaperTypeRelationRepo;
|
|
|
-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.entity.ExamEntity;
|
|
|
-import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamStudentEntity;
|
|
|
-import cn.com.qmth.examcloud.core.examwork.service.ExamStudentService;
|
|
|
-import cn.com.qmth.examcloud.core.examwork.service.bean.ExamStudentInfo;
|
|
|
-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.CopyExamStudentsReq;
|
|
|
-import cn.com.qmth.examcloud.examwork.api.request.GetExamStudentPageReq;
|
|
|
-import cn.com.qmth.examcloud.examwork.api.request.GetExamStudentReq;
|
|
|
-import cn.com.qmth.examcloud.examwork.api.request.SaveExamStudentReq;
|
|
|
-import cn.com.qmth.examcloud.examwork.api.response.CopyExamStudentsResp;
|
|
|
-import cn.com.qmth.examcloud.examwork.api.response.GetExamStudentPageResp;
|
|
|
-import cn.com.qmth.examcloud.examwork.api.response.GetExamStudentResp;
|
|
|
-import cn.com.qmth.examcloud.examwork.api.response.SaveExamStudentResp;
|
|
|
-import cn.com.qmth.examcloud.task.api.DataSyncCloudService;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
-
|
|
|
-/**
|
|
|
- * 类注释
|
|
|
- *
|
|
|
- * @author WANGWEI
|
|
|
- * @date 2018年7月18日
|
|
|
- * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
|
|
|
- */
|
|
|
-@Transactional
|
|
|
-@RestController
|
|
|
-@RequestMapping("${$rmp.cloud.examwork}" + "examStudent")
|
|
|
-public class ExamStudentCloudServiceProvider extends ControllerSupport
|
|
|
- implements
|
|
|
- ExamStudentCloudService {
|
|
|
-
|
|
|
- private static final long serialVersionUID = -89062090947597841L;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- ExamRepo examRepo;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- OrgCloudService orgCloudService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- ExamStudentService examStudentService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- StudentCloudService studentCloudService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- ExamStudentRepo examStudentRepo;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- CourseCloudService courseCloudService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- ExamCourseRelationRepo examCourseRelationRepo;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- ExamPaperTypeRelationRepo examPaperTypeRelationRepo;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- DataSyncCloudService dataSyncCloudService;
|
|
|
-
|
|
|
- @ApiOperation(value = "保存考生")
|
|
|
- @PostMapping("saveExamStudent")
|
|
|
- @Override
|
|
|
- public SaveExamStudentResp saveExamStudent(@RequestBody SaveExamStudentReq req) {
|
|
|
- trim(req);
|
|
|
- ExamStudentInfo info = new ExamStudentInfo();
|
|
|
- info.setCourseCode(req.getCourseCode());
|
|
|
- info.setCourseName(req.getCourseName());
|
|
|
- info.setCourseLevel(req.getCourseLevel());
|
|
|
- info.setCourseId(req.getCourseId());
|
|
|
- info.setRootOrgId(req.getRootOrgId());
|
|
|
- info.setExamId(req.getExamId());
|
|
|
- info.setExamName(req.getExamName());
|
|
|
- info.setIdentityNumber(req.getIdentityNumber());
|
|
|
- info.setPaperType(req.getPaperType());
|
|
|
- info.setStudentCode(req.getStudentCode());
|
|
|
- info.setStudentName(req.getStudentName());
|
|
|
- info.setInfoCollector(req.getInfoCollector());
|
|
|
- info.setGrade(req.getGrade());
|
|
|
- info.setExamSite(req.getExamSite());
|
|
|
- info.setSpecialtyName(req.getSpecialtyName());
|
|
|
- info.setRemark(req.getRemark());
|
|
|
-
|
|
|
- info.setExt1(req.getExt1());
|
|
|
- info.setExt2(req.getExt2());
|
|
|
- info.setExt3(req.getExt3());
|
|
|
- info.setExt4(req.getExt4());
|
|
|
- info.setExt5(req.getExt5());
|
|
|
-
|
|
|
- ExamStudentInfo saved = examStudentService.saveExamStudent(info);
|
|
|
-
|
|
|
- SaveExamStudentResp resp = new SaveExamStudentResp();
|
|
|
-
|
|
|
- ExamStudentBean examStudentBean = new ExamStudentBean();
|
|
|
- examStudentBean.setId(saved.getId());
|
|
|
- examStudentBean.setCourseCode(saved.getCourseCode());
|
|
|
- examStudentBean.setCourseLevel(saved.getCourseLevel());
|
|
|
- examStudentBean.setCourseName(saved.getCourseName());
|
|
|
- examStudentBean.setExamId(saved.getExamId());
|
|
|
- examStudentBean.setExamName(saved.getExamName());
|
|
|
- examStudentBean.setIdentityNumber(saved.getIdentityNumber());
|
|
|
- examStudentBean.setStudentCode(saved.getStudentCode());
|
|
|
- examStudentBean.setPaperType(saved.getPaperType());
|
|
|
- examStudentBean.setRootOrgId(saved.getRootOrgId());
|
|
|
- examStudentBean.setStudentName(saved.getStudentName());
|
|
|
- examStudentBean.setGrade(saved.getGrade());
|
|
|
- examStudentBean.setCourseId(saved.getCourseId());
|
|
|
- examStudentBean.setInfoCollector(saved.getInfoCollector());
|
|
|
- examStudentBean.setExamSite(saved.getExamSite());
|
|
|
- examStudentBean.setOrgId(saved.getOrgId());
|
|
|
- examStudentBean.setOrgCode(saved.getOrgCode());
|
|
|
- examStudentBean.setOrgName(saved.getOrgName());
|
|
|
-
|
|
|
- resp.setExamStudentBean(examStudentBean);
|
|
|
-
|
|
|
- return resp;
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "复制考生")
|
|
|
- @PostMapping("copyExamStudents")
|
|
|
- @Override
|
|
|
- public CopyExamStudentsResp copyExamStudents(@RequestBody CopyExamStudentsReq req) {
|
|
|
-
|
|
|
- Long examId1 = req.getExamId1();
|
|
|
- Long examId2 = req.getExamId2();
|
|
|
-
|
|
|
- if (null == examId1) {
|
|
|
- throw new StatusException("E-210001", "examId1 is null");
|
|
|
- }
|
|
|
- if (null == examId2) {
|
|
|
- throw new StatusException("E-210002", "examId2 is null");
|
|
|
- }
|
|
|
-
|
|
|
- ExamEntity exam1 = examRepo.findOne(examId1);
|
|
|
- ExamEntity exam2 = examRepo.findOne(examId2);
|
|
|
- if (null == exam1) {
|
|
|
- throw new StatusException("E-210003", "ExamEntity is null");
|
|
|
- }
|
|
|
- if (null == exam2) {
|
|
|
- throw new StatusException("E-210004", "ExamEntity is null");
|
|
|
- }
|
|
|
-
|
|
|
- if (!exam1.getRootOrgId().equals(exam2.getRootOrgId())) {
|
|
|
- throw new StatusException("E-210005", "examId1 and examId2 is not matched");
|
|
|
- }
|
|
|
-
|
|
|
- final Long rootOrgId = exam1.getRootOrgId();
|
|
|
-
|
|
|
- final long start = null == req.getStart() ? 1 : req.getStart();
|
|
|
-
|
|
|
- Pageable pageable = new PageRequest(0, 10, Sort.Direction.ASC, "id");
|
|
|
-
|
|
|
- Specification<ExamStudentEntity> specification = (root, query, cb) -> {
|
|
|
- List<Predicate> predicates = new ArrayList<>();
|
|
|
- predicates.add(cb.equal(root.get("rootOrgId"), rootOrgId));
|
|
|
- predicates.add(cb.greaterThanOrEqualTo(root.get("id"), start));
|
|
|
- predicates.add(cb.equal(root.get("examId"), examId1));
|
|
|
-
|
|
|
- return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
- };
|
|
|
-
|
|
|
- Page<ExamStudentEntity> page = examStudentRepo.findAll(specification, pageable);
|
|
|
-
|
|
|
- Iterator<ExamStudentEntity> iterator = page.iterator();
|
|
|
-
|
|
|
- List<Long> examStudentIds = Lists.newArrayList();
|
|
|
-
|
|
|
- long next = start;
|
|
|
- while (iterator.hasNext()) {
|
|
|
- ExamStudentEntity es = iterator.next();
|
|
|
-
|
|
|
- ExamStudentEntity finded = examStudentRepo.findByExamIdAndStudentIdAndCourseId(examId2,
|
|
|
- es.getStudentId(), es.getCourseId());
|
|
|
-
|
|
|
- if (null != finded) {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- ExamStudentInfo one = new ExamStudentInfo();
|
|
|
- one.setExamId(examId2);
|
|
|
- one.setRootOrgId(es.getRootOrgId());
|
|
|
-
|
|
|
- one.setCourseId(es.getCourseId());
|
|
|
- one.setCourseCode(es.getCourseCode());
|
|
|
- one.setCourseLevel(es.getCourseLevel());
|
|
|
- one.setCourseName(es.getCourseName());
|
|
|
-
|
|
|
- one.setOrgId(es.getOrgId());
|
|
|
- one.setOrgCode(es.getOrgCode());
|
|
|
-
|
|
|
- one.setStudentName(es.getName());
|
|
|
- one.setStudentCode(es.getStudentCode());
|
|
|
- one.setStudentId(es.getStudentId());
|
|
|
- one.setIdentityNumber(es.getIdentityNumber());
|
|
|
-
|
|
|
- one.setExamSite(es.getExamSite());
|
|
|
- one.setGrade(es.getGrade());
|
|
|
- one.setPaperType(es.getPaperType());
|
|
|
- one.setRemark(es.getRemark());
|
|
|
- one.setSpecialtyName(es.getSpecialtyName());
|
|
|
- one.setInfoCollector(es.getInfoCollector());
|
|
|
-
|
|
|
- one.setExt1(es.getExt1());
|
|
|
- one.setExt2(es.getExt2());
|
|
|
- one.setExt3(es.getExt3());
|
|
|
- one.setExt4(es.getExt4());
|
|
|
- one.setExt5(es.getExt5());
|
|
|
-
|
|
|
- ExamStudentInfo saved = examStudentService.saveExamStudent(one);
|
|
|
- examStudentIds.add(saved.getId());
|
|
|
-
|
|
|
- next = es.getId();
|
|
|
- }
|
|
|
-
|
|
|
- if (next != start)
|
|
|
-
|
|
|
- {
|
|
|
- next++;
|
|
|
- }
|
|
|
-
|
|
|
- CopyExamStudentsResp resp = new CopyExamStudentsResp();
|
|
|
- resp.setNext(next);
|
|
|
- resp.setExamStudentIds(examStudentIds);
|
|
|
-
|
|
|
- return resp;
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "获取考生")
|
|
|
- @PostMapping("getExamStudent")
|
|
|
- @Override
|
|
|
- public GetExamStudentResp getExamStudent(@RequestBody GetExamStudentReq req) {
|
|
|
- Long examStudentId = req.getExamStudentId();
|
|
|
-
|
|
|
- ExamStudentEntity saved = examStudentRepo.findOne(examStudentId);
|
|
|
-
|
|
|
- ExamStudentBean examStudentBean = new ExamStudentBean();
|
|
|
- examStudentBean.setId(saved.getId());
|
|
|
- examStudentBean.setCourseCode(saved.getCourseCode());
|
|
|
- examStudentBean.setCourseLevel(saved.getCourseLevel());
|
|
|
- examStudentBean.setCourseName(saved.getCourseName());
|
|
|
- examStudentBean.setExamId(saved.getExamId());
|
|
|
- examStudentBean.setIdentityNumber(saved.getIdentityNumber());
|
|
|
- examStudentBean.setStudentCode(saved.getStudentCode());
|
|
|
- examStudentBean.setPaperType(saved.getPaperType());
|
|
|
- examStudentBean.setRootOrgId(saved.getRootOrgId());
|
|
|
- examStudentBean.setGrade(saved.getGrade());
|
|
|
- examStudentBean.setCourseId(saved.getCourseId());
|
|
|
- examStudentBean.setInfoCollector(saved.getInfoCollector());
|
|
|
- examStudentBean.setExamSite(saved.getExamSite());
|
|
|
- examStudentBean.setOrgId(saved.getOrgId());
|
|
|
- examStudentBean.setOrgCode(saved.getOrgCode());
|
|
|
- examStudentBean.setStudentName(saved.getName());
|
|
|
- examStudentBean.setSpecialtyName(saved.getSpecialtyName());
|
|
|
-
|
|
|
- GetExamStudentResp resp = new GetExamStudentResp();
|
|
|
- resp.setExamStudentBean(examStudentBean);
|
|
|
- return resp;
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = " 分页查询考生")
|
|
|
- @PostMapping("getExamStudentPage")
|
|
|
- @Override
|
|
|
- public GetExamStudentPageResp getExamStudentPage(@RequestBody GetExamStudentPageReq req) {
|
|
|
- Long rootOrgId = req.getRootOrgId();
|
|
|
- String courseCode = req.getCourseCode();
|
|
|
- String courseLevel = req.getCourseLevel();
|
|
|
- String courseName = req.getCourseName();
|
|
|
- Integer curPage = req.getCurPage();
|
|
|
- Long examId = req.getExamId();
|
|
|
- String examSite = req.getExamSite();
|
|
|
- String identityNumber = req.getIdentityNumber();
|
|
|
- String infoCollector = req.getInfoCollector();
|
|
|
- Long orgId = req.getOrgId();
|
|
|
- String specialtyName = req.getSpecialtyName();
|
|
|
- String studentCode = req.getStudentCode();
|
|
|
- String studentName = req.getStudentName();
|
|
|
- Integer pageSize = req.getPageSize();
|
|
|
-
|
|
|
- if (null == rootOrgId) {
|
|
|
- throw new StatusException("E-210005", "rootOrgId is null");
|
|
|
- }
|
|
|
-
|
|
|
- Specification<ExamStudentEntity> specification = (root, query, cb) -> {
|
|
|
- List<Predicate> predicates = new ArrayList<>();
|
|
|
- predicates.add(cb.equal(root.get("rootOrgId"), rootOrgId));
|
|
|
-
|
|
|
- if (null != orgId) {
|
|
|
- predicates.add(cb.equal(root.get("orgId"), orgId));
|
|
|
- }
|
|
|
-
|
|
|
- if (null != examId) {
|
|
|
- predicates.add(cb.equal(root.get("examId"), examId));
|
|
|
- }
|
|
|
- if (StringUtils.isNotEmpty(studentName)) {
|
|
|
- predicates.add(cb.like(root.get("name"), toSqlSearchPattern(studentName)));
|
|
|
- }
|
|
|
- if (StringUtils.isNotEmpty(studentCode)) {
|
|
|
- predicates.add(cb.like(root.get("studentCode"), toSqlSearchPattern(studentCode)));
|
|
|
- }
|
|
|
- if (StringUtils.isNotEmpty(courseCode)) {
|
|
|
- predicates.add(cb.equal(root.get("courseCode"), courseCode));
|
|
|
- }
|
|
|
- if (StringUtils.isNotEmpty(courseLevel)) {
|
|
|
- predicates.add(cb.equal(root.get("courseLevel"), courseLevel));
|
|
|
- }
|
|
|
- if (StringUtils.isNotEmpty(courseName)) {
|
|
|
- predicates.add(cb.like(root.get("courseName"), toSqlSearchPattern(courseName)));
|
|
|
- }
|
|
|
- if (!StringUtils.isEmpty(examSite)) {
|
|
|
- predicates.add(cb.like(root.get("examSite"), toSqlSearchPattern(examSite)));
|
|
|
- }
|
|
|
- if (StringUtils.isNotEmpty(identityNumber)) {
|
|
|
- predicates.add(
|
|
|
- cb.like(root.get("identityNumber"), toSqlSearchPattern(identityNumber)));
|
|
|
- }
|
|
|
- if (StringUtils.isNotEmpty(specialtyName)) {
|
|
|
- predicates
|
|
|
- .add(cb.like(root.get("specialtyName"), toSqlSearchPattern(specialtyName)));
|
|
|
- }
|
|
|
- if (StringUtils.isNotEmpty(infoCollector)) {
|
|
|
- predicates
|
|
|
- .add(cb.like(root.get("infoCollector"), toSqlSearchPattern(infoCollector)));
|
|
|
- }
|
|
|
-
|
|
|
- return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
- };
|
|
|
-
|
|
|
- PageRequest pageRequest = new PageRequest(curPage, pageSize,
|
|
|
- new Sort(Direction.DESC, "updateTime"));
|
|
|
-
|
|
|
- Page<ExamStudentEntity> examStudents = examStudentRepo.findAll(specification, pageRequest);
|
|
|
-
|
|
|
- List<ExamStudentBean> list = Lists.newArrayList();
|
|
|
-
|
|
|
- for (ExamStudentEntity cur : examStudents) {
|
|
|
- ExamEntity exam = examRepo.findOne(cur.getExamId());
|
|
|
-
|
|
|
- GetOrgReq getOrgReq = new GetOrgReq();
|
|
|
- getOrgReq.setOrgId(cur.getOrgId());
|
|
|
- GetOrgResp getOrgResp = orgCloudService.getOrg(getOrgReq);
|
|
|
- OrgBean org = getOrgResp.getOrg();
|
|
|
-
|
|
|
- ExamStudentBean bean = new ExamStudentBean();
|
|
|
- bean.setId(cur.getId());
|
|
|
- bean.setExamId(exam.getId());
|
|
|
- bean.setExamName(exam.getName());
|
|
|
- bean.setStudentId(cur.getStudentId());
|
|
|
- bean.setStudentName(cur.getName());
|
|
|
- bean.setStudentCode(cur.getStudentCode());
|
|
|
- bean.setIdentityNumber(cur.getIdentityNumber());
|
|
|
- bean.setCourseCode(cur.getCourseCode());
|
|
|
- bean.setCourseName(cur.getCourseName());
|
|
|
- bean.setInfoCollector(cur.getInfoCollector());
|
|
|
- bean.setOrgId(cur.getOrgId());
|
|
|
- bean.setOrgCode(org.getCode());
|
|
|
- bean.setOrgName(org.getName());
|
|
|
- bean.setPaperType(cur.getPaperType());
|
|
|
- bean.setGrade(cur.getGrade());
|
|
|
- bean.setSpecialtyName(cur.getSpecialtyName());
|
|
|
- bean.setExamSite(cur.getExamSite());
|
|
|
-
|
|
|
- list.add(bean);
|
|
|
- }
|
|
|
-
|
|
|
- GetExamStudentPageResp resp = new GetExamStudentPageResp();
|
|
|
- resp.setList(list);
|
|
|
- resp.setTotal(examStudents.getTotalElements());
|
|
|
-
|
|
|
- return resp;
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
+package cn.com.qmth.examcloud.core.examwork.api.provider;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Iterator;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import javax.persistence.criteria.Predicate;
|
|
|
+
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.data.domain.PageRequest;
|
|
|
+import org.springframework.data.domain.Pageable;
|
|
|
+import org.springframework.data.domain.Sort;
|
|
|
+import org.springframework.data.domain.Sort.Direction;
|
|
|
+import org.springframework.data.jpa.domain.Specification;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+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 com.google.common.collect.Lists;
|
|
|
+
|
|
|
+import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
+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.StudentCloudService;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.bean.OrgBean;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.request.GetOrgReq;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.response.GetOrgResp;
|
|
|
+import cn.com.qmth.examcloud.core.examwork.dao.ExamCourseRelationRepo;
|
|
|
+import cn.com.qmth.examcloud.core.examwork.dao.ExamPaperTypeRelationRepo;
|
|
|
+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.entity.ExamEntity;
|
|
|
+import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamStudentEntity;
|
|
|
+import cn.com.qmth.examcloud.core.examwork.service.ExamStudentService;
|
|
|
+import cn.com.qmth.examcloud.core.examwork.service.bean.ExamStudentInfo;
|
|
|
+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.CopyExamStudentsReq;
|
|
|
+import cn.com.qmth.examcloud.examwork.api.request.GetExamStudentPageReq;
|
|
|
+import cn.com.qmth.examcloud.examwork.api.request.GetExamStudentReq;
|
|
|
+import cn.com.qmth.examcloud.examwork.api.request.SaveExamStudentReq;
|
|
|
+import cn.com.qmth.examcloud.examwork.api.response.CopyExamStudentsResp;
|
|
|
+import cn.com.qmth.examcloud.examwork.api.response.GetExamStudentPageResp;
|
|
|
+import cn.com.qmth.examcloud.examwork.api.response.GetExamStudentResp;
|
|
|
+import cn.com.qmth.examcloud.examwork.api.response.SaveExamStudentResp;
|
|
|
+import cn.com.qmth.examcloud.task.api.DataSyncCloudService;
|
|
|
+import cn.com.qmth.examcloud.web.support.ControllerSupport;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 类注释
|
|
|
+ *
|
|
|
+ * @author WANGWEI
|
|
|
+ * @date 2018年7月18日
|
|
|
+ * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
|
|
|
+ */
|
|
|
+@Transactional
|
|
|
+@RestController
|
|
|
+@RequestMapping("${$rmp.cloud.examwork}" + "examStudent")
|
|
|
+public class ExamStudentCloudServiceProvider extends ControllerSupport
|
|
|
+ implements
|
|
|
+ ExamStudentCloudService {
|
|
|
+
|
|
|
+ private static final long serialVersionUID = -89062090947597841L;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ExamRepo examRepo;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ OrgCloudService orgCloudService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ExamStudentService examStudentService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ StudentCloudService studentCloudService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ExamStudentRepo examStudentRepo;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ CourseCloudService courseCloudService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ExamCourseRelationRepo examCourseRelationRepo;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ExamPaperTypeRelationRepo examPaperTypeRelationRepo;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ DataSyncCloudService dataSyncCloudService;
|
|
|
+
|
|
|
+ @ApiOperation(value = "保存考生")
|
|
|
+ @PostMapping("saveExamStudent")
|
|
|
+ @Override
|
|
|
+ public SaveExamStudentResp saveExamStudent(@RequestBody SaveExamStudentReq req) {
|
|
|
+ trim(req);
|
|
|
+ ExamStudentInfo info = new ExamStudentInfo();
|
|
|
+ info.setCourseCode(req.getCourseCode());
|
|
|
+ info.setCourseName(req.getCourseName());
|
|
|
+ info.setCourseLevel(req.getCourseLevel());
|
|
|
+ info.setCourseId(req.getCourseId());
|
|
|
+ info.setRootOrgId(req.getRootOrgId());
|
|
|
+ info.setExamId(req.getExamId());
|
|
|
+ info.setExamName(req.getExamName());
|
|
|
+ info.setIdentityNumber(req.getIdentityNumber());
|
|
|
+ info.setPaperType(req.getPaperType());
|
|
|
+ info.setStudentCode(req.getStudentCode());
|
|
|
+ info.setStudentName(req.getStudentName());
|
|
|
+ info.setInfoCollector(req.getInfoCollector());
|
|
|
+ info.setGrade(req.getGrade());
|
|
|
+ info.setExamSite(req.getExamSite());
|
|
|
+ info.setSpecialtyName(req.getSpecialtyName());
|
|
|
+ info.setRemark(req.getRemark());
|
|
|
+
|
|
|
+ info.setExt1(req.getExt1());
|
|
|
+ info.setExt2(req.getExt2());
|
|
|
+ info.setExt3(req.getExt3());
|
|
|
+ info.setExt4(req.getExt4());
|
|
|
+ info.setExt5(req.getExt5());
|
|
|
+
|
|
|
+ ExamStudentInfo saved = examStudentService.saveExamStudent(info);
|
|
|
+
|
|
|
+ SaveExamStudentResp resp = new SaveExamStudentResp();
|
|
|
+
|
|
|
+ ExamStudentBean examStudentBean = new ExamStudentBean();
|
|
|
+ examStudentBean.setId(saved.getId());
|
|
|
+ examStudentBean.setCourseCode(saved.getCourseCode());
|
|
|
+ examStudentBean.setCourseLevel(saved.getCourseLevel());
|
|
|
+ examStudentBean.setCourseName(saved.getCourseName());
|
|
|
+ examStudentBean.setExamId(saved.getExamId());
|
|
|
+ examStudentBean.setExamName(saved.getExamName());
|
|
|
+ examStudentBean.setIdentityNumber(saved.getIdentityNumber());
|
|
|
+ examStudentBean.setStudentCode(saved.getStudentCode());
|
|
|
+ examStudentBean.setPaperType(saved.getPaperType());
|
|
|
+ examStudentBean.setRootOrgId(saved.getRootOrgId());
|
|
|
+ examStudentBean.setStudentName(saved.getStudentName());
|
|
|
+ examStudentBean.setGrade(saved.getGrade());
|
|
|
+ examStudentBean.setCourseId(saved.getCourseId());
|
|
|
+ examStudentBean.setInfoCollector(saved.getInfoCollector());
|
|
|
+ examStudentBean.setExamSite(saved.getExamSite());
|
|
|
+ examStudentBean.setOrgId(saved.getOrgId());
|
|
|
+ examStudentBean.setOrgCode(saved.getOrgCode());
|
|
|
+ examStudentBean.setOrgName(saved.getOrgName());
|
|
|
+
|
|
|
+ resp.setExamStudentBean(examStudentBean);
|
|
|
+
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "复制考生")
|
|
|
+ @PostMapping("copyExamStudents")
|
|
|
+ @Override
|
|
|
+ public CopyExamStudentsResp copyExamStudents(@RequestBody CopyExamStudentsReq req) {
|
|
|
+
|
|
|
+ Long examId1 = req.getExamId1();
|
|
|
+ Long examId2 = req.getExamId2();
|
|
|
+
|
|
|
+ if (null == examId1) {
|
|
|
+ throw new StatusException("E-210001", "examId1 is null");
|
|
|
+ }
|
|
|
+ if (null == examId2) {
|
|
|
+ throw new StatusException("E-210002", "examId2 is null");
|
|
|
+ }
|
|
|
+
|
|
|
+ ExamEntity exam1 = examRepo.findOne(examId1);
|
|
|
+ ExamEntity exam2 = examRepo.findOne(examId2);
|
|
|
+ if (null == exam1) {
|
|
|
+ throw new StatusException("E-210003", "ExamEntity is null");
|
|
|
+ }
|
|
|
+ if (null == exam2) {
|
|
|
+ throw new StatusException("E-210004", "ExamEntity is null");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!exam1.getRootOrgId().equals(exam2.getRootOrgId())) {
|
|
|
+ throw new StatusException("E-210005", "examId1 and examId2 is not matched");
|
|
|
+ }
|
|
|
+
|
|
|
+ final Long rootOrgId = exam1.getRootOrgId();
|
|
|
+
|
|
|
+ final long start = null == req.getStart() ? 1 : req.getStart();
|
|
|
+
|
|
|
+ Pageable pageable = new PageRequest(0, 10, Sort.Direction.ASC, "id");
|
|
|
+
|
|
|
+ Specification<ExamStudentEntity> specification = (root, query, cb) -> {
|
|
|
+ List<Predicate> predicates = new ArrayList<>();
|
|
|
+ predicates.add(cb.equal(root.get("rootOrgId"), rootOrgId));
|
|
|
+ predicates.add(cb.greaterThanOrEqualTo(root.get("id"), start));
|
|
|
+ predicates.add(cb.equal(root.get("examId"), examId1));
|
|
|
+
|
|
|
+ return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
+ };
|
|
|
+
|
|
|
+ Page<ExamStudentEntity> page = examStudentRepo.findAll(specification, pageable);
|
|
|
+
|
|
|
+ Iterator<ExamStudentEntity> iterator = page.iterator();
|
|
|
+
|
|
|
+ List<Long> examStudentIds = Lists.newArrayList();
|
|
|
+
|
|
|
+ long next = start;
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ ExamStudentEntity es = iterator.next();
|
|
|
+
|
|
|
+ ExamStudentEntity finded = examStudentRepo.findByExamIdAndStudentIdAndCourseId(examId2,
|
|
|
+ es.getStudentId(), es.getCourseId());
|
|
|
+
|
|
|
+ if (null != finded) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ ExamStudentInfo one = new ExamStudentInfo();
|
|
|
+ one.setExamId(examId2);
|
|
|
+ one.setRootOrgId(es.getRootOrgId());
|
|
|
+
|
|
|
+ one.setCourseId(es.getCourseId());
|
|
|
+ one.setCourseCode(es.getCourseCode());
|
|
|
+ one.setCourseLevel(es.getCourseLevel());
|
|
|
+ one.setCourseName(es.getCourseName());
|
|
|
+
|
|
|
+ one.setOrgId(es.getOrgId());
|
|
|
+ one.setOrgCode(es.getOrgCode());
|
|
|
+
|
|
|
+ one.setStudentName(es.getName());
|
|
|
+ one.setStudentCode(es.getStudentCode());
|
|
|
+ one.setStudentId(es.getStudentId());
|
|
|
+ one.setIdentityNumber(es.getIdentityNumber());
|
|
|
+
|
|
|
+ one.setExamSite(es.getExamSite());
|
|
|
+ one.setGrade(es.getGrade());
|
|
|
+ one.setPaperType(es.getPaperType());
|
|
|
+ one.setRemark(es.getRemark());
|
|
|
+ one.setSpecialtyName(es.getSpecialtyName());
|
|
|
+ one.setInfoCollector(es.getInfoCollector());
|
|
|
+
|
|
|
+ one.setExt1(es.getExt1());
|
|
|
+ one.setExt2(es.getExt2());
|
|
|
+ one.setExt3(es.getExt3());
|
|
|
+ one.setExt4(es.getExt4());
|
|
|
+ one.setExt5(es.getExt5());
|
|
|
+
|
|
|
+ ExamStudentInfo saved = examStudentService.saveExamStudent(one);
|
|
|
+ examStudentIds.add(saved.getId());
|
|
|
+
|
|
|
+ next = es.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (next != start)
|
|
|
+
|
|
|
+ {
|
|
|
+ next++;
|
|
|
+ }
|
|
|
+
|
|
|
+ CopyExamStudentsResp resp = new CopyExamStudentsResp();
|
|
|
+ resp.setNext(next);
|
|
|
+ resp.setExamStudentIds(examStudentIds);
|
|
|
+
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "获取考生")
|
|
|
+ @PostMapping("getExamStudent")
|
|
|
+ @Override
|
|
|
+ public GetExamStudentResp getExamStudent(@RequestBody GetExamStudentReq req) {
|
|
|
+ Long examStudentId = req.getExamStudentId();
|
|
|
+
|
|
|
+ ExamStudentEntity saved = examStudentRepo.findOne(examStudentId);
|
|
|
+
|
|
|
+ ExamStudentBean examStudentBean = new ExamStudentBean();
|
|
|
+ examStudentBean.setId(saved.getId());
|
|
|
+ examStudentBean.setCourseCode(saved.getCourseCode());
|
|
|
+ examStudentBean.setCourseLevel(saved.getCourseLevel());
|
|
|
+ examStudentBean.setCourseName(saved.getCourseName());
|
|
|
+ examStudentBean.setExamId(saved.getExamId());
|
|
|
+ examStudentBean.setIdentityNumber(saved.getIdentityNumber());
|
|
|
+ examStudentBean.setStudentCode(saved.getStudentCode());
|
|
|
+ examStudentBean.setPaperType(saved.getPaperType());
|
|
|
+ examStudentBean.setRootOrgId(saved.getRootOrgId());
|
|
|
+ examStudentBean.setGrade(saved.getGrade());
|
|
|
+ examStudentBean.setCourseId(saved.getCourseId());
|
|
|
+ examStudentBean.setInfoCollector(saved.getInfoCollector());
|
|
|
+ examStudentBean.setExamSite(saved.getExamSite());
|
|
|
+ examStudentBean.setOrgId(saved.getOrgId());
|
|
|
+ examStudentBean.setOrgCode(saved.getOrgCode());
|
|
|
+ examStudentBean.setStudentName(saved.getName());
|
|
|
+ examStudentBean.setSpecialtyName(saved.getSpecialtyName());
|
|
|
+
|
|
|
+ GetExamStudentResp resp = new GetExamStudentResp();
|
|
|
+ resp.setExamStudentBean(examStudentBean);
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = " 分页查询考生")
|
|
|
+ @PostMapping("getExamStudentPage")
|
|
|
+ @Override
|
|
|
+ public GetExamStudentPageResp getExamStudentPage(@RequestBody GetExamStudentPageReq req) {
|
|
|
+ Long rootOrgId = req.getRootOrgId();
|
|
|
+ String courseCode = req.getCourseCode();
|
|
|
+ String courseLevel = req.getCourseLevel();
|
|
|
+ String courseName = req.getCourseName();
|
|
|
+ Integer curPage = req.getCurPage();
|
|
|
+ Long examId = req.getExamId();
|
|
|
+ String examSite = req.getExamSite();
|
|
|
+ String identityNumber = req.getIdentityNumber();
|
|
|
+ String infoCollector = req.getInfoCollector();
|
|
|
+ Long orgId = req.getOrgId();
|
|
|
+ String specialtyName = req.getSpecialtyName();
|
|
|
+ String studentCode = req.getStudentCode();
|
|
|
+ String studentName = req.getStudentName();
|
|
|
+ Integer pageSize = req.getPageSize();
|
|
|
+
|
|
|
+ if (null == rootOrgId) {
|
|
|
+ throw new StatusException("E-210005", "rootOrgId is null");
|
|
|
+ }
|
|
|
+
|
|
|
+ Specification<ExamStudentEntity> specification = (root, query, cb) -> {
|
|
|
+ List<Predicate> predicates = new ArrayList<>();
|
|
|
+ predicates.add(cb.equal(root.get("rootOrgId"), rootOrgId));
|
|
|
+
|
|
|
+ if (null != orgId) {
|
|
|
+ predicates.add(cb.equal(root.get("orgId"), orgId));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (null != examId) {
|
|
|
+ predicates.add(cb.equal(root.get("examId"), examId));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(studentName)) {
|
|
|
+ predicates.add(cb.like(root.get("name"), toSqlSearchPattern(studentName)));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(studentCode)) {
|
|
|
+ predicates.add(cb.like(root.get("studentCode"), toSqlSearchPattern(studentCode)));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(courseCode)) {
|
|
|
+ predicates.add(cb.equal(root.get("courseCode"), courseCode));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(courseLevel)) {
|
|
|
+ predicates.add(cb.equal(root.get("courseLevel"), courseLevel));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(courseName)) {
|
|
|
+ predicates.add(cb.like(root.get("courseName"), toSqlSearchPattern(courseName)));
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(examSite)) {
|
|
|
+ predicates.add(cb.like(root.get("examSite"), toSqlSearchPattern(examSite)));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(identityNumber)) {
|
|
|
+ predicates.add(
|
|
|
+ cb.like(root.get("identityNumber"), toSqlSearchPattern(identityNumber)));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(specialtyName)) {
|
|
|
+ predicates
|
|
|
+ .add(cb.like(root.get("specialtyName"), toSqlSearchPattern(specialtyName)));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(infoCollector)) {
|
|
|
+ predicates
|
|
|
+ .add(cb.like(root.get("infoCollector"), toSqlSearchPattern(infoCollector)));
|
|
|
+ }
|
|
|
+
|
|
|
+ return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
+ };
|
|
|
+
|
|
|
+ PageRequest pageRequest = new PageRequest(curPage, pageSize,
|
|
|
+ new Sort(Direction.DESC, "updateTime"));
|
|
|
+
|
|
|
+ Page<ExamStudentEntity> examStudents = examStudentRepo.findAll(specification, pageRequest);
|
|
|
+
|
|
|
+ List<ExamStudentBean> list = Lists.newArrayList();
|
|
|
+
|
|
|
+ for (ExamStudentEntity cur : examStudents) {
|
|
|
+ ExamEntity exam = examRepo.findOne(cur.getExamId());
|
|
|
+
|
|
|
+ GetOrgReq getOrgReq = new GetOrgReq();
|
|
|
+ getOrgReq.setOrgId(cur.getOrgId());
|
|
|
+ GetOrgResp getOrgResp = orgCloudService.getOrg(getOrgReq);
|
|
|
+ OrgBean org = getOrgResp.getOrg();
|
|
|
+
|
|
|
+ ExamStudentBean bean = new ExamStudentBean();
|
|
|
+ bean.setId(cur.getId());
|
|
|
+ bean.setExamId(exam.getId());
|
|
|
+ bean.setExamName(exam.getName());
|
|
|
+ bean.setStudentId(cur.getStudentId());
|
|
|
+ bean.setStudentName(cur.getName());
|
|
|
+ bean.setStudentCode(cur.getStudentCode());
|
|
|
+ bean.setIdentityNumber(cur.getIdentityNumber());
|
|
|
+ bean.setCourseCode(cur.getCourseCode());
|
|
|
+ bean.setCourseName(cur.getCourseName());
|
|
|
+ bean.setInfoCollector(cur.getInfoCollector());
|
|
|
+ bean.setOrgId(cur.getOrgId());
|
|
|
+ bean.setOrgCode(org.getCode());
|
|
|
+ bean.setOrgName(org.getName());
|
|
|
+ bean.setPaperType(cur.getPaperType());
|
|
|
+ bean.setGrade(cur.getGrade());
|
|
|
+ bean.setSpecialtyName(cur.getSpecialtyName());
|
|
|
+ bean.setExamSite(cur.getExamSite());
|
|
|
+
|
|
|
+ list.add(bean);
|
|
|
+ }
|
|
|
+
|
|
|
+ GetExamStudentPageResp resp = new GetExamStudentPageResp();
|
|
|
+ resp.setList(list);
|
|
|
+ resp.setTotal(examStudents.getTotalElements());
|
|
|
+
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|