| | |
| | | import com.ruoyi.order.api.vo.*; |
| | | import com.ruoyi.order.export.*; |
| | | import com.ruoyi.order.service.*; |
| | | import com.ruoyi.order.util.task.TaskUtil; |
| | | import com.ruoyi.order.vo.StatisticsOfBatteryVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.time.YearMonth; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.time.temporal.TemporalAdjusters; |
| | | import java.util.*; |
| | |
| | | private TChargingOrderRefundService tChargingOrderRefundService; |
| | | @Resource |
| | | private TChargingBillService tChargingBillService; |
| | | @Resource |
| | | private TaskUtil taskUtil; |
| | | |
| | | @RequiresPermissions(value = {"/chargeBill"}, logical = Logical.OR) |
| | | @PostMapping(value = "/generate") |
| | | @ApiOperation(value = "主动生成指定月份未出账充电结算账单", tags = {"管理后台-充电算账单"}) |
| | | public R generateChargingBill(@RequestParam(value = "billingMonth", required = false) String billingMonth) { |
| | | YearMonth targetMonth = billingMonth != null && !billingMonth.trim().isEmpty() |
| | | ? YearMonth.parse(billingMonth.trim()) : YearMonth.now(); |
| | | if (targetMonth.isAfter(YearMonth.now())) { |
| | | return R.fail("不能生成未来月份账单"); |
| | | } |
| | | taskUtil.refreshChargingSettlementBill(targetMonth.atDay(1)); |
| | | return R.ok(); |
| | | } |
| | | @GetMapping(value = "/test") |
| | | public R accountAdd() { |
| | | // List<TChargingBill> list = tChargingBillService.lambdaQuery().list(); |
| | |
| | | tChargingBillExport.setType(orderInvoiceVO.getType().toString()); |
| | | tChargingBillExport.setBillWeek(orderInvoiceVO.getBillWeek()); |
| | | tChargingBillExport.setSiteName(orderInvoiceVO.getSiteName()); |
| | | tChargingBillExport.setPaymentAmount(orderInvoiceVO.getPaymentAmount()); |
| | | tChargingBillExport.setPaymentAmount(orderInvoiceVO.getOrderAmount()); |
| | | tChargingBillExport.setPlatformIncome(orderInvoiceVO.getPlatformIncome()); |
| | | tChargingBillExport.setPartnerIncome(orderInvoiceVO.getPartnerIncome()); |
| | | tChargingBillExport.setElectrovalence(orderInvoiceVO.getElectrovalence()); |
| | |
| | | dto.setPageSize(100000); |
| | | AccountListVO res = chargingBillService.accountSettlementBillList(dto); |
| | | List<ChargingBillListVO> list = res.getList().getRecords(); |
| | | List<TChargingBillExport> tChargingBillExports = new ArrayList<>(); |
| | | List<TAccountSettlementBillExport> tChargingBillExports = new ArrayList<>(); |
| | | for (ChargingBillListVO orderInvoiceVO : list) { |
| | | TChargingBillExport tChargingBillExport = new TChargingBillExport(); |
| | | TAccountSettlementBillExport tChargingBillExport = new TAccountSettlementBillExport(); |
| | | tChargingBillExport.setCode(orderInvoiceVO.getCode()); |
| | | switch (orderInvoiceVO.getOrderState()){ |
| | | case 1: |
| | |
| | | tChargingBillExport.setBillType("月账单"); |
| | | break; |
| | | } |
| | | tChargingBillExport.setType(orderInvoiceVO.getType().toString()); |
| | | tChargingBillExport.setType(Integer.valueOf(1).equals(orderInvoiceVO.getType()) ? "全站账单" : "站点账单"); |
| | | tChargingBillExport.setBillWeek(orderInvoiceVO.getBillWeek()); |
| | | tChargingBillExport.setAccountType("工商银行商户"); |
| | | tChargingBillExport.setSiteName(orderInvoiceVO.getSiteName()); |
| | | tChargingBillExport.setPaymentAmount(orderInvoiceVO.getPaymentAmount()); |
| | | tChargingBillExport.setRefundAmount(orderInvoiceVO.getRefundAmount()); |
| | | tChargingBillExport.setPlatformIncome(orderInvoiceVO.getPlatformIncome()); |
| | | tChargingBillExport.setPartnerIncome(orderInvoiceVO.getPartnerIncome()); |
| | | tChargingBillExport.setElectrovalence(orderInvoiceVO.getElectrovalence()); |
| | | tChargingBillExport.setServiceCharge(orderInvoiceVO.getServiceCharge()); |
| | | tChargingBillExport.setChargingCapacity(orderInvoiceVO.getChargingCapacity()); |
| | | Integer chargingSecond = Optional.ofNullable(orderInvoiceVO.getChargingSecond()).orElse(0); |
| | | // 根据秒数 转换为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() == null ? "-" |
| | | : orderInvoiceVO.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | tChargingBillExports.add(tChargingBillExport); |
| | | } |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TChargingBillExport.class, tChargingBillExports); |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TAccountSettlementBillExport.class, tChargingBillExports); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |