From 7a8d50965cb69ecc348a6b11d902409628012cd0 Mon Sep 17 00:00:00 2001
From: whyclxw <810412026@qq.com>
Date: 星期三, 25 六月 2025 17:15:10 +0800
Subject: [PATCH] 蓄电池对比分析导出

---
 src/main/java/com/whyc/service/ExportService.java |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/whyc/service/ExportService.java b/src/main/java/com/whyc/service/ExportService.java
index 09ea1ea..3e92717 100644
--- a/src/main/java/com/whyc/service/ExportService.java
+++ b/src/main/java/com/whyc/service/ExportService.java
@@ -5,7 +5,9 @@
 import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
 import com.whyc.dto.Real.ExportTinfDataDto;
 import com.whyc.dto.Response;
+import com.whyc.dto.Statistic.BattCompareStic;
 import com.whyc.dto.Statistic.MonStic;
+import com.whyc.dto.Statistic.SticCompare15Res;
 import com.whyc.dto.Statistic.SticMonRes;
 import com.whyc.mapper.CommonMapper;
 import com.whyc.pojo.db_batt_testdata.BatttestdataId;
@@ -229,4 +231,49 @@
             e.printStackTrace();
         }
     }
+    //钃勭數姹犵粍瀵规瘮鍒嗘瀽瀵煎嚭(2.5.1/2/3)
+    public void exportBattCompare(HttpServletRequest req, HttpServletResponse resp, BattCompareStic stic) throws IOException {
+        Map<String,Object> map=new HashMap<>();
+        map.put("avgCap",stic.getAvgCap());
+        map.put("standCapDiff",stic.getStandCapDiff());
+        //琛ㄦ牸鏁版嵁
+        List<SticCompare15Res> dataList= battTinfService.exportBattCompare(stic);
+        map.put("dataList",dataList);
+        BASE64Decoder decoder = new BASE64Decoder();
+        if(!stic.getPicCap().equals("")) {
+            ImageEntity volImage = new ImageEntity();
+            volImage.setData(decoder.decodeBuffer(stic.getPicCap().substring(stic.getPicCap().indexOf(",") + 1)));
+            volImage.setColspan(6);
+            volImage.setRowspan(17);
+            map.put("picCap",volImage);
+        }
+        if(!stic.getPicRes().equals("")) {
+            ImageEntity volImage = new ImageEntity();
+            volImage.setData(decoder.decodeBuffer(stic.getPicRes().substring(stic.getPicRes().indexOf(",") + 1)));
+            volImage.setColspan(6);
+            volImage.setRowspan(17);
+            map.put("picRes",volImage);
+        }
+        if(!stic.getPicFlotVol().equals("")) {
+            ImageEntity volImage = new ImageEntity();
+            volImage.setData(decoder.decodeBuffer(stic.getPicFlotVol().substring(stic.getPicFlotVol().indexOf(",") + 1)));
+            volImage.setColspan(6);
+            volImage.setRowspan(17);
+            map.put("picFlotVol",volImage);
+        }
+        //鑾峰彇瀵煎嚭妯℃澘鍦板潃
+        ClassPathResource classPathResource = new ClassPathResource("excel_templates/batt_compare_template.xlsx");
+        String path = classPathResource.getPath();
+        TemplateExportParams templateExportParams1 = new TemplateExportParams(path,true);
+        Workbook wb = ExcelExportUtil.exportExcel(templateExportParams1, map);
+        try {
+            String fileName = "钃勭數姹犵粍瀵规瘮鏁版嵁.xls";
+            resp.setContentType("application/vnd.ms-excel");
+            resp.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "utf-8"));
+            resp.flushBuffer();
+            wb.write(resp.getOutputStream());
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.1