Quellcode durchsuchen

地大代码提交

weiwenhai vor 7 Jahren
Ursprung
Commit
7df713fce9
13 geänderte Dateien mit 1576 neuen und 3 gelöschten Zeilen
  1. 1 1
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/CommonUtils.java
  2. 2 1
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/initQuesHash/InitQuesHashServiceImpl.java
  3. 782 0
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/DdCollegeUtilService.java
  4. 201 0
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/ImgDataUtils.java
  5. 62 0
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/TestFillAnswer.java
  6. 21 0
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/TestFillContent.java
  7. 44 0
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/TestOption.java
  8. 26 0
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/TestOptionGroup.java
  9. 63 0
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/TestPaper.java
  10. 116 0
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/TestQuestion.java
  11. 191 0
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/TestQuestionInfo.java
  12. 1 1
      examcloud-core-questions-starter/src/main/resources/application-dev.properties
  13. 66 0
      examcloud-core-questions-starter/src/test/java/cn/com/qmth/examcloud/core/questions/starter/DdCollegeUtilTest.java

+ 1 - 1
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/CommonUtils.java

@@ -645,7 +645,7 @@ public final class CommonUtils {
             return "";
         }
         htmlStr = repairHtmlStr(htmlStr);
-        //htmlStr = StringEscapeUtils.unescapeHtml4(htmlStr);
+        htmlStr = StringEscapeUtils.unescapeHtml4(htmlStr);
         htmlStr = UNESCAPE_HTML4.translate(htmlStr);
         return htmlStr;
     }

+ 2 - 1
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/initQuesHash/InitQuesHashServiceImpl.java

@@ -6,6 +6,7 @@ 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.examcloud.core.questions.base.CommonUtils;
 import cn.com.qmth.examcloud.core.questions.dao.entity.Question;
@@ -16,7 +17,7 @@ import cn.com.qmth.examcloud.core.questions.dao.entity.Question;
  * @company		qmth
  * @describle	InitQuesHashServiceImpl
  */
