From 0c31534172f689160c95a4ff61df11712b6890fe Mon Sep 17 00:00:00 2001
From: cy <1664593601@qq.com>
Date: 星期四, 30 十一月 2023 13:42:44 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 consum-base/src/main/java/com/consum/base/controller/LWhFormOutputController.java |   66 ++++++++++++++++++++++++++++----
 1 files changed, 57 insertions(+), 9 deletions(-)

diff --git a/consum-base/src/main/java/com/consum/base/controller/LWhFormOutputController.java b/consum-base/src/main/java/com/consum/base/controller/LWhFormOutputController.java
index ca0024f..0143c76 100644
--- a/consum-base/src/main/java/com/consum/base/controller/LWhFormOutputController.java
+++ b/consum-base/src/main/java/com/consum/base/controller/LWhFormOutputController.java
@@ -1,9 +1,13 @@
 package com.consum.base.controller;
 
+import cn.afterturn.easypoi.excel.ExcelExportUtil;
+import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
+import cn.hutool.core.util.ReflectUtil;
 import com.consum.base.BaseController;
 import com.consum.base.core.utils.CommonUtil;
 import com.consum.base.core.utils.MapUtils;
 import com.consum.base.core.utils.MapperUtil;
+import com.consum.base.core.utils.PageUtil;
 import com.consum.base.pojo.LWhFormOutputParam;
 import com.consum.base.pojo.query.LWhFormOutputQry;
 import com.consum.base.pojo.response.FormOutputGoodsVO;
@@ -13,7 +17,6 @@
 import com.consum.base.pojo.response.LWhFormOutputExtendVO;
 import com.consum.base.service.LWarehouseFlowService;
 import com.consum.base.service.LWhFormOutputServiceImpl;
-import com.consum.base.service.LWhGoodsService;
 import com.consum.base.service.LWhProcureModelService;
 import com.consum.model.po.FinSysTenantUser;
 import com.consum.model.po.LWhFormOutput;
@@ -25,14 +28,23 @@
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.lang.reflect.Field;
+import java.net.URLEncoder;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
 import org.apache.commons.compress.utils.Lists;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.Workbook;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.ClassPathResource;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -52,8 +64,6 @@
     private LWhFormOutputServiceImpl lWhFormOutputService;
     @Autowired
     private LWhProcureModelService lWhProcureModelService;
-    @Autowired
-    private LWhGoodsService lWhGoodsService;
     @Resource
     private LWarehouseFlowService lWarehouseFlowService;
 
@@ -64,7 +74,7 @@
      */
     @ApiOperation(value = "鏂板鍑哄簱鍗�", notes = "鏂板鍑哄簱鍗�")
     @ApiImplicitParams({
-        @ApiImplicitParam(name = "param", value = "鍑哄簱鍗曞疄浣�", required = true, dataType = "LWhFormOutputInsertParam", paramType = "body")
+        @ApiImplicitParam(name = "param", value = "鍑哄簱鍗曞疄浣�", dataType = "lWhFormOutputParam", dataTypeClass = LWhFormOutputParam.class, paramType = "body")
     })
     @PostMapping("/add")
     public ResponseValue add() {
@@ -129,8 +139,9 @@
         }
         try {
             Field fieldDatas = GenericPager.class.getDeclaredField("datas");
-            fieldDatas.setAccessible(true);
-            fieldDatas.set(genericPager, resultList);
+//            fieldDatas.setAccessible(true);
+//            fieldDatas.set(genericPager, resultList);
+            ReflectUtil.setFieldValue(genericPager, fieldDatas, resultList);
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -182,7 +193,6 @@
     }
 
 
-
     @ApiOperation(value = "鏌ヨ鍑哄簱鍗曡鎯呮槑缁�", notes = "鏌ヨ鍑哄簱鍗曡鎯呮槑缁�")
     @ApiImplicitParam(name = "formOutputQry", value = "鍑哄簱鍗曡鎯呮煡璇㈡潯浠�", required = true, dataType = "LWhFormOutputQry", paramType = "query")
     @GetMapping("/detail/list")
@@ -192,8 +202,46 @@
         if (currentUser == null) {
             return ResponseValue.error("鐧诲綍鐢ㄦ埛淇℃伅涓嶅瓨鍦�");
         }
-        GenericPager<Map<String, Object>> mapGenericPager = lWarehouseFlowService.queryBusinessFlowDetail(formOutputQry);
-        return ResponseValue.success(mapGenericPager);
+        PageUtil genericPager = lWarehouseFlowService.queryAllBusinessFlow(formOutputQry);
+        return ResponseValue.success(genericPager);
+    }
+
+
+    @ApiOperation(value = "鍑哄簱鍗曞鍑�", notes = "鍑哄簱鍗曞鍑�")
+    @GetMapping("/list/export")
+    public void export(Long id, HttpServletResponse response) throws IOException {
+        ClassPathResource classPathResource = new ClassPathResource("import/閲囪喘閫�璐у崟.xls");
+        // 鑾峰彇鏂囦欢杈撳叆娴�
+        InputStream inputStream = classPathResource.getInputStream();
+        Workbook wb = new HSSFWorkbook(inputStream);
+        TemplateExportParams params = new TemplateExportParams();
+        params.setTemplateWb(wb);
+
+        FinSysTenantUser sysInfo = this.getSysInfo();
+        String userName = sysInfo.getUserName();
+
+        Map<String, Object> map = lWhFormOutputService.getExportList(id, userName);
+        if (CollectionUtils.isEmpty(map)) {
+            throw new RuntimeException("鏁版嵁涓虹┖");
+        }
+
+        Workbook workbook = ExcelExportUtil.exportExcel(params, map);
+        downLoadExcel("閲囪喘閫�璐у崟", response, workbook);
+
+    }
+
+    private void downLoadExcel(String fileName, HttpServletResponse response, Workbook workbook) {
+        try (OutputStream out = response.getOutputStream()) {
+            response.setCharacterEncoding("UTF-8");
+            response.setHeader("content-Type", "application/vnd.ms-excel");
+            response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName + ".xls", "UTF-8"));
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            workbook.write(baos);
+            response.setHeader("Content-Length", String.valueOf(baos.size()));
+            out.write(baos.toByteArray());
+        } catch (Exception e) {
+            logger.error("瀵煎嚭鏂囦欢澶辫触", e);
+        }
     }
 
 }

--
Gitblit v1.9.1