| | |
| | | package com.ruoyi.system.controller; |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.system.query.ComplainListReq; |
| | | import com.ruoyi.system.query.ComplainListResp; |
| | | import com.ruoyi.system.service.IComplainService; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | |
| | | return R.ok(page); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/exportComplainList") |
| | | @ApiOperation(value = "导出投诉记录列表", tags = {"投诉记录"}) |
| | | public void exportComplainList(ComplainListReq complainListReq, HttpServletResponse response) { |
| | | complainListReq.setPageSize(99999); |
| | | PageInfo<ComplainListResp> page = complainService.getComplainList(complainListReq); |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), ComplainListResp.class, page.getRecords()); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("投诉记录.xls", "utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | workbook.close(); |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |