| | |
| | | package com.consum.base.controller; |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import com.consum.base.BaseController; |
| | | 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.LWhFormScrappedParam; |
| | | import com.consum.base.pojo.excel.ScrappedInfoExport; |
| | | import com.consum.base.pojo.query.LWhFormScrappedQry; |
| | | import com.consum.base.pojo.response.FromTransferTemplateInfoVO; |
| | | import com.consum.base.pojo.response.LWhFormScrappedExtendVO; |
| | |
| | | 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 javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import org.apache.commons.compress.utils.Lists; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | |
| | | */ |
| | | @ApiOperation(value = "新增报废单", notes = "新增报废单") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "param", value = "报废单信息", dataType = "LWhFormScrappedParam", paramType = "body") |
| | | @ApiImplicitParam(name = "param") |
| | | }) |
| | | @PostMapping("/add") |
| | | public ResponseValue add(@RequestBody LWhFormScrappedParam param) { |
| | |
| | | * @Date 2023/11/2 |
| | | */ |
| | | @GetMapping("/export") |
| | | public ResponseValue export(Long id) { |
| | | public ResponseValue export(Long id, HttpServletRequest request, HttpServletResponse response) { |
| | | if (id == null) { |
| | | return ResponseValue.error("报废单id为空"); |
| | | } |
| | | //LWhFormScrappedExtendVO scrappedExtend = this.lWhFormScrappedService.export(id, this.getSysInfo()); |
| | | return ResponseValue.success(null); |
| | | try { |
| | | OutputStream outputStream = response.getOutputStream(); |
| | | List<Map<String, Object>> export = lWhFormScrappedService.export(id); |
| | | ExportParams exportParams = new ExportParams("报废单登记", "报废单登记"); |
| | | Workbook sheets = ExcelExportUtil.exportExcel(exportParams, ScrappedInfoExport.class, export); |
| | | // 设置响应头 |
| | | 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); |
| | | } |
| | | return ResponseValue.success(); |
| | | } |
| | | |
| | | |