فهرست منبع

地大导入试卷bug,套题小题缺id和分数字段

xiatian 5 سال پیش
والد
کامیت
bdd312e7c2

+ 9 - 0
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/ImportDdCollegePaperService.java

@@ -27,6 +27,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 import cn.com.qmth.examcloud.api.commons.security.bean.User;
 import cn.com.qmth.examcloud.commons.exception.StatusException;
+import cn.com.qmth.examcloud.commons.util.Calculator;
 import cn.com.qmth.examcloud.commons.util.JsonUtil;
 import cn.com.qmth.examcloud.core.questions.base.CommonUtils;
 import cn.com.qmth.examcloud.core.questions.base.IdUtils;
@@ -394,9 +395,11 @@ public class ImportDdCollegePaperService {
                     TestQuestionInfo testQuestionInfo2 = JsonUtil.fromJson(testQuestion2.getJson(),
                             TestQuestionInfo.class);
                     Question subQuestion = new Question();
+                    subQuestion.setId(IdUtils.uuid());
                     subQuestion.setDifficulty("中");
                     subQuestion.setDifficultyDegree(0.5);
                     subQuestion.setPublicity(true);
+                    subQuestion.setScore(testQuestion2.getScore());
                     // 按试题分类初始化题干,答案,选项
                     initQuestionInfo(subQuestion, testQuestionInfo2, map, testQuestion2, dir, sheet);
                     subQues.add(subQuestion);
@@ -429,6 +432,12 @@ public class ImportDdCollegePaperService {
             // 获取所有选项
             List<TestFillAnswer> blanks = testQuestionInfo.getBlanks();
             List<Question> subQuestions = initSubQuestions(blanks, wordMLPackage);
+            if (blanks != null && blanks.size() > 0 && testQuestion.getScore() != null) {
+                double subScore = Calculator.divide(testQuestion.getScore(), blanks.size(), 1);
+                for (Question q : subQuestions) {
+                    q.setScore(subScore);
+                }
+            }
             question.setSubQuestions(subQuestions);
         }
         // 问答题 、 名词解释

+ 325 - 216
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/ExportPaperServiceImpl.java

@@ -1,5 +1,42 @@
 package cn.com.qmth.examcloud.core.questions.service.impl;
 
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.docx4j.Docx4J;
+import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
+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 com.google.common.collect.Lists;
+import com.google.gson.Gson;
+
 import cn.com.qmth.examcloud.commons.logging.ExamCloudLog;
 import cn.com.qmth.examcloud.commons.logging.ExamCloudLogFactory;
 import cn.com.qmth.examcloud.core.questions.base.CommonUtils;
@@ -9,9 +46,29 @@ import cn.com.qmth.examcloud.core.questions.base.SpringContextUtils;
 import cn.com.qmth.examcloud.core.questions.base.enums.ExamFileType;
 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.*;
-import cn.com.qmth.examcloud.core.questions.dao.entity.*;
-import cn.com.qmth.examcloud.core.questions.dao.entity.computerTestModel.*;
+import cn.com.qmth.examcloud.core.questions.dao.CoursePropertyRepo;
+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.QuestionAudioRepo;
+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.QuesProperty;
+import cn.com.qmth.examcloud.core.questions.dao.entity.Question;
+import cn.com.qmth.examcloud.core.questions.dao.entity.QuestionAudio;
+import cn.com.qmth.examcloud.core.questions.dao.entity.QuestionPkgPath;
+import cn.com.qmth.examcloud.core.questions.dao.entity.computerTestModel.Block;
+import cn.com.qmth.examcloud.core.questions.dao.entity.computerTestModel.ComputerTestOption;
+import cn.com.qmth.examcloud.core.questions.dao.entity.computerTestModel.ComputerTestPaper;
+import cn.com.qmth.examcloud.core.questions.dao.entity.computerTestModel.ComputerTestPaperDetail;
+import cn.com.qmth.examcloud.core.questions.dao.entity.computerTestModel.ComputerTestQuestion;
+import cn.com.qmth.examcloud.core.questions.dao.entity.computerTestModel.Section;
+import cn.com.qmth.examcloud.core.questions.dao.entity.computerTestModel.Sections;
 import cn.com.qmth.examcloud.core.questions.service.ExportPaperService;
 import cn.com.qmth.examcloud.core.questions.service.PaperDetailService;
 import cn.com.qmth.examcloud.core.questions.service.PaperService;
@@ -21,32 +78,7 @@ import cn.com.qmth.examcloud.core.questions.service.bean.dto.QuestionDistributeD
 import cn.com.qmth.examcloud.core.questions.service.config.SysProperty;
 import cn.com.qmth.examcloud.core.questions.service.converter.PrintExamPaperService;
 import cn.com.qmth.examcloud.core.questions.service.export.ExportPaperAbstractService;
-import com.google.common.collect.Lists;
-import com.google.gson.Gson;
 import main.java.com.UpYun;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.poi.ss.usermodel.Row;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.Workbook;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-import org.docx4j.Docx4J;
-import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
-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 javax.servlet.http.HttpServletResponse;
-import java.io.*;
-import java.util.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
-
 
 @Service("exportPaperService")
 public class ExportPaperServiceImpl implements ExportPaperService {
@@ -93,9 +125,11 @@ public class ExportPaperServiceImpl implements ExportPaperService {
     private SysProperty sysProperty;
 
     @Override
-    public void exportPaperFile(String paperId, String serviceName, String exportContentList, HttpServletResponse response, String loginName, String examType, String psw) throws Exception {
-        ExportPaperAbstractService exportPaperAbstractService = (ExportPaperAbstractService) SpringContextUtils.getBeanById(serviceName);
-        //根据试卷id查询试卷
+    public void exportPaperFile(String paperId, String serviceName, String exportContentList,
+            HttpServletResponse response, String loginName, String examType, String psw) throws Exception {
+        ExportPaperAbstractService exportPaperAbstractService = (ExportPaperAbstractService) SpringContextUtils
+                .getBeanById(serviceName);
+        // 根据试卷id查询试卷
         Paper paper = Model.of(paperRepo.findById(paperId));
 
         String zipFileName = loginName + System.currentTimeMillis() + "";
@@ -120,14 +154,17 @@ public class ExportPaperServiceImpl implements ExportPaperService {
             exportPaperAbstractService.downloadPaperAnswer(paperId, zipFileName);
         }
 
-        //下载考试说明	2018-2-27	weiwehai
-		/*if(examType.equals("offLine") && StringUtils.isNotBlank(paper.getExamRemark())){
-			downExamRemark(paper,zipFileName);
-		}*/
+        // 下载考试说明 2018-2-27 weiwehai
+        /*
+         * if(examType.equals("offLine") &&
+         * StringUtils.isNotBlank(paper.getExamRemark())){
+         * downExamRemark(paper,zipFileName); }
+         */
         log.debug("开始压缩成zip...");
         long startTime = System.currentTimeMillis();
         FileDisposeUtil.fileToZip(TEMP_FILE_EXP + File.separator + zipFileName, TEMP_FILE_EXP, zipFileName);
-        FileDisposeUtil.downloadFile(paper.getName() + "_" + paper.getCourse().getCode() + ".zip", TEMP_FILE_EXP + File.separator + zipFileName + ".zip", response);
+        FileDisposeUtil.downloadFile(paper.getName() + "_" + paper.getCourse().getCode() + ".zip",
+                TEMP_FILE_EXP + File.separator + zipFileName + ".zip", response);
         long endTime = System.currentTimeMillis();
         log.debug("下载zip耗时:" + (endTime - startTime) + "ms");
         deteleFolder(TEMP_FILE_EXP, zipFileName);
@@ -143,12 +180,13 @@ public class ExportPaperServiceImpl implements ExportPaperService {
      */
     @SuppressWarnings("unused")
     private void downExamRemark(Paper paper, String zipFileName) throws Exception {
-        //1.考试说明html转成word
+        // 1.考试说明html转成word
         String title = "<p style=\"text-align:center\"><span style=\"font-size:26px\"><span style=\"font-family:宋体\">考&nbsp;试&nbsp;说&nbsp;明</span></span></p>";
         WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
         DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(title + paper.getExamRemark()));
-        //2.导出考试说明word
-        File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + paper.getCourse().getCode() + TEMP_FILE_NAME);
+        // 2.导出考试说明word
+        File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + paper.getCourse().getCode()
+                + TEMP_FILE_NAME);
         Docx4J.save(wordMLPackage, file);
     }
 
@@ -170,28 +208,29 @@ public class ExportPaperServiceImpl implements ExportPaperService {
     private void downJson(Paper paper, String zipFileName) {
         ComputerTestPaper computerTestPaper = buildComputerTestPapers(paper);
         String jsonDirectory = TEMP_FILE_EXP + File.separator + "json";
-        //新建文件夹
+        // 新建文件夹
         File dirFile = new File(jsonDirectory);
         if (!dirFile.exists()) {
             dirFile.mkdirs();
         }
         makeComputerTestPaperToJsonFile(paper.getCourse().getCode(), computerTestPaper, jsonDirectory);
         downloadAudio(computerTestPaper, jsonDirectory);
-        //将文件夹打包成zip压缩包放在docxExport下
-        FileDisposeUtil.fileToZip(jsonDirectory, TEMP_FILE_EXP + File.separator + zipFileName, paper.getCourse().getCode() + "_" + paper.getName());
+        // 将文件夹打包成zip压缩包放在docxExport下
+        FileDisposeUtil.fileToZip(jsonDirectory, TEMP_FILE_EXP + File.separator + zipFileName,
+                paper.getCourse().getCode() + "_" + paper.getName());
     }
 
     private void downloadAudio(ComputerTestPaper computerTestPaper, String jsonDirectory) {
-        //取到所有大题
+        // 取到所有大题
         List<ComputerTestPaperDetail> details = computerTestPaper.getDetails();
         if (details != null && details.size() > 0) {
             for (ComputerTestPaperDetail detail : details) {
-                //取到所有小题集合
+                // 取到所有小题集合
                 List<ComputerTestQuestion> questions = detail.getQuestions();
                 if (questions != null && questions.size() > 0) {
                     for (ComputerTestQuestion question : questions) {
                         int bodyNum = 1;
-                        //取到题干
+                        // 取到题干
                         Sections body = question.getBody();
                         List<Section> sections = body.getSections();
                         for (Section section : sections) {
@@ -201,10 +240,11 @@ public class ExportPaperServiceImpl implements ExportPaperService {
                                     if (block.getType().equals("audio")) {
                                         String id = block.getValue();
                                         QuestionAudio questionAudio = Model.of(questionAudioRepo.findById(id));
-                                        String audioFileName = questionAudio.getId() + "_" +
-                                                detail.getNumber() + "_" + question.getNumber() +
-                                                "_1_" + bodyNum + "." + questionAudio.getFileSuffixes();
-                                        UpYun upyun = new UpYun(sysProperty.getBucketName(), sysProperty.getUserName(), sysProperty.getPassword());
+                                        String audioFileName = questionAudio.getId() + "_" + detail.getNumber() + "_"
+                                                + question.getNumber() + "_1_" + bodyNum + "."
+                                                + questionAudio.getFileSuffixes();
+                                        UpYun upyun = new UpYun(sysProperty.getBucketName(), sysProperty.getUserName(),
+                                                sysProperty.getPassword());
                                         File file = new File(jsonDirectory + File.separator + audioFileName);
                                         upyun.readFile(questionAudio.getFileUrl(), file);
                                         bodyNum++;
@@ -212,12 +252,12 @@ public class ExportPaperServiceImpl implements ExportPaperService {
                                 }
                             }
                         }
-                        //取到选项
+                        // 取到选项
                         List<ComputerTestOption> options = question.getOptions();
                         if (options != null && options.size() > 0) {
                             for (ComputerTestOption computerTestOption : options) {
                                 int optionNum = 1;
-                                //获取选项主体
+                                // 获取选项主体
                                 Sections optionBody = computerTestOption.getBody();
                                 List<Section> optionSections = optionBody.getSections();
                                 if (optionSections != null && optionSections.size() > 0) {
@@ -227,12 +267,16 @@ public class ExportPaperServiceImpl implements ExportPaperService {
                                             for (Block block : blocks) {
                                                 if (block.getType().equals("audio")) {
                                                     String id = block.getValue();
-                                                    QuestionAudio questionAudio = Model.of(questionAudioRepo.findById(id));
-                                                    String audioFileName = questionAudio.getId() + "_" +
-                                                            detail.getNumber() + "_" + question.getNumber() +
-                                                            "_2_" + computerTestOption.getNumber() + "_" + optionNum + "." + questionAudio.getFileSuffixes();
-                                                    UpYun upyun = new UpYun(sysProperty.getBucketName(), sysProperty.getUserName(), sysProperty.getPassword());
-                                                    File file = new File(jsonDirectory + File.separator + audioFileName);
+                                                    QuestionAudio questionAudio = Model
+                                                            .of(questionAudioRepo.findById(id));
+                                                    String audioFileName = questionAudio.getId() + "_"
+                                                            + detail.getNumber() + "_" + question.getNumber() + "_2_"
+                                                            + computerTestOption.getNumber() + "_" + optionNum + "."
+                                                            + questionAudio.getFileSuffixes();
+                                                    UpYun upyun = new UpYun(sysProperty.getBucketName(),
+                                                            sysProperty.getUserName(), sysProperty.getPassword());
+                                                    File file = new File(
+                                                            jsonDirectory + File.separator + audioFileName);
                                                     upyun.readFile(questionAudio.getFileUrl(), file);
                                                     optionNum++;
                                                 }
@@ -254,43 +298,46 @@ public class ExportPaperServiceImpl implements ExportPaperService {
      * @return
      */
     public ComputerTestPaper buildComputerTestPapers(Paper paper) {
-        //得到所有旧对象的大题对象
+        // 得到所有旧对象的大题对象
         List<PaperDetail> paperDetails = paperService.findPaperDetailsById(paper.getId());
-        //通过 paper 对象 ,生成新的  ComputerTestPaper 对象
+        // 通过 paper 对象 ,生成新的 ComputerTestPaper 对象
         ComputerTestPaper computerTestPaper = new ComputerTestPaper(paper, "");
         List<ComputerTestPaperDetail> details = new ArrayList<>();
-        //遍历所有旧大题对象,得到小题对象的集合
+        // 遍历所有旧大题对象,得到小题对象的集合
         for (PaperDetail paperDetail : paperDetails) {
             List<PaperDetailUnit> paperDetailUnits = paperDetailService.getUnitsByPaperDetailId(paperDetail.getId());
             ComputerTestPaperDetail computerTestPaperDetail = new ComputerTestPaperDetail(paperDetail);
             List<ComputerTestQuestion> questions = new ArrayList<>();
-            //遍历所有的小题对象
+            // 遍历所有的小题对象
             for (int i = 0; i < paperDetailUnits.size(); i++) {
                 PaperDetailUnit paperDetailUnit = paperDetailUnits.get(i);
-                //根据旧的小题对象,生成新的小题对象
+                // 根据旧的小题对象,生成新的小题对象
                 ComputerTestQuestion computerTestQuestion = new ComputerTestQuestion(paperDetailUnit);
-                //设置小题题号
+                // 设置小题题号
                 computerTestQuestion.setNumber(i + 1);
-                //得到小题题干
-                computerTestQuestion.setBody(getBodyOrAnswer(paperDetailUnit.getQuestion().getQuesBody(), computerTestPaper));
-                //得到小题所有选项
+                // 得到小题题干
+                computerTestQuestion
+                        .setBody(getBodyOrAnswer(paperDetailUnit.getQuestion().getQuesBody(), computerTestPaper));
+                // 得到小题所有选项
                 computerTestQuestion.setOptions(getOption(paperDetailUnit.getQuestion(), computerTestPaper));
-                //得到小题的答案
-                computerTestQuestion.setAnswer(getBodyOrAnswer(paperDetailUnit.getQuestion().getQuesAnswer(), computerTestPaper));
-                //查询小题中的 套题
+                // 得到小题的答案
+                computerTestQuestion
+                        .setAnswer(getBodyOrAnswer(paperDetailUnit.getQuestion().getQuesAnswer(), computerTestPaper));
+                // 查询小题中的 套题
                 List<Question> subQuestionsList = paperDetailUnit.getQuestion().getSubQuestions();
-                //判断这个小题中是否有套题
+                // 判断这个小题中是否有套题
                 if (subQuestionsList != null && subQuestionsList.size() > 0) {
                     List<ComputerTestQuestion> subQuestions = new ArrayList<>();
-                    //遍历每个套题
+                    // 遍历每个套题
                     for (int j = 0; j < subQuestionsList.size(); j++) {
                         Question subQuestion = subQuestionsList.get(j);
                         ComputerTestQuestion subcomputerTestQuestion = new ComputerTestQuestion(subQuestion);
-                        //设置套题中小题题号
+                        // 设置套题中小题题号
                         subcomputerTestQuestion.setNumber(j + 1);
                         subcomputerTestQuestion.setBody(getBodyOrAnswer(subQuestion.getQuesBody(), computerTestPaper));
                         subcomputerTestQuestion.setOptions(getOption(subQuestion, computerTestPaper));
-                        subcomputerTestQuestion.setAnswer(getBodyOrAnswer(subQuestion.getQuesAnswer(), computerTestPaper));
+                        subcomputerTestQuestion
+                                .setAnswer(getBodyOrAnswer(subQuestion.getQuesAnswer(), computerTestPaper));
                         subQuestions.add(subcomputerTestQuestion);
                     }
                     computerTestQuestion.setSubQuestions(subQuestions);
@@ -298,7 +345,7 @@ public class ExportPaperServiceImpl implements ExportPaperService {
                 questions.add(computerTestQuestion);
             }
             computerTestPaperDetail.setQuestions(questions);
-            //paperDetail中的题数(unitCount)可能不准确,这里以questions的实际size为准
+            // paperDetail中的题数(unitCount)可能不准确,这里以questions的实际size为准
             computerTestPaperDetail.setQuestionCount(questions.size());
             details.add(computerTestPaperDetail);
         }
@@ -309,7 +356,7 @@ public class ExportPaperServiceImpl implements ExportPaperService {
     private Sections getBodyOrAnswer(String str, ComputerTestPaper computerTestPaper) {
         Sections body = new Sections();
         List<Section> sections = new ArrayList<>();
-        //得到小题题干或者答案行数
+        // 得到小题题干或者答案行数
         if (StringUtils.isBlank(str)) {
             return body;
         }
@@ -318,7 +365,7 @@ public class ExportPaperServiceImpl implements ExportPaperService {
             List<Block> blocks = disposeQuestionBodyOrOption(questionRowStrings[i], computerTestPaper);
             if (blocks != null && blocks.size() > 0) {
                 Section section = new Section();
-                //将小题题干拆分为Block集合
+                // 将小题题干拆分为Block集合
                 section.setBlocks(blocks);
                 sections.add(section);
             }
@@ -328,10 +375,10 @@ public class ExportPaperServiceImpl implements ExportPaperService {
     }
 
     private List<ComputerTestOption> getOption(Question question, ComputerTestPaper computerTestPaper) {
-        //得到小题选项
+        // 得到小题选项
         List<QuesOption> quesOptions = question.getQuesOptions();
         List<ComputerTestOption> options = new ArrayList<>();
-        //遍历小题选项
+        // 遍历小题选项
         if (quesOptions != null && quesOptions.size() > 0) {
             for (QuesOption quesOption : quesOptions) {
                 ComputerTestOption option = new ComputerTestOption();
@@ -340,7 +387,7 @@ public class ExportPaperServiceImpl implements ExportPaperService {
                 Sections body = new Sections();
 
                 List<Section> sections = new ArrayList<>();
-                //得到小题选项
+                // 得到小题选项
                 String optionString = quesOption.getOptionBody();
                 String[] optionStrings = optionString.split("</p>");
                 for (int i = 0; i < optionStrings.length; i++) {
@@ -361,36 +408,33 @@ public class ExportPaperServiceImpl implements ExportPaperService {
 
     private List<Block> disposeQuestionBodyOrOption(String questionRow, ComputerTestPaper computerTestPaper) {
         List<Block> blocks = new ArrayList<>();
-        //去掉每行里面的<p>,<span>,</span>标签
-        questionRow = questionRow.replaceAll("<p>", "")
-                .replaceAll("</p>", "")
-                .replaceAll("<span>", "")
-                .replaceAll("</span>", "")
-                .replaceAll("</a>", "");
+        // 去掉每行里面的<p>,<span>,</span>标签
+        questionRow = questionRow.replaceAll("<p>", "").replaceAll("</p>", "").replaceAll("<span>", "")
+                .replaceAll("</span>", "").replaceAll("</a>", "");
         String[] questionRowStrings = questionRow.split("<|/>|>");
         boolean hasAudio = false;
         for (int i = 0; i < questionRowStrings.length; i++) {
             Block block = new Block();
             String rowStr = questionRowStrings[i];
-            //判断是否有图片
+            // 判断是否有图片
             if (rowStr.startsWith("img")) {
                 rowStr = "<" + rowStr + ">";
                 Map<String, Object> param = new HashMap<>();
-                //需要继续做截取,取到Parma
+                // 需要继续做截取,取到Parma
                 block.setType("image");
-                //获取图片的路径
+                // 获取图片的路径
                 List<String> strSrcList = getImg(rowStr, "src");
                 if (strSrcList.size() > 0) {
                     String strSrc = strSrcList.get(0).replaceAll("src=\"", "").replaceAll("\"", "");
                     block.setValue(strSrc);
                 }
-                //获取图片的高度
+                // 获取图片的高度
                 List<String> strHeightList = getImg(rowStr, "height");
                 if (strHeightList.size() > 0) {
                     String strHeight = strHeightList.get(0).replaceAll("height=\"", "").replaceAll("\"", "");
                     param.put("height", strHeight);
                 }
-                //获取图片的宽度
+                // 获取图片的宽度
                 List<String> strWidthList = getImg(rowStr, "width");
                 if (strHeightList.size() > 0) {
                     String strWidth = strWidthList.get(0).replaceAll("width=\"", "").replaceAll("\"", "");
@@ -398,9 +442,7 @@ public class ExportPaperServiceImpl implements ExportPaperService {
                 }
                 block.setParam(param);
                 blocks.add(block);
-            } else if (rowStr.startsWith("a")
-                    && rowStr.contains("id")
-                    && rowStr.contains("name")) {    //处理音频
+            } else if (rowStr.startsWith("a") && rowStr.contains("id") && rowStr.contains("name")) { // 处理音频
                 rowStr = "<" + rowStr + ">";
                 block.setPlayTime(1);
                 block.setType("audio");
@@ -409,11 +451,11 @@ public class ExportPaperServiceImpl implements ExportPaperService {
                 hasAudio = true;
             } else {
                 block.setType("text");
-                rowStr = rowStr.replace("&nbsp;", "");//消除空格
-                rowStr = rowStr.replace("&quot;", "\"");//将&quot;转换成\"
-                rowStr = rowStr.replace("&lt;", "<");//将&lt;转换成<
-                rowStr = rowStr.replace("&gt;", ">");//将&gt;转换成>
-                rowStr = rowStr.replace("&amp;", "&");//将&amp;转换成&
+                rowStr = rowStr.replace("&nbsp;", "");// 消除空格
+                rowStr = rowStr.replace("&quot;", "\"");// 将&quot;转换成\"
+                rowStr = rowStr.replace("&lt;", "<");// 将&lt;转换成<
+                rowStr = rowStr.replace("&gt;", ">");// 将&gt;转换成>
+                rowStr = rowStr.replace("&amp;", "&");// 将&amp;转换成&
                 if (StringUtils.isNotBlank(rowStr)) {
                     block.setValue(rowStr);
                     blocks.add(block);
@@ -447,15 +489,16 @@ public class ExportPaperServiceImpl implements ExportPaperService {
      * @param computerTestPaper
      * @param jsonDirectoryPath
      */
-    private void makeComputerTestPaperToJsonFile(String courseCode, ComputerTestPaper computerTestPaper, String jsonDirectoryPath) {
-        //创建新的JSON文件
+    private void makeComputerTestPaperToJsonFile(String courseCode, ComputerTestPaper computerTestPaper,
+            String jsonDirectoryPath) {
+        // 创建新的JSON文件
         File file = new File(jsonDirectoryPath + File.separator + courseCode + ".json");
-        //将对象转成 json对象
+        // 将对象转成 json对象
         Gson gson = new Gson();
         String strJSON = gson.toJson(computerTestPaper);
 
         strJSON = CommonUtils.replaceUnicodeStr(strJSON);
-        //生成文件流写入JSON文件
+        // 生成文件流写入JSON文件
         FileOutputStream outputStream = null;
         try {
             outputStream = new FileOutputStream(file);
@@ -473,34 +516,36 @@ public class ExportPaperServiceImpl implements ExportPaperService {
 
     @SuppressWarnings("unused")
     @Override
-    public void exportPaperFiles(List<String> paperIds, String serviceName, String exportContentList, HttpServletResponse response, String loginName, String examType) throws Exception {
-        ExportPaperAbstractService exportPaperAbstractService = (ExportPaperAbstractService) SpringContextUtils.getBeanById(serviceName);
-        //根据试卷id查询所有试卷
+    public void exportPaperFiles(List<String> paperIds, String serviceName, String exportContentList,
+            HttpServletResponse response, String loginName, String examType) throws Exception {
+        ExportPaperAbstractService exportPaperAbstractService = (ExportPaperAbstractService) SpringContextUtils
+                .getBeanById(serviceName);
+        // 根据试卷id查询所有试卷
         List<Paper> papers = CommonUtils.toList(paperRepo.findByIdIn(paperIds));
         String zipFileName = loginName;
-        //创建压缩文件夹
+        // 创建压缩文件夹
         File directory = new File(TEMP_FILE_EXP + File.separator + zipFileName);
         if (directory.exists()) {
             deteleFolder(TEMP_FILE_EXP, zipFileName);
         }
         directory.mkdirs();
-        //下载试卷
+        // 下载试卷
         if (exportContentList.indexOf(ExamFileType.PAPER.name()) > -1) {
             for (Paper paper : papers) {
                 exportPaperAbstractService.downloadPaper(paper.getId(), zipFileName, examType);
             }
         }
-        //下载答案
+        // 下载答案
         if (exportContentList.indexOf(ExamFileType.ANSWER.name()) > -1) {
             for (Paper paper : papers) {
                 exportPaperAbstractService.downloadPaperAnswer(paper.getId(), zipFileName);
             }
         }
-        //下载机考数据包
+        // 下载机考数据包
         if (exportContentList.indexOf(ExamFileType.COMPUTERTEST_PACKAGE.name()) > -1) {
             int i = 1;
             for (Paper paper : papers) {
-                //创建json文件夹
+                // 创建json文件夹
                 String jsonDir = TEMP_FILE_EXP + File.separator + zipFileName + File.separator + "json";
                 File jsonDirectory = new File(jsonDir);
                 if (!jsonDirectory.exists()) {
@@ -508,9 +553,10 @@ public class ExportPaperServiceImpl implements ExportPaperService {
                 }
                 ComputerTestPaper computerTestPaper = buildComputerTestPapers(paper);
                 makeComputerTestPaperToJsonFile(paper.getCourse().getCode(), computerTestPaper, jsonDir);
-                //将文件夹打包成zip压缩包放在docxExport下
-                FileDisposeUtil.fileToZip(jsonDir, TEMP_FILE_EXP + File.separator + zipFileName, paper.getCourse().getCode() + "_" + paper.getName());
-                //删除json文件夹
+                // 将文件夹打包成zip压缩包放在docxExport下
+                FileDisposeUtil.fileToZip(jsonDir, TEMP_FILE_EXP + File.separator + zipFileName,
+                        paper.getCourse().getCode() + "_" + paper.getName());
+                // 删除json文件夹
                 File ComputerTestPaperfoler = new File(jsonDir);
                 if (ComputerTestPaperfoler.exists()) {
                     FileUtils.deleteQuietly(ComputerTestPaperfoler);
@@ -519,19 +565,20 @@ public class ExportPaperServiceImpl implements ExportPaperService {
         }
         String nameString = System.currentTimeMillis() + "";
         FileDisposeUtil.fileToZip(TEMP_FILE_EXP + File.separator + zipFileName, TEMP_FILE_EXP, nameString);
-        FileDisposeUtil.downloadFile(nameString + ".zip", TEMP_FILE_EXP + File.separator + nameString + ".zip", response);
+        FileDisposeUtil.downloadFile(nameString + ".zip", TEMP_FILE_EXP + File.separator + nameString + ".zip",
+                response);
         deteleFolder(TEMP_FILE_EXP, zipFileName);
     }
 
     @Override
     public void downQuestionDistribute(String courseCode, HttpServletResponse response) throws IOException {
-        //生成导出Excle的list集合
+        // 生成导出Excle的list集合
         List<QuestionDistributeDto> questionDistributes = this.downQuestionDistribute(courseCode);
 
         final String fileName = courseCode + "试题分布.xlsx";
         final String filePath = TEMP_FILE_EXP + File.separator + fileName;
 
-        //生成Excel导出
+        // 生成Excel导出
         File tempFile = this.writeExcel(questionDistributes, filePath);
         FileDisposeUtil.downloadFile(fileName, filePath, response);
         FileUtils.deleteQuietly(tempFile);
@@ -552,63 +599,83 @@ public class ExportPaperServiceImpl implements ExportPaperService {
     }
 
     private List<QuestionDistributeDto> downQuestionDistribute(String courseCode) {
-        //1.生成导出Excle的list集合
+        // 1.生成导出Excle的list集合
         List<QuestionDistributeDto> questionDistributes = new ArrayList<>();
 
-        //2.根据课程code查询课程属性集合
+        // 2.根据课程code查询课程属性集合
         List<CourseProperty> courseProperties = coursePropertyRepo.findByCourseCodeAndEnable(courseCode, true);
         if (CollectionUtils.isEmpty(courseProperties)) {
             return questionDistributes;
         }
 
-        //3.遍历课程属性集合,根据课程属性查询一级
+        // 3.遍历课程属性集合,根据课程属性查询一级
         for (CourseProperty courseProperty : courseProperties) {
-            List<Property> parentProperties = propertyService.findParentProperties(courseProperty.getId(), courseProperty.getOrgId());
+            List<Property> parentProperties = propertyService.findParentProperties(courseProperty.getId(),
+                    courseProperty.getOrgId());
             if (parentProperties != null && parentProperties.size() > 0) {
                 for (Property parentProperty : parentProperties) {
                     List<Property> sonProperties = propertyService.findSonProperties(parentProperty.getId());
                     if (sonProperties != null && sonProperties.size() > 0) {
                         for (Property sonProperty : sonProperties) {
-                            //单选题集合
-                            List<Question> sinList = questionList(courseCode, courseProperty, QuesStructType.SINGLE_ANSWER_QUESTION, parentProperty, sonProperty);
-                            //多选题集合
-                            List<Question> mulList = questionList(courseCode, courseProperty, QuesStructType.MULTIPLE_ANSWER_QUESTION, parentProperty, sonProperty);
-                            //判断题集合
-                            List<Question> bolList = questionList(courseCode, courseProperty, QuesStructType.BOOL_ANSWER_QUESTION, parentProperty, sonProperty);
+                            // 单选题集合
+                            List<Question> sinList = questionList(courseCode, courseProperty,
+                                    QuesStructType.SINGLE_ANSWER_QUESTION, parentProperty, sonProperty);
+                            // 多选题集合
+                            List<Question> mulList = questionList(courseCode, courseProperty,
+                                    QuesStructType.MULTIPLE_ANSWER_QUESTION, parentProperty, sonProperty);
+                            // 判断题集合
+                            List<Question> bolList = questionList(courseCode, courseProperty,
+                                    QuesStructType.BOOL_ANSWER_QUESTION, parentProperty, sonProperty);
 
                             List<Question> fillList = null;
-                            //fillList = questionList(courseCode, courseProperty, QuesStructType.FILL_BLANK_QUESTION, parentProperty, sonProperty);
+                            // fillList = questionList(courseCode,
+                            // courseProperty,
+                            // QuesStructType.FILL_BLANK_QUESTION,
+                            // parentProperty, sonProperty);
                             List<Question> textList = null;
-                            //textList = questionList(courseCode, courseProperty, QuesStructType.TEXT_ANSWER_QUESTION, parentProperty, sonProperty);
+                            // textList = questionList(courseCode,
+                            // courseProperty,
+                            // QuesStructType.TEXT_ANSWER_QUESTION,
+                            // parentProperty, sonProperty);
 
-                            //计算所有题型数量
+                            // 计算所有题型数量
                             Map<Long, Long> map = countQuesType(sinList, mulList, bolList, fillList, textList);
-                            QuestionDistributeDto questionDistributeDto = new QuestionDistributeDto(courseProperty.getName(), parentProperty.getName(), sonProperty.getName(), map);
+                            QuestionDistributeDto questionDistributeDto = new QuestionDistributeDto(
+                                    courseProperty.getName(), parentProperty.getName(), sonProperty.getName(), map);
                             questionDistributes.add(questionDistributeDto);
                         }
                     } else {
-                        //一级属性不为空,二级属性为空
-                        //单选题集合
-                        List<Question> sinList = questionList(courseCode, courseProperty, QuesStructType.SINGLE_ANSWER_QUESTION, parentProperty, null);
-                        //多选题集合
-                        List<Question> mulList = questionList(courseCode, courseProperty, QuesStructType.MULTIPLE_ANSWER_QUESTION, parentProperty, null);
-                        //判断题集合
-                        List<Question> bolList = questionList(courseCode, courseProperty, QuesStructType.BOOL_ANSWER_QUESTION, parentProperty, null);
+                        // 一级属性不为空,二级属性为空
+                        // 单选题集合
+                        List<Question> sinList = questionList(courseCode, courseProperty,
+                                QuesStructType.SINGLE_ANSWER_QUESTION, parentProperty, null);
+                        // 多选题集合
+                        List<Question> mulList = questionList(courseCode, courseProperty,
+                                QuesStructType.MULTIPLE_ANSWER_QUESTION, parentProperty, null);
+                        // 判断题集合
+                        List<Question> bolList = questionList(courseCode, courseProperty,
+                                QuesStructType.BOOL_ANSWER_QUESTION, parentProperty, null);
 
                         List<Question> fillList = null;
-                        //fillList = questionList(courseCode, courseProperty, QuesStructType.FILL_BLANK_QUESTION, parentProperty, null);
+                        // fillList = questionList(courseCode, courseProperty,
+                        // QuesStructType.FILL_BLANK_QUESTION, parentProperty,
+                        // null);
                         List<Question> textList = null;
-                        //textList = questionList(courseCode, courseProperty, QuesStructType.TEXT_ANSWER_QUESTION, parentProperty, null);
+                        // textList = questionList(courseCode, courseProperty,
+                        // QuesStructType.TEXT_ANSWER_QUESTION, parentProperty,
+                        // null);
 
-                        //计算所有题型数量
+                        // 计算所有题型数量
                         Map<Long, Long> map = countQuesType(sinList, mulList, bolList, fillList, textList);
-                        QuestionDistributeDto questionDistributeDto = new QuestionDistributeDto(courseProperty.getName(), parentProperty.getName(), null, map);
+                        QuestionDistributeDto questionDistributeDto = new QuestionDistributeDto(
+                                courseProperty.getName(), parentProperty.getName(), null, map);
                         questionDistributes.add(questionDistributeDto);
                     }
                 }
             } else {
-                //一级属性为空
-                QuestionDistributeDto questionDistributeDto = new QuestionDistributeDto(courseProperty.getName(), null, null, null);
+                // 一级属性为空
+                QuestionDistributeDto questionDistributeDto = new QuestionDistributeDto(courseProperty.getName(), null,
+                        null, null);
                 questionDistributes.add(questionDistributeDto);
             }
         }
@@ -618,23 +685,24 @@ public class ExportPaperServiceImpl implements ExportPaperService {
 
     @SuppressWarnings("resource")
     private File writeExcel(List<QuestionDistributeDto> questionDistributes, String filePath) throws IOException {
-        //读取Excel模板
+        // 读取Excel模板
         InputStream in = this.getClass().getResourceAsStream("/quesDistinct.xlsx");
-        //InputStream in = this.getClass().getResourceAsStream("/quesDistinctAll.xlsx");
+        // InputStream in =
+        // this.getClass().getResourceAsStream("/quesDistinctAll.xlsx");
 
-        //获取第一个工作页
+        // 获取第一个工作页
         Workbook workBook = new XSSFWorkbook(in);
         Sheet sheet = workBook.getSheetAt(0);
 
-        //往Excel中写入数据,从第5行开始
+        // 往Excel中写入数据,从第5行开始
         for (int i = 0; i < questionDistributes.size(); i++) {
-            //创建一行:从第五行开始,跳过表头
+            // 创建一行:从第五行开始,跳过表头
             Row row = sheet.createRow(i + 4);
 
-            //获取这行的记录
+            // 获取这行的记录
             QuestionDistributeDto questionDistributeDto = questionDistributes.get(i);
 
-            //每列赋值
+            // 每列赋值
             row.createCell(0).setCellValue(questionDistributeDto.getCoursePropertyName());
             row.createCell(1).setCellValue(questionDistributeDto.getFirstPropertyName());
             row.createCell(2).setCellValue(questionDistributeDto.getSecondPropertyName());
@@ -661,7 +729,8 @@ public class ExportPaperServiceImpl implements ExportPaperService {
         return file;
     }
 
-    private Map<Long, Long> countQuesType(List<Question> sinList, List<Question> mulList, List<Question> bolList, List<Question> fillList, List<Question> textList) {
+    private Map<Long, Long> countQuesType(List<Question> sinList, List<Question> mulList, List<Question> bolList,
+            List<Question> fillList, List<Question> textList) {
         Map<Long, Long> map = new TreeMap<>();
         map = buildMap(sinList, map, 1);
         map = buildMap(mulList, map, 2);
@@ -674,7 +743,7 @@ public class ExportPaperServiceImpl implements ExportPaperService {
             map = buildMap(textList, map, 5);
         }
 
-        //给map的键排序
+        // 给map的键排序
         Map<Long, Long> resultMap = sortMapByKey(map);
         return resultMap;
     }
@@ -684,6 +753,7 @@ public class ExportPaperServiceImpl implements ExportPaperService {
             return null;
         }
         Map<Long, Long> sortMap = new TreeMap<Long, Long>(new Comparator<Long>() {
+
             public int compare(Long l1, Long l2) {
                 return l1.compareTo(l2);
             }
@@ -693,7 +763,7 @@ public class ExportPaperServiceImpl implements ExportPaperService {
     }
 
     private Map<Long, Long> buildMap(List<Question> quesList, Map<Long, Long> map, int questionType) {
-        //初始化map
+        // 初始化map
         for (int i = 1; i < 7; i++) {
             if (i < 4) {
                 map.put((long) (questionType * 100 + i), 0L);
@@ -703,19 +773,23 @@ public class ExportPaperServiceImpl implements ExportPaperService {
         }
         for (Question question : quesList) {
             if (question.getPublicity()) {
-                //公开
-                if (question.getDifficulty() != null && question.getDifficulty().equals("难") || question.getDifficultyDegree() < 0.4 && question.getDifficultyDegree() > 0) {
+                // 公开
+                if (question.getDifficulty() != null && question.getDifficulty().equals("难")
+                        || question.getDifficultyDegree() < 0.4 && question.getDifficultyDegree() > 0) {
                     map = buildMapSum(questionType * 100L + 1L, map);
-                } else if (question.getDifficulty() != null && question.getDifficulty().equals("中") || question.getDifficultyDegree() < 0.8 && question.getDifficultyDegree() > 0.3) {
+                } else if (question.getDifficulty() != null && question.getDifficulty().equals("中")
+                        || question.getDifficultyDegree() < 0.8 && question.getDifficultyDegree() > 0.3) {
                     map = buildMapSum(questionType * 100L + 2L, map);
                 } else {
                     map = buildMapSum(questionType * 100L + 3L, map);
                 }
             } else {
-                //非公开
-                if (question.getDifficulty() != null && question.getDifficulty().equals("难") || question.getDifficultyDegree() < 0.4 && question.getDifficultyDegree() > 0) {
+                // 非公开
+                if (question.getDifficulty() != null && question.getDifficulty().equals("难")
+                        || question.getDifficultyDegree() < 0.4 && question.getDifficultyDegree() > 0) {
                     map = buildMapSum(questionType * 100L + 11L, map);
-                } else if (question.getDifficulty() != null && question.getDifficulty().equals("中") || question.getDifficultyDegree() < 0.8 && question.getDifficultyDegree() > 0.3) {
+                } else if (question.getDifficulty() != null && question.getDifficulty().equals("中")
+                        || question.getDifficultyDegree() < 0.8 && question.getDifficultyDegree() > 0.3) {
                     map = buildMapSum(questionType * 100L + 12L, map);
                 } else {
                     map = buildMapSum(questionType * 100L + 13L, map);
@@ -731,29 +805,33 @@ public class ExportPaperServiceImpl implements ExportPaperService {
         return map;
     }
 
-    public List<Question> questionList(String courseNo, CourseProperty courseProperty, QuesStructType quesStructType, Property parentProperty, Property sonProperty) {
+    public List<Question> questionList(String courseNo, CourseProperty courseProperty, QuesStructType quesStructType,
+            Property parentProperty, Property sonProperty) {
         Query query = new Query();
         query.addCriteria(Criteria.where("orgId").is(courseProperty.getOrgId().toString()));
         query.addCriteria(Criteria.where("course.enable").is("true"));
         query.addCriteria(Criteria.where("course.code").is(courseNo));
         query.addCriteria(Criteria.where("questionType").is(quesStructType.name()));
         query.addCriteria(Criteria.where("quesProperties.coursePropertyName").is(courseProperty.getName()));
-        //二级属性不为空,那么一级属性也不为空
+        // 二级属性不为空,那么一级属性也不为空
         if (sonProperty != null && sonProperty.getId() != null) {
-            query.addCriteria(Criteria.where("quesProperties").elemMatch(Criteria.where("firstProperty.id").is(parentProperty.getId()).and("secondProperty.id").is(sonProperty.getId())));
+            query.addCriteria(Criteria.where("quesProperties").elemMatch(Criteria.where("firstProperty.id")
+                    .is(parentProperty.getId()).and("secondProperty.id").is(sonProperty.getId())));
         } else {
             if (parentProperty != null && parentProperty.getId() != null) {
-                query.addCriteria(Criteria.where("quesProperties").elemMatch(Criteria.where("firstProperty.id").is(parentProperty.getId())));
+                query.addCriteria(Criteria.where("quesProperties")
+                        .elemMatch(Criteria.where("firstProperty.id").is(parentProperty.getId())));
             }
         }
         List<Question> questionList = this.mongoTemplate.find(query, Question.class);
         return questionList;
     }
 
-    public List<Question> questionList2(String courseNo, CourseProperty courseProperty, QuesStructType quesStructType, Property parentProperty, Property sonProperty, List<Question> questions) {
+    public List<Question> questionList2(String courseNo, CourseProperty courseProperty, QuesStructType quesStructType,
+            Property parentProperty, Property sonProperty, List<Question> questions) {
         List<Question> questionList = new ArrayList<>();
         String id = courseNo + quesStructType.name() + courseProperty.getName();
-        //二级属性不为空,那么一级属性也不为空
+        // 二级属性不为空,那么一级属性也不为空
         if (sonProperty != null && sonProperty.getId() != null) {
             id = id + parentProperty.getId() + sonProperty.getId();
         } else {
@@ -769,7 +847,8 @@ public class ExportPaperServiceImpl implements ExportPaperService {
                 for (QuesProperty property : quesProperties) {
                     String idP = id_Q + property.getCoursePropertyName() + property.getFirstProperty().getId();
                     if (property.getSecondProperty() != null) {
-                        idP = id_Q + property.getCoursePropertyName() + property.getFirstProperty().getId() + property.getSecondProperty().getId();
+                        idP = id_Q + property.getCoursePropertyName() + property.getFirstProperty().getId()
+                                + property.getSecondProperty().getId();
                     }
                     idStrings.add(idP);
                 }
@@ -783,23 +862,26 @@ public class ExportPaperServiceImpl implements ExportPaperService {
 
     @Override
     public void downOriginalPaper(String paperId, String loginName, HttpServletResponse response) throws Exception {
-        //生成导出的试卷对象
-        PaperExp paperExp = paperService.getDownPaperExp(paperId);
         String zipFileName = loginName + System.currentTimeMillis() + "";
-        File directory = new File(TEMP_FILE_EXP + File.separator + zipFileName);
-        if (!directory.exists()) {
-            directory.mkdirs();
+        try {
+            // 生成导出的试卷对象
+            PaperExp paperExp = paperService.getDownPaperExp(paperId);
+            File directory = new File(TEMP_FILE_EXP + File.separator + zipFileName);
+            if (!directory.exists()) {
+                directory.mkdirs();
+            }
+            String paperfileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_"
+                    + ExamFileType.PAPER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + paperfileName);
+            List<WordprocessingMLPackage> wordPackages = getPkgList(paperId);
+            DocxProcessUtil.exportWordNew(paperExp, file, ExportPaperAbstractService.ORIGINAL_PAPER);
+            DocxProcessUtil.processImage(zipFileName + File.separator + paperfileName, wordPackages);
+            FileDisposeUtil.fileToZip(TEMP_FILE_EXP + File.separator + zipFileName, TEMP_FILE_EXP, zipFileName);
+            FileDisposeUtil.downloadFile(paperExp.getName() + "_" + paperExp.getCourse().getCode() + ".zip",
+                    TEMP_FILE_EXP + File.separator + zipFileName + ".zip", response);
+        } finally {
+            deteleFolder(TEMP_FILE_EXP, zipFileName);
         }
-        String paperfileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.PAPER.getName() + DOCX_SUFFIX;
-        File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + paperfileName);
-        List<WordprocessingMLPackage> wordPackages = getPkgList(paperId);
-
-        DocxProcessUtil.exportWordNew(paperExp, file, ExportPaperAbstractService.ORIGINAL_PAPER);
-
-        DocxProcessUtil.processImage(zipFileName + File.separator + paperfileName, wordPackages);
-        FileDisposeUtil.fileToZip(TEMP_FILE_EXP + File.separator + zipFileName, TEMP_FILE_EXP, zipFileName);
-        FileDisposeUtil.downloadFile(paperExp.getName() + "_" + paperExp.getCourse().getCode() + ".zip", TEMP_FILE_EXP + File.separator + zipFileName + ".zip", response);
-        deteleFolder(TEMP_FILE_EXP, zipFileName);
     }
 
     /**
@@ -810,9 +892,9 @@ public class ExportPaperServiceImpl implements ExportPaperService {
      */
     protected List<WordprocessingMLPackage> getPkgList(String id) {
         Paper paper = Model.of(paperRepo.findById(id));
-        List<WordprocessingMLPackage> wordMLPackages = paperDetailUnitRepo.findByPaperOrderByNumber(paper)
-                .stream().map(PaperDetailUnit::getQuestion).collect(Collectors.toList())
-                .stream().map(question -> getPkgObj(question)).collect(Collectors.toList());
+        List<WordprocessingMLPackage> wordMLPackages = paperDetailUnitRepo.findByPaperOrderByNumber(paper).stream()
+                .map(PaperDetailUnit::getQuestion).collect(Collectors.toList()).stream()
+                .map(question -> getPkgObj(question)).collect(Collectors.toList());
         return wordMLPackages;
     }
 
@@ -831,79 +913,106 @@ public class ExportPaperServiceImpl implements ExportPaperService {
     public void downQuestionDistributeByPapers(String paperIds, HttpServletResponse response) throws IOException {
         List<QuestionDistributeDto> questionDistributes = new ArrayList<>();
 
-        //定义课程集合
+        // 定义课程集合
         List<String> courseCodes = new ArrayList<>();
 
-        //定义试题集合
+        // 定义试题集合
         List<Question> questions = new ArrayList<>();
 
-        //查询试卷集合
+        // 查询试卷集合
         String[] paperIdArray = paperIds.split(",");
         for (int i = 0; i < paperIdArray.length; i++) {
             Paper basePaper = Model.of(paperRepo.findById(paperIdArray[i]));
             courseCodes.add(basePaper.getCourse().getCode());
-            //将小题全部取出来,只取一次,减少对数据库的查询
+            // 将小题全部取出来,只取一次,减少对数据库的查询
             List<PaperDetailUnit> allPaperDetailUnits = paperDetailUnitRepo.findByPaper(basePaper);
             for (PaperDetailUnit unit : allPaperDetailUnits) {
-                if (unit.getQuestionType().equals(QuesStructType.SINGLE_ANSWER_QUESTION) || unit.getQuestionType().equals(QuesStructType.MULTIPLE_ANSWER_QUESTION)
+                if (unit.getQuestionType().equals(QuesStructType.SINGLE_ANSWER_QUESTION)
+                        || unit.getQuestionType().equals(QuesStructType.MULTIPLE_ANSWER_QUESTION)
                         || unit.getQuestionType().equals(QuesStructType.BOOL_ANSWER_QUESTION)) {
                     questions.add(unit.getQuestion());
                 }
             }
         }
 
-        //根据课程code查询课程属性集合
+        // 根据课程code查询课程属性集合
         for (String courseCode : courseCodes) {
             List<CourseProperty> courseProperties = coursePropertyRepo.findByCourseCodeAndEnable(courseCode, true);
-            //遍历课程属性集合,根据课程属性查询一级
+            // 遍历课程属性集合,根据课程属性查询一级
             if (courseProperties != null && courseProperties.size() > 0) {
                 for (CourseProperty courseProperty : courseProperties) {
-                    List<Property> parentProperties = propertyService.findParentProperties(courseProperty.getId(), courseProperty.getOrgId());
+                    List<Property> parentProperties = propertyService.findParentProperties(courseProperty.getId(),
+                            courseProperty.getOrgId());
                     if (parentProperties != null && parentProperties.size() > 0) {
                         for (Property parentProperty : parentProperties) {
                             List<Property> sonProperties = propertyService.findSonProperties(parentProperty.getId());
                             if (sonProperties != null && sonProperties.size() > 0) {
                                 for (Property sonProperty : sonProperties) {
-                                    //单选题集合
-                                    List<Question> sinList = questionList2(courseCode, courseProperty, QuesStructType.SINGLE_ANSWER_QUESTION, parentProperty, sonProperty, questions);
-                                    //多选题集合
-                                    List<Question> mulList = questionList2(courseCode, courseProperty, QuesStructType.MULTIPLE_ANSWER_QUESTION, parentProperty, sonProperty, questions);
-                                    //判断题集合
-                                    List<Question> bolList = questionList2(courseCode, courseProperty, QuesStructType.BOOL_ANSWER_QUESTION, parentProperty, sonProperty, questions);
+                                    // 单选题集合
+                                    List<Question> sinList = questionList2(courseCode, courseProperty,
+                                            QuesStructType.SINGLE_ANSWER_QUESTION, parentProperty, sonProperty,
+                                            questions);
+                                    // 多选题集合
+                                    List<Question> mulList = questionList2(courseCode, courseProperty,
+                                            QuesStructType.MULTIPLE_ANSWER_QUESTION, parentProperty, sonProperty,
+                                            questions);
+                                    // 判断题集合
+                                    List<Question> bolList = questionList2(courseCode, courseProperty,
+                                            QuesStructType.BOOL_ANSWER_QUESTION, parentProperty, sonProperty,
+                                            questions);
 
                                     List<Question> fillList = null;
-                                    //fillList = questionList2(courseNo, courseProperty, QuesStructType.FILL_BLANK_QUESTION, parentProperty, sonProperty, questions);
+                                    // fillList = questionList2(courseNo,
+                                    // courseProperty,
+                                    // QuesStructType.FILL_BLANK_QUESTION,
+                                    // parentProperty, sonProperty, questions);
                                     List<Question> textList = null;
-                                    //textList = questionList2(courseNo, courseProperty, QuesStructType.TEXT_ANSWER_QUESTION, parentProperty, sonProperty, questions);
+                                    // textList = questionList2(courseNo,
+                                    // courseProperty,
+                                    // QuesStructType.TEXT_ANSWER_QUESTION,
+                                    // parentProperty, sonProperty, questions);
 
-                                    //计算所有题型数量
+                                    // 计算所有题型数量
                                     Map<Long, Long> map = countQuesType(sinList, mulList, bolList, fillList, textList);
-                                    QuestionDistributeDto questionDistributeDto = new QuestionDistributeDto(courseProperty.getName(), parentProperty.getName(), sonProperty.getName(), map);
+                                    QuestionDistributeDto questionDistributeDto = new QuestionDistributeDto(
+                                            courseProperty.getName(), parentProperty.getName(), sonProperty.getName(),
+                                            map);
                                     questionDistributes.add(questionDistributeDto);
                                 }
                             } else {
-                                //一级属性不为空,二级属性为空
-                                //单选题集合
-                                List<Question> sinList = questionList2(courseCode, courseProperty, QuesStructType.SINGLE_ANSWER_QUESTION, parentProperty, null, questions);
-                                //多选题集合
-                                List<Question> mulList = questionList2(courseCode, courseProperty, QuesStructType.MULTIPLE_ANSWER_QUESTION, parentProperty, null, questions);
-                                //判断题集合
-                                List<Question> bolList = questionList2(courseCode, courseProperty, QuesStructType.BOOL_ANSWER_QUESTION, parentProperty, null, questions);
+                                // 一级属性不为空,二级属性为空
+                                // 单选题集合
+                                List<Question> sinList = questionList2(courseCode, courseProperty,
+                                        QuesStructType.SINGLE_ANSWER_QUESTION, parentProperty, null, questions);
+                                // 多选题集合
+                                List<Question> mulList = questionList2(courseCode, courseProperty,
+                                        QuesStructType.MULTIPLE_ANSWER_QUESTION, parentProperty, null, questions);
+                                // 判断题集合
+                                List<Question> bolList = questionList2(courseCode, courseProperty,
+                                        QuesStructType.BOOL_ANSWER_QUESTION, parentProperty, null, questions);
 
                                 List<Question> fillList = null;
-                                //fillList = questionList2(courseNo, courseProperty, QuesStructType.FILL_BLANK_QUESTION, parentProperty, null, questions);
+                                // fillList = questionList2(courseNo,
+                                // courseProperty,
+                                // QuesStructType.FILL_BLANK_QUESTION,
+                                // parentProperty, null, questions);
                                 List<Question> textList = null;
-                                //textList = questionList2(courseNo, courseProperty, QuesStructType.TEXT_ANSWER_QUESTION, parentProperty, null, questions);
+                                // textList = questionList2(courseNo,
+                                // courseProperty,
+                                // QuesStructType.TEXT_ANSWER_QUESTION,
+                                // parentProperty, null, questions);
 
-                                //计算所有题型数量
+                                // 计算所有题型数量
                                 Map<Long, Long> map = countQuesType(sinList, mulList, bolList, fillList, textList);
-                                QuestionDistributeDto questionDistributeDto = new QuestionDistributeDto(courseProperty.getName(), parentProperty.getName(), null, map);
+                                QuestionDistributeDto questionDistributeDto = new QuestionDistributeDto(
+                                        courseProperty.getName(), parentProperty.getName(), null, map);
                                 questionDistributes.add(questionDistributeDto);
                             }
                         }
                     } else {
-                        //一级属性为空
-                        QuestionDistributeDto questionDistributeDto = new QuestionDistributeDto(courseProperty.getName(), null, null, null);
+                        // 一级属性为空
+                        QuestionDistributeDto questionDistributeDto = new QuestionDistributeDto(
+                                courseProperty.getName(), null, null, null);
                         questionDistributes.add(questionDistributeDto);
                     }
                 }
@@ -912,7 +1021,7 @@ public class ExportPaperServiceImpl implements ExportPaperService {
             final String fileName = System.currentTimeMillis() + "试题分布.xlsx";
             final String filePath = TEMP_FILE_EXP + File.separator + fileName;
 
-            //生成Excel导出
+            // 生成Excel导出
             File tempFile = this.writeExcel(questionDistributes, filePath);
             FileDisposeUtil.downloadFile(fileName, filePath, response);
             FileUtils.deleteQuietly(tempFile);