diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/handler/yunkuaichong/ReservationChargingResponseHandler.java b/jsowell-netty/src/main/java/com/jsowell/netty/handler/yunkuaichong/ReservationChargingResponseHandler.java index 4e18aef8f..97ef357c2 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/handler/yunkuaichong/ReservationChargingResponseHandler.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/handler/yunkuaichong/ReservationChargingResponseHandler.java @@ -1,8 +1,11 @@ package com.jsowell.netty.handler.yunkuaichong; +import com.jsowell.common.core.domain.ykc.YKCDataProtocol; import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode; +import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.YKCUtils; import com.jsowell.netty.factory.YKCOperateFactory; +import io.netty.channel.Channel; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @@ -19,4 +22,49 @@ public class ReservationChargingResponseHandler extends AbstractHandler{ public void afterPropertiesSet() throws Exception { YKCOperateFactory.register(type, this); } + + @Override + public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, Channel channel) { + // log.info("[====远程更新应答====] param:{}, channel:{}", JSON.toJSONString(ykcDataProtocol), channel.toString()); + // 消息体 + byte[] msgBody = ykcDataProtocol.getMsgBody(); + + int startIndex = 0; + int length = 16; + + // 交易流水号 + byte[] transactionCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length); + String transactionCode = BytesUtil.bcd2Str(transactionCodeByteArr); + + // 桩编码 + startIndex += length; + length = 7; + byte[] pileSnByteArr = BytesUtil.copyBytes(msgBody, startIndex, length); + String pileSn = BytesUtil.bcd2Str(pileSnByteArr); + + // 保存时间 + saveLastTimeAndCheckChannel(pileSn, channel); + + // 枪口号 + startIndex += length; + length = 1; + byte[] connectorCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length); + String connectorCode = BytesUtil.bcd2Str(connectorCodeByteArr); + + // 启动结果 + startIndex += length; + length = 1; + byte[] resultCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length); + String resultCode = BytesUtil.bcd2Str(resultCodeByteArr); + + // 失败原因 + startIndex += length; + length = 1; + byte[] failedReasonByteArr = BytesUtil.copyBytes(msgBody, startIndex, length); + String failedReason = BytesUtil.bcd2Str(failedReasonByteArr); + + log.info("0x59预约充电响应, 交易流水号:{}, 桩SN:{}, 枪口号:{}, 结果:{}, 失败原因:{}", + transactionCode, pileSn, connectorCode, resultCode, failedReason); + return null; + } } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/PileRemoteService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/PileRemoteService.java index f0393abdf..60cd18d25 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/PileRemoteService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/PileRemoteService.java @@ -94,7 +94,7 @@ public class PileRemoteService { log.warn("远程启动充电, 充电桩编号和枪口号不能为空"); return; } - log.info("=====平台下发指令=====: 远程启动充电, 桩号:{}, 枪口号:{}", pileSn, connectorCode); + log.info("【=====平台下发指令=====】: 远程启动充电, 桩号:{}, 枪口号:{}", pileSn, connectorCode); StartChargingCommand startChargingCommand = StartChargingCommand.builder() .pileSn(pileSn) .connectorCode(connectorCode) diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/YKCPushCommandServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/YKCPushCommandServiceImpl.java index 35610bbf5..20867b799 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/YKCPushCommandServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/YKCPushCommandServiceImpl.java @@ -253,7 +253,7 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService { // push消息 boolean result = this.push(msg, pileSn, YKCFrameTypeCode.REMOTE_ISSUE_QRCODE_CODE); - log.info("=====平台下发指令===== pileSn:{}, 下发二维码,地址为:{}", pileSn, qrCodePrefix); + log.info("【=====平台下发指令=====】 pileSn:{}, 下发二维码,地址为:{}", pileSn, qrCodePrefix); } /** @@ -541,7 +541,7 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService { this.push(msg, pileSn, YKCFrameTypeCode.RESERVATION_CHARGING_CODE); - log.info("=====平台下发指令=====: 预约充电指令, 交易流水号:{}, 桩编号:{}, 枪口号:{}, 操作:{}, 身份验证:{}, 开始时间:{}, 结束时间:{}, 启动金额:{}", + log.info("【=====平台下发指令=====】: 预约充电指令, 交易流水号:{}, 桩编号:{}, 枪口号:{}, 操作:{}, 身份验证:{}, 开始时间:{}, 结束时间:{}, 启动金额:{}", transactionCode, pileSn, connectorCode, operation, verifyIdentity, DateUtils.formatDateTime(reservedStartTime), DateUtils.formatDateTime(reservedEndTime), amount); } }