| | |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiResponse; |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.net.URLEncoder; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | } |
| | | |
| | | @ApiOperation(value = "盘点单导出", notes = "盘点单导出") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "盘点单id", dataType = "Long", required = true, paramType = "query") |
| | | }) |
| | | @GetMapping("/list/export") |
| | | public void export(Long id, HttpServletResponse response) throws IOException { |
| | | public void export(Long id, HttpServletResponse response) throws Exception { |
| | | |
| | | List<InventoryExcelTemplate> exportList = lWhFormInventoryService.getExportList(id); |
| | | if (CollectionUtils.isEmpty(exportList)) { |
| | |
| | | exportList, 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); |
| | | } |
| | | } |
| | | |
| | | |