添加vin码启动相关逻辑代码

This commit is contained in:
Lemon
2023-06-07 15:14:03 +08:00
parent 4b9dc3a468
commit 0cad2dcfa4
12 changed files with 610 additions and 13 deletions

View File

@@ -7,6 +7,7 @@ import com.jsowell.common.core.domain.ykc.YKCDataProtocol;
import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode;
import com.jsowell.common.enums.ykc.CardStatusEnum;
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
import com.jsowell.common.enums.ykc.StartModeEnum;
import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.util.BytesUtil;
import com.jsowell.common.util.StringUtils;
@@ -14,8 +15,10 @@ import com.jsowell.common.util.YKCUtils;
import com.jsowell.netty.factory.YKCOperateFactory;
import com.jsowell.pile.domain.PileAuthCard;
import com.jsowell.pile.dto.GenerateOrderDTO;
import com.jsowell.pile.service.ICarVinInfoService;
import com.jsowell.pile.service.IOrderBasicInfoService;
import com.jsowell.pile.service.IPileAuthCardService;
import com.jsowell.pile.vo.CarVinInfoVO;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -41,6 +44,9 @@ public class ConfirmStartChargingRequestHandler extends AbstractHandler{
@Autowired
private IOrderBasicInfoService orderBasicInfoService;
@Autowired
private ICarVinInfoService carVinInfoService;
@Override
public void afterPropertiesSet() throws Exception {
YKCOperateFactory.register(type, this);
@@ -97,13 +103,14 @@ public class ConfirmStartChargingRequestHandler extends AbstractHandler{
startIndex += length;
length = 17;
byte[] vinCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
String vinCode = BytesUtil.ascii2Str(vinCodeByteArr);
/**
* 刷卡启动充电
*/
String logicCard = "";
byte[] authenticationFlagByteArr = Constants.zeroByteArray;
byte[] accountBalanceByteArr = Constants.zeroByteArray;
byte[] authenticationFlagByteArr = Constants.zeroByteArray; // 鉴权成功标识
byte[] accountBalanceByteArr = Constants.zeroByteArray; // 账户余额
String transactionCode = "";
try {
if (StringUtils.equals("01", startMode)) {
@@ -127,6 +134,7 @@ public class ConfirmStartChargingRequestHandler extends AbstractHandler{
dto.setPileAuthCardInfo(pileAuthCardInfo);
dto.setPileSn(pileSn);
dto.setConnectorCode(connectorCode);
dto.setStartMode(StartModeEnum.AUTH_CARD.getValue());
Map<String, Object> map = orderBasicInfoService.generateOrderByCard(dto);
if (map != null) {
transactionCode = (String) map.get("transactionCode");
@@ -144,6 +152,30 @@ public class ConfirmStartChargingRequestHandler extends AbstractHandler{
/**
* TODO VIN码启动充电
*/
if (StringUtils.equals("03", startMode)) {
// 通过vin码查询数据库绑定用户信息
CarVinInfoVO memberInfo = carVinInfoService.getMemberInfoByVinCode(vinCode);
if (memberInfo == null) {
throw new BusinessException("", "");
}
if (!StringUtils.equals("1", memberInfo.getStatus())) {
// 1- 正常使用
throw new BusinessException("", "");
}
// vin码生成订单 vin启动充电
GenerateOrderDTO dto = new GenerateOrderDTO();
dto.setCarVinInfoVO(memberInfo);
dto.setPileSn(pileSn);
dto.setConnectorCode(connectorCode);
dto.setStartMode(StartModeEnum.VIN_CODE.getValue());
Map<String, Object> map = orderBasicInfoService.generateOrderByCard(dto);
if (map != null) {
transactionCode = (String) map.get("transactionCode");
accountBalanceByteArr = YKCUtils.getPriceByte(String.valueOf(map.get("accountBalance")), 2);
// 鉴权成功标识 0x00 失败 0x01 成功
authenticationFlagByteArr = Constants.oneByteArray;
}
}
// 应答
// 交易流水号