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/config/InitConfig.java        |    6 ++++++
 src/main/resources/application-file.yml              |    3 +++
 src/main/java/com/yssh/service/XlsExportService.java |   25 +++++++++++++++++++++++--
 3 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/yssh/config/InitConfig.java b/src/main/java/com/yssh/config/InitConfig.java
index 8711ca3..6bacd13 100644
--- a/src/main/java/com/yssh/config/InitConfig.java
+++ b/src/main/java/com/yssh/config/InitConfig.java
@@ -1,6 +1,7 @@
 package com.yssh.config;
 
 import com.yssh.service.WarningAnalyseService;
+import com.yssh.service.XlsExportService;
 import com.yssh.utils.CacheUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -33,6 +34,9 @@
     @Resource
     ScheduleConfig task;
 
+    @Resource
+    XlsExportService xlsService;
+
     @Override
     public void run(ApplicationArguments args) throws Exception {
         CacheUtils.init();
@@ -43,6 +47,8 @@
         // 璇诲彇dat鏁版嵁
         commonService.readDatData();
 
+        xlsService.createDayReport();
+
         //test();
         logger.info("***************** 绯荤粺鍚姩瀹屾瘯 *****************" + "\n");
     }
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);
diff --git a/src/main/resources/application-file.yml b/src/main/resources/application-file.yml
index dc439d0..45294a1 100644
--- a/src/main/resources/application-file.yml
+++ b/src/main/resources/application-file.yml
@@ -6,3 +6,6 @@
 csv:
   filePath: 'D:\2022\LBM_New'
   vocPath: 'D:\2022\voc_all'
+#鏃�/鍛�/鏈堟姤璺緞
+report:
+  path: D:\2022\XlsReport

--
Gitblit v1.9.3