update 0x31鉴权失败原因

This commit is contained in:
Lemon
2024-08-28 10:49:57 +08:00
parent 9478e435f9
commit 653ace40e6
2 changed files with 25 additions and 6 deletions

View File

@@ -26,6 +26,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.Map;
/**
@@ -123,7 +124,7 @@ public class ConfirmStartChargingRequestHandler extends AbstractYkcHandler {
.vinCode(vinCode)
.build();
byte[] defeatReasonByteArr = Constants.zeroByteArray;
/**
* 刷卡启动充电
*/
@@ -189,7 +190,12 @@ public class ConfirmStartChargingRequestHandler extends AbstractYkcHandler {
// 通过vin码查询数据库绑定用户信息
MemberPlateNumberRelation plateInfo = memberPlateNumberRelationService.getMemberPlateInfoByVinCode(vinCode);
if (plateInfo == null) {
throw new BusinessException("", vinCode + "未查到绑定用户信息");
// throw new BusinessException("", vinCode + "未查到绑定用户信息");
log.error(vinCode + "未查到绑定用户信息");
defeatReasonByteArr = new byte[] {0x09}; // 系统中vin 码不存在
transactionCode = Constants.ILLEGAL_TRANSACTION_CODE;
accountBalanceByteArr = BytesUtil.checkLengthAndBehindAppendZero(accountBalanceByteArr, 8);
authenticationFlagByteArr = Constants.zeroByteArray;
}
// if (!StringUtils.equals("1", plateInfo.getVinStatus())) {
// // 1- 正常使用
@@ -216,8 +222,13 @@ public class ConfirmStartChargingRequestHandler extends AbstractYkcHandler {
transactionCode = Constants.ILLEGAL_TRANSACTION_CODE;
accountBalanceByteArr = BytesUtil.checkLengthAndBehindAppendZero(accountBalanceByteArr, 8);
authenticationFlagByteArr = Constants.zeroByteArray;
String code = e.getCode();
String message = e.getMessage();
if (StringUtils.length(code) == 2) {
defeatReasonByteArr = BytesUtil.str2Bcd(code);
}
log.error("VIN码启动充电鉴权 error:{}, {}", e.getCode(), e.getMessage());
log.error("VIN码启动充电鉴权 error:{}, {}", code, message);
}catch (Exception e) {
transactionCode = Constants.ILLEGAL_TRANSACTION_CODE;
accountBalanceByteArr = BytesUtil.checkLengthAndBehindAppendZero(accountBalanceByteArr, 8);
@@ -245,7 +256,7 @@ public class ConfirmStartChargingRequestHandler extends AbstractYkcHandler {
* 0x0A 该桩存在未结账记录
* 0x0B 该桩不支持刷卡
*/
byte[] defeatReasonByteArr = Constants.zeroByteArray;
// byte[] defeatReasonByteArr = Constants.zeroByteArray;
// 保存报文
String jsonMsg = JSON.toJSONString(confirmStartChargingData);
@@ -318,4 +329,12 @@ public class ConfirmStartChargingRequestHandler extends AbstractYkcHandler {
return null;
}
public static void main(String[] args) {
String msg = "01";
System.out.println(StringUtils.length(msg));
byte[] bytes = BytesUtil.str2Bcd(msg);
byte[] a = new byte[]{0x01};
String s = Arrays.toString(bytes);
}
}