update 电单车

This commit is contained in:
Guoqs
2024-09-20 14:57:46 +08:00
parent 00b442572a
commit 0c1447c49e
3 changed files with 23 additions and 4 deletions

View File

@@ -102,12 +102,17 @@ public interface PileBillingTemplateService {
List<BillingTemplateVO> queryStationBillingTemplateListForUniApp(String stationId);
/**
* 查询正在使用中的计费模板
* 查询正在使用中的汽车桩计费模板
* @param stationId 站点id
* @return
*/
BillingTemplateVO queryUsedBillingTemplateForEV(String stationId);
/**
* 查询正在使用中的电单车桩计费模板
* @param stationId 站点id
* @return
*/
BillingTemplateVO queryUsedBillingTemplateForEBike(String stationId);
List<BillingPriceVO> conversionParameters(List<BillingDetailVO> billingDetailList);

View File

@@ -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 {