xiatian vor 2 Jahren
Ursprung
Commit
989be1a048
14 geänderte Dateien mit 1189 neuen und 131 gelöschten Zeilen
  1. 52 23
      examcloud-core-questions-api-provider/src/main/java/cn/com/qmth/examcloud/core/questions/api/controller/ImportPaperController.java
  2. 1 1
      examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/CoursePropertyRepo.java
  3. 2 2
      examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/PropertyRepo.java
  4. 62 52
      examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/entity/CourseProperty.java
  5. 72 53
      examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/entity/Property.java
  6. 43 0
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/yunkai/KdDetail.java
  7. 49 0
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/yunkai/KdPaper.java
  8. 26 0
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/yunkai/KdQuesOption.java
  9. 126 0
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/yunkai/KdQuestion.java
  10. 50 0
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/yunkai/PropertyDto.java
  11. 89 0
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/yunkai/YunkaiDifficulty.java
  12. 64 0
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/yunkai/YunkaiImportPaperParam.java
  13. 109 0
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/yunkai/YunkaiQuesStructType.java
  14. 444 0
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/yunkai/YunkaiService.java

+ 52 - 23
examcloud-core-questions-api-provider/src/main/java/cn/com/qmth/examcloud/core/questions/api/controller/ImportPaperController.java

@@ -36,6 +36,8 @@ import cn.com.qmth.examcloud.core.questions.service.ImportDdCollegePaperService;
 import cn.com.qmth.examcloud.core.questions.service.ImportPaperService;
 import cn.com.qmth.examcloud.core.questions.service.impl.CourseService;
 import cn.com.qmth.examcloud.core.questions.service.temp.CqdxService;
+import cn.com.qmth.examcloud.core.questions.service.yunkai.YunkaiImportPaperParam;
+import cn.com.qmth.examcloud.core.questions.service.yunkai.YunkaiService;
 import cn.com.qmth.examcloud.reports.commons.bean.AdminOperateReport;
 import cn.com.qmth.examcloud.reports.commons.util.ReportsUtil;
 import cn.com.qmth.examcloud.web.security.DataRule;
