From a77b79d76907fa6a804ad0c66e372dd34e277ccd Mon Sep 17 00:00:00 2001 From: zyx <zyx123456> Date: 星期一, 22 一月 2024 17:31:56 +0800 Subject: [PATCH] # 导出更新 --- src/main/java/com/zy/asrs/controller/LocDetlController.java | 47 +++++++++++++++++++++++++---------------------- 1 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/zy/asrs/controller/LocDetlController.java b/src/main/java/com/zy/asrs/controller/LocDetlController.java index cf08cdd..3ab417a 100644 --- a/src/main/java/com/zy/asrs/controller/LocDetlController.java +++ b/src/main/java/com/zy/asrs/controller/LocDetlController.java @@ -1,7 +1,5 @@ package com.zy.asrs.controller; -import com.alibaba.excel.EasyExcel; -import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.mapper.EntityWrapper; @@ -21,9 +19,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.net.URLEncoder; import java.util.*; @RestController @@ -256,24 +251,32 @@ @Autowired private LocDetlMapper LocDetlMapper; +// @RequestMapping(value = "/locDetl/statis/export") +//// @ManagerAuth +// public void statisExport(HttpServletResponse response) throws IOException { +// List<LocDetl> excel = LocDetlMapper.getStockStatisExcel(); +// for (LocDetl locDetl : excel) { +// Mat mat = matService.selectByMatnr(locDetl.getMatnr()); +// if (mat != null) { +// locDetl.sync(mat); +// } +// } +// response.setContentType("application/vnd.ms-excel"); +// response.setCharacterEncoding("utf-8"); +// String fileName = URLEncoder.encode("搴撳瓨鏄庣粏缁熻鎶ヨ〃", "UTF-8"); +// response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); +// EasyExcel.write(response.getOutputStream(), LocDetl.class) +// .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) +// .sheet("琛�1") +// .doWrite(excel); +// } + @RequestMapping(value = "/locDetl/statis/export") -// @ManagerAuth - public void statisExport(HttpServletResponse response) throws IOException { - List<LocDetl> excel = LocDetlMapper.getStockStatisExcel(); - for (LocDetl locDetl : excel) { - Mat mat = matService.selectByMatnr(locDetl.getMatnr()); - if (mat != null) { - locDetl.sync(mat); - } - } - response.setContentType("application/vnd.ms-excel"); - response.setCharacterEncoding("utf-8"); - String fileName = URLEncoder.encode("搴撳瓨鏄庣粏缁熻鎶ヨ〃", "UTF-8"); - response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); - EasyExcel.write(response.getOutputStream(), LocDetl.class) - .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) - .sheet("琛�1") - .doWrite(excel); + @ManagerAuth(memo = "搴撲綅鏄庣粏瀵煎嚭") + public synchronized R statisExport(@RequestBody JSONObject param){ + List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class); + List<LocDetl> stockStatisExcel = LocDetlMapper.getStockStatisExcel(); + return R.ok(exportSupport(stockStatisExcel, fields)); } /** -- Gitblit v1.9.1