From 5d6e29cd47762c4dacad7708cbef232414f5b95e Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期二, 29 八月 2023 14:49:02 +0800
Subject: [PATCH] 1

---
 src/main/java/com/yssh/controller/XlsReportController.java |    2 +-
 src/main/java/com/yssh/service/XlsReportService.java       |   11 +++++++++--
 src/main/resources/application-file.yml                    |    1 +
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/yssh/controller/XlsReportController.java b/src/main/java/com/yssh/controller/XlsReportController.java
index 5bb0cdf..bcef9f4 100644
--- a/src/main/java/com/yssh/controller/XlsReportController.java
+++ b/src/main/java/com/yssh/controller/XlsReportController.java
@@ -29,7 +29,7 @@
     @Resource
     XlsReportService xlsReportService;
 
-    private static List<String> TYPES = new ArrayList<>(Arrays.asList("day", "week", "month"));
+    private static final List<String> TYPES = new ArrayList<>(Arrays.asList("day", "week", "month"));
 
     @ApiOperationSupport(order = 1)
     @GetMapping("/selectByPage")
diff --git a/src/main/java/com/yssh/service/XlsReportService.java b/src/main/java/com/yssh/service/XlsReportService.java
index 366503e..7af4899 100644
--- a/src/main/java/com/yssh/service/XlsReportService.java
+++ b/src/main/java/com/yssh/service/XlsReportService.java
@@ -57,6 +57,12 @@
     private double bjz;
 
     /**
+     * 鎶ヨ鍊�
+     */
+    @Value("${report.templates}")
+    private String templates;
+
+    /**
      * 鑾峰彇瀵煎嚭璺緞
      */
     private String getExpPath(String type) {
@@ -74,9 +80,10 @@
      * 鑾峰彇Excel妯℃澘
      */
     private String getXslTemplate(String type) throws IOException {
-        ClassPathResource resource = new ClassPathResource(String.format("templates/%s.xlsx", type));
+        //ClassPathResource resource = new ClassPathResource(String.format("templates/%s.xlsx", type));
+        //return resource.exists() ? resource.getFile().getPath() : null;
 
-        return resource.exists() ? resource.getFile().getPath() : null;
+        return String.format(templates + File.separator + type + ".xlsx");
     }
 
     /**
diff --git a/src/main/resources/application-file.yml b/src/main/resources/application-file.yml
index 22dfc36..852388e 100644
--- a/src/main/resources/application-file.yml
+++ b/src/main/resources/application-file.yml
@@ -8,6 +8,7 @@
   vocPath: 'E:\yssh_data\VOC_ALL'
 #鏃�/鍛�/鏈堟姤璺緞
 report:
+  templates: E:\terrait\TianJin\YanShan\src\main\resources\templates
   path: E:\yssh_data\XlsReport
   yjz: 1.6
   bjz: 2

--
Gitblit v1.9.3