update 预约充电

This commit is contained in:
Guoqs
2024-08-23 11:11:50 +08:00
parent 4925eb1755
commit b17b13367a
2 changed files with 50 additions and 1 deletions

View File

@@ -34,6 +34,55 @@ public class ReservationChargingStartupResultHandler extends AbstractYkcHandler
YKCOperateFactory.register(type, this);
}
public static void main(String[] args) {
// 获取消息体
String msg = "8823000000071801240823102300000088230000000718010190";
byte[] msgBody = BytesUtil.str2Bcd(msg);
int startIndex = 0;
int length = 16;
// 交易流水号
byte[] transactionCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
String transactionCode = BytesUtil.bcd2Str(transactionCodeByteArr);
// 桩编码
startIndex += length;
length = 7;
byte[] pileSnByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
String pileSn = BytesUtil.bcd2Str(pileSnByteArr);
// 枪号
startIndex += length;
length = 1;
byte[] connectorCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
String connectorCode = BytesUtil.bcd2Str(connectorCodeByteArr);
// vin
startIndex += length;
length = 17;
byte[] vinCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
String vinCode = YKCUtils.parseVin(vinCodeByteArr); // 解析vin
// 启动结果 0x00失败 0x01成功
startIndex += length;
length = 1;
byte[] startupResultByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
String startupResult = BytesUtil.bcd2Str(startupResultByteArr);
String startupResultMsg = StringUtils.equals(startupResult, "00") ? "失败" : "成功";
// 失败原因
startIndex += length;
length = 1;
byte[] failReasonByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
String failReason = BytesUtil.bcd2Str(failReasonByteArr);
String failReasonMsg = ChargingFailedReasonEnum.getMsgByCode(Integer.parseInt(failReason, 16));
log.info("[===预约充电启动结果上送===]交易流水号:{}, 桩编号:{}, 枪号:{}, vin:{}, 启动结果:{}, 失败原因:{}",
transactionCode, pileSn, connectorCode, vinCode, startupResult + "-" +startupResultMsg, failReasonMsg);
}
@Override
public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) {
log.info("[===预约充电启动结果上送===] param:{}, channel:{}", JSON.toJSONString(ykcDataProtocol), channel.toString());