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 | 101 ++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 96 insertions(+), 5 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 7f4ca4e..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
@@ -15,9 +15,11 @@
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
+import com.ruoyi.order.api.model.ExportUidDto;
import com.ruoyi.order.api.model.TChargingBill;
import com.ruoyi.order.api.model.TChargingOrder;
import com.ruoyi.order.api.query.TOrderInvoiceQuery;
+import com.ruoyi.order.api.vo.AccountListVO;
import com.ruoyi.order.api.vo.ChargingBillListVO;
import com.ruoyi.order.api.vo.ChargingBillVO;
import com.ruoyi.order.api.model.ChargingListQuery;
@@ -66,7 +68,26 @@
@Resource
private TChargingOrderService chargingOrderService;
+ @PostMapping(value = "/accountBillList")
+ @ApiOperation(value = "列表查询", tags = {"管理后台-账户结算账单"})
+ public R<AccountListVO> accountBillList(@RequestBody ChargingListQuery dto) {
+ AccountListVO accountListVO = new AccountListVO();
+ ChargingBillVO res = chargingBillService.chargingBillList1(dto);
+ ChargingBillVO res1 = chargingBillService.chargingBillList1(dto);
+ List<ChargingBillListVO> records = res1.getList().getRecords();
+ accountListVO.setBillCount(records.size());
+ 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());
+ accountListVO.setSharingAmount(res1.getSharingAmount());
+ accountListVO.setList(res.getList());
+ return R.ok(accountListVO);
+ }
@PostMapping(value = "/chargingBillList")
@ApiOperation(value = "充电算帐单列表查询", tags = {"管理后台-充电算账单"})
public AjaxResult<ChargingBillVO> chargingBillList(@RequestBody ChargingListQuery dto) {
@@ -83,7 +104,7 @@
return R.ok(null);
}
@ApiOperation(value = "导出", tags = {"管理后台-充电算账单"})
- @PostMapping("/export")
+ @PutMapping("/export")
public void export(@RequestBody ChargingListQuery dto)
{
ChargingBillVO res = chargingBillService.chargingBillList(dto);
@@ -128,7 +149,77 @@
response.setCharacterEncoding("utf-8");
ServletOutputStream outputStream = null;
try {
- String fileName = URLEncoder.encode("发票导出.xls", "utf-8");
+ 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("/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");
@@ -146,13 +237,13 @@
}
}
@ApiOperation(value = "下载-未出账", tags = {"管理后台-充电算账单"})
- @GetMapping("/download")
- public void download(String uid)
+ @PutMapping("/download")
+ public void download(@RequestBody ExportUidDto uid)
{
List<ChargingBillExport> chargingBillExports = new ArrayList<>();
List<ChargingBillRefundExport> chargingBillRefundExports = new ArrayList<>();
List<ChargingBillPayExport> chargingBillPayExports = new ArrayList<>();
- TChargingBill byId = chargingBillService.getById(uid);
+ TChargingBill byId = chargingBillService.getById(uid.getUid());
ChargingBillExport chargingBillExport = new ChargingBillExport();
chargingBillExport.setCode(byId.getCode());
// todo 确认商户类型
--
Gitblit v1.7.1