@@ -62,11 +64,12 @@ public class ImportPaperController extends ControllerSupport {
 	private ImportDdCollegePaperService importDdCollegePaperService;
 	@Autowired
 	private CqdxService cqdxService;
-	
-    @Autowired
-    private CourseService courseService;
-    @Autowired
-    private PaperRepo paperRepo;
+	@Autowired
+	private YunkaiService yunkaiService;
+	@Autowired
+	private CourseService courseService;
+	@Autowired
+	private PaperRepo paperRepo;
 
 	/**
 	 * 导入试卷
@@ -74,7 +77,7 @@ public class ImportPaperController extends ControllerSupport {
 	 * @param file
 	 * @return
 	 */
-    @DataRule(type = DataRuleType.COURSE)
+	@DataRule(type = DataRuleType.COURSE)
 	@ApiOperation(value = "导入试卷", notes = "导入试卷")
 	@PostMapping(value = "/importPaper")
 	public ResponseEntity<Object> importPaper(@ModelAttribute Paper paper,
@@ -85,17 +88,18 @@ public class ImportPaperController extends ControllerSupport {
 		File tempFile = null;
 		try {
 			tempFile = importPaperService.getUploadFile(file);
-			Paper newPaper = importPaperService.importPaper(paper, user, tempFile,ud);
-			StringBuilder sb=new StringBuilder();
-			sb.append("课程:"+paper.getCourse().getName()+"("+paper.getCourse().getCode()+")");
-			sb.append(" 试卷名称:"+paper.getName());
-	        ReportsUtil.report(new AdminOperateReport(user.getRootOrgId(), user.getUserId(), AdminOperateType.TYPE29.getDesc(),sb.toString()));
+			Paper newPaper = importPaperService.importPaper(paper, user, tempFile, ud);
+			StringBuilder sb = new StringBuilder();
+			sb.append("课程:" + paper.getCourse().getName() + "(" + paper.getCourse().getCode() + ")");
+			sb.append(" 试卷名称:" + paper.getName());
+			ReportsUtil.report(new AdminOperateReport(user.getRootOrgId(), user.getUserId(),
+					AdminOperateType.TYPE29.getDesc(), sb.toString()));
 			return new ResponseEntity<>(newPaper, HttpStatus.OK);
 		} catch (StatusException e) {
 			throw e;
 		} catch (Exception e) {
 			LOG.error(e.getMessage(), e);
-			throw new StatusException("500", e.getMessage(),e);
+			throw new StatusException("500", e.getMessage(), e);
 		}
 	}
 
@@ -131,15 +135,16 @@ public class ImportPaperController extends ControllerSupport {
 		Map<String, Object> map = new HashMap<>();
 		try {
 			clonePaperService.clonePaper(paperId, paperName, courseNo, user);
-	        Paper paper = Model.of(paperRepo.findById(paperId));
+			Paper paper = Model.of(paperRepo.findById(paperId));
 
-	        Course course = courseService.getCourse(user.getRootOrgId(), courseNo);
-			StringBuilder sb=new StringBuilder();
-			sb.append("来源课程:"+paper.getCourse().getName()+"("+paper.getCourse().getCode()+")");
-			sb.append(" 来源试卷名称:"+paper.getName());
-			sb.append(" 复制到课程:"+course.getName()+"("+course.getCode()+")");
-			sb.append(" 复制到试卷名称:"+paperName);
-			ReportsUtil.report(new AdminOperateReport(user.getRootOrgId(), user.getUserId(), AdminOperateType.TYPE30.getDesc(),sb.toString()));
+			Course course = courseService.getCourse(user.getRootOrgId(), courseNo);
+			StringBuilder sb = new StringBuilder();
+			sb.append("来源课程:" + paper.getCourse().getName() + "(" + paper.getCourse().getCode() + ")");
+			sb.append(" 来源试卷名称:" + paper.getName());
+			sb.append(" 复制到课程:" + course.getName() + "(" + course.getCode() + ")");
+			sb.append(" 复制到试卷名称:" + paperName);
+			ReportsUtil.report(new AdminOperateReport(user.getRootOrgId(), user.getUserId(),
+					AdminOperateType.TYPE30.getDesc(), sb.toString()));
 			map.put("msg", "success");
 			return new ResponseEntity<>(map, HttpStatus.OK);
 		} catch (PaperException e) {
@@ -151,9 +156,10 @@ public class ImportPaperController extends ControllerSupport {
 	@ApiOperation(value = "导入地大试卷", notes = "导入地大试卷")
 	@PostMapping(value = "/importDdCollegePaper")
 	public ResponseEntity<Object> importDdCollegePaper(
-			@RequestPart @NotNull(message = "上传文件不能为空!") MultipartFile dataFile, @RequestParam Long rootOrgId,@RequestParam String courseCode,@RequestParam(required = false) String suff) {
+			@RequestPart @NotNull(message = "上传文件不能为空!") MultipartFile dataFile, @RequestParam Long rootOrgId,
+			@RequestParam String courseCode, @RequestParam(required = false) String suff) {
 		User user = getAccessUser();
-		importDdCollegePaperService.importDdCollegePaper(dataFile, user, rootOrgId,courseCode,suff);
+		importDdCollegePaperService.importDdCollegePaper(dataFile, user, rootOrgId, courseCode, suff);
 		return new ResponseEntity<>(HttpStatus.OK);
 	}
 
@@ -163,8 +169,31 @@ public class ImportPaperController extends ControllerSupport {
 			@RequestPart @NotNull(message = "上传文件不能为空!") MultipartFile dataFile, @RequestParam Long rootOrgId,
 			@RequestParam String paperNameSuffix, @RequestParam String impType) {
 		User user = getAccessUser();
-		cqdxService.bulidPaper(dataFile, user, rootOrgId, paperNameSuffix,impType);
+		cqdxService.bulidPaper(dataFile, user, rootOrgId, paperNameSuffix, impType);
 		return new ResponseEntity<>(HttpStatus.OK);
 	}
+	
+	@ApiOperation(value = "云开导入前清理课程属性、试题属性")
+	@PostMapping(value = "/importYunkaiProp/clear")
+	public void importYunkaiPropClear(Long rootOrgId,@RequestParam String batch) {
+		yunkaiService.propClear(rootOrgId, batch);
+	}
 
+	@ApiOperation(value = "云开导入课程属性、试题属性")
+	@PostMapping(value = "/importYunkaiProp")
+	public void importYunkaiProp(@RequestPart @NotNull(message = "上传文件不能为空!") MultipartFile dataFile,
+			@RequestParam Long rootOrgId, @RequestParam String courseCode, @RequestParam String batch) {
+		User user = getAccessUser();
+		yunkaiService.saveProp(user, dataFile, rootOrgId, courseCode, batch);
+	}
+	
+	@ApiOperation(value = "云开导入试卷")
+	@PostMapping(value = "/importYunkaiPaper")
+	public void importYunkaiPaper(@RequestPart @NotNull(message = "上传文件不能为空!") MultipartFile dataFile,
+			@RequestParam Long rootOrgId,@RequestParam String courseCode) {
+		User user = getAccessUser();
+		YunkaiImportPaperParam p=new YunkaiImportPaperParam(user, dataFile, rootOrgId, courseCode);
+		
+		yunkaiService.importYunkaiPaper(p);
+	}
 }

+ 1 - 1
examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/CoursePropertyRepo.java

@@ -37,6 +37,6 @@ public interface CoursePropertyRepo extends MongoRepository<CourseProperty, Stri
 
 	List<CourseProperty> findByOrgId(Long orgId);
 
-	void deleteByOrgId(Long toRootOrgId);
+	void deleteByOrgIdAndBatch(Long rootOrgId, String batch);
 
 }

+ 2 - 2
examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/PropertyRepo.java

@@ -24,8 +24,8 @@ public interface PropertyRepo extends MongoRepository<Property, String>, QueryBy
 
 	List<Property> findByCoursePropertyIdOrderByNumber(String id);
 
-	void deleteByOrgId(Long toRootOrgId);
-
 	List<Property> findByOrgId(Long fromRootOrgId);
 
+	void deleteByOrgIdAndBatch(Long rootOrgId, String batch);
+
 }

+ 62 - 52
examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/entity/CourseProperty.java

@@ -11,78 +11,88 @@ import java.util.Date;
  * @date 2017.11.2
  */
 public class CourseProperty extends IdBase {
-    @NotNull
-    private Long orgId;
+	@NotNull
+	private Long orgId;
 
-    @NotNull
-    private Long courseId;
+	@NotNull
+	private Long courseId;
 
-    private String courseCode;
+	private String courseCode;
 
-    private String courseName;
+	private String courseName;
 
-    @NotNull
-    private String name;
+	@NotNull
+	private String name;
 
-    private Boolean enable;
+	private Boolean enable;
 
-    private Date updateTime;//更新时间
+	private Date updateTime;// 更新时间
 
+	// 数据录入批次,清理用
+	private String batch;
 
-    public Long getOrgId() {
-        return orgId;
-    }
+	public Long getOrgId() {
+		return orgId;
+	}
 
-    public void setOrgId(Long orgId) {
-        this.orgId = orgId;
-    }
+	public void setOrgId(Long orgId) {
+		this.orgId = orgId;
+	}
 
-    public Long getCourseId() {
-        return courseId;
-    }
+	public Long getCourseId() {
+		return courseId;
+	}
 
-    public void setCourseId(Long courseId) {
-        this.courseId = courseId;
-    }
+	public void setCourseId(Long courseId) {
+		this.courseId = courseId;
+	}
 
-    public String getCourseCode() {
-        return courseCode;
-    }
+	public String getCourseCode() {
+		return courseCode;
+	}
 
-    public void setCourseCode(String courseCode) {
-        this.courseCode = courseCode;
-    }
+	public void setCourseCode(String courseCode) {
+		this.courseCode = courseCode;
+	}
 
-    public String getCourseName() {
-        return courseName;
-    }
+	public String getCourseName() {
+		return courseName;
+	}
 
-    public void setCourseName(String courseName) {
-        this.courseName = courseName;
-    }
+	public void setCourseName(String courseName) {
+		this.courseName = courseName;
+	}
 
-    public String getName() {
-        return name;
-    }
+	public String getName() {
+		return name;
+	}
 
-    public void setName(String name) {
-        this.name = name;
-    }
+	public void setName(String name) {
+		this.name = name;
+	}
 
-    public Boolean getEnable() {
-        return enable;
-    }
+	public Boolean getEnable() {
+		return enable;
+	}
 
-    public void setEnable(Boolean enable) {
-        this.enable = enable;
-    }
+	public void setEnable(Boolean enable) {
+		this.enable = enable;
+	}
 
-    public Date getUpdateTime() {
-        return updateTime;
-    }
+	public Date getUpdateTime() {
+		return updateTime;
+	}
 
-    public void setUpdateTime(Date updateTime) {
-        this.updateTime = updateTime;
-    }
+	public void setUpdateTime(Date updateTime) {
+		this.updateTime = updateTime;
+	}
+
+	public String getBatch() {
+		return batch;
+	}
+
+	public void setBatch(String batch) {
+		this.batch = batch;
+	}
 
 }

+ 72 - 53
examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/entity/Property.java

@@ -10,75 +10,80 @@ import javax.validation.constraints.NotNull;
  * @date 2017.11.6
  */
 public class Property extends IdBase {
-    public static final String ROOT_PARENT_ID = "0";
+	public static final String ROOT_PARENT_ID = "0";
 
-    @NotNull
-    private Long orgId;
+	@NotNull
+	private Long orgId;
 
-    @NotNull
-    private String coursePropertyId;
+	@NotNull
+	private String coursePropertyId;
 
-    @NotNull
-    private String parentId;
+	@NotNull
+	private String parentId;
 
-    @NotNull
-    private String name;
-    
-    @NotNull
-    private String code;
+	@NotNull
+	private String name;
 
-    @NotNull
-    private Integer number;//序号
+	@NotNull
+	private String code;
 
-    private String remark;
+	@NotNull
+	private Integer number;// 序号
 
-    public Long getOrgId() {
-        return orgId;
-    }
+	private String remark;
 
-    public void setOrgId(Long orgId) {
-        this.orgId = orgId;
-    }
+	// 数据来源id,导入用
+	private String fromId;
+	// 数据录入批次,清理用
+	private String batch;
 
-    public String getCoursePropertyId() {
-        return coursePropertyId;
-    }
+	public Long getOrgId() {
+		return orgId;
+	}
 
-    public void setCoursePropertyId(String coursePropertyId) {
-        this.coursePropertyId = coursePropertyId;
-    }
+	public void setOrgId(Long orgId) {
+		this.orgId = orgId;
+	}
 
-    public String getParentId() {
-        return parentId;
-    }
+	public String getCoursePropertyId() {
+		return coursePropertyId;
+	}
 
-    public void setParentId(String parentId) {
-        this.parentId = parentId;
-    }
+	public void setCoursePropertyId(String coursePropertyId) {
+		this.coursePropertyId = coursePropertyId;
+	}
 
-    public String getName() {
-        return name;
-    }
+	public String getParentId() {
+		return parentId;
+	}
 
-    public void setName(String name) {
-        this.name = name;
-    }
+	public void setParentId(String parentId) {
+		this.parentId = parentId;
+	}
 
-    public Integer getNumber() {
-        return number;
-    }
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public Integer getNumber() {
+		return number;
+	}
 
-    public void setNumber(Integer number) {
-        this.number = number;
-    }
+	public void setNumber(Integer number) {
+		this.number = number;
+	}
 
-    public String getRemark() {
-        return remark;
-    }
+	public String getRemark() {
+		return remark;
+	}
 
-    public void setRemark(String remark) {
-        this.remark = remark;
-    }
+	public void setRemark(String remark) {
+		this.remark = remark;
+	}
 
 	public String getCode() {
 		return code;
@@ -87,7 +92,21 @@ public class Property extends IdBase {
 	public void setCode(String code) {
 		this.code = code;
 	}
-    
-    
+
+	public String getFromId() {
+		return fromId;
+	}
+
+	public void setFromId(String fromId) {
+		this.fromId = fromId;
+	}
+
+	public String getBatch() {
+		return batch;
+	}
+
+	public void setBatch(String batch) {
+		this.batch = batch;
+	}
 
 }

+ 43 - 0
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/yunkai/KdDetail.java

@@ -0,0 +1,43 @@
+package cn.com.qmth.examcloud.core.questions.service.yunkai;
+
+import java.util.List;
+
+public class KdDetail {
+	private Integer number;
+	private String name;
+	private Integer questionCount;
+	private Double totalScore;
+	private List<KdQuestion> questions;
+	public Integer getNumber() {
+		return number;
+	}
+	public void setNumber(Integer number) {
+		this.number = number;
+	}
+	public String getName() {
+		return name;
+	}
+	public void setName(String name) {
+		this.name = name;
+	}
+	public Integer getQuestionCount() {
+		return questionCount;
+	}
+	public void setQuestionCount(Integer questionCount) {
+		this.questionCount = questionCount;
+	}
+	public Double getTotalScore() {
+		return totalScore;
+	}
+	public void setTotalScore(Double totalScore) {
+		this.totalScore = totalScore;
+	}
+	public List<KdQuestion> getQuestions() {
+		return questions;
+	}
+	public void setQuestions(List<KdQuestion> questions) {
+		this.questions = questions;
+	}
+	
+	
+}

+ 49 - 0
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/yunkai/KdPaper.java

@@ -0,0 +1,49 @@
+package cn.com.qmth.examcloud.core.questions.service.yunkai;
+
+import java.util.List;
+
+public class KdPaper {
+	private String courseName;
+	private String courseCode;
+	private String name;
+	private Double totalScore;
+	private Integer detailCount;
+	private List<KdDetail> details;
+	public String getCourseCode() {
+		return courseCode;
+	}
+	public void setCourseCode(String courseCode) {
+		this.courseCode = courseCode;
+	}
+	public String getName() {
+		return name;
+	}
+	public void setName(String name) {
+		this.name = name;
+	}
+	public Double getTotalScore() {
+		return totalScore;
+	}
+	public void setTotalScore(Double totalScore) {
+		this.totalScore = totalScore;
+	}
+	public Integer getDetailCount() {
+		return detailCount;
+	}
+	public void setDetailCount(Integer detailCount) {
+		this.detailCount = detailCount;
+	}
+	public List<KdDetail> getDetails() {
+		return details;
+	}
+	public void setDetails(List<KdDetail> details) {
+		this.details = details;
+	}
+	public String getCourseName() {
+		return courseName;
+	}
+	public void setCourseName(String courseName) {
+		this.courseName = courseName;
+	}
+	
+}

+ 26 - 0
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/yunkai/KdQuesOption.java

@@ -0,0 +1,26 @@
+package cn.com.qmth.examcloud.core.questions.service.yunkai;
+
+public class KdQuesOption {
+	private Boolean select;
+	private Integer number;
+	private String body;
+	public Integer getNumber() {
+		return number;
+	}
+	public void setNumber(Integer number) {
+		this.number = number;
+	}
+	public String getBody() {
+		return body;
+	}
+	public void setBody(String body) {
+		this.body = body;
+	}
+	public Boolean getSelect() {
+		return select;
+	}
+	public void setSelect(Boolean select) {
+		this.select = select;
+	}
+	
+}

+ 126 - 0
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/yunkai/KdQuestion.java

@@ -0,0 +1,126 @@
+package cn.com.qmth.examcloud.core.questions.service.yunkai;
+
+import java.util.List;
+
+public class KdQuestion {
+	private Long id;
+	private Integer number;
+	private YunkaiQuesStructType qst;
+	private Integer structType;
+	private Boolean objective;
+	private YunkaiDifficulty difficulty;
+	private String body;
+	private String answer;
+	private String qtype;
+	private Boolean haveAudio;
+	private List<KdQuesOption> options;
+	private List<Long> propIds;
+	private Boolean valid;
+
+	public Integer getNumber() {
+		return number;
+	}
+
+	public void setNumber(Integer number) {
+		this.number = number;
+	}
+
+	public Integer getStructType() {
+		return structType;
+	}
+
+	public void setStructType(Integer structType) {
+		this.structType = structType;
+	}
+
+	public Boolean getObjective() {
+		return objective;
+	}
+
+	public void setObjective(Boolean objective) {
+		this.objective = objective;
+	}
+
+	public String getBody() {
+		return body;
+	}
+
+	public void setBody(String body) {
+		this.body = body;
+	}
+
+	public String getAnswer() {
+		return answer;
+	}
+
+	public void setAnswer(String answer) {
+		this.answer = answer;
+	}
+
+	public List<KdQuesOption> getOptions() {
+		return options;
+	}
+
+	public void setOptions(List<KdQuesOption> options) {
+		this.options = options;
+	}
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public String getQtype() {
+		return qtype;
+	}
+
+	public void setQtype(String qtype) {
+		this.qtype = qtype;
+	}
+
+	public Boolean getHaveAudio() {
+		return haveAudio;
+	}
+
+	public void setHaveAudio(Boolean haveAudio) {
+		this.haveAudio = haveAudio;
+	}
+
+	public Boolean getValid() {
+		return valid;
+	}
+
+	public void setValid(Boolean valid) {
+		this.valid = valid;
+	}
+
+
+	public List<Long> getPropIds() {
+		return propIds;
+	}
+
+	public void setPropIds(List<Long> propIds) {
+		this.propIds = propIds;
+	}
+
+	public YunkaiQuesStructType getQst() {
+		return qst;
+	}
+
+	public void setQst(YunkaiQuesStructType qst) {
+		this.qst = qst;
+	}
+
+	public YunkaiDifficulty getDifficulty() {
+		return difficulty;
+	}
+
+	public void setDifficulty(YunkaiDifficulty difficulty) {
+		this.difficulty = difficulty;
+	}
+
+
+}

+ 50 - 0
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/yunkai/PropertyDto.java

@@ -0,0 +1,50 @@
+package cn.com.qmth.examcloud.core.questions.service.yunkai;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class PropertyDto {
+
+	private Long id;
+	private Long parentId;
+	private String name;
+
+	private List<PropertyDto> subPropertyDto = new ArrayList<>();
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public List<PropertyDto> getSubPropertyDto() {
+		return subPropertyDto;
+	}
+
+	public void setSubPropertyDto(List<PropertyDto> subPropertyDto) {
+		this.subPropertyDto = subPropertyDto;
+	}
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public void addSub(PropertyDto sub) {
+		subPropertyDto.add(sub);
+	}
+
+	public Long getParentId() {
+		return parentId;
+	}
+
+	public void setParentId(Long parentId) {
+		this.parentId = parentId;
+	}
+
+}

+ 89 - 0
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/yunkai/YunkaiDifficulty.java

@@ -0,0 +1,89 @@
+package cn.com.qmth.examcloud.core.questions.service.yunkai;
+
+public enum YunkaiDifficulty {
+	
+	RONGYI(1,"容易",1.0,"易"),
+	JIAORONGYI(2,"较容易",0.7,"易"),
+	ZHONGDENG(3,"中等",0.5,"中"),
+	JIAONAN(4,"较难",0.3,"难"),
+	KUNNAN(5,"困难",0.1,"难"),
+	;
+	
+	private Integer yunKaiType;
+	private String yunKaiDesc;
+	private Double type;
+	private String desc;
+	
+	private YunkaiDifficulty(Integer yunKaiType, String yunKaiDesc, Double type, String desc) {
+		this.yunKaiType = yunKaiType;
+		this.yunKaiDesc = yunKaiDesc;
+		this.type = type;
+		this.desc = desc;
+	}
+	
+	
+		
+	public Integer getYunKaiType() {
+		return yunKaiType;
+	}
+
+
+
+	public void setYunKaiType(Integer yunKaiType) {
+		this.yunKaiType = yunKaiType;
+	}
+
+
+
+	public String getYunKaiDesc() {
+		return yunKaiDesc;
+	}
+
+
+
+	public void setYunKaiDesc(String yunKaiDesc) {
+		this.yunKaiDesc = yunKaiDesc;
+	}
+
+
+
+	public Double getType() {
+		return type;
+	}
+
+
+
+	public void setType(Double type) {
+		this.type = type;
+	}
+
+
+
+	public String getDesc() {
+		return desc;
+	}
+
+
+
+	public void setDesc(String desc) {
+		this.desc = desc;
+	}
+
+
+
+
+
+	public static YunkaiDifficulty getByYunKaiType(Integer yunKaiType) {
+		if(yunKaiType==null) {
+			return null;
+		}
+		for(YunkaiDifficulty t:YunkaiDifficulty.values()) {
+			if(t.getYunKaiType().equals(yunKaiType)) {
+				return t;
+			}
+		}
+		return null;
+	}
+	
+}
+

+ 64 - 0
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/yunkai/YunkaiImportPaperParam.java

@@ -0,0 +1,64 @@
+package cn.com.qmth.examcloud.core.questions.service.yunkai;
+
+import org.springframework.web.multipart.MultipartFile;
+
+import cn.com.qmth.examcloud.api.commons.security.bean.User;
+import cn.com.qmth.examcloud.core.questions.dao.entity.Course;
+
+public class YunkaiImportPaperParam {
+	private User user;
+	private MultipartFile dataFile;
+	private Long rootOrgId;
+	private String courseCode;
+
+	private Course course;
+
+	public User getUser() {
+		return user;
+	}
+
+	public void setUser(User user) {
+		this.user = user;
+	}
+
+	public MultipartFile getDataFile() {
+		return dataFile;
+	}
+
+	public void setDataFile(MultipartFile dataFile) {
+		this.dataFile = dataFile;
+	}
+
+	public Long getRootOrgId() {
+		return rootOrgId;
+	}
+
+	public void setRootOrgId(Long rootOrgId) {
+		this.rootOrgId = rootOrgId;
+	}
+
+	public String getCourseCode() {
+		return courseCode;
+	}
+
+	public void setCourseCode(String courseCode) {
+		this.courseCode = courseCode;
+	}
+
+	public YunkaiImportPaperParam(User user, MultipartFile dataFile, Long rootOrgId, String courseCode) {
+		super();
+		this.user = user;
+		this.dataFile = dataFile;
+		this.rootOrgId = rootOrgId;
+		this.courseCode = courseCode;
+	}
+
+	public Course getCourse() {
+		return course;
+	}
+
+	public void setCourse(Course course) {
+		this.course = course;
+	}
+
+}

+ 109 - 0
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/yunkai/YunkaiQuesStructType.java

@@ -0,0 +1,109 @@
+package cn.com.qmth.examcloud.core.questions.service.yunkai;
+
+public enum YunkaiQuesStructType {
+	
+	DANXUAN(1,"单选题",1,"单选题",true),
+	DUOXUAN(2,"多选题",2,"多选题",true),
+	BUDINGXIANG(3,"不定项选择题",2,"多选题",true),
+	PANDUAN(4,"判断题",3,"判断题",true),
+	JIANDA(5,"简答题",5,"问答题",false),
+	MIGNCIJIESHI(6,"名词解释",5,"问答题",false),
+	LIJIETI(7,"理解题",5,"问答题",false),
+	ANLITI(8,"案例题",5,"问答题",false),
+	LUNSHUTI(9,"论述题",5,"问答题",false),
+	FENXITI(10,"分析题",5,"问答题",false),
+	ZONGHETI(11,"综合题",5,"问答题",false),
+	JISUANTI(12,"计算题",5,"问答题",false),
+	TIANKONGTI(13,"填空题",4,"填空题",false),
+	;
+	
+	private Integer yunKaiType;
+	private String yunKaiDesc;
+	private Integer type;
+	private String desc;
+	private boolean objective;//是否是客观题
+	
+	private YunkaiQuesStructType(Integer yunKaiType, String yunKaiDesc, Integer type, String desc, boolean objective) {
+		this.yunKaiType = yunKaiType;
+		this.yunKaiDesc = yunKaiDesc;
+		this.type = type;
+		this.desc = desc;
+		this.objective = objective;
+	}
+	
+	
+		
+	public Integer getYunKaiType() {
+		return yunKaiType;
+	}
+
+
+
+	public void setYunKaiType(Integer yunKaiType) {
+		this.yunKaiType = yunKaiType;
+	}
+
+
+
+	public String getYunKaiDesc() {
+		return yunKaiDesc;
+	}
+
+
+
+	public void setYunKaiDesc(String yunKaiDesc) {
+		this.yunKaiDesc = yunKaiDesc;
+	}
+
+
+
+	public Integer getType() {
+		return type;
+	}
+
+
+
+	public void setType(Integer type) {
+		this.type = type;
+	}
+
+
+
+	public String getDesc() {
+		return desc;
+	}
+
+
+
+	public void setDesc(String desc) {
+		this.desc = desc;
+	}
+
+
+
+	public boolean isObjective() {
+		return objective;
+	}
+
+
+
+	public void setObjective(boolean objective) {
+		this.objective = objective;
+	}
+
+
+
+	public static YunkaiQuesStructType getByYunKaiType(Integer yunKaiType) {
+		if(yunKaiType==null) {
+			throw new RuntimeException("题型异常");
+		}
+		for(YunkaiQuesStructType t:YunkaiQuesStructType.values()) {
+			if(t.getYunKaiType().equals(yunKaiType)) {
+				return t;
+			}
+		}
+		throw new RuntimeException("题型异常");
+	}
+	
+}
+

+ 444 - 0
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/yunkai/YunkaiService.java

@@ -0,0 +1,444 @@
+package cn.com.qmth.examcloud.core.questions.service.yunkai;
+
+import java.io.File;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+
+import cn.com.qmth.examcloud.api.commons.security.bean.User;
+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.request.GetCourseReq;
+import cn.com.qmth.examcloud.core.basic.api.response.GetCourseResp;
+import cn.com.qmth.examcloud.core.questions.base.converter.utils.FileUtil;
+import cn.com.qmth.examcloud.core.questions.base.enums.PaperStatus;
+import cn.com.qmth.examcloud.core.questions.base.enums.PaperType;
+import cn.com.qmth.examcloud.core.questions.base.question.enums.QuesStructType;
+import cn.com.qmth.examcloud.core.questions.dao.CoursePropertyRepo;
+import cn.com.qmth.examcloud.core.questions.dao.PaperDetailRepo;
+import cn.com.qmth.examcloud.core.questions.dao.PaperDetailUnitRepo;
+import cn.com.qmth.examcloud.core.questions.dao.PaperRepo;
+import cn.com.qmth.examcloud.core.questions.dao.PropertyRepo;
+import cn.com.qmth.examcloud.core.questions.dao.QuesRepo;
+import cn.com.qmth.examcloud.core.questions.dao.QuesTypeNameRepo;
+import cn.com.qmth.examcloud.core.questions.dao.entity.Course;
+import cn.com.qmth.examcloud.core.questions.dao.entity.CourseProperty;
+import cn.com.qmth.examcloud.core.questions.dao.entity.Paper;
+import cn.com.qmth.examcloud.core.questions.dao.entity.PaperDetail;
+import cn.com.qmth.examcloud.core.questions.dao.entity.PaperDetailUnit;
+import cn.com.qmth.examcloud.core.questions.dao.entity.Property;
+import cn.com.qmth.examcloud.core.questions.dao.entity.QuesOption;
+import cn.com.qmth.examcloud.core.questions.dao.entity.QuesTypeName;
+import cn.com.qmth.examcloud.core.questions.dao.entity.Question;
+import cn.com.qmth.examcloud.core.questions.service.PaperService;
+import cn.com.qmth.examcloud.web.config.SystemProperties;
+
+@Component
+public class YunkaiService {
+	@Autowired
+	private CoursePropertyRepo coursePropertyRepo;
+	@Autowired
+	private CourseCloudService courseCloudService;
+	@Autowired
+	private PaperRepo paperRepo;
+	@Autowired
+	private PaperService paperService;
+	@Autowired
+	private PaperDetailRepo paperDetailRepo;
+
+	@Autowired
+	private PaperDetailUnitRepo paperDetailUnitRepo;
+
+	@Autowired
+	private QuesRepo quesRepo;
+	@Autowired
+	private QuesTypeNameRepo quesTypeNameRepo;
+	@Autowired
+	private SystemProperties systemProperties;
+	
+	@Autowired
+	private PropertyRepo propertyRepo;
+
+	@Transactional
+	public void saveProp(User user, MultipartFile dataFile, Long rootOrgId, String courseCode, String batch) {
+		String tempDir = systemProperties.getTempDataDir();
+		String dir = tempDir + File.separator + UUID.randomUUID() + File.separator;
+		try {
+			File dfile = new File(dir);
+			dfile.mkdirs();
+			File zfile = new File(dir + dataFile.getOriginalFilename());
+			zfile.createNewFile();
+			dataFile.transferTo(zfile);
+			GetCourseReq req = new GetCourseReq();
+			req.setRootOrgId(rootOrgId);
+			req.setCode(courseCode);
+			GetCourseResp res = courseCloudService.getCourse(req);
+
+			CourseProperty cp = new CourseProperty();
+			cp.setCourseCode(courseCode);
+			cp.setCourseId(res.getCourseBean().getId());
+			cp.setCourseName(res.getCourseBean().getName());
+			cp.setEnable(true);
+			cp.setOrgId(rootOrgId);
+			cp.setName(res.getCourseBean().getName() + "课程属性" + batch);
+			cp.setBatch(batch);
+			coursePropertyRepo.save(cp);
+			String json = FileUtils.readFileToString(zfile, "utf-8");
+			List<PropertyDto> pds = JSON.parseArray(json, PropertyDto.class);
+			int num = 0;
+			for (PropertyDto pd : pds) {
+				num++;
+				Property p = new Property();
+				p.setCode(pd.getName());
+				p.setCoursePropertyId(cp.getId());
+				p.setName(pd.getName());
+				p.setNumber(num);
+				p.setOrgId(rootOrgId);
+				p.setParentId("0");
+				p.setFromId(pd.getId().toString());
+				propertyRepo.save(p);
+				if (CollectionUtils.isNotEmpty(pd.getSubPropertyDto())) {
+					int subnum = 0;
+					List<Property> ps = new ArrayList<>();
+					for (PropertyDto subpd : pd.getSubPropertyDto()) {
+						subnum++;
+						Property subp = new Property();
+						subp.setCode(subpd.getName());
+						subp.setCoursePropertyId(cp.getId());
+						subp.setName(subpd.getName());
+						subp.setNumber(subnum);
+						subp.setOrgId(rootOrgId);
+						subp.setParentId(p.getId());
+						subp.setFromId(subpd.getId().toString());
+						ps.add(subp);
+					}
+					propertyRepo.saveAll(ps);
+				}
+			}
+		} catch (IOException e) {
+			throw new StatusException("500", "出错", e);
+		} finally {
+			FileUtil.deleteFolder(dir);
+		}
+	}
+
+	@Transactional
+	public void propClear(Long rootOrgId, String batch) {
+		coursePropertyRepo.deleteByOrgIdAndBatch(rootOrgId, batch);
+		propertyRepo.deleteByOrgIdAndBatch(rootOrgId, batch);
+	}
+
+	@Transactional
+	public void importYunkaiPaper(YunkaiImportPaperParam p) {
+		String tempDir = systemProperties.getTempDataDir();
+		String dir = tempDir + File.separator + UUID.randomUUID() + File.separator;
+		try {
+			File dfile = new File(dir);
+			dfile.mkdirs();
+			File zfile = new File(dir + p.getDataFile().getOriginalFilename());
+			zfile.createNewFile();
+			p.getDataFile().transferTo(zfile);
+			FileUtil.unZip(dfile, zfile);
+			resolvingFile(dfile, p);
+		} catch (IOException e) {
+			throw new StatusException("500", "出错", e);
+		} finally {
+			FileUtil.deleteFolder(dir);
+		}
+	}
+
+	private void getPaperFile(File file, List<File> ret) {
+		if (file.isFile()) {
+			if (file.getName().endsWith(".json")) {
+				ret.add(file);
+			}
+			return;
+		} else {
+			for (File paperDir : file.listFiles()) {
+				getPaperFile(paperDir, ret);
+			}
+		}
+
+	}
+
+	private void resolvingFile(File file, YunkaiImportPaperParam p) {
+		List<File> files = new ArrayList<>();
+		getPaperFile(file, files);
+		GetCourseReq req = new GetCourseReq();
+		req.setRootOrgId(p.getRootOrgId());
+		req.setCode(p.getCourseCode());
+		GetCourseResp res = courseCloudService.getCourse(req);
+		Course c=new Course();
+		c.setId(res.getCourseBean().getId().toString());
+		c.setCode(res.getCourseBean().getCode());
+		c.setEnable(res.getCourseBean().getEnable().toString());
+		c.setLevel(res.getCourseBean().getLevel());
+		c.setName(res.getCourseBean().getName());
+		c.setOrgId(res.getCourseBean().getRootOrgId().toString());
+		p.setCourse(c);
+		for (File paperFile : files) {
+			KdPaper kpaper = JSONObject.parseObject(FileUtil.readFileContent(paperFile), KdPaper.class);
+			kpaper.setCourseCode(p.getCourseCode());
+			savePaper(kpaper,p);
+		}
+	}
+
+	private void savePaper(KdPaper kpaper,YunkaiImportPaperParam p) {
+		int questionNum = 0;
+		Paper paper = initPaper(kpaper, p);
+		paper.setDifficultyDegree(0.5);
+		// 定义大题集合
+		List<PaperDetail> paperDetails = new ArrayList<>();
+		// 定义小题集合
+		List<PaperDetailUnit> paperDetailUnits = new ArrayList<>();
+		List<Question> questions = new ArrayList<Question>();
+		for (int i = 0; i < kpaper.getDetails().size(); i++) {
+			KdDetail de = kpaper.getDetails().get(i);
+			de.setNumber(i + 1);
+			PaperDetail paperDetail = initPaperDetail(de, paper);
+			paperDetails.add(paperDetail);
+			for (KdQuestion que : de.getQuestions()) {
+				questionNum++;
+				Question question = initQuestion(que, p);
+				questions.add(question);
+				PaperDetailUnit paperDetailUnit = initPaperDetailUnit(paper, paperDetail, question, questionNum,p.getUser());
+				paperDetailUnits.add(paperDetailUnit);
+			}
+		}
+
+		quesRepo.saveAll(questions);
+		paperRepo.save(paper);
+		paperDetailRepo.saveAll(paperDetails);
+		paperDetailUnitRepo.saveAll(paperDetailUnits);
+		if (paperDetailUnits.size() > 0) {
+			saveQuesTypeName(paperDetailUnits);
+		}
+		paperService.formatPaper(paper, p.getUser());
+	}
+
+	private void saveQuesTypeName(List<PaperDetailUnit> detailUnitList) {
+
+		for (PaperDetailUnit paperDetailUnit : detailUnitList) {
+			String orgId = paperDetailUnit.getPaper().getOrgId();
+			String courseNo = paperDetailUnit.getPaper().getCourseNo();
+			QuesStructType questionType = paperDetailUnit.getQuestionType();
+			String detailName = paperDetailUnit.getPaperDetail().getName();
+			List<QuesTypeName> quesTypeNames = quesTypeNameRepo.findQuesName(orgId, courseNo, questionType);
+			if (quesTypeNames != null && quesTypeNames.size() > 0) {
+				QuesTypeName quesTypeName = quesTypeNames.get(0);
+				List<String> quesNames = quesTypeName.getQuesNames();
+				if (quesNames != null && quesNames.size() > 0) {
+					if (quesNames.contains(detailName)) {
+						continue;
+					} else {
+						quesNames.add(detailName);
+					}
+				} else {
+					quesNames = new ArrayList<>();
+					quesNames.add(detailName);
+				}
+				quesTypeName.setQuesNames(quesNames);
+				quesTypeNameRepo.save(quesTypeName);
+			} else {
+				QuesTypeName quesTypeName = new QuesTypeName();
+				List<String> quesNames = new ArrayList<>();
+				quesNames.add(detailName);
+				quesTypeName.setOrgId(orgId);
+				quesTypeName.setCourseNo(courseNo);
+				quesTypeName.setQuestionType(questionType);
+				quesTypeName.setQuesNames(quesNames);
+				quesTypeNameRepo.save(quesTypeName);
+			}
+		}
+	}
+
+
+	private Paper initPaper(KdPaper kpaper, YunkaiImportPaperParam p) {
+		int unitCount = 0;
+		for (KdDetail de : kpaper.getDetails()) {
+			unitCount = unitCount + de.getQuestions().size();
+		}
+		Paper paper = new Paper();
+		paper.setName(kpaper.getName());
+		paper.setTitle(kpaper.getName());
+		paper.setPaperType(PaperType.IMPORT);
+		paper.setPaperStatus(PaperStatus.DRAFT);
+		paper.setOrgId(p.getRootOrgId().toString());
+		paper.setCreator(p.getUser().getDisplayName());
+		paper.setTotalScore(unitCount + 0.0);
+		paper.setCourse(p.getCourse());
+		paper.setCourseName(p.getCourse().getName());
+		paper.setCourseNo(p.getCourse().getCode());
+		paper.setCreateTime(getCurDateTime());
+		paper.setPaperDetailCount(kpaper.getDetails().size());
+		paper.setCreationBy(p.getUser().getUserId());
+		paper.setCreationDate(new Date());
+		paper.setUnitCount(unitCount);
+		return paper;
+	}
+
+	private String getCurDateTime() {
+		return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
+	}
+
+
+	private PaperDetail initPaperDetail(KdDetail de, Paper paper) {
+		PaperDetail paperDetail = new PaperDetail();
+		if (de.getQuestions() != null && de.getQuestions().size() > 0) {
+			paperDetail.setPaper(paper);
+			paperDetail.setNumber(de.getNumber());
+			paperDetail.setName(de.getName());
+			paperDetail.setScore(de.getQuestions().size() + 0.0);
+			paperDetail.setUnitCount(de.getQuestions().size());
+			paperDetail.setCreator(paper.getCreator());
+			paperDetail.setCreateTime(getCurDateTime());
+			paperDetail.setCreationBy(paper.getCreationBy());
+			paperDetail.setCreationDate(new Date());
+		}
+		return paperDetail;
+	}
+
+	private Question initQuestion(KdQuestion que,YunkaiImportPaperParam p) {
+		Question question = new Question();
+		question.setCreateTime(getCurDateTime());
+		question.setScore(1.0);
+		question.setCourse(p.getCourse());
+		question.setOrgId(p.getRootOrgId().toString());
+		question.setHasAudio(false);
+		question.setDifficulty(que.getDifficulty().getDesc());
+		question.setDifficultyDegree(que.getDifficulty().getType());
+		question.setPublicity(true);
+		question.setCreationBy(p.getUser().getUserId());
+		question.setCreationDate(new Date());
+		question.setCreateTime(getCurDateTime());
+		// 按试题分类初始化题干,答案,选项
+		initQuestionInfo(question, que);
+		return question;
+	}
+
+	private void initQuestionInfo(Question question, KdQuestion que) {
+		// 单选题
+		if (YunkaiQuesStructType.DANXUAN.equals(que.getQst())) {
+			String quesBody = que.getBody();
+			question.setQuesBody(quesBody);
+			question.setQuestionType(QuesStructType.SINGLE_ANSWER_QUESTION);
+			List<QuesOption> quesOptions = new ArrayList<QuesOption>();
+			List<KdQuesOption> options = que.getOptions();
+			Integer answerNumber = null;
+			if (options != null && options.size() > 0) {
+				int number = 1;
+				short isCorrect = 0;
+				for (KdQuesOption testOption : options) {
+					if (testOption.getSelect()) {
+						isCorrect = 1;
+						answerNumber = number;
+					} else {
+						isCorrect = 0;
+					}
+					QuesOption quesOption = initQuesOption(testOption, isCorrect);
+					quesOptions.add(quesOption);
+					number++;
+				}
+			}
+			question.setQuesOptions(quesOptions);
+			if (answerNumber != null) {
+				char c1 = (char) (answerNumber + 64);
+				question.setQuesAnswer(String.valueOf(c1));
+			}
+		} else if (YunkaiQuesStructType.DUOXUAN.equals(que.getQst())
+				|| YunkaiQuesStructType.BUDINGXIANG.equals(que.getQst())) {
+			String quesBody = que.getBody();
+			question.setQuesBody(quesBody);
+			question.setQuestionType(QuesStructType.MULTIPLE_ANSWER_QUESTION);
+			List<QuesOption> quesOptions = new ArrayList<QuesOption>();
+			List<KdQuesOption> options = que.getOptions();
+			List<Integer> answerNumbers = new ArrayList<Integer>();
+			if (options != null && options.size() > 0) {
+				int number = 1;
+				short isCorrect = 0;
+				for (KdQuesOption testOption : options) {
+					if (testOption.getSelect()) {
+						isCorrect = 1;
+						answerNumbers.add(number);
+					} else {
+						isCorrect = 0;
+					}
+					QuesOption quesOption = initQuesOption(testOption, isCorrect);
+					quesOptions.add(quesOption);
+					number++;
+				}
+			}
+			question.setQuesOptions(quesOptions);
+			if (answerNumbers != null && answerNumbers.size() > 0) {
+				String answers = "";
+				for (Integer number : answerNumbers) {
+					char c1 = (char) (number + 64);
+					if (StringUtils.isBlank(answers)) {
+						answers = String.valueOf(c1);
+					} else {
+						answers = answers + "," + String.valueOf(c1);
+					}
+				}
+				question.setQuesAnswer(answers);
+			}
+		} else if (YunkaiQuesStructType.PANDUAN.equals(que.getQst())) {
+			String quesBody = que.getBody();
+			question.setQuesBody(quesBody);
+			question.setQuestionType(QuesStructType.BOOL_ANSWER_QUESTION);
+			String answer = que.getAnswer();
+			question.setQuesAnswer(answer);
+		} else if (YunkaiQuesStructType.TIANKONGTI.equals(que.getQst())) {
+			String quesBody = que.getBody();
+			question.setQuesBody(quesBody);
+			question.setQuestionType(QuesStructType.FILL_BLANK_QUESTION);
+			String answer = que.getAnswer();
+			question.setQuesAnswer(answer);
+		} else {//全是问答题
+			String quesBody = que.getBody();
+			question.setQuesBody(quesBody);
+			question.setQuestionType(QuesStructType.TEXT_ANSWER_QUESTION);
+			String answer = que.getAnswer();
+			question.setQuesAnswer(answer);
+		}
+	}
+
+	private QuesOption initQuesOption(KdQuesOption testOption, short isCorrect) {
+		QuesOption quesOption = new QuesOption();
+		quesOption.setNumber(testOption.getNumber().toString());
+		quesOption.setIsCorrect(isCorrect);
+		String optionBody = testOption.getBody();
+		quesOption.setOptionBody(optionBody);
+		return quesOption;
+	}
+
+	private PaperDetailUnit initPaperDetailUnit(Paper paper, PaperDetail paperDetail, Question question,
+			int questionNum,User user) {
+		PaperDetailUnit paperDetailUnit = new PaperDetailUnit();
+		paperDetailUnit.setPaper(paper);
+		paperDetailUnit.setNumber(questionNum);
+		paperDetailUnit.setScore(1.0);
+		paperDetailUnit.setPaperDetail(paperDetail);
+		paperDetailUnit.setQuestionType(question.getQuestionType());
+		paperDetailUnit.setCreator(user.getDisplayName());
+		paperDetailUnit.setCreateTime(getCurDateTime());
+		paperDetailUnit.setQuestion(question);
+		paperDetailUnit.setPaperType(PaperType.IMPORT);
+		paperDetailUnit.setCreationBy(user.getUserId());
+		paperDetailUnit.setCreationDate(new Date());
+		return paperDetailUnit;
+	}
+}