@GetMapping("/export")
@ResponseBody
public Map<String, Object> export(HttpServletRequest request, HttpServletResponse response, RefundReq req) throws IOException {
logger.info("refunded invoice get params : " + JsonUtils.toJson(req));
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8");
String fileName = URLEncoder.encode("行业退票列表", "UTF-8");
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xls");
Map<String, Object> resultMap = new HashMap<>();
try {
List<TRefundInvoice> exportList = refundInvoiceService.getExportList(req);
List<RefundExportVo> dataList = new ArrayList<>(exportList.size());
for (int i = 0; i < exportList.size(); i++) {
RefundExportVo excelRow = new RefundExportVo();
excelRow.setId(exportList.get(i).getId());
excelRow.setInvoiceNo(exportList.get(i).getInvoiceNo());
excelRow.setInvoiceAmount(exportList.get(i).getInvoiceAmount());
excelRow.setRefundResonContent(exportList.get(i).getRefundResonContent());
excelRow.setStatus(exportList.get(i).getStatus());
excelRow.setCreateTime(exportList.get(i).getCreateTime());
dataList.add(excelRow);
}
EasyExcel.write(response.getOutputStream(), RefundExportVo.class).sheet("退票列表").doWrite(dataList);
resultMap.put("code", 0);
resultMap.put("msg", "导出成功 ! ");
return resultMap;
} catch (IOException e) {
logger.error("RefundInvoice export exception... " + e);
resultMap.put("code", 1);
resultMap.put("msg", "导出失败 ");
}
return resultMap;
}