瀏覽代碼

待考列表接口

xiatian 5 年之前
父節點
當前提交
4d247a2b7c

+ 21 - 2
examcloud-core-oe-admin-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/admin/api/controller/ExamControlController.java

@@ -1,6 +1,7 @@
 package cn.com.qmth.examcloud.core.oe.admin.api.controller;
 
 import java.util.Date;
+import java.util.List;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -13,6 +14,8 @@ import cn.com.qmth.examcloud.api.commons.enums.ExamType;
 import cn.com.qmth.examcloud.api.commons.security.bean.User;
 import cn.com.qmth.examcloud.commons.exception.StatusException;
 import cn.com.qmth.examcloud.commons.util.StringUtil;
+import cn.com.qmth.examcloud.core.oe.admin.service.ExamStudentService;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.OnHandExamInfo;
 import cn.com.qmth.examcloud.support.Constants;
 import cn.com.qmth.examcloud.support.cache.CacheHelper;
 import cn.com.qmth.examcloud.support.cache.bean.CourseCacheBean;
@@ -42,7 +45,12 @@ public class ExamControlController extends ControllerSupport {
 
 	@Autowired
 	private RedisClient redisClient;
-
+	
+	@Autowired
+    private ExamStudentService examStudentService;
+	
+	
+	
 	@ApiOperation(value = "准备考试")
 	@GetMapping("/prepare4Exam")
 	public void prepare4Exam(@RequestParam Long examStudentId) {
@@ -198,5 +206,16 @@ public class ExamControlController extends ControllerSupport {
 		redisClient.set(examBossKey, examBoss, 60);
 
 	}
-
+	
+    /**
+     * 获取在线考试待考列表
+     *
+     * @return
+     */
+    @ApiOperation(value = "获取在线考试待考列表")
+    @GetMapping("/queryExamList")
+    public List<OnHandExamInfo> queryExamList() {
+        User user = getAccessUser();
+        return examStudentService.queryOnlineExamList(user.getUserId());
+    }
 }

+ 1 - 1
examcloud-core-oe-admin-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/admin/api/controller/OfflineExamController.java

@@ -42,7 +42,7 @@ import io.swagger.annotations.ApiOperation;
  */
 @Api(tags = "离线考试控制")
 @RestController
-@RequestMapping("${app.api.oe.student}/offlineExam")
+@RequestMapping("${$rmp.ctr.oe}/offlineExam")
 public class OfflineExamController extends ControllerSupport{
 
 	@Autowired

+ 16 - 2
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/ExamStudentService.java

@@ -7,11 +7,17 @@
 
 package cn.com.qmth.examcloud.core.oe.admin.service;
 
-import cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.*;
+import java.util.List;
 
 import org.springframework.data.domain.Page;
 
-import java.util.List;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.OnHandExamInfo;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.CourseProgressInfo;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.ExamStudentFinishedStatistic;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.ExamStudentInfo;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.ExamStudentOrgStatistic;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.ExamStudentPartInfo;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.ExamStudentQuery;
 
 /**
  * 考生信息接口
@@ -117,4 +123,12 @@ public interface ExamStudentService {
 	 */
 	public List<ExamStudentInfo> getLimitExamStudentList(Long examId,Long startId,Integer size);
 
+	/**
+     * 获取在线考试待考列表
+     * @param studentId
+     * @return
+     */
+    public List<OnHandExamInfo> queryOnlineExamList(Long studentId);
+    
+
 }

+ 289 - 0
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/bean/OnHandExamInfo.java

@@ -0,0 +1,289 @@
+package cn.com.qmth.examcloud.core.oe.admin.service.bean;
+
+import java.util.Date;
+
+import cn.com.qmth.examcloud.api.commons.exchange.JsonSerializable;
+
+public class OnHandExamInfo implements JsonSerializable{
+
+    /**
+     * 待考列表信息
+     */
+    private static final long serialVersionUID = 6364550318267288565L;
+
+    private Long examStudentId;//考试报考ID
+    
+    private Long examId;//网考批次ID
+    
+    private String examName;//批次名称
+    
+    private String studentName;//考生名称
+    
+    private String studentCode;//考生学号
+    
+    private String identityNumber;//身份证号码
+    
+    private String specialtyName;//专业名称
+    
+    private String specialtyLevel;//层次
+    
+    private Long courseId;//课程ID
+    
+    private String courseName;//课程名称
+    
+    private String courseCode;//课程代码
+    
+    private String courseLevel;//课程层次
+    
+    private Long orgId;//学校中心ID
+    
+    private String orgName;//学习中心名称
+    
+    private String isPhotoUpload;//是否上传照片
+    
+    private int paperMins;//考试时长
+    
+    private int allowExamCount;//允许考试次数
+    
+    private Date startTime;//考试时间范围开始时间
+    
+    private Date endTime; //考试时间范围结束时间
+    
+    private Long rootOrgId;//机构ID
+    
+    private String isFinished;//是否缺考
+    
+    /**
+     * 考试状态
+     */
+    private String examStatus;
+
+    /**
+     * 是否有效
+     */
+    //private Boolean isvalid;
+    /**
+     * 是否启用人脸识别
+     */
+    private Boolean faceEnable;
+    /**
+     * 进入考试是否验证人脸识别(强制、非强制)
+     */
+    private Boolean faceCheck;
+    
+    /**
+     * 是否显示客观分
+     */
+    private Boolean isObjScoreView;
+
+
+    public String getStudentName() {
+        return studentName;
+    }
+
+    public void setStudentName(String studentName) {
+        this.studentName = studentName;
+    }
+    
+    public String getStudentCode() {
+        return studentCode;
+    }
+
+    public void setStudentCode(String studentCode) {
+        this.studentCode = studentCode;
+    }
+
+    public String getSpecialtyName() {
+        return specialtyName;
+    }
+
+    public void setSpecialtyName(String specialtyName) {
+        this.specialtyName = specialtyName;
+    }
+
+    public String getSpecialtyLevel() {
+        return specialtyLevel;
+    }
+
+    public void setSpecialtyLevel(String specialtyLevel) {
+        this.specialtyLevel = specialtyLevel;
+    }
+
+    public Long getCourseId() {
+        return courseId;
+    }
+
+    public void setCourseId(Long courseId) {
+        this.courseId = courseId;
+    }
+
+    public String getCourseName() {
+        return courseName;
+    }
+
+    public void setCourseName(String courseName) {
+        this.courseName = courseName;
+    }
+
+    public String getCourseCode() {
+        return courseCode;
+    }
+
+    public void setCourseCode(String courseCode) {
+        this.courseCode = courseCode;
+    }
+
+
+    public String getIsPhotoUpload() {
+        return isPhotoUpload;
+    }
+
+    public void setIsPhotoUpload(String isPhotoUpload) {
+        this.isPhotoUpload = isPhotoUpload;
+    }
+
+    public int getPaperMins() {
+        return paperMins;
+    }
+
+    public void setPaperMins(int paperMins) {
+        this.paperMins = paperMins;
+    }
+
+    public int getAllowExamCount() {
+        return allowExamCount;
+    }
+
+    public void setAllowExamCount(int allowExamCount) {
+        this.allowExamCount = allowExamCount;
+    }
+
+    public Date getStartTime() {
+        return startTime;
+    }
+
+    public void setStartTime(Date startTime) {
+        this.startTime = startTime;
+    }
+
+    public Date getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(Date endTime) {
+        this.endTime = endTime;
+    }
+
+    public String getIsFinished() {
+        return isFinished;
+    }
+
+    public void setIsFinished(String isFinished) {
+        this.isFinished = isFinished;
+    }
+
+    public String getExamStatus() {
+        return examStatus;
+    }
+
+    public void setExamStatus(String examStatus) {
+        this.examStatus = examStatus;
+    }
+
+    public String getIdentityNumber() {
+        return identityNumber;
+    }
+
+    public void setIdentityNumber(String identityNumber) {
+        this.identityNumber = identityNumber;
+    }
+
+    public String getCourseLevel() {
+        return courseLevel;
+    }
+
+    public void setCourseLevel(String courseLevel) {
+        this.courseLevel = courseLevel;
+    }
+
+    /*public Boolean getIsvalid() {
+        return isvalid;
+    }
+
+    public void setIsvalid(Boolean isvalid) {
+        this.isvalid = isvalid;
+    }*/
+
+    public Long getExamStudentId() {
+        return examStudentId;
+    }
+
+    public void setExamStudentId(Long examStudentId) {
+        this.examStudentId = examStudentId;
+    }
+
+    public Long getExamId() {
+        return examId;
+    }
+
+    public void setExamId(Long examId) {
+        this.examId = examId;
+    }
+
+    public String getExamName() {
+        return examName;
+    }
+
+    public void setExamName(String examName) {
+        this.examName = examName;
+    }
+
+    public Long getOrgId() {
+        return orgId;
+    }
+
+    public void setOrgId(Long orgId) {
+        this.orgId = orgId;
+    }
+
+    public String getOrgName() {
+        return orgName;
+    }
+
+    public void setOrgName(String orgName) {
+        this.orgName = orgName;
+    }
+
+    public Long getRootOrgId() {
+        return rootOrgId;
+    }
+
+    public void setRootOrgId(Long rootOrgId) {
+        this.rootOrgId = rootOrgId;
+    }
+
+    public Boolean getFaceEnable() {
+        return faceEnable;
+    }
+
+    public void setFaceEnable(Boolean faceEnable) {
+        this.faceEnable = faceEnable;
+    }
+
+    public Boolean getFaceCheck() {
+        return faceCheck;
+    }
+
+    public void setFaceCheck(Boolean faceCheck) {
+        this.faceCheck = faceCheck;
+    }
+
+    public Boolean getIsObjScoreView() {
+        return isObjScoreView;
+    }
+
+    public void setIsObjScoreView(Boolean isObjScoreView) {
+        this.isObjScoreView = isObjScoreView;
+    }
+    
+}

+ 127 - 1
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/ExamStudentServiceImpl.java

@@ -22,12 +22,24 @@ import cn.com.qmth.examcloud.core.oe.admin.service.ExamRecordService;
 import cn.com.qmth.examcloud.core.oe.admin.service.ExamStudentService;
 import cn.com.qmth.examcloud.core.oe.admin.service.GainBaseDataService;
 import cn.com.qmth.examcloud.core.oe.admin.service.LocalCacheService;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.OnHandExamInfo;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.*;
 import cn.com.qmth.examcloud.core.oe.admin.service.cache.ExamStudentCache;
 import cn.com.qmth.examcloud.core.oe.admin.service.others.ExamCacheTransferHelper;
+import cn.com.qmth.examcloud.examwork.api.ExamCloudService;
 import cn.com.qmth.examcloud.examwork.api.bean.ExamBean;
+import cn.com.qmth.examcloud.examwork.api.bean.ExamSpecialSettingsBean;
+import cn.com.qmth.examcloud.examwork.api.request.GetOngoingExamListReq;
+import cn.com.qmth.examcloud.examwork.api.response.GetOngoingExamListResp;
+import cn.com.qmth.examcloud.support.cache.CacheHelper;
 import cn.com.qmth.examcloud.support.cache.bean.ExamPropertyCacheBean;
 import cn.com.qmth.examcloud.support.cache.bean.OrgCacheBean;
+import cn.com.qmth.examcloud.support.cache.bean.StudentCacheBean;
+import cn.com.qmth.examcloud.support.examing.ExamBoss;
+import cn.com.qmth.examcloud.support.helper.FaceBiopsyHelper;
+import cn.com.qmth.examcloud.support.redis.RedisKeyHelper;
+import cn.com.qmth.examcloud.web.redis.RedisClient;
+
 import org.apache.commons.lang3.StringUtils;
 import org.hibernate.query.NativeQuery;
 import org.hibernate.transform.Transformers;
@@ -50,6 +62,8 @@ import java.math.BigDecimal;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.util.*;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 import static cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.ExamStudentMapper.statisticFinishedColumns;
 import static cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.ExamStudentMapper.statisticOrgColumns;
@@ -81,7 +95,11 @@ public class ExamStudentServiceImpl implements ExamStudentService {
     private LocalCacheService localCacheService;
     @Autowired
     private ExamStudentCache examStudentCache;
-
+    @Autowired
+    private ExamCloudService examCloudService;
+    @Autowired
+    private RedisClient redisClient;
+    
     @Override
     public void syncExamStudentAllData(List<ExamStudentInfo> examStudents) {
         Check.isEmpty(examStudents, "考生信息不能为空!");
@@ -658,4 +676,112 @@ public class ExamStudentServiceImpl implements ExamStudentService {
         return resultList;
     }
 
+    /**
+     * 根据学生id获取考试列表
+     *
+     * @param studentId 学生id
+     */
+    @Override
+    public List<OnHandExamInfo> queryOnlineExamList(Long studentId) {
+        StudentCacheBean studentBean = CacheHelper.getStudent(studentId);
+
+        //获取可以考的和即将考的考试Id
+        GetOngoingExamListReq getOngoingExamListReq = new GetOngoingExamListReq();
+        getOngoingExamListReq.setExamType(ExamType.ONLINE.name());
+        getOngoingExamListReq.setRootOrgId(studentBean.getRootOrgId());
+        getOngoingExamListReq.setOrgId(studentBean.getOrgId());
+        getOngoingExamListReq.setStudentId(studentId);
+        GetOngoingExamListResp getOngoingExamListResp = examCloudService.getOngoingExamList(getOngoingExamListReq);
+
+        //获取学生所在组织机构的所有考试列表集合(虽然名字起的特殊考试设置,事实上取的就是实际的可考的考试列表,可能是考试中心特殊设置的考试时间,也可能不是)
+        List<ExamSpecialSettingsBean> examSpecialSettingsBeanList = getOngoingExamListResp.getExamSpecialSettingsList();
+        if (examSpecialSettingsBeanList == null || examSpecialSettingsBeanList.size() == 0) {
+            return null;
+        }
+        List<Long> examIds = examSpecialSettingsBeanList.stream().map(ExamSpecialSettingsBean::getExamId).collect(Collectors.toList());
+
+        //只查没有禁用的考生
+        List<ExamStudentEntity> examStudents = examStudentRepo.findByStudentIdAndEnableAndExamIdIn(studentId, true, examIds);
+        List<OnHandExamInfo> examStudentDtoList = new ArrayList<OnHandExamInfo>();
+        for (ExamStudentEntity examStudent : examStudents) {
+            Stream<ExamSpecialSettingsBean> examSpecialSettingsBeanStream = examSpecialSettingsBeanList.stream().filter(examSpecialSettingsBean -> {
+                return examSpecialSettingsBean.getExamId().longValue() == examStudent.getExamId().longValue();
+            });
+            if (examSpecialSettingsBeanStream != null) {
+                ExamSpecialSettingsBean examSpecialSettingsBean = examSpecialSettingsBeanStream.findFirst().get();
+                examStudentDtoList.add(assemblingExamStudentDto(examStudent, examSpecialSettingsBean));
+            }
+        }
+        return examStudentDtoList;
+    }
+    
+    private OnHandExamInfo assemblingExamStudentDto(ExamStudentEntity examStudent, ExamSpecialSettingsBean examSpecialSettingsBean) {
+        OnHandExamInfo examStudentInfo = new OnHandExamInfo();
+        examStudentInfo.setExamStudentId(examStudent.getExamStudentId());
+        examStudentInfo.setStudentCode(examStudent.getStudentCode());
+        examStudentInfo.setStudentName(examStudent.getStudentName());
+        Long rootOrgId = examStudent.getRootOrgId();
+        examStudentInfo.setRootOrgId(rootOrgId);
+        examStudentInfo.setIdentityNumber(examStudent.getIdentityNumber());
+
+        CourseBean courseBean = ExamCacheTransferHelper.getCachedCourse(examStudent.getCourseId());
+        examStudentInfo.setCourseName(courseBean.getName());
+        examStudentInfo.setCourseCode(courseBean.getCode());
+        examStudentInfo.setCourseLevel(CourseLevel.getCourseLevel(courseBean.getLevel()).getTitle());
+        examStudentInfo.setCourseId(examStudent.getCourseId());
+        examStudentInfo.setSpecialtyName(examStudent.getSpecialtyName());
+        Long orgId = examStudent.getOrgId();
+        examStudentInfo.setOrgId(orgId);
+
+        OrgCacheBean orgBean = gainBaseDataService.getOrgBean(orgId);
+        Long studentId = examStudent.getStudentId();
+        ExamBean examBean = ExamCacheTransferHelper.getCachedExam(examStudent.getExamId(),
+                 studentId);
+
+        examStudentInfo.setOrgName(orgBean.getName());
+        Long examId = examBean.getId();
+        examStudentInfo.setExamId(examId);
+        examStudentInfo.setExamName(examBean.getName());
+        examStudentInfo.setStartTime(examSpecialSettingsBean.getBeginTime());//考试开始时间设置
+        examStudentInfo.setEndTime(examSpecialSettingsBean.getEndTime());//考试结束时间设置
+        examStudentInfo.setAllowExamCount(countExamTimes(examStudent, examBean));
+        examStudentInfo.setPaperMins(examBean.getDuration());
+        //是否启用人脸识别
+        examStudentInfo.setFaceEnable(FaceBiopsyHelper.isFaceEnable(rootOrgId, examId,  studentId));
+        //进入考试是否验证人脸识别(强制、非强制)
+        examStudentInfo.setFaceCheck(FaceBiopsyHelper.isFaceCheck(examId, studentId));
+        //是否显示客观分
+        String isObjScoreView = ExamCacheTransferHelper.getCachedExamProperty(examId,
+                studentId, ExamProperties.IS_OBJ_SCORE_VIEW.name()).getValue();
+        if (StringUtils.isBlank(isObjScoreView)) {
+            examStudentInfo.setIsObjScoreView(false);
+        } else {
+            examStudentInfo.setIsObjScoreView(Boolean.valueOf(isObjScoreView));
+        }
+        return examStudentInfo;
+    }
+    
+    private Integer countExamTimes(ExamStudentEntity examStudentInfo, ExamBean examBean) {
+        if (ExamType.OFFLINE.name().equals(examBean.getExamType())) {
+            return 1;
+        }
+        //考试批次中设置的考试次数
+        int canExamTimes = examBean.getExamTimes().intValue();
+        //可补考次数
+        int extraNum = (examStudentInfo.getExtraNum()==null?0:examStudentInfo.getExtraNum());
+        //考生已考次数
+        int usedNum = (examStudentInfo.getUsedNum()==null?0:examStudentInfo.getUsedNum());
+        //缓存中开考次数
+        int startCount=0;
+        //缓存中考试完结次数
+        int endCount=0;
+        String key = RedisKeyHelper.getBuilder().examBossKey(examBean.getId());
+        ExamBoss eb=redisClient.get(key, ExamBoss.class);
+        if(eb!=null) {
+            startCount=eb.getStartCount();
+            endCount=eb.getEndCount();
+        }
+        return canExamTimes+extraNum-(usedNum+startCount-endCount);
+    }
+    
 }