From e0746875b50c27bb81486535383f8b62add03804 Mon Sep 17 00:00:00 2001 From: ls Date: Fri, 8 Nov 2024 22:04:52 +0800 Subject: [PATCH] update --- Dockerfile | 1 + .../src/main/resources/application-dev.yml | 3 +++ .../src/main/resources/application-prod.yml | 2 ++ .../src/main/resources/application-test.yml | 2 ++ .../impl/ExperimentDocServiceImpl.java | 19 +++++++++--------- .../templates/doc => templates}/fzsyjhb.docx | Bin .../templates/doc => templates}/fzsyzjd.docx | Bin .../templates/doc => templates}/sbsyjlb.docx | Bin .../templates/doc => templates}/sybg.docx | Bin .../templates/doc => templates}/sybgpsb.docx | Bin 10 files changed, 18 insertions(+), 9 deletions(-) rename {physical-module-system/physical-system-biz/src/main/resources/templates/doc => templates}/fzsyjhb.docx (100%) rename {physical-module-system/physical-system-biz/src/main/resources/templates/doc => templates}/fzsyzjd.docx (100%) rename {physical-module-system/physical-system-biz/src/main/resources/templates/doc => templates}/sbsyjlb.docx (100%) rename {physical-module-system/physical-system-biz/src/main/resources/templates/doc => templates}/sybg.docx (100%) rename {physical-module-system/physical-system-biz/src/main/resources/templates/doc => templates}/sybgpsb.docx (100%) diff --git a/Dockerfile b/Dockerfile index cdb2154..5b7c5fd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,5 +23,6 @@ WORKDIR /app EXPOSE 8080 #ADD ./src/main/resources/jeecg ./config/jeecg COPY --from=build /app/physical-launcher/target/physical-launcher-3.7.0.jar physical-launcher-3.7.0.jar +COPY --from=build /app/templates ./templates CMD sleep 10;java -Djava.security.egd=file:/dev/./urandom -jar physical-launcher-3.7.0.jar --spring.profiles.active=test \ No newline at end of file diff --git a/physical-launcher/src/main/resources/application-dev.yml b/physical-launcher/src/main/resources/application-dev.yml index 2f592b2..ddea611 100644 --- a/physical-launcher/src/main/resources/application-dev.yml +++ b/physical-launcher/src/main/resources/application-dev.yml @@ -204,7 +204,10 @@ mybatis-plus: #jeecg专用配置 minidao: base-package: org.jeecg.modules.jmreport.*,org.jeecg.modules.drag.* + jeecg: + template: + path: /app/templates # 平台上线安全配置 firewall: # 数据源安全 (开启后,Online报表和图表的数据源为必填) diff --git a/physical-launcher/src/main/resources/application-prod.yml b/physical-launcher/src/main/resources/application-prod.yml index a31d8a1..78b9c41 100644 --- a/physical-launcher/src/main/resources/application-prod.yml +++ b/physical-launcher/src/main/resources/application-prod.yml @@ -207,6 +207,8 @@ mybatis-plus: minidao: base-package: org.jeecg.modules.jmreport.*,org.jeecg.modules.drag.* jeecg: + template: + path: /app/templates # 平台上线安全配置 firewall: # 数据源安全 (开启后,Online报表和图表的数据源为必填) diff --git a/physical-launcher/src/main/resources/application-test.yml b/physical-launcher/src/main/resources/application-test.yml index 5596684..f302e5b 100644 --- a/physical-launcher/src/main/resources/application-test.yml +++ b/physical-launcher/src/main/resources/application-test.yml @@ -207,6 +207,8 @@ mybatis-plus: minidao: base-package: org.jeecg.modules.jmreport.*,org.jeecg.modules.drag.* jeecg: + template: + path: /app/templates # 平台上线安全配置 firewall: # 数据源安全 (开启后,Online报表和图表的数据源为必填) diff --git a/physical-module-system/physical-system-biz/src/main/java/org/jeecg/modules/database/service/impl/ExperimentDocServiceImpl.java b/physical-module-system/physical-system-biz/src/main/java/org/jeecg/modules/database/service/impl/ExperimentDocServiceImpl.java index 87b0c3a..81813a0 100755 --- a/physical-module-system/physical-system-biz/src/main/java/org/jeecg/modules/database/service/impl/ExperimentDocServiceImpl.java +++ b/physical-module-system/physical-system-biz/src/main/java/org/jeecg/modules/database/service/impl/ExperimentDocServiceImpl.java @@ -9,13 +9,13 @@ import org.jeecg.common.util.MinioUtil; import org.jeecg.modules.database.entity.ExperimentDoc; import org.jeecg.modules.database.mapper.ExperimentDocMapper; import org.jeecg.modules.database.service.IExperimentDocService; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import java.io.File; import java.io.IOException; -import java.net.URL; import java.util.HashMap; import java.util.Map; -import java.util.Objects; /** * @Description: 试验文档 @@ -27,6 +27,9 @@ import java.util.Objects; @Slf4j public class ExperimentDocServiceImpl extends ServiceImpl implements IExperimentDocService { + @Value("${jeecg.template.path}") + private String templatePath; + static Map docTempalteMap = new HashMap<>(); static { @@ -42,17 +45,15 @@ public class ExperimentDocServiceImpl extends ServiceImpl maps = new HashMap<>(); maps.put("title", "辐照试验计划表"); - generateExperimentDoc("20241028号实验", "辐照试验计划表", maps); + //generateExperimentDoc("20241028号实验", "辐照试验计划表", maps); } - public static String generateExperimentDoc(String experimentId, String fileName, Map params) { - URL resourceUrl = ExperimentDocServiceImpl.class.getClassLoader().getResource("templates/doc/" + docTempalteMap.get(fileName)); - if (Objects.isNull(resourceUrl)) { + public String generateExperimentDoc(String experimentId, String fileName, Map params) { + String absolutePath = templatePath + File.separator + docTempalteMap.get(fileName); + log.info("doc template path: " + absolutePath); + if (FileUtil.exist(absolutePath)) { throw new RuntimeException("模板文件不存在!"); } - String absolutePath = resourceUrl.getPath(); - log.info("doc template path: " + absolutePath); - try { String tmpDirPath = FileUtil.getTmpDirPath(); String outputFile = tmpDirPath + fileName + "-" + experimentId + ".docx"; diff --git a/physical-module-system/physical-system-biz/src/main/resources/templates/doc/fzsyjhb.docx b/templates/fzsyjhb.docx similarity index 100% rename from physical-module-system/physical-system-biz/src/main/resources/templates/doc/fzsyjhb.docx rename to templates/fzsyjhb.docx diff --git a/physical-module-system/physical-system-biz/src/main/resources/templates/doc/fzsyzjd.docx b/templates/fzsyzjd.docx similarity index 100% rename from physical-module-system/physical-system-biz/src/main/resources/templates/doc/fzsyzjd.docx rename to templates/fzsyzjd.docx diff --git a/physical-module-system/physical-system-biz/src/main/resources/templates/doc/sbsyjlb.docx b/templates/sbsyjlb.docx similarity index 100% rename from physical-module-system/physical-system-biz/src/main/resources/templates/doc/sbsyjlb.docx rename to templates/sbsyjlb.docx diff --git a/physical-module-system/physical-system-biz/src/main/resources/templates/doc/sybg.docx b/templates/sybg.docx similarity index 100% rename from physical-module-system/physical-system-biz/src/main/resources/templates/doc/sybg.docx rename to templates/sybg.docx diff --git a/physical-module-system/physical-system-biz/src/main/resources/templates/doc/sybgpsb.docx b/templates/sybgpsb.docx similarity index 100% rename from physical-module-system/physical-system-biz/src/main/resources/templates/doc/sybgpsb.docx rename to templates/sybgpsb.docx