mirror of
https://gitee.com/san-bing/JChargePointProtocol
synced 2026-05-04 09:59:55 +08:00
grpc 增加连接过程
This commit is contained in:
@@ -26,6 +26,10 @@
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>sanbing</groupId>
|
||||
<artifactId>jcpp-infrastructure-util</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.annotation</groupId>
|
||||
<artifactId>javax.annotation-api</artifactId>
|
||||
|
||||
@@ -8,6 +8,8 @@ package sanbing.jcpp.infrastructure.proto;
|
||||
import sanbing.jcpp.infrastructure.proto.model.PricingModel;
|
||||
import sanbing.jcpp.infrastructure.proto.model.PricingModel.FlagPrice;
|
||||
import sanbing.jcpp.infrastructure.proto.model.PricingModel.Period;
|
||||
import sanbing.jcpp.infrastructure.util.trace.Tracer;
|
||||
import sanbing.jcpp.infrastructure.util.trace.TracerContextUtil;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.*;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -17,6 +19,15 @@ import java.util.Map;
|
||||
*/
|
||||
public class ProtoConverter {
|
||||
|
||||
public static TracerProto toTracerProto() {
|
||||
Tracer currentTracer = TracerContextUtil.getCurrentTracer();
|
||||
return TracerProto.newBuilder()
|
||||
.setId(currentTracer.getTraceId())
|
||||
.setOrigin(currentTracer.getOrigin())
|
||||
.setTs(currentTracer.getTracerTs())
|
||||
.build();
|
||||
}
|
||||
|
||||
public static PricingModelProto toPricingModel(PricingModel pricingModel) {
|
||||
// 创建 PricingModelProto 实例
|
||||
PricingModelProto.Builder builder = PricingModelProto.newBuilder();
|
||||
|
||||
@@ -9,8 +9,35 @@ package infrastructureProto;
|
||||
option java_package = "sanbing.jcpp.proto.gen";
|
||||
option java_outer_classname = "ProtocolProto";
|
||||
|
||||
service ProtocolDownlinkInterface {
|
||||
rpc onDownlink(stream DownlinkRequestMessage) returns (stream DownlinkResponseMessage) {}
|
||||
service ProtocolInterface {
|
||||
rpc onDownlink(stream RequestMsg) returns (stream ResponseMsg) {}
|
||||
}
|
||||
|
||||
message RequestMsg {
|
||||
int64 ts = 1;
|
||||
TracerProto tracer = 2;
|
||||
ConnectRequestMsg connectRequestMsg = 10;
|
||||
DownlinkRequestMessage downlinkRequestMessage = 11;
|
||||
}
|
||||
|
||||
message ResponseMsg {
|
||||
TracerProto tracer = 2;
|
||||
ConnectResponseMsg connectResponseMsg = 12;
|
||||
DownlinkResponseMessage downlinkResponseMsg = 13;
|
||||
}
|
||||
|
||||
message ConnectResponseMsg {
|
||||
ConnectResponseCode responseCode = 1;
|
||||
string errorMsg = 2;
|
||||
}
|
||||
|
||||
message ConnectRequestMsg {
|
||||
string nodeId = 1;
|
||||
}
|
||||
|
||||
enum ConnectResponseCode {
|
||||
ACCEPTED = 0;
|
||||
REFUSE = 1;
|
||||
}
|
||||
|
||||
message TracerProto {
|
||||
@@ -49,7 +76,6 @@ message DownlinkRequestMessage {
|
||||
optional int64 requestIdMSB = 8;
|
||||
optional int64 requestIdLSB = 9;
|
||||
optional bytes requestData = 10;
|
||||
TracerProto tracer = 12;
|
||||
string downlinkCmd = 20;
|
||||
LoginResponse loginResponse = 21;
|
||||
VerifyPricingResponse verifyPricingResponse = 22;
|
||||
@@ -206,7 +232,7 @@ message RemoteStartChargingRequest {
|
||||
string pileCode = 4;
|
||||
string gunCode = 5;
|
||||
string tradeNo = 6;
|
||||
int32 limitYuan = 7;
|
||||
string limitYuan = 7;
|
||||
optional string additionalInfo = 20;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user