Pārlūkot izejas kodu

导出调卷规则信息

xiatian 1 gadu atpakaļ
vecāks
revīzija
0b9e0bfd6a

+ 95 - 0
src/main/java/cn/com/qmth/dp/examcloud/oe/entity/question/RandomPaper.java

@@ -0,0 +1,95 @@
+package cn.com.qmth.dp.examcloud.oe.entity.question;
+
+import java.util.List;
+
+import cn.com.qmth.dp.examcloud.oe.enums.question.PaperStructType;
+import cn.com.qmth.dp.examcloud.oe.enums.question.PaperType;
+
+public class RandomPaper extends MongoBaseEntity {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = -1357471464371313050L;
+
+	private Long rootOrgId;
+
+	private Long courseId;
+
+	private String name;
+
+	private PaperStructType paperStructType;
+
+	private String paperStructId;
+
+	private PaperType paperType;
+
+	private List<String> paperIds;
+
+	private Boolean enable;
+
+	public Long getRootOrgId() {
+		return rootOrgId;
+	}
+
+	public void setRootOrgId(Long rootOrgId) {
+		this.rootOrgId = rootOrgId;
+	}
+
+	public Long getCourseId() {
+		return courseId;
+	}
+
+	public void setCourseId(Long courseId) {
+		this.courseId = courseId;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public PaperStructType getPaperStructType() {
+		return paperStructType;
+	}
+
+	public void setPaperStructType(PaperStructType paperStructType) {
+		this.paperStructType = paperStructType;
+	}
+
+	public String getPaperStructId() {
+		return paperStructId;
+	}
+
+	public void setPaperStructId(String paperStructId) {
+		this.paperStructId = paperStructId;
+	}
+
+	public PaperType getPaperType() {
+		return paperType;
+	}
+
+	public void setPaperType(PaperType paperType) {
+		this.paperType = paperType;
+	}
+
+	public List<String> getPaperIds() {
+		return paperIds;
+	}
+
+	public void setPaperIds(List<String> paperIds) {
+		this.paperIds = paperIds;
+	}
+
+	public Boolean getEnable() {
+		return enable;
+	}
+
+	public void setEnable(Boolean enable) {
+		this.enable = enable;
+	}
+
+}

+ 92 - 0
src/main/java/cn/com/qmth/dp/examcloud/oe/modules/export_extract_config/ExportExtractConfigService.java

@@ -0,0 +1,92 @@
+package cn.com.qmth.dp.examcloud.oe.modules.export_extract_config;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.collections4.CollectionUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
+import org.springframework.stereotype.Service;
+
+import cn.com.qmth.dp.examcloud.oe.entity.question.ExamPaper;
+import cn.com.qmth.dp.examcloud.oe.entity.question.RandomPaper;
+import cn.com.qmth.dp.examcloud.oe.excel.ExportUtils;
+import cn.com.qmth.examcloud.api.commons.enums.CallType;
+import cn.com.qmth.examcloud.commons.exception.StatusException;
+
+/**
+ * 
+ * @author chenken
+ *
+ */
+@Service
+public class ExportExtractConfigService {
+	private static Long examId=28L;
+	
+	@Autowired
+	private MongoTemplate mongoTemplate;
+	
+	public void start() {
+		File file = new File("d:/ret.xlsx");
+		if (file.exists()) {
+			file.delete();
+		}
+		Query query = new Query();
+		query.addCriteria(Criteria.where("examId").is(examId));
+		List<ExtractConfig> ps = mongoTemplate.find(query, ExtractConfig.class, "extractConfig");
+		if(CollectionUtils.isEmpty(ps)) {
+			return;
+		}
+		List<ExtractConfigDto> ret=new ArrayList<>();
+		for(ExtractConfig ec:ps) {
+			if(CallType.RANDOM_PAPER.equals(ec.getCallType())) {
+				ExtractConfigDto dto=new ExtractConfigDto();
+				dto.setCourseName(ec.getCourse().getName());
+				dto.setCourseCode(ec.getCourse().getCode());
+				dto.setCallType(ec.getCallType().getName());
+				dto.setPaperName(getPaperName(ec.getRandomPaperId()));
+				ret.add(dto);
+			}else {
+				for(ExamPaper ep:ec.getExamPaperList()) {
+					ExtractConfigDto dto=new ExtractConfigDto();
+					dto.setCourseName(ec.getCourse().getName());
+					dto.setCourseCode(ec.getCourse().getCode());
+					dto.setCallType(ec.getCallType().getName());
+					dto.setPaperName(ep.getPaper().getName());
+					ret.add(dto);
+				}
+			}
+		}
+		FileOutputStream fos = null;
+		try {
+			file.createNewFile();
+			fos = new FileOutputStream(file);
+			ExportUtils.makeExcel(ExtractConfigDto.class, ret, fos);
+		} catch (Exception e) {
+			e.printStackTrace();
+		} finally {
+			if (fos != null) {
+				try {
+					fos.close();
+				} catch (IOException e) {
+					e.printStackTrace();
+				}
+			}
+		}
+	}
+	
+	private String getPaperName(String id) {
+		Query query = new Query();
+		query.addCriteria(Criteria.where("examId").is(examId));
+		RandomPaper p = mongoTemplate.findById(id, RandomPaper.class);
+		if(p==null) {
+			throw new StatusException("未找到千卷模版");
+		}
+		return p.getName();
+	}
+}

+ 262 - 0
src/main/java/cn/com/qmth/dp/examcloud/oe/modules/export_extract_config/ExtractConfig.java

@@ -0,0 +1,262 @@
+package cn.com.qmth.dp.examcloud.oe.modules.export_extract_config;
+
+import java.util.List;
+import java.util.Map;
+
+import cn.com.qmth.dp.examcloud.oe.entity.question.Course;
+import cn.com.qmth.dp.examcloud.oe.entity.question.ExamPaper;
+import cn.com.qmth.dp.examcloud.oe.entity.question.MongoBaseEntity;
+import cn.com.qmth.dp.examcloud.oe.enums.question.ExtractPolicy;
+import cn.com.qmth.examcloud.api.commons.enums.CallType;
+
+
+/**
+ * 调卷规则
+ *
+ * @author chenken
+ */
+public class ExtractConfig extends MongoBaseEntity {
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = -2723715817328472562L;
+	/**
+	 * 考试ID
+	 */
+	private Long examId;
+	/**
+	 * 考试类型 网络考试 传统考试
+	 */
+	private String examType;
+	/**
+	 * 考试名称
+	 */
+	private String examName;
+	/**
+	 * 课程名称
+	 */
+	private String courseName;
+	/**
+	 * 课程代码
+	 */
+	private String courseCode;
+
+	private Course course;
+	/**
+	 * 调卷类型 成套调用 重组调用
+	 */
+	private CallType callType;
+	/**
+	 * 是否生成 1:生成 0:没生成 生成预览卷
+	 */
+	private Short ifFinish;
+	/**
+	 * 已经生成的试卷ID Map 数据结构: { "A":"0001", "B":"0002" } A 类型下生成的paperId为 0001 B
+	 * 类型下生成的paperId为 0002
+	 */
+	private Map<String, String> finishedPaperIdMap;
+	/**
+	 * 抽取试卷对象集合
+	 */
+	private List<ExamPaper> examPaperList;
+	/**
+	 * 小题乱序 1:乱序 0:不乱序
+	 */
+	private Short scrambling_the_question_order;
+	/**
+	 * 选项乱序 1:乱序 0:不乱序
+	 */
+	private Short scrambling_the_option_order;
+
+	/**
+	 * 抽卷规则
+	 */
+	private ExtractPolicy policy;
+	/**
+	 * 类型参数
+	 */
+	private Map<String, Object> params;
+	/**
+	 * 机构ID
+	 */
+	private String orgId;
+
+	private String orgName;
+
+	// 随机抽题试卷模板
+	private String randomPaperId;
+
+	// 随机抽题音频播放次数
+	private Integer playTime;
+
+	public ExtractConfig() {
+
+	}
+
+	public ExtractConfig(String id) {
+		this.id = id;
+	}
+
+	public ExtractConfig(Long exam_id, String course_code) {
+		this.examId = exam_id;
+		this.courseCode = course_code;
+	}
+
+
+	public Long getExamId() {
+		return examId;
+	}
+
+	public void setExamId(Long examId) {
+		this.examId = examId;
+	}
+
+	public String getCourseCode() {
+		return courseCode;
+	}
+
+	public void setCourseCode(String courseCode) {
+		this.courseCode = courseCode;
+	}
+
+	public ExtractPolicy getPolicy() {
+		return policy;
+	}
+
+	public void setPolicy(ExtractPolicy policy) {
+		this.policy = policy;
+	}
+
+	public String getExamType() {
+		return examType;
+	}
+
+	public void setExamType(String examType) {
+		this.examType = examType;
+	}
+
+	public String getExamName() {
+		return examName;
+	}
+
+	public void setExamName(String examName) {
+		this.examName = examName;
+	}
+
+	public String getCourseName() {
+		return courseName;
+	}
+
+	public void setCourseName(String courseName) {
+		this.courseName = courseName;
+	}
+
+	public CallType getCallType() {
+		return callType;
+	}
+
+	public void setCallType(CallType callType) {
+		this.callType = callType;
+	}
+
+	public Short getIfFinish() {
+		return ifFinish;
+	}
+
+	public void setIfFinish(Short ifFinish) {
+		if (ifFinish == null) {
+			this.ifFinish = 0;
+		} else {
+			this.ifFinish = ifFinish;
+		}
+	}
+
+	public Map<String, Object> getParams() {
+		return params;
+	}
+
+	public void setParams(Map<String, Object> params) {
+		this.params = params;
+	}
+
+	public String getOrgId() {
+		return orgId;
+	}
+
+	public void setOrgId(String orgId) {
+		this.orgId = orgId;
+	}
+
+	public List<ExamPaper> getExamPaperList() {
+		return examPaperList;
+	}
+
+	public void setExamPaperList(List<ExamPaper> examPaperList) {
+		this.examPaperList = examPaperList;
+	}
+
+	public Short getScrambling_the_question_order() {
+		return scrambling_the_question_order;
+	}
+
+	public void setScrambling_the_question_order(Short scrambling_the_question_order) {
+		if (scrambling_the_question_order == null) {
+			this.scrambling_the_question_order = 0;
+		} else {
+			this.scrambling_the_question_order = scrambling_the_question_order;
+		}
+	}
+
+	public Short getScrambling_the_option_order() {
+		return scrambling_the_option_order;
+	}
+
+	public void setScrambling_the_option_order(Short scrambling_the_option_order) {
+		if (scrambling_the_option_order == null) {
+			this.scrambling_the_option_order = 0;
+		} else {
+			this.scrambling_the_option_order = scrambling_the_option_order;
+		}
+	}
+
+	public Map<String, String> getFinishedPaperIdMap() {
+		return finishedPaperIdMap;
+	}
+
+	public void setFinishedPaperIdMap(Map<String, String> finishedPaperIdMap) {
+		this.finishedPaperIdMap = finishedPaperIdMap;
+	}
+
+	public String getOrgName() {
+		return orgName;
+	}
+
+	public void setOrgName(String orgName) {
+		this.orgName = orgName;
+	}
+
+	public Course getCourse() {
+		return course;
+	}
+
+	public void setCourse(Course course) {
+		this.course = course;
+	}
+
+	public String getRandomPaperId() {
+		return randomPaperId;
+	}
+
+	public void setRandomPaperId(String randomPaperId) {
+		this.randomPaperId = randomPaperId;
+	}
+
+	public Integer getPlayTime() {
+		return playTime;
+	}
+
+	public void setPlayTime(Integer playTime) {
+		this.playTime = playTime;
+	}
+
+}

+ 40 - 0
src/main/java/cn/com/qmth/dp/examcloud/oe/modules/export_extract_config/ExtractConfigDto.java

@@ -0,0 +1,40 @@
+package cn.com.qmth.dp.examcloud.oe.modules.export_extract_config;
+
+import cn.com.qmth.dp.examcloud.oe.excel.ExcelProperty;
+
+public class ExtractConfigDto {
+	@ExcelProperty(name = "课程名称", width = 25, index = 1)
+	private String courseName;
+	@ExcelProperty(name = "课程代码", width = 25, index = 2)
+	private String courseCode;
+	@ExcelProperty(name = "抽题模式", width = 25, index = 3)
+	private String callType;
+	@ExcelProperty(name = "试卷名称", width = 25, index = 4)
+	private String paperName;
+	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 getPaperName() {
+		return paperName;
+	}
+	public void setPaperName(String paperName) {
+		this.paperName = paperName;
+	}
+	public String getCallType() {
+		return callType;
+	}
+	public void setCallType(String callType) {
+		this.callType = callType;
+	}
+	
+	
+}