Merge branch 'dev' into electricbicycles

This commit is contained in:
Guoqs
2024-07-29 16:15:20 +08:00
149 changed files with 2166 additions and 1393 deletions

View File

@@ -25,9 +25,6 @@ import org.springframework.stereotype.Component;
public class ReadRealTimeMonitorDataHandler extends AbstractHandler{
private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.READ_REAL_TIME_MONITOR_DATA_CODE.getBytes());
@Autowired
private YKCPushCommandServiceImpl ykcPushBusinessServiceImpl;
@Override
public void afterPropertiesSet() throws Exception {

View File

@@ -12,9 +12,9 @@ import org.springframework.stereotype.Component;
*/
@Slf4j
@Component
public class ReserveChargingHandler extends AbstractHandler{
public class ReservationChargingHandler extends AbstractHandler{
private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.RESERVE_CHARGING_CODE.getBytes());
private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.RESERVATION_CHARGING_CODE.getBytes());
@Override
public void afterPropertiesSet() throws Exception {

View File

@@ -11,9 +11,9 @@ import org.springframework.stereotype.Component;
*/
@Slf4j
@Component
public class ReserveChargingResponseHandler extends AbstractHandler{
public class ReservationChargingResponseHandler extends AbstractHandler{
private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.RESERVE_CHARGING_ANSWER_CODE.getBytes());
private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.RESERVATION_CHARGING_ANSWER_CODE.getBytes());
@Override
public void afterPropertiesSet() throws Exception {

View File

@@ -0,0 +1,105 @@
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.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 com.jsowell.pile.dto.ReservationChargingStartupResult;
import com.jsowell.pile.service.PileBasicInfoService;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 预约充电启动结果上送
*/
@Slf4j
@Component
public class ReservationChargingStartupResultHandler extends AbstractHandler{
private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.RESERVATION_CHARGING_STARTUP_RESULT_CODE.getBytes());
@Autowired
private PileBasicInfoService pileBasicInfoService;
@Override
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);
// vin
startIndex += length;
length = 17;
byte[] vinCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
String vinCode = BytesUtil.bcd2Str(vinCodeByteArr);
// 启动结果
startIndex += length;
length = 1;
byte[] startupResultByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
String startupResult = BytesUtil.bcd2Str(startupResultByteArr);
// 失败原因
startIndex += length;
length = 1;
byte[] failReasonByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
String failReason = BytesUtil.bcd2Str(failReasonByteArr);
log.info("[===预约充电启动结果上送===]交易流水号:{}, 桩编号:{}, 枪号:{}, vin:{}, 启动结果:{}, 失败原因:{}",
transactionCode, pileSn, connectorCode, vinCode, startupResult, failReason);
ReservationChargingStartupResult chargingStartupResult = ReservationChargingStartupResult.builder()
.transactionCode(transactionCode)
.pileSn(pileSn)
.connectorCode(connectorCode)
.vinCode(vinCode)
.startupResult(startupResult)
.failReason(failReason)
.build();
pileBasicInfoService.startupResult(chargingStartupResult);
/*
应答
确认结果 0x00 成功 0x01 失败
*/
byte[] confirmResultBytes = Constants.zeroByteArray;
byte[] concatMsgBody = Bytes.concat(transactionCodeByteArr, pileSnByteArr, connectorCodeByteArr, confirmResultBytes);
return getResult(ykcDataProtocol, concatMsgBody);
}
}

View File

@@ -330,8 +330,8 @@ public class TransactionRecordsRequestHandler extends AbstractHandler {
int length = 16;
// 交易流水号
byte[] orderCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
String transactionCode = BytesUtil.bcd2Str(orderCodeByteArr);
byte[] transactionCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
String transactionCode = BytesUtil.bcd2Str(transactionCodeByteArr);
// 桩编码
startIndex += length;
@@ -569,7 +569,7 @@ public class TransactionRecordsRequestHandler extends AbstractHandler {
processOrder(data);
}
} catch (Exception e) {
log.error("处理订单发生异常", e);
log.error("处理订单transactionCode:{}, 发生异常", transactionCode, e);
} finally {
if (uuid.equals(redisCache.getCacheObject(lockKey).toString())) {
redisCache.unLock(lockKey);
@@ -582,7 +582,7 @@ public class TransactionRecordsRequestHandler extends AbstractHandler {
2022年12月15日11点28分发现返回 01非法账单充电桩会持续上传交易记录后面产生的交易记录被阻塞
*/
byte[] confirmResultBytes = Constants.zeroByteArray;
byte[] concatMsgBody = Bytes.concat(orderCodeByteArr, confirmResultBytes);
byte[] concatMsgBody = Bytes.concat(transactionCodeByteArr, confirmResultBytes);
return getResult(ykcDataProtocol, concatMsgBody);
}
@@ -597,7 +597,7 @@ public class TransactionRecordsRequestHandler extends AbstractHandler {
PileBasicInfo pileBasicInfo = pileBasicInfoService.selectPileBasicInfoBySN(pileSn);
if (StringUtils.equals(pileBasicInfo.getBusinessType(), Constants.TWO)) {
personalChargingRecordService.processPersonalChargingRecord(data);
return;
// return;
}
String transactionCode = data.getTransactionCode();