mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
新增 0xA3运营平台主动下发并充启动充电
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
package com.jsowell.netty.handler.yunkuaichong;
|
||||
|
||||
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.enums.ykc.ChargingFailedReasonEnum;
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.YKCUtils;
|
||||
import com.jsowell.netty.factory.YKCOperateFactory;
|
||||
import com.jsowell.pile.service.OrderBasicInfoService;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 0xA3 远程并充启机命令回复
|
||||
*
|
||||
* @author Lemon
|
||||
* @Date 2025/6/19 15:40:15
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class AnswerPlatformStartMergeChargeHandler extends AbstractYkcHandler {
|
||||
private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.ANSWER_PLATFORM_START_MERGE_CODE.getBytes());
|
||||
|
||||
@Autowired
|
||||
private OrderBasicInfoService orderBasicInfoService;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
YKCOperateFactory.register(type, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) {
|
||||
// 获取消息体
|
||||
byte[] msgBody = ykcDataProtocol.getMsgBody();
|
||||
|
||||
int startIndex = 0;
|
||||
int length = 16;
|
||||
|
||||
// 交易流水号
|
||||
byte[] transactionCodeByte = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String transactionCode = BytesUtil.bcd2Str(transactionCodeByte);
|
||||
|
||||
// 桩编码
|
||||
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);
|
||||
|
||||
// 启动结果 0x00失败 0x01成功
|
||||
startIndex += length;
|
||||
byte[] startResultByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String startResult = BytesUtil.bcd2Str(startResultByteArr);
|
||||
|
||||
/**
|
||||
* 失败原因
|
||||
*
|
||||
* 桩在收到启充命令后,检测到未插枪则发送 0x33 报文回复充电失败。
|
||||
* 若在 60 秒(以收到 0x34 时间开始计算)内检测到枪重新连接,则补送 0x33 成功报文;超时或者离线等其他异常,桩不启充、不补发 0x33 报文
|
||||
* 0x00 无
|
||||
* 0x01 设备编号不匹配
|
||||
* 0x02 枪已在充电
|
||||
* 0x03 设备故障
|
||||
* 0x04 设备离线
|
||||
* 0x05 未插枪
|
||||
*/
|
||||
startIndex += length;
|
||||
byte[] failedReasonByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String failedReason = BytesUtil.bin2HexStr(failedReasonByteArr);
|
||||
String failedReasonMsg = ChargingFailedReasonEnum.getMsgByCode(Integer.parseInt(failedReason, 16));
|
||||
|
||||
// 主辅枪标记
|
||||
// 0x00 主枪
|
||||
// 0x01 辅枪
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
byte[] connectorMarkByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String connectorMark = BytesUtil.bcd2Str(connectorMarkByteArr);
|
||||
|
||||
// 并充序号
|
||||
// 由桩生成:年月日时分秒,多个枪并充时上送并充序号一致,表示为同一次并充操作
|
||||
startIndex += length;
|
||||
length = 6;
|
||||
byte[] mergeChargeNumberByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String mergeChargeNumber = BytesUtil.bcd2Str(mergeChargeNumberByteArr);
|
||||
|
||||
if (StringUtils.equals(startResult, Constants.DOUBLE_ZERO)) {
|
||||
// 启动失败 2025年4月2日16点39分修改逻辑:启动失败后不退款, 使用支付完成未启动定时任务退款
|
||||
// orderBasicInfoService.chargingPileFailedToStart(transactionCode, failedReasonMsg);
|
||||
} else {
|
||||
// 启动成功
|
||||
orderBasicInfoService.chargingPileStartedSuccessfully(transactionCode);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user