diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/handler/yunkuaichong/ConfirmStartChargingRequestHandler.java b/jsowell-netty/src/main/java/com/jsowell/netty/handler/yunkuaichong/ConfirmStartChargingRequestHandler.java index bc752633c..483de0cb5 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/handler/yunkuaichong/ConfirmStartChargingRequestHandler.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/handler/yunkuaichong/ConfirmStartChargingRequestHandler.java @@ -66,6 +66,70 @@ public class ConfirmStartChargingRequestHandler extends AbstractYkcHandler { 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 public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) { // log.info("[===充电桩主动申请启动充电===] param:{}, channel:{}", JSON.toJSONString(ykcDataProtocol), channel.toString()); @@ -293,6 +357,7 @@ public class ConfirmStartChargingRequestHandler extends AbstractYkcHandler { * @return */ private Map confirmStartCharging(ConfirmStartChargingData confirmStartChargingData) { + log.info("充电桩主动申请充电逻辑, param:{}", JSON.toJSONString(confirmStartChargingData)); Map resultMap = new HashMap<>(); String pileSn = confirmStartChargingData.getPileSn(); @@ -307,9 +372,11 @@ public class ConfirmStartChargingRequestHandler extends AbstractYkcHandler { if (StringUtils.equals("01", startMode)) { String physicsCard = confirmStartChargingData.getPhysicsCard(); memberWalletVO = memberBasicInfoService.queryMemberInfoByCardCode(physicsCard, pileBasicInfo.getMerchantId() + "", pileBasicInfo.getStationId() + ""); + log.info("根据卡号:{},查询会员信息:{}", physicsCard, JSON.toJSONString(memberWalletVO)); } else if (StringUtils.equals("03", startMode)) { String vinCode = confirmStartChargingData.getVinCode(); memberWalletVO = memberBasicInfoService.queryByVinCode(vinCode, pileBasicInfo.getMerchantId() + "", pileBasicInfo.getStationId() + ""); + log.info("根据vin码:{},查询会员信息:{}", vinCode, JSON.toJSONString(memberWalletVO)); } String accountBalance = Constants.ZERO; @@ -319,6 +386,7 @@ public class ConfirmStartChargingRequestHandler extends AbstractYkcHandler { resultMap.put("transactionCode", Constants.ILLEGAL_TRANSACTION_CODE); resultMap.put("accountBalance", accountBalance); resultMap.put("defeatReasonCode", "01"); + log.info("无此会员权限"); return resultMap; } @@ -327,13 +395,13 @@ public class ConfirmStartChargingRequestHandler extends AbstractYkcHandler { resultMap.put("transactionCode", Constants.ILLEGAL_TRANSACTION_CODE); resultMap.put("accountBalance", accountBalance); resultMap.put("defeatReasonCode", "03"); + log.info("余额不足"); return resultMap; } /* 鉴权通过, 生成订单并支付 */ - String payMode; if (StringUtils.equals(Constants.ONE, memberWalletVO.getPlatformTesterFlag()) || StringUtils.equals(Constants.ONE, memberWalletVO.getStationWhiteListFlag())) { diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/MemberBasicInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/MemberBasicInfoServiceImpl.java index 768cd5ba5..eeafef462 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/MemberBasicInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/MemberBasicInfoServiceImpl.java @@ -805,7 +805,7 @@ public class MemberBasicInfoServiceImpl implements MemberBasicInfoService { // 查询会员在站点是否是白名单用户 PileStationWhitelist whitelist = pileStationWhitelistMapper.queryWhitelistByMemberId(stationId, memberVO.getMemberId()); memberVO.setStationWhiteListFlag(whitelist != null ? Constants.ONE : Constants.ZERO); - return null; + return memberVO; } }