新增 0x31 充电桩主动申请充电报文存数据库

This commit is contained in:
Lemon
2023-10-12 13:34:32 +08:00
parent 7c59aa4abf
commit cf4a9bf72f
2 changed files with 100 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ package com.jsowell.netty.handler;
import com.alibaba.fastjson2.JSONObject;
import com.google.common.primitives.Bytes;
import com.jsowell.common.constant.Constants;
import com.jsowell.common.core.domain.ykc.ConfirmStartChargingData;
import com.jsowell.common.core.domain.ykc.YKCDataProtocol;
import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode;
import com.jsowell.common.enums.ykc.CardStatusEnum;
@@ -12,6 +13,7 @@ import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.util.BytesUtil;
import com.jsowell.common.util.StringUtils;
import com.jsowell.common.util.YKCUtils;
import com.jsowell.common.util.sign.MD5Util;
import com.jsowell.netty.factory.YKCOperateFactory;
import com.jsowell.pile.domain.MemberPlateNumberRelation;
import com.jsowell.pile.domain.PileAuthCard;
@@ -19,6 +21,7 @@ import com.jsowell.pile.dto.GenerateOrderDTO;
import com.jsowell.pile.service.IMemberPlateNumberRelationService;
import com.jsowell.pile.service.IOrderBasicInfoService;
import com.jsowell.pile.service.IPileAuthCardService;
import com.jsowell.pile.service.IPileMsgRecordService;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -47,6 +50,9 @@ public class ConfirmStartChargingRequestHandler extends AbstractHandler{
@Autowired
private IMemberPlateNumberRelationService memberPlateNumberRelationService;
@Autowired
private IPileMsgRecordService pileMsgRecordService;
@Override
public void afterPropertiesSet() throws Exception {
YKCOperateFactory.register(type, this);
@@ -97,6 +103,7 @@ public class ConfirmStartChargingRequestHandler extends AbstractHandler{
startIndex += length;
length = 16;
byte[] inputPasswordByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
String inputPasswordHexStr = BytesUtil.bin2HexStr(inputPasswordByteArr);
// VIN码
startIndex += length;
@@ -104,6 +111,18 @@ public class ConfirmStartChargingRequestHandler extends AbstractHandler{
byte[] vinCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
String vinCode = BytesUtil.ascii2Str(vinCodeByteArr);
ConfirmStartChargingData confirmStartChargingData = ConfirmStartChargingData.builder()
.pileSn(pileSn)
.connectorCode(connectorCode)
.startMode(startMode)
.needPasswordFlag(needPasswordFlag)
.inputPasswordByteArr(inputPasswordHexStr)
.physicsCard(physicsCard)
.vinCode(vinCode)
.build();
/**
* 刷卡启动充电
*/
@@ -243,6 +262,10 @@ public class ConfirmStartChargingRequestHandler extends AbstractHandler{
// pileSnByteArr = BytesUtil.checkLengthAndBehindAppendZero(pileSnByteArr, 14);
// accountBalanceByteArr = BytesUtil.checkLengthAndBehindAppendZero(accountBalanceByteArr, 8);
// 保存报文
String jsonMsg = JSONObject.toJSONString(confirmStartChargingData);
pileMsgRecordService.save(pileSn, pileSn, type, jsonMsg, ykcDataProtocol.getHEXString());
// 拼装消息体
byte[] msgBodyByteArr = Bytes.concat(serialNumByteArr, pileSnByteArr, connectorNumByteArr, cardNumByteArr, accountBalanceByteArr,
authenticationFlagByteArr, defeatReasonByteArr);