From b18350e2f06c55f6aaae957631238bf02bb07b63 Mon Sep 17 00:00:00 2001
From: 石广澎 <shiguangpeng@163.com>
Date: 星期六, 02 十二月 2023 11:56:14 +0800
Subject: [PATCH] fix: 修复标签页 主页刷新后消失的问题

---
 consum-base/src/main/java/com/consum/base/controller/LWhFormScrappedController.java |  104 +++++++++++++++++++---------------------------------
 1 files changed, 38 insertions(+), 66 deletions(-)

diff --git a/consum-base/src/main/java/com/consum/base/controller/LWhFormScrappedController.java b/consum-base/src/main/java/com/consum/base/controller/LWhFormScrappedController.java
index df5e542..d37dd49 100644
--- a/consum-base/src/main/java/com/consum/base/controller/LWhFormScrappedController.java
+++ b/consum-base/src/main/java/com/consum/base/controller/LWhFormScrappedController.java
@@ -23,14 +23,6 @@
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.URLEncoder;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import javax.servlet.http.HttpServletResponse;
 import org.apache.commons.compress.utils.Lists;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.springframework.beans.BeanUtils;
@@ -39,6 +31,15 @@
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.URLEncoder;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
 
 /**
  * @Description 鎶ュ簾鍗�
@@ -70,26 +71,7 @@
         CommonUtil.copyProperties(param, query);
         param = query;
         FinSysTenantUser sysInfo = this.getSysInfo();
-        int result = this.lWhFormScrappedService.add(param, 0, this.getCurrentUser(), sysInfo);
-        if (result > 0) {
-            return ResponseValue.success(1);
-        }
-        return ResponseValue.error("鏂板澶辫触锛�");
-    }
-
-    @ApiOperation(value = "鏂板鎶ュ簾鍗�", notes = "鏂板鎶ュ簾鍗�")
-    @ApiImplicitParams({
-        @ApiImplicitParam(name = "param")
-    })
-    @PostMapping("/deprAdd")
-    public ResponseValue deprAdd() {
-        LWhFormScrappedParam param = CommonUtil.getObjFromReqBody(LWhFormScrappedParam.class);
-        LWhFormScrappedParam query = new LWhFormScrappedParam();
-        CommonUtil.copyProperties(param, query);
-        param = query;
-
-        FinSysTenantUser sysInfo = this.getSysInfo();
-        int result = this.lWhFormScrappedService.add(param, 1, this.getCurrentUser(), sysInfo);
+        int result = this.lWhFormScrappedService.add(param, this.getCurrentUser(), sysInfo);
         if (result > 0) {
             return ResponseValue.success(1);
         }
@@ -186,51 +168,41 @@
         return ResponseValue.success(pageUtil);
     }
 
-    /**
-     * @Description 瀵煎嚭鎶ュ簾鐧昏鍗�
-     * @Author 鍗㈠簡闃�
-     * @Date 2023/11/2
-     */
+    @ApiOperation(value = "瀵煎嚭鎶ュ簾鍗�", notes = "瀵煎嚭鎶ュ簾鍗�")
+    @ApiImplicitParams({
+        @ApiImplicitParam(name = "id", value = "鎶ュ簾鍗昳d", dataType = "Long", paramType = "query")
+    })
     @GetMapping("/list/export")
-    public void export(Long id, HttpServletResponse response) {
+    public void export(Long id, HttpServletResponse response) throws Exception {
         if (id == null) {
             throw new RuntimeException("鎶ュ簾鍗昳d涓虹┖");
         }
-        try {
-            OutputStream outputStream = response.getOutputStream();
-            List<ScrappedInfoExcelTemplate> export = lWhFormScrappedService.export(id);
-            if (CollectionUtils.isEmpty(export)) {
-                throw new RuntimeException("鏁版嵁涓虹┖");
-            }
-            TemplateExportParams exportParams = new TemplateExportParams("import/鎶ュ簾鐧昏鍗�.xlsx");
-            exportParams.setHeadingStartRow(2);
 
-            Optional<ScrappedInfoExcelTemplate> first = export.stream().findFirst();
-            ScrappedInfoExcelTemplate scrappedInfoExcelTemplate = first.get();
-            Long dealTime = scrappedInfoExcelTemplate.getDealTime();
-            String operatorName = scrappedInfoExcelTemplate.getOperatorName();
-            String businessFormCode = scrappedInfoExcelTemplate.getBusinessFormCode();
-
-            int countNum = export.stream().filter(item -> item.getNum() != null).mapToInt(ScrappedInfoExcelTemplate::getNum).sum();
-            int totalAmount = export.stream().filter(item -> item.getTotalAmount() != null).mapToInt(ScrappedInfoExcelTemplate::getTotalAmount).sum();
-
-            Map<String, Object> map = new HashMap<>();
-            map.put("code", businessFormCode);
-            map.put("date", DateUtils.toShowDate(dealTime));
-            map.put("name", operatorName);
-            map.put("countNum", countNum);
-            map.put("totalAmount", totalAmount);
-
-            Workbook sheets = ExcelExportUtil.exportExcel(exportParams, ScrappedInfoExcelTemplate.class, export, map);
-            // 璁剧疆鍝嶅簲澶�
-            response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
-            response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode("鎶ュ簾鍗曠櫥璁�.xlsx", "utf-8"));
-            sheets.write(outputStream);
-            sheets.close();
-        } catch (IOException e) {
-            throw new RuntimeException(e);
+        List<ScrappedInfoExcelTemplate> export = lWhFormScrappedService.export(id);
+        if (CollectionUtils.isEmpty(export)) {
+            throw new RuntimeException("鏁版嵁涓虹┖");
         }
+        TemplateExportParams exportParams = new TemplateExportParams("import/鎶ュ簾鐧昏鍗�.xlsx");
+        exportParams.setHeadingStartRow(2);
 
+        Optional<ScrappedInfoExcelTemplate> first = export.stream().findFirst();
+        ScrappedInfoExcelTemplate scrappedInfoExcelTemplate = first.get();
+        Long dealTime = scrappedInfoExcelTemplate.getDealTime();
+        String operatorName = scrappedInfoExcelTemplate.getOperatorName();
+        String businessFormCode = scrappedInfoExcelTemplate.getBusinessFormCode();
+
+        int countNum = export.stream().filter(item -> item.getNum() != null).mapToInt(ScrappedInfoExcelTemplate::getNum).sum();
+        int totalAmount = export.stream().filter(item -> item.getTotalAmount() != null).mapToInt(ScrappedInfoExcelTemplate::getTotalAmount).sum();
+
+        Map<String, Object> map = new HashMap<>();
+        map.put("code", businessFormCode);
+        map.put("date", DateUtils.toShowDate(dealTime));
+        map.put("name", operatorName);
+        map.put("countNum", countNum);
+        map.put("totalAmount", totalAmount);
+
+        Workbook sheets = ExcelExportUtil.exportExcel(exportParams, ScrappedInfoExcelTemplate.class, export, map);
+        downLoadExcel("鎶ュ簾鐧昏鍗�", response, sheets);
 
     }
 

--
Gitblit v1.9.1