From 19d542ddaa4a2d5a737912505e3195948ffa9ebe Mon Sep 17 00:00:00 2001
From: liuhaonan <31457034@qq.com>
Date: 星期四, 04 八月 2022 10:48:34 +0800
Subject: [PATCH] changes

---
 ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightReportDataService.java |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightReportDataService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightReportDataService.java
index 88c2a53..2e6c093 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightReportDataService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightReportDataService.java
@@ -47,6 +47,7 @@
 
     private final FileProperties properties;
     private final AliOssFileServiceImpl fileService;
+    private final LightReportDataMapper lightReportDataMapper;
 
     /**
      * 淇濆瓨涓婃姤鐨勭伅蹇冭烦鏁版嵁
@@ -64,7 +65,6 @@
             lightReportData = new LightReportData();
             lightReportData.setCreateTime(format);
         }
-        //todo
         lightReportData.setCreateTime(format);
         BeanUtils.copyProperties(heartBeatDataPackage, lightReportData);
         lightReportData.setDeviceCode(deviceName);
@@ -132,7 +132,7 @@
     }
 
     @SneakyThrows
-    public String exportList(HttpServletRequest request, HttpServletResponse response, String deviceCode) {
+    public void exportList(HttpServletRequest request, HttpServletResponse response, String deviceCode) {
 
         if (SecurityUtils.getClientId() != null) {
             PoleBinding one = SpringContextHolder.getBean(PoleBindingService.class).getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceCode, deviceCode)
@@ -149,7 +149,7 @@
             }
         }
 
-        List<LightReportDataBo> list = baseMapper.listReportData(null, deviceCode);
+        List<LightReportDataBo> list = lightReportDataMapper.listReportData(null, deviceCode);
 
         File file = new File("./" + RandomUtil.randomString(12) + ".xlsx");
 
@@ -158,8 +158,7 @@
         //鏂囦欢娴佸寲杩斿洖缁欏墠绔�
         findfile(request, response, file);
         //鍒犻櫎鏂囦欢
-        file.delete();
-        return null;
+       // file.delete();
     }
 
     /**
@@ -174,8 +173,6 @@
         ServletOutputStream out = null;
         FileInputStream ips = null;
         try {
-            //鑾峰彇鏂囦欢瀛樻斁鐨勮矾寰�
-            String fileName = file.getName();
             //鑾峰彇鍒版枃瀛� 鏁版嵁搴撻噷瀵瑰簲鐨勯檮浠跺悕瀛楀姞涓婅�佺殑鏂囦欢鍚嶅瓧锛歠ilename 鎴彇鍒板悗闈㈢殑鏂囦欢绫诲瀷 渚嬶細txt  缁勬垚涓�涓柊鐨勬枃浠跺悕瀛楋細newFileName
             //鐢熸垚3涓殢鏈烘暟锛岀敤鏉ョ敓鎴愭柊鐨勬枃浠跺悕瀛�
             String newFileName = "鍗曠伅鏁版嵁" + RandomUtil.randomString(3) + ".xlsx";
@@ -184,7 +181,7 @@
                 return;
             }
             ips = new FileInputStream(file);
-            response.setContentType("multipart/form-data");
+            response.setContentType("application/json;charset=utf-8");
             //涓烘枃浠堕噸鏂拌缃悕瀛楋紝閲囩敤鏁版嵁搴撳唴瀛樺偍鐨勬枃浠跺悕绉�
             response.addHeader("Content-Disposition", "attachment; filename=\"" + new String(newFileName.getBytes("UTF-8"), "ISO8859-1") + "\"");
             out = response.getOutputStream();
@@ -201,6 +198,7 @@
             try {
                 out.close();
                 ips.close();
+                file.delete();
             } catch (IOException e) {
                 System.out.println("鍏抽棴娴佸嚭鐜板紓甯�");
                 e.printStackTrace();

--
Gitblit v1.9.3