From 3be9cfcb6b59366b936821966d20a998a6895f9f Mon Sep 17 00:00:00 2001
From: 黎星凯 <13949086503@163.com>
Date: 星期二, 30 四月 2024 14:38:13 +0800
Subject: [PATCH] bug41、42修改

---
 consum-base/src/main/java/com/consum/base/controller/DepFormScrappedController.java |   75 +++++--------------------------------
 1 files changed, 10 insertions(+), 65 deletions(-)

diff --git a/consum-base/src/main/java/com/consum/base/controller/DepFormScrappedController.java b/consum-base/src/main/java/com/consum/base/controller/DepFormScrappedController.java
index bf0cb94..fbb78f4 100644
--- a/consum-base/src/main/java/com/consum/base/controller/DepFormScrappedController.java
+++ b/consum-base/src/main/java/com/consum/base/controller/DepFormScrappedController.java
@@ -146,7 +146,7 @@
     @ApiOperation(value = "瀵煎嚭鎶ュ簾鍗�", notes = "瀵煎嚭鎶ュ簾鍗�")
     @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "鎶ュ簾鍗昳d", dataType = "Long", paramType = "query")})
     @GetMapping("/deptList/export")
-    public void export(Long id, HttpServletResponse response) throws Exception {
+    public ResponseValue<String> export(Long id, HttpServletResponse response) throws Exception {
         if (id == null) {
             throw new RuntimeException("鎶ュ簾鍗昳d涓虹┖");
         }
@@ -174,12 +174,15 @@
 
         Workbook workbook = ExcelExportUtil.exportExcel(exportParams, map);
         // 璁剧疆鍝嶅簲澶�
-        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
-        response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode("閮ㄩ棬鎶ュ簾鍗�.xlsx", "utf-8"));
-        try (OutputStream outputStream = response.getOutputStream()) {
-            workbook.write(outputStream);
-            workbook.close();
-        }
+//        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
+//        response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode("閮ㄩ棬鎶ュ簾鍗�.xlsx", "utf-8"));
+//        try (OutputStream outputStream = response.getOutputStream()) {
+//            workbook.write(outputStream);
+//            workbook.close();
+//        }
+        String filePath = downLoadExcel("閲囪喘鍏ュ簱鍗�", workbook);
+        return ResponseValue.success("瀵煎嚭鎴愬姛", filePath);
+
     }
 
     @GetMapping("/deptListByModel")
@@ -224,62 +227,4 @@
         return ResponseValue.success(depFormScrappedService.listByModel2(param));
     }
 
-    // public static void main(String[] args) {
-    // TemplateExportParams exportParams = new
-    // TemplateExportParams("D:\\MyProjects\\jmy\\浣庡�兼槗鑰楀搧\\low-consum-manage\\deploy-jar-single\\src\\main\\resources\\import\\deptScrapped.xlsx");
-    // exportParams.setHeadingStartRow(2);
-    //
-    // List<Map<String, Object>> export = new ArrayList<>();
-    //
-    // // 鍒涘缓绗竴鏉℃暟鎹�
-    // Map<String, Object> data1 = new HashMap<>();
-    // data1.put("agencyName", 1);
-    // data1.put("baseGoodsTemplateName", "Bob");
-    // data1.put("scrappedName", "Bob");
-    // data1.put("bz", "Bob");
-    // data1.put("baseGoodsModelsName", 30);
-    // data1.put("counts", 30);
-    // data1.put("totalPrice", 30);
-    // export.add(data1);
-    //
-    // // 鍒涘缓绗簩鏉℃暟鎹�
-    // Map<String, Object> data2 = new HashMap<>();
-    // data2.put("agencyName", 2);
-    // data2.put("baseGoodsTemplateName", "Bob");
-    // data2.put("scrappedName", "Bob");
-    // data2.put("bz", "Bob");
-    // data2.put("baseGoodsModelsName", 30);
-    // data2.put("counts", 30);
-    // data2.put("totalPrice", 30);
-    // export.add(data2);
-    //
-    //
-    // Map<String, Object> map = new HashMap<>();
-    // map.put("code", "2023");
-    // map.put("date", "2023");
-    // map.put("name", "operatorName");
-    // map.put("countNum", 0);
-    // map.put("totalAmount", 0);
-    // map.put("maplist", export);
-    //
-    // Workbook workbook = ExcelExportUtil.exportExcel(exportParams, map);
-    //
-    // File file = new File("C:\\Users\\cy\\Desktop\\鏂板缓鏂囦欢澶�");
-    // OutputStream stream = null;
-    // try {
-    // SimpleDateFormat sdf = new SimpleDateFormat("yyyy_MM_dd");
-    // stream = new FileOutputStream(new File(file, "鏈烘瀯瀹㈡埛淇℃伅琛�.xls"));
-    // //document.write(stream);
-    // workbook.write(stream);
-    // } catch (Exception e) {
-    // e.printStackTrace();
-    // } finally {
-    // if (stream != null) ;
-    // try {
-    // stream.close();
-    // } catch (IOException e) {
-    // e.printStackTrace();
-    // }
-    // }
-    // }
 }

--
Gitblit v1.9.1