|
@@ -16,6 +16,9 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import main.java.com.UpYun;
|
|
|
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
+import org.docx4j.Docx4J;
|
|
|
+import org.docx4j.openpackaging.exceptions.InvalidFormatException;
|
|
|
+import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -60,6 +63,7 @@ import com.qmth.cqb.utils.SpringContextUtils;
|
|
|
import com.qmth.cqb.utils.enums.ExamFileType;
|
|
|
import com.qmth.cqb.utils.enums.ExportType;
|
|
|
import com.qmth.cqb.utils.enums.ExportWay;
|
|
|
+import com.qmth.cqb.utils.word.DocxProcessUtil;
|
|
|
|
|
|
/**
|
|
|
* @author chenken
|
|
@@ -72,6 +76,10 @@ public class ExtractConfigFileServiceImpl implements ExtractConfigFileService {
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(ExtractConfigFileServiceImpl.class);
|
|
|
|
|
|
+ public static final String TEMP_FILE_EXP = "docxExport/";
|
|
|
+
|
|
|
+ public static final String TEMP_FILE_NAME = "_考试说明.docx";
|
|
|
+
|
|
|
@Autowired
|
|
|
private ExamCourseClient examCourseClient;
|
|
|
|
|
@@ -174,7 +182,7 @@ public class ExtractConfigFileServiceImpl implements ExtractConfigFileService {
|
|
|
@Override
|
|
|
public void exportExamPaperInfo(ExportPaperInfoModel exportModel,HttpServletResponse response,String loginName) throws Exception {
|
|
|
String downloadDir = downloadDirectory + loginName;
|
|
|
- String downZipDir = zipDirectory + loginName;
|
|
|
+ String downZipDir = zipDirectory + loginName;
|
|
|
//创建试卷和压缩文件 文件夹
|
|
|
FileDisposeUtil.createDirectory(downloadDir);
|
|
|
//创建压缩文件的文件夹
|
|
@@ -213,7 +221,7 @@ public class ExtractConfigFileServiceImpl implements ExtractConfigFileService {
|
|
|
String groupCode = entry.getKey();
|
|
|
String paperId = entry.getValue();
|
|
|
if(groupCode.equals(examFile.getGroupCode())){
|
|
|
- downloadAudio(paperId,examFile);
|
|
|
+ downloadAudio(paperId,examFile,downloadDir);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -232,9 +240,12 @@ public class ExtractConfigFileServiceImpl implements ExtractConfigFileService {
|
|
|
|
|
|
/**
|
|
|
* 下载试卷音频文件
|
|
|
+ * @throws Exception
|
|
|
*/
|
|
|
- private void downloadAudio(String paperId,ExamFile examFile){
|
|
|
+ private void downloadAudio(String paperId,ExamFile examFile,String downloadDir) throws Exception{
|
|
|
Paper paper = paperRepo.findOne(paperId);
|
|
|
+ //下载考试说明
|
|
|
+ downExamRemark(paper,downloadDir);
|
|
|
List<PaperDetailUnit> paperDetailUnits = paperDetailUnitRepo.findByPaperOrderByNumber(paper);
|
|
|
for(PaperDetailUnit unit:paperDetailUnits){
|
|
|
if(unit.getQuestion().getHasAudio()!=null&&unit.getQuestion().getHasAudio()){
|
|
@@ -253,6 +264,22 @@ public class ExtractConfigFileServiceImpl implements ExtractConfigFileService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 下载考试说明
|
|
|
+ * @param paper
|
|
|
+ * @param zipFileName
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public void downExamRemark(Paper paper,String zipFileName) throws Exception {
|
|
|
+ //1.考试说明html转成word
|
|
|
+ String title = "<p style=\"text-align:center\"><span style=\"font-size:26px\"><span style=\"font-family:宋体\">考 试 说 明</span></span></p>";
|
|
|
+ WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
|
|
|
+ DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(title+paper.getExamRemark()));
|
|
|
+ //2.导出考试说明word
|
|
|
+ File file = new File(zipFileName+File.separator+paper.getCourse().getCode()+TEMP_FILE_NAME);
|
|
|
+ Docx4J.save(wordMLPackage, file);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 计算取得音频文件名称
|
|
|
* @param audio
|