diff --git a/jsowell-admin/src/test/java/SpringBootTestController.java b/jsowell-admin/src/test/java/SpringBootTestController.java index bf2909e90..2b49fa1b8 100644 --- a/jsowell-admin/src/test/java/SpringBootTestController.java +++ b/jsowell-admin/src/test/java/SpringBootTestController.java @@ -3372,7 +3372,7 @@ public class SpringBootTestController { public void testGenerateBillingTemplateMsgBody() { String pileSn = "13273881"; // 根据桩号查询计费模板 - BillingTemplateVO billingTemplateVO = pileBillingTemplateService.selectBillingTemplateDetailByPileSn(pileSn); + BillingTemplateVO billingTemplateVO = pileBillingTemplateService.queryUsedBillingTemplateForEBike("2"); System.out.println(billingTemplateVO); // byte[] messageBody = pileBillingTemplateService.generateBillingTemplateMsgBody(pileSn, billingTemplateVO); // System.out.println(BytesUtil.binary(messageBody, 16)); diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/PileBillingTemplateService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/PileBillingTemplateService.java index b017255a9..5fe855f86 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/PileBillingTemplateService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/PileBillingTemplateService.java @@ -102,12 +102,17 @@ public interface PileBillingTemplateService { List queryStationBillingTemplateListForUniApp(String stationId); /** - * 查询正在使用中的计费模板 + * 查询正在使用中的汽车桩计费模板 * @param stationId 站点id * @return */ BillingTemplateVO queryUsedBillingTemplateForEV(String stationId); + /** + * 查询正在使用中的电单车桩计费模板 + * @param stationId 站点id + * @return + */ BillingTemplateVO queryUsedBillingTemplateForEBike(String stationId); List conversionParameters(List billingDetailList); diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/PileRemoteService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/PileRemoteService.java index 5027ec6b5..3fd57572d 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/PileRemoteService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/PileRemoteService.java @@ -133,7 +133,17 @@ public class PileRemoteService { */ public void remoteStartChargingEBike(String pileSn, String connectorCode, String transactionCode, BigDecimal chargeAmount) { if (StringUtils.isEmpty(pileSn) || StringUtils.isEmpty(connectorCode)) { - log.warn("远程启动充电, 充电桩编号和枪口号不能为空"); + log.error("电单车远程启动充电, 充电桩编号和枪口号不能为空"); + return; + } + PileDetailVO pileDetailVO = pileBasicInfoService.selectPileDetailByPileSn(pileSn); + if (pileDetailVO == null) { + log.error("电单车远程启动充电, 充电桩:{}查询不能为空", pileSn); + return; + } + BillingTemplateVO billingTemplateVO = pileBillingTemplateService.queryUsedBillingTemplateForEBike(pileDetailVO.getStationId()); + if (billingTemplateVO == null) { + log.error("电单车远程启动充电, 站点id:{}, 充电桩:{}, 没有配置计费模板", pileDetailVO.getStationId(), pileSn); return; } log.info("【=====平台下发指令=====】: 电单车远程启动充电, 桩号:{}, 枪口号:{}", pileSn, connectorCode); @@ -141,11 +151,15 @@ public class PileRemoteService { startChargingCommand.setPileSn(pileSn); startChargingCommand.setConnectorCode(connectorCode); startChargingCommand.setTransactionCode(transactionCode); - startChargingCommand.setChargeAmount(chargeAmount); // 电单车这个字段表示具体度数 + startChargingCommand.setChargeAmount(chargeAmount); // 支付金额 startChargingCommand.setRateMode(2); // 根据启动金额计算电量 + BigDecimal flatElectricityPrice = billingTemplateVO.getFlatElectricityPrice(); BigDecimal electricity = BigDecimal.ZERO; + if (flatElectricityPrice.compareTo(BigDecimal.ZERO) > 0) { + electricity = chargeAmount.divide(flatElectricityPrice, 2, BigDecimal.ROUND_HALF_UP); + } startChargingCommand.setElectricity(electricity); try {