-
+@Service("initQuesHashService")
 public class InitQuesHashServiceImpl implements InitQuesHashService{
 
 	@Autowired

+ 782 - 0
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/DdCollegeUtilService.java

@@ -0,0 +1,782 @@
+package cn.com.qmth.examcloud.core.questions.service.temp;
+
+import java.io.UnsupportedEncodingException;
+import java.math.BigDecimal;
+import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.commons.lang3.StringUtils;
+import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.stereotype.Service;
+
+
+
+
+
+
+import cn.com.qmth.examcloud.common.dto.question.enums.QuesStructType;
+import cn.com.qmth.examcloud.commons.base.util.JsonUtil;
+import cn.com.qmth.examcloud.core.questions.base.CommonUtils;
+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.word.DocxProcessUtil;
+import cn.com.qmth.examcloud.core.questions.dao.CourseRepo;
+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.QuesPkgPathRepo;
+import cn.com.qmth.examcloud.core.questions.dao.QuesRepo;
+import cn.com.qmth.examcloud.core.questions.dao.entity.Course;
+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.QuesOption;
+import cn.com.qmth.examcloud.core.questions.dao.entity.Question;
+import cn.com.qmth.examcloud.core.questions.dao.entity.QuestionPkgPath;
+import cn.com.qmth.examcloud.core.questions.service.temp.vo.TestFillAnswer;
+import cn.com.qmth.examcloud.core.questions.service.temp.vo.TestFillContent;
+import cn.com.qmth.examcloud.core.questions.service.temp.vo.TestOption;
+import cn.com.qmth.examcloud.core.questions.service.temp.vo.TestOptionGroup;
+import cn.com.qmth.examcloud.core.questions.service.temp.vo.TestPaper;
+import cn.com.qmth.examcloud.core.questions.service.temp.vo.TestQuestion;
+import cn.com.qmth.examcloud.core.questions.service.temp.vo.TestQuestionInfo;
+
+/**
+ * @author 		weiwenhai
+ * @date		2018.7.19
+ * @company		qmth
+ * @describle	地大题库数据导入
+ */
+@Service("ddCollegeUtilService")
+public class DdCollegeUtilService {
+
+	@Autowired
+	private JdbcTemplate jdbcTemplate;
+	
+	@Autowired
+    private CourseRepo courseRepo;
+	
+	@Autowired
+	private QuesPkgPathRepo quesPkgPathRepo;
+	
+	@Autowired
+	private QuesRepo quesRepo;
+	
+	@Autowired
+	private PaperRepo paperRepo;
+	
+	@Autowired
+	private PaperDetailRepo paperDetailRepo;
+	
+	@Autowired
+	private PaperDetailUnitRepo paperDetailUnitRepo;
+	
+	public void importPaper(String orgId,String courseCode) throws Exception{
+		//查询课程
+		Course course = courseRepo.findFirstByCodeAndOrgId(courseCode,orgId);
+		//查询试卷集合
+		//List<TestPaper> papers = queryByCourse(courseCode);
+		TestPaper testPaper1 = new TestPaper();
+		testPaper1.setId("21D9D5D5E5FE0A438282C9B490BF45DE");
+		testPaper1.setName("地大所有题型");
+		testPaper1.setScore(100.0);
+		testPaper1.setTestPaperContentId("F61A67F4898249767CB0A31A3BD2616B");//EBE6752BCE3A360D1F50BE9FBA4ADCE7,F61A67F4898249767CB0A31A3BD2616B
+		List<TestPaper> papers = new ArrayList<TestPaper>();
+		papers.add(testPaper1);
+		if(papers != null && papers.size()>0){
+			for(TestPaper testPaper:papers){
+				//查询试题详情
+				List<TestQuestion> questions = queryByTestPaper(testPaper.getTestPaperContentId());
+				if(questions != null && questions.size()>0){
+					//构建大题和小题对应关系
+					Map<Integer, List<TestQuestion>> map = sortPaperDetail(questions);
+					//初始化试卷
+					Paper paper = initPaper(testPaper,orgId,course,map);
+					//定义大题集合
+					List<PaperDetail> paperDetails = new ArrayList<PaperDetail>();
+					//定义小题集合
+					List<PaperDetailUnit> paperDetailUnits = new ArrayList<PaperDetailUnit>();
+					//试题---资源 对应关系
+					Map<Question, QuestionPkgPath> map2 = new HashMap<Question, QuestionPkgPath>();
+					//定义试卷难度
+					double difficulty = 0;
+					for(Integer key:map.keySet()){
+						List<TestQuestion> dQuestions = map.get(key);
+						//初始化大题对象
+						PaperDetail paperDetail = initPaperDetail(dQuestions,paper);
+						if(dQuestions != null && dQuestions.size()>0){
+							for(TestQuestion testQuestion:dQuestions){
+								TestQuestionInfo testQuestionInfo = JsonUtil.fromJson(testQuestion.getJson(),TestQuestionInfo.class);
+								//初始化试题对象
+								Question question= initQuestion(testQuestionInfo,testQuestion,course,map2,difficulty);
+								//初始化小题对象
+								PaperDetailUnit paperDetailUnit = initPaperDetailUnit(paper, paperDetail, question, testQuestion);
+								paperDetailUnits.add(paperDetailUnit);
+							}
+						}
+						paperDetails.add(paperDetail);
+					}
+					//保存试题资源
+					quesPkgPathRepo.save(map2.values());
+					for(Map.Entry<Question, QuestionPkgPath> entry:map2.entrySet()){
+						entry.getKey().setQuesPkgPathId(entry.getValue().getId());
+					}
+					//计算试卷难度
+					BigDecimal b = new BigDecimal(difficulty / paper.getTotalScore());
+					Double difficultyDegree = b.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
+					paper.setDifficultyDegree(difficultyDegree);
+					//重新计算试题序号
+					Map<PaperDetail, List<PaperDetailUnit>> map3 = new LinkedHashMap<PaperDetail, List<PaperDetailUnit>>();
+					List<PaperDetailUnit> newList = null;
+					for(PaperDetail paperDetail:paperDetails){
+						for(PaperDetailUnit paperDetailUnit:paperDetailUnits){
+							if(paperDetail.getName().equals(paperDetailUnit.getPaperDetail().getName())){
+								if(map3.get(paperDetail) == null){
+									newList = new ArrayList<PaperDetailUnit>();
+									newList.add(paperDetailUnit);
+								}else {
+									newList = map3.get(paperDetail);
+									newList.add(paperDetailUnit);
+								}
+								map3.put(paperDetail, newList);
+							}
+						}
+					}
+					int number =1;
+					for(Map.Entry<PaperDetail, List<PaperDetailUnit>> entry:map3.entrySet()){
+						for(PaperDetailUnit paperDetailUnit:entry.getValue()){
+							paperDetailUnit.setNumber(number);
+							number++;
+						}
+					}
+					quesRepo.save(map2.keySet());
+					paperRepo.save(paper);
+					paperDetailRepo.save(paperDetails);
+					paperDetailUnitRepo.save(paperDetailUnits);
+				}
+			}
+		}
+	}
+	
+	/**
+	 * 根据课程代码查询所有试卷
+	 * @param codeName
+	 * @return
+	 */
+	@SuppressWarnings({"unchecked","rawtypes"})
+	public List<TestPaper> queryByCourse(String courseCode){
+		String sql = "SELECT * from dd_test_paper_info_temp p WHERE p.COURSE_ID in "
+				+ "(SELECT c.ID FROM dd_pe_tch_course_temp c WHERE c.code = '"+ courseCode +"')";
+		List<TestPaper> papers = this.jdbcTemplate.query(sql, new BeanPropertyRowMapper(TestPaper.class));
+		return papers;
+	}
+    
+    /**
+     * 根据考试id查询所有试题
+     * @param testPaperContentId
+     * @return
+     */
+    @SuppressWarnings({"unchecked","rawtypes"})
+    public List<TestQuestion> queryByTestPaper(String testPaperContentId){
+    	String sql = "SELECT q.ID id,d.dNumber,d.`name` dName,d.number number,d.score score,q.PARENT_ID parent_id,q.QUESTION_TYPE_ENUM type,q.JSON "
+    			+ "FROM dd_question_content_temp q ,(SELECT b.QUESTION_CONTENT_ID question_id, b.SCORE score, b.SEQUENCE number, c.name name, c.dNumber dNumber "
+    			+ "FROM dd_test_paper_question_temp b ,(SELECT a.ID id, a.`NAME` name,a.SEQUENCE dNumber,a.TEST_PAPER_CONTENT_ID "
+    			+ "FROM dd_test_paper_question_group_temp a WHERE a.TEST_PAPER_CONTENT_ID = '"+ testPaperContentId + "' ORDER BY a.sequence) c "
+    			+ "WHERE b.TEST_PAPER_QUESTION_GROUP_ID = c.id ORDER BY c.dNumber,b.SEQUENCE) d WHERE q.ID = d.question_id ORDER BY d.dNumber,d.number;";
+    	List<TestQuestion> questions = this.jdbcTemplate.query(sql, new BeanPropertyRowMapper(TestQuestion.class));
+    	return questions;
+    }
+    
+    /**
+     * 根据父ID查询子题
+     * @param parentId
+     * @return
+     */
+    @SuppressWarnings({"unchecked","rawtypes"})
+    public List<TestQuestion> querySubQuestions(String parentId){
+    	String sql = "SELECT q.question_type_enum type, q.json json from dd_question_content_temp q WHERE q.parent_id = '" + parentId +"'";
+    	List<TestQuestion> questions = this.jdbcTemplate.query(sql, new BeanPropertyRowMapper(TestQuestion.class));
+    	return questions;
+    }
+    
+    /**
+	 * 初始化试卷对象
+	 * @param paper
+	 * @param paperName
+	 * @param user
+	 */
+    public Paper initPaper(TestPaper testPaper, String orgId, Course course,Map<Integer, List<TestQuestion>> map) {
+    	int unitCount = 0;
+    	Set<Integer> paperDetails = map.keySet();
+    	for(Map.Entry<Integer, List<TestQuestion>> entry:map.entrySet()){
+			unitCount = unitCount + entry.getValue().size();
+		}
+    	Paper paper = new Paper();
+        paper.setName(testPaper.getName());
+        paper.setTitle(testPaper.getName());
+        paper.setPaperType(PaperType.IMPORT);
+        paper.setPaperStatus(PaperStatus.DRAFT);
+        paper.setOrgId(orgId);
+        paper.setCreator("wei");
+        paper.setTotalScore(testPaper.getScore());
+        paper.setCourse(course);
+        paper.setCourseName(course.getName());
+        paper.setCourseNo(course.getCode());
+        paper.setCreateTime(CommonUtils.getCurDateTime());
+        paper.setPaperDetailCount(paperDetails.size());
+        paper.setUnitCount(unitCount);
+        return paper;
+    }
+    
+    /**
+     * 初始化大题对象
+     * @param testQuestion
+     * @return
+     */
+    public PaperDetail initPaperDetail(List<TestQuestion> dQuestions,Paper paper){
+    	//定义大题分数
+    	double dTotal = 0;
+    	PaperDetail paperDetail = new PaperDetail();
+    	if(dQuestions != null && dQuestions.size()>0){
+    		for(TestQuestion question:dQuestions){
+    			dTotal = dTotal + question.getScore();
+    		}
+    		paperDetail.setPaper(paper);
+        	paperDetail.setNumber(dQuestions.get(0).getdNumber());
+        	paperDetail.setName(dQuestions.get(0).getdName());
+        	paperDetail.setScore(dTotal);
+        	paperDetail.setUnitCount(dQuestions.size());
+        	paperDetail.setCreator("wei");
+        	paperDetail.setCreateTime(CommonUtils.getCurDateTime());
+    	}
+    	return paperDetail;
+    }
+    
+   /**
+    * 初始化试题对象
+    * @param testQuestionInfo
+    * @param testQuestion
+    * @param course
+    * @param map
+    * @return
+    * @throws Exception
+    */
+    public Question initQuestion(TestQuestionInfo testQuestionInfo,TestQuestion testQuestion,Course course,Map<Question, QuestionPkgPath> map,double difficulty) throws Exception{
+    	Question question = new Question();
+    	question.setCreateTime(CommonUtils.getCurDateTime());
+    	question.setScore(testQuestion.getScore());
+    	question.setCourse(course);
+    	question.setOrgId(course.getOrgId());
+    	question.setHasAudio(false);
+    	question.setDifficulty("中");
+    	question.setDifficultyDegree(0.5);
+    	question.setPublicity(true);
+    	//按试题分类初始化题干,答案,选项
+    	initQuestionInfo(question,testQuestionInfo,map,testQuestion);
+    	difficulty = question.getScore() * 0.5 + difficulty;
+    	return question;
+    }
+    
+    /**
+     * 初始化题干,答案,选项,资源
+     * @param question
+     * @param testQuestionInfo
+     * @param map
+     * @throws Exception
+     */
+    public void initQuestionInfo(Question question,TestQuestionInfo testQuestionInfo,Map<Question, QuestionPkgPath> map,TestQuestion testQuestion) throws Exception{
+    	WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
+    	//选词填空
+    	if(testQuestionInfo.getQuestionType() == 14){
+    		question.setQuestionType(QuesStructType.TEXT_ANSWER_QUESTION);
+    		//定义答案集合
+    		List<String> answers = new ArrayList<String>();
+    		//定义答案ID集合
+    		List<String> answerIds = new ArrayList<String>();
+    		List<TestFillAnswer> blanks = testQuestionInfo.getBlanks();
+    		if(blanks != null && blanks.size()>0){
+    			for(TestFillAnswer answer : blanks){
+    				answerIds.add(answer.getAnswerId());
+    			}
+    		}
+    		StringBuffer quesBody = new StringBuffer();
+    		quesBody.append("<p>"+testQuestionInfo.getQuestionHTML()+"</p>");
+    		//获取选项,添加到题干
+    		TestOptionGroup optionGroup = testQuestionInfo.getOptionGroup();
+    		if(optionGroup!=null){
+    			List<TestOption> options =  optionGroup.getOptions();
+    			if(options != null && options.size()>0){
+    				int number = 1;
+    				for(TestOption option:options){
+    					char c1=(char) (number+64);
+    					quesBody.append("<p>"+"("+String.valueOf(c1)+")"+option.getOptionHTML()+"</p>");
+    					if(answerIds.contains(option.getID())){
+    						answers.add(String.valueOf(c1));
+    					}
+    					number++;
+    				}
+    				//去掉<span>标签中的lang
+    	    		String quesBodys = replaceLang(quesBody.toString());
+    	    		//获取img标签
+    	    		LinkedHashMap<String, String> bodyImgList = imgList(quesBodys);
+    	    		//替换、补全Img标签
+    	    		quesBodys = replaceImg(bodyImgList, quesBodys);
+    				question.setQuesBody(quesBodys);
+    				question.setQuesBodyWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(question.getQuesBody())));
+    				question.setQuesAnswer(StringUtils.join(answers,","));
+    				String answerWord = "<p>" +question.getQuesAnswer() +"</p>";
+    				question.setQuesAnswerWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(answerWord)));
+    			}
+    		}
+    	}
+    	//阅读理解题
+    	if(testQuestionInfo.getQuestionType() == 42){
+    		String quesBody = testQuestionInfo.getQuestionHTML();
+    		//去掉<span>标签中的lang
+    		quesBody = replaceLang(quesBody);
+    		//获取img标签
+    		LinkedHashMap<String, String> bodyImgList = imgList(quesBody);
+    		//替换、补全Img标签
+    		quesBody = replaceImg(bodyImgList, quesBody);
+    		question.setQuesBody("<p>"+quesBody+"</p>");
+        	question.setQuesBodyWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(question.getQuesBody())));
+    		question.setQuestionType(QuesStructType.NESTED_ANSWER_QUESTION);
+    		List<Question> subQues = new ArrayList<Question>();
+    		//查询所有子题
+    		List<TestQuestion> subQuestions = querySubQuestions(testQuestion.getId());
+    		if(subQuestions!=null && subQuestions.size()>0){
+    			for(TestQuestion testQuestion2:subQuestions){
+    				TestQuestionInfo testQuestionInfo2 = JsonUtil.fromJson(testQuestion2.getJson(),TestQuestionInfo.class);
+    				Question subQuestion = new Question();
+    				subQuestion.setDifficulty("中");
+    				subQuestion.setDifficultyDegree(0.5);
+    				subQuestion.setPublicity(true);
+    		    	//按试题分类初始化题干,答案,选项
+    		    	initQuestionInfo(subQuestion,testQuestionInfo2,map,testQuestion2);
+    		    	subQues.add(subQuestion);
+    			}
+    			question.setSubQuestions(subQues);
+    		}
+    	}
+    	//完形填空题
+    	if(testQuestionInfo.getQuestionType() == 15){
+    		String quesBody = testQuestionInfo.getQuestionHTML();
+    		//去掉<span>标签中的lang
+    		quesBody = replaceLang(quesBody);
+    		//获取img标签
+    		LinkedHashMap<String, String> bodyImgList = imgList(quesBody);
+    		if(bodyImgList != null && bodyImgList.size()>0){
+    			int number = 1;
+    			for(Map.Entry<String, String> entry:bodyImgList.entrySet()){
+    				if(StringUtils.isBlank(entry.getValue())){
+    					quesBody = quesBody.replace(entry.getKey(),"##"+number+"##");
+    					number++;
+    				}else {
+    					quesBody = quesBody.replace(entry.getKey(),entry.getValue());
+					}
+    			}
+    		}
+    		question.setQuesBody("<p>"+quesBody+"</p>");
+        	question.setQuesBodyWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(question.getQuesBody())));
+    		question.setQuestionType(QuesStructType.NESTED_ANSWER_QUESTION);
+    		//获取所有选项
+    		List<TestFillAnswer> blanks = testQuestionInfo.getBlanks();
+    		List<Question> subQuestions = initSubQuestions(blanks, wordMLPackage);
+    		question.setSubQuestions(subQuestions);
+    	}
+    	//问答题  、 名词解释
+    	if(testQuestionInfo.getQuestionType() == 60 || testQuestionInfo.getQuestionType() == 69){
+    		String quesBody = testQuestionInfo.getQuestionHTML();
+    		//去掉<span>标签中的lang
+    		quesBody = replaceLang(quesBody);
+    		//获取img标签
+    		LinkedHashMap<String, String> bodyImgList = imgList(quesBody);
+    		//替换、补全Img标签
+    		quesBody = replaceImg(bodyImgList, quesBody);
+    		question.setQuesBody("<p>"+quesBody+"</p>");
+        	question.setQuesBodyWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(question.getQuesBody())));
+    		question.setQuestionType(QuesStructType.TEXT_ANSWER_QUESTION);
+    		String answer = testQuestionInfo.getAnswer();
+    		//去掉<span>标签中的lang
+    		answer = replaceLang(answer);
+    		//获取img标签
+    		LinkedHashMap<String, String> answerImgList = imgList(answer);
+    		//替换、补全Img标签
+    		answer = replaceImg(answerImgList, answer);
+    		question.setQuesAnswer("<p>"+answer+"</p>");
+    		question.setQuesAnswerWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(question.getQuesAnswer())));
+    	}
+    	//单选题
+    	if(testQuestionInfo.getQuestionType() == 11){
+    		String quesBody = testQuestionInfo.getQuestionHTML();
+    		//去掉<span>标签中的lang
+    		quesBody = replaceLang(quesBody);
+    		//获取img标签
+    		LinkedHashMap<String, String> bodyImgList = imgList(quesBody);
+    		//替换、补全Img标签
+    		quesBody = replaceImg(bodyImgList, quesBody);
+    		question.setQuesBody("<p>"+quesBody+"</p>");
+        	question.setQuesBodyWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(question.getQuesBody())));
+    		question.setQuestionType(QuesStructType.SINGLE_ANSWER_QUESTION);
+    		List<QuesOption> quesOptions = new ArrayList<QuesOption>();
+    		List<TestOption> options = testQuestionInfo.getOptions();
+    		Integer answerNumber = null;
+    		if(options != null && options.size()>0){
+    			int number = 1;
+    			short isCorrect = 0;
+    			for(TestOption testOption:options){
+    				if(testOption.getID().equals(testQuestionInfo.getAnswerId())){
+    					isCorrect = 1;
+    					answerNumber = number;
+    				}else {
+    					isCorrect = 0;
+					}
+    				QuesOption quesOption = initQuesOption(testOption, number, isCorrect, wordMLPackage);
+    				quesOptions.add(quesOption);
+    				number++;
+    			}
+    		}
+    		question.setQuesOptions(quesOptions);
+    		if(answerNumber != null){
+    			char c1=(char) (answerNumber+64);
+    			question.setQuesAnswer(String.valueOf(c1));
+    			question.setQuesAnswerWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml("<p>"+question.getQuesAnswer()+"</p>")));
+    		}
+    	}
+    	//多选题
+    	if(testQuestionInfo.getQuestionType() == 12){
+    		String quesBody = testQuestionInfo.getQuestionHTML();
+    		//去掉<span>标签中的lang
+    		quesBody = replaceLang(quesBody);
+    		//获取img标签
+    		LinkedHashMap<String, String> bodyImgList = imgList(quesBody);
+    		//替换、补全Img标签
+    		quesBody = replaceImg(bodyImgList, quesBody);
+    		question.setQuesBody("<p>"+quesBody+"</p>");
+        	question.setQuesBodyWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(question.getQuesBody())));
+    		question.setQuestionType(QuesStructType.MULTIPLE_ANSWER_QUESTION);
+    		List<QuesOption> quesOptions = new ArrayList<QuesOption>();
+    		List<TestOption> options = testQuestionInfo.getOptions();
+    		List<Integer> answerNumbers = new ArrayList<Integer>();
+    		if(options != null && options.size()>0){
+    			int number = 1;
+    			short isCorrect = 0;
+    			for(TestOption testOption:options){
+    				if(testQuestionInfo.getAnswers().contains(testOption.getID())){
+    					isCorrect = 1;
+    					answerNumbers.add(number);
+    				}else {
+    					isCorrect = 0;
+					}
+    				QuesOption quesOption = initQuesOption(testOption, number, isCorrect, wordMLPackage);
+    				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);
+    			question.setQuesAnswerWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml("<p>"+question.getQuesAnswer()+"</p>")));
+    		}
+    	}
+    	//填空题 ###
+    	if(testQuestionInfo.getQuestionType() == 13){
+    		String quesBody = testQuestionInfo.getQuestionHTML();
+    		//去掉<span>标签中的lang
+    		quesBody = replaceLang(quesBody);
+    		//获取img标签
+    		LinkedHashMap<String, String> imgList = imgList(quesBody);
+    		if(imgList != null && imgList.size()>0){
+    			for(Map.Entry<String, String> entry:imgList.entrySet()){
+    				if(StringUtils.isBlank(entry.getValue())){
+    					quesBody = quesBody.replace(entry.getKey(),"(###)");
+    				}else {
+    					quesBody = quesBody.replace(entry.getKey(),entry.getValue());
+					}
+    			}
+    		}
+    		question.setQuesBody("<p>"+quesBody+"</p>");
+        	question.setQuesBodyWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(question.getQuesBody())));
+    		question.setQuestionType(QuesStructType.FILL_BLANK_QUESTION);
+    		String answer = "";
+    		List<TestFillAnswer> blanks = testQuestionInfo.getBlanks();
+    		if(blanks != null && blanks.size()>0){
+    			for(TestFillAnswer testFillAnswer:blanks){
+    				List<TestFillContent> answers = testFillAnswer.getAnswers();
+    				if(answers != null && answers.size()>0){
+    					for(TestFillContent testFillContent:answers){
+    						if(StringUtils.isBlank(answer)){
+    							answer = testFillContent.getContent();
+    						}else {
+    							answer = answer + "##" + testFillContent.getContent();
+							}
+    					}
+    				}
+    			}
+    			//去掉<span>标签中的lang
+        		answer = replaceLang(answer);
+        		//获取img标签
+        		LinkedHashMap<String, String> answerImgList = imgList(answer);
+        		//替换、补全Img标签
+        		answer = replaceImg(answerImgList, answer);
+    			question.setQuesAnswer("<p>"+answer+"</p>");
+    			question.setQuesAnswerWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(question.getQuesAnswer())));
+    		}
+    	}
+    	//判断题
+    	if(testQuestionInfo.getQuestionType() == 20){
+    		String quesBody = testQuestionInfo.getQuestionHTML();
+    		//去掉<span>标签中的lang
+    		quesBody = replaceLang(quesBody);
+    		//获取img标签
+    		LinkedHashMap<String, String> bodyImgList = imgList(quesBody);
+    		//替换、补全Img标签
+    		quesBody = replaceImg(bodyImgList, quesBody);
+    		question.setQuesBody("<p>"+quesBody+"</p>");
+        	question.setQuesBodyWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(question.getQuesBody())));
+    		question.setQuestionType(QuesStructType.BOOL_ANSWER_QUESTION);
+    		String answer = testQuestionInfo.getAnswer();
+    		if(answer.equals("false")){
+    			answer = "错误";
+    		}else {
+				answer = "正确";
+			}
+    		question.setQuesAnswer(answer);
+    		question.setQuesAnswerWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml("<p>"+question.getQuesAnswer()+"</p>")));
+    	}
+    	byte [] pkgByte = DocxProcessUtil.getPkgByte(wordMLPackage);
+    	QuestionPkgPath quesPkgPath = new QuestionPkgPath(pkgByte);
+    	map.put(question, quesPkgPath);
+    }
+    
+    /**
+     * 初始化选项
+     * @param testOption
+     * @param number
+     * @param isCorrect
+     * @param wordMLPackage
+     * @return
+     * @throws Exception
+     */
+    public QuesOption initQuesOption(TestOption testOption,int number,short isCorrect,WordprocessingMLPackage wordMLPackage) throws Exception{
+    	QuesOption quesOption = new QuesOption();
+    	quesOption.setNumber(String.valueOf(number));
+    	quesOption.setIsCorrect(isCorrect);
+    	String optionBody = testOption.getOptionHTML();
+		//去掉<span>标签中的lang
+    	optionBody = replaceLang(optionBody);
+		//获取img标签
+		LinkedHashMap<String, String> optionBodyImgList = imgList(optionBody);
+		//替换、补全Img标签
+		optionBody = replaceImg(optionBodyImgList, optionBody);
+    	quesOption.setOptionBody("<p>"+optionBody+"</p>");
+    	quesOption.setOptionBodyWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(quesOption.getOptionBody())));
+    	return quesOption;
+    }
+    /**
+     * 完形填空初始化所有子题
+     * @param blanks
+     * @param wordMLPackage
+     * @return
+     * @throws Exception
+     */
+    public List<Question> initSubQuestions(List<TestFillAnswer> blanks,WordprocessingMLPackage wordMLPackage) throws Exception{
+    	List<Question> subQuestions = new ArrayList<Question>();
+    	if(blanks!=null && blanks.size()>0){
+    		//int number = 1;
+    		for(TestFillAnswer testFillAnswer:blanks){
+    			Question question = new Question();
+    			question.setId(UUID.randomUUID().toString());
+    			question.setQuestionType(QuesStructType.SINGLE_ANSWER_QUESTION);
+    			question.setDifficulty("中");
+    	    	question.setDifficultyDegree(0.5);
+    	    	question.setPublicity(true);
+    			question.setQuesBody("______");
+    			question.setQuesBodyWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml("<p>"+question.getQuesBody()+"</p>")));
+    			TestOptionGroup optionGroup = testFillAnswer.getOptionGroup();
+    			List<QuesOption> quesOptions = new ArrayList<QuesOption>();
+    			List<TestOption> subOptions = optionGroup.getOptions();
+    			Integer answerNumber = null;
+    			if(subOptions!=null && subOptions.size()>0){
+    				int subNumber = 1;
+    				short isCorrect = 0;
+    				for(TestOption subOption:subOptions){
+    					if (testFillAnswer.getAnswerId().equals(subOption.getID())) {
+    						isCorrect = 1;
+        					answerNumber = subNumber;
+						}else {
+							isCorrect = 0;
+						}
+    					QuesOption quesOption = initQuesOption(subOption,subNumber,isCorrect,wordMLPackage);
+    					quesOptions.add(quesOption);
+    					subNumber++;
+    				}
+    			}
+    			question.setQuesOptions(quesOptions);
+    			if(answerNumber != null){
+        			char c1=(char) (answerNumber+64);
+        			question.setQuesAnswer(String.valueOf(c1));
+        			question.setQuesAnswerWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml("<p>"+question.getQuesAnswer()+"</p>")));
+        		}
+    			subQuestions.add(question);
+    			//number++;
+    		}
+    	}
+    	return subQuestions;
+    }
+    /**
+     * 初始化小题对象
+     * @param question
+     * @return
+     */
+    public PaperDetailUnit initPaperDetailUnit(Paper paper,PaperDetail paperDetail,Question question,TestQuestion testQuestion){
+    	PaperDetailUnit paperDetailUnit = new PaperDetailUnit();
+    	paperDetailUnit.setPaper(paper);
+    	paperDetailUnit.setNumber(testQuestion.getNumber());
+    	paperDetailUnit.setScore(testQuestion.getScore());
+    	paperDetailUnit.setPaperDetail(paperDetail);
+    	paperDetailUnit.setQuestionType(question.getQuestionType());
+    	paperDetailUnit.setCreator("wei");
+    	paperDetailUnit.setCreateTime(CommonUtils.getCurDateTime());
+    	paperDetailUnit.setQuestion(question);
+    	return paperDetailUnit;
+    }
+    
+    /**
+     * 将大题和小题分类
+     * @param questions
+     * @return
+     */
+    public Map<Integer, List<TestQuestion>> sortPaperDetail(List<TestQuestion> questions){
+    	if(questions != null && questions.size()>0){
+    		Map<Integer, List<TestQuestion>> map = new HashMap<Integer, List<TestQuestion>>();
+    		List<TestQuestion> sortQuestions = null;
+    		for(TestQuestion testQuestion:questions){
+    			if(map.get(testQuestion.getdNumber()) == null){
+    				sortQuestions = new ArrayList<TestQuestion>();
+    				sortQuestions.add(testQuestion);
+    			}else {
+    				sortQuestions = map.get(testQuestion.getdNumber());
+    				sortQuestions.add(testQuestion);
+				}
+    			map.put(testQuestion.getdNumber(), sortQuestions);
+    		}
+    		return map;
+    	}
+    	return null;
+    }
+    
+    /**
+     * 去除图片中有下划线的图片,并补全图片下载地址
+     * @param str
+     * @return
+     * @throws Exception 
+     */
+    public LinkedHashMap<String, String> imgList(String str) throws Exception{
+    	LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
+    	//获取img标签
+		List<String> srcList = ImgDataUtils.parseImages(str);
+		if(srcList!=null && srcList.size()>0){
+			for (String img : srcList) {
+	           if(img.contains("/Shared/UnderLine")){
+	        	   map.put(img, "");
+	           }else {
+	        	   List<String> parseImageSrc = ImgDataUtils.parseImageSrc(img);
+	        	   if(parseImageSrc!=null && parseImageSrc.size()>0){
+	        		   String src = parseImageSrc.get(0);
+	        		   String url = regexCH(src);
+	        		   String picture = "http://ncexam.cug.edu.cn"+url;
+	        		   String base64 = ImgDataUtils.loadImageToBase64(picture);
+	        		   if(base64 == null){
+	        			   throw new Exception("图片下载失败" + picture);
+	        		   }else {
+	        			   if(src.contains("jpg")){
+								map.put(img, img.replace(src, "data:image/jpg;base64,"+base64));
+							}else {
+								map.put(img, img.replace(src, "data:image/png;base64,"+base64));
+							}
+	        		   }
+	        	  }
+	           }
+	        }
+			return map;
+		}
+    	return null;
+    }
+    
+    /**
+     * 去除<span>标签中lang=EN-US
+     * @param str
+     * @return
+     */
+    public String replaceLang(String str){
+    	if(str.contains("lang=EN-US")){
+    		str = str.replace("lang=EN-US", "");
+		}
+    	return str;
+    }
+    
+    /**
+     * 替换img标签,补全图片
+     * @param imgList
+     * @param str
+     * @return
+     */
+    public String replaceImg(LinkedHashMap<String, String> imgList,String str){
+		if(imgList != null && imgList.size()>0){
+			for(Map.Entry<String, String> entry:imgList.entrySet()){
+				if(StringUtils.isBlank(entry.getValue())){
+					str = str.replace(entry.getKey(),"___");
+				}else {
+					str = str.replace(entry.getKey(),entry.getValue());
+				}
+			}
+		}
+		return str;
+    }
+    
+    /**
+     * 將url路徑中的中文转码
+     * @param str
+     * @return
+     * @throws UnsupportedEncodingException 
+     */
+    public String regexCH(String str) throws UnsupportedEncodingException{
+    	StringBuffer s = new StringBuffer();
+    	Pattern pat = Pattern.compile("[\u4E00-\u9FA5]");
+        Matcher mat = pat.matcher(str);
+        while(mat.find()) {
+        	s.append(mat.group());
+        }
+        String url =  java.net.URLEncoder.encode(s.toString(), "utf-8");
+    	return str.replace(s.toString(), url);
+    }
+    
+    public static void main(String[] args) throws UnsupportedEncodingException{
+    	String ssString = "/UploadFiles/刘昌辉/Images/OnlineExam20140923161629.jpg";
+    	//String ss = regexCH(ssString);
+    	//System.out.println(ss);
+    }
+}

