mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 03:25:12 +08:00
update 新增 0xA4平台主动下发并充充电指令
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package com.jsowell.pile.domain.ykcCommond;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 远程启动并充充电指令 0xA4
|
||||
*
|
||||
* @author Lemon
|
||||
* @Date 2025/8/6 8:52:34
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class StartMergeChargeCommand {
|
||||
|
||||
// 桩编号
|
||||
public String pileSn;
|
||||
|
||||
// 枪口号
|
||||
public String connectorCode;
|
||||
|
||||
// 交易流水号
|
||||
public String transactionCode;
|
||||
|
||||
// 逻辑卡号
|
||||
public String logicCardCode;
|
||||
|
||||
// 物理卡号
|
||||
public String physicsCardCode;
|
||||
|
||||
// 账户余额
|
||||
public BigDecimal accountAmount;
|
||||
|
||||
// 并充序号
|
||||
public String mergeChargeCode;
|
||||
}
|
||||
@@ -589,4 +589,13 @@ public interface OrderBasicInfoService{
|
||||
* @return
|
||||
*/
|
||||
List<SupStationStatsVO> queryOrderListByStationIdAndTime(String stationId , String startTime , String endTime);
|
||||
|
||||
/**
|
||||
* 充电桩启动成功
|
||||
* 汽车桩收到0xA3 成功后调用
|
||||
* @param transactionCode 交易流水号
|
||||
* @param pileConnectorCode 枪口号
|
||||
* @param connectorMark 主辅枪标记
|
||||
*/
|
||||
void chargingPileStartedSuccessfully(String transactionCode, String pileConnectorCode, String connectorMark);
|
||||
}
|
||||
|
||||
@@ -129,6 +129,33 @@ public class PileRemoteService {
|
||||
ykcPushCommandService.pushStartChargingCommand(startChargingCommand);
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程启动并充充电 0xA4
|
||||
* @param pileSn
|
||||
* @param connectorCode
|
||||
* @param transactionCode
|
||||
* @param chargeAmount
|
||||
*/
|
||||
public void remoteStartMergeCharging(String pileSn, String connectorCode, String transactionCode,
|
||||
BigDecimal chargeAmount, String mergeChargeCode) {
|
||||
if (StringUtils.isEmpty(pileSn) || StringUtils.isEmpty(connectorCode)) {
|
||||
log.warn("远程启动充电, 充电桩编号和枪口号不能为空");
|
||||
log.info("【=====平台下发指令=====】: 远程启动并充充电, 桩号:{}, 枪口号:{}", pileSn, connectorCode);
|
||||
|
||||
StartMergeChargeCommand command = StartMergeChargeCommand.builder()
|
||||
.pileSn(pileSn)
|
||||
.connectorCode(connectorCode)
|
||||
// .logicCardCode()
|
||||
.transactionCode(transactionCode)
|
||||
// .physicsCardCode()
|
||||
.accountAmount(chargeAmount)
|
||||
.mergeChargeCode(mergeChargeCode)
|
||||
|
||||
.build();
|
||||
ykcPushCommandService.pushStartMergeChargingCommand(command);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 电单车远程启动充电
|
||||
*/
|
||||
|
||||
@@ -86,4 +86,9 @@ public interface YKCPushCommandService {
|
||||
*/
|
||||
byte[] pushReservationChargingCommand(ReservationChargingCommand command);
|
||||
|
||||
/**
|
||||
* 发送并充充电指令
|
||||
* @param command
|
||||
*/
|
||||
void pushStartMergeChargingCommand(StartMergeChargeCommand command);
|
||||
}
|
||||
|
||||
@@ -640,6 +640,35 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 充电桩启动成功
|
||||
* 汽车桩收到0xA3 成功后调用
|
||||
* @param transactionCode
|
||||
*/
|
||||
@Override
|
||||
public void chargingPileStartedSuccessfully(String transactionCode, String pileConnectorCode, String connectorMark) {
|
||||
// OrderBasicInfo orderInfo = getOrderInfoByOrderCode(orderCode);
|
||||
OrderBasicInfo orderInfo = getOrderInfoByTransactionCode(transactionCode);
|
||||
if (orderInfo == null) {
|
||||
return;
|
||||
}
|
||||
// 启动成功,订单状态改为充电中
|
||||
orderInfo.setOrderStatus(OrderStatusEnum.IN_THE_CHARGING.getValue());
|
||||
if (orderInfo.getChargeStartTime() == null) {
|
||||
orderInfo.setChargeStartTime(new Date());
|
||||
}
|
||||
if (StringUtils.equals(Constants.DOUBLE_ZERO, connectorMark)) {
|
||||
// 主枪
|
||||
orderInfo.setMainConnectorCode(pileConnectorCode);
|
||||
}
|
||||
updateOrderBasicInfo(orderInfo);
|
||||
// 判断是否要向小程序发送通知
|
||||
if (StringUtils.isNotEmpty(orderInfo.getMemberId())){
|
||||
// 发送小程序通知
|
||||
wxAppletRemoteService.startChargingSendMsg(orderInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭启动失败订单
|
||||
*
|
||||
@@ -4251,7 +4280,14 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
||||
pileRemoteService.remoteStartChargingEBike(pileSn, orderInfo.getConnectorCode(), orderInfo.getTransactionCode(), chargeAmount);
|
||||
} else {
|
||||
// 电动汽车桩
|
||||
pileRemoteService.remoteStartCharging(pileSn, orderInfo.getConnectorCode(), orderInfo.getTransactionCode(), chargeAmount);
|
||||
String orderType = orderInfo.getOrderType();
|
||||
if (StringUtils.equals(OrderTypeEnum.MERGE_CHARGE_ORDER.getValue(), orderType)) {
|
||||
// 并充订单,调用并充启动充电
|
||||
pileRemoteService.remoteStartMergeCharging(pileSn, orderInfo.getConnectorCode(), orderInfo.getTransactionCode(), chargeAmount, orderInfo.getMergeChargeNumber());
|
||||
}else {
|
||||
// 普通订单启动充电
|
||||
pileRemoteService.remoteStartCharging(pileSn, orderInfo.getConnectorCode(), orderInfo.getTransactionCode(), chargeAmount);
|
||||
}
|
||||
}
|
||||
logger.info("订单:{}支付成功, 发送启动指令", dto.getOrderCode());
|
||||
}
|
||||
@@ -4761,6 +4797,11 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
||||
if (StringUtils.isNotBlank(dto.getMergeChargeNumber())) {
|
||||
// 并充订单序号
|
||||
orderBasicInfo.setMergeChargeNumber(dto.getMergeChargeNumber());
|
||||
}else {
|
||||
// 如果并充订单序号为空,生成一个
|
||||
// 生成规则:年月日时分秒
|
||||
String mergeChargeNumber = DateUtils.dateTimeNow(DateUtils.YYMMDDHHMMSS);
|
||||
orderBasicInfo.setMergeChargeNumber(mergeChargeNumber);
|
||||
}
|
||||
if (StringUtils.isNotBlank(dto.getMainConnectorCode())) {
|
||||
// 主枪枪编号
|
||||
|
||||
@@ -267,6 +267,69 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
|
||||
return rpcResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送并充启动充电指令
|
||||
* @param command
|
||||
*/
|
||||
@Override
|
||||
public void pushStartMergeChargingCommand(StartMergeChargeCommand command) {
|
||||
String pileSn = command.getPileSn();
|
||||
String connectorCode = command.getConnectorCode();
|
||||
String transactionCode = command.getTransactionCode();
|
||||
String mergeChargeCode = command.getMergeChargeCode();
|
||||
|
||||
if (StringUtils.isEmpty(pileSn) || StringUtils.isEmpty(connectorCode)) {
|
||||
log.error("远程启动并充充电, 充电桩编号和枪口号不能为空");
|
||||
return;
|
||||
}
|
||||
if (StringUtils.isEmpty(transactionCode)) {
|
||||
log.error("远程启动并充充电, 交易流水号不能为空");
|
||||
return;
|
||||
}
|
||||
if (command.getAccountAmount() == null || BigDecimal.ZERO.equals(command.getAccountAmount())) {
|
||||
log.error("远程启动并充充电, 充电金额不能为0");
|
||||
return;
|
||||
}
|
||||
|
||||
// 枪口号
|
||||
byte[] connectorCodeByteArr = BytesUtil.str2Bcd(connectorCode);
|
||||
|
||||
// 交易流水号
|
||||
byte[] orderIdByteArr = BytesUtil.str2Bcd(transactionCode);
|
||||
|
||||
// 桩编号
|
||||
byte[] pileSnByteArr = BytesUtil.str2Bcd(pileSn);
|
||||
|
||||
// 逻辑卡号
|
||||
String logicCardNum = StringUtils.isBlank(command.getLogicCardCode())
|
||||
? Constants.ZERO
|
||||
: command.getLogicCardCode();
|
||||
byte[] logicCardNumByteArr = BytesUtil.checkLengthAndFrontAppendZero(BytesUtil.str2Bcd(logicCardNum), 16);
|
||||
|
||||
// 物理卡号
|
||||
String physicsCardNum = StringUtils.isBlank(command.getPhysicsCardCode())
|
||||
? Constants.ZERO
|
||||
: command.getPhysicsCardCode();
|
||||
byte[] physicsCardNumByteArr = BytesUtil.checkLengthAndFrontAppendZero(BytesUtil.str2Bcd(physicsCardNum), 16);
|
||||
|
||||
// 账户余额
|
||||
BigDecimal chargeAmount = command.getAccountAmount();
|
||||
byte[] accountBalanceByteArr = YKCUtils.getPriceByte(chargeAmount.toString(), 2);
|
||||
|
||||
// 并充序号
|
||||
byte[] mergeChargeCodeByteArr = BytesUtil.str2Bcd(mergeChargeCode);
|
||||
|
||||
byte[] msgBody = Bytes.concat(orderIdByteArr, pileSnByteArr, connectorCodeByteArr, logicCardNumByteArr, physicsCardNumByteArr, accountBalanceByteArr, mergeChargeCodeByteArr);
|
||||
try {
|
||||
this.runSend(msgBody, pileSn, YKCFrameTypeCode.PLATFORM_START_MERGE_CHARGE_CODE);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
log.info("【=====平台下发并充充电指令=====】:订单id:{}, 桩号:{}, 枪口号:{}, 逻辑卡号:{}, 物理卡号:{}, 账户余额:{}, 并充序号:{}",
|
||||
transactionCode, pileSn, BytesUtil.bcd2Str(connectorCodeByteArr), logicCardNum, physicsCardNum, chargeAmount, mergeChargeCode);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送启动充电指令
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user