commit 3271fee5cca958ce35018f2bc9600d3ba86b839a
Author: Quentin <1771956812@qq.com>
Date: Tue Sep 29 09:43:13 2026 +0800
init: WordFileParse docx→HTML 解析服务(含 Word EQ 域公式修复)
服务:Spring Boot 3.2 + docx4j 8.3.9,POST /api/v3/server_office_file/file/parse
接受 .docx,返回 HTML(公式 → LaTeX,图片 → RustFS 外链)
公式支持三类来源:
- OMML(Word 2007+ 公式) → Python omml_mathml2latex
- MathType OLE 对象 → Ruby mathtype2mathml → MathML → LaTeX
- Word EQ 域(老教辅主力) → EqToLatexUtil(本次新增)
本次改动:
1. 新增 java-svc/.../core/EqToLatexUtil.java:
移植自 jby backend-services office-core,EQ 语法 → LaTeX
(\f→\dfrac、\r→\sqrt、\i→\int/\sum/\prod、\s→^{}/_{}、\b→\left\right、
\a→array、\x→\boxed/\overline、\o\al 堆叠、圈码、化学符号、极限、连等式)
品牌标记 JBYU* → WPU*,与采集端一致
2. CtoMathFinder:接上 EQ 分支(原为 not-ported 桩),域代码经
EqToLatexUtil.convert 转 LaTeX 写入 eqLatexMap(WPEQNUM 占位符)
3. WordParseUtil.dealPlaceholder:EQ 的 LaTeX 同样加 \( \) 包裹
(原先因 WPEQNUM 例外不加包裹,前端/MathJax 不渲染)
修前症状:教辅 Word 里分式/方程组/上下标整段丢失(如 {−1/3, 1} 变成 {-,1})
修后实测:46 份教辅 2908 处 EQ 域全部还原,公式总数 2954 处、零未包裹残留
安全:application.yml(含 RustFS 密钥)不入库,提供 application.yml.example;
OssService 的 @Value 默认密钥已清空
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b96bd4e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,18 @@
+# 构建产物
+java-svc/target/
+java-svc-jdk8/target/
+*.class
+*.jar
+!scripts/**/*.jar
+
+# 含密钥的本地配置(仓库里只放 application.yml.example)
+java-svc/src/main/resources/application.yml
+
+# 备份/临时
+*.bak-*
+*.log
+logs/
+.DS_Store
+__MACOSX/
+.idea/
+.vscode/
diff --git a/java-src/config/OfficeCoreConfig.java b/java-src/config/OfficeCoreConfig.java
new file mode 100644
index 0000000..0936bec
--- /dev/null
+++ b/java-src/config/OfficeCoreConfig.java
@@ -0,0 +1,413 @@
+/*
+ * Decompiled with CFR 0.152.
+ *
+ * Could not load the following classes:
+ * com.jby.common.util.SpringContextHolder
+ * org.apache.commons.lang3.StringUtils
+ * org.springframework.boot.context.properties.ConfigurationProperties
+ * org.springframework.cloud.context.config.annotation.RefreshScope
+ * org.springframework.stereotype.Component
+ */
+package com.jby.officecore.config;
+
+import com.jby.common.util.SpringContextHolder;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
+import org.springframework.stereotype.Component;
+
+@Component
+@RefreshScope
+@ConfigurationProperties(prefix="office.core.config")
+public class OfficeCoreConfig {
+ private String tmpPath = "/opt/files/tmp";
+ private String templatePath;
+ private Boolean deleteTmpFile = true;
+ private String foreLatexToMathMlApi = "https://test.xinjiaoyu.com/api/v3/server_node_sheet_new/latex/to-mathml";
+ private String latexToMathMlApi = "http://172.26.197.220:8050/latex_to_mathml";
+ private String mathMlToLatexApi = "http://172.26.197.220:8050/mathml_to_latex";
+ private Boolean mathMlToLatexApiSwitch;
+ private String mf2SvgApi = "http://test.format.xinjiaoyu.com/server_format/graphic/mf2svg";
+ private String downloadPdfApi = "https://test.xinjiaoyu.com/api/v3/server_node_sheet_new/office/download";
+ private String errorBookTemplate = "https://test.xinjiaoyu.com/main/print.html?%s#/downloadNotebook";
+ private Integer nodeConnectTimeout = 5000;
+ private Integer nodeSocketTimeout = 30000;
+ private Long contentLimit = 100000L;
+ private Double limitRatio = 0.6;
+ private Integer checkSize = 10;
+ private Double imageScalingFactor = 0.7;
+ private String copyrightAddresses = "www.zxxk.com,www.zujuan.com,www.jyeoo.com";
+ private Boolean newParseVersion;
+ private Boolean newDownloadVersion;
+ private Boolean openParseCache = true;
+ private Map> cleanStyleMap = new HashMap>();
+ private String transformScriptPath = "E:\\IdeaProject\\jby-project\\base_server\\jby-office\\jby-office-transform";
+
+ public String getTransformScriptPath() {
+ return this.isLocal() ? this.transformScriptPath : "/opt/servers/jby-office-transform";
+ }
+
+ public String getPythonCommand() {
+ return this.isLocal() ? "python" : "python3";
+ }
+
+ private boolean isLocal() {
+ String env = SpringContextHolder.getActiveProfile();
+ return StringUtils.isBlank((CharSequence)env) || env.contains("local");
+ }
+
+ public String getTmpPath() {
+ return this.tmpPath;
+ }
+
+ public String getTemplatePath() {
+ return this.templatePath;
+ }
+
+ public Boolean getDeleteTmpFile() {
+ return this.deleteTmpFile;
+ }
+
+ public String getForeLatexToMathMlApi() {
+ return this.foreLatexToMathMlApi;
+ }
+
+ public String getLatexToMathMlApi() {
+ return this.latexToMathMlApi;
+ }
+
+ public String getMathMlToLatexApi() {
+ return this.mathMlToLatexApi;
+ }
+
+ public Boolean getMathMlToLatexApiSwitch() {
+ return this.mathMlToLatexApiSwitch;
+ }
+
+ public String getMf2SvgApi() {
+ return this.mf2SvgApi;
+ }
+
+ public String getDownloadPdfApi() {
+ return this.downloadPdfApi;
+ }
+
+ public String getErrorBookTemplate() {
+ return this.errorBookTemplate;
+ }
+
+ public Integer getNodeConnectTimeout() {
+ return this.nodeConnectTimeout;
+ }
+
+ public Integer getNodeSocketTimeout() {
+ return this.nodeSocketTimeout;
+ }
+
+ public Long getContentLimit() {
+ return this.contentLimit;
+ }
+
+ public Double getLimitRatio() {
+ return this.limitRatio;
+ }
+
+ public Integer getCheckSize() {
+ return this.checkSize;
+ }
+
+ public Double getImageScalingFactor() {
+ return this.imageScalingFactor;
+ }
+
+ public String getCopyrightAddresses() {
+ return this.copyrightAddresses;
+ }
+
+ public Boolean getNewParseVersion() {
+ return this.newParseVersion;
+ }
+
+ public Boolean getNewDownloadVersion() {
+ return this.newDownloadVersion;
+ }
+
+ public Boolean getOpenParseCache() {
+ return this.openParseCache;
+ }
+
+ public Map> getCleanStyleMap() {
+ return this.cleanStyleMap;
+ }
+
+ public void setTmpPath(String tmpPath) {
+ this.tmpPath = tmpPath;
+ }
+
+ public void setTemplatePath(String templatePath) {
+ this.templatePath = templatePath;
+ }
+
+ public void setDeleteTmpFile(Boolean deleteTmpFile) {
+ this.deleteTmpFile = deleteTmpFile;
+ }
+
+ public void setForeLatexToMathMlApi(String foreLatexToMathMlApi) {
+ this.foreLatexToMathMlApi = foreLatexToMathMlApi;
+ }
+
+ public void setLatexToMathMlApi(String latexToMathMlApi) {
+ this.latexToMathMlApi = latexToMathMlApi;
+ }
+
+ public void setMathMlToLatexApi(String mathMlToLatexApi) {
+ this.mathMlToLatexApi = mathMlToLatexApi;
+ }
+
+ public void setMathMlToLatexApiSwitch(Boolean mathMlToLatexApiSwitch) {
+ this.mathMlToLatexApiSwitch = mathMlToLatexApiSwitch;
+ }
+
+ public void setMf2SvgApi(String mf2SvgApi) {
+ this.mf2SvgApi = mf2SvgApi;
+ }
+
+ public void setDownloadPdfApi(String downloadPdfApi) {
+ this.downloadPdfApi = downloadPdfApi;
+ }
+
+ public void setErrorBookTemplate(String errorBookTemplate) {
+ this.errorBookTemplate = errorBookTemplate;
+ }
+
+ public void setNodeConnectTimeout(Integer nodeConnectTimeout) {
+ this.nodeConnectTimeout = nodeConnectTimeout;
+ }
+
+ public void setNodeSocketTimeout(Integer nodeSocketTimeout) {
+ this.nodeSocketTimeout = nodeSocketTimeout;
+ }
+
+ public void setContentLimit(Long contentLimit) {
+ this.contentLimit = contentLimit;
+ }
+
+ public void setLimitRatio(Double limitRatio) {
+ this.limitRatio = limitRatio;
+ }
+
+ public void setCheckSize(Integer checkSize) {
+ this.checkSize = checkSize;
+ }
+
+ public void setImageScalingFactor(Double imageScalingFactor) {
+ this.imageScalingFactor = imageScalingFactor;
+ }
+
+ public void setCopyrightAddresses(String copyrightAddresses) {
+ this.copyrightAddresses = copyrightAddresses;
+ }
+
+ public void setNewParseVersion(Boolean newParseVersion) {
+ this.newParseVersion = newParseVersion;
+ }
+
+ public void setNewDownloadVersion(Boolean newDownloadVersion) {
+ this.newDownloadVersion = newDownloadVersion;
+ }
+
+ public void setOpenParseCache(Boolean openParseCache) {
+ this.openParseCache = openParseCache;
+ }
+
+ public void setCleanStyleMap(Map> cleanStyleMap) {
+ this.cleanStyleMap = cleanStyleMap;
+ }
+
+ public void setTransformScriptPath(String transformScriptPath) {
+ this.transformScriptPath = transformScriptPath;
+ }
+
+ public boolean equals(Object o) {
+ if (o == this) {
+ return true;
+ }
+ if (!(o instanceof OfficeCoreConfig)) {
+ return false;
+ }
+ OfficeCoreConfig other = (OfficeCoreConfig)o;
+ if (!other.canEqual(this)) {
+ return false;
+ }
+ String this$tmpPath = this.getTmpPath();
+ String other$tmpPath = other.getTmpPath();
+ if (this$tmpPath == null ? other$tmpPath != null : !this$tmpPath.equals(other$tmpPath)) {
+ return false;
+ }
+ String this$templatePath = this.getTemplatePath();
+ String other$templatePath = other.getTemplatePath();
+ if (this$templatePath == null ? other$templatePath != null : !this$templatePath.equals(other$templatePath)) {
+ return false;
+ }
+ Boolean this$deleteTmpFile = this.getDeleteTmpFile();
+ Boolean other$deleteTmpFile = other.getDeleteTmpFile();
+ if (this$deleteTmpFile == null ? other$deleteTmpFile != null : !((Object)this$deleteTmpFile).equals(other$deleteTmpFile)) {
+ return false;
+ }
+ String this$foreLatexToMathMlApi = this.getForeLatexToMathMlApi();
+ String other$foreLatexToMathMlApi = other.getForeLatexToMathMlApi();
+ if (this$foreLatexToMathMlApi == null ? other$foreLatexToMathMlApi != null : !this$foreLatexToMathMlApi.equals(other$foreLatexToMathMlApi)) {
+ return false;
+ }
+ String this$latexToMathMlApi = this.getLatexToMathMlApi();
+ String other$latexToMathMlApi = other.getLatexToMathMlApi();
+ if (this$latexToMathMlApi == null ? other$latexToMathMlApi != null : !this$latexToMathMlApi.equals(other$latexToMathMlApi)) {
+ return false;
+ }
+ String this$mathMlToLatexApi = this.getMathMlToLatexApi();
+ String other$mathMlToLatexApi = other.getMathMlToLatexApi();
+ if (this$mathMlToLatexApi == null ? other$mathMlToLatexApi != null : !this$mathMlToLatexApi.equals(other$mathMlToLatexApi)) {
+ return false;
+ }
+ Boolean this$mathMlToLatexApiSwitch = this.getMathMlToLatexApiSwitch();
+ Boolean other$mathMlToLatexApiSwitch = other.getMathMlToLatexApiSwitch();
+ if (this$mathMlToLatexApiSwitch == null ? other$mathMlToLatexApiSwitch != null : !((Object)this$mathMlToLatexApiSwitch).equals(other$mathMlToLatexApiSwitch)) {
+ return false;
+ }
+ String this$mf2SvgApi = this.getMf2SvgApi();
+ String other$mf2SvgApi = other.getMf2SvgApi();
+ if (this$mf2SvgApi == null ? other$mf2SvgApi != null : !this$mf2SvgApi.equals(other$mf2SvgApi)) {
+ return false;
+ }
+ String this$downloadPdfApi = this.getDownloadPdfApi();
+ String other$downloadPdfApi = other.getDownloadPdfApi();
+ if (this$downloadPdfApi == null ? other$downloadPdfApi != null : !this$downloadPdfApi.equals(other$downloadPdfApi)) {
+ return false;
+ }
+ String this$errorBookTemplate = this.getErrorBookTemplate();
+ String other$errorBookTemplate = other.getErrorBookTemplate();
+ if (this$errorBookTemplate == null ? other$errorBookTemplate != null : !this$errorBookTemplate.equals(other$errorBookTemplate)) {
+ return false;
+ }
+ Integer this$nodeConnectTimeout = this.getNodeConnectTimeout();
+ Integer other$nodeConnectTimeout = other.getNodeConnectTimeout();
+ if (this$nodeConnectTimeout == null ? other$nodeConnectTimeout != null : !((Object)this$nodeConnectTimeout).equals(other$nodeConnectTimeout)) {
+ return false;
+ }
+ Integer this$nodeSocketTimeout = this.getNodeSocketTimeout();
+ Integer other$nodeSocketTimeout = other.getNodeSocketTimeout();
+ if (this$nodeSocketTimeout == null ? other$nodeSocketTimeout != null : !((Object)this$nodeSocketTimeout).equals(other$nodeSocketTimeout)) {
+ return false;
+ }
+ Long this$contentLimit = this.getContentLimit();
+ Long other$contentLimit = other.getContentLimit();
+ if (this$contentLimit == null ? other$contentLimit != null : !((Object)this$contentLimit).equals(other$contentLimit)) {
+ return false;
+ }
+ Double this$limitRatio = this.getLimitRatio();
+ Double other$limitRatio = other.getLimitRatio();
+ if (this$limitRatio == null ? other$limitRatio != null : !((Object)this$limitRatio).equals(other$limitRatio)) {
+ return false;
+ }
+ Integer this$checkSize = this.getCheckSize();
+ Integer other$checkSize = other.getCheckSize();
+ if (this$checkSize == null ? other$checkSize != null : !((Object)this$checkSize).equals(other$checkSize)) {
+ return false;
+ }
+ Double this$imageScalingFactor = this.getImageScalingFactor();
+ Double other$imageScalingFactor = other.getImageScalingFactor();
+ if (this$imageScalingFactor == null ? other$imageScalingFactor != null : !((Object)this$imageScalingFactor).equals(other$imageScalingFactor)) {
+ return false;
+ }
+ String this$copyrightAddresses = this.getCopyrightAddresses();
+ String other$copyrightAddresses = other.getCopyrightAddresses();
+ if (this$copyrightAddresses == null ? other$copyrightAddresses != null : !this$copyrightAddresses.equals(other$copyrightAddresses)) {
+ return false;
+ }
+ Boolean this$newParseVersion = this.getNewParseVersion();
+ Boolean other$newParseVersion = other.getNewParseVersion();
+ if (this$newParseVersion == null ? other$newParseVersion != null : !((Object)this$newParseVersion).equals(other$newParseVersion)) {
+ return false;
+ }
+ Boolean this$newDownloadVersion = this.getNewDownloadVersion();
+ Boolean other$newDownloadVersion = other.getNewDownloadVersion();
+ if (this$newDownloadVersion == null ? other$newDownloadVersion != null : !((Object)this$newDownloadVersion).equals(other$newDownloadVersion)) {
+ return false;
+ }
+ Boolean this$openParseCache = this.getOpenParseCache();
+ Boolean other$openParseCache = other.getOpenParseCache();
+ if (this$openParseCache == null ? other$openParseCache != null : !((Object)this$openParseCache).equals(other$openParseCache)) {
+ return false;
+ }
+ Map> this$cleanStyleMap = this.getCleanStyleMap();
+ Map> other$cleanStyleMap = other.getCleanStyleMap();
+ if (this$cleanStyleMap == null ? other$cleanStyleMap != null : !((Object)this$cleanStyleMap).equals(other$cleanStyleMap)) {
+ return false;
+ }
+ String this$transformScriptPath = this.getTransformScriptPath();
+ String other$transformScriptPath = other.getTransformScriptPath();
+ return !(this$transformScriptPath == null ? other$transformScriptPath != null : !this$transformScriptPath.equals(other$transformScriptPath));
+ }
+
+ protected boolean canEqual(Object other) {
+ return other instanceof OfficeCoreConfig;
+ }
+
+ public int hashCode() {
+ int PRIME = 59;
+ int result = 1;
+ String $tmpPath = this.getTmpPath();
+ result = result * 59 + ($tmpPath == null ? 43 : $tmpPath.hashCode());
+ String $templatePath = this.getTemplatePath();
+ result = result * 59 + ($templatePath == null ? 43 : $templatePath.hashCode());
+ Boolean $deleteTmpFile = this.getDeleteTmpFile();
+ result = result * 59 + ($deleteTmpFile == null ? 43 : ((Object)$deleteTmpFile).hashCode());
+ String $foreLatexToMathMlApi = this.getForeLatexToMathMlApi();
+ result = result * 59 + ($foreLatexToMathMlApi == null ? 43 : $foreLatexToMathMlApi.hashCode());
+ String $latexToMathMlApi = this.getLatexToMathMlApi();
+ result = result * 59 + ($latexToMathMlApi == null ? 43 : $latexToMathMlApi.hashCode());
+ String $mathMlToLatexApi = this.getMathMlToLatexApi();
+ result = result * 59 + ($mathMlToLatexApi == null ? 43 : $mathMlToLatexApi.hashCode());
+ Boolean $mathMlToLatexApiSwitch = this.getMathMlToLatexApiSwitch();
+ result = result * 59 + ($mathMlToLatexApiSwitch == null ? 43 : ((Object)$mathMlToLatexApiSwitch).hashCode());
+ String $mf2SvgApi = this.getMf2SvgApi();
+ result = result * 59 + ($mf2SvgApi == null ? 43 : $mf2SvgApi.hashCode());
+ String $downloadPdfApi = this.getDownloadPdfApi();
+ result = result * 59 + ($downloadPdfApi == null ? 43 : $downloadPdfApi.hashCode());
+ String $errorBookTemplate = this.getErrorBookTemplate();
+ result = result * 59 + ($errorBookTemplate == null ? 43 : $errorBookTemplate.hashCode());
+ Integer $nodeConnectTimeout = this.getNodeConnectTimeout();
+ result = result * 59 + ($nodeConnectTimeout == null ? 43 : ((Object)$nodeConnectTimeout).hashCode());
+ Integer $nodeSocketTimeout = this.getNodeSocketTimeout();
+ result = result * 59 + ($nodeSocketTimeout == null ? 43 : ((Object)$nodeSocketTimeout).hashCode());
+ Long $contentLimit = this.getContentLimit();
+ result = result * 59 + ($contentLimit == null ? 43 : ((Object)$contentLimit).hashCode());
+ Double $limitRatio = this.getLimitRatio();
+ result = result * 59 + ($limitRatio == null ? 43 : ((Object)$limitRatio).hashCode());
+ Integer $checkSize = this.getCheckSize();
+ result = result * 59 + ($checkSize == null ? 43 : ((Object)$checkSize).hashCode());
+ Double $imageScalingFactor = this.getImageScalingFactor();
+ result = result * 59 + ($imageScalingFactor == null ? 43 : ((Object)$imageScalingFactor).hashCode());
+ String $copyrightAddresses = this.getCopyrightAddresses();
+ result = result * 59 + ($copyrightAddresses == null ? 43 : $copyrightAddresses.hashCode());
+ Boolean $newParseVersion = this.getNewParseVersion();
+ result = result * 59 + ($newParseVersion == null ? 43 : ((Object)$newParseVersion).hashCode());
+ Boolean $newDownloadVersion = this.getNewDownloadVersion();
+ result = result * 59 + ($newDownloadVersion == null ? 43 : ((Object)$newDownloadVersion).hashCode());
+ Boolean $openParseCache = this.getOpenParseCache();
+ result = result * 59 + ($openParseCache == null ? 43 : ((Object)$openParseCache).hashCode());
+ Map> $cleanStyleMap = this.getCleanStyleMap();
+ result = result * 59 + ($cleanStyleMap == null ? 43 : ((Object)$cleanStyleMap).hashCode());
+ String $transformScriptPath = this.getTransformScriptPath();
+ result = result * 59 + ($transformScriptPath == null ? 43 : $transformScriptPath.hashCode());
+ return result;
+ }
+
+ public String toString() {
+ return "OfficeCoreConfig(tmpPath=" + this.getTmpPath() + ", templatePath=" + this.getTemplatePath() + ", deleteTmpFile=" + this.getDeleteTmpFile() + ", foreLatexToMathMlApi=" + this.getForeLatexToMathMlApi() + ", latexToMathMlApi=" + this.getLatexToMathMlApi() + ", mathMlToLatexApi=" + this.getMathMlToLatexApi() + ", mathMlToLatexApiSwitch=" + this.getMathMlToLatexApiSwitch() + ", mf2SvgApi=" + this.getMf2SvgApi() + ", downloadPdfApi=" + this.getDownloadPdfApi() + ", errorBookTemplate=" + this.getErrorBookTemplate() + ", nodeConnectTimeout=" + this.getNodeConnectTimeout() + ", nodeSocketTimeout=" + this.getNodeSocketTimeout() + ", contentLimit=" + this.getContentLimit() + ", limitRatio=" + this.getLimitRatio() + ", checkSize=" + this.getCheckSize() + ", imageScalingFactor=" + this.getImageScalingFactor() + ", copyrightAddresses=" + this.getCopyrightAddresses() + ", newParseVersion=" + this.getNewParseVersion() + ", newDownloadVersion=" + this.getNewDownloadVersion() + ", openParseCache=" + this.getOpenParseCache() + ", cleanStyleMap=" + this.getCleanStyleMap() + ", transformScriptPath=" + this.getTransformScriptPath() + ")";
+ }
+}
+
diff --git a/java-src/controller/FileController.java b/java-src/controller/FileController.java
new file mode 100644
index 0000000..f599393
--- /dev/null
+++ b/java-src/controller/FileController.java
@@ -0,0 +1,152 @@
+/*
+ * Decompiled with CFR 0.152.
+ *
+ * Could not load the following classes:
+ * com.alibaba.fastjson.JSON
+ * com.jby.common.advisor.annotation.ParamBarrier
+ * com.jby.common.result.Result
+ * com.jby.office.api.FileServiceApi
+ * com.jby.office.domain.param.DownloadFileParam
+ * com.jby.office.domain.param.DownloadParam
+ * com.jby.office.domain.param.FileParam
+ * com.jby.office.domain.param.GenerateFileParam
+ * com.jby.office.domain.param.OfficeFileParseParam
+ * com.jby.office.domain.param.OfficeFileParseRecordParam
+ * com.jby.office.domain.vo.OfficeFileDownloadScheduleVO
+ * com.jby.office.domain.vo.OfficeFileInfoVO
+ * com.jby.office.domain.vo.OfficeFileParseRecordVO
+ * com.jby.office.domain.vo.OfficeFileParseVO
+ * com.jby.officecore.annotation.CostTime
+ * com.jby.officecore.domain.dto.CreateWordDTO
+ * com.jby.officecore.utils.WordExportUtil
+ * com.jby.system.domain.param.NodeParam
+ * javax.annotation.Resource
+ * org.map.utils.BeanMapping
+ * org.slf4j.Logger
+ * org.slf4j.LoggerFactory
+ * org.springframework.web.bind.annotation.GetMapping
+ * org.springframework.web.bind.annotation.PathVariable
+ * org.springframework.web.bind.annotation.PostMapping
+ * org.springframework.web.bind.annotation.RequestBody
+ * org.springframework.web.bind.annotation.RequestMapping
+ * org.springframework.web.bind.annotation.RestController
+ */
+package com.jby.officefile.controller;
+
+import com.alibaba.fastjson.JSON;
+import com.jby.common.advisor.annotation.ParamBarrier;
+import com.jby.common.result.Result;
+import com.jby.office.api.FileServiceApi;
+import com.jby.office.domain.param.DownloadFileParam;
+import com.jby.office.domain.param.DownloadParam;
+import com.jby.office.domain.param.FileParam;
+import com.jby.office.domain.param.GenerateFileParam;
+import com.jby.office.domain.param.OfficeFileParseParam;
+import com.jby.office.domain.param.OfficeFileParseRecordParam;
+import com.jby.office.domain.vo.OfficeFileDownloadScheduleVO;
+import com.jby.office.domain.vo.OfficeFileInfoVO;
+import com.jby.office.domain.vo.OfficeFileParseRecordVO;
+import com.jby.office.domain.vo.OfficeFileParseVO;
+import com.jby.officecore.annotation.CostTime;
+import com.jby.officecore.domain.dto.CreateWordDTO;
+import com.jby.officecore.utils.WordExportUtil;
+import com.jby.officefile.service.FileService;
+import com.jby.system.domain.param.NodeParam;
+import java.util.List;
+import java.util.Objects;
+import javax.annotation.Resource;
+import org.map.utils.BeanMapping;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping(value={"/file"})
+public class FileController
+implements FileServiceApi {
+ private static final Logger log = LoggerFactory.getLogger(FileController.class);
+ @Resource
+ private FileService fileService;
+
+ @CostTime
+ @PostMapping(value={"/generate/by/url"})
+ public Result generateFileByUrl(@RequestBody GenerateFileParam param) {
+ log.info("\u901a\u8fc7word\u8d44\u6e90\u5730\u5740\u751f\u6210\u5728\u7ebf\u7f16\u8f91\u6587\u4ef6(\u5b8c\u6574\u6587\u6863), param={}", (Object)JSON.toJSONString((Object)param));
+ OfficeFileInfoVO result = this.fileService.generateFileByUrl(param);
+ return Result.success((Object)result);
+ }
+
+ @CostTime
+ @PostMapping(value={"/generate/by/file"}, consumes={"multipart/form-data"})
+ public Result generateFileByFile(FileParam param) {
+ log.info("\u901a\u8fc7word\u8d44\u6e90\u6587\u4ef6\u751f\u6210\u5728\u7ebf\u7f16\u8f91\u6587\u4ef6(\u5b8c\u6574\u6587\u6863), param={}", (Object)JSON.toJSONString((Object)param));
+ OfficeFileInfoVO result = this.fileService.generateFileByFile(param);
+ return Result.success((Object)result);
+ }
+
+ @CostTime
+ @PostMapping(value={"/parse"}, consumes={"multipart/form-data"})
+ public Result parseOfficeFile(OfficeFileParseParam param) {
+ OfficeFileParseVO parseVO = this.fileService.parseOfficeFile(param);
+ return Result.success((Object)parseVO);
+ }
+
+ @CostTime
+ @PostMapping(value={"/download"}, consumes={"multipart/form-data"})
+ public Result downloadOfficeFile(DownloadFileParam param) {
+ log.info("\u4e0b\u8f7d\u5728\u7ebf\u7f16\u8f91\u6587\u4ef6, file={}, param={}", (Object)Objects.nonNull(param.getPdfFile()), (Object)JSON.toJSONString((Object)param));
+ String fileUrl = this.fileService.downloadOfficeFile(param);
+ return Result.success((Object)fileUrl);
+ }
+
+ @CostTime
+ @PostMapping(value={"/v2/download"})
+ public Result downloadFile(@RequestBody DownloadParam param) {
+ log.info("\u4e0b\u8f7d\u5728\u7ebf\u7f16\u8f91\u6587\u4ef6V2, param={}", (Object)JSON.toJSONString((Object)param));
+ DownloadFileParam fileParam = (DownloadFileParam)BeanMapping.toBean((Object)param, DownloadFileParam.class);
+ String fileUrl = this.fileService.downloadOfficeFile(fileParam);
+ return Result.success((Object)fileUrl);
+ }
+
+ @Deprecated
+ @CostTime
+ @PostMapping(value={"/batch/download"})
+ public Result batchDownloadOfficeFile(@RequestBody NodeParam rootNode) {
+ log.info("\u6279\u91cf\u4e0b\u8f7d\u5728\u7ebf\u6587\u4ef6, \u8282\u70b9\u53c2\u6570rootNode={}", (Object)JSON.toJSONString((Object)rootNode));
+ OfficeFileDownloadScheduleVO result = this.fileService.batchDownloadOfficeFile(rootNode);
+ return Result.success((Object)result);
+ }
+
+ @CostTime
+ @PostMapping(value={"/download/word"})
+ public Result downloadWord(@RequestBody CreateWordDTO param) {
+ log.info("\u4e0b\u8f7dword\u6587\u4ef6, param={}", (Object)JSON.toJSONString((Object)param));
+ String result = WordExportUtil.createWord((CreateWordDTO)param);
+ return Result.success((Object)result);
+ }
+
+ @GetMapping(value={"/parse/record/{md5}"})
+ public Result getOfficeFileParseRecordByMd5(@PathVariable String md5) {
+ OfficeFileParseRecordVO result = this.fileService.getOfficeFileParseRecordByMd5(md5);
+ return Result.success((Object)result);
+ }
+
+ @PostMapping(value={"/parse/record"})
+ public Result> saveOfficeFileParseRecord(@RequestBody OfficeFileParseRecordParam param) {
+ this.fileService.saveOfficeFileParseRecord(param);
+ return Result.success();
+ }
+
+ @PostMapping(value={"/parse/record/query"})
+ @ParamBarrier(value={"fileIds"})
+ public Result> queryFileUrlByFileIds(@RequestBody OfficeFileParseRecordParam param) {
+ List result = this.fileService.queryFileUrlByFileIds(param);
+ return Result.success(result);
+ }
+}
+
diff --git a/java-src/domain/bo/ImageBO.java b/java-src/domain/bo/ImageBO.java
new file mode 100644
index 0000000..47b4d83
--- /dev/null
+++ b/java-src/domain/bo/ImageBO.java
@@ -0,0 +1,123 @@
+/*
+ * Decompiled with CFR 0.152.
+ */
+package com.jby.officecore.domain.bo;
+
+import java.io.InputStream;
+import java.io.Serializable;
+
+public class ImageBO
+implements Serializable {
+ private static final long serialVersionUID = 6640950035295880234L;
+ private InputStream is;
+ private Double width;
+ private Double height;
+ private Integer pictureType;
+ private String pictureUrl;
+
+ public InputStream getIs() {
+ return this.is;
+ }
+
+ public Double getWidth() {
+ return this.width;
+ }
+
+ public Double getHeight() {
+ return this.height;
+ }
+
+ public Integer getPictureType() {
+ return this.pictureType;
+ }
+
+ public String getPictureUrl() {
+ return this.pictureUrl;
+ }
+
+ public ImageBO setIs(InputStream is) {
+ this.is = is;
+ return this;
+ }
+
+ public ImageBO setWidth(Double width) {
+ this.width = width;
+ return this;
+ }
+
+ public ImageBO setHeight(Double height) {
+ this.height = height;
+ return this;
+ }
+
+ public ImageBO setPictureType(Integer pictureType) {
+ this.pictureType = pictureType;
+ return this;
+ }
+
+ public ImageBO setPictureUrl(String pictureUrl) {
+ this.pictureUrl = pictureUrl;
+ return this;
+ }
+
+ public boolean equals(Object o) {
+ if (o == this) {
+ return true;
+ }
+ if (!(o instanceof ImageBO)) {
+ return false;
+ }
+ ImageBO other = (ImageBO)o;
+ if (!other.canEqual(this)) {
+ return false;
+ }
+ InputStream this$is = this.getIs();
+ InputStream other$is = other.getIs();
+ if (this$is == null ? other$is != null : !this$is.equals(other$is)) {
+ return false;
+ }
+ Double this$width = this.getWidth();
+ Double other$width = other.getWidth();
+ if (this$width == null ? other$width != null : !((Object)this$width).equals(other$width)) {
+ return false;
+ }
+ Double this$height = this.getHeight();
+ Double other$height = other.getHeight();
+ if (this$height == null ? other$height != null : !((Object)this$height).equals(other$height)) {
+ return false;
+ }
+ Integer this$pictureType = this.getPictureType();
+ Integer other$pictureType = other.getPictureType();
+ if (this$pictureType == null ? other$pictureType != null : !((Object)this$pictureType).equals(other$pictureType)) {
+ return false;
+ }
+ String this$pictureUrl = this.getPictureUrl();
+ String other$pictureUrl = other.getPictureUrl();
+ return !(this$pictureUrl == null ? other$pictureUrl != null : !this$pictureUrl.equals(other$pictureUrl));
+ }
+
+ protected boolean canEqual(Object other) {
+ return other instanceof ImageBO;
+ }
+
+ public int hashCode() {
+ int PRIME = 59;
+ int result = 1;
+ InputStream $is = this.getIs();
+ result = result * 59 + ($is == null ? 43 : $is.hashCode());
+ Double $width = this.getWidth();
+ result = result * 59 + ($width == null ? 43 : ((Object)$width).hashCode());
+ Double $height = this.getHeight();
+ result = result * 59 + ($height == null ? 43 : ((Object)$height).hashCode());
+ Integer $pictureType = this.getPictureType();
+ result = result * 59 + ($pictureType == null ? 43 : ((Object)$pictureType).hashCode());
+ String $pictureUrl = this.getPictureUrl();
+ result = result * 59 + ($pictureUrl == null ? 43 : $pictureUrl.hashCode());
+ return result;
+ }
+
+ public String toString() {
+ return "ImageBO(is=" + this.getIs() + ", width=" + this.getWidth() + ", height=" + this.getHeight() + ", pictureType=" + this.getPictureType() + ", pictureUrl=" + this.getPictureUrl() + ")";
+ }
+}
+
diff --git a/java-src/domain/bo/ParseBO.java b/java-src/domain/bo/ParseBO.java
new file mode 100644
index 0000000..0679e54
--- /dev/null
+++ b/java-src/domain/bo/ParseBO.java
@@ -0,0 +1,455 @@
+/*
+ * Decompiled with CFR 0.152.
+ *
+ * Could not load the following classes:
+ * com.alibaba.fastjson.JSONObject
+ * org.docx4j.openpackaging.parts.WordprocessingML.StyleDefinitionsPart
+ */
+package com.jby.officecore.domain.bo;
+
+import com.alibaba.fastjson.JSONObject;
+import com.jby.officecore.domain.bo.ImageBO;
+import com.jby.officecore.utils.NumPr;
+import java.io.Serializable;
+import java.nio.file.Path;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.xml.transform.Transformer;
+import org.docx4j.openpackaging.parts.WordprocessingML.StyleDefinitionsPart;
+
+public class ParseBO
+implements Serializable {
+ private static final long serialVersionUID = -1386361606482288851L;
+ public static final String IMAGES = "images";
+ public static final String PARSE_ = "parse-";
+ public static final String OUTPUT_HTML = "output.html";
+ private static final String JBY_OPEN_OFFICE_XML_ = "JBY_OPEN_OFFICE_XML_";
+ private static final String JBY_IMAGE_DATA_ = "JBY_IMAGE_DATA_";
+ private static final String PLACEHOLDER_SUFFIX = "_END";
+ private static final String IMAGE_ = "image_";
+ private static final String JBY_EQ_LATEX_ = "JBY_EQ_LATEX_";
+ public static final String JBY_TEXTBOX = "JBY_TEXTBOX_JBY";
+ private static final String JBY_MATHTYPE_DATA_ = "JBY_MATHTYPE_DATA_";
+ private Path tempDir;
+ private String sourceFilePath;
+ private String sourceFileUrl;
+ private String sourceFileMd5;
+ private String sourceFileBakPath;
+ private String htmlPath;
+ private String imagesDir;
+ private String ossFolder;
+ private Transformer transformer;
+ private List latexReplaceList;
+ private Map imgMap = new HashMap();
+ private Map shapeImgMap;
+ private Map openOfficeXmlMap = new HashMap();
+ private Map mathTypeMap = new HashMap();
+ private Map eqLatexMap = new HashMap();
+ private StyleDefinitionsPart styleDefinitionsPart;
+ private Map numberingDefinitionsMap = new HashMap();
+ private Map imageMap;
+ private Boolean newParseVersion;
+ private Integer count = 0;
+ private Long fileId;
+
+ public ParseBO() {
+ this.shapeImgMap = new HashMap();
+ this.imageMap = new HashMap();
+ }
+
+ private Integer incrCount() {
+ this.count = this.count + 1;
+ return this.count;
+ }
+
+ public String getOpenOfficeXmlPlaceholder() {
+ return JBY_OPEN_OFFICE_XML_ + this.incrCount() + PLACEHOLDER_SUFFIX;
+ }
+
+ public String getMathTypePlaceholder() {
+ return JBY_IMAGE_DATA_ + this.incrCount() + PLACEHOLDER_SUFFIX;
+ }
+
+ public String getMathTypePlaceholder(String ctOleObjectRid) {
+ return JBY_MATHTYPE_DATA_ + ctOleObjectRid + PLACEHOLDER_SUFFIX;
+ }
+
+ public String getImgName() {
+ return IMAGE_ + this.incrCount();
+ }
+
+ public String getEqLatexPlaceholder() {
+ return JBY_EQ_LATEX_ + this.incrCount() + PLACEHOLDER_SUFFIX;
+ }
+
+ public String getShapeImgPlaceholder() {
+ return JBY_IMAGE_DATA_ + this.incrCount() + PLACEHOLDER_SUFFIX;
+ }
+
+ public String getImagePlaceholder(String rid) {
+ return JBY_IMAGE_DATA_ + this.incrCount() + PLACEHOLDER_SUFFIX;
+ }
+
+ public Path getTempDir() {
+ return this.tempDir;
+ }
+
+ public String getSourceFilePath() {
+ return this.sourceFilePath;
+ }
+
+ public String getSourceFileUrl() {
+ return this.sourceFileUrl;
+ }
+
+ public String getSourceFileMd5() {
+ return this.sourceFileMd5;
+ }
+
+ public String getSourceFileBakPath() {
+ return this.sourceFileBakPath;
+ }
+
+ public String getHtmlPath() {
+ return this.htmlPath;
+ }
+
+ public String getImagesDir() {
+ return this.imagesDir;
+ }
+
+ public String getOssFolder() {
+ return this.ossFolder;
+ }
+
+ public Transformer getTransformer() {
+ return this.transformer;
+ }
+
+ public List getLatexReplaceList() {
+ return this.latexReplaceList;
+ }
+
+ public Map getImgMap() {
+ return this.imgMap;
+ }
+
+ public Map getShapeImgMap() {
+ return this.shapeImgMap;
+ }
+
+ public Map getOpenOfficeXmlMap() {
+ return this.openOfficeXmlMap;
+ }
+
+ public Map getMathTypeMap() {
+ return this.mathTypeMap;
+ }
+
+ public Map getEqLatexMap() {
+ return this.eqLatexMap;
+ }
+
+ public StyleDefinitionsPart getStyleDefinitionsPart() {
+ return this.styleDefinitionsPart;
+ }
+
+ public Map getNumberingDefinitionsMap() {
+ return this.numberingDefinitionsMap;
+ }
+
+ public Map getImageMap() {
+ return this.imageMap;
+ }
+
+ public Boolean getNewParseVersion() {
+ return this.newParseVersion;
+ }
+
+ public Integer getCount() {
+ return this.count;
+ }
+
+ public Long getFileId() {
+ return this.fileId;
+ }
+
+ public ParseBO setTempDir(Path tempDir) {
+ this.tempDir = tempDir;
+ return this;
+ }
+
+ public ParseBO setSourceFilePath(String sourceFilePath) {
+ this.sourceFilePath = sourceFilePath;
+ return this;
+ }
+
+ public ParseBO setSourceFileUrl(String sourceFileUrl) {
+ this.sourceFileUrl = sourceFileUrl;
+ return this;
+ }
+
+ public ParseBO setSourceFileMd5(String sourceFileMd5) {
+ this.sourceFileMd5 = sourceFileMd5;
+ return this;
+ }
+
+ public ParseBO setSourceFileBakPath(String sourceFileBakPath) {
+ this.sourceFileBakPath = sourceFileBakPath;
+ return this;
+ }
+
+ public ParseBO setHtmlPath(String htmlPath) {
+ this.htmlPath = htmlPath;
+ return this;
+ }
+
+ public ParseBO setImagesDir(String imagesDir) {
+ this.imagesDir = imagesDir;
+ return this;
+ }
+
+ public ParseBO setOssFolder(String ossFolder) {
+ this.ossFolder = ossFolder;
+ return this;
+ }
+
+ public ParseBO setTransformer(Transformer transformer) {
+ this.transformer = transformer;
+ return this;
+ }
+
+ public ParseBO setLatexReplaceList(List latexReplaceList) {
+ this.latexReplaceList = latexReplaceList;
+ return this;
+ }
+
+ public ParseBO setImgMap(Map imgMap) {
+ this.imgMap = imgMap;
+ return this;
+ }
+
+ public ParseBO setShapeImgMap(Map shapeImgMap) {
+ this.shapeImgMap = shapeImgMap;
+ return this;
+ }
+
+ public ParseBO setOpenOfficeXmlMap(Map openOfficeXmlMap) {
+ this.openOfficeXmlMap = openOfficeXmlMap;
+ return this;
+ }
+
+ public ParseBO setMathTypeMap(Map mathTypeMap) {
+ this.mathTypeMap = mathTypeMap;
+ return this;
+ }
+
+ public ParseBO setEqLatexMap(Map eqLatexMap) {
+ this.eqLatexMap = eqLatexMap;
+ return this;
+ }
+
+ public ParseBO setStyleDefinitionsPart(StyleDefinitionsPart styleDefinitionsPart) {
+ this.styleDefinitionsPart = styleDefinitionsPart;
+ return this;
+ }
+
+ public ParseBO setNumberingDefinitionsMap(Map numberingDefinitionsMap) {
+ this.numberingDefinitionsMap = numberingDefinitionsMap;
+ return this;
+ }
+
+ public ParseBO setImageMap(Map imageMap) {
+ this.imageMap = imageMap;
+ return this;
+ }
+
+ public ParseBO setNewParseVersion(Boolean newParseVersion) {
+ this.newParseVersion = newParseVersion;
+ return this;
+ }
+
+ public ParseBO setCount(Integer count) {
+ this.count = count;
+ return this;
+ }
+
+ public ParseBO setFileId(Long fileId) {
+ this.fileId = fileId;
+ return this;
+ }
+
+ public boolean equals(Object o) {
+ if (o == this) {
+ return true;
+ }
+ if (!(o instanceof ParseBO)) {
+ return false;
+ }
+ ParseBO other = (ParseBO)o;
+ if (!other.canEqual(this)) {
+ return false;
+ }
+ Path this$tempDir = this.getTempDir();
+ Path other$tempDir = other.getTempDir();
+ if (this$tempDir == null ? other$tempDir != null : !((Object)this$tempDir).equals(other$tempDir)) {
+ return false;
+ }
+ String this$sourceFilePath = this.getSourceFilePath();
+ String other$sourceFilePath = other.getSourceFilePath();
+ if (this$sourceFilePath == null ? other$sourceFilePath != null : !this$sourceFilePath.equals(other$sourceFilePath)) {
+ return false;
+ }
+ String this$sourceFileUrl = this.getSourceFileUrl();
+ String other$sourceFileUrl = other.getSourceFileUrl();
+ if (this$sourceFileUrl == null ? other$sourceFileUrl != null : !this$sourceFileUrl.equals(other$sourceFileUrl)) {
+ return false;
+ }
+ String this$sourceFileMd5 = this.getSourceFileMd5();
+ String other$sourceFileMd5 = other.getSourceFileMd5();
+ if (this$sourceFileMd5 == null ? other$sourceFileMd5 != null : !this$sourceFileMd5.equals(other$sourceFileMd5)) {
+ return false;
+ }
+ String this$sourceFileBakPath = this.getSourceFileBakPath();
+ String other$sourceFileBakPath = other.getSourceFileBakPath();
+ if (this$sourceFileBakPath == null ? other$sourceFileBakPath != null : !this$sourceFileBakPath.equals(other$sourceFileBakPath)) {
+ return false;
+ }
+ String this$htmlPath = this.getHtmlPath();
+ String other$htmlPath = other.getHtmlPath();
+ if (this$htmlPath == null ? other$htmlPath != null : !this$htmlPath.equals(other$htmlPath)) {
+ return false;
+ }
+ String this$imagesDir = this.getImagesDir();
+ String other$imagesDir = other.getImagesDir();
+ if (this$imagesDir == null ? other$imagesDir != null : !this$imagesDir.equals(other$imagesDir)) {
+ return false;
+ }
+ String this$ossFolder = this.getOssFolder();
+ String other$ossFolder = other.getOssFolder();
+ if (this$ossFolder == null ? other$ossFolder != null : !this$ossFolder.equals(other$ossFolder)) {
+ return false;
+ }
+ Transformer this$transformer = this.getTransformer();
+ Transformer other$transformer = other.getTransformer();
+ if (this$transformer == null ? other$transformer != null : !this$transformer.equals(other$transformer)) {
+ return false;
+ }
+ List this$latexReplaceList = this.getLatexReplaceList();
+ List other$latexReplaceList = other.getLatexReplaceList();
+ if (this$latexReplaceList == null ? other$latexReplaceList != null : !((Object)this$latexReplaceList).equals(other$latexReplaceList)) {
+ return false;
+ }
+ Map this$imgMap = this.getImgMap();
+ Map other$imgMap = other.getImgMap();
+ if (this$imgMap == null ? other$imgMap != null : !((Object)this$imgMap).equals(other$imgMap)) {
+ return false;
+ }
+ Map this$shapeImgMap = this.getShapeImgMap();
+ Map other$shapeImgMap = other.getShapeImgMap();
+ if (this$shapeImgMap == null ? other$shapeImgMap != null : !((Object)this$shapeImgMap).equals(other$shapeImgMap)) {
+ return false;
+ }
+ Map this$openOfficeXmlMap = this.getOpenOfficeXmlMap();
+ Map other$openOfficeXmlMap = other.getOpenOfficeXmlMap();
+ if (this$openOfficeXmlMap == null ? other$openOfficeXmlMap != null : !((Object)this$openOfficeXmlMap).equals(other$openOfficeXmlMap)) {
+ return false;
+ }
+ Map this$mathTypeMap = this.getMathTypeMap();
+ Map other$mathTypeMap = other.getMathTypeMap();
+ if (this$mathTypeMap == null ? other$mathTypeMap != null : !((Object)this$mathTypeMap).equals(other$mathTypeMap)) {
+ return false;
+ }
+ Map this$eqLatexMap = this.getEqLatexMap();
+ Map other$eqLatexMap = other.getEqLatexMap();
+ if (this$eqLatexMap == null ? other$eqLatexMap != null : !((Object)this$eqLatexMap).equals(other$eqLatexMap)) {
+ return false;
+ }
+ StyleDefinitionsPart this$styleDefinitionsPart = this.getStyleDefinitionsPart();
+ StyleDefinitionsPart other$styleDefinitionsPart = other.getStyleDefinitionsPart();
+ if (this$styleDefinitionsPart == null ? other$styleDefinitionsPart != null : !this$styleDefinitionsPart.equals(other$styleDefinitionsPart)) {
+ return false;
+ }
+ Map this$numberingDefinitionsMap = this.getNumberingDefinitionsMap();
+ Map other$numberingDefinitionsMap = other.getNumberingDefinitionsMap();
+ if (this$numberingDefinitionsMap == null ? other$numberingDefinitionsMap != null : !((Object)this$numberingDefinitionsMap).equals(other$numberingDefinitionsMap)) {
+ return false;
+ }
+ Map this$imageMap = this.getImageMap();
+ Map other$imageMap = other.getImageMap();
+ if (this$imageMap == null ? other$imageMap != null : !((Object)this$imageMap).equals(other$imageMap)) {
+ return false;
+ }
+ Boolean this$newParseVersion = this.getNewParseVersion();
+ Boolean other$newParseVersion = other.getNewParseVersion();
+ if (this$newParseVersion == null ? other$newParseVersion != null : !((Object)this$newParseVersion).equals(other$newParseVersion)) {
+ return false;
+ }
+ Integer this$count = this.getCount();
+ Integer other$count = other.getCount();
+ if (this$count == null ? other$count != null : !((Object)this$count).equals(other$count)) {
+ return false;
+ }
+ Long this$fileId = this.getFileId();
+ Long other$fileId = other.getFileId();
+ return !(this$fileId == null ? other$fileId != null : !((Object)this$fileId).equals(other$fileId));
+ }
+
+ protected boolean canEqual(Object other) {
+ return other instanceof ParseBO;
+ }
+
+ public int hashCode() {
+ int PRIME = 59;
+ int result = 1;
+ Path $tempDir = this.getTempDir();
+ result = result * 59 + ($tempDir == null ? 43 : ((Object)$tempDir).hashCode());
+ String $sourceFilePath = this.getSourceFilePath();
+ result = result * 59 + ($sourceFilePath == null ? 43 : $sourceFilePath.hashCode());
+ String $sourceFileUrl = this.getSourceFileUrl();
+ result = result * 59 + ($sourceFileUrl == null ? 43 : $sourceFileUrl.hashCode());
+ String $sourceFileMd5 = this.getSourceFileMd5();
+ result = result * 59 + ($sourceFileMd5 == null ? 43 : $sourceFileMd5.hashCode());
+ String $sourceFileBakPath = this.getSourceFileBakPath();
+ result = result * 59 + ($sourceFileBakPath == null ? 43 : $sourceFileBakPath.hashCode());
+ String $htmlPath = this.getHtmlPath();
+ result = result * 59 + ($htmlPath == null ? 43 : $htmlPath.hashCode());
+ String $imagesDir = this.getImagesDir();
+ result = result * 59 + ($imagesDir == null ? 43 : $imagesDir.hashCode());
+ String $ossFolder = this.getOssFolder();
+ result = result * 59 + ($ossFolder == null ? 43 : $ossFolder.hashCode());
+ Transformer $transformer = this.getTransformer();
+ result = result * 59 + ($transformer == null ? 43 : $transformer.hashCode());
+ List $latexReplaceList = this.getLatexReplaceList();
+ result = result * 59 + ($latexReplaceList == null ? 43 : ((Object)$latexReplaceList).hashCode());
+ Map $imgMap = this.getImgMap();
+ result = result * 59 + ($imgMap == null ? 43 : ((Object)$imgMap).hashCode());
+ Map $shapeImgMap = this.getShapeImgMap();
+ result = result * 59 + ($shapeImgMap == null ? 43 : ((Object)$shapeImgMap).hashCode());
+ Map $openOfficeXmlMap = this.getOpenOfficeXmlMap();
+ result = result * 59 + ($openOfficeXmlMap == null ? 43 : ((Object)$openOfficeXmlMap).hashCode());
+ Map $mathTypeMap = this.getMathTypeMap();
+ result = result * 59 + ($mathTypeMap == null ? 43 : ((Object)$mathTypeMap).hashCode());
+ Map $eqLatexMap = this.getEqLatexMap();
+ result = result * 59 + ($eqLatexMap == null ? 43 : ((Object)$eqLatexMap).hashCode());
+ StyleDefinitionsPart $styleDefinitionsPart = this.getStyleDefinitionsPart();
+ result = result * 59 + ($styleDefinitionsPart == null ? 43 : $styleDefinitionsPart.hashCode());
+ Map $numberingDefinitionsMap = this.getNumberingDefinitionsMap();
+ result = result * 59 + ($numberingDefinitionsMap == null ? 43 : ((Object)$numberingDefinitionsMap).hashCode());
+ Map $imageMap = this.getImageMap();
+ result = result * 59 + ($imageMap == null ? 43 : ((Object)$imageMap).hashCode());
+ Boolean $newParseVersion = this.getNewParseVersion();
+ result = result * 59 + ($newParseVersion == null ? 43 : ((Object)$newParseVersion).hashCode());
+ Integer $count = this.getCount();
+ result = result * 59 + ($count == null ? 43 : ((Object)$count).hashCode());
+ Long $fileId = this.getFileId();
+ result = result * 59 + ($fileId == null ? 43 : ((Object)$fileId).hashCode());
+ return result;
+ }
+
+ public String toString() {
+ return "ParseBO(tempDir=" + this.getTempDir() + ", sourceFilePath=" + this.getSourceFilePath() + ", sourceFileUrl=" + this.getSourceFileUrl() + ", sourceFileMd5=" + this.getSourceFileMd5() + ", sourceFileBakPath=" + this.getSourceFileBakPath() + ", htmlPath=" + this.getHtmlPath() + ", imagesDir=" + this.getImagesDir() + ", ossFolder=" + this.getOssFolder() + ", transformer=" + this.getTransformer() + ", latexReplaceList=" + this.getLatexReplaceList() + ", imgMap=" + this.getImgMap() + ", shapeImgMap=" + this.getShapeImgMap() + ", openOfficeXmlMap=" + this.getOpenOfficeXmlMap() + ", mathTypeMap=" + this.getMathTypeMap() + ", eqLatexMap=" + this.getEqLatexMap() + ", styleDefinitionsPart=" + this.getStyleDefinitionsPart() + ", numberingDefinitionsMap=" + this.getNumberingDefinitionsMap() + ", imageMap=" + this.getImageMap() + ", newParseVersion=" + this.getNewParseVersion() + ", count=" + this.getCount() + ", fileId=" + this.getFileId() + ")";
+ }
+}
+
diff --git a/java-src/domain/bo/TagStyleBO.java b/java-src/domain/bo/TagStyleBO.java
new file mode 100644
index 0000000..e02f95c
--- /dev/null
+++ b/java-src/domain/bo/TagStyleBO.java
@@ -0,0 +1,42 @@
+/*
+ * Decompiled with CFR 0.152.
+ */
+package com.jby.officecore.domain.bo;
+
+import java.io.Serializable;
+
+public class TagStyleBO
+implements Serializable {
+ private static final long serialVersionUID = -5541312317983576319L;
+ private String tagName;
+ private String attr;
+ private String value;
+
+ public String getTagName() {
+ return this.tagName;
+ }
+
+ public String getAttr() {
+ return this.attr;
+ }
+
+ public String getValue() {
+ return this.value;
+ }
+
+ public TagStyleBO setTagName(String tagName) {
+ this.tagName = tagName;
+ return this;
+ }
+
+ public TagStyleBO setAttr(String attr) {
+ this.attr = attr;
+ return this;
+ }
+
+ public TagStyleBO setValue(String value) {
+ this.value = value;
+ return this;
+ }
+}
+
diff --git a/java-src/domain/param/ParseParam.java b/java-src/domain/param/ParseParam.java
new file mode 100644
index 0000000..5815f4c
--- /dev/null
+++ b/java-src/domain/param/ParseParam.java
@@ -0,0 +1,132 @@
+/*
+ * Decompiled with CFR 0.152.
+ *
+ * Could not load the following classes:
+ * com.alibaba.fastjson.JSONObject
+ * com.alibaba.fastjson.annotation.JSONField
+ * org.springframework.web.multipart.MultipartFile
+ */
+package com.jby.officecore.domain.param;
+
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.annotation.JSONField;
+import java.io.Serializable;
+import java.util.List;
+import org.springframework.web.multipart.MultipartFile;
+
+public class ParseParam
+implements Serializable {
+ private static final long serialVersionUID = 4113866861283462539L;
+ private String sourceUrl;
+ @JSONField(serialize=false)
+ private MultipartFile sourceFile;
+ private List latexReplaceList;
+ private Boolean newParseVersion;
+ private Long fileId;
+
+ public String getSourceUrl() {
+ return this.sourceUrl;
+ }
+
+ public MultipartFile getSourceFile() {
+ return this.sourceFile;
+ }
+
+ public List getLatexReplaceList() {
+ return this.latexReplaceList;
+ }
+
+ public Boolean getNewParseVersion() {
+ return this.newParseVersion;
+ }
+
+ public Long getFileId() {
+ return this.fileId;
+ }
+
+ public ParseParam setSourceUrl(String sourceUrl) {
+ this.sourceUrl = sourceUrl;
+ return this;
+ }
+
+ public ParseParam setSourceFile(MultipartFile sourceFile) {
+ this.sourceFile = sourceFile;
+ return this;
+ }
+
+ public ParseParam setLatexReplaceList(List latexReplaceList) {
+ this.latexReplaceList = latexReplaceList;
+ return this;
+ }
+
+ public ParseParam setNewParseVersion(Boolean newParseVersion) {
+ this.newParseVersion = newParseVersion;
+ return this;
+ }
+
+ public ParseParam setFileId(Long fileId) {
+ this.fileId = fileId;
+ return this;
+ }
+
+ public boolean equals(Object o) {
+ if (o == this) {
+ return true;
+ }
+ if (!(o instanceof ParseParam)) {
+ return false;
+ }
+ ParseParam other = (ParseParam)o;
+ if (!other.canEqual(this)) {
+ return false;
+ }
+ String this$sourceUrl = this.getSourceUrl();
+ String other$sourceUrl = other.getSourceUrl();
+ if (this$sourceUrl == null ? other$sourceUrl != null : !this$sourceUrl.equals(other$sourceUrl)) {
+ return false;
+ }
+ MultipartFile this$sourceFile = this.getSourceFile();
+ MultipartFile other$sourceFile = other.getSourceFile();
+ if (this$sourceFile == null ? other$sourceFile != null : !this$sourceFile.equals(other$sourceFile)) {
+ return false;
+ }
+ List this$latexReplaceList = this.getLatexReplaceList();
+ List other$latexReplaceList = other.getLatexReplaceList();
+ if (this$latexReplaceList == null ? other$latexReplaceList != null : !((Object)this$latexReplaceList).equals(other$latexReplaceList)) {
+ return false;
+ }
+ Boolean this$newParseVersion = this.getNewParseVersion();
+ Boolean other$newParseVersion = other.getNewParseVersion();
+ if (this$newParseVersion == null ? other$newParseVersion != null : !((Object)this$newParseVersion).equals(other$newParseVersion)) {
+ return false;
+ }
+ Long this$fileId = this.getFileId();
+ Long other$fileId = other.getFileId();
+ return !(this$fileId == null ? other$fileId != null : !((Object)this$fileId).equals(other$fileId));
+ }
+
+ protected boolean canEqual(Object other) {
+ return other instanceof ParseParam;
+ }
+
+ public int hashCode() {
+ int PRIME = 59;
+ int result = 1;
+ String $sourceUrl = this.getSourceUrl();
+ result = result * 59 + ($sourceUrl == null ? 43 : $sourceUrl.hashCode());
+ MultipartFile $sourceFile = this.getSourceFile();
+ result = result * 59 + ($sourceFile == null ? 43 : $sourceFile.hashCode());
+ List $latexReplaceList = this.getLatexReplaceList();
+ result = result * 59 + ($latexReplaceList == null ? 43 : ((Object)$latexReplaceList).hashCode());
+ Boolean $newParseVersion = this.getNewParseVersion();
+ result = result * 59 + ($newParseVersion == null ? 43 : ((Object)$newParseVersion).hashCode());
+ Long $fileId = this.getFileId();
+ result = result * 59 + ($fileId == null ? 43 : ((Object)$fileId).hashCode());
+ return result;
+ }
+
+ public String toString() {
+ return "ParseParam(sourceUrl=" + this.getSourceUrl() + ", sourceFile=" + this.getSourceFile() + ", latexReplaceList=" + this.getLatexReplaceList() + ", newParseVersion=" + this.getNewParseVersion() + ", fileId=" + this.getFileId() + ")";
+ }
+}
+
diff --git a/java-src/enums/AttrEnum.java b/java-src/enums/AttrEnum.java
new file mode 100644
index 0000000..182c34e
--- /dev/null
+++ b/java-src/enums/AttrEnum.java
@@ -0,0 +1,79 @@
+/*
+ * Decompiled with CFR 0.152.
+ */
+package com.jby.officecore.enums;
+
+public enum AttrEnum {
+ STYLE("style"),
+ COLOR("color"),
+ BACKGROUND_COLOR("background-color"),
+ BACKGROUND("background"),
+ FONT_WEIGHT("font-weight"),
+ FONT_SIZE("font-size"),
+ MIN_HEIGHT("min-height"),
+ LINE_HEIGHT("line-height"),
+ TEXT_ALIGN("text-align"),
+ PADDING("padding"),
+ PADDING_TOP("padding-top"),
+ PADDING_RIGHT("padding-right"),
+ PADDING_BOTTOM("padding-bottom"),
+ PADDING_LEFT("padding-left"),
+ TEXT_INDENT("text-indent"),
+ MARGIN("margin"),
+ MARGIN_TOP("margin-top"),
+ MARGIN_RIGHT("margin-right"),
+ MARGIN_BOTTOM("margin-bottom"),
+ MARGIN_LEFT("margin-left"),
+ VERTICAL_ALIGN("vertical-align"),
+ FONT_FAMILY("font-family"),
+ FONT_STYLE("font-style"),
+ FACE("face"),
+ SIZE("size"),
+ HREF("href"),
+ SRC("src"),
+ WIDTH("width"),
+ HEIGHT("height"),
+ CLASS("class"),
+ BORDER_STYLE("border-style"),
+ COLSPAN("colspan"),
+ ROWSPAN("rowspan"),
+ TEXT_DECORATION("text-decoration"),
+ BACKGROUND_IMAGE("background-image"),
+ TINYMCE_HORIZONTAL_LINE("tinymce-horizontal-line"),
+ TINYMCE_LINE_NUMBER("tinymce-line-number"),
+ TEXT_EMPHASIS_POSITION("text-emphasis-position"),
+ DATA_TYPE("data-type"),
+ SEGMENT("segment"),
+ BUSINESS("business"),
+ LIST_STYLE_TYPE("list-style-type"),
+ ALT("alt"),
+ NAME("name"),
+ DATA_HREF("data-href"),
+ DATA_File_SUFFIX("data-file-suffix"),
+ TINYMCE_LINK("tinymce-link"),
+ DATA_RESOURCE_URL("data-resource-url"),
+ DATA_COURSE_NETWORK_LESSON_RESOURCE_NAME("data-course-network-lesson-resource-name"),
+ TINYMCE_HOLLOWOUT("tinymce-hollowOut"),
+ TINYMCE_HIDDENONLY("tinymce-hiddenOnly"),
+ TINYMCE_HIDDENANDANSWER("tinymce-hiddenAndAnswer"),
+ BORDER("border"),
+ BORDER_LEFT("border-left"),
+ BORDER_BOTTOM("border-bottom"),
+ BORDER_RIGHT("border-right"),
+ BORDER_TOP("border-top"),
+ BORDER_LEFT_COLOR("border-left-color"),
+ BORDER_BOTTOM_COLOR("border-bottom-color"),
+ BORDER_RIGHT_COLOR("border-right-color"),
+ BORDER_TOP_COLOR("border-top-color");
+
+ private final String attr;
+
+ public String getAttr() {
+ return this.attr;
+ }
+
+ private AttrEnum(String attr) {
+ this.attr = attr;
+ }
+}
+
diff --git a/java-src/enums/TagEnum.java b/java-src/enums/TagEnum.java
new file mode 100644
index 0000000..2d0befa
--- /dev/null
+++ b/java-src/enums/TagEnum.java
@@ -0,0 +1,140 @@
+/*
+ * Decompiled with CFR 0.152.
+ *
+ * Could not load the following classes:
+ * com.jby.common.util.DistinctUtils
+ * org.apache.commons.collections4.CollectionUtils
+ * org.apache.commons.lang3.StringUtils
+ * org.jsoup.nodes.Element
+ */
+package com.jby.officecore.enums;
+
+import com.jby.common.util.DistinctUtils;
+import com.jby.officecore.domain.bo.TagStyleBO;
+import com.jby.officecore.enums.AttrEnum;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.jsoup.nodes.Element;
+
+public enum TagEnum {
+ H1("h1", true, null),
+ H2("h2", true, null),
+ H3("h3", true, null),
+ H4("h4", true, null),
+ P("p", false, null),
+ DIV("div", false, null),
+ FONT("font", false, Stream.of(AttrEnum.FACE, AttrEnum.SIZE, AttrEnum.COLOR).collect(Collectors.toList())),
+ STRIKE("strike", true, null),
+ BR("br", false, null),
+ PBR("pbr", false, null),
+ HR("hr", false, null),
+ U("u", true, null),
+ I("i", true, null),
+ SUB("sub", true, null),
+ SUP("sup", true, null),
+ WAVE("wave", true, null),
+ DOT("dot", true, null),
+ B("b", true, null),
+ A("a", false, Stream.of(AttrEnum.HREF).collect(Collectors.toList())),
+ TABLE("table", false, null),
+ UL("ul", false, null),
+ OL("ol", false, null),
+ LI("li", false, null),
+ IMG("img", false, Stream.of(AttrEnum.WIDTH, AttrEnum.HEIGHT).collect(Collectors.toList())),
+ IMQ("imq", false, Stream.of(AttrEnum.WIDTH, AttrEnum.HEIGHT).collect(Collectors.toList())),
+ VIDEO("video", false, Stream.of(AttrEnum.WIDTH, AttrEnum.HEIGHT).collect(Collectors.toList())),
+ SOURCE("source", false, null),
+ MATH("math", false, null),
+ TAB("tab", false, null),
+ TEXT("#text", false, null),
+ SPAN("span", false, Stream.of(AttrEnum.CLASS).collect(Collectors.toList())),
+ EM("em", true, null),
+ STRONG("strong", true, null);
+
+ private final String name;
+ private final Boolean dealTagStyle;
+ private final List attrList;
+ public static final Set H_P_SET;
+ public static final Set H_SET;
+ public static final Set UL_OL_SET;
+ private static final Map MAP;
+
+ public static TagEnum getTagEnum(String tagName) {
+ return MAP.get(tagName);
+ }
+
+ public static List getStyleList(Element element) {
+ ArrayList styleList = new ArrayList();
+ TagEnum tagEnum = TagEnum.getTagEnum(element.tagName());
+ if (Objects.nonNull((Object)tagEnum) && Boolean.TRUE.equals(tagEnum.dealTagStyle)) {
+ styleList.add(new TagStyleBO().setTagName(element.tagName()).setAttr(tagEnum.getName()).setValue(tagEnum.getName()));
+ }
+ if (Objects.nonNull((Object)tagEnum) && CollectionUtils.isNotEmpty(tagEnum.getAttrList())) {
+ for (AttrEnum attrEnum : tagEnum.getAttrList()) {
+ if (!StringUtils.isNotBlank((CharSequence)element.attr(attrEnum.getAttr())) || "null".equals(element.attr(attrEnum.getAttr()))) continue;
+ styleList.add(new TagStyleBO().setTagName(element.tagName()).setAttr(attrEnum.getAttr()).setValue(element.attr(attrEnum.getAttr())));
+ }
+ }
+ List styles = StringUtils.isBlank((CharSequence)element.attr(AttrEnum.STYLE.getAttr())) ? Collections.emptyList() : Arrays.asList(element.attr(AttrEnum.STYLE.getAttr()).split(";"));
+ styles.forEach(style -> {
+ if (StringUtils.isBlank((CharSequence)style)) {
+ return;
+ }
+ String[] split = style.split(":");
+ if (split.length < 2) {
+ return;
+ }
+ String attr = split[0].trim();
+ String value = split[1].trim();
+ if (StringUtils.isBlank((CharSequence)value) || "null".equals(value) || StringUtils.isBlank((CharSequence)attr) || "null".equals(attr)) {
+ return;
+ }
+ styleList.add(new TagStyleBO().setTagName(element.tagName()).setAttr(attr).setValue(value));
+ });
+ return styleList.stream().filter(DistinctUtils.distinctByKey(TagStyleBO::getAttr)).filter(e -> !e.getValue().contains("auto")).collect(Collectors.toList());
+ }
+
+ public static Map getStyleMap(Element element) {
+ List styleList = TagEnum.getStyleList(element);
+ return styleList.stream().collect(Collectors.toMap(TagStyleBO::getAttr, TagStyleBO::getValue, (l, r) -> l));
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public Boolean getDealTagStyle() {
+ return this.dealTagStyle;
+ }
+
+ public List getAttrList() {
+ return this.attrList;
+ }
+
+ private TagEnum(String name, Boolean dealTagStyle, List attrList) {
+ this.name = name;
+ this.dealTagStyle = dealTagStyle;
+ this.attrList = attrList;
+ }
+
+ static {
+ H_P_SET = Stream.of(H1.getName(), H2.getName(), H3.getName(), H4.getName(), P.getName()).collect(Collectors.toSet());
+ H_SET = Stream.of(H1.getName(), H2.getName(), H3.getName(), H4.getName()).collect(Collectors.toSet());
+ UL_OL_SET = Stream.of(UL.getName(), OL.getName()).collect(Collectors.toSet());
+ MAP = new HashMap();
+ for (TagEnum tagEnum : TagEnum.values()) {
+ MAP.put(tagEnum.getName(), tagEnum);
+ }
+ }
+}
+
diff --git a/java-src/pool/OMml2MmlTransformerPool.java b/java-src/pool/OMml2MmlTransformerPool.java
new file mode 100644
index 0000000..4d54bb0
--- /dev/null
+++ b/java-src/pool/OMml2MmlTransformerPool.java
@@ -0,0 +1,110 @@
+/*
+ * Decompiled with CFR 0.152.
+ *
+ * Could not load the following classes:
+ * com.jby.common.exceptions.BusinessException
+ * org.apache.commons.pool2.BasePooledObjectFactory
+ * org.apache.commons.pool2.PooledObject
+ * org.apache.commons.pool2.PooledObjectFactory
+ * org.apache.commons.pool2.impl.DefaultPooledObject
+ * org.apache.commons.pool2.impl.GenericObjectPool
+ * org.apache.commons.pool2.impl.GenericObjectPoolConfig
+ * org.slf4j.Logger
+ * org.slf4j.LoggerFactory
+ * org.springframework.core.io.ClassPathResource
+ */
+package com.jby.officecore.pool;
+
+import com.jby.common.exceptions.BusinessException;
+import java.util.Objects;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamSource;
+import org.apache.commons.pool2.BasePooledObjectFactory;
+import org.apache.commons.pool2.PooledObject;
+import org.apache.commons.pool2.PooledObjectFactory;
+import org.apache.commons.pool2.impl.DefaultPooledObject;
+import org.apache.commons.pool2.impl.GenericObjectPool;
+import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.core.io.ClassPathResource;
+
+public enum OMml2MmlTransformerPool {
+ INSTANCE;
+
+ private static final Logger log;
+ private GenericObjectPool objectPool;
+
+ private OMml2MmlTransformerPool() {
+ GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
+ poolConfig.setMaxTotal(30);
+ poolConfig.setMinIdle(4);
+ poolConfig.setMaxIdle(8);
+ poolConfig.setBlockWhenExhausted(true);
+ poolConfig.setMaxWaitMillis(3000L);
+ poolConfig.setTestOnCreate(true);
+ poolConfig.setTestOnBorrow(true);
+ poolConfig.setTestOnReturn(true);
+ poolConfig.setTestWhileIdle(true);
+ PooledTransformerFactory objectFactory = new PooledTransformerFactory();
+ this.objectPool = new GenericObjectPool((PooledObjectFactory)objectFactory, poolConfig);
+ }
+
+ public Transformer borrowObject() {
+ log.info("\u8f6c\u6362\u5668\u6c60TransformerPool, \u7a7a\u95f2\u5bf9\u8c61\u6570\u91cf:{}, \u6d3b\u8dc3\u5bf9\u8c61\u6570\u91cf:{}, \u963b\u585e\u7b49\u5f85\u6570\u91cf:{},", new Object[]{this.objectPool.getNumIdle(), this.objectPool.getNumActive(), this.objectPool.getNumWaiters()});
+ try {
+ return (Transformer)this.objectPool.borrowObject();
+ }
+ catch (Exception e) {
+ log.error("\u4ece\u5bf9\u8c61\u6c60\u4e2d\u501f\u51fa\u5bf9\u8c61\u5f02\u5e38", (Throwable)e);
+ return null;
+ }
+ }
+
+ public void returnObject(Transformer transformer) {
+ log.info("\u8f6c\u6362\u5668\u6c60TransformerPool, \u7a7a\u95f2\u5bf9\u8c61\u6570\u91cf:{}, \u6d3b\u8dc3\u5bf9\u8c61\u6570\u91cf:{}, \u963b\u585e\u7b49\u5f85\u6570\u91cf:{},", new Object[]{this.objectPool.getNumIdle(), this.objectPool.getNumActive(), this.objectPool.getNumWaiters()});
+ if (Objects.nonNull(transformer)) {
+ this.objectPool.returnObject((Object)transformer);
+ }
+ }
+
+ static {
+ log = LoggerFactory.getLogger(OMml2MmlTransformerPool.class);
+ }
+
+ public static class PooledTransformerFactory
+ extends BasePooledObjectFactory {
+ private static final Logger log = LoggerFactory.getLogger(PooledTransformerFactory.class);
+ private static final TransformerFactory TRANSFORMER_FACTORY = TransformerFactory.newInstance();
+
+ public Transformer create() throws Exception {
+ return PooledTransformerFactory.buildTransformer();
+ }
+
+ public PooledObject wrap(Transformer transformer) {
+ return new DefaultPooledObject((Object)transformer);
+ }
+
+ public void destroyObject(PooledObject p) throws Exception {
+ super.destroyObject(p);
+ }
+
+ public boolean validateObject(PooledObject p) {
+ return Objects.nonNull(p.getObject());
+ }
+
+ private static Transformer buildTransformer() {
+ try {
+ ClassPathResource resource = new ClassPathResource("xsl/OMML2MML.XSL");
+ StreamSource xslSource = new StreamSource(resource.getInputStream());
+ return TRANSFORMER_FACTORY.newTransformer(xslSource);
+ }
+ catch (Exception e) {
+ log.error("\u751f\u6210\u8f6c\u6362\u5668\u5f02\u5e38", (Throwable)e);
+ throw new BusinessException("\u751f\u6210\u8f6c\u6362\u5668\u5f02\u5e38");
+ }
+ }
+ }
+}
+
diff --git a/java-src/service/impl/FileServiceImpl.java b/java-src/service/impl/FileServiceImpl.java
new file mode 100644
index 0000000..2be3d26
--- /dev/null
+++ b/java-src/service/impl/FileServiceImpl.java
@@ -0,0 +1,2255 @@
+/*
+ * Decompiled with CFR 0.152.
+ *
+ * Could not load the following classes:
+ * cn.hutool.core.io.FileUtil
+ * com.alibaba.fastjson.JSON
+ * com.alibaba.fastjson.JSONObject
+ * com.baomidou.mybatisplus.core.conditions.Wrapper
+ * com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
+ * com.baomidou.mybatisplus.core.toolkit.Wrappers
+ * com.jby.common.base.entity.CommonBean
+ * com.jby.common.bo.SessionUser
+ * com.jby.common.exceptions.BizAssert
+ * com.jby.common.exceptions.BusinessException
+ * com.jby.common.feign.FeignUtils
+ * com.jby.common.result.Result
+ * com.jby.common.util.FileUtil
+ * com.jby.common.util.RequestUtil
+ * com.jby.common.util.SpringContextHolder
+ * com.jby.common.util.UniqueUtil
+ * com.jby.office.constant.ConfigConstants$FileConfig
+ * com.jby.office.constant.Constants
+ * com.jby.office.domain.dto.QuestionSourceFeatureMetadataDTO
+ * com.jby.office.domain.param.DownloadFileParam
+ * com.jby.office.domain.param.FileParam
+ * com.jby.office.domain.param.GenerateFileParam
+ * com.jby.office.domain.param.GlobalConfigParam
+ * com.jby.office.domain.param.OfficeFileParseParam
+ * com.jby.office.domain.param.OfficeFileParseRecordParam
+ * com.jby.office.domain.param.QueryFileParam
+ * com.jby.office.domain.param.UpdateFileParam
+ * com.jby.office.domain.vo.ExportQuestionVO
+ * com.jby.office.domain.vo.OfficeConfigVO
+ * com.jby.office.domain.vo.OfficeFileConfigVO
+ * com.jby.office.domain.vo.OfficeFileDownloadScheduleVO
+ * com.jby.office.domain.vo.OfficeFileElementVO
+ * com.jby.office.domain.vo.OfficeFileInfoVO
+ * com.jby.office.domain.vo.OfficeFileParseRecordVO
+ * com.jby.office.domain.vo.OfficeFileParseVO
+ * com.jby.office.domain.vo.OfficeFileStyleVO
+ * com.jby.office.domain.vo.OfficeGlobalConfigVO
+ * com.jby.office.domain.vo.OfficeMarginVO
+ * com.jby.office.domain.vo.OfficeQuestionBlockVO
+ * com.jby.office.domain.vo.QuestionDetailVO
+ * com.jby.office.domain.vo.TagVO
+ * com.jby.office.enums.BooleanEnum
+ * com.jby.office.enums.DownScheduleTypeEnum
+ * com.jby.office.enums.EditionEnum
+ * com.jby.office.enums.ElementTypeEnum
+ * com.jby.office.enums.FileTypeEnum
+ * com.jby.office.enums.ListenEnum
+ * com.jby.officecore.config.OfficeCoreConfig
+ * com.jby.officecore.domain.bo.CreateDocumentBO
+ * com.jby.officecore.domain.bo.CreateFileBO
+ * com.jby.officecore.domain.bo.ElementNumBO
+ * com.jby.officecore.domain.bo.QuestionBO
+ * com.jby.officecore.domain.bo.TitleBO
+ * com.jby.officecore.domain.param.CreatePdfParam
+ * com.jby.officecore.domain.param.ParseParam
+ * com.jby.officecore.enums.AttrEnum
+ * com.jby.officecore.enums.CollectQuestionEnum
+ * com.jby.officecore.enums.LogicTypeEnum
+ * com.jby.officecore.enums.MarginTypeEnum
+ * com.jby.officecore.enums.PageEnum
+ * com.jby.officecore.enums.QuestionEnum
+ * com.jby.officecore.enums.TagEnum
+ * com.jby.officecore.enums.TitleShowEnum
+ * com.jby.officecore.utils.AttachmentUtil
+ * com.jby.officecore.utils.CodeUtil
+ * com.jby.officecore.utils.ElementNumberUtil
+ * com.jby.officecore.utils.OfficeParseUtil
+ * com.jby.officecore.utils.WordExportUtil
+ * com.jby.officecore.utils.WordParseUtil
+ * com.jby.system.domain.param.NodeParam
+ * com.jby.system.enums.AttachmentModuleEnum
+ * javax.annotation.Resource
+ * org.apache.commons.collections4.CollectionUtils
+ * org.apache.commons.compress.utils.Lists
+ * org.apache.commons.lang3.StringUtils
+ * org.apache.poi.xwpf.usermodel.XWPFDocument
+ * org.jsoup.Jsoup
+ * org.jsoup.nodes.Document
+ * org.jsoup.nodes.Element
+ * org.jsoup.nodes.Node
+ * org.jsoup.select.Elements
+ * org.map.utils.BeanMapping
+ * org.slf4j.Logger
+ * org.slf4j.LoggerFactory
+ * org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
+ * org.springframework.stereotype.Service
+ * org.springframework.web.multipart.MultipartFile
+ */
+package com.jby.officefile.service.impl;
+
+import cn.hutool.core.io.FileUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.jby.common.base.entity.CommonBean;
+import com.jby.common.bo.SessionUser;
+import com.jby.common.exceptions.BizAssert;
+import com.jby.common.exceptions.BusinessException;
+import com.jby.common.feign.FeignUtils;
+import com.jby.common.result.Result;
+import com.jby.common.util.RequestUtil;
+import com.jby.common.util.SpringContextHolder;
+import com.jby.common.util.UniqueUtil;
+import com.jby.office.constant.ConfigConstants;
+import com.jby.office.constant.Constants;
+import com.jby.office.domain.dto.QuestionSourceFeatureMetadataDTO;
+import com.jby.office.domain.param.DownloadFileParam;
+import com.jby.office.domain.param.FileParam;
+import com.jby.office.domain.param.GenerateFileParam;
+import com.jby.office.domain.param.GlobalConfigParam;
+import com.jby.office.domain.param.OfficeFileParseParam;
+import com.jby.office.domain.param.OfficeFileParseRecordParam;
+import com.jby.office.domain.param.QueryFileParam;
+import com.jby.office.domain.param.UpdateFileParam;
+import com.jby.office.domain.vo.ExportQuestionVO;
+import com.jby.office.domain.vo.OfficeConfigVO;
+import com.jby.office.domain.vo.OfficeFileConfigVO;
+import com.jby.office.domain.vo.OfficeFileDownloadScheduleVO;
+import com.jby.office.domain.vo.OfficeFileElementVO;
+import com.jby.office.domain.vo.OfficeFileInfoVO;
+import com.jby.office.domain.vo.OfficeFileParseRecordVO;
+import com.jby.office.domain.vo.OfficeFileParseVO;
+import com.jby.office.domain.vo.OfficeFileStyleVO;
+import com.jby.office.domain.vo.OfficeGlobalConfigVO;
+import com.jby.office.domain.vo.OfficeMarginVO;
+import com.jby.office.domain.vo.OfficeQuestionBlockVO;
+import com.jby.office.domain.vo.QuestionDetailVO;
+import com.jby.office.domain.vo.TagVO;
+import com.jby.office.enums.BooleanEnum;
+import com.jby.office.enums.DownScheduleTypeEnum;
+import com.jby.office.enums.EditionEnum;
+import com.jby.office.enums.ElementTypeEnum;
+import com.jby.office.enums.FileTypeEnum;
+import com.jby.office.enums.ListenEnum;
+import com.jby.officecore.config.OfficeCoreConfig;
+import com.jby.officecore.domain.bo.CreateDocumentBO;
+import com.jby.officecore.domain.bo.CreateFileBO;
+import com.jby.officecore.domain.bo.ElementNumBO;
+import com.jby.officecore.domain.bo.QuestionBO;
+import com.jby.officecore.domain.bo.TitleBO;
+import com.jby.officecore.domain.param.CreatePdfParam;
+import com.jby.officecore.domain.param.ParseParam;
+import com.jby.officecore.enums.AttrEnum;
+import com.jby.officecore.enums.CollectQuestionEnum;
+import com.jby.officecore.enums.LogicTypeEnum;
+import com.jby.officecore.enums.MarginTypeEnum;
+import com.jby.officecore.enums.PageEnum;
+import com.jby.officecore.enums.QuestionEnum;
+import com.jby.officecore.enums.TagEnum;
+import com.jby.officecore.enums.TitleShowEnum;
+import com.jby.officecore.utils.AttachmentUtil;
+import com.jby.officecore.utils.CodeUtil;
+import com.jby.officecore.utils.ElementNumberUtil;
+import com.jby.officecore.utils.OfficeParseUtil;
+import com.jby.officecore.utils.WordExportUtil;
+import com.jby.officecore.utils.WordParseUtil;
+import com.jby.officefile.config.OfficeFileConfig;
+import com.jby.officefile.domain.entity.OfficeFileDownloadSchedule;
+import com.jby.officefile.domain.entity.OfficeFileParseRecord;
+import com.jby.officefile.feign.OfficeFileServiceFeign;
+import com.jby.officefile.feign.OfficeGlobalConfigServiceFeign;
+import com.jby.officefile.mapper.OfficeFileDownloadScheduleMapper;
+import com.jby.officefile.service.FileService;
+import com.jby.officefile.service.OfficeFileDownloadScheduleService;
+import com.jby.officefile.service.OfficeFileParseRecordService;
+import com.jby.system.domain.param.NodeParam;
+import com.jby.system.enums.AttachmentModuleEnum;
+import java.io.File;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.IdentityHashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionException;
+import java.util.concurrent.CompletionStage;
+import java.util.concurrent.Executor;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Function;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import javax.annotation.Resource;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.compress.utils.Lists;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.xwpf.usermodel.XWPFDocument;
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.jsoup.nodes.Element;
+import org.jsoup.nodes.Node;
+import org.jsoup.select.Elements;
+import org.map.utils.BeanMapping;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+@Service
+public class FileServiceImpl
+implements FileService {
+ private static final Logger log = LoggerFactory.getLogger(FileServiceImpl.class);
+ private static final Pattern QUESTION_NUM_PATTERN = Pattern.compile("(?:(?:?u>|[\u300a\u300b\\s]| )*\\d(?:?u>|[\u300a\u300b\\s]| )*)+");
+ public static final Set ANSWER_MERGE_QUESTION_TYPE_SET_OLD = Stream.of(1L, 2L, 3L, 4L, 5L, 7L, 8L, 9L, 10L, 11L).collect(Collectors.toSet());
+ private static final Set ANSWER_MERGE_QUESTION_TYPE_SET_NEW = Stream.of(1048L, 1049L, 1050L, 1051L, 1054L, 1055L, 1525L).collect(Collectors.toSet());
+ @Resource
+ private OfficeCoreConfig officeCoreConfig;
+ @Resource
+ private OfficeFileConfig officeFileConfig;
+ @Resource
+ private OfficeFileDownloadScheduleService downloadScheduleService;
+ @Resource
+ private OfficeFileDownloadScheduleMapper officeFileDownloadScheduleMapper;
+ @Resource
+ private OfficeFileServiceFeign officeFileServiceFeign;
+ @Resource
+ private OfficeGlobalConfigServiceFeign officeGlobalConfigServiceFeign;
+ @Resource(name="batchDownloadMainExecutor")
+ private ThreadPoolTaskExecutor batchDownloadMainExecutor;
+ @Resource(name="batchDownloadTaskExecutor")
+ private ThreadPoolTaskExecutor batchDownloadTaskExecutor;
+ @Resource
+ private OfficeFileParseRecordService officeFileParseRecordService;
+
+ @Override
+ public OfficeFileInfoVO generateFileByUrl(GenerateFileParam param) {
+ BizAssert.isNotBlank((String)param.getSourceUrl(), (String)"\u6e90\u6587\u4ef6\u5730\u5740\u4e3a\u7a7a");
+ BizAssert.notNull((Object)param.getPhaseId(), (String)"\u5b66\u6bb5id\u4e3a\u7a7a");
+ BizAssert.notNull((Object)param.getCourseId(), (String)"\u5b66\u79d1id\u4e3a\u7a7a");
+ FileServiceImpl.compatibleEncode(param);
+ if (StringUtils.isBlank((CharSequence)param.getFileName())) {
+ param.setFileName(com.jby.common.util.FileUtil.getFileName((String)param.getSourceUrl()));
+ }
+ ParseParam parseParam = new ParseParam().setSourceUrl(param.getSourceUrl());
+ this.addLatexReplaceList(parseParam);
+ String html = WordParseUtil.parseByUrl((ParseParam)parseParam);
+ List elementList = OfficeParseUtil.buildElements((String)html);
+ param.setElementList(elementList);
+ return (OfficeFileInfoVO)FeignUtils.parse((Result)this.officeFileServiceFeign.generateFile(param));
+ }
+
+ private static void compatibleEncode(GenerateFileParam param) {
+ if (!param.getFileName().contains("+")) {
+ param.setFileName(com.jby.common.util.FileUtil.decodeUrl((String)param.getFileName()));
+ }
+ if (!param.getSourceUrl().contains("+")) {
+ param.setSourceUrl(com.jby.common.util.FileUtil.decodeUrl((String)param.getSourceUrl()));
+ }
+ }
+
+ @Override
+ public OfficeFileInfoVO generateFileByFile(FileParam fileParam) {
+ BizAssert.notNull((Object)fileParam.getSourceFile(), (String)"\u6e90\u6587\u4ef6\u4e3a\u7a7a");
+ BizAssert.isTrue((fileParam.getSourceFile().getSize() != 0L ? 1 : 0) != 0, (String)"\u6587\u6863\u5185\u5bb9\u4e3a\u7a7a\uff01");
+ BizAssert.isNotBlank((String)fileParam.getGenerateFileJson(), (String)"json\u53c2\u6570\u4e3a\u7a7a");
+ GenerateFileParam param = (GenerateFileParam)JSONObject.parseObject((String)fileParam.getGenerateFileJson(), GenerateFileParam.class);
+ BizAssert.notNull((Object)param.getPhaseId(), (String)"\u5b66\u6bb5id\u4e3a\u7a7a");
+ BizAssert.notNull((Object)param.getCourseId(), (String)"\u5b66\u79d1id\u4e3a\u7a7a");
+ if (StringUtils.isBlank((CharSequence)param.getFileName())) {
+ param.setFileName(com.jby.common.util.FileUtil.getFileName((String)fileParam.getSourceFile().getOriginalFilename()));
+ }
+ ParseParam parseParam = new ParseParam().setSourceFile(fileParam.getSourceFile());
+ this.addLatexReplaceList(parseParam);
+ String html = WordParseUtil.parseByFile((ParseParam)parseParam);
+ List elementList = OfficeParseUtil.buildElements((String)html);
+ param.setElementList(elementList);
+ return (OfficeFileInfoVO)FeignUtils.parse((Result)this.officeFileServiceFeign.generateFile(param));
+ }
+
+ @Override
+ public OfficeFileParseVO parseOfficeFile(OfficeFileParseParam param) {
+ BizAssert.notNull((Object)param.getFile(), (String)"\u6587\u6863\u4e3a\u7a7a");
+ BizAssert.isTrue((param.getFile().getSize() != 0L ? 1 : 0) != 0, (String)"\u6587\u6863\u5185\u5bb9\u4e3a\u7a7a\uff01");
+ WordParseUtil.validSize((double)param.getFile().getSize(), null);
+ ParseParam parseParam = new ParseParam().setSourceFile(param.getFile()).setNewParseVersion(param.getNewParseVersion()).setFileId(param.getFileId());
+ this.addLatexReplaceList(parseParam);
+ String html = WordParseUtil.parseByFile((ParseParam)parseParam);
+ return new OfficeFileParseVO().setFileId(param.getFileId()).setContent(html);
+ }
+
+ private void addLatexReplaceList(ParseParam parseParam) {
+ try {
+ OfficeGlobalConfigVO configVO = (OfficeGlobalConfigVO)FeignUtils.parse((Result)this.officeGlobalConfigServiceFeign.getGlobalConfigInfo(new GlobalConfigParam().setConfigKey("LATEX_REPLACE")));
+ if (Objects.nonNull(configVO) && CollectionUtils.isNotEmpty((Collection)configVO.getConfigList())) {
+ List latexReplaceList = JSONObject.parseArray((String)JSON.toJSONString((Object)configVO.getConfigList()), JSONObject.class);
+ parseParam.setLatexReplaceList(latexReplaceList);
+ }
+ }
+ catch (Exception e) {
+ log.error("\u6dfb\u52a0latex\u516c\u5f0f\u89c4\u8303\u914d\u7f6e\u4fe1\u606f\u5f02\u5e38", (Throwable)e);
+ }
+ }
+
+ @Override
+ public String downloadOfficeFile(DownloadFileParam param) {
+ String fileUrl;
+ if (FileTypeEnum.PDF.getType().equals(param.getFileType())) {
+ fileUrl = Objects.isNull(param.getPdfFile()) ? this.downloadPdf(param) : this.downloadListenAudio(param);
+ } else {
+ CreateFileBO createFileBO;
+ OfficeFileInfoVO fileInfo = (OfficeFileInfoVO)FeignUtils.parse((Result)this.officeFileServiceFeign.getFileDetail(new QueryFileParam().setFileId(param.getFileId())));
+ if (EditionEnum.STUDENT_ANSWER_END.getEdition().equals(param.getEdition())) {
+ createFileBO = this.createDocument(param.setEdition(EditionEnum.STUDENT.getEdition()), fileInfo, null);
+ this.createDocument(param.setEdition(EditionEnum.ANSWER.getEdition()), fileInfo, createFileBO.getDocument());
+ } else {
+ createFileBO = this.createDocument(param, fileInfo, null);
+ }
+ fileUrl = WordExportUtil.createOfficeFile((CreateFileBO)createFileBO);
+ }
+ log.info("\u4e0b\u8f7d\u5728\u7ebf\u7f16\u8f91\u6587\u4ef6\u6210\u529f, fileUrl={}, param={}", (Object)fileUrl, (Object)JSON.toJSONString((Object)param));
+ if (BooleanEnum.TRUE.getValue().equals(param.getIsEncodeUrl())) {
+ fileUrl = com.jby.common.util.FileUtil.encodeUrl((String)fileUrl);
+ }
+ return fileUrl;
+ }
+
+ private CreateFileBO createDocument(DownloadFileParam param, OfficeFileInfoVO fileInfoVO, XWPFDocument xwpfDocument) {
+ OfficeFileInfoVO fileInfo = (OfficeFileInfoVO)JSON.parseObject((String)JSON.toJSONString((Object)fileInfoVO), OfficeFileInfoVO.class);
+ this.filterElementList(fileInfo, param.getEdition());
+ ArrayList contentList = new ArrayList();
+ ArrayList questionList = new ArrayList();
+ this.collectContent(contentList, questionList, fileInfo, fileInfo.getOfficeConfigVO(), param.getEdition());
+ PageEnum pageEnum = PageEnum.getPageEnum((String)param.getPage());
+ String templateName = this.getTemplateName(StringUtils.isBlank((CharSequence)param.getTemplateName()) ? pageEnum.name() : param.getTemplateName(), param.getEdition(), fileInfo.getFileConfigList());
+ XWPFDocument document = WordExportUtil.createDocument((CreateDocumentBO)new CreateDocumentBO().setTemplateName(templateName).setPageEnum(pageEnum).setOfficeConfig(fileInfo.getOfficeConfigVO()).setContentList(contentList).setFileMarginVO(fileInfo.getFileMarginVO()).setEdition(param.getEdition()).setNewDownloadVersion(param.getNewDownloadVersion()).setXwpfDocument(xwpfDocument));
+ BizAssert.notNull((Object)document, (String)"\u751f\u6210\u6587\u6863\u5f02\u5e38");
+ return new CreateFileBO().setDocument(document).setFileName(fileInfo.getFileName()).setQuestionList(questionList).setDownloadListenType(param.getDownloadListenType());
+ }
+
+ private String getTemplateName(String templateName, Integer edition, List fileConfigList) {
+ Optional bindingLine;
+ if (EditionEnum.STUDENT.getEdition().equals(edition) && (bindingLine = fileConfigList.stream().filter(e -> "bindingLine".equals(e.getFieldKey()) && BooleanEnum.TRUE.getValue().equals(e.getEnableField())).findAny()).isPresent()) {
+ templateName = templateName + "_" + bindingLine.get().getFieldKey();
+ }
+ return templateName + "." + "docx";
+ }
+
+ private void collectContent(List contentList, List questionList, OfficeFileInfoVO fileInfo, OfficeConfigVO officeConfig, Integer edition) {
+ Map configMap = fileInfo.getFileConfigList().stream().collect(Collectors.toMap(OfficeFileConfigVO::getFieldKey, Function.identity(), (l, r) -> l));
+ for (String head : ConfigConstants.FileConfig.FILE_HEAD_LIST) {
+ String content;
+ OfficeFileConfigVO headConfig = (OfficeFileConfigVO)configMap.get(head);
+ String string = content = "title".equals(headConfig.getFieldKey()) ? fileInfo.getFileLabelName() : headConfig.getFieldValue();
+ if (!BooleanEnum.TRUE.getValue().equals(headConfig.getEnableField()) || !StringUtils.isNotBlank((CharSequence)content)) continue;
+ String fieldValue = this.addDefaultTemplateStyle(officeConfig.getTemplateStyleMap(), headConfig.getFieldKey(), content);
+ contentList.add(fieldValue);
+ }
+ this.collectElementInfo(fileInfo, contentList, questionList, officeConfig, edition);
+ }
+
+ private String addDefaultTemplateStyle(Map templateStyleMap, String templateKey, String template) {
+ String templateStyle = templateStyleMap.get(templateKey);
+ if (StringUtils.isNotBlank((CharSequence)templateStyle) && templateStyle.contains("replaceKey")) {
+ return templateStyle.replace("replaceKey", template);
+ }
+ return template;
+ }
+
+ private void filterElementList(OfficeFileInfoVO fileInfo, Integer edition) {
+ if (EditionEnum.STUDENT.getEdition().equals(edition)) {
+ fileInfo.setElementList(fileInfo.getElementList().stream().filter(e -> Boolean.TRUE.equals(e.getStudentShow())).collect(Collectors.toList()));
+ }
+ if (EditionEnum.ANSWER.getEdition().equals(edition) || EditionEnum.ANSWER_ONLY_ANSWER.getEdition().equals(edition)) {
+ fileInfo.setElementList(fileInfo.getElementList().stream().filter(e -> ElementTypeEnum.ANSWER_FILTER_SET.contains(e.getElementType())).peek(m -> {
+ if (ElementTypeEnum.TEXT.getType().equals(m.getElementType()) && StringUtils.isNotBlank((CharSequence)m.getContent())) {
+ Document doc = Jsoup.parse((String)m.getContent());
+ Element body = doc.body();
+ Elements targetSpans = body.select("span." + AttrEnum.TINYMCE_HOLLOWOUT.getAttr() + ", span." + AttrEnum.TINYMCE_HIDDENANDANSWER.getAttr());
+ if (CollectionUtils.isEmpty((Collection)targetSpans)) {
+ m.setDeleted(Boolean.TRUE);
+ return;
+ }
+ Element container = body.child(0);
+ container.empty();
+ for (int i = 0; i < targetSpans.size(); ++i) {
+ ((Element)targetSpans.get(i)).removeClass(AttrEnum.TINYMCE_HOLLOWOUT.getAttr());
+ ((Element)targetSpans.get(i)).removeClass(AttrEnum.TINYMCE_HIDDENANDANSWER.getAttr());
+ container.appendChild((Node)((Element)targetSpans.get(i)).clone());
+ if (i >= targetSpans.size() - 1) continue;
+ container.appendChild((Node)new Element("span").text("\uff1b"));
+ }
+ m.setContent(body.html());
+ }
+ }).filter(e -> !Boolean.TRUE.equals(e.getDeleted())).collect(Collectors.toList()));
+ }
+ }
+
+ private void collectElementInfo(OfficeFileInfoVO fileInfo, List contentList, List questionList, OfficeConfigVO officeConfig, Integer edition) {
+ ElementNumberUtil elementNumberUtil = new ElementNumberUtil();
+ ArrayList titleList = new ArrayList();
+ titleList.add(new TitleBO().setQuestionList(new ArrayList()));
+ for (OfficeFileElementVO element : fileInfo.getElementList()) {
+ if (ElementTypeEnum.TITLE_1.getType().equals(element.getElementType())) {
+ titleList.add(new TitleBO().setIndex(Integer.valueOf(contentList.size())).setElementNumberStyle(element.getElementNumberStyle()).setQuestionList(new ArrayList()));
+ }
+ if (ElementTypeEnum.QUESTION.getType().equals(element.getElementType()) && element.getQuestionShowType() != 1) {
+ this.collectQuestionBankInfo(contentList, edition, officeConfig, element, titleList, questionList, fileInfo.getFileStyle());
+ } else if (ElementTypeEnum.RELATION_SET.contains(element.getElementType()) && (EditionEnum.STUDENT.getEdition().equals(edition) || EditionEnum.TEACHER.getEdition().equals(edition))) {
+ this.collectAttachmentInfo(contentList, officeConfig.getAttachmentCard(), officeConfig.getCommonIconMap(), element, fileInfo.getFileMarginVO());
+ } else if (ElementTypeEnum.CONTENT_SET.contains(element.getElementType())) {
+ ElementNumBO elementNumBO = elementNumberUtil.getElementNum(element, fileInfo.getFileStyle(), officeConfig.getElementNumStyleMap(), officeConfig.getElementIconMap());
+ String elementContent = elementNumBO.getStyleElementNum() + officeConfig.getTagVO().getDivStart() + this.notNullContent(element.getContent()) + officeConfig.getTagVO().getDivEnd();
+ contentList.add(elementContent);
+ } else if (ElementTypeEnum.QUESTION_BLOCK.getType().equals(element.getElementType())) {
+ String[] split;
+ OfficeQuestionBlockVO officeQuestionBlockVO = element.getOfficeQuestionBlockVO();
+ if (officeQuestionBlockVO == null) continue;
+ ElementNumBO elementNumBO = elementNumberUtil.getElementNum(element, fileInfo.getFileStyle(), officeConfig.getElementNumStyleMap(), officeConfig.getElementIconMap());
+ TagVO tagVO = officeConfig.getTagVO();
+ String questionBlockType = tagVO.getQuestionBlockType();
+ String questionBlockTypeTag = "";
+ if (StringUtils.isNotBlank((CharSequence)questionBlockType) && (split = questionBlockType.split("#")).length == 3) {
+ int blockType = element.getOfficeQuestionBlockVO().getBlockType();
+ questionBlockTypeTag = split[blockType - 1];
+ }
+ if (StringUtils.isNotBlank((CharSequence)questionBlockTypeTag)) {
+ questionBlockTypeTag = questionBlockTypeTag.replaceAll("number", elementNumBO.getStyleElementNum());
+ String scoreStr = FileServiceImpl.getScoreStr(officeQuestionBlockVO);
+ questionBlockTypeTag = questionBlockTypeTag.replaceAll("score", scoreStr);
+ }
+ String blockContent = this.notNullContent(officeQuestionBlockVO.getBlockContent());
+ if (StringUtils.isNotBlank((CharSequence)questionBlockTypeTag) && StringUtils.isNotBlank((CharSequence)blockContent)) {
+ blockContent = this.insertTagIntoFirstElement(blockContent, questionBlockTypeTag);
+ }
+ String elementContent = officeConfig.getTagVO().getDivStart() + blockContent + officeConfig.getTagVO().getDivEnd();
+ contentList.add(elementContent);
+ }
+ this.addElementAfterInfo(contentList, edition, element, officeConfig.getTagVO());
+ }
+ this.dealTitle(fileInfo, contentList, titleList, officeConfig.getElementNumStyleMap());
+ if (EditionEnum.ANSWER.getEdition().equals(edition) || EditionEnum.ANSWER_ONLY_ANSWER.getEdition().equals(edition)) {
+ this.dealAnswerMergeNew2(contentList, titleList);
+ }
+ }
+
+ private static String getScoreStr(OfficeQuestionBlockVO officeQuestionBlockVO) {
+ BigDecimal score = officeQuestionBlockVO.getScore();
+ String scoreStr = "";
+ if (score != null && score.compareTo(BigDecimal.ZERO) != 0) {
+ BigDecimal stripped = score.stripTrailingZeros();
+ scoreStr = stripped.scale() <= 0 ? stripped.toPlainString() : stripped.setScale(1, RoundingMode.HALF_UP).toPlainString();
+ scoreStr = "(" + scoreStr + "\u5206" + ")";
+ }
+ return scoreStr;
+ }
+
+ private String insertTagIntoFirstElement(String blockContent, String insertTag) {
+ try {
+ Element firstChild;
+ Document doc = Jsoup.parse((String)blockContent);
+ doc.outputSettings().prettyPrint(false).indentAmount(0);
+ Element body = doc.body();
+ Element firstElement = body.children().first();
+ if (firstElement == null) {
+ return insertTag + blockContent;
+ }
+ Elements children = firstElement.children();
+ if (!children.isEmpty() && "br".equalsIgnoreCase((firstChild = children.first()).tagName())) {
+ firstChild.remove();
+ }
+ firstElement.prepend(insertTag);
+ return body.html();
+ }
+ catch (Exception e) {
+ log.error("\u63d2\u5165\u9898\u5757\u6807\u7b7e\u5230\u5185\u5bb9\u5931\u8d25, blockContent:{}, insertTag:{}", new Object[]{blockContent, insertTag, e});
+ return insertTag + blockContent;
+ }
+ }
+
+ private void dealAnswerMerge(List contentList, List titleList) {
+ List>> groups;
+ if (CollectionUtils.isEmpty(contentList)) {
+ return;
+ }
+ HashMap indexToTitleMap = new HashMap();
+ for (TitleBO titleBO : titleList) {
+ if (CollectionUtils.isEmpty((Collection)titleBO.getQuestionList())) continue;
+ for (QuestionBO q2 : titleBO.getQuestionList()) {
+ if (!Objects.nonNull(q2.getIndex())) continue;
+ indexToTitleMap.put(q2.getIndex(), titleBO);
+ }
+ }
+ IdentityHashMap>>> titleGroups = new IdentityHashMap>>>();
+ for (TitleBO title : titleList) {
+ if (CollectionUtils.isEmpty((Collection)title.getQuestionList())) continue;
+ List sortedQuestions = title.getQuestionList().stream().filter(q -> Objects.nonNull(q.getIndex())).sorted(Comparator.comparing(QuestionBO::getIndex)).collect(Collectors.toList());
+ groups = new ArrayList();
+ ArrayList currentGroup = new ArrayList();
+ for (QuestionBO questionBO : sortedQuestions) {
+ if (Boolean.TRUE.equals(questionBO.getIsMergeAnswer())) {
+ currentGroup.add(questionBO.getIndex());
+ continue;
+ }
+ if (!currentGroup.isEmpty()) {
+ groups.add(new ArrayList(currentGroup));
+ currentGroup.clear();
+ }
+ groups.add((ArrayList>)Collections.singletonList(questionBO.getIndex()));
+ }
+ if (!currentGroup.isEmpty()) {
+ groups.add(currentGroup);
+ }
+ titleGroups.put(title, groups);
+ }
+ ArrayList arrayList = new ArrayList();
+ int i = 0;
+ while (i < contentList.size()) {
+ if (indexToTitleMap.containsKey(i)) {
+ TitleBO title = (TitleBO)indexToTitleMap.get(i);
+ groups = (List)titleGroups.get(title);
+ boolean found = false;
+ for (List list : groups) {
+ if (!list.contains(i) || !((Integer)list.get(0)).equals(i)) continue;
+ StringBuilder merged = new StringBuilder();
+ Iterator iterator = list.iterator();
+ while (iterator.hasNext()) {
+ int idx = (Integer)iterator.next();
+ if (merged.length() > 0) {
+ merged.append(" ");
+ }
+ merged.append(contentList.get(idx));
+ }
+ arrayList.add(merged.toString());
+ i = (Integer)Collections.max(list) + 1;
+ found = true;
+ break;
+ }
+ if (found) continue;
+ arrayList.add(contentList.get(i));
+ ++i;
+ continue;
+ }
+ arrayList.add(contentList.get(i));
+ ++i;
+ }
+ contentList.clear();
+ contentList.addAll(arrayList);
+ }
+
+ private void dealTitle(OfficeFileInfoVO fileInfo, List contentList, List titleList, Map> styleMap) {
+ titleList.forEach(titleBO -> {
+ if (Objects.isNull(titleBO.getIndex()) || CollectionUtils.isEmpty((Collection)titleBO.getQuestionList())) {
+ return;
+ }
+ Integer showType = fileInfo.getFileStyle().getShowQuestionNumberScore();
+ ArrayList showList = new ArrayList();
+ if (TitleShowEnum.SHOW_QUESTION_NUM_SET.contains(showType)) {
+ showList.add("\u5171" + titleBO.getQuestionList().size() + "\u5c0f\u9898");
+ }
+ if (TitleShowEnum.SHOW_QUESTION_SCORE_SET.contains(showType)) {
+ BigDecimal total = titleBO.getQuestionList().stream().map(QuestionBO::getScore).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
+ if ((total = total.stripTrailingZeros()).scale() <= 0) {
+ total = total.setScale(0);
+ }
+ showList.add("\u5171" + total + "\u5206");
+ }
+ if (CollectionUtils.isNotEmpty(showList)) {
+ String questionTip = "(" + String.join((CharSequence)",", showList) + ")";
+ if (StringUtils.isBlank((CharSequence)titleBO.getElementNumberStyle())) {
+ String elementNumberStyle = (String)((Map)styleMap.get("elementType" + ElementTypeEnum.TITLE_1.getType())).get("numStyle");
+ questionTip = elementNumberStyle.replace("elementNumber\u3001", questionTip);
+ }
+ String title = (String)contentList.get(titleBO.getIndex());
+ contentList.set(titleBO.getIndex(), title + questionTip);
+ }
+ fileInfo.getFileConfigList().stream().filter(e -> "bigScoreLine".equals(e.getFieldKey()) && BooleanEnum.TRUE.getValue().equals(e.getEnableField()) && StringUtils.isNotBlank((CharSequence)e.getFieldValue())).map(OfficeFileConfigVO::getFieldValue).findFirst().ifPresent(bigScoreLine -> {
+ String title = (String)contentList.get(titleBO.getIndex());
+ contentList.set(titleBO.getIndex(), bigScoreLine + title);
+ });
+ });
+ }
+
+ private void collectAttachmentInfo(List contentList, String attachmentCard, Map commonIconMap, OfficeFileElementVO element, OfficeMarginVO officeMarginVO) {
+ String qrCodeUrl = null;
+ if (ElementTypeEnum.AUDIO.getType().equals(element.getElementType()) && Objects.nonNull(element.getAudioDetail())) {
+ qrCodeUrl = element.getAudioDetail().getQrCodeUrl();
+ }
+ if (ElementTypeEnum.VIDEO.getType().equals(element.getElementType()) && Objects.nonNull(element.getVideoDetail())) {
+ qrCodeUrl = element.getVideoDetail().getQrCodeUrl();
+ }
+ if (ElementTypeEnum.GGB.getType().equals(element.getElementType()) && Objects.nonNull(element.getGgbDetail())) {
+ qrCodeUrl = element.getGgbDetail().getQrCodeUrl();
+ }
+ if (ElementTypeEnum.CHEMISTRY.getType().equals(element.getElementType()) && Objects.nonNull(element.getChemistryDetail())) {
+ qrCodeUrl = element.getChemistryDetail().getQrCodeUrl();
+ }
+ if (ElementTypeEnum.MINDMAP.getType().equals(element.getElementType()) && Objects.nonNull(element.getMindmapDetailVo())) {
+ qrCodeUrl = element.getMindmapDetailVo().getQrCodeUrl();
+ }
+ String attachmentContent = this.getAttachmentCard(attachmentCard, commonIconMap, element.getElementType(), element.getAttachmentName(), qrCodeUrl);
+ if (officeMarginVO != null && !StringUtils.isEmpty((CharSequence)officeMarginVO.getLeftMargin())) {
+ Document doc;
+ Element tabNode;
+ String currLeftMarginStr = officeMarginVO.getLeftMargin();
+ double currLeftMargin = Double.parseDouble(currLeftMarginStr = currLeftMarginStr.replaceAll("[^\\d.]", ""));
+ if (currLeftMargin > MarginTypeEnum.NORMAL.getLeftMargin() && (tabNode = (doc = Jsoup.parse((String)attachmentContent)).select(TagEnum.TAB.getName()).first()) != null) {
+ String widthStr = tabNode.attr(AttrEnum.WIDTH.getAttr());
+ double width = Double.parseDouble(widthStr);
+ tabNode.attr(AttrEnum.WIDTH.getAttr(), (int)(width *= MarginTypeEnum.NORMAL.getLeftMargin() / currLeftMargin) + "");
+ attachmentContent = doc.body().html();
+ }
+ }
+ contentList.add(attachmentContent);
+ }
+
+ private void collectQuestionInfo(List contentList, List questionList, OfficeFileStyleVO fileStyle, Integer edition, OfficeConfigVO officeConfig, ElementNumberUtil elementNumberUtil, List titleList, OfficeFileElementVO element) {
+ QuestionDetailVO question = element.getQuestionDetail();
+ if (Objects.isNull(question)) {
+ ElementNumBO elementNumBO = elementNumberUtil.getElementNum(element, fileStyle, officeConfig.getElementNumStyleMap(), officeConfig.getElementIconMap());
+ String questionContent = officeConfig.getTagVO().getDivStart() + "\u9898\u76ee\u4fe1\u606f\u4e3a\u7a7a" + officeConfig.getTagVO().getDivEnd();
+ this.addRestoreInfo(titleList, contentList.size(), questionContent, null, false);
+ contentList.add(elementNumBO.getStyleElementNum() + questionContent);
+ return;
+ }
+ if (CollectionUtils.isEmpty((Collection)question.getChildList())) {
+ ElementNumBO elementNumBO = question.isSystemQuestionNumber() != false ? elementNumberUtil.getElementNum(element, fileStyle, officeConfig.getElementNumStyleMap(), officeConfig.getElementIconMap()) : new ElementNumBO().setStyleElementNum(question.getShowCustomQuestionNumber());
+ Set collectTypes = CollectQuestionEnum.getCollectTypes((QuestionEnum)QuestionEnum.SINGLE_QUESTION, (Integer)edition, (String)question.getTypeName());
+ this.addQuestionInfo(contentList, titleList, elementNumBO.getStyleElementNum(), question, collectTypes, officeConfig.getTagVO(), QuestionEnum.SINGLE_QUESTION, fileStyle, edition);
+ questionList.add(new ExportQuestionVO().setQuestion(question));
+ return;
+ }
+ String elementNum = question.isSystemQuestionNumber() != false ? "" : question.getShowCustomQuestionNumber();
+ Set collectTypes = CollectQuestionEnum.getCollectTypes((QuestionEnum)QuestionEnum.PARENT_QUESTION, (Integer)edition, (String)question.getTypeName());
+ Integer contentIndex = this.addQuestionInfo(contentList, titleList, elementNum, question, collectTypes, officeConfig.getTagVO(), QuestionEnum.PARENT_QUESTION, fileStyle, edition);
+ collectTypes = CollectQuestionEnum.getCollectTypes((QuestionEnum)QuestionEnum.CHILD_QUESTION, (Integer)edition, (String)question.getTypeName());
+ ArrayList elementNumList = new ArrayList();
+ for (int i = 0; i < question.getChildList().size(); ++i) {
+ ElementNumBO elementNumBO;
+ QuestionDetailVO child = (QuestionDetailVO)question.getChildList().get(i);
+ if (question.isSystemQuestionNumber().booleanValue()) {
+ elementNumBO = elementNumberUtil.getElementNum(element, fileStyle, officeConfig.getElementNumStyleMap(), officeConfig.getElementIconMap());
+ } else {
+ elementNumBO = new ElementNumBO().setElementNum(Integer.valueOf(i + 1));
+ String customNumber = elementNumBO.getElementNum() + ".";
+ if ((EditionEnum.ANSWER.getEdition().equals(edition) || EditionEnum.ANSWER_ONLY_ANSWER.getEdition().equals(edition)) && StringUtils.isNotBlank((CharSequence)question.getShowCustomQuestionNumber())) {
+ customNumber = question.getShowCustomQuestionNumber().trim() + "-" + customNumber;
+ }
+ elementNumBO.setStyleElementNum(customNumber);
+ }
+ this.addQuestionInfo(contentList, titleList, elementNumBO.getStyleElementNum(), child, collectTypes, officeConfig.getTagVO(), QuestionEnum.CHILD_QUESTION, null, edition);
+ elementNumList.add(elementNumBO.getElementNum());
+ }
+ this.dealQuestionNum(contentList, question, contentIndex, elementNumList);
+ questionList.add(new ExportQuestionVO().setQuestion(question));
+ }
+
+ private void dealQuestionNum(List contentList, QuestionDetailVO question, Integer contentIndex, List elementNumList) {
+ if ((Constants.QUESTION_TYPE_SET.contains(question.getTypeName()) || "\u5b8c\u5f62\u586b\u7a7a".equals(question.getTypeName())) && Objects.nonNull(contentIndex)) {
+ String content = contentList.get(contentIndex);
+ Matcher matcher = QUESTION_NUM_PATTERN.matcher(content);
+ StringBuffer sb = new StringBuffer();
+ int count = 0;
+ while (matcher.find() && count <= elementNumList.size() - 1) {
+ String newNum = " " + elementNumList.get(count++).toString() + " " + "";
+ matcher.appendReplacement(sb, newNum);
+ }
+ matcher.appendTail(sb);
+ contentList.set(contentIndex, sb.toString());
+ }
+ }
+
+ private void markQuestionImg(QuestionDetailVO question) {
+ if (Objects.nonNull(question)) {
+ this.replaceQuestionImg(question);
+ if (CollectionUtils.isNotEmpty((Collection)question.getChildList())) {
+ question.getChildList().forEach(this::replaceQuestionImg);
+ }
+ }
+ }
+
+ private void replaceQuestionImg(QuestionDetailVO question) {
+ question.setContent(this.replaceImg(question.getContent()));
+ question.setOptionA(this.replaceImg(question.getOptionA()));
+ question.setOptionB(this.replaceImg(question.getOptionB()));
+ question.setOptionC(this.replaceImg(question.getOptionC()));
+ question.setOptionD(this.replaceImg(question.getOptionD()));
+ question.setOptionE(this.replaceImg(question.getOptionE()));
+ question.setOptionF(this.replaceImg(question.getOptionF()));
+ question.setOptionG(this.replaceImg(question.getOptionG()));
+ question.setAnswer(this.replaceImg(question.getAnswer()));
+ question.setAnswerExplanation(Optional.ofNullable(question.getAnswerExplanation()).orElse(Collections.emptyList()).stream().map(this::replaceImg).collect(Collectors.toList()));
+ }
+
+ private String replaceImg(String content) {
+ if (StringUtils.isBlank((CharSequence)content)) {
+ return content;
+ }
+ return content.replace("
contentList, Integer edition, OfficeFileElementVO element, TagVO tagVO) {
+ if (!EditionEnum.ANSWER.getEdition().equals(edition) && !EditionEnum.ANSWER_ONLY_ANSWER.getEdition().equals(edition)) {
+ this.addEmptyArea(contentList, element.getEmptyLineNum(), element.getHasLine());
+ }
+ this.addTeachingRemark(contentList, edition, element, tagVO);
+ this.addPageBreak(contentList, edition, element.getHasPageBreak());
+ }
+
+ private void addEmptyArea(List contentList, Integer emptyLineNum, Boolean hasLine) {
+ if (Objects.nonNull(emptyLineNum) && emptyLineNum > 0) {
+ String tag = Boolean.TRUE.equals(hasLine) ? "
" : "
";
+ for (int i = 0; i < emptyLineNum; ++i) {
+ contentList.add(tag);
+ }
+ }
+ }
+
+ private void addTeachingRemark(List contentList, Integer edition, OfficeFileElementVO element, TagVO tagVO) {
+ if (EditionEnum.TEACHER.getEdition().equals(edition) && Boolean.TRUE.equals(element.getIsShowRemark()) && StringUtils.isNotBlank((CharSequence)element.getTeachingRemark())) {
+ contentList.add(tagVO.getTeachingRemark() + tagVO.getDivStart() + element.getTeachingRemark() + tagVO.getDivEnd());
+ }
+ }
+
+ private void addPageBreak(List contentList, Integer edition, Boolean hasPageBreak) {
+ if (!EditionEnum.STUDENT.getEdition().equals(edition) || !Boolean.TRUE.equals(hasPageBreak)) {
+ return;
+ }
+ contentList.add("");
+ }
+
+ private Integer addQuestionInfo(List contentList, List titleList, String elementNum, QuestionDetailVO question, Set collectTypes, TagVO tagVO, QuestionEnum questionEnum, OfficeFileStyleVO fileStyle, Integer edition) {
+ ArrayList questionContentList = new ArrayList();
+ Integer contentIndex = null;
+ if (collectTypes.contains(CollectQuestionEnum.CONTENT) && StringUtils.isNotBlank((CharSequence)question.getContent())) {
+ questionContentList.add(tagVO.getDivStart() + question.getContent() + tagVO.getDivEnd());
+ contentIndex = contentList.size();
+ }
+ if (collectTypes.contains(CollectQuestionEnum.ORIGINAL_TEXT) && StringUtils.isNotBlank((CharSequence)question.getOriginalText())) {
+ questionContentList.add(tagVO.getListeningText() + tagVO.getDivStart() + question.getOriginalText() + tagVO.getDivEnd());
+ }
+ if (collectTypes.contains(CollectQuestionEnum.DECIPHERMENT) && StringUtils.isNotBlank((CharSequence)question.getDecipherment())) {
+ questionContentList.add(tagVO.getDecipherment() + tagVO.getDivStart() + question.getDecipherment() + tagVO.getDivEnd());
+ }
+ if (collectTypes.contains(CollectQuestionEnum.OPTION)) {
+ this.addOption(questionContentList, question, tagVO);
+ }
+ if (collectTypes.contains(CollectQuestionEnum.EMPTY_AREA)) {
+ this.addEmptyArea(questionContentList, question.getEmptyLineNum(), question.getHasLine());
+ }
+ String answer = collectTypes.contains(CollectQuestionEnum.ANSWER) ? question.getAnswer() : "";
+ ArrayList answerExplanationList = new ArrayList();
+ if (collectTypes.contains(CollectQuestionEnum.EXPLANATION) && CollectionUtils.isNotEmpty((Collection)question.getAnswerExplanation())) {
+ question.getAnswerExplanation().stream().filter(StringUtils::isNotBlank).forEach(answerExplanationList::add);
+ }
+ String answerTag = tagVO.getAnswer();
+ if (EditionEnum.ANSWER.getEdition().equals(edition) || EditionEnum.ANSWER_ONLY_ANSWER.getEdition().equals(edition)) {
+ answerTag = " ";
+ }
+ if ((EditionEnum.ANSWER.getEdition().equals(edition) || EditionEnum.ANSWER_ONLY_ANSWER.getEdition().equals(edition)) && (ANSWER_MERGE_QUESTION_TYPE_SET_OLD.contains(question.getTypeDetailId()) || ANSWER_MERGE_QUESTION_TYPE_SET_NEW.contains(question.getLogicTypeId()) || StringUtils.isNotBlank((CharSequence)question.getDecipherment()))) {
+ String answerExplanation2 = "";
+ if (StringUtils.isNotBlank((CharSequence)answer)) {
+ answerExplanation2 = answerTag + tagVO.getDivStart() + answer + tagVO.getDivEnd();
+ }
+ if (CollectionUtils.isNotEmpty(answerExplanationList)) {
+ answerExplanation2 = answerExplanation2 + tagVO.getExplanation() + tagVO.getDivStart() + String.join((CharSequence)",", answerExplanationList) + tagVO.getDivEnd();
+ }
+ if (StringUtils.isNotBlank((CharSequence)answerExplanation2)) {
+ questionContentList.add(answerExplanation2);
+ }
+ } else {
+ if (StringUtils.isNotBlank((CharSequence)answer)) {
+ questionContentList.add(answerTag + tagVO.getDivStart() + answer + tagVO.getDivEnd());
+ }
+ if (CollectionUtils.isNotEmpty(answerExplanationList)) {
+ answerExplanationList.forEach(answerExplanation -> questionContentList.add(tagVO.getExplanation() + tagVO.getDivStart() + answerExplanation + tagVO.getDivEnd()));
+ }
+ }
+ Boolean isMergeAnswer = !(!EditionEnum.ANSWER.getEdition().equals(edition) && !EditionEnum.ANSWER_ONLY_ANSWER.getEdition().equals(edition) || !ANSWER_MERGE_QUESTION_TYPE_SET_OLD.contains(question.getTypeDetailId()) && !ANSWER_MERGE_QUESTION_TYPE_SET_NEW.contains(question.getLogicTypeId()) || !CollectionUtils.isEmpty(answerExplanationList));
+ if (CollectionUtils.isEmpty(questionContentList)) {
+ return null;
+ }
+ if (Boolean.TRUE.equals(question.getIsShowScore()) && Objects.nonNull(question.getScore()) && question.getScore().compareTo(BigDecimal.ZERO) > 0) {
+ elementNum = elementNum + "\uff08" + question.getScore().stripTrailingZeros().toPlainString() + "\u5206\uff09";
+ }
+ String firstContent = (String)questionContentList.get(0);
+ if (StringUtils.isNotEmpty((CharSequence)question.getSource()) && fileStyle != null && fileStyle.getQuestionSourceShowFlag() == 1) {
+ questionContentList.set(0, elementNum + "\uff08" + question.getSource() + "\uff09" + firstContent);
+ } else {
+ questionContentList.set(0, elementNum + firstContent);
+ }
+ if (QuestionEnum.PARENT_QUESTION.equals((Object)questionEnum)) {
+ contentList.addAll(questionContentList);
+ return contentIndex;
+ }
+ this.addRestoreInfo(titleList, contentList.size(), firstContent, question.getScore(), isMergeAnswer);
+ contentList.addAll(questionContentList);
+ return null;
+ }
+
+ private void addRestoreInfo(List titleList, int index, String restore, BigDecimal score, Boolean isMergeAnswer) {
+ titleList.get(titleList.size() - 1).getQuestionList().add(new QuestionBO().setIndex(Integer.valueOf(index)).setQuestionContent(restore).setScore(score).setIsMergeAnswer(isMergeAnswer));
+ }
+
+ private void addOption(List contentList, QuestionDetailVO question, TagVO tagVO) {
+ if (Boolean.TRUE.equals(question.getIsSubjective())) {
+ return;
+ }
+ List optionList = this.getOptionList(question, tagVO);
+ if (Objects.nonNull(question.getOptionColumn()) && question.getOptionColumn() > 1) {
+ this.addMultiColumnOptionByTab(contentList, optionList, question.getOptionColumn());
+ } else {
+ contentList.addAll(optionList);
+ }
+ }
+
+ private void addMultiColumnOptionByTab(List contentList, List optionList, Integer columnNum) {
+ if (CollectionUtils.isEmpty(optionList)) {
+ return;
+ }
+ StringBuilder optionBuilder = new StringBuilder();
+ for (int i = 0; i < optionList.size(); ++i) {
+ if (i > 0) {
+ optionBuilder.append(i % columnNum == 0 ? "
" : "");
+ }
+ optionBuilder.append(optionList.get(i));
+ }
+ contentList.add(optionBuilder.toString());
+ }
+
+ private String addMultiColumnOptionByTab(List optionList, Integer columnNum) {
+ StringBuilder optionBuilder = new StringBuilder();
+ for (int i = 0; i < optionList.size(); ++i) {
+ if (i > 0) {
+ optionBuilder.append(i % columnNum == 0 ? "
" : "");
+ }
+ String option = FileServiceImpl.removeSpaceStrOfEnd(optionList.get(i));
+ optionBuilder.append(option);
+ }
+ return optionBuilder.toString();
+ }
+
+ private List getOptionList(QuestionDetailVO question, TagVO tagVO) {
+ ArrayList optionList = new ArrayList();
+ if ("\u5224\u65ad\u9898".equals(question.getTypeDetailName())) {
+ optionList.add(tagVO.getDivStart() + "T. \u6b63\u786e" + tagVO.getDivEnd());
+ optionList.add(tagVO.getDivStart() + "F. \u9519\u8bef" + tagVO.getDivEnd());
+ return optionList;
+ }
+ if (StringUtils.isNotBlank((CharSequence)question.getOptionA())) {
+ String optionA = FileServiceImpl.removeSpaceStrOfEnd(question.getOptionA());
+ optionList.add("A. " + tagVO.getDivStart() + optionA + tagVO.getDivEnd());
+ }
+ if (StringUtils.isNotBlank((CharSequence)question.getOptionB())) {
+ String optionB = FileServiceImpl.removeSpaceStrOfEnd(question.getOptionB());
+ optionList.add("B. " + tagVO.getDivStart() + optionB + tagVO.getDivEnd());
+ }
+ if (StringUtils.isNotBlank((CharSequence)question.getOptionC())) {
+ String optionC = FileServiceImpl.removeSpaceStrOfEnd(question.getOptionC());
+ optionList.add("C. " + tagVO.getDivStart() + optionC + tagVO.getDivEnd());
+ }
+ if (StringUtils.isNotBlank((CharSequence)question.getOptionD())) {
+ String optionD = FileServiceImpl.removeSpaceStrOfEnd(question.getOptionD());
+ optionList.add("D. " + tagVO.getDivStart() + optionD + tagVO.getDivEnd());
+ }
+ if (StringUtils.isNotBlank((CharSequence)question.getOptionE())) {
+ String optionE = FileServiceImpl.removeSpaceStrOfEnd(question.getOptionE());
+ optionList.add("E. " + tagVO.getDivStart() + optionE + tagVO.getDivEnd());
+ }
+ if (StringUtils.isNotBlank((CharSequence)question.getOptionF())) {
+ String optionF = FileServiceImpl.removeSpaceStrOfEnd(question.getOptionF());
+ optionList.add("F. " + tagVO.getDivStart() + optionF + tagVO.getDivEnd());
+ }
+ if (StringUtils.isNotBlank((CharSequence)question.getOptionG())) {
+ String optionG = FileServiceImpl.removeSpaceStrOfEnd(question.getOptionG());
+ optionList.add("G. " + tagVO.getDivStart() + optionG + tagVO.getDivEnd());
+ }
+ return optionList;
+ }
+
+ private static String removeSpaceStrOfEnd(String input) {
+ if (input == null) {
+ return null;
+ }
+ String step1 = input.replaceAll("(?<=>)([^<]*?)\\s+(?=<)", "$1");
+ String step2 = step1.replaceAll("\\s+$", "");
+ return step2;
+ }
+
+ private String notNullContent(String content) {
+ return StringUtils.isBlank((CharSequence)content) ? "" : content;
+ }
+
+ private String getAttachmentCard(String attachmentCard, Map iconMap, Integer elementType, String attachmentName, String qrCodeUrl) {
+ BizAssert.isNotBlank((String)attachmentCard, (String)"\u9644\u4ef6\u5361\u7247\u6837\u5f0f\u4e3a\u7a7a");
+ BizAssert.notNull(iconMap, (String)"\u56fe\u6807\u914d\u7f6e\u4fe1\u606f\u4e3a\u7a7a");
+ ElementTypeEnum elementTypeEnum = ElementTypeEnum.get((Integer)elementType);
+ BizAssert.notNull((Object)elementTypeEnum, (String)"\u975e\u6cd5\u5143\u7d20\u7c7b\u578b");
+ qrCodeUrl = StringUtils.isBlank((CharSequence)qrCodeUrl) ? "" : qrCodeUrl;
+ attachmentName = StringUtils.isBlank((CharSequence)attachmentName) ? "\u672a\u547d\u540d" : attachmentName;
+ try {
+ String attachmentIcon = null;
+ if (ElementTypeEnum.AUDIO.getType().equals(elementType)) {
+ attachmentIcon = iconMap.get("audioIcon");
+ } else if (ElementTypeEnum.VIDEO.getType().equals(elementType)) {
+ attachmentIcon = iconMap.get("videoIcon");
+ } else if (ElementTypeEnum.GGB.getType().equals(elementType)) {
+ attachmentIcon = iconMap.get("ggbIcon");
+ } else if (ElementTypeEnum.CHEMISTRY.getType().equals(elementType)) {
+ attachmentIcon = iconMap.get("chemistryIcon");
+ } else if (ElementTypeEnum.MINDMAP.getType().equals(elementType)) {
+ attachmentIcon = iconMap.get("mindmapIcon");
+ }
+ BizAssert.isNotBlank((String)attachmentIcon, (String)("\u672a\u627e\u5230\u5143\u7d20\u3010" + elementTypeEnum.getName() + "\u3011\u56fe\u6807\uff0c\u8bf7\u8054\u7cfb\u7ba1\u7406\u5458"));
+ assert (attachmentIcon != null);
+ return attachmentCard.replace("attachmentIcon", attachmentIcon).replace("attachmentName", attachmentName).replace("qrCodeUrl", qrCodeUrl);
+ }
+ catch (BusinessException e) {
+ log.error("\u83b7\u53d6\u9644\u4ef6\u5361\u7247\u6837\u5f0f\u5f02\u5e38, attachmentCard:{}, iconMap:{}, elementType:{},attachmentName:{},qrCodeUrl:{}", new Object[]{attachmentCard, JSON.toJSONString(iconMap), elementType, attachmentName, qrCodeUrl, e});
+ throw e;
+ }
+ catch (Exception e) {
+ log.error("\u83b7\u53d6\u9644\u4ef6\u5361\u7247\u6837\u5f0f\u5f02\u5e38, attachmentCard:{}, iconMap:{}, elementType:{},attachmentName:{},qrCodeUrl:{}", new Object[]{attachmentCard, JSON.toJSONString(iconMap), elementType, attachmentName, qrCodeUrl, e});
+ throw new BusinessException("\u83b7\u53d6\u9644\u4ef6\u5361\u7247\u6837\u5f0f\u5f02\u5e38, \u8bf7\u8054\u7cfb\u7ba1\u7406\u5458");
+ }
+ }
+
+ private String downloadListenAudio(DownloadFileParam param) {
+ BizAssert.notNull((Object)param.getPdfFile(), (String)"pdf\u6587\u4ef6\u4e3a\u7a7a");
+ OfficeFileInfoVO fileInfo = (OfficeFileInfoVO)FeignUtils.parse((Result)this.officeFileServiceFeign.getFileInfo(new QueryFileParam().setFileId(param.getFileId())));
+ this.filterElementList(fileInfo, param.getEdition());
+ List questionList = this.getQuestionList(fileInfo);
+ return WordExportUtil.createOfficeFile((CreateFileBO)new CreateFileBO().setPdf(param.getPdfFile()).setFileName(fileInfo.getFileName()).setQuestionList(questionList).setDownloadListenType(param.getDownloadListenType()));
+ }
+
+ /*
+ * WARNING - Removed try catching itself - possible behaviour change.
+ */
+ private String downloadPdf(DownloadFileParam param) {
+ BizAssert.notNull((Object)param.getFileId(), (String)"\u6587\u6863id\u4e3a\u7a7a");
+ BizAssert.notNull((Object)param.getEdition(), (String)"\u4e0b\u8f7d\u7248\u672c\u4e3a\u7a7a");
+ String path = WordExportUtil.createPdf((CreatePdfParam)new CreatePdfParam().setShareCode(CodeUtil.convertToCode((long)param.getFileId())).setTemplate(String.format(this.officeFileConfig.getOfficeTemplate(), System.currentTimeMillis(), param.getFileId(), param.getEdition())));
+ assert (path != null);
+ File localFile = com.jby.common.util.FileUtil.getFile((String)path);
+ try {
+ MultipartFile file = com.jby.common.util.FileUtil.getMultipartFile((String)localFile.getName(), (File)localFile);
+ OfficeFileInfoVO fileInfo = (OfficeFileInfoVO)FeignUtils.parse((Result)this.officeFileServiceFeign.getFileInfo(new QueryFileParam().setFileId(param.getFileId())));
+ this.filterElementList(fileInfo, param.getEdition());
+ List questionList = this.getQuestionList(fileInfo);
+ String string = WordExportUtil.createOfficeFile((CreateFileBO)new CreateFileBO().setPdf(file).setFileName(fileInfo.getFileName()).setQuestionList(questionList).setDownloadListenType(param.getDownloadListenType()));
+ return string;
+ }
+ finally {
+ FileUtil.del((File)localFile);
+ }
+ }
+
+ private List getQuestionList(OfficeFileInfoVO fileInfo) {
+ return fileInfo.getElementList().stream().filter(e -> ElementTypeEnum.QUESTION.getType().equals(e.getElementType()) && Objects.nonNull(e.getQuestionDetail())).map(e -> new ExportQuestionVO().setQuestion(e.getQuestionDetail())).collect(Collectors.toList());
+ }
+
+ @Override
+ public OfficeFileDownloadScheduleVO batchDownloadOfficeFile(NodeParam rootNode) {
+ OfficeFileDownloadScheduleVO schedule = (OfficeFileDownloadScheduleVO)BeanMapping.toBean((Object)((Object)this.initDownloadSchedule(rootNode)), OfficeFileDownloadScheduleVO.class);
+ CompletableFuture.runAsync(() -> {
+ try {
+ this.asyncExecuteDownloadTask(rootNode, schedule.getId());
+ log.info("\u6279\u91cf\u4e0b\u8f7d\u5728\u7ebf\u6587\u4ef6\u5f02\u6b65\u4e3b\u7ebf\u7a0b====>\u7ed3\u675f, \u8fdb\u5ea6\u4e3b\u952eid:{}", (Object)schedule.getId());
+ }
+ catch (Exception e) {
+ log.error("\u5f02\u6b65\u4e0b\u8f7d\u4efb\u52a1\u6267\u884c\u5931\u8d25: {}", (Object)e.getMessage(), (Object)e);
+ }
+ }, (Executor)this.batchDownloadMainExecutor).exceptionally(e -> {
+ log.error("\u6279\u91cf\u4e0b\u8f7d\u5728\u7ebf\u6587\u4ef6\u5f02\u6b65\u4e3b\u4efb\u52a1\u63d0\u4ea4\u5931\u8d25: {}", (Object)e.getMessage(), e);
+ throw new BusinessException("\u6279\u91cf\u4e0b\u8f7d\u5728\u7ebf\u6587\u4ef6\u5f02\u6b65\u4e3b\u4efb\u52a1\u63d0\u4ea4\u5931\u8d25");
+ });
+ return schedule;
+ }
+
+ private OfficeFileDownloadSchedule initDownloadSchedule(NodeParam rootNode) {
+ SessionUser sessionUser = RequestUtil.getSessionUser((boolean)true);
+ OfficeFileDownloadSchedule progress = new OfficeFileDownloadSchedule();
+ progress.setCreateBy(sessionUser.getId());
+ progress.setCreateTime(LocalDateTime.now());
+ progress.setUpdateBy(sessionUser.getId());
+ progress.setUpdateTime(LocalDateTime.now());
+ progress.setFileName(rootNode.getNodeName());
+ AtomicInteger totalCount = new AtomicInteger(0);
+ this.countTotalFiles(rootNode, progress, totalCount);
+ if (this.officeFileConfig.getMaxDownloadNum() < totalCount.get()) {
+ throw new BusinessException("\u6587\u4ef6\u6570\u91cf\u8d85\u8fc7 " + this.officeFileConfig.getMaxDownloadNum() + "\u4e2a\uff0c\u65e0\u6cd5\u4e0b\u8f7d\uff0c\u8bf7\u91cd\u65b0\u9009\u62e9");
+ }
+ this.downloadScheduleService.saveOrUpdate((Object)progress);
+ return progress;
+ }
+
+ private void countTotalFiles(NodeParam rootNode, OfficeFileDownloadSchedule progress, AtomicInteger totalCount) {
+ if (rootNode.getIsFile().booleanValue()) {
+ progress.setTotalCount(totalCount.incrementAndGet());
+ } else if (CollectionUtils.isNotEmpty((Collection)rootNode.getNodeList())) {
+ for (NodeParam child : rootNode.getNodeList()) {
+ this.countTotalFiles(child, progress, totalCount);
+ }
+ }
+ }
+
+ private void asyncExecuteDownloadTask(NodeParam rootNode, Long id) {
+ OfficeFileDownloadSchedule downloadProgress = (OfficeFileDownloadSchedule)((Object)this.downloadScheduleService.getById(id));
+ ArrayList> downloadFutures = new ArrayList>();
+ try {
+ this.submitDownloadTasks(rootNode, "", downloadFutures);
+ }
+ catch (Exception e) {
+ log.error("\u4e0b\u8f7d\u4efb\u52a1\u5f02\u5e38{}", (Object)e.getMessage());
+ downloadProgress.setStatus(Integer.valueOf(DownScheduleTypeEnum.FAIL_TYPE.getType()));
+ this.officeFileDownloadScheduleMapper.updateById((Object)downloadProgress);
+ throw new BusinessException("\u4e0b\u8f7d\u4efb\u52a1\u5f02\u5e38");
+ }
+ CompletableFuture.allOf(downloadFutures.toArray(new CompletableFuture[0])).join();
+ String saveKey = AttachmentUtil.organize((NodeParam)rootNode);
+ AtomicInteger successCount = new AtomicInteger(0);
+ AtomicInteger failureCount = new AtomicInteger(0);
+ try {
+ for (CompletableFuture completableFuture : downloadFutures) {
+ try {
+ completableFuture.join();
+ downloadProgress.setSuccessCount(successCount.incrementAndGet());
+ }
+ catch (CompletionException e) {
+ log.error("Download task failed\uff1a{}", (Object)e.getMessage());
+ downloadProgress.setFailCount(failureCount.incrementAndGet());
+ }
+ }
+ String sourceKey = saveKey + "/" + rootNode.getNodeName();
+ String string = AttachmentUtil.compressToZip((String)sourceKey, (String)saveKey, (String)rootNode.getNodeName());
+ log.info("Compression completed: {}", (Object)string);
+ downloadProgress.setFileUrl(string);
+ downloadProgress.setStatus(Integer.valueOf(DownScheduleTypeEnum.SUCCESS_TYPE.getType()));
+ this.officeFileDownloadScheduleMapper.updateById((Object)downloadProgress);
+ }
+ catch (Exception e) {
+ log.error("\u538b\u7f29\u5931\u8d25\uff1a{}", (Object)e.getMessage());
+ downloadProgress.setStatus(Integer.valueOf(DownScheduleTypeEnum.FAIL_TYPE.getType()));
+ this.officeFileDownloadScheduleMapper.updateById((Object)downloadProgress);
+ throw new BusinessException("\u538b\u7f29\u5931\u8d25");
+ }
+ }
+
+ private void submitDownloadTasks(NodeParam node, String currentPath, List> downloadFutures) {
+ if (node.getIsFile().booleanValue()) {
+ CompletableFuture future = CompletableFuture.runAsync(() -> {
+ if (node.getOfficeFileId() != null && StringUtils.isBlank((CharSequence)node.getFileUrl())) {
+ DownloadFileParam param = new DownloadFileParam();
+ param.setFileId(node.getOfficeFileId());
+ param.setFileType(FileTypeEnum.WORD.getType());
+ param.setEdition(EditionEnum.TEACHER.getEdition());
+ param.setDownloadListenType(ListenEnum.COMBINE_FILE.getType());
+ try {
+ String filePath = this.downloadOfficeFile(param);
+ node.setFileUrl(filePath);
+ }
+ catch (Exception e) {
+ log.error("Download task failed for file {}: {}", new Object[]{node.getOfficeFileId(), e.getMessage(), e});
+ }
+ }
+ }, (Executor)this.batchDownloadTaskExecutor);
+ downloadFutures.add(future);
+ } else {
+ String newPath = currentPath + node.getNodeName() + "/";
+ if (CollectionUtils.isNotEmpty((Collection)node.getNodeList())) {
+ node.getNodeList().forEach(child -> this.submitDownloadTasks((NodeParam)child, newPath, downloadFutures));
+ }
+ }
+ }
+
+ public OfficeFileDownloadScheduleVO batchDownloadOfficeFile2(NodeParam rootNode) {
+ OfficeFileDownloadSchedule downloadProgress = this.initDownloadSchedule(rootNode);
+ String parentPath = this.initDownloadPath();
+ ArrayList> downloadFutures = new ArrayList>();
+ this.submitDownloadTasks(rootNode, "", downloadFutures);
+ CompletableFuture.allOf(downloadFutures.toArray(new CompletableFuture[0])).join();
+ String saveKey = AttachmentUtil.organize((NodeParam)rootNode);
+ CompletableFuture allDownloadsFuture = CompletableFuture.allOf(downloadFutures.toArray(new CompletableFuture[0]));
+ CompletionStage future = allDownloadsFuture.thenApplyAsync(v -> {
+ AtomicInteger successCount = new AtomicInteger(0);
+ AtomicInteger failureCount = new AtomicInteger(0);
+ try {
+ for (CompletableFuture downloadFuture : downloadFutures) {
+ try {
+ downloadFuture.join();
+ downloadProgress.setSuccessCount(successCount.incrementAndGet());
+ }
+ catch (CompletionException e) {
+ log.error("Download task failed", e.getCause());
+ downloadProgress.setFailCount(failureCount.incrementAndGet());
+ }
+ }
+ String sourceKey = saveKey + "/" + rootNode.getNodeName();
+ String zipPath = AttachmentUtil.compressToZip((String)sourceKey, (String)saveKey, (String)rootNode.getNodeName());
+ log.info("Compression completed: {}", (Object)zipPath);
+ downloadProgress.setFileUrl(zipPath);
+ downloadProgress.setStatus(Integer.valueOf(DownScheduleTypeEnum.SUCCESS_TYPE.getType()));
+ this.officeFileDownloadScheduleMapper.updateById((Object)downloadProgress);
+ return downloadProgress;
+ }
+ catch (Exception e) {
+ log.error("Compression failed", (Throwable)e);
+ downloadProgress.setStatus(Integer.valueOf(DownScheduleTypeEnum.FAIL_TYPE.getType()));
+ this.officeFileDownloadScheduleMapper.updateById((Object)downloadProgress);
+ return null;
+ }
+ }, (Executor)this.batchDownloadTaskExecutor);
+ OfficeFileDownloadSchedule join = (OfficeFileDownloadSchedule)((Object)((CompletableFuture)future).join());
+ return (OfficeFileDownloadScheduleVO)BeanMapping.toBean((Object)((Object)join), OfficeFileDownloadScheduleVO.class, (s, t) -> t.setId(s.getId()));
+ }
+
+ private String initDownloadPath() {
+ return SpringContextHolder.getActiveProfile() + "/" + AttachmentModuleEnum.OFFICE_FILE.getModule() + "/" + "organize" + "/" + LocalDateTime.now().format(DateTimeFormatter.BASIC_ISO_DATE) + "/" + UniqueUtil.getUuid();
+ }
+
+ @Override
+ public OfficeFileParseRecordVO getOfficeFileParseRecordByMd5(String md5) {
+ List officeFileParseRecordList = this.officeFileParseRecordService.list((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery().eq(OfficeFileParseRecord::getFileMd5, (Object)md5)).orderByDesc(CommonBean::getCreateTime));
+ if (CollectionUtils.isNotEmpty((Collection)officeFileParseRecordList)) {
+ return (OfficeFileParseRecordVO)BeanMapping.toBean(officeFileParseRecordList.get(0), OfficeFileParseRecordVO.class);
+ }
+ return null;
+ }
+
+ @Override
+ public void saveOfficeFileParseRecord(OfficeFileParseRecordParam param) {
+ OfficeFileParseRecord bean = (OfficeFileParseRecord)((Object)BeanMapping.toBean((Object)param, OfficeFileParseRecord.class));
+ this.officeFileParseRecordService.save((Object)bean);
+ if (Objects.nonNull(bean.getFileId()) && bean.getFileId() > 0L && StringUtils.isNotBlank((CharSequence)bean.getFileUrl())) {
+ UpdateFileParam updateFileParam = new UpdateFileParam();
+ updateFileParam.setFileUrl(bean.getFileUrl());
+ updateFileParam.setFileId(bean.getFileId());
+ this.officeFileServiceFeign.updateFileUrl(updateFileParam);
+ }
+ }
+
+ @Override
+ public List queryFileUrlByFileIds(OfficeFileParseRecordParam param) {
+ List officeFileParseRecordList = this.officeFileParseRecordService.list((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery().in(OfficeFileParseRecord::getFileId, (Collection)param.getFileIds())).orderByDesc(CommonBean::getCreateTime));
+ if (CollectionUtils.isEmpty((Collection)officeFileParseRecordList)) {
+ return Collections.emptyList();
+ }
+ return officeFileParseRecordList.stream().map(record -> (OfficeFileParseRecordVO)BeanMapping.toBean((Object)record, OfficeFileParseRecordVO.class)).collect(Collectors.toList());
+ }
+
+ private void addOption(QuestionDetailVO question, List contentList, String questionNumber) {
+ if (Boolean.FALSE.equals(question.getIsSubjective()) && CollectionUtils.isNotEmpty((Collection)question.getOptionsList())) {
+ AtomicInteger counter = new AtomicInteger(0);
+ List optionList = question.getOptionsList().stream().filter(StringUtils::isNotBlank).map(m -> (char)(65 + counter.getAndIncrement()) + "." + m.replace("", "").replace("
", "")).collect(Collectors.toList());
+ if (Objects.nonNull(question.getOptionColumn()) && question.getOptionColumn() > 1) {
+ contentList.add(questionNumber + this.addMultiColumnOptionByTab(optionList, question.getOptionColumn()));
+ } else {
+ for (int i = 0; i < optionList.size(); ++i) {
+ if (i == 0 && Objects.nonNull(question.getQuestionNumber())) {
+ contentList.add(questionNumber + optionList.get(i));
+ continue;
+ }
+ contentList.add((String)optionList.get(i));
+ }
+ }
+ }
+ }
+
+ private void dealCombination(QuestionDetailVO question, Integer edition, TagVO tagVO, List contentList, OfficeFileStyleVO fileStyle) {
+ String allExplation;
+ boolean isAnswerEdition = EditionEnum.ANSWER.getEdition().equals(edition) || EditionEnum.ANSWER_ONLY_ANSWER.getEdition().equals(edition);
+ String string = allExplation = CollectionUtils.isEmpty((Collection)question.getAnswerExplanation()) ? "" : (String)question.getAnswerExplanation().get(0);
+ if (!isAnswerEdition) {
+ if (EditionEnum.TEACHER.getEdition().equals(edition)) {
+ this.addQuestionInfo(edition, question, tagVO, contentList, 1);
+ }
+ String contentPrefix1 = this.getContentPrefix(question, fileStyle);
+ contentList.add(contentPrefix1 + tagVO.getDivStart() + question.getContent() + tagVO.getDivEnd());
+ if (CollectionUtils.isNotEmpty((Collection)question.getChildList())) {
+ question.getChildList().forEach(two -> {
+ String contentPrefix2 = this.getContentPrefix((QuestionDetailVO)two, fileStyle);
+ contentList.add(contentPrefix2 + tagVO.getDivStart() + two.getContent() + tagVO.getDivEnd());
+ this.addOption((QuestionDetailVO)two, contentList, "");
+ if (CollectionUtils.isNotEmpty((Collection)two.getChildList())) {
+ two.getChildList().forEach(three -> {
+ if (LogicTypeEnum.MULTIPLE_CHOOSE_MULTIPLE.getLogicTypeId().equals(three.getLogicTypeId())) {
+ return;
+ }
+ String contentPrefix3 = this.getContentPrefix((QuestionDetailVO)three, fileStyle);
+ contentList.add(contentPrefix3 + tagVO.getDivStart() + three.getContent() + tagVO.getDivEnd());
+ this.addOption((QuestionDetailVO)three, contentList, "");
+ });
+ }
+ });
+ }
+ if (EditionEnum.TEACHER.getEdition().equals(edition)) {
+ HashMap questionMap = new HashMap();
+ AtomicBoolean lastMerger = new AtomicBoolean(false);
+ if (CollectionUtils.isNotEmpty((Collection)question.getChildList())) {
+ ArrayList twoAnswerList = new ArrayList();
+ question.getChildList().forEach(two -> {
+ questionMap.put(two.getQuestionId(), two);
+ String twoAnswer = two.getAnswer();
+ if (StringUtils.isNotBlank((CharSequence)twoAnswer) && !LogicTypeEnum.MULTIPLE_CHOOSE_MULTIPLE.getLogicTypeId().equals(two.getLogicTypeId())) {
+ if (CollectionUtils.isEmpty((Collection)twoAnswerList)) {
+ twoAnswerList.add(tagVO.getAnswer() + tagVO.getDivStart() + FileServiceImpl.joinQuestionNum(two.getShowQuestionNumber(), twoAnswer) + tagVO.getDivEnd());
+ } else if (lastMerger.get() || LogicTypeEnum.RESPONSE.getLogicTypeId().equals(two.getLogicTypeId()) || LogicTypeEnum.COMBINATION.getLogicTypeId().equals(two.getLogicTypeId())) {
+ twoAnswerList.add(tagVO.getDivStart() + FileServiceImpl.joinQuestionNum(two.getShowQuestionNumber(), twoAnswer) + tagVO.getDivEnd());
+ } else {
+ twoAnswerList.set(twoAnswerList.size() - 1, (String)twoAnswerList.get(twoAnswerList.size() - 1) + " " + tagVO.getDivStart() + FileServiceImpl.joinQuestionNum(two.getShowQuestionNumber(), twoAnswer) + tagVO.getDivEnd());
+ }
+ lastMerger.set(LogicTypeEnum.RESPONSE.getLogicTypeId().equals(two.getLogicTypeId()) || LogicTypeEnum.COMBINATION.getLogicTypeId().equals(two.getLogicTypeId()));
+ }
+ if (CollectionUtils.isNotEmpty((Collection)two.getChildList())) {
+ ArrayList threeAnswerList = Lists.newArrayList();
+ two.getChildList().forEach(three -> {
+ String threeAnswer = three.getAnswer();
+ if (StringUtils.isNotBlank((CharSequence)threeAnswer)) {
+ if (CollectionUtils.isEmpty((Collection)threeAnswerList)) {
+ threeAnswerList.add(((QuestionDetailVO)questionMap.get(three.getParentId())).getShowQuestionNumber() + tagVO.getDivStart() + FileServiceImpl.joinQuestionNum(three.getShowQuestionNumber(), threeAnswer) + tagVO.getDivEnd());
+ if (CollectionUtils.isEmpty((Collection)twoAnswerList)) {
+ threeAnswerList.set(0, tagVO.getAnswer() + (String)threeAnswerList.get(0));
+ }
+ } else if (lastMerger.get() || LogicTypeEnum.RESPONSE.getLogicTypeId().equals(three.getLogicTypeId())) {
+ threeAnswerList.add(tagVO.getDivStart() + FileServiceImpl.joinQuestionNum(three.getShowQuestionNumber(), threeAnswer) + tagVO.getDivEnd());
+ } else {
+ threeAnswerList.set(threeAnswerList.size() - 1, (String)threeAnswerList.get(threeAnswerList.size() - 1) + " " + tagVO.getDivStart() + FileServiceImpl.joinQuestionNum(three.getShowQuestionNumber(), threeAnswer) + tagVO.getDivEnd());
+ }
+ lastMerger.set(LogicTypeEnum.RESPONSE.getLogicTypeId().equals(two.getLogicTypeId()));
+ }
+ });
+ if (CollectionUtils.isNotEmpty((Collection)threeAnswerList)) {
+ twoAnswerList.addAll(threeAnswerList);
+ }
+ }
+ });
+ if (CollectionUtils.isNotEmpty(twoAnswerList)) {
+ contentList.addAll(twoAnswerList.stream().map(m -> FileServiceImpl.checkContentStyle(m) ? m.replace("", "").replace("
", "") : m).collect(Collectors.toList()));
+ }
+ }
+ if (CollectionUtils.isNotEmpty((Collection)question.getChildList())) {
+ ArrayList twoExplanationList = new ArrayList();
+ question.getChildList().forEach(two -> {
+ if (CollectionUtils.isNotEmpty((Collection)two.getAnswerExplanation()) && StringUtils.isNotBlank((CharSequence)((CharSequence)two.getAnswerExplanation().get(0)))) {
+ if (CollectionUtils.isEmpty((Collection)twoExplanationList)) {
+ twoExplanationList.add(tagVO.getExplanation() + tagVO.getDivStart() + allExplation + FileServiceImpl.joinQuestionNum(two.getShowQuestionNumber(), (String)two.getAnswerExplanation().get(0)) + tagVO.getDivEnd());
+ } else {
+ twoExplanationList.add(tagVO.getDivStart() + FileServiceImpl.joinQuestionNum(two.getShowQuestionNumber(), (String)two.getAnswerExplanation().get(0)) + tagVO.getDivEnd());
+ }
+ }
+ if (CollectionUtils.isNotEmpty((Collection)two.getChildList())) {
+ ArrayList threeExplanationList = new ArrayList();
+ two.getChildList().forEach(three -> {
+ if (CollectionUtils.isNotEmpty((Collection)three.getAnswerExplanation()) && StringUtils.isNotBlank((CharSequence)((CharSequence)three.getAnswerExplanation().get(0)))) {
+ if (CollectionUtils.isEmpty((Collection)threeExplanationList)) {
+ threeExplanationList.add(((QuestionDetailVO)questionMap.get(three.getParentId())).getShowQuestionNumber() + tagVO.getDivStart() + FileServiceImpl.joinQuestionNum(three.getShowQuestionNumber(), (String)three.getAnswerExplanation().get(0)) + tagVO.getDivEnd());
+ if (CollectionUtils.isEmpty((Collection)twoExplanationList)) {
+ threeExplanationList.set(0, tagVO.getExplanation() + allExplation + (String)threeExplanationList.get(0));
+ }
+ } else {
+ threeExplanationList.add(tagVO.getDivStart() + FileServiceImpl.joinQuestionNum(three.getShowQuestionNumber(), (String)three.getAnswerExplanation().get(0)) + tagVO.getDivEnd());
+ }
+ }
+ });
+ if (CollectionUtils.isNotEmpty(threeExplanationList)) {
+ twoExplanationList.addAll(threeExplanationList);
+ }
+ }
+ });
+ if (CollectionUtils.isNotEmpty(twoExplanationList)) {
+ contentList.addAll(twoExplanationList.stream().map(m -> FileServiceImpl.checkContentStyle(m) ? m.replace("", "").replace("
", "") : m).collect(Collectors.toList()));
+ }
+ this.addQuestionInfo(edition, question, tagVO, contentList, 2);
+ }
+ }
+ } else {
+ if (EditionEnum.ANSWER.getEdition().equals(edition)) {
+ this.addQuestionInfo(edition, question, tagVO, contentList, 1);
+ if (StringUtils.isNotBlank((CharSequence)allExplation)) {
+ contentList.add(tagVO.getDivStart() + allExplation + tagVO.getDivEnd());
+ }
+ }
+ HashMap questionMap = new HashMap();
+ questionMap.put(question.getQuestionId(), question);
+ if (CollectionUtils.isNotEmpty((Collection)question.getChildList())) {
+ ArrayList twoAnswerExplanationList = new ArrayList();
+ AtomicInteger index = new AtomicInteger(0);
+ question.getChildList().forEach(two -> {
+ FileServiceImpl.dealQuestionAnswerExplationStyle(two);
+ questionMap.put(two.getQuestionId(), (QuestionDetailVO)two);
+ String twoAnswer = two.getAnswer();
+ String twoTmp = "";
+ if (StringUtils.isNotBlank((CharSequence)twoAnswer) && !LogicTypeEnum.MULTIPLE_CHOOSE_MULTIPLE.getLogicTypeId().equals(two.getLogicTypeId())) {
+ twoTmp = twoTmp + tagVO.getDivStart() + FileServiceImpl.joinQuestionNum(two.getShowQuestionNumber(), twoAnswer) + tagVO.getDivEnd();
+ }
+ if (EditionEnum.ANSWER.getEdition().equals(edition) && CollectionUtils.isNotEmpty((Collection)two.getAnswerExplanation()) && StringUtils.isNotBlank((CharSequence)((CharSequence)two.getAnswerExplanation().get(0)))) {
+ twoTmp = LogicTypeEnum.MULTIPLE_CHOOSE_MULTIPLE.getLogicTypeId().equals(two.getLogicTypeId()) ? twoTmp + tagVO.getDivStart() + (String)two.getAnswerExplanation().get(0) + tagVO.getDivEnd() : (LogicTypeEnum.RESPONSE.getLogicTypeId().equals(two.getLogicTypeId()) ? twoTmp + "
" + tagVO.getExplanation() + tagVO.getDivStart() + (String)two.getAnswerExplanation().get(0) + tagVO.getDivEnd() : twoTmp + tagVO.getExplanation() + tagVO.getDivStart() + (String)two.getAnswerExplanation().get(0) + tagVO.getDivEnd());
+ twoTmp = twoTmp + "###\u3010\u4e0d\u5408\u5e76\u3011###";
+ }
+ if (StringUtils.isNotBlank((CharSequence)twoTmp)) {
+ if (!twoTmp.contains(tagVO.getExplanation()) && (LogicTypeEnum.RESPONSE.getLogicTypeId().equals(two.getLogicTypeId()) || LogicTypeEnum.COMBINATION.getLogicTypeId().equals(two.getLogicTypeId()))) {
+ twoAnswerExplanationList.add(twoTmp + "###\u3010\u4e0d\u5408\u5e76\u3011###");
+ } else {
+ twoAnswerExplanationList.add(twoTmp);
+ }
+ }
+ if (CollectionUtils.isNotEmpty((Collection)two.getChildList())) {
+ ArrayList threeAnswerExplanationList = new ArrayList();
+ two.getChildList().forEach(three -> {
+ FileServiceImpl.dealQuestionAnswerExplationStyle(three);
+ String threeAnswer = three.getAnswer();
+ String threeTmp = "";
+ if (StringUtils.isNotBlank((CharSequence)threeAnswer)) {
+ threeTmp = threeTmp + tagVO.getDivStart() + FileServiceImpl.joinQuestionNum(three.getShowQuestionNumber(), threeAnswer) + tagVO.getDivEnd();
+ }
+ if (EditionEnum.ANSWER.getEdition().equals(edition) && CollectionUtils.isNotEmpty((Collection)three.getAnswerExplanation()) && StringUtils.isNotBlank((CharSequence)((CharSequence)three.getAnswerExplanation().get(0)))) {
+ threeTmp = threeTmp + tagVO.getExplanation() + tagVO.getDivStart() + (String)three.getAnswerExplanation().get(0) + tagVO.getDivEnd() + "###\u3010\u4e0d\u5408\u5e76\u3011###";
+ }
+ if (StringUtils.isNotBlank((CharSequence)threeTmp)) {
+ if (CollectionUtils.isEmpty((Collection)threeAnswerExplanationList)) {
+ threeTmp = ((QuestionDetailVO)questionMap.get(three.getParentId())).getShowQuestionNumber() + threeTmp;
+ }
+ if (!threeTmp.contains(tagVO.getExplanation()) && LogicTypeEnum.RESPONSE.getLogicTypeId().equals(three.getLogicTypeId())) {
+ threeAnswerExplanationList.add(threeTmp + "###\u3010\u4e0d\u5408\u5e76\u3011###");
+ } else {
+ threeAnswerExplanationList.add(threeTmp);
+ }
+ }
+ });
+ if (CollectionUtils.isNotEmpty(threeAnswerExplanationList)) {
+ twoAnswerExplanationList.addAll(threeAnswerExplanationList);
+ }
+ }
+ if (index.getAndIncrement() == 0 && CollectionUtils.isNotEmpty((Collection)twoAnswerExplanationList)) {
+ String content = (String)twoAnswerExplanationList.get(0);
+ String newContent = question.getShowQuestionNumber() + content;
+ twoAnswerExplanationList.set(0, newContent);
+ }
+ });
+ if (CollectionUtils.isNotEmpty(twoAnswerExplanationList)) {
+ contentList.addAll(twoAnswerExplanationList);
+ }
+ }
+ if (EditionEnum.ANSWER.getEdition().equals(edition)) {
+ this.addQuestionInfo(edition, question, tagVO, contentList, 2);
+ }
+ }
+ }
+
+ private void dealBlank(QuestionDetailVO question, Integer edition, TagVO tagVO, List contentList, OfficeFileStyleVO fileStyle) {
+ boolean isAnswerEdition;
+ boolean bl = isAnswerEdition = EditionEnum.ANSWER.getEdition().equals(edition) || EditionEnum.ANSWER_ONLY_ANSWER.getEdition().equals(edition);
+ if (!isAnswerEdition) {
+ if (EditionEnum.TEACHER.getEdition().equals(edition)) {
+ this.addQuestionInfo(edition, question, tagVO, contentList, 1);
+ }
+ String contentPrefix = this.getContentPrefix(question, fileStyle);
+ String questionStem = contentPrefix + tagVO.getDivStart() + question.getContent() + tagVO.getDivEnd();
+ List numList = question.getChildList().stream().map(QuestionDetailVO::getShowQuestionNumber).collect(Collectors.toList());
+ Document parse = Jsoup.parseBodyFragment((String)questionStem);
+ parse.outputSettings().prettyPrint(false).indentAmount(0);
+ Elements numberSpans = parse.select("span.tinymce-horizontal-number, span.tinymce-line-number");
+ for (int i = 0; i < numberSpans.size(); ++i) {
+ Element span = (Element)numberSpans.get(i);
+ span.html(span.html().replaceAll("\\d+\\.?", (String)numList.get(i)).replace(" ", " "));
+ }
+ contentList.add(parse.body().html());
+ if (EditionEnum.TEACHER.getEdition().equals(edition)) {
+ String answer = question.getChildList().stream().filter(f -> StringUtils.isNotBlank((CharSequence)f.getAnswer())).map(m -> FileServiceImpl.joinQuestionNum2(m.getShowQuestionNumber(), m.getAnswer())).collect(Collectors.joining(" "));
+ if (StringUtils.isNotBlank((CharSequence)answer)) {
+ contentList.add(tagVO.getAnswer() + tagVO.getDivStart() + (FileServiceImpl.checkContentStyle(answer) ? answer.replace("", "").replace("
", "") : answer) + tagVO.getDivEnd());
+ }
+ ArrayList answerExplanation = new ArrayList();
+ if (CollectionUtils.isNotEmpty((Collection)question.getAnswerExplanation()) && StringUtils.isNotBlank((CharSequence)((CharSequence)question.getAnswerExplanation().get(0)))) {
+ answerExplanation.add(tagVO.getDivStart() + (String)question.getAnswerExplanation().get(0) + tagVO.getDivEnd());
+ }
+ answerExplanation.addAll(question.getChildList().stream().filter(f -> CollectionUtils.isNotEmpty((Collection)f.getAnswerExplanation()) && StringUtils.isNotBlank((CharSequence)((CharSequence)f.getAnswerExplanation().get(0)))).map(m -> FileServiceImpl.joinQuestionNum(m.getShowQuestionNumber(), (String)m.getAnswerExplanation().get(0))).collect(Collectors.toList()));
+ if (CollectionUtils.isNotEmpty(answerExplanation)) {
+ for (int i = 0; i < answerExplanation.size(); ++i) {
+ if (i == 0) {
+ contentList.add(tagVO.getExplanation() + tagVO.getDivStart() + (FileServiceImpl.checkContentStyle((String)answerExplanation.get(i)) ? ((String)answerExplanation.get(i)).replace("", "").replace("
", "") : (String)answerExplanation.get(i)) + tagVO.getDivEnd());
+ continue;
+ }
+ contentList.add(tagVO.getDivStart() + (FileServiceImpl.checkContentStyle((String)answerExplanation.get(i)) ? ((String)answerExplanation.get(i)).replace("", "").replace("
", "") : (String)answerExplanation.get(i)) + tagVO.getDivEnd());
+ }
+ }
+ this.addQuestionInfo(edition, question, tagVO, contentList, 2);
+ }
+ } else {
+ if (EditionEnum.ANSWER.getEdition().equals(edition)) {
+ this.addQuestionInfo(edition, question, tagVO, contentList, 1);
+ }
+ ArrayList answerExplanationList = new ArrayList();
+ if (EditionEnum.ANSWER.getEdition().equals(edition) && CollectionUtils.isNotEmpty((Collection)question.getAnswerExplanation()) && StringUtils.isNotBlank((CharSequence)((CharSequence)question.getAnswerExplanation().get(0)))) {
+ answerExplanationList.add(tagVO.getDivStart() + (String)question.getAnswerExplanation().get(0) + tagVO.getDivEnd());
+ }
+ if (EditionEnum.ANSWER.getEdition().equals(edition)) {
+ answerExplanationList.addAll(question.getChildList().stream().map(m -> {
+ String tmp = "";
+ if (StringUtils.isNotBlank((CharSequence)m.getAnswer())) {
+ tmp = tmp + FileServiceImpl.joinQuestionNum(m.getShowQuestionNumber(), m.getAnswer());
+ }
+ if (EditionEnum.ANSWER.getEdition().equals(edition) && CollectionUtils.isNotEmpty((Collection)m.getAnswerExplanation()) && StringUtils.isNotBlank((CharSequence)((CharSequence)m.getAnswerExplanation().get(0)))) {
+ tmp = tmp + tagVO.getExplanation() + tagVO.getDivStart() + (String)m.getAnswerExplanation().get(0) + tagVO.getDivEnd() + "###\u3010\u4e0d\u5408\u5e76\u3011###";
+ }
+ return tmp;
+ }).collect(Collectors.toList()));
+ } else {
+ String answer = question.getChildList().stream().filter(f -> StringUtils.isNotBlank((CharSequence)f.getAnswer())).map(m -> FileServiceImpl.joinQuestionNum2(m.getShowQuestionNumber(), m.getAnswer())).collect(Collectors.joining(" "));
+ answerExplanationList.add(answer);
+ }
+ if (CollectionUtils.isNotEmpty(answerExplanationList)) {
+ contentList.addAll(answerExplanationList.stream().map(m -> FileServiceImpl.checkContentStyle(m) ? m.replace("", "").replace("
", "") : m).collect(Collectors.toList()));
+ }
+ if (EditionEnum.ANSWER.getEdition().equals(edition)) {
+ this.addQuestionInfo(edition, question, tagVO, contentList, 2);
+ }
+ }
+ }
+
+ private void dealCompletion(QuestionDetailVO question, Integer edition, TagVO tagVO, List contentList, OfficeFileStyleVO fileStyle) {
+ boolean isAnswerEdition;
+ boolean bl = isAnswerEdition = EditionEnum.ANSWER.getEdition().equals(edition) || EditionEnum.ANSWER_ONLY_ANSWER.getEdition().equals(edition);
+ if (!isAnswerEdition) {
+ if (EditionEnum.TEACHER.getEdition().equals(edition)) {
+ this.addQuestionInfo(edition, question, tagVO, contentList, 1);
+ }
+ String contentPrefix = this.getContentPrefix(question, fileStyle);
+ String questionStem = contentPrefix + tagVO.getDivStart() + question.getContent() + tagVO.getDivEnd();
+ List numList = question.getChildList().stream().map(QuestionDetailVO::getQuestionNumber).collect(Collectors.toList());
+ Document parse = Jsoup.parseBodyFragment((String)questionStem);
+ parse.outputSettings().prettyPrint(false).indentAmount(0);
+ Elements numberSpans = parse.select("span.tinymce-horizontal-number, span.tinymce-line-number");
+ for (int i = 0; i < numberSpans.size(); ++i) {
+ Element span = (Element)numberSpans.get(i);
+ span.html(span.html().replaceAll("\\d+\\.?", (String)numList.get(i)).replace(" ", " "));
+ }
+ contentList.add(parse.body().html());
+ question.getChildList().forEach(f -> this.addOption((QuestionDetailVO)f, contentList, f.getShowQuestionNumber()));
+ if (EditionEnum.TEACHER.getEdition().equals(edition)) {
+ String answer = question.getChildList().stream().filter(f -> StringUtils.isNotBlank((CharSequence)f.getAnswer())).map(m -> FileServiceImpl.joinQuestionNum2(m.getShowQuestionNumber(), m.getAnswer())).collect(Collectors.joining(" "));
+ if (StringUtils.isNotBlank((CharSequence)answer)) {
+ contentList.add(tagVO.getAnswer() + tagVO.getDivStart() + (FileServiceImpl.checkContentStyle(answer) ? answer.replace("", "").replace("
", "") : answer) + tagVO.getDivEnd());
+ }
+ ArrayList answerExplanation = new ArrayList();
+ if (CollectionUtils.isNotEmpty((Collection)question.getAnswerExplanation()) && StringUtils.isNotBlank((CharSequence)((CharSequence)question.getAnswerExplanation().get(0)))) {
+ answerExplanation.add(tagVO.getDivStart() + (String)question.getAnswerExplanation().get(0) + tagVO.getDivEnd());
+ }
+ answerExplanation.addAll(question.getChildList().stream().filter(f -> CollectionUtils.isNotEmpty((Collection)f.getAnswerExplanation()) && StringUtils.isNotBlank((CharSequence)((CharSequence)f.getAnswerExplanation().get(0)))).map(m -> FileServiceImpl.joinQuestionNum(m.getShowQuestionNumber(), (String)m.getAnswerExplanation().get(0))).collect(Collectors.toList()));
+ if (CollectionUtils.isNotEmpty(answerExplanation)) {
+ for (int i = 0; i < answerExplanation.size(); ++i) {
+ if (i == 0) {
+ contentList.add(tagVO.getExplanation() + tagVO.getDivStart() + (FileServiceImpl.checkContentStyle((String)answerExplanation.get(i)) ? ((String)answerExplanation.get(i)).replace("", "").replace("
", "") : (String)answerExplanation.get(i)) + tagVO.getDivEnd());
+ continue;
+ }
+ contentList.add(tagVO.getDivStart() + (FileServiceImpl.checkContentStyle((String)answerExplanation.get(i)) ? ((String)answerExplanation.get(i)).replace("", "").replace("
", "") : (String)answerExplanation.get(i)) + tagVO.getDivEnd());
+ }
+ }
+ this.addQuestionInfo(edition, question, tagVO, contentList, 2);
+ }
+ } else {
+ if (EditionEnum.ANSWER.getEdition().equals(edition)) {
+ this.addQuestionInfo(edition, question, tagVO, contentList, 1);
+ }
+ ArrayList answerExplanationList = new ArrayList();
+ if (EditionEnum.ANSWER.getEdition().equals(edition) && CollectionUtils.isNotEmpty((Collection)question.getAnswerExplanation()) && StringUtils.isNotBlank((CharSequence)((CharSequence)question.getAnswerExplanation().get(0)))) {
+ answerExplanationList.add(tagVO.getDivStart() + (String)question.getAnswerExplanation().get(0) + tagVO.getDivEnd());
+ }
+ if (EditionEnum.ANSWER.getEdition().equals(edition)) {
+ answerExplanationList.addAll(question.getChildList().stream().map(m -> {
+ String tmp = "";
+ if (StringUtils.isNotBlank((CharSequence)m.getAnswer())) {
+ tmp = tmp + FileServiceImpl.joinQuestionNum(m.getShowQuestionNumber(), m.getAnswer());
+ }
+ if (EditionEnum.ANSWER.getEdition().equals(edition) && CollectionUtils.isNotEmpty((Collection)m.getAnswerExplanation()) && StringUtils.isNotBlank((CharSequence)((CharSequence)m.getAnswerExplanation().get(0)))) {
+ tmp = tmp + tagVO.getExplanation() + tagVO.getDivStart() + (String)m.getAnswerExplanation().get(0) + tagVO.getDivEnd() + "###\u3010\u4e0d\u5408\u5e76\u3011###";
+ }
+ return tmp;
+ }).collect(Collectors.toList()));
+ } else {
+ String answer = question.getChildList().stream().filter(f -> StringUtils.isNotBlank((CharSequence)f.getAnswer())).map(m -> FileServiceImpl.joinQuestionNum2(m.getShowQuestionNumber(), m.getAnswer())).collect(Collectors.joining(" "));
+ answerExplanationList.add(answer);
+ }
+ if (CollectionUtils.isNotEmpty(answerExplanationList)) {
+ contentList.addAll(answerExplanationList.stream().map(m -> FileServiceImpl.checkContentStyle(m) ? m.replace("", "").replace("
", "") : m).collect(Collectors.toList()));
+ }
+ if (EditionEnum.ANSWER.getEdition().equals(edition)) {
+ this.addQuestionInfo(edition, question, tagVO, contentList, 2);
+ }
+ }
+ }
+
+ private void dealMultipleChooseMultiple(QuestionDetailVO question, Integer edition, TagVO tagVO, List contentList, OfficeFileStyleVO fileStyle) {
+ boolean isAnswerEdition;
+ boolean bl = isAnswerEdition = EditionEnum.ANSWER.getEdition().equals(edition) || EditionEnum.ANSWER_ONLY_ANSWER.getEdition().equals(edition);
+ if (!isAnswerEdition) {
+ if (EditionEnum.TEACHER.getEdition().equals(edition)) {
+ this.addQuestionInfo(edition, question, tagVO, contentList, 1);
+ }
+ String contentPrefix = this.getContentPrefix(question, fileStyle);
+ String questionStem = contentPrefix + tagVO.getDivStart() + question.getContent() + tagVO.getDivEnd();
+ List numList = question.getChildList().stream().map(QuestionDetailVO::getQuestionNumber).collect(Collectors.toList());
+ Document parse = Jsoup.parseBodyFragment((String)questionStem);
+ parse.outputSettings().prettyPrint(false).indentAmount(0);
+ Elements numberSpans = parse.select("span.tinymce-horizontal-number, span.tinymce-line-number");
+ for (int i = 0; i < numberSpans.size(); ++i) {
+ Element span = (Element)numberSpans.get(i);
+ span.html(span.html().replaceAll("\\d+\\.?", (String)numList.get(i)).replace(" ", " "));
+ }
+ contentList.add(parse.body().html());
+ this.addOption(question, contentList, "");
+ if (EditionEnum.TEACHER.getEdition().equals(edition)) {
+ String answer = question.getChildList().stream().filter(f -> StringUtils.isNotBlank((CharSequence)f.getAnswer())).map(m -> FileServiceImpl.joinQuestionNum2(m.getShowQuestionNumber(), m.getAnswer())).collect(Collectors.joining(" "));
+ if (StringUtils.isNotBlank((CharSequence)answer)) {
+ contentList.add(tagVO.getAnswer() + tagVO.getDivStart() + (FileServiceImpl.checkContentStyle(answer) ? answer.replace("", "").replace("
", "") : answer) + tagVO.getDivEnd());
+ }
+ ArrayList answerExplanation = new ArrayList();
+ if (CollectionUtils.isNotEmpty((Collection)question.getAnswerExplanation()) && StringUtils.isNotBlank((CharSequence)((CharSequence)question.getAnswerExplanation().get(0)))) {
+ answerExplanation.add(tagVO.getDivStart() + (String)question.getAnswerExplanation().get(0) + tagVO.getDivEnd());
+ }
+ answerExplanation.addAll(question.getChildList().stream().filter(f -> CollectionUtils.isNotEmpty((Collection)f.getAnswerExplanation()) && StringUtils.isNotBlank((CharSequence)((CharSequence)f.getAnswerExplanation().get(0)))).map(m -> FileServiceImpl.joinQuestionNum(m.getShowQuestionNumber(), (String)m.getAnswerExplanation().get(0))).collect(Collectors.toList()));
+ if (CollectionUtils.isNotEmpty(answerExplanation)) {
+ for (int i = 0; i < answerExplanation.size(); ++i) {
+ if (i == 0) {
+ contentList.add(tagVO.getExplanation() + tagVO.getDivStart() + (FileServiceImpl.checkContentStyle((String)answerExplanation.get(i)) ? ((String)answerExplanation.get(i)).replace("", "").replace("
", "") : (String)answerExplanation.get(i)) + tagVO.getDivEnd());
+ continue;
+ }
+ contentList.add(tagVO.getDivStart() + (FileServiceImpl.checkContentStyle((String)answerExplanation.get(i)) ? ((String)answerExplanation.get(i)).replace("", "").replace("
", "") : (String)answerExplanation.get(i)) + tagVO.getDivEnd());
+ }
+ }
+ this.addQuestionInfo(edition, question, tagVO, contentList, 2);
+ }
+ } else {
+ if (EditionEnum.ANSWER.getEdition().equals(edition)) {
+ this.addQuestionInfo(edition, question, tagVO, contentList, 1);
+ }
+ ArrayList answerExplanationList = new ArrayList();
+ if (EditionEnum.ANSWER.getEdition().equals(edition) && CollectionUtils.isNotEmpty((Collection)question.getAnswerExplanation()) && StringUtils.isNotBlank((CharSequence)((CharSequence)question.getAnswerExplanation().get(0)))) {
+ answerExplanationList.add(tagVO.getDivStart() + (String)question.getAnswerExplanation().get(0) + tagVO.getDivEnd());
+ }
+ if (EditionEnum.ANSWER.getEdition().equals(edition)) {
+ answerExplanationList.addAll(question.getChildList().stream().map(m -> {
+ String tmp = "";
+ if (StringUtils.isNotBlank((CharSequence)m.getAnswer())) {
+ tmp = tmp + FileServiceImpl.joinQuestionNum(m.getShowQuestionNumber(), m.getAnswer());
+ }
+ if (EditionEnum.ANSWER.getEdition().equals(edition) && CollectionUtils.isNotEmpty((Collection)m.getAnswerExplanation()) && StringUtils.isNotBlank((CharSequence)((CharSequence)m.getAnswerExplanation().get(0)))) {
+ tmp = tmp + tagVO.getExplanation() + tagVO.getDivStart() + (String)m.getAnswerExplanation().get(0) + tagVO.getDivEnd() + "###\u3010\u4e0d\u5408\u5e76\u3011###";
+ }
+ return tmp;
+ }).collect(Collectors.toList()));
+ } else {
+ String answer = question.getChildList().stream().filter(f -> StringUtils.isNotBlank((CharSequence)f.getAnswer())).map(m -> FileServiceImpl.joinQuestionNum2(m.getShowQuestionNumber(), m.getAnswer())).collect(Collectors.joining(" "));
+ answerExplanationList.add(answer);
+ }
+ if (CollectionUtils.isNotEmpty(answerExplanationList)) {
+ contentList.addAll(answerExplanationList.stream().map(m -> FileServiceImpl.checkContentStyle(m) ? m.replace("", "").replace("
", "") : m).collect(Collectors.toList()));
+ }
+ if (EditionEnum.ANSWER.getEdition().equals(edition)) {
+ this.addQuestionInfo(edition, question, tagVO, contentList, 2);
+ }
+ }
+ }
+
+ private void collectQuestionBankInfo(List contentList, Integer edition, OfficeConfigVO officeConfig, OfficeFileElementVO element, List titleList, List questionList, OfficeFileStyleVO fileStyle) {
+ QuestionDetailVO one = element.getQuestionDetail();
+ int startIndex = contentList.size();
+ if (Objects.nonNull(one)) {
+ questionList.add(new ExportQuestionVO().setQuestion(one));
+ if (EditionEnum.STUDENT.getEdition().equals(edition) || EditionEnum.TEACHER.getEdition().equals(edition)) {
+ if (LogicTypeEnum.COMBINATION.getLogicTypeId().equals(one.getLogicTypeId()) && Objects.nonNull(one.getMergerType()) && one.getMergerType() == 1) {
+ BigDecimal score = one.getChildList().stream().map(m -> {
+ if (CollectionUtils.isNotEmpty((Collection)m.getChildList())) {
+ return m.getChildList().stream().filter(c2 -> Objects.nonNull(c2.getScore()) && c2.getScore().compareTo(BigDecimal.ZERO) > 0).map(QuestionDetailVO::getScore).reduce(BigDecimal.ZERO, BigDecimal::add);
+ }
+ return Objects.nonNull(m.getScore()) ? m.getScore() : BigDecimal.ZERO;
+ }).reduce(BigDecimal.ZERO, BigDecimal::add);
+ titleList.get(titleList.size() - 1).getQuestionList().add(new QuestionBO().setQuestionContent(one.getContent()).setScore(score));
+ } else if (CollectionUtils.isNotEmpty((Collection)one.getChildList())) {
+ for (QuestionDetailVO child1 : one.getChildList()) {
+ if ("\u6bb5\u843d".equals(child1.getLogicTypeName())) continue;
+ if (CollectionUtils.isNotEmpty((Collection)child1.getChildList())) {
+ List child1List = child1.getChildList();
+ if (child1.getLogicTypeName().equals("\u7ec4\u5408")) {
+ BigDecimal reduce = child1List.stream().filter(m -> Objects.nonNull(m.getScore()) && m.getScore().compareTo(BigDecimal.ZERO) > 0).map(QuestionDetailVO::getScore).reduce(BigDecimal.ZERO, BigDecimal::add);
+ titleList.get(titleList.size() - 1).getQuestionList().add(new QuestionBO().setQuestionContent(child1.getContent()).setScore(reduce));
+ continue;
+ }
+ child1List.forEach(child2 -> ((TitleBO)titleList.get(titleList.size() - 1)).getQuestionList().add(new QuestionBO().setQuestionContent(child2.getContent()).setScore(child2.getScore())));
+ continue;
+ }
+ titleList.get(titleList.size() - 1).getQuestionList().add(new QuestionBO().setQuestionContent(child1.getContent()).setScore(child1.getScore()));
+ }
+ } else {
+ titleList.get(titleList.size() - 1).getQuestionList().add(new QuestionBO().setQuestionContent(one.getContent()).setScore(one.getScore()));
+ }
+ }
+ TagVO tagVO = officeConfig.getTagVO();
+ if (LogicTypeEnum.COMBINATION.getLogicTypeId().equals(one.getLogicTypeId())) {
+ this.dealCombination(one, edition, tagVO, contentList, fileStyle);
+ } else if (LogicTypeEnum.BLANK.getLogicTypeId().equals(one.getLogicTypeId()) && Objects.nonNull(one.getMergerType()) && one.getMergerType() == 1) {
+ this.dealBlank(one, edition, tagVO, contentList, fileStyle);
+ } else if (LogicTypeEnum.COMPLETION.getLogicTypeId().equals(one.getLogicTypeId())) {
+ this.dealCompletion(one, edition, tagVO, contentList, fileStyle);
+ } else if (LogicTypeEnum.MULTIPLE_CHOOSE_MULTIPLE.getLogicTypeId().equals(one.getLogicTypeId())) {
+ this.dealMultipleChooseMultiple(one, edition, tagVO, contentList, fileStyle);
+ } else {
+ boolean isAnswerEdition;
+ boolean bl = isAnswerEdition = EditionEnum.ANSWER.getEdition().equals(edition) || EditionEnum.ANSWER_ONLY_ANSWER.getEdition().equals(edition);
+ if (!isAnswerEdition) {
+ if (EditionEnum.TEACHER.getEdition().equals(edition)) {
+ this.addQuestionInfo(edition, one, tagVO, contentList, 1);
+ }
+ String contentPrefix = this.getContentPrefix(one, fileStyle);
+ contentList.add(contentPrefix + tagVO.getDivStart() + one.getContent() + tagVO.getDivEnd());
+ this.addOption(one, contentList, "");
+ if (EditionEnum.TEACHER.getEdition().equals(edition)) {
+ if (StringUtils.isNotBlank((CharSequence)one.getAnswer())) {
+ contentList.add(tagVO.getAnswer() + tagVO.getDivStart() + (FileServiceImpl.checkContentStyle(one.getAnswer()) ? one.getAnswer().replace("", "").replace("
", "") : one.getAnswer()) + tagVO.getDivEnd());
+ }
+ if (CollectionUtils.isNotEmpty((Collection)one.getAnswerExplanation()) && StringUtils.isNotBlank((CharSequence)((CharSequence)one.getAnswerExplanation().get(0)))) {
+ contentList.add(tagVO.getExplanation() + tagVO.getDivStart() + (FileServiceImpl.checkContentStyle((String)one.getAnswerExplanation().get(0)) ? ((String)one.getAnswerExplanation().get(0)).replace("", "").replace("
", "") : (String)one.getAnswerExplanation().get(0)) + tagVO.getDivEnd());
+ }
+ this.addQuestionInfo(edition, one, tagVO, contentList, 2);
+ }
+ } else {
+ if (EditionEnum.ANSWER.getEdition().equals(edition)) {
+ this.addQuestionInfo(edition, one, tagVO, contentList, 1);
+ }
+ String tmp = "";
+ if (StringUtils.isNotBlank((CharSequence)one.getAnswer())) {
+ tmp = FileServiceImpl.checkContentStyle(one.getAnswer()) ? tmp + one.getShowQuestionNumber() + tagVO.getDivStart() + one.getAnswer().replace("", "").replace("
", "") + tagVO.getDivEnd() : tmp + tagVO.getDivStart() + FileServiceImpl.joinQuestionNum(one.getShowQuestionNumber(), one.getAnswer()) + tagVO.getDivEnd();
+ }
+ if (EditionEnum.ANSWER.getEdition().equals(edition) && CollectionUtils.isNotEmpty((Collection)one.getAnswerExplanation()) && StringUtils.isNotBlank((CharSequence)((CharSequence)one.getAnswerExplanation().get(0)))) {
+ if (LogicTypeEnum.RESPONSE.getLogicTypeId().equals(one.getLogicTypeId())) {
+ tmp = tmp + "
";
+ }
+ tmp = tmp + tagVO.getExplanation() + tagVO.getDivStart() + (String)one.getAnswerExplanation().get(0) + tagVO.getDivEnd() + "###\u3010\u4e0d\u5408\u5e76\u3011###";
+ }
+ if (!tmp.contains(tagVO.getExplanation()) && LogicTypeEnum.RESPONSE.getLogicTypeId().equals(one.getLogicTypeId())) {
+ contentList.add(tmp + "###\u3010\u4e0d\u5408\u5e76\u3011###");
+ } else {
+ contentList.add(tmp);
+ }
+ if (EditionEnum.ANSWER.getEdition().equals(edition)) {
+ this.addQuestionInfo(edition, one, tagVO, contentList, 2);
+ }
+ }
+ }
+ for (int i = startIndex; i < contentList.size(); ++i) {
+ if (!EditionEnum.ANSWER.getEdition().equals(edition) && !EditionEnum.ANSWER_ONLY_ANSWER.getEdition().equals(edition)) continue;
+ contentList.set(i, contentList.get(i) + "###\u3010\u9898\u76ee\u3011###");
+ }
+ }
+ }
+
+ private void collectQuestionInfoNew(List contentList, List questionList, OfficeFileStyleVO fileStyle, String editionStr, OfficeConfigVO officeConfig, ElementNumberUtil elementNumberUtil, List titleList, OfficeFileElementVO element) {
+ QuestionDetailVO question1 = element.getQuestionDetail();
+ String logicTypeName = question1.getLogicTypeName();
+ questionList.add(new ExportQuestionVO().setQuestion(question1));
+ String elementNum1 = "\u586b\u7a7a".equals(logicTypeName) && Objects.nonNull(question1.getMergerType()) && question1.getMergerType() == 1 || "\u5b8c\u5f62".equals(logicTypeName) || "\u591a\u9009\u591a".equals(logicTypeName) || "\u7ec4\u5408".equals(logicTypeName) && question1.getMergerType() == 0 ? "" : this.getQuestionNum(question1, element, fileStyle, officeConfig, elementNumberUtil);
+ Integer startIndex1 = this.dealQuestionInfo(contentList, elementNum1, question1, logicTypeName, officeConfig.getTagVO(), fileStyle, 1, editionStr);
+ if (editionStr.equals("\u3010\u5b66\u751f\u7248\u3011") || editionStr.equals("\u3010\u6559\u5e08\u7248\u3011")) {
+ if (question1.getLogicTypeName().equals("\u7ec4\u5408") && Objects.nonNull(question1.getMergerType()) && question1.getMergerType() == 1) {
+ BigDecimal score = question1.getChildList().stream().map(m -> {
+ if (CollectionUtils.isNotEmpty((Collection)m.getChildList())) {
+ return m.getChildList().stream().filter(c2 -> Objects.nonNull(c2.getScore()) && c2.getScore().compareTo(BigDecimal.ZERO) > 0).map(QuestionDetailVO::getScore).reduce(BigDecimal.ZERO, BigDecimal::add);
+ }
+ return Objects.nonNull(m.getScore()) ? m.getScore() : BigDecimal.ZERO;
+ }).reduce(BigDecimal.ZERO, BigDecimal::add);
+ titleList.get(titleList.size() - 1).getQuestionList().add(new QuestionBO().setQuestionContent(question1.getContent()).setScore(score));
+ } else if (CollectionUtils.isNotEmpty((Collection)question1.getChildList())) {
+ for (QuestionDetailVO child1 : question1.getChildList()) {
+ if ("\u6bb5\u843d".equals(child1.getLogicTypeName())) continue;
+ if (CollectionUtils.isNotEmpty((Collection)child1.getChildList())) {
+ List child1List = child1.getChildList();
+ if (child1.getLogicTypeName().equals("\u7ec4\u5408")) {
+ BigDecimal reduce = child1List.stream().filter(m -> Objects.nonNull(m.getScore()) && m.getScore().compareTo(BigDecimal.ZERO) > 0).map(QuestionDetailVO::getScore).reduce(BigDecimal.ZERO, BigDecimal::add);
+ titleList.get(titleList.size() - 1).getQuestionList().add(new QuestionBO().setQuestionContent(child1.getContent()).setScore(reduce));
+ continue;
+ }
+ child1List.forEach(child2 -> ((TitleBO)titleList.get(titleList.size() - 1)).getQuestionList().add(new QuestionBO().setQuestionContent(child2.getContent()).setScore(child2.getScore())));
+ continue;
+ }
+ titleList.get(titleList.size() - 1).getQuestionList().add(new QuestionBO().setQuestionContent(child1.getContent()).setScore(child1.getScore()));
+ }
+ } else {
+ titleList.get(titleList.size() - 1).getQuestionList().add(new QuestionBO().setQuestionContent(question1.getContent()).setScore(question1.getScore()));
+ }
+ }
+ ArrayList numList1 = new ArrayList();
+ if (!CollectionUtils.isEmpty((Collection)question1.getChildList())) {
+ int num1 = 0;
+ for (int i = 0; i < question1.getChildList().size(); ++i) {
+ QuestionDetailVO question2 = (QuestionDetailVO)question1.getChildList().get(i);
+ String elementNum2 = "";
+ if (!"\u6bb5\u843d".equals(question2.getLogicTypeName()) || question2.getMergerType() != 1) {
+ if (!"\u7ec4\u5408".equals(logicTypeName)) {
+ elementNum2 = this.getQuestionNum(question2, element, fileStyle, officeConfig, elementNumberUtil);
+ } else if (!"\u5b8c\u5f62".equals(question2.getLogicTypeName()) && !"\u591a\u9009\u591a".equals(question2.getLogicTypeName())) {
+ if (question1.getMergerType() == 0) {
+ elementNum2 = this.getQuestionNum(question2, element, fileStyle, officeConfig, elementNumberUtil);
+ } else {
+ elementNum2 = "(" + (num1 + 1) + ")";
+ ++num1;
+ }
+ }
+ }
+ numList1.add(elementNum2.replace(".", ""));
+ Integer startIndex2 = this.dealQuestionInfo(contentList, elementNum2, question2, logicTypeName, officeConfig.getTagVO(), fileStyle, 2, editionStr);
+ ArrayList numList2 = new ArrayList();
+ if (!CollectionUtils.isEmpty((Collection)question2.getChildList())) {
+ int num2 = 0;
+ for (int j = 0; j < question2.getChildList().size(); ++j) {
+ QuestionDetailVO question3 = (QuestionDetailVO)question2.getChildList().get(j);
+ String elementNum3 = "";
+ if (!"\u6bb5\u843d".equals(question3.getLogicTypeName()) || question3.getMergerType() != 1) {
+ if ("\u5b8c\u5f62".equals(question3.getLogicTypeName()) || "\u591a\u9009\u591a".equals(question3.getLogicTypeName())) {
+ elementNum3 = this.getQuestionNum(question3, element, fileStyle, officeConfig, elementNumberUtil);
+ } else if (question1.getMergerType() == 0) {
+ elementNum3 = "(" + (num2 + 1) + ")";
+ ++num2;
+ } else {
+ elementNum3 = String.valueOf((char)(9311 + num2 + 1));
+ ++num2;
+ }
+ }
+ numList2.add(elementNum3.replace(".", ""));
+ this.dealQuestionInfo(contentList, elementNum3, question3, logicTypeName, officeConfig.getTagVO(), fileStyle, 3, editionStr);
+ }
+ }
+ if (!editionStr.equals("\u3010\u5b66\u751f\u7248\u3011") && !editionStr.equals("\u3010\u6559\u5e08\u7248\u3011")) continue;
+ if ("\u5b8c\u5f62".equals(question2.getLogicTypeName()) || "\u591a\u9009\u591a".equals(question2.getLogicTypeName())) {
+ this.updateContentNum(contentList, startIndex2, numList2);
+ }
+ if (!"\u7ec4\u5408".equals(question2.getLogicTypeName())) continue;
+ ArrayList answerList = new ArrayList();
+ ArrayList explanationList = new ArrayList();
+ ArrayList otherList = new ArrayList();
+ boolean lastIsMerge = false;
+ for (int j = startIndex2.intValue(); j < contentList.size(); ++j) {
+ String content = contentList.get(j);
+ if (content.contains("\u3010\u7b54\u6848\u3011")) {
+ content = content.replace("\u3010\u7b54\u6848\u3011", "");
+ if (CollectionUtils.isEmpty(answerList)) {
+ answerList.add("\u3010\u7b54\u6848\u3011\u3010\u5408\u5e76\u3011" + elementNum2 + content);
+ } else if (content.contains("\u3010\u5408\u5e76\u3011") || lastIsMerge) {
+ answerList.add("\u3010\u7b54\u6848\u3011\u3010\u5408\u5e76\u3011" + content);
+ } else {
+ answerList.set(answerList.size() - 1, (String)answerList.get(answerList.size() - 1) + " " + content);
+ }
+ lastIsMerge = content.contains("\u3010\u5408\u5e76\u3011");
+ continue;
+ }
+ if (content.contains("\u3010\u89e3\u6790\u3011")) {
+ content = content.replace("\u3010\u89e3\u6790\u3011", "");
+ explanationList.add("\u3010\u89e3\u6790\u3011" + elementNum2 + content);
+ continue;
+ }
+ otherList.add(content);
+ }
+ contentList.subList(startIndex2, contentList.size()).clear();
+ contentList.addAll(otherList);
+ contentList.addAll(answerList);
+ contentList.addAll(explanationList);
+ }
+ }
+ if (editionStr.equals("\u3010\u5b66\u751f\u7248\u3011") || editionStr.equals("\u3010\u6559\u5e08\u7248\u3011")) {
+ if ("\u586b\u7a7a".equals(logicTypeName) && Objects.nonNull(question1.getMergerType()) && question1.getMergerType() == 1 || "\u5b8c\u5f62".equals(logicTypeName) || "\u591a\u9009\u591a".equals(logicTypeName)) {
+ this.updateContentNum(contentList, startIndex1, numList1);
+ }
+ if ("\u7ec4\u5408".equals(question1.getLogicTypeName())) {
+ List
;", "
\uff1b") + tagVO.getDivEnd() + "\u3010\u6559\u5e08\u7248\u3011" + "\u3010\u7b54\u6848\u7248\u3011" + "\u3010\u7b54\u6848\u7248\u4ec5\u7b54\u6848\u3011";
+ if (question.getLogicTypeName().equals("\u5224\u65ad")) {
+ if (question.getTrueFalseType() == 1) {
+ answer = answer.replace("T", "\u221a").replace("F", "\u00d7");
+ } else if (question.getTrueFalseType() == 2) {
+ answer = answer.replace("T", "\u5bf9").replace("F", "\u9519");
+ }
+ }
+ if (!question.getLogicTypeName().equals("\u7ec4\u5408") && !question.getLogicTypeName().equals("\u6bb5\u843d")) {
+ if (!(level != 1 || question.getLogicTypeName().equals("\u586b\u7a7a") && Objects.nonNull(question.getMergerType()) && question.getMergerType() == 1 || question.getLogicTypeName().equals("\u5b8c\u5f62") || question.getLogicTypeName().equals("\u591a\u9009\u591a"))) {
+ answerStr = answerPrefix + (isAnswerEdition ? numStr + " " : "") + answer;
+ } else if (level == 2 && (!"\u591a\u9009\u591a".equals(question.getLogicTypeName()) || "\u591a\u9009\u591a".equals(logicTypeName))) {
+ answerStr = answerPrefix + numStr + (isAnswerEdition ? " " : "") + answer;
+ } else if (level == 3) {
+ answerStr = answerPrefix + numStr + (isAnswerEdition ? " " : "") + answer;
+ }
+ }
+ String answerExplanationStr = "";
+ if (CollectionUtils.isNotEmpty((Collection)question.getAnswerExplanation())) {
+ boolean isLevel1AndNoNum = level == 1 && (!"\u586b\u7a7a".equals(logicTypeName) || !Objects.nonNull(question.getMergerType()) || question.getMergerType() != 1) && !"\u5b8c\u5f62".equals(logicTypeName) && !"\u591a\u9009\u591a".equals(logicTypeName);
+ ArrayList answerExplanationList = new ArrayList();
+ for (String answerExplanationTmp : question.getAnswerExplanation()) {
+ if (!StringUtils.isNotBlank((CharSequence)answerExplanationTmp)) continue;
+ answerExplanationTmp = tagVO.getDivStart() + answerExplanationTmp + tagVO.getDivEnd();
+ if (CollectionUtils.isEmpty(answerExplanationList)) {
+ answerExplanationList.add(isLevel1AndNoNum | isAnswerEdition ? answerExplanationTmp : numStr + answerExplanationTmp);
+ continue;
+ }
+ answerExplanationList.add(isAnswerEdition ? "\uff1b" + answerExplanationTmp : "" + answerExplanationTmp + "
");
+ }
+ if (CollectionUtils.isNotEmpty(answerExplanationList)) {
+ answerExplanationStr = "\u3010\u89e3\u6790\u3011\u3010\u6559\u5e08\u7248\u3011\u3010\u7b54\u6848\u7248\u3011\u3010\u7b54\u6848\u7248\u4ec5\u7b54\u6848\u3011" + String.join((CharSequence)"", answerExplanationList);
+ }
+ }
+ if (isAnswerEdition) {
+ String string = answerExplanationStr = "\u3010\u7b54\u6848\u7248\u4ec5\u7b54\u6848\u3011".equals(editionStr) ? "" : answerExplanationStr;
+ if ("\u7ec4\u5408".equals(question.getLogicTypeName()) && (level != 1 || !Objects.nonNull(question.getMergerType()) || question.getMergerType() != 0)) {
+ tmpContentList.add("###\u3010\u5408\u5e76\u7ec4\u5408\u3011###\u3010\u7b54\u6848\u7248\u3011\u3010\u7b54\u6848\u7248\u4ec5\u7b54\u6848\u3011" + numStr);
+ }
+ if ("\u89e3\u7b54".equals(question.getLogicTypeName()) && StringUtils.isNotBlank((CharSequence)answerStr) || !"\u89e3\u7b54".equals(question.getLogicTypeName()) && StringUtils.isNotBlank((CharSequence)answerExplanationStr) && StringUtils.isNotBlank((CharSequence)answerStr)) {
+ answerStr = answerStr + "###\u3010\u4e0d\u5408\u5e76\u3011###";
+ }
+ if (StringUtils.isNotBlank((CharSequence)answerStr) || StringUtils.isNotBlank((CharSequence)answerExplanationStr)) {
+ tmpContentList.add(answerStr + ("\u3010\u7b54\u6848\u7248\u4ec5\u7b54\u6848\u3011".equals(editionStr) ? "" : answerExplanationStr));
+ }
+ } else {
+ if (StringUtils.isNotBlank((CharSequence)answerStr)) {
+ tmpContentList.add(answerStr);
+ }
+ if (StringUtils.isNotBlank((CharSequence)answerExplanationStr)) {
+ tmpContentList.add(answerExplanationStr);
+ }
+ }
+ Integer startIndex = contentList.size();
+ contentList.addAll(tmpContentList);
+ return startIndex;
+ }
+
+ private void updateContentNum(List contentList, Integer startIndex, List numList) {
+ if (contentList.get(startIndex).startsWith("(\u5171")) {
+ Integer n = startIndex;
+ Integer n2 = startIndex = Integer.valueOf(startIndex + 1);
+ }
+ Document parse = Jsoup.parseBodyFragment((String)contentList.get(startIndex));
+ parse.outputSettings().prettyPrint(false).indentAmount(0);
+ Elements numberSpans = parse.select("span.tinymce-horizontal-number, span.tinymce-line-number");
+ for (int i = 0; i < numberSpans.size(); ++i) {
+ Element span = (Element)numberSpans.get(i);
+ span.html(span.html().replaceAll("\\d+\\.?", numList.get(i)).replace(" ", " "));
+ }
+ contentList.set(startIndex, parse.body().html());
+ }
+
+ private void addOptionNew(List contentList, QuestionDetailVO question, TagVO tagVO, String numStr) {
+ if (Boolean.TRUE.equals(question.getIsSubjective())) {
+ return;
+ }
+ ArrayList tContentList = new ArrayList();
+ List optionList = this.getOptionList(question, tagVO);
+ if (Objects.nonNull(question.getOptionColumn()) && question.getOptionColumn() > 1) {
+ this.addMultiColumnOptionByTab(tContentList, optionList, question.getOptionColumn());
+ } else {
+ tContentList.addAll(optionList);
+ }
+ contentList.addAll(tContentList.stream().map(m -> numStr + m + "\u3010\u5b66\u751f\u7248\u3011" + "\u3010\u6559\u5e08\u7248\u3011").collect(Collectors.toList()));
+ }
+
+ private void dealAnswerMergeNew(List contentList, List titleList, String editionStr, TagVO tagVO) {
+ if (CollectionUtils.isNotEmpty(titleList)) {
+ List