mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-24 17:19:51 +08:00
羽信预约充电
This commit is contained in:
@@ -66,23 +66,39 @@ public class ReservationChargingResponseHandler extends AbstractYkcHandler {
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
byte[] connectorCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String connectorCode = BytesUtil.bcd2Str(connectorCodeByteArr);
|
||||
String responseFrameType = YKCUtils.frameType2Str(ykcDataProtocol.getFrameType());
|
||||
boolean yuxinResponse = StringUtils.equals(responseFrameType, yuxinType);
|
||||
String connectorCode = yuxinResponse ? parseYuxinConnectorCode(connectorCodeByteArr) : BytesUtil.bcd2Str(connectorCodeByteArr);
|
||||
|
||||
String reservationType = null;
|
||||
if (yuxinResponse) {
|
||||
// 羽信0xB1在枪号后多一个预约方式字段: 0x00 立即预约, 0x01 取消预约。
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
byte[] reservationTypeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
reservationType = BytesUtil.bin2HexStr(reservationTypeByteArr);
|
||||
}
|
||||
|
||||
// 启动结果 0x00失败 0x01成功
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
byte[] resultCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String resultCode = BytesUtil.bcd2Str(resultCodeByteArr);
|
||||
String resultCode = yuxinResponse ? BytesUtil.bin2HexStr(resultCodeByteArr) : BytesUtil.bcd2Str(resultCodeByteArr);
|
||||
|
||||
// 失败原因
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
byte[] failedReasonByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String failedReason = BytesUtil.bcd2Str(failedReasonByteArr);
|
||||
String failedReason = yuxinResponse ? BytesUtil.bin2HexStr(failedReasonByteArr) : BytesUtil.bcd2Str(failedReasonByteArr);
|
||||
String failedReasonMsg = yuxinResponse ? getYuxinFailedReasonMsg(failedReason) : failedReason;
|
||||
|
||||
String responseFrameType = YKCUtils.frameType2Str(ykcDataProtocol.getFrameType());
|
||||
log.info("{}预约充电响应, 交易流水号:{}, 桩SN:{}, 枪口号:{}, 结果:{}, 失败原因:{}",
|
||||
responseFrameType, transactionCode, pileSn, connectorCode, resultCode, failedReason);
|
||||
if (yuxinResponse) {
|
||||
log.info("{}预约充电响应, 交易流水号:{}, 桩SN:{}, 枪口号:{}, 预约方式:{}, 结果:{}, 失败原因:{}",
|
||||
responseFrameType, transactionCode, pileSn, connectorCode, reservationType, resultCode, failedReasonMsg);
|
||||
} else {
|
||||
log.info("{}预约充电响应, 交易流水号:{}, 桩SN:{}, 枪口号:{}, 结果:{}, 失败原因:{}",
|
||||
responseFrameType, transactionCode, pileSn, connectorCode, resultCode, failedReason);
|
||||
}
|
||||
|
||||
// 根据请求id,在集合中找到与外部线程通信的SyncPromise对象
|
||||
String requestFrameType = YKCFrameTypeCode.PileAnswersRelation.getRequestFrameType(responseFrameType);
|
||||
@@ -114,4 +130,21 @@ public class ReservationChargingResponseHandler extends AbstractYkcHandler {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String parseYuxinConnectorCode(byte[] connectorCodeByteArr) {
|
||||
return String.format("%02d", connectorCodeByteArr[0] & 0xFF);
|
||||
}
|
||||
|
||||
private String getYuxinFailedReasonMsg(String failedReason) {
|
||||
if (StringUtils.equals(failedReason, "00")) {
|
||||
return "无";
|
||||
} else if (StringUtils.equals(failedReason, "01")) {
|
||||
return "保存失败";
|
||||
} else if (StringUtils.equals(failedReason, "02")) {
|
||||
return "系统当前时间小于主板时间";
|
||||
} else if (StringUtils.equals(failedReason, "03")) {
|
||||
return "预约时间小于当前时间";
|
||||
}
|
||||
return failedReason;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user