mirror of
https://gitee.com/san-bing/JChargePointProtocol
synced 2026-05-04 09:59:55 +08:00
* !44 comment * !39 添加下行日志打印 * !36 扩展计价领域模型 * !35 webui 初步成型 * !34 webui 初步成型
This commit is contained in:
@@ -73,6 +73,9 @@
|
||||
|
||||
---
|
||||
|
||||
#### 0x23 充电过程BMS需求与充电机输出
|
||||
`68 30 6c 40 00 23 20 23 12 12 00 00 10 01 25 08 27 23 03 54 04 67 20 23 12 12 00 00 10 01 a6 13 48 17 02 8d 12 12 14 58 01 53 11 00 92 12 32 14 00 00 b2 d8`
|
||||
|
||||
#### 0x25 充电过程BMS信息
|
||||
`68 31 01 00 00 25 32 01 02 00 00 00 00 11 15 11 16 15 55 35 02 60 20 23 12 12 00 00 10 01 01 01 01 01 01 01 00 01 00 01 00 01 00 01 00 01 00 01 00 00 00 BE C8`
|
||||
|
||||
@@ -113,14 +116,17 @@
|
||||
#### 0x41 远程账户余额更新应答
|
||||
`68 14 19 00 00 41 20 23 12 12 00 00 10 10 00 00 00 00 12 34 56 00 bc 16`
|
||||
|
||||
---
|
||||
|
||||
#### 0x44 离线卡数据同步
|
||||
`68 3f 02 00 00 44 20 23 12 12 00 00 10 03 00 00 00 10 00 00 00 00 12 34 56 10 00 00 00 00 12 34 56 10 00 00 00 00 12 34 57 10 00 00 00 00 12 34 57 10 00 00 00 00 12 34 58 10 00 00 00 00 12 34 58 ba 94`
|
||||
|
||||
#### 0x43 离线卡数据同步应答
|
||||
#### 成功
|
||||
##### 成功
|
||||
`68 0d 19 00 00 43 20 23 12 12 00 00 10 01 00 38 83`
|
||||
#### 失败
|
||||
##### 失败
|
||||
`68 0d 19 00 00 43 20 23 12 12 00 00 10 00 01 f8 d3`
|
||||
|
||||
---
|
||||
|
||||
#### 0x56 对时设置
|
||||
@@ -128,3 +134,5 @@
|
||||
|
||||
#### 0x55 对时设置应答
|
||||
`68 12 01 00 00 55 20 23 12 12 00 00 10 E0 2E 0C 0C 15 08 19 AB 37`
|
||||
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import sanbing.jcpp.infrastructure.util.codec.BCDUtil;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.PeriodProto;
|
||||
import sanbing.jcpp.protocol.domain.DownlinkCmdEnum;
|
||||
import sanbing.jcpp.protocol.listener.tcp.TcpSession;
|
||||
import sanbing.jcpp.protocol.listener.tcp.enums.SequenceNumberLength;
|
||||
@@ -29,7 +29,7 @@ import static sanbing.jcpp.infrastructure.util.codec.ByteUtil.crcSum;
|
||||
import static sanbing.jcpp.infrastructure.util.codec.ByteUtil.toBytes;
|
||||
|
||||
/**
|
||||
* @author baigod
|
||||
* @author 九筒
|
||||
*/
|
||||
public class AbstractYunKuaiChongCmdExe {
|
||||
|
||||
@@ -61,8 +61,8 @@ public class AbstractYunKuaiChongCmdExe {
|
||||
return BCDUtil.toBytes(PRICING_ID_DECIMAL_FORMAT.format(pricingId % 10000));
|
||||
}
|
||||
|
||||
protected static byte getFlagForCurrentTime(List<ProtocolProto.PeriodProto> periodList, LocalTime currentTime) {
|
||||
for (ProtocolProto.PeriodProto period : periodList) {
|
||||
protected static byte getFlagForCurrentTime(List<PeriodProto> periodList, LocalTime currentTime) {
|
||||
for (PeriodProto period : periodList) {
|
||||
LocalTime beginLt = LocalTime.parse(period.getBegin());
|
||||
LocalTime endLt = "00:00".equals(period.getEnd()) ? LocalTime.MAX : LocalTime.parse(period.getEnd());
|
||||
if ((currentTime.equals(beginLt) || currentTime.isAfter(beginLt)) && currentTime.isBefore(endLt)) {
|
||||
@@ -218,7 +218,7 @@ public class AbstractYunKuaiChongCmdExe {
|
||||
*/
|
||||
protected static void writeParamFillZero(ByteBuf target, String param, int maxLength) {
|
||||
if (maxLength <= 0) {
|
||||
throw new IllegalArgumentException("maxLength must be positive");
|
||||
throw new IllegalArgumentException("最大长度必须为正数");
|
||||
}
|
||||
|
||||
if (param == null) {
|
||||
@@ -257,7 +257,7 @@ public class AbstractYunKuaiChongCmdExe {
|
||||
*/
|
||||
protected static void writeParamFillZero(ByteBuf target, int param, int maxLength) {
|
||||
if (maxLength <= 0) {
|
||||
throw new IllegalArgumentException("maxLength must be positive");
|
||||
throw new IllegalArgumentException("最大长度必须为正数");
|
||||
}
|
||||
|
||||
// 确保目标ByteBuf有足够的写入空间
|
||||
|
||||
@@ -10,7 +10,7 @@ import sanbing.jcpp.protocol.ProtocolContext;
|
||||
import sanbing.jcpp.protocol.listener.tcp.TcpSession;
|
||||
|
||||
/**
|
||||
* @author baigod
|
||||
* @author 九筒
|
||||
*/
|
||||
public abstract class YunKuaiChongDownlinkCmdExe extends AbstractYunKuaiChongCmdExe {
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.io.Serializable;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author baigod
|
||||
* @author 九筒
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
|
||||
@@ -6,10 +6,12 @@
|
||||
*/
|
||||
package sanbing.jcpp.protocol.yunkuaichong;
|
||||
|
||||
import sanbing.jcpp.protocol.enums.SupportedProtocols;
|
||||
|
||||
/**
|
||||
* 云快充协议常量定义
|
||||
*
|
||||
* @author sanbing
|
||||
* @author 九筒
|
||||
* @since 2024-12-16
|
||||
*/
|
||||
public final class YunKuaiChongProtocolConstants {
|
||||
@@ -23,13 +25,13 @@ public final class YunKuaiChongProtocolConstants {
|
||||
*/
|
||||
public static final class ProtocolNames {
|
||||
/** 云快充协议 v1.5.0 */
|
||||
public static final String YUNKUAICHONG_V150 = "yunkuaichongV150";
|
||||
public static final String YUNKUAICHONG_V150 = SupportedProtocols.YUNKUAICHONG_V150;
|
||||
|
||||
/** 云快充协议 v1.6.0 */
|
||||
public static final String YUNKUAICHONG_V160 = "yunkuaichongV160";
|
||||
public static final String YUNKUAICHONG_V160 = SupportedProtocols.YUNKUAICHONG_V160;
|
||||
|
||||
/** 云快充协议 v1.7.0 */
|
||||
public static final String YUNKUAICHONG_V170 = "yunkuaichongV170";
|
||||
public static final String YUNKUAICHONG_V170 = SupportedProtocols.YUNKUAICHONG_V170;
|
||||
|
||||
// 注解专用简短别名
|
||||
public static final String V150 = YUNKUAICHONG_V150;
|
||||
@@ -40,4 +42,4 @@ public final class YunKuaiChongProtocolConstants {
|
||||
// 工具类,禁止实例化
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -137,7 +137,7 @@ public class YunKuaiChongProtocolMessageProcessor extends ProtocolMessageProcess
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downlinkHandle(SessionToHandlerMsg sessionToHandlerMsg) {
|
||||
protected void doDownlinkHandle(SessionToHandlerMsg sessionToHandlerMsg) {
|
||||
TcpSession session = (TcpSession) sessionToHandlerMsg.session();
|
||||
|
||||
DownlinkRequestMessage protocolDownlinkMsg = sessionToHandlerMsg.downlinkMsg();
|
||||
|
||||
@@ -9,12 +9,13 @@ package sanbing.jcpp.protocol.yunkuaichong;
|
||||
import com.google.protobuf.ByteString;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import sanbing.jcpp.infrastructure.util.jackson.JacksonUtil;
|
||||
import sanbing.jcpp.infrastructure.util.trace.TracerContextUtil;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.UplinkQueueMessage;
|
||||
import sanbing.jcpp.protocol.ProtocolContext;
|
||||
import sanbing.jcpp.protocol.listener.tcp.TcpSession;
|
||||
|
||||
/**
|
||||
* @author baigod
|
||||
* @author 九筒
|
||||
*/
|
||||
@Slf4j
|
||||
public abstract class YunKuaiChongUplinkCmdExe extends AbstractYunKuaiChongCmdExe {
|
||||
@@ -22,11 +23,15 @@ public abstract class YunKuaiChongUplinkCmdExe extends AbstractYunKuaiChongCmdEx
|
||||
public abstract void execute(TcpSession tcpSession, YunKuaiChongUplinkMessage yunKuaiChongUplinkMessage, ProtocolContext ctx);
|
||||
|
||||
protected UplinkQueueMessage.Builder uplinkMessageBuilder(String messageKey, TcpSession tcpSession, YunKuaiChongUplinkMessage yunKuaiChongUplinkMessage) {
|
||||
// 从Tracer总获取当前时间
|
||||
long ts = TracerContextUtil.getCurrentTracer().getTracerTs();
|
||||
|
||||
return UplinkQueueMessage.newBuilder()
|
||||
.setMessageIdMSB(yunKuaiChongUplinkMessage.getId().getMostSignificantBits())
|
||||
.setMessageIdLSB(yunKuaiChongUplinkMessage.getId().getLeastSignificantBits())
|
||||
.setSessionIdMSB(tcpSession.getId().getMostSignificantBits())
|
||||
.setSessionIdLSB(tcpSession.getId().getLeastSignificantBits())
|
||||
.setTs(ts)
|
||||
.setRequestData(ByteString.copyFrom(JacksonUtil.writeValueAsBytes(yunKuaiChongUplinkMessage)))
|
||||
.setMessageKey(messageKey)
|
||||
.setProtocolName(tcpSession.getProtocolName());
|
||||
|
||||
@@ -14,13 +14,13 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* 云快充协议下行命令转换器(单例)
|
||||
*
|
||||
* <p>
|
||||
* 建立通用下行命令与云快充协议特定命令字的显式转换关系
|
||||
* 使用Map存储转换关系,提供O(1)性能
|
||||
*
|
||||
* <p>
|
||||
* 采用单例模式,避免重复实例化
|
||||
*
|
||||
* @author sanbing
|
||||
* @author 九筒
|
||||
* @since 2024-12-16
|
||||
*/
|
||||
public class YunKuaiChongDownlinkCmdConverter implements DownlinkCmdConverter {
|
||||
|
||||
@@ -15,7 +15,7 @@ import sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongProtocolMessageProcessor;
|
||||
import static sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongProtocolConstants.ProtocolNames.YUNKUAICHONG_V150;
|
||||
|
||||
/**
|
||||
* @author baigod
|
||||
* @author 九筒
|
||||
*/
|
||||
|
||||
@ProtocolComponent(YUNKUAICHONG_V150)
|
||||
|
||||
@@ -14,7 +14,6 @@ import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import sanbing.jcpp.infrastructure.util.codec.BCDUtil;
|
||||
import sanbing.jcpp.infrastructure.util.jackson.JacksonUtil;
|
||||
import sanbing.jcpp.infrastructure.util.trace.TracerContextUtil;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.BmsAbortProto;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.UplinkQueueMessage;
|
||||
import sanbing.jcpp.protocol.ProtocolContext;
|
||||
@@ -40,9 +39,6 @@ public class YunKuaiChongV150BmsAbortULCmd extends YunKuaiChongUplinkCmdExe {
|
||||
log.debug("{} 云快充1.5.0充电阶段BMS中止", tcpSession);
|
||||
ByteBuf byteBuf = Unpooled.wrappedBuffer(yunKuaiChongUplinkMessage.getMsgBody());
|
||||
|
||||
// 从Tracer总获取当前时间
|
||||
long ts = TracerContextUtil.getCurrentTracer().getTracerTs();
|
||||
|
||||
ObjectNode additionalInfo = JacksonUtil.newObjectNode();
|
||||
// 1.交易流水号
|
||||
byte[] tradeNoBytes = new byte[16];
|
||||
@@ -71,7 +67,6 @@ public class YunKuaiChongV150BmsAbortULCmd extends YunKuaiChongUplinkCmdExe {
|
||||
additionalInfo.put("BMS中止充电错误原因", parseErrorReasons(errorReasonByte));
|
||||
|
||||
BmsAbortProto proto = BmsAbortProto.newBuilder()
|
||||
.setTs(ts)
|
||||
.setPileCode(pileCode)
|
||||
.setGunCode(gunCode)
|
||||
.setTradeNo(tradeNo)
|
||||
|
||||
@@ -12,7 +12,6 @@ import io.netty.buffer.Unpooled;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import sanbing.jcpp.infrastructure.util.codec.BCDUtil;
|
||||
import sanbing.jcpp.infrastructure.util.jackson.JacksonUtil;
|
||||
import sanbing.jcpp.infrastructure.util.trace.TracerContextUtil;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.BmsChargingErrorProto;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.UplinkQueueMessage;
|
||||
import sanbing.jcpp.protocol.ProtocolContext;
|
||||
@@ -34,8 +33,6 @@ public class YunKuaiChongV150BmsChargingErrorULCmd extends YunKuaiChongUplinkCmd
|
||||
public void execute(TcpSession tcpSession, YunKuaiChongUplinkMessage yunKuaiChongUplinkMessage, ProtocolContext ctx) {
|
||||
log.debug("{} 云快充1.5.0 充电桩与 BMS 充电错误报文", tcpSession);
|
||||
ByteBuf byteBuf = Unpooled.wrappedBuffer(yunKuaiChongUplinkMessage.getMsgBody());
|
||||
// 从Tracer总获取当前时间
|
||||
long ts = TracerContextUtil.getCurrentTracer().getTracerTs();
|
||||
|
||||
ObjectNode additionalInfo = JacksonUtil.newObjectNode();
|
||||
byte[] tradeNoBytes = new byte[16];
|
||||
@@ -118,7 +115,6 @@ public class YunKuaiChongV150BmsChargingErrorULCmd extends YunKuaiChongUplinkCmd
|
||||
|
||||
// 转发到后端
|
||||
BmsChargingErrorProto bmsChargingErrorProto = BmsChargingErrorProto.newBuilder()
|
||||
.setTs(ts)
|
||||
.setPileCode(pileCode)
|
||||
.setTradeNo(tradeNo)
|
||||
.setGunCode(gunCode)
|
||||
|
||||
@@ -12,7 +12,6 @@ import io.netty.buffer.Unpooled;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import sanbing.jcpp.infrastructure.util.codec.BCDUtil;
|
||||
import sanbing.jcpp.infrastructure.util.jackson.JacksonUtil;
|
||||
import sanbing.jcpp.infrastructure.util.trace.TracerContextUtil;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.BmsChargingInfoProto;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.UplinkQueueMessage;
|
||||
import sanbing.jcpp.protocol.ProtocolContext;
|
||||
@@ -35,8 +34,6 @@ public class YunKuaiChongV150BmsChargingInfoULCmd extends YunKuaiChongUplinkCmdE
|
||||
public void execute(TcpSession tcpSession, YunKuaiChongUplinkMessage yunKuaiChongUplinkMessage, ProtocolContext ctx) {
|
||||
log.debug("{} 云快充1.5.0充电过程BMS信息", tcpSession);
|
||||
ByteBuf byteBuf = Unpooled.wrappedBuffer(yunKuaiChongUplinkMessage.getMsgBody());
|
||||
// 从Tracer总获取当前时间
|
||||
long ts = TracerContextUtil.getCurrentTracer().getTracerTs();
|
||||
|
||||
ObjectNode additionalInfo = JacksonUtil.newObjectNode();
|
||||
// 1.交易流水号
|
||||
@@ -79,7 +76,6 @@ public class YunKuaiChongV150BmsChargingInfoULCmd extends YunKuaiChongUplinkCmdE
|
||||
byteBuf.skipBytes(2);
|
||||
|
||||
BmsChargingInfoProto bmsCharingInfoProto = BmsChargingInfoProto.newBuilder()
|
||||
.setTs(ts)
|
||||
.setPileCode(pileCode)
|
||||
.setTradeNo(tradeNo)
|
||||
.setGunCode(gunCode)
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
/**
|
||||
* 开源代码,仅供学习和交流研究使用,商用请联系三丙
|
||||
* 微信:mohan_88888
|
||||
* 抖音:程序员三丙
|
||||
* 付费课程知识星球:https://t.zsxq.com/aKtXo
|
||||
*/
|
||||
package sanbing.jcpp.protocol.yunkuaichong.v150.cmd;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import sanbing.jcpp.infrastructure.util.codec.BCDUtil;
|
||||
import sanbing.jcpp.infrastructure.util.jackson.JacksonUtil;
|
||||
import sanbing.jcpp.infrastructure.util.trace.TracerContextUtil;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.BmsDemandChargerOutputProto;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.UplinkQueueMessage;
|
||||
import sanbing.jcpp.protocol.ProtocolContext;
|
||||
import sanbing.jcpp.protocol.annotation.ProtocolCmd;
|
||||
import sanbing.jcpp.protocol.listener.tcp.TcpSession;
|
||||
import sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongUplinkCmdExe;
|
||||
import sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongUplinkMessage;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import static sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongProtocolConstants.ProtocolNames.*;
|
||||
|
||||
/**
|
||||
* 云快充1.5.0 充电过程BMS需求与充电机输出
|
||||
*/
|
||||
@Slf4j
|
||||
@ProtocolCmd(value = 0x23, protocolNames = {V150, V160, V170})
|
||||
public class YunKuaiChongV150BmsDemandChargerOutputULCmd extends YunKuaiChongUplinkCmdExe {
|
||||
|
||||
@Override
|
||||
public void execute(TcpSession tcpSession, YunKuaiChongUplinkMessage yunKuaiChongUplinkMessage, ProtocolContext ctx) {
|
||||
log.debug("{} 云快充1.5.0充电过程BMS需求与充电机输出", tcpSession);
|
||||
ByteBuf byteBuf = Unpooled.wrappedBuffer(yunKuaiChongUplinkMessage.getMsgBody());
|
||||
|
||||
// 从Tracer总获取当前时间
|
||||
long ts = TracerContextUtil.getCurrentTracer().getTracerTs();
|
||||
|
||||
ObjectNode additionalInfo = JacksonUtil.newObjectNode();
|
||||
|
||||
// 1.交易流水号
|
||||
byte[] tradeNoBytes = new byte[16];
|
||||
byteBuf.readBytes(tradeNoBytes);
|
||||
String tradeNo = BCDUtil.toString(tradeNoBytes);
|
||||
|
||||
// 2.桩编号
|
||||
byte[] pileCodeBytes = new byte[7];
|
||||
byteBuf.readBytes(pileCodeBytes);
|
||||
String pileCode = BCDUtil.toString(pileCodeBytes);
|
||||
|
||||
// 3.枪号
|
||||
byte gunCodeByte = byteBuf.readByte();
|
||||
String gunCode = BCDUtil.toString(gunCodeByte);
|
||||
|
||||
// 4.BMS电压需求 0.1 V/位, 0 V 偏移量
|
||||
additionalInfo.put("BMS电压需求", reduceMagnification(byteBuf.readUnsignedShortLE(), 10));
|
||||
|
||||
// 5.BMS电流需求 0.1 A/位, -400 A 偏移量
|
||||
additionalInfo.put("BMS电流需求", reduceMagnification(byteBuf.readUnsignedShortLE(), 10).subtract(new BigDecimal("400")));
|
||||
|
||||
// 6.BMS充电模式 0x01:恒压充电; 0x02:恒流充电
|
||||
additionalInfo.put("BMS充电模式", byteBuf.readByte() == 0x01 ? "恒压充电" : "恒流充电");
|
||||
|
||||
// 7.BMS充电电压测量值 0.1 V/位, 0 V 偏移量
|
||||
additionalInfo.put("BMS充电电压测量值", reduceMagnification(byteBuf.readUnsignedShortLE(), 10));
|
||||
|
||||
// 8.BMS充电电流测量值 0.1 A/位, -400 A 偏移量
|
||||
additionalInfo.put("BMS充电电流测量值", reduceMagnification(byteBuf.readUnsignedShortLE(), 10).subtract(new BigDecimal("400")));
|
||||
|
||||
// 9.BMS最高单体动力蓄电池电压及组号
|
||||
int i = byteBuf.readUnsignedShortLE();
|
||||
// 1-12 位:最高单体动力蓄电池电压,数据分辨率: 0.01V/位,0V偏移量;数据范围:0~24V
|
||||
additionalInfo.put("BMS最高单体动力蓄电池电压", reduceMagnification(i & 0x0FFF, 100));
|
||||
// 13-16 位: 最高单体动力蓄电池电压所在组号,数据分辨率: 1/位, 0 偏移量;数据范围:0~15
|
||||
additionalInfo.put("BMS最高单体动力蓄电池电压所在组号", (i >> 12) & 0x0F);
|
||||
|
||||
// 10.BMS当前荷电状态 SOC( %)
|
||||
additionalInfo.put("BMS当前荷电状态SOC", byteBuf.readByte());
|
||||
|
||||
// 11.BMS 估算剩余充电时间
|
||||
additionalInfo.put("BMS估算剩余充电时间", byteBuf.readUnsignedShortLE());
|
||||
|
||||
// 12.电桩电压输出值
|
||||
additionalInfo.put("电桩电压输出值", reduceMagnification(byteBuf.readUnsignedShortLE(), 10));
|
||||
|
||||
// 13.电桩电流输出值
|
||||
additionalInfo.put("电桩电流输出值", reduceMagnification(byteBuf.readUnsignedShortLE(), 10).subtract(new BigDecimal("400")));
|
||||
|
||||
// 14.累计充电时间
|
||||
additionalInfo.put("累计充电时间", byteBuf.readUnsignedShortLE());
|
||||
|
||||
BmsDemandChargerOutputProto proto = BmsDemandChargerOutputProto.newBuilder()
|
||||
.setPileCode(pileCode)
|
||||
.setGunCode(gunCode)
|
||||
.setTradeNo(tradeNo)
|
||||
.setAdditionalInfo(additionalInfo.toString())
|
||||
.build();
|
||||
|
||||
// 转发到后端
|
||||
UplinkQueueMessage uplinkQueueMessage = uplinkMessageBuilder(pileCode, tcpSession, yunKuaiChongUplinkMessage)
|
||||
.setBmsDemandChargerOutputProto(proto)
|
||||
.build();
|
||||
|
||||
tcpSession.getForwarder().sendMessage(uplinkQueueMessage);
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,6 @@ import io.netty.buffer.Unpooled;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import sanbing.jcpp.infrastructure.util.codec.BCDUtil;
|
||||
import sanbing.jcpp.infrastructure.util.jackson.JacksonUtil;
|
||||
import sanbing.jcpp.infrastructure.util.trace.TracerContextUtil;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.BmsHandshakeProto;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.UplinkQueueMessage;
|
||||
import sanbing.jcpp.protocol.ProtocolContext;
|
||||
@@ -29,7 +28,7 @@ import static sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongProtocolConstants.P
|
||||
/**
|
||||
* 云快充1.5.0 充电握手
|
||||
*
|
||||
* @author baigod
|
||||
* @author 九筒
|
||||
*/
|
||||
@Slf4j
|
||||
@ProtocolCmd(value = 0x15, protocolNames = {V150, V160, V170})
|
||||
@@ -39,9 +38,6 @@ public class YunKuaiChongV150BmsHandshakeULCmd extends YunKuaiChongUplinkCmdExe
|
||||
log.debug("{} 云快充1.5.0充电握手", tcpSession);
|
||||
ByteBuf byteBuf = Unpooled.wrappedBuffer(yunKuaiChongUplinkMessage.getMsgBody());
|
||||
|
||||
// 从Tracer总获取当前时间
|
||||
long ts = TracerContextUtil.getCurrentTracer().getTracerTs();
|
||||
|
||||
ObjectNode additionalInfo = JacksonUtil.newObjectNode();
|
||||
|
||||
// 1.交易流水号
|
||||
@@ -108,7 +104,6 @@ public class YunKuaiChongV150BmsHandshakeULCmd extends YunKuaiChongUplinkCmdExe
|
||||
|
||||
// 构建BmsHandshakeProto对象
|
||||
BmsHandshakeProto bmsHandshakeProto = BmsHandshakeProto.newBuilder()
|
||||
.setTs(ts)
|
||||
.setPileCode(pileCode)
|
||||
.setGunCode(gunCode)
|
||||
.setTradeNo(tradeNo)
|
||||
|
||||
@@ -10,7 +10,6 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import sanbing.jcpp.infrastructure.util.codec.BCDUtil;
|
||||
import sanbing.jcpp.infrastructure.util.trace.TracerContextUtil;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.BmsParamConfigReportProto;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.UplinkQueueMessage;
|
||||
import sanbing.jcpp.protocol.ProtocolContext;
|
||||
@@ -46,9 +45,6 @@ public class YunKuaiChongV150BmsParamConfigReportULCmd extends YunKuaiChongUplin
|
||||
log.info("{} 云快充1.5.0充电桩参数配置帧请求", tcpSession);
|
||||
// 将消息体包装为ByteBuf以便读取
|
||||
ByteBuf byteBuf = Unpooled.wrappedBuffer(yunKuaiChongUplinkMessage.getMsgBody());
|
||||
// 从Tracer总获取当前时间
|
||||
long ts = TracerContextUtil.getCurrentTracer().getTracerTs();
|
||||
|
||||
/* 按协议顺序解析消息体 */
|
||||
|
||||
// 1. 交易流水号:16字节BCD编码字符串
|
||||
@@ -95,7 +91,6 @@ public class YunKuaiChongV150BmsParamConfigReportULCmd extends YunKuaiChongUplin
|
||||
|
||||
// 转发到后端
|
||||
BmsParamConfigReportProto bmsParamConfigReportProto = BmsParamConfigReportProto.newBuilder()
|
||||
.setTs(ts)
|
||||
.setPileCode(pileCode)
|
||||
.setTradeNo(tradeNo)
|
||||
.setGunCode(gunCode)
|
||||
|
||||
@@ -26,7 +26,7 @@ import static sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongProtocolConstants.P
|
||||
/**
|
||||
* 云快充1.5.0 充电桩心跳包
|
||||
*
|
||||
* @author baigod
|
||||
* @author 九筒
|
||||
*/
|
||||
@Slf4j
|
||||
@ProtocolCmd(value = 0x03, protocolNames = {V150, V160, V170})
|
||||
|
||||
@@ -10,7 +10,6 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import sanbing.jcpp.infrastructure.util.codec.BCDUtil;
|
||||
import sanbing.jcpp.infrastructure.util.trace.TracerContextUtil;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.GroundLockStatusProto;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.UplinkQueueMessage;
|
||||
import sanbing.jcpp.protocol.ProtocolContext;
|
||||
@@ -40,8 +39,6 @@ public class YunKuaiChongV150LockStatusULCmd extends YunKuaiChongUplinkCmdExe {
|
||||
log.info("{} 云快充1.5.0地锁状态/报警信息帧请求", tcpSession);
|
||||
// 将消息体包装为ByteBuf以便读取
|
||||
ByteBuf byteBuf = Unpooled.wrappedBuffer(yunKuaiChongUplinkMessage.getMsgBody());
|
||||
// 从Tracer总获取当前时间
|
||||
long ts = TracerContextUtil.getCurrentTracer().getTracerTs();
|
||||
|
||||
/* 按协议顺序解析消息体 */
|
||||
|
||||
@@ -73,7 +70,6 @@ public class YunKuaiChongV150LockStatusULCmd extends YunKuaiChongUplinkCmdExe {
|
||||
|
||||
// 构建转发消息
|
||||
GroundLockStatusProto groundLockStatusProto = GroundLockStatusProto.newBuilder()
|
||||
.setTs(ts)
|
||||
.setPileCode(pileCode)
|
||||
.setGunCode(gunCode)
|
||||
.setLockStatus(lockStatus)
|
||||
|
||||
@@ -28,9 +28,9 @@ import java.util.Arrays;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static sanbing.jcpp.infrastructure.util.config.ThreadPoolConfiguration.PROTOCOL_SESSION_SCHEDULED;
|
||||
import static sanbing.jcpp.proto.gen.ProtocolProto.SessionCloseReason.SESSION_CLOSE_MANUALLY;
|
||||
import static sanbing.jcpp.protocol.domain.DownlinkCmdEnum.LOGIN_ACK;
|
||||
import static sanbing.jcpp.protocol.domain.DownlinkCmdEnum.SYNC_TIME_REQUEST;
|
||||
import static sanbing.jcpp.protocol.domain.SessionCloseReason.MANUALLY;
|
||||
import static sanbing.jcpp.protocol.listener.tcp.TcpSession.SCHEDULE_KEY_AUTO_SYNC_TIME;
|
||||
import static sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongDwonlinkMessage.FAILURE_BYTE;
|
||||
import static sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongDwonlinkMessage.SUCCESS_BYTE;
|
||||
@@ -39,7 +39,7 @@ import static sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongProtocolConstants.P
|
||||
/**
|
||||
* 云快充1.5.0登录认证应答
|
||||
*
|
||||
* @author baigod
|
||||
* @author 九筒
|
||||
*/
|
||||
@Slf4j
|
||||
@ProtocolCmd(value = 0x02, protocolNames = {V150, V160, V170})
|
||||
@@ -78,7 +78,7 @@ public class YunKuaiChongV150LoginAckDLCmd extends YunKuaiChongDownlinkCmdExe {
|
||||
loginAck(tcpSession, pileCodeBytes, requestData, false);
|
||||
|
||||
// 断开连接
|
||||
tcpSession.close(MANUALLY);
|
||||
tcpSession.close(SESSION_CLOSE_MANUALLY);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import sanbing.jcpp.infrastructure.util.codec.BCDUtil;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.OfflineCardSyncRequest;
|
||||
import sanbing.jcpp.protocol.ProtocolContext;
|
||||
import sanbing.jcpp.protocol.annotation.ProtocolCmd;
|
||||
import sanbing.jcpp.protocol.listener.tcp.TcpSession;
|
||||
@@ -39,7 +39,7 @@ public class YunKuaiChongV150OfflineCardSyncRequestDLCmd extends YunKuaiChongDow
|
||||
return;
|
||||
}
|
||||
|
||||
ProtocolProto.OfflineCardSyncRequest request = message.getMsg().getOfflineCardSyncRequest();
|
||||
OfflineCardSyncRequest request = message.getMsg().getOfflineCardSyncRequest();
|
||||
|
||||
if (request.getTotal() > 15) {
|
||||
log.error("云快充1.5.0 离线卡数据同步 下发卡个数最大支持: 15个当前: {}个", request.getTotal());
|
||||
@@ -67,7 +67,7 @@ public class YunKuaiChongV150OfflineCardSyncRequestDLCmd extends YunKuaiChongDow
|
||||
* @param request request
|
||||
* @return bufferInitialCapacity
|
||||
*/
|
||||
private int bufferInitialCapacity(ProtocolProto.OfflineCardSyncRequest request) {
|
||||
private int bufferInitialCapacity(OfflineCardSyncRequest request) {
|
||||
return (8 + 8) * request.getCardInfoCount() + 7 + 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,8 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import sanbing.jcpp.infrastructure.util.codec.BCDUtil;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.OfflineCardSyncResponse;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.UplinkQueueMessage;
|
||||
import sanbing.jcpp.protocol.ProtocolContext;
|
||||
import sanbing.jcpp.protocol.annotation.ProtocolCmd;
|
||||
import sanbing.jcpp.protocol.listener.tcp.TcpSession;
|
||||
@@ -65,8 +66,8 @@ public class YunKuaiChongV150OfflineCardSyncResponseULCmd extends YunKuaiChongUp
|
||||
failureReason = byteBuf.readByte();
|
||||
}
|
||||
|
||||
ProtocolProto.UplinkQueueMessage queueMessage = uplinkMessageBuilder(pileCode, tcpSession, message)
|
||||
.setOfflineCardSyncResponse(ProtocolProto.OfflineCardSyncResponse.newBuilder()
|
||||
UplinkQueueMessage queueMessage = uplinkMessageBuilder(pileCode, tcpSession, message)
|
||||
.setOfflineCardSyncResponse(OfflineCardSyncResponse.newBuilder()
|
||||
.setPileCode(pileCode)
|
||||
.setSuccess(saveResult == 0x01)
|
||||
.setErrorMsg(errorMsg(saveResult, failureReason))
|
||||
|
||||
@@ -10,7 +10,8 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import sanbing.jcpp.infrastructure.util.codec.BCDUtil;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.OtaResponse;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.UplinkQueueMessage;
|
||||
import sanbing.jcpp.protocol.ProtocolContext;
|
||||
import sanbing.jcpp.protocol.annotation.ProtocolCmd;
|
||||
import sanbing.jcpp.protocol.listener.tcp.TcpSession;
|
||||
@@ -56,8 +57,8 @@ public class YunKuaiChongV150OtaResponseULCmd extends YunKuaiChongUplinkCmdExe {
|
||||
// 升级状态 // 0x00成功 0x01编号错误 0x01程序与桩型号不符 0x01下载更新文件超时
|
||||
byte upgradeStatus = byteBuf.readByte();
|
||||
|
||||
ProtocolProto.UplinkQueueMessage queueMessage = uplinkMessageBuilder(pileCode, tcpSession, message)
|
||||
.setOtaResponse(ProtocolProto.OtaResponse.newBuilder()
|
||||
UplinkQueueMessage queueMessage = uplinkMessageBuilder(pileCode, tcpSession, message)
|
||||
.setOtaResponse(OtaResponse.newBuilder()
|
||||
.setPileCode(pileCode)
|
||||
.setSuccess(upgradeStatus == 0x00)
|
||||
.setErrorMsg(UPGRADE_STATUS.getOrDefault(upgradeStatus,UNKNOWN_MSG))
|
||||
|
||||
@@ -9,10 +9,7 @@ package sanbing.jcpp.protocol.yunkuaichong.v150.cmd;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.FlagPriceProto;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.PeriodProto;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.PricingModelProto;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.QueryPricingResponse;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.*;
|
||||
import sanbing.jcpp.protocol.ProtocolContext;
|
||||
import sanbing.jcpp.protocol.annotation.ProtocolCmd;
|
||||
import sanbing.jcpp.protocol.listener.tcp.TcpSession;
|
||||
@@ -31,7 +28,7 @@ import static sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongProtocolConstants.P
|
||||
/**
|
||||
* 计费模型请求应答
|
||||
*
|
||||
* @author baigod
|
||||
* @author 九筒
|
||||
*/
|
||||
@Slf4j
|
||||
@ProtocolCmd(value = 0x0A, protocolNames = {V150, V160, V170})
|
||||
@@ -50,8 +47,20 @@ public class YunKuaiChongV150QueryPricingModelAckDLCmd extends YunKuaiChongDownl
|
||||
long pricingId = queryPricingResponse.getPricingId();
|
||||
String pileCode = queryPricingResponse.getPileCode();
|
||||
PricingModelProto pricingModel = queryPricingResponse.getPricingModel();
|
||||
Map<Integer, FlagPriceProto> flagPriceMap = pricingModel.getFlagPriceMap();
|
||||
List<PeriodProto> periodList = pricingModel.getPeriodList();
|
||||
// 适配新的protobuf结构:根据计费规则获取价格信息
|
||||
Map<Integer, FlagPriceProto> flagPriceMap = null;
|
||||
List<PeriodProto> periodList = null;
|
||||
|
||||
if (pricingModel.hasPeakValleyPricing()) {
|
||||
// 峰谷计价:使用预定义的尖峰平谷时段
|
||||
PeakValleyPricingProto peakValleyPricing = pricingModel.getPeakValleyPricing();
|
||||
flagPriceMap = peakValleyPricing.getFlagPriceMap();
|
||||
periodList = peakValleyPricing.getPeriodList();
|
||||
} else {
|
||||
// 未知计费模式
|
||||
log.info("未知的计费模式,桩编号: {}, 计费ID: {}, 计费规则: {}", pileCode, pricingId, pricingModel.getRule());
|
||||
throw new IllegalArgumentException("未知的计费模式: " + pricingModel.getRule());
|
||||
}
|
||||
|
||||
// 从上行报文中取出桩编号字节数组
|
||||
byte[] pileCodeBytes = encodePileCode(pileCode);
|
||||
|
||||
@@ -24,7 +24,7 @@ import static sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongProtocolConstants.P
|
||||
|
||||
/**
|
||||
* 云快充1.5.0充电桩计费模型请求
|
||||
* @author baigod
|
||||
* @author 九筒
|
||||
*/
|
||||
@Slf4j
|
||||
@ProtocolCmd(value = 0x09, protocolNames = {V150, V160, V170})
|
||||
|
||||
@@ -13,7 +13,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import sanbing.jcpp.infrastructure.util.codec.BCDUtil;
|
||||
import sanbing.jcpp.infrastructure.util.jackson.JacksonUtil;
|
||||
import sanbing.jcpp.infrastructure.util.trace.TracerContextUtil;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.ChargingProgressProto;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.GunRunStatus;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.GunRunStatusProto;
|
||||
@@ -33,7 +32,7 @@ import static sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongProtocolConstants.P
|
||||
/**
|
||||
* 云快充1.5.0上传实时监测数据
|
||||
*
|
||||
* @author baigod
|
||||
* @author 九筒
|
||||
*/
|
||||
@Slf4j
|
||||
@ProtocolCmd(value = 0x13, protocolNames = {V150, V160, V170})
|
||||
@@ -61,9 +60,6 @@ public class YunKuaiChongV150RealTimeDataULCmd extends YunKuaiChongUplinkCmdExe
|
||||
log.info("{} 云快充1.5.0上传实时监测数据", tcpSession);
|
||||
ByteBuf byteBuf = Unpooled.wrappedBuffer(yunKuaiChongUplinkMessage.getMsgBody());
|
||||
|
||||
// 从Tracer总获取当前时间
|
||||
long ts = TracerContextUtil.getCurrentTracer().getTracerTs();
|
||||
|
||||
ObjectNode additionalInfo = JacksonUtil.newObjectNode();
|
||||
|
||||
// 1.交易流水号
|
||||
@@ -138,7 +134,6 @@ public class YunKuaiChongV150RealTimeDataULCmd extends YunKuaiChongUplinkCmdExe
|
||||
// 抢状态
|
||||
GunRunStatus gunRunStatus = parseGunRunStatus(gunStatus, gunInsert, tradeNo);
|
||||
GunRunStatusProto.Builder gunRunStatusProtoBuilder = GunRunStatusProto.newBuilder()
|
||||
.setTs(ts)
|
||||
.setPileCode(pileCode)
|
||||
.setGunCode(gunCode)
|
||||
.setGunRunStatus(gunRunStatus)
|
||||
@@ -156,7 +151,6 @@ public class YunKuaiChongV150RealTimeDataULCmd extends YunKuaiChongUplinkCmdExe
|
||||
|
||||
// 充电进度
|
||||
ChargingProgressProto.Builder chargingProgressProtoBuilder = ChargingProgressProto.newBuilder()
|
||||
.setTs(ts)
|
||||
.setPileCode(pileCode)
|
||||
.setGunCode(gunCode)
|
||||
.setTradeNo(tradeNo)
|
||||
@@ -204,7 +198,7 @@ public class YunKuaiChongV150RealTimeDataULCmd extends YunKuaiChongUplinkCmdExe
|
||||
public static boolean[] parseFaults(byte[] bytes) {
|
||||
// 确保输入有效
|
||||
if (bytes.length != 2) {
|
||||
throw new IllegalArgumentException("输入 byte 数组长度不为 2");
|
||||
throw new IllegalArgumentException("输入字节数组长度必须为2字节");
|
||||
}
|
||||
|
||||
// 创建一个布尔数组来存储故障状态
|
||||
|
||||
@@ -24,7 +24,7 @@ import static sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongProtocolConstants.P
|
||||
/**
|
||||
* 云快充1.5.0 运营平台远程控制启机
|
||||
*
|
||||
* @author baigod
|
||||
* @author 九筒
|
||||
*/
|
||||
@Slf4j
|
||||
@ProtocolCmd(value = 0x34, protocolNames = {V150, V160, V170})
|
||||
|
||||
@@ -12,7 +12,6 @@ import io.netty.buffer.Unpooled;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import sanbing.jcpp.infrastructure.util.codec.BCDUtil;
|
||||
import sanbing.jcpp.infrastructure.util.jackson.JacksonUtil;
|
||||
import sanbing.jcpp.infrastructure.util.trace.TracerContextUtil;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.RemoteStartChargingResponse;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.UplinkQueueMessage;
|
||||
import sanbing.jcpp.protocol.ProtocolContext;
|
||||
@@ -26,7 +25,7 @@ import static sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongProtocolConstants.P
|
||||
/**
|
||||
* 云快充1.5.0 远程启动充电命令回复
|
||||
*
|
||||
* @author baigod
|
||||
* @author 九筒
|
||||
*/
|
||||
@Slf4j
|
||||
@ProtocolCmd(value = 0x33, protocolNames = {V150, V160, V170})
|
||||
@@ -37,9 +36,6 @@ public class YunKuaiChongV150RemoteStartResultULCmd extends YunKuaiChongUplinkCm
|
||||
log.info("{} 云快充1.5.0远程启动充电命令回复", tcpSession);
|
||||
ByteBuf byteBuf = Unpooled.wrappedBuffer(yunKuaiChongUplinkMessage.getMsgBody());
|
||||
|
||||
// 从Tracer总获取当前时间
|
||||
long ts = TracerContextUtil.getCurrentTracer().getTracerTs();
|
||||
|
||||
ObjectNode additionalInfo = JacksonUtil.newObjectNode();
|
||||
|
||||
// 1.交易流水号
|
||||
@@ -64,7 +60,6 @@ public class YunKuaiChongV150RemoteStartResultULCmd extends YunKuaiChongUplinkCm
|
||||
String failReason = mapFailCode(failReasonByte);
|
||||
|
||||
RemoteStartChargingResponse remoteStartChargingResponse = RemoteStartChargingResponse.newBuilder()
|
||||
.setTs(ts)
|
||||
.setPileCode(pileCode)
|
||||
.setGunCode(gunCode)
|
||||
.setTradeNo(tradeNo)
|
||||
|
||||
@@ -22,7 +22,7 @@ import static sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongProtocolConstants.P
|
||||
/**
|
||||
* 云快充1.5.0 运营平台远程停机
|
||||
*
|
||||
* @author baigod
|
||||
* @author 九筒
|
||||
*/
|
||||
@Slf4j
|
||||
@ProtocolCmd(value = 0x36, protocolNames = {V150, V160, V170})
|
||||
|
||||
@@ -12,7 +12,6 @@ import io.netty.buffer.Unpooled;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import sanbing.jcpp.infrastructure.util.codec.BCDUtil;
|
||||
import sanbing.jcpp.infrastructure.util.jackson.JacksonUtil;
|
||||
import sanbing.jcpp.infrastructure.util.trace.TracerContextUtil;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.RemoteStopChargingResponse;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.UplinkQueueMessage;
|
||||
import sanbing.jcpp.protocol.ProtocolContext;
|
||||
@@ -26,7 +25,7 @@ import static sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongProtocolConstants.P
|
||||
/**
|
||||
* 云快充1.5.0 远程停机命令回复
|
||||
*
|
||||
* @author baigod
|
||||
* @author 九筒
|
||||
*/
|
||||
@Slf4j
|
||||
@ProtocolCmd(value = 0x35, protocolNames = {V150, V160, V170})
|
||||
@@ -36,9 +35,6 @@ public class YunKuaiChongV150RemoteStopResultULCmd extends YunKuaiChongUplinkCmd
|
||||
log.info("{} 云快充1.5.0远程停机命令回复", tcpSession);
|
||||
ByteBuf byteBuf = Unpooled.wrappedBuffer(yunKuaiChongUplinkMessage.getMsgBody());
|
||||
|
||||
// 从Tracer总获取当前时间
|
||||
long ts = TracerContextUtil.getCurrentTracer().getTracerTs();
|
||||
|
||||
ObjectNode additionalInfo = JacksonUtil.newObjectNode();
|
||||
|
||||
// 1.桩编号
|
||||
@@ -58,7 +54,6 @@ public class YunKuaiChongV150RemoteStopResultULCmd extends YunKuaiChongUplinkCmd
|
||||
String failReason = mapFailCode(failReasonByte);
|
||||
|
||||
RemoteStopChargingResponse remoteStopChargingResponse = RemoteStopChargingResponse.newBuilder()
|
||||
.setTs(ts)
|
||||
.setPileCode(pileCode)
|
||||
.setGunCode(gunCode)
|
||||
.setSuccess(isSuccess)
|
||||
|
||||
@@ -10,7 +10,6 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import sanbing.jcpp.infrastructure.util.codec.BCDUtil;
|
||||
import sanbing.jcpp.infrastructure.util.trace.TracerContextUtil;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.RestartPileResponse;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.UplinkQueueMessage;
|
||||
import sanbing.jcpp.protocol.ProtocolContext;
|
||||
@@ -33,9 +32,6 @@ public class YunKuaiChongV150RestartPileAckULCmd extends YunKuaiChongUplinkCmdEx
|
||||
log.info("{} 云快充1.5.0远程重启动充电命令回复", tcpSession);
|
||||
ByteBuf byteBuf = Unpooled.wrappedBuffer(yunKuaiChongUplinkMessage.getMsgBody());
|
||||
|
||||
// 从Tracer总获取当前时间
|
||||
long ts = TracerContextUtil.getCurrentTracer().getTracerTs();
|
||||
|
||||
// 1.桩编号
|
||||
byte[] pileCodeBytes = new byte[7];
|
||||
byteBuf.readBytes(pileCodeBytes);
|
||||
@@ -45,7 +41,6 @@ public class YunKuaiChongV150RestartPileAckULCmd extends YunKuaiChongUplinkCmdEx
|
||||
boolean isSuccess = (byteBuf.readByte() == 0x01);
|
||||
|
||||
RestartPileResponse restartPileResponse = RestartPileResponse.newBuilder()
|
||||
.setTs(ts)
|
||||
.setPileCode(pileCode)
|
||||
.setSuccess(isSuccess)
|
||||
.build();
|
||||
|
||||
@@ -25,7 +25,7 @@ import static sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongProtocolConstants.P
|
||||
/**
|
||||
* 云快充1.5.0 计费模型应答
|
||||
*
|
||||
* @author baigod
|
||||
* @author 九筒
|
||||
*/
|
||||
@Slf4j
|
||||
@ProtocolCmd(value = 0x57, protocolNames = {V150, V160, V170})
|
||||
|
||||
@@ -9,10 +9,7 @@ package sanbing.jcpp.protocol.yunkuaichong.v150.cmd;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.FlagPriceProto;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.PeriodProto;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.PricingModelProto;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.SetPricingRequest;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.*;
|
||||
import sanbing.jcpp.protocol.ProtocolContext;
|
||||
import sanbing.jcpp.protocol.annotation.ProtocolCmd;
|
||||
import sanbing.jcpp.protocol.listener.tcp.TcpSession;
|
||||
@@ -32,7 +29,7 @@ import static sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongProtocolConstants.P
|
||||
/**
|
||||
* 云快充1.5.0 计费模型设置
|
||||
*
|
||||
* @author baigod
|
||||
* @author 九筒
|
||||
*/
|
||||
@Slf4j
|
||||
@ProtocolCmd(value = 0x58, protocolNames = {V150, V160, V170})
|
||||
@@ -50,8 +47,20 @@ public class YunKuaiChongV150SetPricingModelDLCmd extends YunKuaiChongDownlinkCm
|
||||
long pricingId = setPricingRequest.getPricingId();
|
||||
String pileCode = setPricingRequest.getPileCode();
|
||||
PricingModelProto pricingModel = setPricingRequest.getPricingModel();
|
||||
Map<Integer, FlagPriceProto> flagPriceMap = pricingModel.getFlagPriceMap();
|
||||
List<PeriodProto> periodList = pricingModel.getPeriodList();
|
||||
// 适配新的protobuf结构:根据计费规则获取价格信息
|
||||
Map<Integer, FlagPriceProto> flagPriceMap = null;
|
||||
List<PeriodProto> periodList = null;
|
||||
|
||||
if (pricingModel.hasPeakValleyPricing()) {
|
||||
// 峰谷计价:使用预定义的尖峰平谷时段
|
||||
PeakValleyPricingProto peakValleyPricing = pricingModel.getPeakValleyPricing();
|
||||
flagPriceMap = peakValleyPricing.getFlagPriceMap();
|
||||
periodList = peakValleyPricing.getPeriodList();
|
||||
} else {
|
||||
// 未知计费模式
|
||||
log.info("未知的计费模式,桩编号: {}, 计费ID: {}, 计费规则: {}", pileCode, pricingId, pricingModel.getRule());
|
||||
throw new IllegalArgumentException("未知的计费模式: " + pricingModel.getRule());
|
||||
}
|
||||
|
||||
// 反转取出桩编号字节数组
|
||||
byte[] pileCodeBytes = encodePileCode(pileCode);
|
||||
|
||||
@@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import sanbing.jcpp.infrastructure.util.codec.CP56Time2aUtil;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.TimeSyncRequest;
|
||||
import sanbing.jcpp.protocol.ProtocolContext;
|
||||
import sanbing.jcpp.protocol.annotation.ProtocolCmd;
|
||||
import sanbing.jcpp.protocol.listener.tcp.TcpSession;
|
||||
@@ -36,7 +36,7 @@ public class YunKuaiChongV150TimeSyncDLCmd extends YunKuaiChongDownlinkCmdExe {
|
||||
if (!yunKuaiChongDwonlinkMessage.getMsg().hasTimeSyncRequest()) {
|
||||
return;
|
||||
}
|
||||
ProtocolProto.TimeSyncRequest timeSyncRequest = yunKuaiChongDwonlinkMessage.getMsg().getTimeSyncRequest();
|
||||
TimeSyncRequest timeSyncRequest = yunKuaiChongDwonlinkMessage.getMsg().getTimeSyncRequest();
|
||||
String pileCode = timeSyncRequest.getPileCode();
|
||||
String time = timeSyncRequest.getTime();
|
||||
ByteBuf syncTimeMsgBody = Unpooled.buffer(14);
|
||||
|
||||
@@ -12,7 +12,8 @@ import io.netty.buffer.Unpooled;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import sanbing.jcpp.infrastructure.util.codec.BCDUtil;
|
||||
import sanbing.jcpp.infrastructure.util.codec.CP56Time2aUtil;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.TimeSyncResponse;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.UplinkQueueMessage;
|
||||
import sanbing.jcpp.protocol.ProtocolContext;
|
||||
import sanbing.jcpp.protocol.annotation.ProtocolCmd;
|
||||
import sanbing.jcpp.protocol.listener.tcp.TcpSession;
|
||||
@@ -44,11 +45,11 @@ public class YunKuaiChongV150TimeSyncResultULCmd extends YunKuaiChongUplinkCmdEx
|
||||
byteBuf.readBytes(timeBytes);
|
||||
LocalDateTime dateTime = CP56Time2aUtil.decode(timeBytes);
|
||||
String time = DateUtil.formatLocalDateTime(dateTime);
|
||||
ProtocolProto.TimeSyncResponse timeSyncResponse = ProtocolProto.TimeSyncResponse.newBuilder()
|
||||
TimeSyncResponse timeSyncResponse = TimeSyncResponse.newBuilder()
|
||||
.setPileCode(pileCode)
|
||||
.setTime(time)
|
||||
.build();
|
||||
ProtocolProto.UplinkQueueMessage uplinkQueueMessage = uplinkMessageBuilder(pileCode, tcpSession, yunKuaiChongUplinkMessage)
|
||||
UplinkQueueMessage uplinkQueueMessage = uplinkMessageBuilder(pileCode, tcpSession, yunKuaiChongUplinkMessage)
|
||||
.setTimeSyncResponse(timeSyncResponse)
|
||||
.build();
|
||||
tcpSession.getForwarder().sendMessage(uplinkQueueMessage);
|
||||
|
||||
@@ -25,7 +25,7 @@ import static sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongProtocolConstants.P
|
||||
|
||||
/**
|
||||
* 云快充1.5.0 交易记录确认
|
||||
* @author baigod
|
||||
* @author 九筒
|
||||
*/
|
||||
@Slf4j
|
||||
@ProtocolCmd(value = 0x40, protocolNames = {V150, V160, V170})
|
||||
|
||||
@@ -31,7 +31,7 @@ import static sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongProtocolConstants.P
|
||||
/**
|
||||
* 云快充1.5.0 交易记录
|
||||
*
|
||||
* @author baigod
|
||||
* @author 九筒
|
||||
*/
|
||||
@Slf4j
|
||||
@ProtocolCmd(value = 0x3B, protocolNames = {V150, V160})
|
||||
@@ -200,7 +200,7 @@ public class YunKuaiChongV150TransactionRecordULCmd extends YunKuaiChongUplinkCm
|
||||
public static long readLongLE5Byte(byte[] bytes) {
|
||||
// 确保字节数组的长度至少为 5
|
||||
if (bytes.length < 5) {
|
||||
throw new IllegalArgumentException("Byte array must contain at least 5 bytes.");
|
||||
throw new IllegalArgumentException("字节数组长度必须至少为5字节");
|
||||
}
|
||||
|
||||
// 使用小端字节序读取 5 字节数字
|
||||
|
||||
@@ -28,7 +28,7 @@ import static sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongProtocolConstants.P
|
||||
/**
|
||||
* 云快充1.5.0计费模型验证请求应答
|
||||
*
|
||||
* @author baigod
|
||||
* @author 九筒
|
||||
*/
|
||||
@Slf4j
|
||||
@ProtocolCmd(value = 0x06, protocolNames = {V150, V160, V170})
|
||||
|
||||
@@ -27,7 +27,7 @@ import static sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongProtocolConstants.P
|
||||
/**
|
||||
* 云快充1.5.0计费模型验证请求
|
||||
*
|
||||
* @author baigod
|
||||
* @author 九筒
|
||||
*/
|
||||
@Slf4j
|
||||
@ProtocolCmd(value = 0x05, protocolNames = {V150, V160, V170})
|
||||
|
||||
@@ -15,7 +15,7 @@ import sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongProtocolMessageProcessor;
|
||||
import static sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongProtocolConstants.ProtocolNames.YUNKUAICHONG_V160;
|
||||
|
||||
/**
|
||||
* @author baigod
|
||||
* @author 九筒
|
||||
*/
|
||||
|
||||
@ProtocolComponent(YUNKUAICHONG_V160)
|
||||
|
||||
@@ -29,7 +29,7 @@ import static sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongProtocolConstants.P
|
||||
/**
|
||||
* 云快充1.6.0 运营平台远程控制并充启机
|
||||
*
|
||||
* @author baigod
|
||||
* @author 九筒
|
||||
*/
|
||||
@Slf4j
|
||||
@ProtocolCmd(value = 0xA4, protocolNames = {V160, V170})
|
||||
|
||||
@@ -12,7 +12,6 @@ import io.netty.buffer.Unpooled;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import sanbing.jcpp.infrastructure.util.codec.BCDUtil;
|
||||
import sanbing.jcpp.infrastructure.util.jackson.JacksonUtil;
|
||||
import sanbing.jcpp.infrastructure.util.trace.TracerContextUtil;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.RemoteStartChargingResponse;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.UplinkQueueMessage;
|
||||
import sanbing.jcpp.protocol.ProtocolContext;
|
||||
@@ -26,7 +25,7 @@ import static sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongProtocolConstants.P
|
||||
/**
|
||||
* 云快充1.6.0 远程并充启机命令回复
|
||||
*
|
||||
* @author baigod
|
||||
* @author 九筒
|
||||
*/
|
||||
@Slf4j
|
||||
@ProtocolCmd(value = 0xA3, protocolNames = {V160})
|
||||
@@ -37,9 +36,6 @@ public class YunKuaiChongV160RemoteParallelStartResultULCmd extends YunKuaiChong
|
||||
log.info("{} 云快充1.6.远程并充启机命令回复", tcpSession);
|
||||
ByteBuf byteBuf = Unpooled.wrappedBuffer(yunKuaiChongUplinkMessage.getMsgBody());
|
||||
|
||||
// 从Tracer总获取当前时间
|
||||
long ts = TracerContextUtil.getCurrentTracer().getTracerTs();
|
||||
|
||||
ObjectNode additionalInfo = JacksonUtil.newObjectNode();
|
||||
|
||||
// 1.交易流水号
|
||||
@@ -75,7 +71,6 @@ public class YunKuaiChongV160RemoteParallelStartResultULCmd extends YunKuaiChong
|
||||
additionalInfo.put("并充序号", parallelSeqNo);
|
||||
|
||||
RemoteStartChargingResponse remoteStartChargingResponse = RemoteStartChargingResponse.newBuilder()
|
||||
.setTs(ts)
|
||||
.setPileCode(pileCode)
|
||||
.setGunCode(gunCode)
|
||||
.setTradeNo(tradeNo)
|
||||
|
||||
@@ -15,7 +15,7 @@ import sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongProtocolMessageProcessor;
|
||||
import static sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongProtocolConstants.ProtocolNames.YUNKUAICHONG_V170;
|
||||
|
||||
/**
|
||||
* @author baigod
|
||||
* @author 九筒
|
||||
*/
|
||||
|
||||
@ProtocolComponent(YUNKUAICHONG_V170)
|
||||
|
||||
@@ -31,7 +31,7 @@ import static sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongProtocolConstants.P
|
||||
/**
|
||||
* 云快充1.7.0 交易记录
|
||||
*
|
||||
* @author baigod
|
||||
* @author 九筒
|
||||
*/
|
||||
@Slf4j
|
||||
@ProtocolCmd(value = 0x3D, protocolNames = {V170})
|
||||
@@ -224,7 +224,7 @@ public class YunKuaiChongV170TransactionRecordULCmd extends YunKuaiChongUplinkCm
|
||||
public static long readLongLE5Byte(byte[] bytes) {
|
||||
// 确保字节数组的长度至少为 5
|
||||
if (bytes.length < 5) {
|
||||
throw new IllegalArgumentException("Byte array must contain at least 5 bytes.");
|
||||
throw new IllegalArgumentException("字节数组长度必须至少为5字节");
|
||||
}
|
||||
|
||||
// 使用小端字节序读取 5 字节数字
|
||||
|
||||
Reference in New Issue
Block a user