From 4fd0278cda787a91eb35d95d6491f5485afe3e48 Mon Sep 17 00:00:00 2001 From: zhibing.pu <393733352@qq.com> Date: 星期六, 07 九月 2024 18:03:32 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TApplyChargingPileController.java | 35 +++++++++++++++++++++++++++++++++++ 1 files changed, 35 insertions(+), 0 deletions(-) diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TApplyChargingPileController.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TApplyChargingPileController.java index 22b010c..c1e071b 100644 --- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TApplyChargingPileController.java +++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TApplyChargingPileController.java @@ -42,6 +42,7 @@ import com.ruoyi.order.api.feignClient.ChargingOrderClient; import com.ruoyi.order.api.model.ChargingListQuery; import com.ruoyi.order.api.vo.ChargingBillVO; +import com.ruoyi.order.api.vo.SettlementTotalVO; import io.swagger.annotations.ApiOperation; import org.apache.commons.codec.CharEncoding; import org.springframework.beans.BeanUtils; @@ -281,7 +282,41 @@ } return R.ok(); } + @ApiOperation(value = "导出", tags = {"管理后台-结算汇总表"}) + @GetMapping("/downloadSettlementTotal") + public R downloadSettlementTotal(String time,HttpServletResponse response) + { + SettlementTotalVO data = chargingOrderClient.settlementTotalR(time).getData(); + + try { + response.setCharacterEncoding(Constants.UTF8); + response.setContentType("application/vnd.ms-excel"); + response.setHeader("Access-Control-Expose-Headers", "Content-disposition"); + response.setHeader("Content-Disposition", "attachment;filename=" + + URLEncoder.encode("结算确认单", CharEncoding.UTF_8) + ".xlsx"); + } catch (UnsupportedEncodingException e) { + return R.fail("excel导出失败!"); + } + try { + // excel模板封装 + ExcelWriterBuilder excelWriterBuilder = EasyExcelFactory.write(response.getOutputStream()); + InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("template/" +"运营商名称1-充电桩名称1-结算对账单明细-结算月份1" + ".xlsx"); + // 自动释放资源 + try (ExcelWriter excelWriter = excelWriterBuilder.withTemplate(stream).build()) { + WriteSheet writeSheet = EasyExcel.writerSheet().build(); + FillConfig fillConfig = FillConfig.builder().direction(WriteDirectionEnum.VERTICAL).build(); + excelWriter.fill(new FillWrapper("data1", data.getList1()), fillConfig, writeSheet); + excelWriter.fill(new FillWrapper("data2", data.getList2()), fillConfig, writeSheet); + excelWriter.finish(); + } catch (Exception e) { + return R.fail("excel导出失败!"); + } + } catch (IOException e) { + return R.fail("excel导出失败!"); + } + return R.ok(); + } @ApiOperation(value = "下载", tags = {"管理后台-结算表记录"}) @GetMapping("/downloadSettlement") public R downloadSettlement(String uid,HttpServletResponse response) -- Gitblit v1.7.1