无关风月
2024-09-07 1725e64e39e120a94c694b7c18ed313c98a411ba
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TApplyChargingPileController.java
@@ -2,6 +2,7 @@
import java.math.BigDecimal;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.order.api.model.TChargingOrder;
import com.ruoyi.order.api.model.TSettlementConfirm;
import com.ruoyi.order.api.vo.ChargingBillListVO;
@@ -272,6 +273,47 @@
        }
        return R.ok();
    }
    @ApiOperation(value = "下载", tags = {"管理后台-结算表记录"})
    @GetMapping("/downloadSettlement")
    public R downloadSettlement(String uid,HttpServletResponse response)
    {
        TSettlementConfirm data = chargingOrderClient.downloadSettlement(uid).getData();
        List<TSettlementConfirm> chargingBillVOS = new ArrayList<>();
        chargingBillVOS.add(data);
        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.HORIZONTAL).build();
                excelWriter.fill(new FillWrapper("data1", chargingBillVOS), fillConfig, writeSheet);
                excelWriter.fill(new FillWrapper("data2", chargingBillVOS), 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("/download")
    public R download(String uid,HttpServletResponse response)