mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-07-04 22:18:02 +08:00
update 充电桩主动申请充电逻辑优化
This commit is contained in:
@@ -66,6 +66,70 @@ public class ConfirmStartChargingRequestHandler extends AbstractYkcHandler {
|
|||||||
YKCOperateFactory.register(type, this);
|
YKCOperateFactory.register(type, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
String msg = "882500000137280103000000000000000000000000000000000000000000000000003130303030303030303030524554494153";
|
||||||
|
|
||||||
|
byte[] msgBody = BytesUtil.str2Bcd(msg);
|
||||||
|
|
||||||
|
int startIndex = 0;
|
||||||
|
int length = 7;
|
||||||
|
|
||||||
|
// 桩编码
|
||||||
|
byte[] pileSnByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||||
|
String pileSn = BytesUtil.binary(pileSnByteArr, 16);
|
||||||
|
|
||||||
|
// 保存时间
|
||||||
|
// saveLastTimeAndCheckChannel(pileSn, channel);
|
||||||
|
|
||||||
|
// 枪号
|
||||||
|
startIndex += length;
|
||||||
|
length = 1;
|
||||||
|
byte[] connectorNumByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||||
|
String connectorCode = BytesUtil.bcd2Str(connectorNumByteArr);
|
||||||
|
|
||||||
|
// 启动方式
|
||||||
|
// 0x01 表示通过刷卡启动充电
|
||||||
|
// 0x02 表求通过帐号启动充电 (暂不支持)
|
||||||
|
// 0x03 表示vin码启动充电
|
||||||
|
startIndex += length;
|
||||||
|
byte[] startModeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||||
|
String startMode = BytesUtil.bcd2Str(startModeByteArr);
|
||||||
|
|
||||||
|
// 是否需要密码 0x00 不需要 0x01 需要
|
||||||
|
startIndex += length;
|
||||||
|
byte[] needPasswordFlagByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||||
|
String needPasswordFlag = BytesUtil.bcd2Str(needPasswordFlagByteArr);
|
||||||
|
|
||||||
|
// 物理卡号 不足 8 位补 0
|
||||||
|
startIndex += length;
|
||||||
|
length = 8;
|
||||||
|
byte[] cardNumByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||||
|
log.info("充电桩主动申请启动充电cardNumByteArr:{}", cardNumByteArr);
|
||||||
|
String physicsCard = BytesUtil.binary(cardNumByteArr, 16);
|
||||||
|
|
||||||
|
// 输入密码 对用户输入的密码进行16 位MD5 加密,采用小写上传
|
||||||
|
startIndex += length;
|
||||||
|
length = 16;
|
||||||
|
byte[] inputPasswordByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||||
|
String inputPasswordHexStr = BytesUtil.bin2HexStr(inputPasswordByteArr);
|
||||||
|
|
||||||
|
// VIN码
|
||||||
|
startIndex += length;
|
||||||
|
length = 17;
|
||||||
|
byte[] vinCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||||
|
String vinCode = BytesUtil.ascii2StrLittle(vinCodeByteArr);
|
||||||
|
|
||||||
|
ConfirmStartChargingData confirmStartChargingData = ConfirmStartChargingData.builder()
|
||||||
|
.pileSn(pileSn)
|
||||||
|
.connectorCode(connectorCode)
|
||||||
|
.startMode(startMode)
|
||||||
|
.needPasswordFlag(needPasswordFlag)
|
||||||
|
.inputPasswordByteArr(inputPasswordHexStr)
|
||||||
|
.physicsCard(physicsCard)
|
||||||
|
.vinCode(vinCode)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) {
|
public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) {
|
||||||
// log.info("[===充电桩主动申请启动充电===] param:{}, channel:{}", JSON.toJSONString(ykcDataProtocol), channel.toString());
|
// log.info("[===充电桩主动申请启动充电===] param:{}, channel:{}", JSON.toJSONString(ykcDataProtocol), channel.toString());
|
||||||
@@ -293,6 +357,7 @@ public class ConfirmStartChargingRequestHandler extends AbstractYkcHandler {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private Map<String, String> confirmStartCharging(ConfirmStartChargingData confirmStartChargingData) {
|
private Map<String, String> confirmStartCharging(ConfirmStartChargingData confirmStartChargingData) {
|
||||||
|
log.info("充电桩主动申请充电逻辑, param:{}", JSON.toJSONString(confirmStartChargingData));
|
||||||
Map<String, String> resultMap = new HashMap<>();
|
Map<String, String> resultMap = new HashMap<>();
|
||||||
|
|
||||||
String pileSn = confirmStartChargingData.getPileSn();
|
String pileSn = confirmStartChargingData.getPileSn();
|
||||||
@@ -307,9 +372,11 @@ public class ConfirmStartChargingRequestHandler extends AbstractYkcHandler {
|
|||||||
if (StringUtils.equals("01", startMode)) {
|
if (StringUtils.equals("01", startMode)) {
|
||||||
String physicsCard = confirmStartChargingData.getPhysicsCard();
|
String physicsCard = confirmStartChargingData.getPhysicsCard();
|
||||||
memberWalletVO = memberBasicInfoService.queryMemberInfoByCardCode(physicsCard, pileBasicInfo.getMerchantId() + "", pileBasicInfo.getStationId() + "");
|
memberWalletVO = memberBasicInfoService.queryMemberInfoByCardCode(physicsCard, pileBasicInfo.getMerchantId() + "", pileBasicInfo.getStationId() + "");
|
||||||
|
log.info("根据卡号:{},查询会员信息:{}", physicsCard, JSON.toJSONString(memberWalletVO));
|
||||||
} else if (StringUtils.equals("03", startMode)) {
|
} else if (StringUtils.equals("03", startMode)) {
|
||||||
String vinCode = confirmStartChargingData.getVinCode();
|
String vinCode = confirmStartChargingData.getVinCode();
|
||||||
memberWalletVO = memberBasicInfoService.queryByVinCode(vinCode, pileBasicInfo.getMerchantId() + "", pileBasicInfo.getStationId() + "");
|
memberWalletVO = memberBasicInfoService.queryByVinCode(vinCode, pileBasicInfo.getMerchantId() + "", pileBasicInfo.getStationId() + "");
|
||||||
|
log.info("根据vin码:{},查询会员信息:{}", vinCode, JSON.toJSONString(memberWalletVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
String accountBalance = Constants.ZERO;
|
String accountBalance = Constants.ZERO;
|
||||||
@@ -319,6 +386,7 @@ public class ConfirmStartChargingRequestHandler extends AbstractYkcHandler {
|
|||||||
resultMap.put("transactionCode", Constants.ILLEGAL_TRANSACTION_CODE);
|
resultMap.put("transactionCode", Constants.ILLEGAL_TRANSACTION_CODE);
|
||||||
resultMap.put("accountBalance", accountBalance);
|
resultMap.put("accountBalance", accountBalance);
|
||||||
resultMap.put("defeatReasonCode", "01");
|
resultMap.put("defeatReasonCode", "01");
|
||||||
|
log.info("无此会员权限");
|
||||||
return resultMap;
|
return resultMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,13 +395,13 @@ public class ConfirmStartChargingRequestHandler extends AbstractYkcHandler {
|
|||||||
resultMap.put("transactionCode", Constants.ILLEGAL_TRANSACTION_CODE);
|
resultMap.put("transactionCode", Constants.ILLEGAL_TRANSACTION_CODE);
|
||||||
resultMap.put("accountBalance", accountBalance);
|
resultMap.put("accountBalance", accountBalance);
|
||||||
resultMap.put("defeatReasonCode", "03");
|
resultMap.put("defeatReasonCode", "03");
|
||||||
|
log.info("余额不足");
|
||||||
return resultMap;
|
return resultMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
鉴权通过, 生成订单并支付
|
鉴权通过, 生成订单并支付
|
||||||
*/
|
*/
|
||||||
|
|
||||||
String payMode;
|
String payMode;
|
||||||
if (StringUtils.equals(Constants.ONE, memberWalletVO.getPlatformTesterFlag())
|
if (StringUtils.equals(Constants.ONE, memberWalletVO.getPlatformTesterFlag())
|
||||||
|| StringUtils.equals(Constants.ONE, memberWalletVO.getStationWhiteListFlag())) {
|
|| StringUtils.equals(Constants.ONE, memberWalletVO.getStationWhiteListFlag())) {
|
||||||
|
|||||||
@@ -805,7 +805,7 @@ public class MemberBasicInfoServiceImpl implements MemberBasicInfoService {
|
|||||||
// 查询会员在站点是否是白名单用户
|
// 查询会员在站点是否是白名单用户
|
||||||
PileStationWhitelist whitelist = pileStationWhitelistMapper.queryWhitelistByMemberId(stationId, memberVO.getMemberId());
|
PileStationWhitelist whitelist = pileStationWhitelistMapper.queryWhitelistByMemberId(stationId, memberVO.getMemberId());
|
||||||
memberVO.setStationWhiteListFlag(whitelist != null ? Constants.ONE : Constants.ZERO);
|
memberVO.setStationWhiteListFlag(whitelist != null ? Constants.ONE : Constants.ZERO);
|
||||||
return null;
|
return memberVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user