支持yuxin主板预约充电

This commit is contained in:
Guoqs
2026-06-12 10:59:26 +08:00
parent b001d036e0
commit e9024665d7
8 changed files with 67 additions and 8 deletions

View File

@@ -15,9 +15,11 @@ import org.springframework.stereotype.Component;
public class ReservationChargingHandler extends AbstractYkcHandler {
private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.RESERVATION_CHARGING_SETUP_CODE.getBytes());
private final String yuxinType = YKCUtils.frameType2Str(YKCFrameTypeCode.YUXIN_RESERVATION_CHARGING_SETUP_CODE.getBytes());
@Override
public void afterPropertiesSet() throws Exception {
YKCOperateFactory.register(type, this);
YKCOperateFactory.register(yuxinType, this);
}
}

View File

@@ -8,6 +8,7 @@ import com.jsowell.common.core.redis.RedisCache;
import com.jsowell.common.protocol.SyncPromise;
import com.jsowell.common.util.BytesUtil;
import com.jsowell.common.util.RpcUtil;
import com.jsowell.common.util.StringUtils;
import com.jsowell.common.util.YKCUtils;
import com.jsowell.netty.factory.YKCOperateFactory;
import com.jsowell.pile.domain.PileReservationInfo;
@@ -25,6 +26,7 @@ import org.springframework.stereotype.Component;
public class ReservationChargingResponseHandler extends AbstractYkcHandler {
private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.RESERVATION_CHARGING_SETUP_ANSWER_CODE.getBytes());
private final String yuxinType = YKCUtils.frameType2Str(YKCFrameTypeCode.YUXIN_RESERVATION_CHARGING_SETUP_ANSWER_CODE.getBytes());
@Autowired
private RedisCache redisCache;
@@ -35,6 +37,7 @@ public class ReservationChargingResponseHandler extends AbstractYkcHandler {
@Override
public void afterPropertiesSet() throws Exception {
YKCOperateFactory.register(type, this);
YKCOperateFactory.register(yuxinType, this);
}
@Override
@@ -77,11 +80,16 @@ public class ReservationChargingResponseHandler extends AbstractYkcHandler {
byte[] failedReasonByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
String failedReason = BytesUtil.bcd2Str(failedReasonByteArr);
log.info("0x59预约充电响应, 交易流水号:{}, 桩SN:{}, 枪口号:{}, 结果:{}, 失败原因:{}",
transactionCode, pileSn, connectorCode, resultCode, failedReason);
String responseFrameType = YKCUtils.frameType2Str(ykcDataProtocol.getFrameType());
log.info("{}预约充电响应, 交易流水号:{}, 桩SN:{}, 枪口号:{}, 结果:{}, 失败原因:{}",
responseFrameType, transactionCode, pileSn, connectorCode, resultCode, failedReason);
// 根据请求id在集合中找到与外部线程通信的SyncPromise对象
String msgId = ctx.channel().id().toString() + "_" + YKCUtils.frameType2Str(YKCFrameTypeCode.RESERVATION_CHARGING_SETUP_CODE.getBytes());
String requestFrameType = YKCFrameTypeCode.PileAnswersRelation.getRequestFrameType(responseFrameType);
if (StringUtils.isBlank(requestFrameType)) {
requestFrameType = YKCUtils.frameType2Str(YKCFrameTypeCode.RESERVATION_CHARGING_SETUP_CODE.getBytes());
}
String msgId = ctx.channel().id().toString() + "_" + requestFrameType;
log.info("同步获取响应数据-收到消息, msgId:{}", msgId);
SyncPromise syncPromise = RpcUtil.getSyncPromiseMap().get(msgId);
if(syncPromise != null) {