From 5c2a3cdd8bce78f25bbaa4f13947760f2d0d9411 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期二, 10 九月 2024 13:01:37 +0800 Subject: [PATCH] 代码提交 --- ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ChargingBillController.java | 74 ++++++++++++++++++++++++++++++++++++- 1 files changed, 72 insertions(+), 2 deletions(-) diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ChargingBillController.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ChargingBillController.java index a83c82d..84f0aba 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ChargingBillController.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ChargingBillController.java @@ -71,9 +71,9 @@ @ApiOperation(value = "列表查询", tags = {"管理后台-账户结算账单"}) public R<AccountListVO> accountBillList(@RequestBody ChargingListQuery dto) { AccountListVO accountListVO = new AccountListVO(); - ChargingBillVO res = chargingBillService.chargingBillList(dto); + ChargingBillVO res = chargingBillService.chargingBillList1(dto); - ChargingBillVO res1 = chargingBillService.chargingBillList(dto); + ChargingBillVO res1 = chargingBillService.chargingBillList1(dto); List<ChargingBillListVO> records = res1.getList().getRecords(); accountListVO.setBillCount(records.size()); accountListVO.setTotalAmount(res1.getPaymentAmount().subtract(res1.getRefundAmount()).subtract(res1.getCommissionAmount()).subtract(res1.getSharingAmount())); @@ -162,6 +162,76 @@ } } } + @ApiOperation(value = "导出", tags = {"管理后台-账户结算账单"}) + @PostMapping("/exportAccount") + public void exportAccount(@RequestBody ChargingListQuery dto) + { + ChargingBillVO res = chargingBillService.chargingBillList1(dto); + List<ChargingBillListVO> list = res.getList().getRecords(); + List<TChargingBillExport> tChargingBillExports = new ArrayList<>(); + for (ChargingBillListVO orderInvoiceVO : list) { + TChargingBillExport tChargingBillExport = new TChargingBillExport(); + tChargingBillExport.setCode(orderInvoiceVO.getCode()); + switch (orderInvoiceVO.getTimeType()){ + case 1: + tChargingBillExport.setBillType("日账单"); + break; + case 2: + tChargingBillExport.setBillType("月账单"); + break; + } + tChargingBillExport.setType(orderInvoiceVO.getType().toString()); + tChargingBillExport.setBillWeek(orderInvoiceVO.getBillWeek()); + tChargingBillExport.setSiteName(orderInvoiceVO.getSiteName()); + tChargingBillExport.setPaymentAmount(orderInvoiceVO.getPaymentAmount()); + tChargingBillExport.setElectrovalence(orderInvoiceVO.getElectrovalence()); + tChargingBillExport.setServiceCharge(orderInvoiceVO.getServiceCharge()); + tChargingBillExport.setChargingCapacity(orderInvoiceVO.getChargingCapacity()); + Integer chargingSecond = orderInvoiceVO.getChargingSecond(); + // 根据秒数 转换为xx小时xx分钟xx秒 如果小时为0不展示 如果分钟为0则不展示 + // 计算小时、分钟和秒 + int hours = chargingSecond / 60 / 60; + int minutes = chargingSecond /60 % 60; + int seconds = 0; // 如果没有秒数,则默认是0 + // 构造结果字符串 + StringBuilder result = new StringBuilder(); + if (hours > 0) { + result.append(hours).append("小时"); + } + if (minutes > 0) { + result.append(minutes).append("分钟"); + } + if (seconds > 0 || result.length() == 0) { // 如果秒数大于0,或者小时和分钟都为0,则显示秒数 + result.append(seconds).append("秒"); + } + tChargingBillExport.setChargingTime(result.toString()); + tChargingBillExport.setOrderCount(orderInvoiceVO.getOrderCount()); + tChargingBillExport.setBillTime(orderInvoiceVO.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); + tChargingBillExports.add(tChargingBillExport); + } + Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TChargingBillExport.class, tChargingBillExports); + HttpServletResponse response = WebUtils.response(); + response.setContentType("application/vnd.ms-excel"); + response.setCharacterEncoding("utf-8"); + ServletOutputStream outputStream = null; + try { + String fileName = URLEncoder.encode("月账单-"+res.getCategory()+"-"+res.getBillWeek()+"-"+res.getSiteName()+".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 { + outputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } @ApiOperation(value = "下载-未出账", tags = {"管理后台-充电算账单"}) @GetMapping("/download") public void download(String uid) -- Gitblit v1.7.1