mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
新增协议0x65预约充电启动结果上传
This commit is contained in:
@@ -1,9 +1,22 @@
|
||||
package com.jsowell.netty.handler.yunkuaichong;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.google.common.primitives.Bytes;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.core.domain.ykc.YKCDataProtocol;
|
||||
import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode;
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
import com.jsowell.common.util.YKCUtils;
|
||||
import com.jsowell.netty.factory.YKCOperateFactory;
|
||||
import io.netty.channel.Channel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 预约充电启动结果上送
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ReservationChargingStartupResultHandler extends AbstractHandler{
|
||||
|
||||
private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.RESERVATION_CHARGING_STARTUP_RESULT_CODE.getBytes());
|
||||
@@ -12,4 +25,66 @@ public class ReservationChargingStartupResultHandler extends AbstractHandler{
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
YKCOperateFactory.register(type, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, Channel channel) {
|
||||
log.info("[===预约充电启动结果上送===] param:{}, channel:{}", JSON.toJSONString(ykcDataProtocol), channel.toString());
|
||||
// 消息体
|
||||
byte[] msgBody = ykcDataProtocol.getMsgBody();
|
||||
|
||||
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);
|
||||
|
||||
// 保存时间
|
||||
saveLastTimeAndCheckChannel(pileSn, channel);
|
||||
|
||||
// 枪号
|
||||
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 = BytesUtil.bcd2Str(vinCodeByteArr);
|
||||
|
||||
// 启动结果
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
byte[] startupResultByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String startupResult = BytesUtil.bcd2Str(startupResultByteArr);
|
||||
|
||||
// 失败原因
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
byte[] failReasonByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String failReason = BytesUtil.bcd2Str(failReasonByteArr);
|
||||
|
||||
log.info("[===预约充电启动结果上送===]交易流水号:{}, 桩编号:{}, 枪号:{}, vin:{}, 启动结果:{}, 失败原因:{}",
|
||||
transactionCode, pileSn, connectorCode, vinCode, startupResult, failReason);
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
应答
|
||||
确认结果 0x00 成功 0x01 失败
|
||||
*/
|
||||
byte[] confirmResultBytes = Constants.zeroByteArray;
|
||||
byte[] concatMsgBody = Bytes.concat(transactionCodeByteArr, pileSnByteArr, connectorCodeByteArr, confirmResultBytes);
|
||||
|
||||
return getResult(ykcDataProtocol, concatMsgBody);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,8 +330,8 @@ public class TransactionRecordsRequestHandler extends AbstractHandler {
|
||||
int length = 16;
|
||||
|
||||
// 交易流水号
|
||||
byte[] orderCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String transactionCode = BytesUtil.bcd2Str(orderCodeByteArr);
|
||||
byte[] transactionCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String transactionCode = BytesUtil.bcd2Str(transactionCodeByteArr);
|
||||
|
||||
// 桩编码
|
||||
startIndex += length;
|
||||
@@ -582,7 +582,7 @@ public class TransactionRecordsRequestHandler extends AbstractHandler {
|
||||
2022年12月15日11点28分发现返回 01非法账单,充电桩会持续上传交易记录,后面产生的交易记录被阻塞
|
||||
*/
|
||||
byte[] confirmResultBytes = Constants.zeroByteArray;
|
||||
byte[] concatMsgBody = Bytes.concat(orderCodeByteArr, confirmResultBytes);
|
||||
byte[] concatMsgBody = Bytes.concat(transactionCodeByteArr, confirmResultBytes);
|
||||
|
||||
return getResult(ykcDataProtocol, concatMsgBody);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user