From 35e2ef0acc864f44cc99cc2c946ec78b4e5535e6 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期三, 25 九月 2024 11:23:31 +0800
Subject: [PATCH] 工作台修改
---
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ChargingBillController.java | 79 ++++++++++++++++++++++++++++++++++++++-
1 files changed, 76 insertions(+), 3 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 d491088..d9b3c8d 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
@@ -72,12 +72,15 @@
@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()));
+ accountListVO.setTotalAmount(
+ res1.getPaymentAmount().subtract(res1.getRefundAmount()==null?BigDecimal.ZERO:res1.getRefundAmount())
+ .subtract(res1.getCommissionAmount()==null?BigDecimal.ZERO:res1.getCommissionAmount())
+ .subtract(res1.getSharingAmount()==null?BigDecimal.ZERO:res1.getSharingAmount()));
accountListVO.setPaymentAmount(res1.getPaymentAmount());
accountListVO.setRefundAmount(res1.getRefundAmount());
accountListVO.setCommissionAmount(res1.getCommissionAmount());
@@ -163,6 +166,76 @@
}
}
}
+ @ApiOperation(value = "导出", tags = {"管理后台-账户结算账单"})
+ @PutMapping("/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.getOrderState()){
+ 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 = {"管理后台-充电算账单"})
@PutMapping("/download")
public void download(@RequestBody ExportUidDto uid)
--
Gitblit v1.7.1