|
@@ -24,6 +24,7 @@ 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;
|
|
import org.springframework.data.domain.Example;
|
|
import org.springframework.data.domain.Example;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
|
|
|
|
@@ -35,6 +36,8 @@ import cn.com.qmth.examcloud.core.questions.base.IoUtils;
|
|
import cn.com.qmth.examcloud.core.questions.base.Model;
|
|
import cn.com.qmth.examcloud.core.questions.base.Model;
|
|
import cn.com.qmth.examcloud.core.questions.base.enums.ExamFileType;
|
|
import cn.com.qmth.examcloud.core.questions.base.enums.ExamFileType;
|
|
import cn.com.qmth.examcloud.core.questions.base.enums.ExportTemplateType;
|
|
import cn.com.qmth.examcloud.core.questions.base.enums.ExportTemplateType;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.base.enums.ExportType;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.base.enums.PaperSeqMode;
|
|
import cn.com.qmth.examcloud.core.questions.base.excel.ExcelWriter;
|
|
import cn.com.qmth.examcloud.core.questions.base.excel.ExcelWriter;
|
|
import cn.com.qmth.examcloud.core.questions.base.json.JsonImportUtil;
|
|
import cn.com.qmth.examcloud.core.questions.base.json.JsonImportUtil;
|
|
import cn.com.qmth.examcloud.core.questions.base.question.enums.QuesStructType;
|
|
import cn.com.qmth.examcloud.core.questions.base.question.enums.QuesStructType;
|
|
@@ -66,6 +69,7 @@ import cn.com.qmth.examcloud.core.questions.service.ExportTemplateService;
|
|
import cn.com.qmth.examcloud.core.questions.service.PaperDetailService;
|
|
import cn.com.qmth.examcloud.core.questions.service.PaperDetailService;
|
|
import cn.com.qmth.examcloud.core.questions.service.PaperService;
|
|
import cn.com.qmth.examcloud.core.questions.service.PaperService;
|
|
import cn.com.qmth.examcloud.core.questions.service.QuestionAudioService;
|
|
import cn.com.qmth.examcloud.core.questions.service.QuestionAudioService;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.service.bean.dto.DownloadPaperDto;
|
|
import cn.com.qmth.examcloud.core.questions.service.bean.dto.ObjectiveQuestionStructure;
|
|
import cn.com.qmth.examcloud.core.questions.service.bean.dto.ObjectiveQuestionStructure;
|
|
import cn.com.qmth.examcloud.core.questions.service.bean.dto.PaperDetailExp;
|
|
import cn.com.qmth.examcloud.core.questions.service.bean.dto.PaperDetailExp;
|
|
import cn.com.qmth.examcloud.core.questions.service.bean.dto.PaperDetailUnitExp;
|
|
import cn.com.qmth.examcloud.core.questions.service.bean.dto.PaperDetailUnitExp;
|
|
@@ -85,7 +89,8 @@ import freemarker.template.Template;
|
|
* @company QMTH
|
|
* @company QMTH
|
|
* @description 导出、上传文件service 父类
|
|
* @description 导出、上传文件service 父类
|
|
*/
|
|
*/
|
|
-public abstract class ExportPaperAbstractService {
|
|
|
|
|
|
+@Service("exportPaperAbstractService")
|
|
|
|
+public class ExportPaperAbstractService {
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(ExportPaperAbstractService.class);
|
|
private static final Logger log = LoggerFactory.getLogger(ExportPaperAbstractService.class);
|
|
|
|
|
|
@@ -159,126 +164,6 @@ public abstract class ExportPaperAbstractService {
|
|
|
|
|
|
protected static final String OFFLINE = "offLine";
|
|
protected static final String OFFLINE = "offLine";
|
|
|
|
|
|
- // // 陕西师范模板
|
|
|
|
- // protected static Template SXSF_TEMPLATE_PAPER;
|
|
|
|
- //
|
|
|
|
- // protected static Template SXSF_TEMPLATE_ANSWER;
|
|
|
|
- //
|
|
|
|
- // protected static Template SXSF_OUTLINE_TEMPLATE_PAPER;
|
|
|
|
- //
|
|
|
|
- // // 西南交通大学
|
|
|
|
- // protected static Template XNJD_TEMPLATE_PAPER;
|
|
|
|
- //
|
|
|
|
- // protected static Template XNJD_TEMPLATE_ANSWER;
|
|
|
|
- //
|
|
|
|
- // protected static Template XNJD_OUTLINE_TEMPLATE_PAPER;
|
|
|
|
- //
|
|
|
|
- // // 电子科大模板
|
|
|
|
- // protected static Template DZKD_TEMPLATE_PAPER;
|
|
|
|
- //
|
|
|
|
- // protected static Template DZKD_TEMPLATE_ANSWER;
|
|
|
|
- //
|
|
|
|
- // // 华中科技大学模板
|
|
|
|
- // protected static Template HZKJ_TEMPLATE_PAPER;
|
|
|
|
- //
|
|
|
|
- // protected static Template HZKJ_TEMPLATE_ANSWER;
|
|
|
|
- //
|
|
|
|
- // // 山东大学
|
|
|
|
- // protected static Template SDDX_TEMPLATE_PAPER;
|
|
|
|
- //
|
|
|
|
- // protected static Template SDDX_TEMPLATE_ANSWER;
|
|
|
|
- //
|
|
|
|
- // // 天津大学
|
|
|
|
- // protected static Template TJDX_TEMPLATE_PAPER;
|
|
|
|
- //
|
|
|
|
- // protected static Template TJDX_TEMPLATE_ANSWER;
|
|
|
|
- //
|
|
|
|
- // protected static Template TJDX_OUTLINE_TEMPLATE_PAPER;
|
|
|
|
- //
|
|
|
|
- // // 石油大学模板
|
|
|
|
- // protected static Template SYDX_TEMPLATE_PAPER;
|
|
|
|
- //
|
|
|
|
- // protected static Template SYDX_TEMPLATE_ANSWER;
|
|
|
|
- //
|
|
|
|
- // // 西安交大模板
|
|
|
|
- // protected static Template XAJD_TEMPLATE_PAPER;
|
|
|
|
- //
|
|
|
|
- // protected static Template XAJD_TEMPLATE_ANSWER;
|
|
|
|
- //
|
|
|
|
- // // 武汉软件工程职业学院模板
|
|
|
|
- // protected static Template RJGC_TMPLATE_PAPER;
|
|
|
|
- //
|
|
|
|
- // protected static Template RJGC_TMPLATE_ANSWER;
|
|
|
|
- //
|
|
|
|
- // // 北京师范模板
|
|
|
|
- // protected static Template BJSF_TMPLATE_PAPER;
|
|
|
|
- //
|
|
|
|
- // protected static Template BJSF_TMPLATE_ANSWER;
|
|
|
|
- //
|
|
|
|
- // // 重庆大学
|
|
|
|
- // protected static Template CQDX_TMPLATE_PAPER;
|
|
|
|
- //
|
|
|
|
- // protected static Template CQDX_TMPLATE_ANSWER;
|
|
|
|
- //
|
|
|
|
- // // 福建师范
|
|
|
|
- // protected static Template FJSF_TMPLATE_PAPER;
|
|
|
|
- //
|
|
|
|
- // protected static Template FJSF_TMPLATE_ANSWER;
|
|
|
|
- //
|
|
|
|
- // // 中国地质大学(北京)
|
|
|
|
- // protected static Template CUGB_TMPLATE_PAPER;
|
|
|
|
- //
|
|
|
|
- // protected static Template CUGB_TMPLATE_ANSWER;
|
|
|
|
- //
|
|
|
|
- // // 武汉市第二轻工业学校
|
|
|
|
- // protected static Template WHEQX_TMPLATE_PAPER;
|
|
|
|
- //
|
|
|
|
- // protected static Template WHEQX_TMPLATE_ANSWER;
|
|
|
|
- //
|
|
|
|
- // // 华南师范
|
|
|
|
- // protected static Template HNSF_TMPLATE_PAPER;
|
|
|
|
- //
|
|
|
|
- // protected static Template HNSF_TMPLATE_ANSWER;
|
|
|
|
- //
|
|
|
|
- // // 中国医科
|
|
|
|
- // protected static Template YKDX_TMPLATE_PAPER;
|
|
|
|
- //
|
|
|
|
- // protected static Template YKDX_TMPLATE_ANSWER;
|
|
|
|
- //
|
|
|
|
- // // 北京交通大学
|
|
|
|
- // protected static Template BJJT_TMPLATE_PAPER;
|
|
|
|
- //
|
|
|
|
- // protected static Template BJJT_TMPLATE_ANSWER;
|
|
|
|
- //
|
|
|
|
- // // 中国地质大学(武汉)
|
|
|
|
- // protected static Template ZGDDW_TMPLATE_PAPER;
|
|
|
|
- //
|
|
|
|
- // protected static Template ZGDDW_TMPLATE_ANSWER;
|
|
|
|
- //
|
|
|
|
- // // 中国地质大学(北京)
|
|
|
|
- // protected static Template ZGDDB_TMPLATE_PAPER;
|
|
|
|
- //
|
|
|
|
- // protected static Template ZGDDB_TMPLATE_ANSWER;
|
|
|
|
- //
|
|
|
|
- // // 东北师范大学
|
|
|
|
- // protected static Template DBSF_TMPLATE_PAPER;
|
|
|
|
- //
|
|
|
|
- // protected static Template DBSF_TMPLATE_ANSWER;
|
|
|
|
- //
|
|
|
|
- // // 南开大学
|
|
|
|
- // protected static Template NKDX_TMPLATE_PAPER;
|
|
|
|
- //
|
|
|
|
- // protected static Template NKDX_TMPLATE_ANSWER;
|
|
|
|
- //
|
|
|
|
- // // 北京航空航天大学
|
|
|
|
- // protected static Template BJHK_TMPLATE_PAPER;
|
|
|
|
- //
|
|
|
|
- // protected static Template BJHK_TMPLATE_ANSWER;
|
|
|
|
- //
|
|
|
|
- // // 华东师范大学
|
|
|
|
- // protected static Template FDSF_TMPLATE_PAPER;
|
|
|
|
- //
|
|
|
|
- // protected static Template FDSF_TMPLATE_ANSWER;
|
|
|
|
|
|
|
|
// 原卷word A4 模板
|
|
// 原卷word A4 模板
|
|
public final static Template ORIGINAL_PAPER;
|
|
public final static Template ORIGINAL_PAPER;
|
|
@@ -301,133 +186,6 @@ public abstract class ExportPaperAbstractService {
|
|
}
|
|
}
|
|
ORIGINAL_PAPER = originalTemplate;
|
|
ORIGINAL_PAPER = originalTemplate;
|
|
|
|
|
|
- // try {
|
|
|
|
- // SXSF_TEMPLATE_PAPER =
|
|
|
|
- // CONFIGURATION.getTemplate("sxsf_paper_template.ftl", ENCODING);
|
|
|
|
- // SXSF_TEMPLATE_ANSWER =
|
|
|
|
- // CONFIGURATION.getTemplate("sxsf_answer_template.ftl", ENCODING);
|
|
|
|
- // SXSF_OUTLINE_TEMPLATE_PAPER =
|
|
|
|
- // CONFIGURATION.getTemplate("sxsf_outline_paper_template.ftl",
|
|
|
|
- // ENCODING);
|
|
|
|
- //
|
|
|
|
- // DZKD_TEMPLATE_PAPER =
|
|
|
|
- // CONFIGURATION.getTemplate("dzkd_paper_template.ftl", ENCODING);
|
|
|
|
- // DZKD_TEMPLATE_ANSWER =
|
|
|
|
- // CONFIGURATION.getTemplate("dzkd_answer_template.ftl", ENCODING);
|
|
|
|
- //
|
|
|
|
- // HZKJ_TEMPLATE_PAPER =
|
|
|
|
- // CONFIGURATION.getTemplate("hzkj_paper_template.ftl", ENCODING);
|
|
|
|
- // HZKJ_TEMPLATE_ANSWER =
|
|
|
|
- // CONFIGURATION.getTemplate("hzkj_answer_template.ftl", ENCODING);
|
|
|
|
- //
|
|
|
|
- // SDDX_TEMPLATE_PAPER =
|
|
|
|
- // CONFIGURATION.getTemplate("sddx_paper_template.ftl", ENCODING);
|
|
|
|
- // SDDX_TEMPLATE_ANSWER =
|
|
|
|
- // CONFIGURATION.getTemplate("sddx_answer_template.ftl", ENCODING);
|
|
|
|
- //
|
|
|
|
- // TJDX_TEMPLATE_PAPER =
|
|
|
|
- // CONFIGURATION.getTemplate("tjdx_paper_template.ftl", ENCODING);
|
|
|
|
- // TJDX_TEMPLATE_ANSWER =
|
|
|
|
- // CONFIGURATION.getTemplate("tjdx_answer_template.ftl", ENCODING);
|
|
|
|
- // TJDX_OUTLINE_TEMPLATE_PAPER =
|
|
|
|
- // CONFIGURATION.getTemplate("tjdx_outline_paper_template.ftl",
|
|
|
|
- // ENCODING);
|
|
|
|
- //
|
|
|
|
- // XNJD_TEMPLATE_PAPER =
|
|
|
|
- // CONFIGURATION.getTemplate("xnjd_paper_template.ftl", ENCODING);
|
|
|
|
- // XNJD_TEMPLATE_ANSWER =
|
|
|
|
- // CONFIGURATION.getTemplate("xnjd_answer_template.ftl", ENCODING);
|
|
|
|
- // XNJD_OUTLINE_TEMPLATE_PAPER =
|
|
|
|
- // CONFIGURATION.getTemplate("xnjd_outline_paper_template.ftl",
|
|
|
|
- // ENCODING);
|
|
|
|
- //
|
|
|
|
- // SYDX_TEMPLATE_PAPER =
|
|
|
|
- // CONFIGURATION.getTemplate("sydx_paper_template.ftl", ENCODING);
|
|
|
|
- // SYDX_TEMPLATE_ANSWER =
|
|
|
|
- // CONFIGURATION.getTemplate("sydx_answer_template.ftl", ENCODING);
|
|
|
|
- //
|
|
|
|
- // XAJD_TEMPLATE_PAPER =
|
|
|
|
- // CONFIGURATION.getTemplate("xajd_paper_template.ftl", ENCODING);
|
|
|
|
- // XAJD_TEMPLATE_ANSWER =
|
|
|
|
- // CONFIGURATION.getTemplate("xajd_answer_template.ftl", ENCODING);
|
|
|
|
- //
|
|
|
|
- // RJGC_TMPLATE_PAPER =
|
|
|
|
- // CONFIGURATION.getTemplate("rjgc_paper_template.ftl", ENCODING);
|
|
|
|
- // RJGC_TMPLATE_ANSWER =
|
|
|
|
- // CONFIGURATION.getTemplate("rjgc_answer_template.ftl", ENCODING);
|
|
|
|
- //
|
|
|
|
- // BJSF_TMPLATE_PAPER =
|
|
|
|
- // CONFIGURATION.getTemplate("bjsf_paper_template.ftl", ENCODING);
|
|
|
|
- // BJSF_TMPLATE_ANSWER =
|
|
|
|
- // CONFIGURATION.getTemplate("bjsf_answer_template.ftl", ENCODING);
|
|
|
|
- //
|
|
|
|
- // CQDX_TMPLATE_PAPER =
|
|
|
|
- // CONFIGURATION.getTemplate("cqdx_paper_template.ftl", ENCODING);
|
|
|
|
- // CQDX_TMPLATE_ANSWER =
|
|
|
|
- // CONFIGURATION.getTemplate("cqdx_answer_template.ftl", ENCODING);
|
|
|
|
- //
|
|
|
|
- // FJSF_TMPLATE_PAPER =
|
|
|
|
- // CONFIGURATION.getTemplate("fjsf_paper_template.ftl", ENCODING);
|
|
|
|
- // FJSF_TMPLATE_ANSWER =
|
|
|
|
- // CONFIGURATION.getTemplate("fjsf_answer_template.ftl", ENCODING);
|
|
|
|
- //
|
|
|
|
- // CUGB_TMPLATE_PAPER =
|
|
|
|
- // CONFIGURATION.getTemplate("cugb_paper_template.ftl", ENCODING);
|
|
|
|
- // CUGB_TMPLATE_ANSWER =
|
|
|
|
- // CONFIGURATION.getTemplate("cugb_answer_template.ftl", ENCODING);
|
|
|
|
- //
|
|
|
|
- // WHEQX_TMPLATE_PAPER =
|
|
|
|
- // CONFIGURATION.getTemplate("wheqx_paper_template.ftl", ENCODING);
|
|
|
|
- // WHEQX_TMPLATE_ANSWER =
|
|
|
|
- // CONFIGURATION.getTemplate("wheqx_answer_template.ftl", ENCODING);
|
|
|
|
- //
|
|
|
|
- // HNSF_TMPLATE_PAPER =
|
|
|
|
- // CONFIGURATION.getTemplate("hnsf_paper_template.ftl", ENCODING);
|
|
|
|
- // HNSF_TMPLATE_ANSWER =
|
|
|
|
- // CONFIGURATION.getTemplate("hnsf_answer_template.ftl", ENCODING);
|
|
|
|
- //
|
|
|
|
- // YKDX_TMPLATE_PAPER =
|
|
|
|
- // CONFIGURATION.getTemplate("ykdx_paper_template.ftl", ENCODING);
|
|
|
|
- // YKDX_TMPLATE_ANSWER =
|
|
|
|
- // CONFIGURATION.getTemplate("ykdx_answer_template.ftl", ENCODING);
|
|
|
|
- //
|
|
|
|
- // BJJT_TMPLATE_PAPER =
|
|
|
|
- // CONFIGURATION.getTemplate("bjjt_paper_template.ftl", ENCODING);
|
|
|
|
- // BJJT_TMPLATE_ANSWER =
|
|
|
|
- // CONFIGURATION.getTemplate("bjjt_answer_template.ftl", ENCODING);
|
|
|
|
- //
|
|
|
|
- // ZGDDW_TMPLATE_PAPER =
|
|
|
|
- // CONFIGURATION.getTemplate("zgddw_paper_template.ftl", ENCODING);
|
|
|
|
- // ZGDDW_TMPLATE_ANSWER =
|
|
|
|
- // CONFIGURATION.getTemplate("zgddw_answer_template.ftl", ENCODING);
|
|
|
|
- //
|
|
|
|
- // ZGDDB_TMPLATE_PAPER =
|
|
|
|
- // CONFIGURATION.getTemplate("zgddb_paper_template.ftl", ENCODING);
|
|
|
|
- // ZGDDB_TMPLATE_ANSWER =
|
|
|
|
- // CONFIGURATION.getTemplate("zgddb_answer_template.ftl", ENCODING);
|
|
|
|
- //
|
|
|
|
- // DBSF_TMPLATE_PAPER =
|
|
|
|
- // CONFIGURATION.getTemplate("dbsf_paper_template.ftl", ENCODING);
|
|
|
|
- // DBSF_TMPLATE_ANSWER =
|
|
|
|
- // CONFIGURATION.getTemplate("dbsf_answer_template.ftl", ENCODING);
|
|
|
|
- //
|
|
|
|
- // NKDX_TMPLATE_PAPER =
|
|
|
|
- // CONFIGURATION.getTemplate("nkdx_paper_template.ftl", ENCODING);
|
|
|
|
- // NKDX_TMPLATE_ANSWER =
|
|
|
|
- // CONFIGURATION.getTemplate("nkdx_answer_template.ftl", ENCODING);
|
|
|
|
- //
|
|
|
|
- // BJHK_TMPLATE_PAPER =
|
|
|
|
- // CONFIGURATION.getTemplate("bjhk_paper_template.ftl", ENCODING);
|
|
|
|
- // BJHK_TMPLATE_ANSWER =
|
|
|
|
- // CONFIGURATION.getTemplate("bjhk_answer_template.ftl", ENCODING);
|
|
|
|
- //
|
|
|
|
- // FDSF_TMPLATE_PAPER =
|
|
|
|
- // CONFIGURATION.getTemplate("fdsf_paper_template.ftl", ENCODING);
|
|
|
|
- // FDSF_TMPLATE_ANSWER =
|
|
|
|
- // CONFIGURATION.getTemplate("fdsf_answer_template.ftl", ENCODING);
|
|
|
|
- // } catch (Exception e) {
|
|
|
|
- // log.error(e.getMessage(), e);
|
|
|
|
- // }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -437,8 +195,26 @@ public abstract class ExportPaperAbstractService {
|
|
* @param zipFileName
|
|
* @param zipFileName
|
|
* @throws Exception
|
|
* @throws Exception
|
|
*/
|
|
*/
|
|
- public abstract void downloadPaper(Long rootOrgId, String paperId, String zipFileName, String examType)
|
|
|
|
- throws Exception;
|
|
|
|
|
|
+ public void downloadPaper(DownloadPaperDto dto) throws Exception {
|
|
|
|
+ PaperExp paperExp = initPaperExp(dto);
|
|
|
|
+ if (paperExp != null) {
|
|
|
|
+ String paperfileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_"
|
|
|
|
+ + ExamFileType.PAPER.getName() + DOCX_SUFFIX;
|
|
|
|
+ File directory = new File(TEMP_FILE_EXP + File.separator + dto.getZipFileName());
|
|
|
|
+ if (OFFLINE.equals(dto.getExamType())) {
|
|
|
|
+ if (StringUtils.isBlank(paperExp.getExamRemark())) {
|
|
|
|
+ paperExp.setExamRemark("<p></p>");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ExportPaperUtil.createPaperDocFile(dto.getRootOrgId(),paperExp, directory,paperfileName, ExportTemplateType.OUTLINE_PAPER_EXPORT);
|
|
|
|
+ } else {
|
|
|
|
+ ExportPaperUtil.createPaperDocFile(dto.getRootOrgId(),paperExp, directory,paperfileName, ExportTemplateType.PAPER_EXPORT);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 下载音频
|
|
|
|
+ downloadAudio(paperExp, dto.getZipFileName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* 下载答案
|
|
* 下载答案
|
|
@@ -447,7 +223,15 @@ public abstract class ExportPaperAbstractService {
|
|
* @param zipFileName
|
|
* @param zipFileName
|
|
* @throws Exception
|
|
* @throws Exception
|
|
*/
|
|
*/
|
|
- public abstract void downloadPaperAnswer(Long rootOrgId, String paperId, String zipFileName) throws Exception;
|
|
|
|
|
|
+ public void downloadPaperAnswer(DownloadPaperDto dto) throws Exception {
|
|
|
|
+ PaperExp paperExp = initPaperExp(dto);
|
|
|
|
+ if (paperExp != null) {
|
|
|
|
+ String answerFileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_"
|
|
|
|
+ + ExamFileType.ANSWER.getName() + DOCX_SUFFIX;
|
|
|
|
+ File directory = new File(TEMP_FILE_EXP + File.separator + dto.getZipFileName());
|
|
|
|
+ ExportPaperUtil.createPaperDocFile(dto.getRootOrgId(),paperExp, directory,answerFileName, ExportTemplateType.ANWSER_EXPORT);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* 上传试卷相关文件
|
|
* 上传试卷相关文件
|
|
@@ -458,46 +242,41 @@ public abstract class ExportPaperAbstractService {
|
|
* @param accessUser
|
|
* @param accessUser
|
|
* @throws Exception
|
|
* @throws Exception
|
|
*/
|
|
*/
|
|
- public abstract void uploadFile(ExtractConfig extractConfig, String paperId, ExportStructure exportStructure,
|
|
|
|
- User accessUser, ExamPaper examPaper) throws Exception;
|
|
|
|
|
|
+ public void uploadFile(ExtractConfig extractConfig, String paperId, ExportStructure exportStructure,
|
|
|
|
+ User accessUser, ExamPaper examPaper,PaperSeqMode seqMode){
|
|
|
|
+ DownloadPaperDto dto=new DownloadPaperDto();
|
|
|
|
+ dto.setPaperId(paperId);
|
|
|
|
+ dto.setSeqMode(seqMode);
|
|
|
|
+ PaperExp paperExp = initPaperExp(dto);
|
|
|
|
+ if (paperExp != null) {
|
|
|
|
+ String currNum = CommonUtils.getCurNum();
|
|
|
|
+ // 没有试卷结构导出设置
|
|
|
|
+ if (exportStructure == null) {
|
|
|
|
+ // 上传试卷
|
|
|
|
+ uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum,
|
|
|
|
+ ExportTemplateType.PAPER_EXPORT, ExamFileType.PAPER, examPaper);
|
|
|
|
+ // 上传答案
|
|
|
|
+ uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum,
|
|
|
|
+ ExportTemplateType.ANWSER_EXPORT, ExamFileType.ANSWER, examPaper);
|
|
|
|
+ } else if (exportStructure != null && exportStructure.getExportType() == ExportType.NORMAL) {
|
|
|
|
+ List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
|
|
|
|
+ // 检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
|
|
|
|
+ checkObjectiveDetailsNum(paperExp, questionTypeNums);
|
|
|
|
+ // 上传试卷
|
|
|
|
+ uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum,
|
|
|
|
+ ExportTemplateType.PAPER_EXPORT, ExamFileType.PAPER, examPaper);
|
|
|
|
+ // 上传答案
|
|
|
|
+ uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum,
|
|
|
|
+ ExportTemplateType.ANWSER_EXPORT, ExamFileType.ANSWER, examPaper);
|
|
|
|
+ // 上传试卷结构 不能在上传试卷和答案之前
|
|
|
|
+ uploadPaperStructure(paperExp, extractConfig, accessUser, currNum, questionTypeNums, examPaper);
|
|
|
|
+ } else if (exportStructure != null && exportStructure.getExportType() == ExportType.ONLINE) {
|
|
|
|
+ // 上传机考JSON文件
|
|
|
|
+ uploadComputerTestFile(extractConfig, accessUser, examPaper);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
|
- * 设置选项号
|
|
|
|
- *
|
|
|
|
- * @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();
|
|
|
|
- // }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 将数字1,2,3,4转化成A,B,C,D
|
|
* 将数字1,2,3,4转化成A,B,C,D
|
|
@@ -510,265 +289,6 @@ public abstract class ExportPaperAbstractService {
|
|
return String.valueOf(optionNum);
|
|
return String.valueOf(optionNum);
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * 替换填空 将###替换为下划线_______
|
|
|
|
- *
|
|
|
|
- * @param wordMl
|
|
|
|
- * @param num
|
|
|
|
- * @return
|
|
|
|
- * @throws Exception
|
|
|
|
- */
|
|
|
|
- // public 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<>();
|
|
|
|
- // 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();
|
|
|
|
- // // 1
|
|
|
|
- // if ("##".equals(str.trim())) {
|
|
|
|
- // str = "___";
|
|
|
|
- // text.setValue(str);
|
|
|
|
- // }
|
|
|
|
- // // 2
|
|
|
|
- // str = str.replaceAll("###", "______");
|
|
|
|
- // text.setValue(str);
|
|
|
|
- // // 3
|
|
|
|
- // Pattern pattern = Pattern.compile("##\\d{1,}##");
|
|
|
|
- // Matcher m = pattern.matcher(str);
|
|
|
|
- // while (m.find()) {
|
|
|
|
- // int curNum = num + index;
|
|
|
|
- // String a = m.group();
|
|
|
|
- // str = str.replaceAll(a, "___" + (curNum) + "___");
|
|
|
|
- // text.setValue(str);
|
|
|
|
- // index++;
|
|
|
|
- // }
|
|
|
|
- // // 4
|
|
|
|
- // /*
|
|
|
|
- // * if(str.startsWith("#") || str.equals("___")){
|
|
|
|
- // * curMap.put(cur,str); text.setValue(""); }
|
|
|
|
- // */
|
|
|
|
- // // 5
|
|
|
|
- // if (str.matches("^\\d{1,}$")) {
|
|
|
|
- // String preStr = curMap.get(cur - 1);
|
|
|
|
- // int curNum = num + index;
|
|
|
|
- // if (!StringUtils.isEmpty(preStr) && preStr.startsWith("#")) {
|
|
|
|
- // 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 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();
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 处理Word的题干选项 1.设置题号 2.给小题选项进行排序 3.设置选项号 4.替换题干中的##为____
|
|
|
|
- */
|
|
|
|
- // public void setQuestionNumberForWord(List<PaperDetailExp> details) throws
|
|
|
|
- // Exception {
|
|
|
|
- // if (CollectionUtils.isEmpty(details)) {
|
|
|
|
- // return;
|
|
|
|
- // }
|
|
|
|
- //
|
|
|
|
- // for (PaperDetailExp detail : details) {
|
|
|
|
- // List<PaperDetailUnitExp> units = detail.getPaperDetailUnits();
|
|
|
|
- // for (PaperDetailUnitExp unit : units) {
|
|
|
|
- // Question question = unit.getQuestion();
|
|
|
|
- //
|
|
|
|
- // // 定义一个字段,用来判断是否为选择题
|
|
|
|
- // boolean isOption = false;
|
|
|
|
- // List<QuesOption> options = question.getQuesOptions();
|
|
|
|
- // if (CollectionUtils.isNotEmpty(options)) {
|
|
|
|
- // isOption = true;
|
|
|
|
- // int index = 0;
|
|
|
|
- // for (QuesOption option : options) {
|
|
|
|
- // option.setOptionBodyWord(setOptionNum(option.getOptionBodyWord(),
|
|
|
|
- // getOptionNum(index)));
|
|
|
|
- // index++;
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- //
|
|
|
|
- // if (isOption) {
|
|
|
|
- // // 检测选项是否换行
|
|
|
|
- // int i = optionLine(options);
|
|
|
|
- // if (i == 4) {
|
|
|
|
- // optionListFourline(options);
|
|
|
|
- // }
|
|
|
|
- // if (i == 2) {
|
|
|
|
- // optionListTwoline(options);
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- //
|
|
|
|
- // List<Question> subQuestions = question.getSubQuestions();
|
|
|
|
- // if (CollectionUtils.isNotEmpty(subQuestions)) {
|
|
|
|
- // // 套题主题干
|
|
|
|
- // question.setQuesBodyWord(
|
|
|
|
- // replaceQuesBlank(question.getQuesBodyWord(),
|
|
|
|
- // subQuestions.get(0).getNumber()));
|
|
|
|
- //
|
|
|
|
- // for (Question subQues : subQuestions) {
|
|
|
|
- // // 处理子题题干,答案
|
|
|
|
- // subQues.setQuesBodyWord(setSubQuesNum(subQues.getQuesBodyWord(),
|
|
|
|
- // subQues.getNumber()));
|
|
|
|
- // subQues.setQuesAnswerWord(setSubQuesNum(subQues.getQuesAnswerWord(),
|
|
|
|
- // subQues.getNumber()));
|
|
|
|
- // subQues.setQuesBodyWord(replaceQuesBlank(subQues.getQuesBodyWord(),
|
|
|
|
- // subQues.getNumber()));
|
|
|
|
- //
|
|
|
|
- // List<QuesOption> subOptions = subQues.getQuesOptions();
|
|
|
|
- // if (CollectionUtils.isNotEmpty(subOptions)) {
|
|
|
|
- // int subIndex = 0;
|
|
|
|
- // for (QuesOption subOption : subOptions) {
|
|
|
|
- // subOption.setOptionBodyWord(
|
|
|
|
- // setOptionNum(subOption.getOptionBodyWord(), getOptionNum(subIndex)));
|
|
|
|
- // subIndex++;
|
|
|
|
- // }
|
|
|
|
- //
|
|
|
|
- // // 检测选项是否换行
|
|
|
|
- // int i = optionLine(subOptions);
|
|
|
|
- // if (i == 4) {
|
|
|
|
- // optionListFourline(subOptions);
|
|
|
|
- // }
|
|
|
|
- // if (i == 2) {
|
|
|
|
- // optionListTwoline(subOptions);
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // } else {
|
|
|
|
- // // 处理非套题题干、答案
|
|
|
|
- // question.setQuesBodyWord(setSubQuesNum(question.getQuesBodyWord(),
|
|
|
|
- // unit.getNumber()));
|
|
|
|
- // question.setQuesAnswerWord(setSubQuesNum(question.getQuesAnswerWord(),
|
|
|
|
- // unit.getNumber()));
|
|
|
|
- //
|
|
|
|
- // question.setQuesBodyWord(replaceQuesBlank(question.getQuesBodyWord(),
|
|
|
|
- // unit.getNumber()));
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 检测同一行可以放多少个选项
|
|
|
|
- *
|
|
|
|
- * @param optionList
|
|
|
|
- * @return
|
|
|
|
- * @throws Exception
|
|
|
|
- */
|
|
|
|
- // private int optionLine(List<QuesOption> optionList) throws Exception {
|
|
|
|
- // int four = 0;
|
|
|
|
- // String tmpText = "";
|
|
|
|
- // for (int i = 0; i < optionList.size(); i++) {
|
|
|
|
- // QuesOption quesOption = optionList.get(i);
|
|
|
|
- // List<Object> pList = getPlist(quesOption);
|
|
|
|
- // if (pList == null || pList.size() == 0) {
|
|
|
|
- // four++;
|
|
|
|
- // continue;
|
|
|
|
- // }
|
|
|
|
- // // 判断是否为纯文本
|
|
|
|
- // boolean isText = DocxProcessUtil.isText((P) pList.get(0));
|
|
|
|
- // if (isText) {
|
|
|
|
- // tmpText = DocxProcessUtil.getPText((P) pList.get(0));
|
|
|
|
- // // 如果四个选项在同一行,长度不能超过64
|
|
|
|
- // if (optionsLength(tmpText) < 18) {
|
|
|
|
- // four++;
|
|
|
|
- // } else if (optionsLength(tmpText) < 42) {
|
|
|
|
- // // 什么都不做
|
|
|
|
- // } else {
|
|
|
|
- // return 1;
|
|
|
|
- // }
|
|
|
|
- // } else {
|
|
|
|
- // return 1;
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // if (four == optionList.size()) {
|
|
|
|
- // return 4;
|
|
|
|
- // } else {
|
|
|
|
- // return 2;
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 根据选项得到选项段落
|
|
|
|
- *
|
|
|
|
- * @param quesOption
|
|
|
|
- * @return
|
|
|
|
- * @throws Exception
|
|
|
|
- */
|
|
|
|
- // private List<Object> getPlist(QuesOption quesOption) throws Exception {
|
|
|
|
- // String optionBodyWordMl = quesOption.getOptionBodyWord();
|
|
|
|
- // String tmpStr = DocxProcessUtil.BODY_HEADER + optionBodyWordMl +
|
|
|
|
- // DocxProcessUtil.BODY_TAIL;
|
|
|
|
- // Body body = (Body) XmlUtils.unmarshalString(tmpStr, Context.jc,
|
|
|
|
- // Body.class);
|
|
|
|
- // List<Object> pList = body.getContent();
|
|
|
|
- // return pList;
|
|
|
|
- // }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 计算选项长度
|
|
* 计算选项长度
|
|
@@ -782,175 +302,6 @@ public abstract class ExportPaperAbstractService {
|
|
return term.length();
|
|
return term.length();
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * 两个选项在同一行
|
|
|
|
- *
|
|
|
|
- * @param optionList
|
|
|
|
- * @throws Exception
|
|
|
|
- */
|
|
|
|
- // public void optionListTwoline(List<QuesOption> optionList) throws
|
|
|
|
- // Exception {
|
|
|
|
- // for (int i = 0; i < optionList.size(); i++) {
|
|
|
|
- // QuesOption quesOption = optionList.get(i);
|
|
|
|
- // String optionBodyWordMl = quesOption.getOptionBodyWord();
|
|
|
|
- // String tmpStr = DocxProcessUtil.BODY_HEADER + optionBodyWordMl +
|
|
|
|
- // DocxProcessUtil.BODY_TAIL;
|
|
|
|
- // Body body = (Body) XmlUtils.unmarshalString(tmpStr, Context.jc,
|
|
|
|
- // Body.class);
|
|
|
|
- // List<Object> pList = body.getContent();
|
|
|
|
- // // 首选项添加tabs标签
|
|
|
|
- // if (i % 2 == 0) {
|
|
|
|
- // if (pList.size() > 0) {
|
|
|
|
- // P p = (P) pList.get(0);
|
|
|
|
- // // 添加tabs标签
|
|
|
|
- // addTabs(p, 1);
|
|
|
|
- // StringBuffer pWordMl = new StringBuffer();
|
|
|
|
- // for (Object pObj : pList) {
|
|
|
|
- // if (pObj instanceof P) {
|
|
|
|
- // pWordMl.append(DocxProcessUtil.formatPWordMl(XmlUtils.marshaltoString(pObj)));
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // quesOption.setOptionBodyWord(pWordMl.toString());
|
|
|
|
- // }
|
|
|
|
- // } else {
|
|
|
|
- // if (pList.size() > 0) {
|
|
|
|
- // String tmpText = DocxProcessUtil.getPText((P) pList.get(0));
|
|
|
|
- // optionMerge(optionList.get((i / 2) * 2), tmpText, true);
|
|
|
|
- // quesOption.setOptionBodyWord("");
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 四个选项在同一行
|
|
|
|
- */
|
|
|
|
- // public void optionListFourline(List<QuesOption> optionList) throws
|
|
|
|
- // Exception {
|
|
|
|
- // for (int i = 0; i < optionList.size(); i++) {
|
|
|
|
- // Boolean isAddTbale = false;
|
|
|
|
- // QuesOption quesOption = optionList.get(i);
|
|
|
|
- // String optionBodyWordMl = quesOption.getOptionBodyWord();
|
|
|
|
- // String tmpStr = DocxProcessUtil.BODY_HEADER + optionBodyWordMl +
|
|
|
|
- // DocxProcessUtil.BODY_TAIL;
|
|
|
|
- // Body body = (Body) XmlUtils.unmarshalString(tmpStr, Context.jc,
|
|
|
|
- // Body.class);
|
|
|
|
- // List<Object> pList = body.getContent();
|
|
|
|
- // P p = null;
|
|
|
|
- // if (pList == null || pList.size() == 0) {
|
|
|
|
- // p = new P();
|
|
|
|
- // } else {
|
|
|
|
- // p = (P) pList.get(0);
|
|
|
|
- // }
|
|
|
|
- // // 首选项添加tabs标签
|
|
|
|
- // if (i % 4 == 0) {
|
|
|
|
- // isAddTbale = true;
|
|
|
|
- // // 添加tabs标签
|
|
|
|
- // addTabs(p, 3);
|
|
|
|
- // StringBuffer pWordMl = new StringBuffer();
|
|
|
|
- // for (Object pObj : pList) {
|
|
|
|
- // if (pObj instanceof P) {
|
|
|
|
- // pWordMl.append(DocxProcessUtil.formatPWordMl(XmlUtils.marshaltoString(pObj)));
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // quesOption.setOptionBodyWord(pWordMl.toString());
|
|
|
|
- // } else {
|
|
|
|
- // String tmpText = DocxProcessUtil.getPText(p);
|
|
|
|
- // if ((i + 1) % 4 == 0) {
|
|
|
|
- // isAddTbale = true;
|
|
|
|
- // }
|
|
|
|
- // optionMerge(optionList.get((i / 4) * 4), tmpText, isAddTbale);
|
|
|
|
- // quesOption.setOptionBodyWord("");
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 在p标签中添加tabs标签
|
|
|
|
- *
|
|
|
|
- * @param p
|
|
|
|
- */
|
|
|
|
- // public void addTabs(P p, int tabNumbers) {
|
|
|
|
- // // 添加tabs标签
|
|
|
|
- // PPr pPr = p.getPPr();
|
|
|
|
- // if (pPr == null) {
|
|
|
|
- // pPr = new PPr();
|
|
|
|
- // p.getContent().add(0, pPr);
|
|
|
|
- // }
|
|
|
|
- // Tabs tabs = new Tabs();
|
|
|
|
- // if (tabNumbers == 3) {
|
|
|
|
- // // 添加tabs
|
|
|
|
- // CTTabStop tab1 = new CTTabStop();
|
|
|
|
- // tab1.setVal(STTabJc.LEFT);
|
|
|
|
- // tab1.setPos(BigInteger.valueOf(2268));
|
|
|
|
- // CTTabStop tab2 = new CTTabStop();
|
|
|
|
- // tab2.setVal(STTabJc.LEFT);
|
|
|
|
- // tab2.setPos(BigInteger.valueOf(4536));
|
|
|
|
- // CTTabStop tab3 = new CTTabStop();
|
|
|
|
- // tab3.setVal(STTabJc.LEFT);
|
|
|
|
- // tab3.setPos(BigInteger.valueOf(7230));
|
|
|
|
- // tabs.getTab().add(tab1);
|
|
|
|
- // tabs.getTab().add(tab2);
|
|
|
|
- // tabs.getTab().add(tab3);
|
|
|
|
- // } else {
|
|
|
|
- // CTTabStop tab1 = new CTTabStop();
|
|
|
|
- // tab1.setVal(STTabJc.LEFT);
|
|
|
|
- // tab1.setPos(BigInteger.valueOf(4536));
|
|
|
|
- // tabs.getTab().add(tab1);
|
|
|
|
- // }
|
|
|
|
- // pPr.setTabs(tabs);
|
|
|
|
- // List<Object> pContent = p.getContent();
|
|
|
|
- // addTab(pContent);
|
|
|
|
- // }
|
|
|
|
- //
|
|
|
|
- // /**
|
|
|
|
- // * 每行添加tab标签
|
|
|
|
- // *
|
|
|
|
- // * @param content
|
|
|
|
- // */
|
|
|
|
- // public void addTab(List<Object> content) {
|
|
|
|
- // R run = new R();
|
|
|
|
- // R.Tab tab = new R.Tab();
|
|
|
|
- // run.getContent().add(tab);
|
|
|
|
- // content.add(run);
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 选项合并
|
|
|
|
- *
|
|
|
|
- * @param tmpText
|
|
|
|
- * @param isLast
|
|
|
|
- * @throws Exception
|
|
|
|
- */
|
|
|
|
- // public void optionMerge(QuesOption option, String tmpText, Boolean
|
|
|
|
- // isLast) throws Exception {
|
|
|
|
- // String optionBodyWordMl = option.getOptionBodyWord();
|
|
|
|
- // String tmpStr = DocxProcessUtil.BODY_HEADER + optionBodyWordMl +
|
|
|
|
- // DocxProcessUtil.BODY_TAIL;
|
|
|
|
- // Body body = (Body) XmlUtils.unmarshalString(tmpStr, Context.jc,
|
|
|
|
- // Body.class);
|
|
|
|
- // List<Object> pList = body.getContent();
|
|
|
|
- // if (pList.size() > 0) {
|
|
|
|
- // P p = (P) pList.get(pList.size() - 1);
|
|
|
|
- // List<Object> pContent = p.getContent();
|
|
|
|
- // R run = new R();
|
|
|
|
- // Text text = new Text();
|
|
|
|
- // text.setValue(tmpText);
|
|
|
|
- // run.getContent().add(text);
|
|
|
|
- // pContent.add(run);
|
|
|
|
- // // 每个选项添加tab结束标签
|
|
|
|
- // if (!isLast) {
|
|
|
|
- // addTab(pContent);
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // StringBuffer pWordMl = new StringBuffer();
|
|
|
|
- // for (Object pObj : pList) {
|
|
|
|
- // if (pObj instanceof P) {
|
|
|
|
- // pWordMl.append(DocxProcessUtil.formatPWordMl(XmlUtils.marshaltoString(pObj)));
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // option.setOptionBodyWord(pWordMl.toString());
|
|
|
|
- // }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 设置大题标题
|
|
* 设置大题标题
|
|
@@ -1003,8 +354,7 @@ public abstract class ExportPaperAbstractService {
|
|
* @param accessUser
|
|
* @param accessUser
|
|
* @throws IOException
|
|
* @throws IOException
|
|
*/
|
|
*/
|
|
- protected void uploadComputerTestFile(ExtractConfig extractConfig, User accessUser, ExamPaper examPaper)
|
|
|
|
- throws IOException {
|
|
|
|
|
|
+ protected void uploadComputerTestFile(ExtractConfig extractConfig, User accessUser, ExamPaper examPaper){
|
|
List<ComputerTestPaper> computerTestPaperList = buildComputerTestJsonService
|
|
List<ComputerTestPaper> computerTestPaperList = buildComputerTestJsonService
|
|
.buildComputerTestPapers(extractConfig);
|
|
.buildComputerTestPapers(extractConfig);
|
|
String currentTimeStr = CommonUtils.getCurNum();
|
|
String currentTimeStr = CommonUtils.getCurNum();
|
|
@@ -1505,31 +855,6 @@ public abstract class ExportPaperAbstractService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * 获取当前试卷下所有试题WordPkg
|
|
|
|
- *
|
|
|
|
- * @param id
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- // 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());
|
|
|
|
- // return wordMLPackages;
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- // private WordprocessingMLPackage getPkgObj(Question question) {
|
|
|
|
- // String pkgPathId = question.getQuesPkgPathId();
|
|
|
|
- // QuestionPkgPath quesPkg = quesPkgPathRepo.findFirstById(pkgPathId);
|
|
|
|
- // if (quesPkg == null) {
|
|
|
|
- // byte[] bytes = new byte[0];
|
|
|
|
- // return DocxProcessUtil.getPkg(bytes);
|
|
|
|
- // }
|
|
|
|
- // byte[] pkgByte = quesPkg.getQuesPkg();
|
|
|
|
- // return DocxProcessUtil.getPkg(pkgByte);
|
|
|
|
- // }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 筛选出试卷类型
|
|
* 筛选出试卷类型
|
|
@@ -1633,11 +958,11 @@ public abstract class ExportPaperAbstractService {
|
|
/*
|
|
/*
|
|
* 用于导出Word试卷和试卷答案
|
|
* 用于导出Word试卷和试卷答案
|
|
*/
|
|
*/
|
|
- public PaperExp initPaperExp(String paperId) throws Exception {
|
|
|
|
- PaperExp exportPaper = initPaperExpService.initPaperExp(paperId);
|
|
|
|
|
|
+ public PaperExp initPaperExp(DownloadPaperDto dto){
|
|
|
|
+ PaperExp exportPaper = initPaperExpService.initPaperExp(dto);
|
|
|
|
|
|
// 给新的大题下所有小题排序
|
|
// 给新的大题下所有小题排序
|
|
- sortPaperDetailUnits(exportPaper.getPaperDetails());
|
|
|
|
|
|
+// sortPaperDetailUnits(exportPaper.getPaperDetails());
|
|
|
|
|
|
// 如果每个小题分数不一样,题干后面添加分数
|
|
// 如果每个小题分数不一样,题干后面添加分数
|
|
setQuestionScore(exportPaper.getPaperDetails(), true);
|
|
setQuestionScore(exportPaper.getPaperDetails(), true);
|
|
@@ -1654,10 +979,12 @@ public abstract class ExportPaperAbstractService {
|
|
* 用于页面上预览PDF试卷
|
|
* 用于页面上预览PDF试卷
|
|
*/
|
|
*/
|
|
public PaperExp previewPaperForPDF(Paper paper) {
|
|
public PaperExp previewPaperForPDF(Paper paper) {
|
|
- PaperExp previewPaper = initPaperExpService.initPaperExp(paper);
|
|
|
|
|
|
+ DownloadPaperDto dto=new DownloadPaperDto();
|
|
|
|
+ dto.setSeqMode(PaperSeqMode.MODE3);
|
|
|
|
+ PaperExp previewPaper = initPaperExpService.initPaperExp(paper,dto);
|
|
|
|
|
|
// 给新的大题下所有小题排序
|
|
// 给新的大题下所有小题排序
|
|
- sortPaperDetailUnits(previewPaper.getPaperDetails());
|
|
|
|
|
|
+// sortPaperDetailUnits(previewPaper.getPaperDetails());
|
|
|
|
|
|
// 如果每个小题分数不一致,题干后面添加分数;一致时则不用加
|
|
// 如果每个小题分数不一致,题干后面添加分数;一致时则不用加
|
|
setQuestionScore(previewPaper.getPaperDetails(), false);
|
|
setQuestionScore(previewPaper.getPaperDetails(), false);
|
|
@@ -1728,57 +1055,6 @@ public abstract class ExportPaperAbstractService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * 题干上设置分数内容(Word)
|
|
|
|
- */
|
|
|
|
- // public String appendScoreToQuestionWordBody(String wordStr, double score)
|
|
|
|
- // {
|
|
|
|
- // String totalScore =
|
|
|
|
- // BigDecimal.valueOf(score).stripTrailingZeros().toPlainString();
|
|
|
|
- // String scores = CommonUtils.clearZeroPoint(totalScore);
|
|
|
|
- //
|
|
|
|
- // String tmpStr = DocxProcessUtil.BODY_HEADER + wordStr +
|
|
|
|
- // DocxProcessUtil.BODY_TAIL;
|
|
|
|
- // Body body;
|
|
|
|
- // try {
|
|
|
|
- // body = (Body) XmlUtils.unmarshalString(tmpStr, Context.jc, Body.class);
|
|
|
|
- // } catch (Exception e) {
|
|
|
|
- // log.error(e.getMessage());
|
|
|
|
- // throw new StatusException("500", "Word解析异常!");
|
|
|
|
- // }
|
|
|
|
- //
|
|
|
|
- // List<Object> pList = body.getContent();
|
|
|
|
- // int index = 0;
|
|
|
|
- // for (Object pObj : pList) {
|
|
|
|
- // if (index == pList.size() - 1) {
|
|
|
|
- // List<Object> pContent = ((P) pObj).getContent();
|
|
|
|
- //
|
|
|
|
- // R run = new R();
|
|
|
|
- // Text text = new Text();
|
|
|
|
- // text.setValue("(" + scores + "分)");
|
|
|
|
- // run.getContent().add(text);
|
|
|
|
- // pContent.add(run);
|
|
|
|
- // }
|
|
|
|
- // index++;
|
|
|
|
- // }
|
|
|
|
- //
|
|
|
|
- // StringBuffer pWord = new StringBuffer();
|
|
|
|
- // for (Object pObj : pList) {
|
|
|
|
- // if (pObj instanceof P) {
|
|
|
|
- // String value;
|
|
|
|
- // try {
|
|
|
|
- // value = DocxProcessUtil.formatPWordMl(XmlUtils.marshaltoString(pObj));
|
|
|
|
- // } catch (Exception e) {
|
|
|
|
- // log.error(e.getMessage());
|
|
|
|
- // throw new StatusException("500", "Word解析异常!");
|
|
|
|
- // }
|
|
|
|
- //
|
|
|
|
- // pWord.append(value);
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- //
|
|
|
|
- // return pWord.toString();
|
|
|
|
- // }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 题干上设置分数内容(Html)
|
|
* 题干上设置分数内容(Html)
|
|
@@ -1934,41 +1210,5 @@ public abstract class ExportPaperAbstractService {
|
|
return CommonUtils.relaceQuestionIdx(str, 0);
|
|
return CommonUtils.relaceQuestionIdx(str, 0);
|
|
}
|
|
}
|
|
|
|
|
|
- // public Configuration getConfig(Long rootOrgId) {
|
|
|
|
- // Configuration config = configs.get(rootOrgId);
|
|
|
|
- // if (config == null) {
|
|
|
|
- // config = new Configuration(Configuration.VERSION_2_3_25);
|
|
|
|
- // // 设置编码
|
|
|
|
- // config.setDefaultEncoding(ENCODING);
|
|
|
|
- // // 设置ftl模板路径
|
|
|
|
- // String temPath =
|
|
|
|
- // PropertyHolder.getString("examcloud.web.sys.tempDataDir");
|
|
|
|
- // File dir = new File(temPath + File.separator + rootOrgId +
|
|
|
|
- // File.separator);
|
|
|
|
- // try {
|
|
|
|
- // config.setDirectoryForTemplateLoading(dir);
|
|
|
|
- // configs.put(rootOrgId, config);
|
|
|
|
- // } catch (IOException e) {
|
|
|
|
- // throw new StatusException("10001", "模板配置初始化出错 " + e.getMessage());
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // return config;
|
|
|
|
- // }
|
|
|
|
- //
|
|
|
|
- // public Template getTemplate(Long rootOrgId, ExportTemplateType type) {
|
|
|
|
- // String key = rootOrgId + "_" + type.getCode();
|
|
|
|
- // Template temp = templates.get(key);
|
|
|
|
- // String tname = exportTemplateService.getExportTemplateName(type,
|
|
|
|
- // rootOrgId);
|
|
|
|
- // if (temp == null || !temp.getName().equals(tname)) {
|
|
|
|
- // try {
|
|
|
|
- // temp = getConfig(rootOrgId).getTemplate(tname, ENCODING);
|
|
|
|
- // templates.put(key, temp);
|
|
|
|
- // } catch (IOException e) {
|
|
|
|
- // throw new StatusException("20002", "获取模板出错 " + e.getMessage());
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // return temp;
|
|
|
|
- // }
|
|
|
|
|
|
|
|
}
|
|
}
|