|
@@ -2,14 +2,25 @@ package com.qmth.cqb.paper.service.export;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.Collections;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.HashSet;
|
|
import java.util.HashSet;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
+import javax.xml.bind.JAXBElement;
|
|
|
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.docx4j.XmlUtils;
|
|
|
|
+import org.docx4j.jaxb.Context;
|
|
|
|
+import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
|
|
|
|
+import org.docx4j.wml.Body;
|
|
|
|
+import org.docx4j.wml.P;
|
|
|
|
+import org.docx4j.wml.R;
|
|
|
|
+import org.docx4j.wml.Text;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -57,41 +68,36 @@ public abstract class ExportPaperAbstractService {
|
|
@Autowired
|
|
@Autowired
|
|
QuesRepo quesRepo;
|
|
QuesRepo quesRepo;
|
|
|
|
|
|
- @Autowired
|
|
|
|
- ExportPaperService exportPaperService;
|
|
|
|
|
|
+ private static final String FILL_BLANK_QUESTION_FLAG = "###";
|
|
|
|
|
|
public static Configuration CONFIGURATION;
|
|
public static Configuration CONFIGURATION;
|
|
|
|
|
|
public static final String ENCODING = "UTF-8";
|
|
public static final String ENCODING = "UTF-8";
|
|
|
|
|
|
|
|
+ //陕西师范模板
|
|
protected static Template SXSF_TEMPLATE_PAPER;
|
|
protected static Template SXSF_TEMPLATE_PAPER;
|
|
-
|
|
|
|
protected static Template SXSF_TEMPLATE_ANSWER;
|
|
protected static Template SXSF_TEMPLATE_ANSWER;
|
|
-
|
|
|
|
|
|
+ //电子科大模板
|
|
protected static Template DZKD_TEMPLATE_PAPER;
|
|
protected static Template DZKD_TEMPLATE_PAPER;
|
|
-
|
|
|
|
protected static Template DZKD_TEMPLATE_ANSWER;
|
|
protected static Template DZKD_TEMPLATE_ANSWER;
|
|
-
|
|
|
|
- protected static Template TEMPLATE_NORMAL;
|
|
|
|
|
|
+ //石油大学模板
|
|
|
|
+ protected static Template SYDX_TEMPLATE_NORMAL;
|
|
|
|
|
|
static {
|
|
static {
|
|
try {
|
|
try {
|
|
- logger.info("*********************试卷导出设置初始化start**************************");
|
|
|
|
CONFIGURATION = new Configuration(Configuration.VERSION_2_3_25);
|
|
CONFIGURATION = new Configuration(Configuration.VERSION_2_3_25);
|
|
// 设置编码
|
|
// 设置编码
|
|
CONFIGURATION.setDefaultEncoding(ENCODING);
|
|
CONFIGURATION.setDefaultEncoding(ENCODING);
|
|
// 设置ftl模板路径
|
|
// 设置ftl模板路径
|
|
CONFIGURATION.setClassForTemplateLoading(DocxProcessUtil.class, "/");
|
|
CONFIGURATION.setClassForTemplateLoading(DocxProcessUtil.class, "/");
|
|
|
|
|
|
- //陕西师范模板
|
|
|
|
SXSF_TEMPLATE_PAPER = CONFIGURATION.getTemplate("sxsf_paper_template.ftl", ENCODING);
|
|
SXSF_TEMPLATE_PAPER = CONFIGURATION.getTemplate("sxsf_paper_template.ftl", ENCODING);
|
|
SXSF_TEMPLATE_ANSWER = CONFIGURATION.getTemplate("sxsf_answer_template.ftl", ENCODING);
|
|
SXSF_TEMPLATE_ANSWER = CONFIGURATION.getTemplate("sxsf_answer_template.ftl", ENCODING);
|
|
- //电子科大模板
|
|
|
|
|
|
+
|
|
DZKD_TEMPLATE_PAPER = CONFIGURATION.getTemplate("dzkd_paper_template.ftl", ENCODING);
|
|
DZKD_TEMPLATE_PAPER = CONFIGURATION.getTemplate("dzkd_paper_template.ftl", ENCODING);
|
|
DZKD_TEMPLATE_ANSWER = CONFIGURATION.getTemplate("dzkd_answer_template.ftl", ENCODING);
|
|
DZKD_TEMPLATE_ANSWER = CONFIGURATION.getTemplate("dzkd_answer_template.ftl", ENCODING);
|
|
|
|
|
|
- TEMPLATE_NORMAL = CONFIGURATION.getTemplate("paper_template.ftl", ENCODING);
|
|
|
|
- logger.info("*********************试卷导出设置初始化end**************************");
|
|
|
|
|
|
+ SYDX_TEMPLATE_NORMAL = CONFIGURATION.getTemplate("paper_template.ftl", ENCODING);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
@@ -149,9 +155,8 @@ public abstract class ExportPaperAbstractService {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- } else if (paperDetailUnits.get(0).getQuestionType() == QuesStructType.TEXT_ANSWER_QUESTION) {
|
|
|
|
- hasTextAnswer = true;
|
|
|
|
- } else if (paperDetailUnits.get(0).getQuestionType() == QuesStructType.FILL_BLANK_QUESTION) {
|
|
|
|
|
|
+ } else if (paperDetailUnits.get(0).getQuestionType() == QuesStructType.TEXT_ANSWER_QUESTION
|
|
|
|
+ ||paperDetailUnits.get(0).getQuestionType() == QuesStructType.FILL_BLANK_QUESTION) {
|
|
hasTextAnswer = true;
|
|
hasTextAnswer = true;
|
|
}
|
|
}
|
|
if (hasTextAnswer) {
|
|
if (hasTextAnswer) {
|
|
@@ -194,15 +199,9 @@ public abstract class ExportPaperAbstractService {
|
|
String totalScore = BigDecimal.valueOf(paperDetailExp.getScore()).stripTrailingZeros().toPlainString();
|
|
String totalScore = BigDecimal.valueOf(paperDetailExp.getScore()).stripTrailingZeros().toPlainString();
|
|
String unitScore = BigDecimal.valueOf(paperDetailExp.getPaperDetailUnits().get(0).getScore()).stripTrailingZeros().toPlainString();
|
|
String unitScore = BigDecimal.valueOf(paperDetailExp.getPaperDetailUnits().get(0).getScore()).stripTrailingZeros().toPlainString();
|
|
QuesStructType type = paperDetailExp.getPaperDetailUnits().get(0).getQuestionType();
|
|
QuesStructType type = paperDetailExp.getPaperDetailUnits().get(0).getQuestionType();
|
|
- String scoreString = "";
|
|
|
|
- if (type == QuesStructType.FILL_BLANK_QUESTION) {
|
|
|
|
- scoreString = checkPaperDetailUnitScore(paperDetailExp) ? "每空"+ unitScore + "分" : "";
|
|
|
|
- } else {
|
|
|
|
- scoreString = checkPaperDetailUnitScore(paperDetailExp) ? "每小题"+ unitScore + "分" : "";
|
|
|
|
- }
|
|
|
|
|
|
+ String scoreString = checkPaperDetailUnitScore(paperDetailExp) ? "每小题"+ unitScore + "分" : "";
|
|
if (type == QuesStructType.SINGLE_ANSWER_QUESTION) {
|
|
if (type == QuesStructType.SINGLE_ANSWER_QUESTION) {
|
|
paperDetailExp.setName("单项选择题");
|
|
paperDetailExp.setName("单项选择题");
|
|
-
|
|
|
|
title = "(本大题共" + paperDetailExp.getUnitCount() + "小题,"
|
|
title = "(本大题共" + paperDetailExp.getUnitCount() + "小题,"
|
|
+ scoreString + "共" + totalScore + "分)。"
|
|
+ scoreString + "共" + totalScore + "分)。"
|
|
+ "在每小题列出的四个备选中只有一个符合题目要求的,请将其选出并将“答题卡”的相应代码涂黑,错涂、多涂或未涂均无分";
|
|
+ "在每小题列出的四个备选中只有一个符合题目要求的,请将其选出并将“答题卡”的相应代码涂黑,错涂、多涂或未涂均无分";
|
|
@@ -212,14 +211,14 @@ public abstract class ExportPaperAbstractService {
|
|
} else if (type == QuesStructType.FILL_BLANK_QUESTION) {
|
|
} else if (type == QuesStructType.FILL_BLANK_QUESTION) {
|
|
paperDetailExp.setName("填空题");
|
|
paperDetailExp.setName("填空题");
|
|
int blankNum = 0;
|
|
int blankNum = 0;
|
|
- for (PaperDetailUnitExp unit : paperDetailExp.getPaperDetailUnits()) {
|
|
|
|
- String tempStr = unit.getQuestion().getQuesBody().replaceAll("###", "");
|
|
|
|
- int lenTimes = (unit.getQuestion().getQuesBody().length() - tempStr.length()) / "###".length();// 出现的次数
|
|
|
|
|
|
+ for (PaperDetailUnitExp unit:paperDetailExp.getPaperDetailUnits()){
|
|
|
|
+ String tempStr = unit.getQuestion().getQuesBody().replaceAll(FILL_BLANK_QUESTION_FLAG, "");
|
|
|
|
+ int lenTimes = (unit.getQuestion().getQuesBody().length() - tempStr.length()) / FILL_BLANK_QUESTION_FLAG.length();// 出现的次数
|
|
blankNum += lenTimes;
|
|
blankNum += lenTimes;
|
|
}
|
|
}
|
|
- title = "(本大题共" + blankNum + "个空格,将每空答在答题卡 “1—" + blankNum+ "”相应的序号上。" + scoreString + "共" + totalScore + "分)";
|
|
|
|
|
|
+ title = "(本大题共"+blankNum+"个空格,将每空答在答题卡 “1—" +blankNum+"”相应的序号上。"+"共"+totalScore + "分)";
|
|
} else {
|
|
} else {
|
|
- title = "(本大题共" + paperDetailExp.getUnitCount() + "小题,"+ scoreString + "共" + totalScore + "分)";
|
|
|
|
|
|
+ title = "(本大题共"+paperDetailExp.getUnitCount()+"小题,"+scoreString+"共"+totalScore+"分)";
|
|
}
|
|
}
|
|
paperDetailExp.setTitle(title);
|
|
paperDetailExp.setTitle(title);
|
|
}
|
|
}
|
|
@@ -247,7 +246,7 @@ public abstract class ExportPaperAbstractService {
|
|
if (optionList != null && optionList.size() > 0) {
|
|
if (optionList != null && optionList.size() > 0) {
|
|
int index = 0;
|
|
int index = 0;
|
|
for (QuesOption quesOption : optionList) {
|
|
for (QuesOption quesOption : optionList) {
|
|
- quesOption.setOptionBodyWord(exportPaperService.setOptionNum(quesOption.getOptionBodyWord(),exportPaperService.getOptionNum(index)));
|
|
|
|
|
|
+ quesOption.setOptionBodyWord(setOptionNum(quesOption.getOptionBodyWord(),getOptionNum(index)));
|
|
index++;
|
|
index++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -255,28 +254,248 @@ public abstract class ExportPaperAbstractService {
|
|
Question question = paperDetailUnit.getQuestion();
|
|
Question question = paperDetailUnit.getQuestion();
|
|
// 套题序号
|
|
// 套题序号
|
|
if (subQuesList != null && subQuesList.size() > 0) {
|
|
if (subQuesList != null && subQuesList.size() > 0) {
|
|
- question.setQuesBodyWord(exportPaperService.replaceQuesBlank(question.getQuesBodyWord(),subNum + 1));
|
|
|
|
|
|
+ question.setQuesBodyWord(replaceQuesBlank(question.getQuesBodyWord(),subNum + 1));
|
|
for (Question subQues : subQuesList) {
|
|
for (Question subQues : subQuesList) {
|
|
int curSubNum = ++subNum;
|
|
int curSubNum = ++subNum;
|
|
- subQues.setQuesBodyWord(exportPaperService.setSubQuesNum(subQues.getQuesBodyWord(),curSubNum));
|
|
|
|
- subQues.setQuesAnswerWord(exportPaperService.setSubQuesNum(subQues.getQuesAnswerWord(),curSubNum));
|
|
|
|
- subQues.setQuesBodyWord(exportPaperService.replaceQuesBlank(subQues.getQuesBodyWord(),curSubNum));
|
|
|
|
|
|
+ subQues.setQuesBodyWord(setSubQuesNum(subQues.getQuesBodyWord(),curSubNum));
|
|
|
|
+ subQues.setQuesAnswerWord(setSubQuesNum(subQues.getQuesAnswerWord(),curSubNum));
|
|
|
|
+ subQues.setQuesBodyWord(replaceQuesBlank(subQues.getQuesBodyWord(),curSubNum));
|
|
List<QuesOption> subOptionList = subQues.getQuesOptions();
|
|
List<QuesOption> subOptionList = subQues.getQuesOptions();
|
|
if (subOptionList != null && subOptionList.size() > 0) {
|
|
if (subOptionList != null && subOptionList.size() > 0) {
|
|
int sub_index = 0;
|
|
int sub_index = 0;
|
|
for (QuesOption quesOption : subOptionList) {
|
|
for (QuesOption quesOption : subOptionList) {
|
|
- quesOption.setOptionBodyWord(exportPaperService.setOptionNum(quesOption.getOptionBodyWord(),exportPaperService.getOptionNum(sub_index)));
|
|
|
|
|
|
+ quesOption.setOptionBodyWord(setOptionNum(quesOption.getOptionBodyWord(),getOptionNum(sub_index)));
|
|
sub_index++;
|
|
sub_index++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
int curSubNum = ++subNum;
|
|
int curSubNum = ++subNum;
|
|
- question.setQuesBodyWord(exportPaperService.setSubQuesNum(question.getQuesBodyWord(), curSubNum));
|
|
|
|
- question.setQuesAnswerWord(exportPaperService.setSubQuesNum(question.getQuesAnswerWord(),curSubNum));
|
|
|
|
- question.setQuesBodyWord(exportPaperService.replaceQuesBlank(question.getQuesBodyWord(),curSubNum));
|
|
|
|
|
|
+ question.setQuesBodyWord(setSubQuesNum(question.getQuesBodyWord(), curSubNum));
|
|
|
|
+ question.setQuesAnswerWord(setSubQuesNum(question.getQuesAnswerWord(),curSubNum));
|
|
|
|
+ question.setQuesBodyWord(replaceQuesBlank(question.getQuesBodyWord(),curSubNum));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 替换填空
|
|
|
|
+ * 将###替换为下划线_______
|
|
|
|
+ * @param wordMl
|
|
|
|
+ * @param num
|
|
|
|
+ * @return
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ protected String replaceQuesBlank(String wordMl,int num) throws Exception {
|
|
|
|
+ String tmpStr = DocxProcessUtil.BODY_HEADER + wordMl + DocxProcessUtil.BODY_TAIL;
|
|
|
|
+ Body body = (Body)XmlUtils.unmarshalString(tmpStr,Context.jc,Body.class);
|
|
|
|
+ List<Object> pList = body.getContent();
|
|
|
|
+ int index = 0;
|
|
|
|
+ int cur = 0;
|
|
|
|
+ Map<Integer,String> curMap = new HashMap<Integer,String>();
|
|
|
|
+ for(Object pObj:pList){
|
|
|
|
+ if(pObj.getClass().equals(P.class)){
|
|
|
|
+ List<Object> pContent = ((P)pObj).getContent();
|
|
|
|
+ for(Object rObj:pContent){
|
|
|
|
+ if(rObj.getClass().equals(R.class)){
|
|
|
|
+ List<Object> rContent = ((R)rObj).getContent();
|
|
|
|
+ for(Object tObj:rContent){
|
|
|
|
+ if (tObj instanceof JAXBElement)
|
|
|
|
+ tObj = ((JAXBElement<?>) tObj).getValue();
|
|
|
|
+ if(tObj.getClass().equals(Text.class)){
|
|
|
|
+ Text text = (Text)tObj;
|
|
|
|
+ String str = text.getValue().trim();
|
|
|
|
+ if(str.equals("###")){
|
|
|
|
+ text.setValue("______");
|
|
|
|
+ }else if(str.equals("(###)")){
|
|
|
|
+ text.setValue("(______)");
|
|
|
|
+ }else if(str.equals("(###)")){
|
|
|
|
+ text.setValue("(______)");
|
|
|
|
+ }else if(str.matches("##\\d{1,}##")){
|
|
|
|
+ int curNum = num + index;
|
|
|
|
+ text.setValue("___"+(curNum)+"___");
|
|
|
|
+ index++;
|
|
|
|
+ }else if(str.startsWith("#") || str.equals("___")){
|
|
|
|
+ curMap.put(cur,str);
|
|
|
|
+ text.setValue("");
|
|
|
|
+ }else if(str.matches("^\\d{1,}$")){
|
|
|
|
+ String preStr = curMap.get(cur - 1);
|
|
|
|
+ if(!StringUtils.isEmpty(preStr) && preStr.startsWith("#")){
|
|
|
|
+ int curNum = num + index;
|
|
|
|
+ text.setValue("___"+(curNum)+"___");
|
|
|
|
+ index++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ cur++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ StringBuffer pWordMl = new StringBuffer();
|
|
|
|
+ for(Object pObj:pList){
|
|
|
|
+ if(pObj instanceof P){
|
|
|
|
+ pWordMl.append(DocxProcessUtil.formatPWordMl(XmlUtils.marshaltoString(pObj)));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return pWordMl.toString();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 初始化序号
|
|
|
|
+ * @param paperExp
|
|
|
|
+ */
|
|
|
|
+ public void initPaperNum(PaperExp paperExp)throws Exception{
|
|
|
|
+ if(paperExp.getPaperDetails() == null || paperExp.getPaperDetails().size() == 0){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ int mainNum = 0;
|
|
|
|
+ int subNum = 0;
|
|
|
|
+ Collections.sort(paperExp.getPaperDetails());
|
|
|
|
+ for(PaperDetailExp paperDetail: paperExp.getPaperDetails()){
|
|
|
|
+ //大题序号
|
|
|
|
+ paperDetail.setNumber(++mainNum);
|
|
|
|
+ paperDetail.setCnNum(CommonUtils.toCHNum(paperDetail.getNumber()));
|
|
|
|
+ if(paperDetail.getPaperDetailUnits() == null ||
|
|
|
|
+ paperDetail.getPaperDetailUnits().size() == 0){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ //小题序号
|
|
|
|
+ for(PaperDetailUnitExp paperDetailUnit:paperDetail.getPaperDetailUnits()){
|
|
|
|
+ List<QuesOption> optionList = paperDetailUnit.getQuestion().getQuesOptions();
|
|
|
|
+ if(optionList != null && optionList.size() > 0){
|
|
|
|
+ int index = 0;
|
|
|
|
+ for(QuesOption quesOption:optionList){
|
|
|
|
+ quesOption.setOptionBodyWord(setOptionNum(quesOption.getOptionBodyWord(),getOptionNum(index)));
|
|
|
|
+ index++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ List<Question> subQuesList = paperDetailUnit.getQuestion().getSubQuestions();
|
|
|
|
+ Question question = paperDetailUnit.getQuestion();
|
|
|
|
+ //套题序号
|
|
|
|
+ if(subQuesList != null && subQuesList.size() > 0){
|
|
|
|
+
|
|
|
|
+ question.setQuesBodyWord(replaceQuesBlank(question.getQuesBodyWord(),subNum + 1));
|
|
|
|
+
|
|
|
|
+ for(Question subQues:subQuesList){
|
|
|
|
+ int curSubNum = ++subNum;
|
|
|
|
+ subQues.setQuesBodyWord(setSubQuesNum(subQues.getQuesBodyWord(),curSubNum));
|
|
|
|
+ subQues.setQuesBodyWord(replaceQuesBlank(subQues.getQuesBodyWord(),curSubNum));
|
|
|
|
+ List<QuesOption> subOptionList = subQues.getQuesOptions();
|
|
|
|
+ if(subOptionList != null && subOptionList.size() > 0){
|
|
|
|
+ int sub_index = 0;
|
|
|
|
+ for(QuesOption quesOption:subOptionList){
|
|
|
|
+ quesOption.setOptionBodyWord(setOptionNum(quesOption.getOptionBodyWord(),getOptionNum(sub_index)));
|
|
|
|
+ sub_index++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ int curSubNum = ++subNum;
|
|
|
|
+ question.setQuesBodyWord(setSubQuesNum(question.getQuesBodyWord(),curSubNum));
|
|
|
|
+ question.setQuesBodyWord(replaceQuesBlank(question.getQuesBodyWord(),curSubNum));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public String getOptionNum(int number){
|
|
|
|
+ char optionNum = (char)(65 + number);
|
|
|
|
+ return String.valueOf(optionNum);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取当前试卷下所有试题WordPkg
|
|
|
|
+ * @param id
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public List<WordprocessingMLPackage> getPkgList(String id){
|
|
|
|
+ Paper paper = paperRepo.findOne(id);
|
|
|
|
+ List<WordprocessingMLPackage> wordMLPackages = paperDetailUnitRepo.findByPaper(paper)
|
|
|
|
+ .stream().map(PaperDetailUnit::getQuestion).collect(Collectors.toList())
|
|
|
|
+ .stream().map(Question::getPkgObj).collect(Collectors.toList());
|
|
|
|
+ return wordMLPackages;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 设置题号
|
|
|
|
+ * @param quesBodyWordMl
|
|
|
|
+ * @param num
|
|
|
|
+ * @return
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ public String setSubQuesNum(String quesBodyWordMl,int num) throws Exception {
|
|
|
|
+ String tmpStr = DocxProcessUtil.BODY_HEADER + quesBodyWordMl + DocxProcessUtil.BODY_TAIL;
|
|
|
|
+ Body body = (Body)XmlUtils.unmarshalString(tmpStr,
|
|
|
|
+ Context.jc,Body.class);
|
|
|
|
+ List<Object> pList = body.getContent();
|
|
|
|
+ int index = 0;
|
|
|
|
+ for(Object pObj:pList){
|
|
|
|
+ if(index > 0){
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ P p = (P) pObj;
|
|
|
|
+ List<Object> pContent = p.getContent();
|
|
|
|
+ R run = new R();
|
|
|
|
+ Text text = new Text();
|
|
|
|
+ text.setValue(num+". ");
|
|
|
|
+ run.getContent().add(text);
|
|
|
|
+ pContent.add(0,run);
|
|
|
|
+ index++;
|
|
|
|
+ }
|
|
|
|
+ StringBuffer pWordMl = new StringBuffer();
|
|
|
|
+ for(Object pObj:pList){
|
|
|
|
+ if(pObj instanceof P){
|
|
|
|
+ pWordMl.append(DocxProcessUtil.formatPWordMl(XmlUtils.marshaltoString(pObj)));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return pWordMl.toString();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 设置选项号
|
|
|
|
+ * @param optionWordMl
|
|
|
|
+ * @param num
|
|
|
|
+ * @return
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ public String setOptionNum(String optionWordMl,String num) throws Exception {
|
|
|
|
+ String tmpStr = DocxProcessUtil.BODY_HEADER + optionWordMl + DocxProcessUtil.BODY_TAIL;
|
|
|
|
+ Body body = (Body)XmlUtils.unmarshalString(tmpStr,
|
|
|
|
+ Context.jc,Body.class);
|
|
|
|
+ List<Object> pList = body.getContent();
|
|
|
|
+ int index = 0;
|
|
|
|
+ for(Object pObj:pList){
|
|
|
|
+ if(index > 0){
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ P p = (P) pObj;
|
|
|
|
+ List<Object> pContent = p.getContent();
|
|
|
|
+ R run = new R();
|
|
|
|
+ Text text = new Text();
|
|
|
|
+ text.setValue(num+". ");
|
|
|
|
+ run.getContent().add(text);
|
|
|
|
+ pContent.add(0,run);
|
|
|
|
+ index++;
|
|
|
|
+ }
|
|
|
|
+ StringBuffer pWordMl = new StringBuffer();
|
|
|
|
+ for(Object pObj:pList){
|
|
|
|
+ if(pObj instanceof P){
|
|
|
|
+ pWordMl.append(DocxProcessUtil.formatPWordMl(XmlUtils.marshaltoString(pObj)));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return pWordMl.toString();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ protected void appendScore(List<PaperDetailExp> paperDetails){
|
|
|
|
+ for(PaperDetailExp paperDetailExp:paperDetails){
|
|
|
|
+ for (PaperDetailUnitExp paperDetailUnit : paperDetailExp.getPaperDetailUnits()) {
|
|
|
|
+ String scoreString = "("+paperDetailUnit.getScore()+"分)";
|
|
|
|
+ String questionBodyWord = paperDetailUnit.getQuestion().getQuesBodyWord();
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|