wangwei 6 жил өмнө
parent
commit
c627ff05af

+ 66 - 33
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/ExamStudentController.java

@@ -19,12 +19,12 @@ import org.springframework.data.jpa.domain.Specification;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.ModelAttribute;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PutMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import com.google.common.collect.Lists;
@@ -55,6 +55,9 @@ 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.core.oe.admin.api.ExamRecordCloudService;
+import cn.com.qmth.examcloud.core.oe.admin.api.request.CheckExamIsStartedReq;
+import cn.com.qmth.examcloud.core.oe.admin.api.response.CheckExamIsStartedResp;
 import io.swagger.annotations.ApiOperation;
 
 /**
@@ -83,6 +86,9 @@ public class ExamStudentController extends ControllerSupport {
 	@Autowired
 	OrgCloudService orgCloudService;
 
+	@Autowired
+	ExamRecordCloudService examRecordCloudService;
+
 	/**
 	 * 方法注释
 	 *
@@ -108,54 +114,60 @@ public class ExamStudentController extends ControllerSupport {
 	 */
 	@ApiOperation(value = "查询考试学生带条件和分页", notes = "带条件带分页")
 	@GetMapping("examStudentPage/{curPage}/{pageSize}")
-	public PageInfo<ExamStudentDomain> getExamStudentPage(
-			@ModelAttribute ExamStudentDomain examCriteria, @PathVariable Integer curPage,
-			@PathVariable Integer pageSize) {
+	public PageInfo<ExamStudentDomain> getExamStudentPage(@PathVariable Integer curPage,
+			@PathVariable Integer pageSize, @RequestParam(required = false) Long orgId,
+			@RequestParam(required = false) Long examId,
+			@RequestParam(required = false) String studentName,
+			@RequestParam(required = false) String studentCode,
+			@RequestParam(required = false) String courseCode,
+			@RequestParam(required = false) String courseLevel,
+			@RequestParam(required = false) String courseName,
+			@RequestParam(required = false) String examSite,
+			@RequestParam(required = false) String identityNumber,
+			@RequestParam(required = false) String specialtyName,
+			@RequestParam(required = false) String infoCollector,
+			@RequestParam(required = false) Boolean withStarted) {
 		User accessUser = getAccessUser();
 		Specification<ExamStudentEntity> specification = (root, query, cb) -> {
 			List<Predicate> predicates = new ArrayList<>();
 			predicates.add(cb.equal(root.get("rootOrgId"), accessUser.getRootOrgId()));
 
-			if (null != examCriteria.getOrgId()) {
-				predicates.add(cb.equal(root.get("orgId"), examCriteria.getOrgId()));
+			if (null != orgId) {
+				predicates.add(cb.equal(root.get("orgId"), orgId));
 			}
 
-			if (null != examCriteria.getExamId()) {
-				predicates.add(cb.equal(root.get("examId"), examCriteria.getExamId()));
+			if (null != examId) {
+				predicates.add(cb.equal(root.get("examId"), examId));
 			}
-			if (StringUtils.isNotEmpty(examCriteria.getStudentName())) {
-				predicates.add(cb.like(root.get("name"),
-						toSqlSearchPattern(examCriteria.getStudentName())));
+			if (StringUtils.isNotEmpty(studentName)) {
+				predicates.add(cb.like(root.get("name"), toSqlSearchPattern(studentName)));
 			}
-			if (StringUtils.isNotEmpty(examCriteria.getStudentCode())) {
-				predicates.add(cb.like(root.get("studentCode"),
-						toSqlSearchPattern(examCriteria.getStudentCode())));
+			if (StringUtils.isNotEmpty(studentCode)) {
+				predicates.add(cb.like(root.get("studentCode"), toSqlSearchPattern(studentCode)));
 			}
-			if (StringUtils.isNotEmpty(examCriteria.getCourseCode())) {
-				predicates.add(cb.equal(root.get("courseCode"), examCriteria.getCourseCode()));
+			if (StringUtils.isNotEmpty(courseCode)) {
+				predicates.add(cb.equal(root.get("courseCode"), courseCode));
 			}
-			if (StringUtils.isNotEmpty(examCriteria.getCourseLevel())) {
-				predicates.add(cb.equal(root.get("courseLevel"), examCriteria.getCourseLevel()));
+			if (StringUtils.isNotEmpty(courseLevel)) {
+				predicates.add(cb.equal(root.get("courseLevel"), courseLevel));
 			}
-			if (StringUtils.isNotEmpty(examCriteria.getCourseName())) {
-				predicates.add(cb.like(root.get("courseName"),
-						toSqlSearchPattern(examCriteria.getCourseName())));
+			if (StringUtils.isNotEmpty(courseName)) {
+				predicates.add(cb.like(root.get("courseName"), toSqlSearchPattern(courseName)));
 			}
-			if (!StringUtils.isEmpty(examCriteria.getExamSite())) {
-				predicates.add(cb.like(root.get("examSite"),
-						toSqlSearchPattern(examCriteria.getExamSite())));
+			if (!StringUtils.isEmpty(examSite)) {
+				predicates.add(cb.like(root.get("examSite"), toSqlSearchPattern(examSite)));
 			}
-			if (StringUtils.isNotEmpty(examCriteria.getIdentityNumber())) {
-				predicates.add(cb.like(root.get("identityNumber"),
-						toSqlSearchPattern(examCriteria.getIdentityNumber())));
+			if (StringUtils.isNotEmpty(identityNumber)) {
+				predicates.add(
+						cb.like(root.get("identityNumber"), toSqlSearchPattern(identityNumber)));
 			}
-			if (StringUtils.isNotEmpty(examCriteria.getSpecialtyName())) {
-				predicates.add(cb.like(root.get("specialtyName"),
-						toSqlSearchPattern(examCriteria.getSpecialtyName())));
+			if (StringUtils.isNotEmpty(specialtyName)) {
+				predicates
+						.add(cb.like(root.get("specialtyName"), toSqlSearchPattern(specialtyName)));
 			}
-			if (StringUtils.isNotEmpty(examCriteria.getInfoCollector())) {
-				predicates.add(cb.like(root.get("infoCollector"),
-						toSqlSearchPattern(examCriteria.getInfoCollector())));
+			if (StringUtils.isNotEmpty(infoCollector)) {
+				predicates
+						.add(cb.like(root.get("infoCollector"), toSqlSearchPattern(infoCollector)));
 			}
 
 			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
@@ -170,11 +182,13 @@ public class ExamStudentController extends ControllerSupport {
 
 		for (ExamStudentEntity cur : examStudents) {
 			ExamEntity exam = examRepo.findOne(cur.getExamId());
+
 			GetCourseReq req = new GetCourseReq();
 			req.setId(cur.getCourseId());
 			req.setRootOrgId(accessUser.getRootOrgId());
 			GetCourseResp getCourseResp = courseCloudService.getCourse(req);
 			CourseBean courseBean = getCourseResp.getCourseBean();
+
 			GetOrgReq getOrgReq = new GetOrgReq();
 			getOrgReq.setOrgId(cur.getOrgId());
 			GetOrgResp getOrgResp = orgCloudService.getOrg(getOrgReq);
@@ -186,6 +200,23 @@ public class ExamStudentController extends ControllerSupport {
 			GetStudentResp getStudentResp = studentCloudService.getStudent(getStudentReq);
 			StudentBean studentBean = getStudentResp.getStudentInfo();
 
+			Boolean started = null;
+			if (null != withStarted && withStarted) {
+				CheckExamIsStartedReq checkExamIsStartedReq = new CheckExamIsStartedReq();
+				checkExamIsStartedReq.setExamId(exam.getId());
+				checkExamIsStartedReq.setCourseCode(courseBean.getCode());
+				checkExamIsStartedReq.setStudentId(studentBean.getId());
+				checkExamIsStartedReq.setExamId(exam.getId());
+				try {
+					CheckExamIsStartedResp checkExamIsStartedResp = examRecordCloudService
+							.checkExamIsStarted(checkExamIsStartedReq);
+					started = checkExamIsStartedResp.getIsStarted();
+				} catch (Exception e) {
+					log.error("fail to invoke remote method: checkExamIsStarted()", e);
+				}
+
+			}
+
 			ExamStudentDomain bean = new ExamStudentDomain();
 			bean.setId(cur.getId());
 			bean.setExamId(exam.getId());
@@ -209,6 +240,8 @@ public class ExamStudentController extends ControllerSupport {
 			bean.setUpdateTime(cur.getUpdateTime());
 			bean.setEnable(cur.getEnable());
 			bean.setLocked(exam.getExamStudentLocked());
+			bean.setStarted(started);
+
 			ret.add(bean);
 		}
 		return new PageInfo<ExamStudentDomain>(examStudents, ret);

+ 11 - 13
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/bean/ExamStudentDomain.java

@@ -5,7 +5,7 @@ import java.util.Date;
 import cn.com.qmth.examcloud.commons.web.cloud.api.JsonSerializable;
 
 /**
- * 类注释
+ * 考生
  *
  * @author WANGWEI
  * @date 2018年7月9日
@@ -51,26 +51,14 @@ public class ExamStudentDomain implements JsonSerializable {
 
 	private String specialtyName;
 
-	/**
-	 * 考点
-	 */
 	private String examSite;
 
-	/**
-	 * 信息采集人
-	 */
 	private String infoCollector;
 
-	/**
-	 * 学生电话
-	 */
 	private String phone;
 
 	private String remark;
 
-	/**
-	 * 年级
-	 */
 	private String grade;
 
 	private String examType;
@@ -81,6 +69,8 @@ public class ExamStudentDomain implements JsonSerializable {
 
 	private Boolean locked;
 
+	private Boolean started;
+
 	public Long getId() {
 		return id;
 	}
@@ -297,4 +287,12 @@ public class ExamStudentDomain implements JsonSerializable {
 		this.locked = locked;
 	}
 
+	public Boolean getStarted() {
+		return started;
+	}
+
+	public void setStarted(Boolean started) {
+		this.started = started;
+	}
+
 }

+ 6 - 0
examcloud-core-examwork-service/pom.xml

@@ -21,6 +21,12 @@
 			<version>${examcloud.version}</version>
 		</dependency>
 
+		<dependency>
+			<groupId>cn.com.qmth.examcloud.rmi</groupId>
+			<artifactId>examcloud-core-oe-admin-client</artifactId>
+			<version>${examcloud.version}</version>
+		</dependency>
+
 	</dependencies>
 
 </project>