黎星凯
2024-04-15 62b6a7fac3f2acde70b578431147c4a01f19c182
consum-base/src/main/java/com/consum/base/controller/DepFormScrappedController.java
@@ -146,7 +146,7 @@
    @ApiOperation(value = "导出报废单", notes = "导出报废单")
    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "报废单id", 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("报废单id为空");
        }
@@ -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")