mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
update 预约充电
This commit is contained in:
@@ -3,7 +3,7 @@ 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.ConfirmStartChargingData;
|
||||
import com.jsowell.pile.dto.ConfirmStartChargingData;
|
||||
import com.jsowell.common.core.domain.ykc.YKCDataProtocol;
|
||||
import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode;
|
||||
import com.jsowell.common.enums.ykc.CardStatusEnum;
|
||||
@@ -21,7 +21,6 @@ import com.jsowell.pile.service.MemberPlateNumberRelationService;
|
||||
import com.jsowell.pile.service.OrderBasicInfoService;
|
||||
import com.jsowell.pile.service.PileAuthCardService;
|
||||
import com.jsowell.pile.service.PileMsgRecordService;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -248,12 +247,6 @@ public class ConfirmStartChargingRequestHandler extends AbstractHandler{
|
||||
*/
|
||||
byte[] defeatReasonByteArr = Constants.zeroByteArray;
|
||||
|
||||
// 不足位数的值补零
|
||||
// cardNumByteArr = BytesUtil.checkLengthAndBehindAppendZero(cardNumByteArr, 16);
|
||||
// serialNumByteArr = BytesUtil.checkLengthAndBehindAppendZero(serialNumByteArr, 32);
|
||||
// pileSnByteArr = BytesUtil.checkLengthAndBehindAppendZero(pileSnByteArr, 14);
|
||||
// accountBalanceByteArr = BytesUtil.checkLengthAndBehindAppendZero(accountBalanceByteArr, 8);
|
||||
|
||||
// 保存报文
|
||||
String jsonMsg = JSON.toJSONString(confirmStartChargingData);
|
||||
pileMsgRecordService.save(pileSn, pileSn, type, jsonMsg, ykcDataProtocol.getHEXString());
|
||||
@@ -264,4 +257,65 @@ public class ConfirmStartChargingRequestHandler extends AbstractHandler{
|
||||
|
||||
return getResult(ykcDataProtocol, msgBodyByteArr);
|
||||
}
|
||||
|
||||
/**
|
||||
* 充电桩主动申请充电 逻辑
|
||||
* @param confirmStartChargingData
|
||||
* @return
|
||||
*/
|
||||
private byte[] confirmStartCharging(ConfirmStartChargingData confirmStartChargingData) {
|
||||
String startMode = confirmStartChargingData.getStartMode();
|
||||
String pileSn = confirmStartChargingData.getPileSn();
|
||||
String connectorCode = confirmStartChargingData.getConnectorCode();
|
||||
|
||||
GenerateOrderDTO dto = null;
|
||||
try {
|
||||
if (StringUtils.equals("01", startMode)) {
|
||||
String physicsCard = confirmStartChargingData.getPhysicsCard();
|
||||
// 查询卡信息 根据传过来的物理卡号查询数据库中此卡信息
|
||||
PileAuthCard pileAuthCardInfo = pileAuthCardService.selectCardInfoByLogicCard(physicsCard);
|
||||
if (pileAuthCardInfo == null) {
|
||||
// 未查到此卡信息
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_THIS_CARD_HAS_NO_INFO);
|
||||
}
|
||||
if (StringUtils.isBlank(pileAuthCardInfo.getMemberId())) {
|
||||
// 卡未绑定用户
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_THIS_CARD_NOT_BIND_USER);
|
||||
}
|
||||
|
||||
// 判断卡状态
|
||||
if (!StringUtils.equals(CardStatusEnum.NORMAL.getCode(), pileAuthCardInfo.getStatus())) {
|
||||
log.info("卡号:{}, 状态:{}, 非正常使用状态", physicsCard, CardStatusEnum.getCardStatus(pileAuthCardInfo.getStatus()));
|
||||
return null;
|
||||
}
|
||||
dto = new GenerateOrderDTO();
|
||||
dto.setPileAuthCardInfo(pileAuthCardInfo);
|
||||
dto.setPileSn(pileSn);
|
||||
dto.setConnectorCode(connectorCode);
|
||||
dto.setStartMode(StartModeEnum.AUTH_CARD.getValue());
|
||||
dto.setMemberId(pileAuthCardInfo.getMemberId());
|
||||
} else if (StringUtils.equals("03", startMode)) {
|
||||
String vinCode = confirmStartChargingData.getVinCode();
|
||||
// 通过vin码查询数据库绑定用户信息
|
||||
MemberPlateNumberRelation plateInfo = memberPlateNumberRelationService.getMemberPlateInfoByVinCode(vinCode);
|
||||
if (plateInfo == null) {
|
||||
throw new BusinessException("", vinCode + "未查到绑定用户信息");
|
||||
}
|
||||
dto = new GenerateOrderDTO();
|
||||
dto.setMemberPlateNumberRelation(plateInfo);
|
||||
dto.setPileSn(pileSn);
|
||||
dto.setConnectorCode(connectorCode);
|
||||
dto.setStartMode(StartModeEnum.VIN_CODE.getValue());
|
||||
dto.setMemberId(plateInfo.getMemberId());
|
||||
}
|
||||
|
||||
if (dto != null) {
|
||||
// Map<String, Object> map = orderBasicInfoService.generateOrderByCard(dto);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.jsowell.common.core.domain.ykc;
|
||||
package com.jsowell.pile.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
@@ -55,23 +55,23 @@ public class ConfirmStartChargingData {
|
||||
*/
|
||||
private String vinCode;
|
||||
|
||||
// /**
|
||||
// * 鉴权成功标识
|
||||
// */
|
||||
// private String authenticationFlagByteArr;
|
||||
//
|
||||
// /**
|
||||
// * 账户余额
|
||||
// */
|
||||
// private String accountBalanceByteArr;
|
||||
//
|
||||
// /**
|
||||
// * 交易流水号
|
||||
// */
|
||||
// private String serialNumByteArr;
|
||||
//
|
||||
// /**
|
||||
// * 失败原因
|
||||
// */
|
||||
// private String defeatReasonByteArr;
|
||||
/**
|
||||
* 鉴权成功标识
|
||||
*/
|
||||
private String authFlag;
|
||||
|
||||
/**
|
||||
* 账户余额
|
||||
*/
|
||||
private String accountBalance;
|
||||
|
||||
/**
|
||||
* 交易流水号
|
||||
*/
|
||||
private String transactionCode;
|
||||
|
||||
/**
|
||||
* 失败原因
|
||||
*/
|
||||
private String failReason;
|
||||
}
|
||||
@@ -477,4 +477,6 @@ public interface OrderBasicInfoService{
|
||||
* @param chargingStartupResult
|
||||
*/
|
||||
void createReservationOrder(ReservationChargingStartupResult chargingStartupResult);
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user