From dc4ca57e049ec18d8303109d1aa332096b880a34 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期五, 11 八月 2023 16:49:49 +0800
Subject: [PATCH] 1

---
 src/main/java/com/yssh/service/XlsReportService.java |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/yssh/service/XlsReportService.java b/src/main/java/com/yssh/service/XlsReportService.java
index a194aea..366503e 100644
--- a/src/main/java/com/yssh/service/XlsReportService.java
+++ b/src/main/java/com/yssh/service/XlsReportService.java
@@ -10,6 +10,7 @@
 import com.yssh.utils.CalculateUtils;
 import com.yssh.utils.DateUtils;
 import com.yssh.utils.ExcelUtils;
+import com.yssh.utils.WebUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Value;
@@ -17,6 +18,7 @@
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
 import java.io.File;
 import java.io.IOException;
 import java.util.*;
@@ -343,4 +345,22 @@
             logger.error(ex.getMessage(), ex);
         }
     }
+
+    /**
+     * 鏍规嵁ID涓嬭浇
+     */
+    public void downloadById(Integer id, HttpServletResponse res) {
+        XlsReport xlsReport = mapper.selectById(id);
+        if (null == xlsReport) return;
+
+        String file = reportPath + File.separator + xlsReport.getPath();
+        File f = new File(file);
+        if (!f.exists() || f.isDirectory()) return;
+
+        try {
+            WebUtils.download(file, xlsReport.getName(), false, res);
+        } catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
+        }
+    }
 }

--
Gitblit v1.9.3