xiatian 2 жил өмнө
parent
commit
dfe7259c2e

+ 18 - 0
examcloud-core-examwork-base/src/main/java/cn/com/qmth/examcloud/core/examwork/base/enums/CallType.java

@@ -0,0 +1,18 @@
+package cn.com.qmth.examcloud.core.examwork.base.enums;
+
+public enum CallType {
+	WHOLE_SET("成套调用"), 
+	RANDOM_PAPER("随机抽题"),
+	;
+
+	private String name;
+
+	CallType(String name) {
+		this.name = name;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+}

+ 18 - 3
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/entity/ExamEntity.java

@@ -16,15 +16,15 @@ import org.springframework.format.annotation.DateTimeFormat;
 
 import cn.com.qmth.examcloud.api.commons.enums.ExamSpecialSettingsType;
 import cn.com.qmth.examcloud.api.commons.enums.ExamType;
+import cn.com.qmth.examcloud.core.examwork.base.enums.CallType;
 import cn.com.qmth.examcloud.web.jpa.JpaEntity;
 
 /**
  * Created by songyue on 17/1/13.
  */
 @Entity
-@Table(name = "EC_E_EXAM", indexes = {
-		@Index(name = "IDX_E_E_001001", columnList = "rootOrgId,name", unique = true),
-		@Index(name = "IDX_E_E_001002", columnList = "rootOrgId,code", unique = true)})
+@Table(name = "EC_E_EXAM", indexes = { @Index(name = "IDX_E_E_001001", columnList = "rootOrgId,name", unique = true),
+		@Index(name = "IDX_E_E_001002", columnList = "rootOrgId,code", unique = true) })
 public class ExamEntity extends JpaEntity {
 
 	private static final long serialVersionUID = 4009839764353162256L;
@@ -111,6 +111,13 @@ public class ExamEntity extends JpaEntity {
 	@Enumerated(EnumType.STRING)
 	private ExamSpecialSettingsType specialSettingsType;
 
+	/**
+	 * 抽题模式
+	 */
+	@Column(nullable = false)
+	@Enumerated(EnumType.STRING)
+	private CallType callType;
+
 	public Long getId() {
 		return id;
 	}
@@ -231,4 +238,12 @@ public class ExamEntity extends JpaEntity {
 		this.specialSettingsType = specialSettingsType;
 	}
 
+	public CallType getCallType() {
+		return callType;
+	}
+
+	public void setCallType(CallType callType) {
+		this.callType = callType;
+	}
+
 }

+ 202 - 187
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/bean/ExamInfo.java

@@ -1,14 +1,16 @@
 package cn.com.qmth.examcloud.core.examwork.service.bean;
 
-import cn.com.qmth.examcloud.api.commons.enums.ExamSpecialSettingsType;
-import cn.com.qmth.examcloud.api.commons.enums.ExamType;
-import cn.com.qmth.examcloud.api.commons.exchange.JsonSerializable;
+import java.util.Date;
+import java.util.Map;
 
 import javax.persistence.EnumType;
 import javax.persistence.Enumerated;
 import javax.validation.constraints.NotNull;
-import java.util.Date;
-import java.util.Map;
+
+import cn.com.qmth.examcloud.api.commons.enums.ExamSpecialSettingsType;
+import cn.com.qmth.examcloud.api.commons.enums.ExamType;
+import cn.com.qmth.examcloud.api.commons.exchange.JsonSerializable;
+import cn.com.qmth.examcloud.core.examwork.base.enums.CallType;
 
 /**
  * 类注释
@@ -19,190 +21,203 @@ import java.util.Map;
  */
 public class ExamInfo implements JsonSerializable {
 
-    private static final long serialVersionUID = 4009839764353162256L;
-
-    /**
-     * 顶级机构Id
-     */
-    private Long rootOrgId;
-
-    /**
-     * 考试批次开始时间
-     */
-    private Date beginTime;
-
-    /**
-     * 考试批次结束时间
-     */
-    private Date endTime;
-
-    /**
-     * 考试名称
-     */
-    @NotNull
-    private String name;
-
-    /**
-     * 考试编码
-     */
-    private String code;
-
-    /**
-     * 考试类型
-     */
-    @Enumerated(EnumType.STRING)
-    private ExamType examType;
-
-    /**
-     * 考试时长
-     */
-    private Integer duration;
-
-    /**
-     * 是否可用
-     */
-    private Boolean enable;
-
-    /**
-     * 考试备注
-     */
-    private String remark;
-
-    /**
-     * 考试次数
-     */
-    private Long examTimes;
-
-    /**
-     * 是否禁止考试
-     */
-    private Boolean examLimit;
-
-    /**
-     * 开启特殊设置
-     */
-    private Boolean specialSettingsEnabled;
-
-    /**
-     * 特殊设置类型
-     */
-    private ExamSpecialSettingsType specialSettingsType;
-
-    /**
-     * 考试属性
-     */
-    private Map<String, String> properties;
-
-    public Long getRootOrgId() {
-        return rootOrgId;
-    }
-
-    public void setRootOrgId(Long rootOrgId) {
-        this.rootOrgId = rootOrgId;
-    }
-
-    public Date getBeginTime() {
-        return beginTime;
-    }
-
-    public void setBeginTime(Date beginTime) {
-        this.beginTime = beginTime;
-    }
-
-    public Date getEndTime() {
-        return endTime;
-    }
-
-    public void setEndTime(Date endTime) {
-        this.endTime = endTime;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public String getCode() {
-        return code;
-    }
-
-    public void setCode(String code) {
-        this.code = code;
-    }
-
-    public ExamType getExamType() {
-        return examType;
-    }
-
-    public void setExamType(ExamType examType) {
-        this.examType = examType;
-    }
-
-    public Integer getDuration() {
-        return duration;
-    }
-
-    public void setDuration(Integer duration) {
-        this.duration = duration;
-    }
-
-    public Boolean getEnable() {
-        return enable;
-    }
-
-    public void setEnable(Boolean enable) {
-        this.enable = enable;
-    }
-
-    public String getRemark() {
-        return remark;
-    }
-
-    public void setRemark(String remark) {
-        this.remark = remark;
-    }
-
-    public Long getExamTimes() {
-        return examTimes;
-    }
-
-    public void setExamTimes(Long examTimes) {
-        this.examTimes = examTimes;
-    }
-
-    public Boolean getExamLimit() {
-        return examLimit;
-    }
-
-    public void setExamLimit(Boolean examLimit) {
-        this.examLimit = examLimit;
-    }
-
-    public Map<String, String> getProperties() {
-        return properties;
-    }
-
-    public void setProperties(Map<String, String> properties) {
-        this.properties = properties;
-    }
-
-    public Boolean getSpecialSettingsEnabled() {
-        return specialSettingsEnabled;
-    }
+	private static final long serialVersionUID = 4009839764353162256L;
+
+	/**
+	 * 顶级机构Id
+	 */
+	private Long rootOrgId;
+
+	/**
+	 * 考试批次开始时间
+	 */
+	private Date beginTime;
+
+	/**
+	 * 考试批次结束时间
+	 */
+	private Date endTime;
+
+	/**
+	 * 考试名称
+	 */
+	@NotNull
+	private String name;
+
+	/**
+	 * 考试编码
+	 */
+	private String code;
+
+	/**
+	 * 考试类型
+	 */
+	@Enumerated(EnumType.STRING)
+	private ExamType examType;
+
+	/**
+	 * 考试时长
+	 */
+	private Integer duration;
+
+	/**
+	 * 是否可用
+	 */
+	private Boolean enable;
+
+	/**
+	 * 考试备注
+	 */
+	private String remark;
+
+	/**
+	 * 考试次数
+	 */
+	private Long examTimes;
+
+	/**
+	 * 是否禁止考试
+	 */
+	private Boolean examLimit;
+
+	/**
+	 * 开启特殊设置
+	 */
+	private Boolean specialSettingsEnabled;
+
+	/**
+	 * 特殊设置类型
+	 */
+	private ExamSpecialSettingsType specialSettingsType;
+
+	/**
+	 * 考试属性
+	 */
+	private Map<String, String> properties;
+
+	/**
+	 * 抽题模式
+	 */
+	private CallType callType;
+
+	public Long getRootOrgId() {
+		return rootOrgId;
+	}
+
+	public void setRootOrgId(Long rootOrgId) {
+		this.rootOrgId = rootOrgId;
+	}
+
+	public Date getBeginTime() {
+		return beginTime;
+	}
+
+	public void setBeginTime(Date beginTime) {
+		this.beginTime = beginTime;
+	}
+
+	public Date getEndTime() {
+		return endTime;
+	}
+
+	public void setEndTime(Date endTime) {
+		this.endTime = endTime;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public String getCode() {
+		return code;
+	}
+
+	public void setCode(String code) {
+		this.code = code;
+	}
+
+	public ExamType getExamType() {
+		return examType;
+	}
+
+	public void setExamType(ExamType examType) {
+		this.examType = examType;
+	}
+
+	public Integer getDuration() {
+		return duration;
+	}
+
+	public void setDuration(Integer duration) {
+		this.duration = duration;
+	}
+
+	public Boolean getEnable() {
+		return enable;
+	}
+
+	public void setEnable(Boolean enable) {
+		this.enable = enable;
+	}
+
+	public String getRemark() {
+		return remark;
+	}
+
+	public void setRemark(String remark) {
+		this.remark = remark;
+	}
+
+	public Long getExamTimes() {
+		return examTimes;
+	}
+
+	public void setExamTimes(Long examTimes) {
+		this.examTimes = examTimes;
+	}
+
+	public Boolean getExamLimit() {
+		return examLimit;
+	}
+
+	public void setExamLimit(Boolean examLimit) {
+		this.examLimit = examLimit;
+	}
+
+	public Map<String, String> getProperties() {
+		return properties;
+	}
+
+	public void setProperties(Map<String, String> properties) {
+		this.properties = properties;
+	}
+
+	public Boolean getSpecialSettingsEnabled() {
+		return specialSettingsEnabled;
+	}
+
+	public void setSpecialSettingsEnabled(Boolean specialSettingsEnabled) {
+		this.specialSettingsEnabled = specialSettingsEnabled;
+	}
+
+	public ExamSpecialSettingsType getSpecialSettingsType() {
+		return specialSettingsType;
+	}
 
-    public void setSpecialSettingsEnabled(Boolean specialSettingsEnabled) {
-        this.specialSettingsEnabled = specialSettingsEnabled;
-    }
+	public void setSpecialSettingsType(ExamSpecialSettingsType specialSettingsType) {
+		this.specialSettingsType = specialSettingsType;
+	}
 
-    public ExamSpecialSettingsType getSpecialSettingsType() {
-        return specialSettingsType;
-    }
+	public CallType getCallType() {
+		return callType;
+	}
 
-    public void setSpecialSettingsType(ExamSpecialSettingsType specialSettingsType) {
-        this.specialSettingsType = specialSettingsType;
-    }
+	public void setCallType(CallType callType) {
+		this.callType = callType;
+	}
 
 }

+ 53 - 26
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/impl/ExamServiceImpl.java

@@ -1,5 +1,39 @@
 package cn.com.qmth.examcloud.core.examwork.service.impl;
 
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Optional;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import javax.persistence.criteria.Predicate;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.jsoup.nodes.Element;
+import org.jsoup.select.Elements;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
 import cn.com.qmth.examcloud.api.commons.enums.CURD;
 import cn.com.qmth.examcloud.api.commons.enums.ExamType;
 import cn.com.qmth.examcloud.api.commons.exchange.PageInfo;
@@ -17,9 +51,18 @@ import cn.com.qmth.examcloud.core.basic.api.OrgCloudService;
 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.base.enums.CallType;
 import cn.com.qmth.examcloud.core.examwork.base.enums.ExamProperty;
-import cn.com.qmth.examcloud.core.examwork.dao.*;
-import cn.com.qmth.examcloud.core.examwork.dao.entity.*;
+import cn.com.qmth.examcloud.core.examwork.dao.ExamIpLimitRepo;
+import cn.com.qmth.examcloud.core.examwork.dao.ExamOrgPropertyRepo;
+import cn.com.qmth.examcloud.core.examwork.dao.ExamPropertyRepo;
+import cn.com.qmth.examcloud.core.examwork.dao.ExamRepo;
+import cn.com.qmth.examcloud.core.examwork.dao.ExamSpecialSettingsRepo;
+import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamEntity;
+import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamIpLimitEntity;
+import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamOrgPropertyEntity;
+import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamPropertyEntity;
+import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamSpecialSettingsEntity;
 import cn.com.qmth.examcloud.core.examwork.dao.enums.IpLimitType;
 import cn.com.qmth.examcloud.core.examwork.service.ExamService;
 import cn.com.qmth.examcloud.core.examwork.service.ExamStudentService;
@@ -38,30 +81,6 @@ import cn.com.qmth.examcloud.task.api.request.SyncExamReq;
 import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 import cn.com.qmth.examcloud.web.helpers.SequenceLockHelper;
 import cn.com.qmth.examcloud.web.redis.RedisClient;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.jsoup.Jsoup;
-import org.jsoup.nodes.Document;
-import org.jsoup.nodes.Element;
-import org.jsoup.select.Elements;
-import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.data.domain.Sort;
-import org.springframework.data.jpa.domain.Specification;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import javax.persistence.criteria.Predicate;
-import java.io.File;
-import java.util.*;
-import java.util.Map.Entry;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
 
 /**
  * 类注释
@@ -127,10 +146,17 @@ public class ExamServiceImpl implements ExamService {
         String code = examInfo.getCode();
         String name = examInfo.getName();
         ExamType examType = examInfo.getExamType();
+        CallType callType=examInfo.getCallType(); 
 
         if (null == examType) {
             throw new StatusException("001005", "考试类型不能为空");
         }
+        if (!ExamType.ONLINE.equals(examType)&&!ExamType.PRACTICE.equals(examType)) {
+        	callType=CallType.WHOLE_SET;
+        }
+        if(callType==null) {
+        	throw new StatusException("调卷模式不能为空");
+        }
 
         if (StringUtils.isBlank(code)) {
             throw new StatusException("001005", "考试编码不能为空");
@@ -206,6 +232,7 @@ public class ExamServiceImpl implements ExamService {
             exam.setCode(code);
             exam.setRootOrgId(rootOrgId);
             exam.setExamType(examType);
+            exam.setCallType(callType);
             exam.setEnable(true);
             exam.setExamLimit(false);
             exam.setSpecialSettingsEnabled(false);