Selaa lähdekoodia

feature 获取模板方式修改

xiahan 3 kuukautta sitten
vanhempi
commit
907ea177e4

+ 1 - 1
zhsw-common/src/main/java/com/rongwei/zhsw/system/service/impl/SwCollectionNoticeServiceImpl.java

@@ -340,7 +340,7 @@ public class SwCollectionNoticeServiceImpl implements SwCollectionNoticeService
         List<SwBusinesshallDo> list = swBusinesshallService.list(new LambdaQueryWrapper<SwBusinesshallDo>().eq(BaseDo::getDeleted, "0")
                 .orderByAsc(SwBusinesshallDo::getOrdernumber));
         String addresStr = list.stream().map(data -> data.getAddress()+" ("+data.getWorktime()+")").collect(Collectors.joining("\n"));
-        try (InputStream templateStream = EnvironmentAwareResourceLoader.loadResource("temp/" + tempName)) {
+        try (InputStream templateStream = EnvironmentAwareResourceLoader.loadResource(tempName)) {
             Date now = new Date();
             Calendar instance = Calendar.getInstance();
             instance.setTime(now);

+ 3 - 2
zhsw-common/src/main/java/com/rongwei/zhsw/system/utils/EnvironmentAwareResourceLoader.java

@@ -17,6 +17,7 @@ import java.nio.file.Files;
 public class EnvironmentAwareResourceLoader {
     /**
      * 智能加载资源(自动判断环境)
+     *
      * @param relativePath 资源相对路径(如:temp/example.txt)
      * @return 文件输入流
      * @throws IOException
@@ -25,7 +26,7 @@ public class EnvironmentAwareResourceLoader {
         if (isRunningInJar()) {
             // 服务器环境:从JAR同级目录加载
             File jarDir = getJarDirectory();
-            File targetFile = new File(jarDir, relativePath);
+            File targetFile = new File(jarDir, "cjdTemp/" + relativePath);
 
             if (!targetFile.exists()) {
                 throw new FileNotFoundException("服务器环境文件未找到: " + targetFile.getAbsolutePath());
@@ -34,7 +35,7 @@ public class EnvironmentAwareResourceLoader {
 
         } else {
             // 开发环境:从resources目录加载
-            ClassPathResource classPathResource = new ClassPathResource(relativePath);
+            ClassPathResource classPathResource = new ClassPathResource("temp/cjd/" + relativePath);
             return classPathResource.getInputStream();
         }
     }

zhsw-server/src/main/resources/temp/徐州大吴水务催缴单.docx → zhsw-server/src/main/resources/temp/cjd/徐州大吴水务催缴单.docx