+ 201 - 0
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/ImgDataUtils.java

@@ -0,0 +1,201 @@
+/*
+ * *************************************************
+ * Created by Deason on 2018-07-23 17:32:42.
+ * *************************************************
+ */
+package cn.com.qmth.examcloud.core.questions.service.temp;
+import org.apache.commons.codec.binary.Base64;
+
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class ImgDataUtils {
+
+    public static void main(String[] args) throws UnsupportedEncodingException {
+        /*String html = "ss<img src=\"http://fanyi.bdstatic.com/static/translation/img/header/logo_cbfea26.png\"/>aa"
+                + "sss<img src=\"http://fanyi.bdstatic.com/static/translation/pkg/index_z_15cc24c.png\"/>ss";*/
+    	String html = "in its&nbsp;<img class=\"UnderLine15\" src=\"/Shared/UnderLine?index=1\" alt=\"\" />area."
+    			+"in its&nbsp;<img class=\"UnderLine15\" src=\"/Shared/UnderLine?index=1\" alt=\"\" />area. People could"
+    			+"nbsp;<img class=\"UnderLine15\" src=\"/Shared/UnderLine?index=2\" alt=\"\" />&nbsp;than they cou"
+    			+"that led to downtown.<br /><img class=\"UnderLine15\" src=\"/Shared/UnderLine?index=3\" alt=\"\" />&nb,"
+    			+"people&nbsp;<img class=\"UnderLine15\" src=\"/Shared/UnderLine?index=4\" alt=\"\" />&nbsp;";
+        List<String> srcList = parseImages(html);
+        /*for (String src : srcList) {
+            System.out.println(src);
+            src = "http://ncexam.cug.edu.cn/UploadFiles/%E5%88%98%E6%98%8C%E8%BE%89/Images/OnlineExam20140923161629.jpg";
+            //http://ncexam.cug.edu.cn%2FUploadFiles%2F %E5%88%98%E6%98%8C%E8%BE%89%2FImages%2FOnlineExam20140923161629.jpg
+            String base64 = loadImageToBase64(src);
+            //System.out.println(base64);
+            List<String> parseImageSrc = parseImageSrc(src);
+            System.out.println(parseImageSrc.get(0));
+            
+            
+        }*/
+        String ssString = "/UploadFiles/刘昌辉/Images/OnlineExam20140923161629.jpg";
+        //String ssString =  java.net.URLEncoder.encode("刘昌辉/Images/OnlineExam20140923161629.jpg", "GBK");
+        System.out.println(ssString);
+       
+        String testTxt = "8个文件";
+        Pattern pat = Pattern.compile("[\u4E00-\u9FA5]");
+        Matcher mat = pat.matcher(ssString);
+        while(mat.find()) {
+        	System.out.println(mat.group());
+        }
+        String ss =  java.net.URLEncoder.encode("刘昌辉", "utf-8");
+        System.out.println(ss);
+    }
+
+    /**
+     * 获取html中所有图片的src地址
+     */
+    public static List<String> parseImageSrc(String content) {
+        if (content == null) {
+            return new ArrayList<>();
+        }
+        List<String> images = new ArrayList<>();
+        String reg = "(<img.*src\\s*=\\s*(.*?)[^>]*?>)";
+        Pattern pattern = Pattern.compile(reg, Pattern.CASE_INSENSITIVE);
+        Matcher matcher = pattern.matcher(content);
+        while (matcher.find()) {
+            String img = matcher.group();
+            Matcher m = Pattern.compile("src\\s*=\\s*\"?(.*?)(\"|>|\\s+)").matcher(img);
+            while (m.find()) {
+                images.add(m.group(1));
+            }
+        }
+        return images;
+    }
+
+    /**
+     * 获取html中所有图片标签
+     */
+    public static List<String> parseImages(String content) {
+        if (content == null) {
+            return new ArrayList<>();
+        }
+        List<String> images = new ArrayList<>();
+        String reg = "<(img|IMG)(.*?)(/>|></img>|>)";
+        Pattern pattern = Pattern.compile(reg, Pattern.CASE_INSENSITIVE);
+        Matcher matcher = pattern.matcher(content);
+        while (matcher.find()) {
+            String img = matcher.group();
+            images.add(img);
+        }
+        return images;
+    }
+    
+    /**
+     * 获取网络图片的流数据,并base64编码
+     */
+    public static String loadImageToBase64(String imgUrl) {
+        byte[] data = loadImage(imgUrl);
+        if (data == null) {
+            return null;
+        }
+        return convertDataToBase64(data);
+    }
+
+    /**
+     * 获取网络图片的流数据,并保存到文件
+     */
+    public static void loadImageToFile(String imgUrl, String filePath) {
+        byte[] data = loadImage(imgUrl);
+        if (data == null) {
+            return;
+        }
+        convertDataToFile(data, filePath);
+    }
+
+    /**
+     * 获取网络图片的流数据(不支持https)
+     */
+    public static byte[] loadImage(String imgUrl) {
+        HttpURLConnection conn = null;
+        try {
+            URL url = new URL(imgUrl);
+            conn = (HttpURLConnection) url.openConnection();
+            conn.setRequestMethod("GET");
+            conn.setConnectTimeout(10 * 1000);//超时响应时间为10秒
+            InputStream inStream = conn.getInputStream();
+            return readInputStream(inStream);//得到图片的二进制数据
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        } finally {
+            if (conn != null) {
+                conn.disconnect();
+            }
+        }
+    }
+
+    public static String convertDataToBase64(byte[] data) {
+        try {
+            return Base64.encodeBase64String(data);
+        } catch (Exception e) {
+            return null;
+        }
+    }
+
+    public static byte[] convertBase64ToData(String data) {
+        try {
+            return Base64.decodeBase64(data);
+        } catch (Exception e) {
+            return null;
+        }
+    }
+
+    public static void convertDataToFile(byte[] data, String filePath) {
+        if (data == null) {
+            return;
+        }
+        FileOutputStream outStream = null;
+        try {
+            File imageFile = new File(filePath);
+            outStream = new FileOutputStream(imageFile);
+            outStream.write(data);
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                if (outStream != null) {
+                    outStream.close();
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    public static byte[] readInputStream(InputStream inStream) {
+        if (inStream == null) {
+            return null;
+        }
+        try {
+            int len;
+            byte[] bytes = new byte[1024];
+            ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+            while ((len = inStream.read(bytes)) != -1) {
+                outStream.write(bytes, 0, len);
+            }
+            return outStream.toByteArray();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                if (inStream != null) {
+                    inStream.close();
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return null;
+    }
+
+}

+ 62 - 0
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/TestFillAnswer.java

@@ -0,0 +1,62 @@
+package cn.com.qmth.examcloud.core.questions.service.temp.vo;
+
+import java.util.List;
+
+/**
+ * @author 		weiwenhai
+ * @date		2018.7.22
+ * @company	 	qmth
+ * @describle	填空题答案对象
+ */
+public class TestFillAnswer {
+
+	private String ID;
+	
+	/**
+	 * 填空题答案
+	 */
+	private List<TestFillContent> Answers;
+	
+	/**
+	 * 选词填空题答案
+	 */
+	private String AnswerId;
+	
+	/**
+	 * 完形填空选项
+	 */
+	private TestOptionGroup OptionGroup;
+
+	public String getID() {
+		return ID;
+	}
+
+	public void setID(String iD) {
+		ID = iD;
+	}
+
+	public List<TestFillContent> getAnswers() {
+		return Answers;
+	}
+
+	public void setAnswers(List<TestFillContent> answers) {
+		Answers = answers;
+	}
+
+	public String getAnswerId() {
+		return AnswerId;
+	}
+
+	public void setAnswerId(String answerId) {
+		AnswerId = answerId;
+	}
+
+	public TestOptionGroup getOptionGroup() {
+		return OptionGroup;
+	}
+
+	public void setOptionGroup(TestOptionGroup optionGroup) {
+		OptionGroup = optionGroup;
+	}
+	
+}

+ 21 - 0
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/TestFillContent.java

@@ -0,0 +1,21 @@
+package cn.com.qmth.examcloud.core.questions.service.temp.vo;
+
+/**
+ * @author 		weiwenhai
+ * @date		2018.7.22
+ * @company		qmth
+ * @describle	填空题文本对象
+ */
+public class TestFillContent {
+
+	private String Content;
+
+	public String getContent() {
+		return Content;
+	}
+
+	public void setContent(String content) {
+		Content = content;
+	}
+	
+}

+ 44 - 0
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/TestOption.java

@@ -0,0 +1,44 @@
+package cn.com.qmth.examcloud.core.questions.service.temp.vo;
+
+public class TestOption {
+
+	/**
+	 * ID
+	 */
+	private String ID;
+	
+	/**
+	 * 选项Html
+	 */
+	private String OptionHTML;
+	
+	/**
+	 * 选项文本
+	 */
+	private String OptionTXT;
+
+	public String getID() {
+		return ID;
+	}
+
+	public void setID(String iD) {
+		ID = iD;
+	}
+
+	public String getOptionHTML() {
+		return OptionHTML;
+	}
+
+	public void setOptionHTML(String optionHTML) {
+		OptionHTML = optionHTML;
+	}
+
+	public String getOptionTXT() {
+		return OptionTXT;
+	}
+
+	public void setOptionTXT(String optionTXT) {
+		OptionTXT = optionTXT;
+	}
+
+}

+ 26 - 0
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/TestOptionGroup.java

@@ -0,0 +1,26 @@
+package cn.com.qmth.examcloud.core.questions.service.temp.vo;
+
+import java.util.List;
+
+/**
+ * @author 		weiwenhai
+ * @date 		2018.7.23
+ * @company		qmth
+ * @describle	选词填空选项组
+ */
+public class TestOptionGroup {
+
+	/**
+	 * 选词填空选项集合
+	 */
+	private List<TestOption> Options;
+
+	public List<TestOption> getOptions() {
+		return Options;
+	}
+
+	public void setOptions(List<TestOption> options) {
+		Options = options;
+	}
+	
+}

+ 63 - 0
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/TestPaper.java

@@ -0,0 +1,63 @@
+package cn.com.qmth.examcloud.core.questions.service.temp.vo;
+
+/**
+ * @author 		weiwenhai
+ * @date		2018.7.19
+ * @company 	qmth
+ * @describle	地大试卷对象
+ */
+public class TestPaper {
+
+	/**
+	 * id
+	 */
+	private String id;
+	
+	/**
+	 * 试卷名称
+	 */
+	private String name;
+	
+	/**
+	 * 试卷详情
+	 */
+	private String testPaperContentId;
+	
+	/**
+	 * 试卷总分
+	 */
+	private Double score;
+	
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public String getTestPaperContentId() {
+		return testPaperContentId;
+	}
+
+	public void setTestPaperContentId(String testPaperContentId) {
+		this.testPaperContentId = testPaperContentId;
+	}
+
+	public Double getScore() {
+		return score;
+	}
+
+	public void setScore(Double score) {
+		this.score = score;
+	}
+	
+}

+ 116 - 0
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/TestQuestion.java

@@ -0,0 +1,116 @@
+package cn.com.qmth.examcloud.core.questions.service.temp.vo;
+
+/**
+ * @author 		weiwenhai
+ * @date		2018.7.19
+ * @company		qmth
+ * @describle	地大试题对象
+ */
+public class TestQuestion {
+
+	/**
+	 * 试题id
+	 */
+	private String id;
+	
+	/**
+	 * 大题序号
+	 */
+	private Integer dNumber;
+	
+	/**
+	 * 大题名称
+	 */
+	private String dName;
+	
+	/**
+	 * 小题序号
+	 */
+	private Integer number;
+	
+	/**
+	 * 小题分数
+	 */
+	private Double score;
+	
+	/**
+	 * 小题父id,用于套题
+	 */
+	private String parentId;
+	
+	/**
+	 * 小题类型
+	 * 11-单选题;12-多选题;13-填空题;14-选词填空;15-完形填空;20-判断题;42-复合题;60-问答题;69-名词解释
+	 */
+	private Integer type;
+	
+	/**
+	 * 试题内容
+	 */
+	private String json;
+
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	public Integer getdNumber() {
+		return dNumber;
+	}
+
+	public void setdNumber(Integer dNumber) {
+		this.dNumber = dNumber;
+	}
+
+	public String getdName() {
+		return dName;
+	}
+
+	public void setdName(String dName) {
+		this.dName = dName;
+	}
+
+	public Integer getNumber() {
+		return number;
+	}
+
+	public void setNumber(Integer number) {
+		this.number = number;
+	}
+
+	public Double getScore() {
+		return score;
+	}
+
+	public void setScore(Double score) {
+		this.score = score;
+	}
+
+	public String getParentId() {
+		return parentId;
+	}
+
+	public void setParentId(String parentId) {
+		this.parentId = parentId;
+	}
+
+	public Integer getType() {
+		return type;
+	}
+
+	public void setType(Integer type) {
+		this.type = type;
+	}
+
+	public String getJson() {
+		return json;
+	}
+
+	public void setJson(String json) {
+		this.json = json;
+	}
+	
+}

+ 191 - 0
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/TestQuestionInfo.java

@@ -0,0 +1,191 @@
+package cn.com.qmth.examcloud.core.questions.service.temp.vo;
+
+import java.util.List;
+
+public class TestQuestionInfo {
+
+	/**
+	 * ID
+	 */
+	private String ID;
+	
+	/**
+	 * 试题类型
+	 * 11-单选题;12-多选题;13-填空题;14-选词填空;15-完形填空;
+	 * 20-判断题;42-复合题;60-问答题;69-名词解释
+	 */
+	private int QuestionType;
+	
+	/**
+	 * 答案 (问答题)
+	 */
+	private String Answer;
+
+	/**
+	 * 创建时间
+	 */
+	private String CreateTime;
+	
+	/**
+	 * 父id(用于套题-42)
+	 */
+	private String ParentId;
+	
+	/**
+	 * QuestionInfoId
+	 */
+	private String QuestionInfoId;
+	
+	/**
+	 * 题干HTML
+	 */
+	private String QuestionHTML;
+	
+	/**
+	 * 题干文本
+	 */
+	private String QuestionTXT;
+	
+	/**
+	 * 答案提示
+	 */
+	private String AnswerTips;
+	
+	/**
+	 * 选项
+	 */
+	private List<TestOption> Options;
+	
+	/**
+	 * 答案ID对应  选择题选项的答案
+	 */
+	private String AnswerId;
+	
+	/**
+	 * 多选题答案集合
+	 */
+	private List<String> Answers;
+	
+	/**
+	 * 填空题答案
+	 */
+	private List<TestFillAnswer> Blanks;
+	
+	/**
+	 * 选词填空选项组
+	 */
+	private TestOptionGroup OptionGroup;
+
+	public String getID() {
+		return ID;
+	}
+
+	public void setID(String iD) {
+		ID = iD;
+	}
+
+	public int getQuestionType() {
+		return QuestionType;
+	}
+
+	public void setQuestionType(int questionType) {
+		QuestionType = questionType;
+	}
+
+	public String getAnswer() {
+		return Answer;
+	}
+
+	public void setAnswer(String answer) {
+		Answer = answer;
+	}
+
+	public String getCreateTime() {
+		return CreateTime;
+	}
+
+	public void setCreateTime(String createTime) {
+		CreateTime = createTime;
+	}
+
+	public String getParentId() {
+		return ParentId;
+	}
+
+	public void setParentId(String parentId) {
+		ParentId = parentId;
+	}
+
+	public String getQuestionInfoId() {
+		return QuestionInfoId;
+	}
+
+	public void setQuestionInfoId(String questionInfoId) {
+		QuestionInfoId = questionInfoId;
+	}
+
+	public String getQuestionHTML() {
+		return QuestionHTML;
+	}
+
+	public void setQuestionHTML(String questionHTML) {
+		QuestionHTML = questionHTML;
+	}
+
+	public String getQuestionTXT() {
+		return QuestionTXT;
+	}
+
+	public void setQuestionTXT(String questionTXT) {
+		QuestionTXT = questionTXT;
+	}
+
+	public String getAnswerTips() {
+		return AnswerTips;
+	}
+
+	public void setAnswerTips(String answerTips) {
+		AnswerTips = answerTips;
+	}
+
+	public List<TestOption> getOptions() {
+		return Options;
+	}
+
+	public void setOptions(List<TestOption> options) {
+		Options = options;
+	}
+
+	public String getAnswerId() {
+		return AnswerId;
+	}
+
+	public void setAnswerId(String answerId) {
+		AnswerId = answerId;
+	}
+
+	public List<String> getAnswers() {
+		return Answers;
+	}
+
+	public void setAnswers(List<String> answers) {
+		Answers = answers;
+	}
+
+	public List<TestFillAnswer> getBlanks() {
+		return Blanks;
+	}
+
+	public void setBlanks(List<TestFillAnswer> blanks) {
+		Blanks = blanks;
+	}
+
+	public TestOptionGroup getOptionGroup() {
+		return OptionGroup;
+	}
+
+	public void setOptionGroup(TestOptionGroup optionGroup) {
+		OptionGroup = optionGroup;
+	}
+
+}

+ 1 - 1
examcloud-core-questions-starter/src/main/resources/application-dev.properties

@@ -3,7 +3,7 @@ spring.data.mongodb.uri=mongodb://192.168.10.30:27017/comm-ques-bank
 spring.data.mongodb.grid-fs-database=comm-ques-bank
 spring.data.mongodb.database=comm-ques-bank
 eureka.client.serviceUrl.defaultZone=http://192.168.10.30:1111/eureka/
-spring.application.name=ExamCloud-service-question
+spring.application.name=weiwenhai-ExamCloud-service-question
 
 spring.redis.host=192.168.10.30
 spring.redis.port=6379

+ 66 - 0
examcloud-core-questions-starter/src/test/java/cn/com/qmth/examcloud/core/questions/starter/DdCollegeUtilTest.java

@@ -0,0 +1,66 @@
+package cn.com.qmth.examcloud.core.questions.starter;
+
+import java.util.List;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import cn.com.qmth.examcloud.core.questions.service.temp.DdCollegeUtilService;
+import cn.com.qmth.examcloud.core.questions.service.temp.vo.TestOption;
+import cn.com.qmth.examcloud.core.questions.service.temp.vo.TestPaper;
+import cn.com.qmth.examcloud.core.questions.service.temp.vo.TestQuestion;
+
+/**
+ * @author 		weiwenhai
+ * @date 		2018.7.19
+ * @company		qmth
+ * @describle	测试地大题库导入
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class DdCollegeUtilTest {
+
+	@Autowired
+	private DdCollegeUtilService ddCollegeUtilService;
+	
+	@Test
+	public void testPapers() {
+		/*String codeName = "基础工程学/D06020008";
+		List<TestPaper> testPapers = ddCollegeUtilService.queryByCourse(codeName);
+		for(TestPaper testPaper:testPapers){
+			System.out.println(testPaper.toString());
+		}*/
+		try {
+			ddCollegeUtilService.importPaper("109", "000001");
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		List<TestQuestion> list = ddCollegeUtilService.querySubQuestions("24AE438A37B67D7F0430D434A9D0C929");
+		System.out.println(list);
+	}
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+}
+
+
+