From 2c786593c62d1a97cfc531b35106798047279042 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期三, 09 八月 2023 10:22:53 +0800
Subject: [PATCH] 1

---
 src/main/java/com/yssh/service/XlsExportService.java |   25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/yssh/service/XlsExportService.java b/src/main/java/com/yssh/service/XlsExportService.java
index fc38802..dc788a8 100644
--- a/src/main/java/com/yssh/service/XlsExportService.java
+++ b/src/main/java/com/yssh/service/XlsExportService.java
@@ -4,9 +4,11 @@
 import com.yssh.utils.ExcelUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.stereotype.Service;
 
+import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -21,6 +23,23 @@
 @Service
 public class XlsExportService {
     protected final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+    @Value("${report.path}")
+    private String reportPath;
+
+    /**
+     * 鑾峰彇瀵煎嚭璺緞
+     */
+    private String getExpPath(String type) {
+        String path = reportPath + File.separator + type;
+
+        File f = new File(path);
+        if (!f.exists() || !f.isDirectory()) {
+            f.mkdirs();
+        }
+
+        return path;
+    }
 
     /**
      * 鑾峰彇Excel妯℃澘
@@ -46,14 +65,16 @@
      */
     public void createDayReport() {
         try {
+            String type = "day";
             List<DayExcel> list = new ArrayList<>();
             for (int i = 1; i < 47; i++) {
                 DayExcel day = new DayExcel("AI-" + (i < 10 ? "0" : "") + i, "lj", "ljtb", "ys", "fs", "fx", "wd");
                 list.add(day);
             }
 
-            String source = getXslTemplate("day");
-            String target = "";
+            String source = getXslTemplate(type);
+            String target = String.format("%s\\%d.xlsx", getExpPath(type), 20230808);
+
             createExcel(source, target, list);
         } catch (Exception ex) {
             logger.error(ex.getMessage(), ex);

--
Gitblit v1.9.3