|
@@ -1,95 +1,91 @@
|
|
-package cn.com.qmth.examcloud.core.questions.service.export;
|
|
|
|
-
|
|
|
|
-import java.io.File;
|
|
|
|
-
|
|
|
|
-import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
|
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
|
-
|
|
|
|
-import cn.com.qmth.examcloud.commons.web.security.bean.User;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.base.CommonUtils;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.base.enums.ExamFileType;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.base.word.DocxProcessUtil;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.dao.entity.ExtractConfig;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.service.bean.dto.PaperExp;
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * @author weiwenhai
|
|
|
|
- * @date 2018年6月2日 上午11:29:49
|
|
|
|
- * @company QMTH
|
|
|
|
- * @description 北京师范大学导出、上传文件service
|
|
|
|
- */
|
|
|
|
-@Service("bjsfExportPaperService")
|
|
|
|
-public class BjsfExportPaperService extends ExportPaperAbstractService {
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void downloadPaper(String paperId,String zipFileName,String examType) throws Exception {
|
|
|
|
- PaperExp paperExp = super.initPaperExp(paperId);
|
|
|
|
- if(paperExp!=null){
|
|
|
|
- String paperfileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.PAPER.getName()+DOCX_SUFFIX;
|
|
|
|
- File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+paperfileName);
|
|
|
|
- if(examType.equals("offLine")){
|
|
|
|
- WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
|
|
|
|
- paperExp.setExamRemarkWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(paperExp.getExamRemark())));
|
|
|
|
- DocxProcessUtil.exportWordNew(paperExp, file,BJSF_TMPLATE_PAPER);
|
|
|
|
- }else{
|
|
|
|
- DocxProcessUtil.exportWordNew(paperExp, file,BJSF_TMPLATE_PAPER);
|
|
|
|
- }
|
|
|
|
- DocxProcessUtil.processImage(zipFileName+File.separator+paperfileName,getPkgList(paperId));
|
|
|
|
- //下载音频
|
|
|
|
- super.downloadAudio(paperExp, zipFileName);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void downloadPaperAnswer(String paperId, String zipFileName)throws Exception {
|
|
|
|
- PaperExp paperExp = initPaperExp(paperId);
|
|
|
|
- if(paperExp!=null){
|
|
|
|
- String answerFileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.ANSWER.getName()+DOCX_SUFFIX;
|
|
|
|
- File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+answerFileName);
|
|
|
|
- DocxProcessUtil.exportWordNew(paperExp,file,BJSF_TMPLATE_ANSWER);
|
|
|
|
- DocxProcessUtil.processImage(zipFileName+File.separator+answerFileName,getPkgList(paperId));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void uploadFile(ExtractConfig extractConfig,String paperId,User accessUser) throws Exception{
|
|
|
|
- PaperExp paperExp = initPaperExp(paperId);
|
|
|
|
- if (paperExp!=null) {
|
|
|
|
- String currNum = CommonUtils.getCurNum();
|
|
|
|
- //删除原有试卷文件
|
|
|
|
- /*ExamFile examFile = new ExamFile();
|
|
|
|
- examFile.setExamId(extractConfig.getExamId()+"");
|
|
|
|
- examFile.setCourseId(extractConfig.getCourseCode());
|
|
|
|
- examFile.setOrgId(extractConfig.getOrgId());
|
|
|
|
- examFileService.deleteExamFile(examFile);*/
|
|
|
|
- //没有试卷结构导出设置
|
|
|
|
- /*if(exportStructure==null){
|
|
|
|
- //上传试卷
|
|
|
|
- uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,SXSF_TEMPLATE_PAPER,ExamFileType.PAPER);
|
|
|
|
- //上传答案
|
|
|
|
- uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,SXSF_TEMPLATE_ANSWER,ExamFileType.ANSWER);
|
|
|
|
- }else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.NORMAL){
|
|
|
|
- List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
|
|
|
|
- //检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
|
|
|
|
- checkObjectiveDetailsNum(paperExp,questionTypeNums);
|
|
|
|
- //上传试卷
|
|
|
|
- uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,SXSF_TEMPLATE_PAPER,ExamFileType.PAPER);
|
|
|
|
- //上传答案
|
|
|
|
- uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,SXSF_TEMPLATE_ANSWER,ExamFileType.ANSWER);
|
|
|
|
- //上传试卷结构 不能在上传试卷和答案之前
|
|
|
|
- uploadPaperStructure(paperExp,extractConfig,accessUser,currNum,questionTypeNums);
|
|
|
|
- }else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.ONLINE){
|
|
|
|
- //上传机考JSON文件
|
|
|
|
- uploadComputerTestFile(extractConfig,accessUser);
|
|
|
|
- }*/
|
|
|
|
- //checkObjectiveDetailsNum(paperExp,questionTypeNums);
|
|
|
|
- //上传试卷
|
|
|
|
- uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,BJSF_TMPLATE_PAPER,ExamFileType.PAPER);
|
|
|
|
- //上传答案
|
|
|
|
- uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,BJSF_TMPLATE_ANSWER,ExamFileType.ANSWER);
|
|
|
|
- //上传机考JSON文件
|
|
|
|
- uploadComputerTestFile(extractConfig,accessUser);
|
|
|
|
- //uploadPaperStructure(paperExp,extractConfig,accessUser,currNum,questionTypeNums);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
|
|
+package cn.com.qmth.examcloud.core.questions.service.export;
|
|
|
|
+
|
|
|
|
+import java.io.File;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+
|
|
|
|
+import cn.com.qmth.examcloud.commons.web.security.bean.User;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.base.CommonUtils;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.base.enums.ExamFileType;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.base.enums.ExportType;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.base.word.DocxProcessUtil;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.dao.entity.ExportStructure;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.dao.entity.ExtractConfig;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.dao.entity.QuestionTypeNum;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.service.bean.dto.PaperExp;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @author weiwenhai
|
|
|
|
+ * @date 2018年6月2日 上午11:29:49
|
|
|
|
+ * @company QMTH
|
|
|
|
+ * @description 北京师范大学导出、上传文件service
|
|
|
|
+ */
|
|
|
|
+@Service("bjsfExportPaperService")
|
|
|
|
+public class BjsfExportPaperService extends ExportPaperAbstractService {
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void downloadPaper(String paperId,String zipFileName,String examType) throws Exception {
|
|
|
|
+ PaperExp paperExp = super.initPaperExp(paperId);
|
|
|
|
+ if(paperExp!=null){
|
|
|
|
+ String paperfileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.PAPER.getName()+DOCX_SUFFIX;
|
|
|
|
+ File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+paperfileName);
|
|
|
|
+ if(examType.equals("offLine")){
|
|
|
|
+ WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
|
|
|
|
+ paperExp.setExamRemarkWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(paperExp.getExamRemark())));
|
|
|
|
+ DocxProcessUtil.exportWordNew(paperExp, file,BJSF_TMPLATE_PAPER);
|
|
|
|
+ }else{
|
|
|
|
+ DocxProcessUtil.exportWordNew(paperExp, file,BJSF_TMPLATE_PAPER);
|
|
|
|
+ }
|
|
|
|
+ DocxProcessUtil.processImage(zipFileName+File.separator+paperfileName,getPkgList(paperId));
|
|
|
|
+ //下载音频
|
|
|
|
+ super.downloadAudio(paperExp, zipFileName);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void downloadPaperAnswer(String paperId, String zipFileName)throws Exception {
|
|
|
|
+ PaperExp paperExp = initPaperExp(paperId);
|
|
|
|
+ if(paperExp!=null){
|
|
|
|
+ String answerFileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.ANSWER.getName()+DOCX_SUFFIX;
|
|
|
|
+ File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+answerFileName);
|
|
|
|
+ DocxProcessUtil.exportWordNew(paperExp,file,BJSF_TMPLATE_ANSWER);
|
|
|
|
+ DocxProcessUtil.processImage(zipFileName+File.separator+answerFileName,getPkgList(paperId));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void uploadFile(ExtractConfig extractConfig,String paperId,ExportStructure exportStructure,User accessUser) throws Exception{
|
|
|
|
+ PaperExp paperExp = initPaperExp(paperId);
|
|
|
|
+ if (paperExp!=null) {
|
|
|
|
+ String currNum = CommonUtils.getCurNum();
|
|
|
|
+ //删除原有试卷文件
|
|
|
|
+ /*ExamFile examFile = new ExamFile();
|
|
|
|
+ examFile.setExamId(extractConfig.getExamId()+"");
|
|
|
|
+ examFile.setCourseId(extractConfig.getCourseCode());
|
|
|
|
+ examFile.setOrgId(extractConfig.getOrgId());
|
|
|
|
+ examFileService.deleteExamFile(examFile);*/
|
|
|
|
+ //没有试卷结构导出设置
|
|
|
|
+ if(exportStructure==null){
|
|
|
|
+ //上传试卷
|
|
|
|
+ uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,BJSF_TMPLATE_PAPER,ExamFileType.PAPER);
|
|
|
|
+ //上传答案
|
|
|
|
+ uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,BJSF_TMPLATE_ANSWER,ExamFileType.ANSWER);
|
|
|
|
+ }else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.NORMAL){
|
|
|
|
+ List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
|
|
|
|
+ //检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
|
|
|
|
+ checkObjectiveDetailsNum(paperExp,questionTypeNums);
|
|
|
|
+ //上传试卷
|
|
|
|
+ uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,BJSF_TMPLATE_PAPER,ExamFileType.PAPER);
|
|
|
|
+ //上传答案
|
|
|
|
+ uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,BJSF_TMPLATE_ANSWER,ExamFileType.ANSWER);
|
|
|
|
+ //上传试卷结构 不能在上传试卷和答案之前
|
|
|
|
+ uploadPaperStructure(paperExp,extractConfig,accessUser,currNum,questionTypeNums);
|
|
|
|
+ }else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.ONLINE){
|
|
|
|
+ //上传机考JSON文件
|
|
|
|
+ uploadComputerTestFile(extractConfig,accessUser);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|