xiatian 5 éve
szülő
commit
dece59c9b3

+ 3 - 0
examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/entity/QuestionPkgPath.java

@@ -4,7 +4,10 @@ import cn.com.qmth.examcloud.core.questions.dao.entity.base.IdBase;
 
 /**
  * Created by songyue on 17/11/19.
+ * 
  */
+//新方案导出不存word字节信息
+@Deprecated
 public class QuestionPkgPath extends IdBase {
 
     private byte[] quesPkg;

+ 22 - 36
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/CqdxService.java

@@ -4,7 +4,6 @@ import java.io.File;
 import java.io.UnsupportedEncodingException;
 import java.math.BigDecimal;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
@@ -16,7 +15,6 @@ import javax.xml.parsers.DocumentBuilderFactory;
 
 import org.apache.commons.collections4.map.HashedMap;
 import org.apache.commons.lang3.StringUtils;
-import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -35,11 +33,9 @@ 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.base.word.DocxProcessUtil;
 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;
@@ -47,7 +43,6 @@ 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.QuesTypeNameService;
 import cn.com.qmth.examcloud.core.questions.service.impl.CourseService;
 import cn.com.qmth.examcloud.web.bootstrap.PropertyHolder;
@@ -67,8 +62,8 @@ public class CqdxService {
 	private PaperDetailRepo paperDetailRepo;
 	@Autowired
 	private PaperDetailUnitRepo paperDetailUnitRepo;
-	@Autowired
-	private QuesPkgPathRepo quesPkgPathRepo;
+//	@Autowired
+//	private QuesPkgPathRepo quesPkgPathRepo;
 	@Autowired
 	private QuesTypeNameService quesTypeNameService;
 
@@ -89,21 +84,21 @@ public class CqdxService {
 			// 大题集合
 			List<PaperDetail> paperDetails = initPaperDetails(paperInfoMap, paper, user);
 			// 试题---资源 对应关系
-			Map<Question, QuestionPkgPath> questionMaps = new HashMap<>();
+			List<Question> questionLists = new ArrayList<>();
 
 			// 定义小题集合
 			List<PaperDetailUnit> paperDetailUnits;
-			paperDetailUnits = initpaperDetailUnits(paper, paperDetails, questionMaps, paperInfoMap, course, user);
+			paperDetailUnits = initpaperDetailUnits(paper, paperDetails, questionLists, paperInfoMap, course, user);
 			if (paperDetailUnits == null) {
 				throw new StatusException("100001", "有错误的XML");
 			}
 
 			// 保存试题资源
 //			quesPkgPathRepo.saveAll(questionMaps.values());
-			for (Map.Entry<Question, QuestionPkgPath> entry : questionMaps.entrySet()) {
-				entry.getKey().setQuesPkgPathId(entry.getValue().getId());
-			}
-			quesRepo.saveAll(questionMaps.keySet());
+//			for (Map.Entry<Question, QuestionPkgPath> entry : questionMaps.entrySet()) {
+//				entry.getKey().setQuesPkgPathId(entry.getValue().getId());
+//			}
+			quesRepo.saveAll(questionLists);
 			paperRepo.save(paper);
 			paperDetailRepo.saveAll(paperDetails);
 			paperDetailUnitRepo.saveAll(paperDetailUnits);
@@ -441,7 +436,7 @@ public class CqdxService {
 
 	// 初始化小题集合
 	private List<PaperDetailUnit> initpaperDetailUnits(Paper paper, List<PaperDetail> paperDetails,
-			Map<Question, QuestionPkgPath> map, Map<Object, Object> paperInfoMap, Course course, User user)
+			List<Question> questionLists, Map<Object, Object> paperInfoMap, Course course, User user)
 			throws Exception {
 		List<PaperDetailUnit> paperDetailUnits = new ArrayList<PaperDetailUnit>();
 		int detailCount = paperDetails.size();
@@ -452,7 +447,7 @@ public class CqdxService {
 			Map<Object, Object> detailInfoMap = detailTemp.getQues();
 			int quesCount = detailInfoMap.size();
 			for (int j = 0; j < quesCount; j++) {
-				WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
+//				WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
 				QuestionsTemp quesTemp = (QuestionsTemp) detailInfoMap.get(String.valueOf(j + 1));
 				Question question = new Question();
 				question.setCreateTime(CommonUtils.getCurDateTime());
@@ -468,21 +463,18 @@ public class CqdxService {
 				String body = imgList(quesTemp.getBody());
 				question.setQuesBody(replaceBlank(body));
 				try {
-					question.setQuesBodyWord(
-							DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(question.getQuesBody())));
+//					question.setQuesBodyWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(question.getQuesBody())));
 				} catch (Exception e) {
 					log.error("错误题干信息:" + question.getQuesBody());
 					throw new IllegalArgumentException("题干信息错误!"+e.getMessage());
 				}
 				if (question.getQuestionType() == QuesStructType.BOOL_ANSWER_QUESTION) {
 					question.setQuesAnswer(quesTemp.getAnswer());
-					question.setQuesAnswerWord(DocxProcessUtil.html2Docx(wordMLPackage,
-							CommonUtils.formatHtml("<p>" + question.getQuesAnswer() + "</p>")));
+//					question.setQuesAnswerWord(DocxProcessUtil.html2Docx(wordMLPackage,CommonUtils.formatHtml("<p>" + question.getQuesAnswer() + "</p>")));
 				} else {
 					question.setQuesAnswer(imgList(quesTemp.getAnswer()));
 					try {
-						question.setQuesAnswerWord(DocxProcessUtil.html2Docx(wordMLPackage,
-								CommonUtils.formatHtml(question.getQuesAnswer())));
+//						question.setQuesAnswerWord(DocxProcessUtil.html2Docx(wordMLPackage,CommonUtils.formatHtml(question.getQuesAnswer())));
 					} catch (Exception e) {
 						log.error("错误答案信息:" + question.getQuesAnswer());
 						throw new IllegalArgumentException("答案信息错误!"+e.getMessage());
@@ -506,8 +498,7 @@ public class CqdxService {
 						}
 
 						try {
-							quesOption.setOptionBodyWord(DocxProcessUtil.html2Docx(wordMLPackage,
-									CommonUtils.formatHtml(quesOption.getOptionBody())));
+//							quesOption.setOptionBodyWord(DocxProcessUtil.html2Docx(wordMLPackage,CommonUtils.formatHtml(quesOption.getOptionBody())));
 						} catch (Exception e) {
 							log.error("错误的选项:" + quesOption.getOptionBody());
 							throw new IllegalArgumentException("选项信息错误!"+e.getMessage());
@@ -532,8 +523,7 @@ public class CqdxService {
 						}
 					}
 					question.setQuesAnswer("<p>" + answer + "</p>");
-					question.setQuesAnswerWord(
-							DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(question.getQuesAnswer())));
+//					question.setQuesAnswerWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(question.getQuesAnswer())));
 				}
 				// 存在子题
 				if (question.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION) {
@@ -556,11 +546,9 @@ public class CqdxService {
 						question.setQuesBody(replaceBlank(body));
 						subQuestion.setQuesBody(subBody);
 
-						subQuestion.setQuesBodyWord(DocxProcessUtil.html2Docx(wordMLPackage,
-								CommonUtils.formatHtml(subQuestion.getQuesBody())));
+//						subQuestion.setQuesBodyWord(DocxProcessUtil.html2Docx(wordMLPackage,CommonUtils.formatHtml(subQuestion.getQuesBody())));
 						subQuestion.setQuesAnswer(imgList(subQuesTmp.getAnswer()));
-						subQuestion.setQuesBodyWord(DocxProcessUtil.html2Docx(wordMLPackage,
-								CommonUtils.formatHtml(subQuestion.getQuesAnswer())));
+//						subQuestion.setQuesBodyWord(DocxProcessUtil.html2Docx(wordMLPackage,CommonUtils.formatHtml(subQuestion.getQuesAnswer())));
 						// 存在选项
 						if (subQuestion.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION
 								|| subQuestion.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION) {
@@ -578,8 +566,7 @@ public class CqdxService {
 									subQuesOption.setOptionBody(optionBody);
 								}
 
-								subQuesOption.setOptionBodyWord(DocxProcessUtil.html2Docx(wordMLPackage,
-										CommonUtils.formatHtml(subQuesOption.getOptionBody())));
+//								subQuesOption.setOptionBodyWord(DocxProcessUtil.html2Docx(wordMLPackage,CommonUtils.formatHtml(subQuesOption.getOptionBody())));
 								if (subQuestion.getQuesAnswer().contains(String.valueOf(k + 1))) {
 									subQuesOption.setIsCorrect((short) 1);
 								} else {
@@ -600,16 +587,15 @@ public class CqdxService {
 								}
 							}
 							subQuestion.setQuesAnswer(answer);
-							subQuestion.setQuesAnswerWord(DocxProcessUtil.html2Docx(wordMLPackage,
-									CommonUtils.formatHtml("<p>" + subQuestion.getQuesAnswer() + "</p>")));
+//							subQuestion.setQuesAnswerWord(DocxProcessUtil.html2Docx(wordMLPackage,CommonUtils.formatHtml("<p>" + subQuestion.getQuesAnswer() + "</p>")));
 						}
 						subQuestions.add(subQuestion);
 					}
 					question.setSubQuestions(subQuestions);
 				}
-				byte[] pkgByte = DocxProcessUtil.getPkgByte(wordMLPackage);
-				QuestionPkgPath quesPkgPath = new QuestionPkgPath(pkgByte);
-				map.put(question, quesPkgPath);
+//				byte[] pkgByte = DocxProcessUtil.getPkgByte(wordMLPackage);
+//				QuestionPkgPath quesPkgPath = new QuestionPkgPath(pkgByte);
+				questionLists.add(question);
 				// 包装小题
 				PaperDetailUnit paperDetailUnit = new PaperDetailUnit();
 				paperDetailUnit.setPaper(paper);