mirror of
https://gitee.com/san-bing/JChargePointProtocol
synced 2026-05-04 18:09:54 +08:00
!18 远程更新 远程更新应答
* 远程更新应答 补充 onRemoteUpdate 去掉 UpgradeStatusEnum 枚举 用hashMap 处理升级结果返回 领域模型优化 代码优化 * Merge branch 'master' of gitee.com:san-bing/JChargePointProtocol into Feat_远程更新 * 远程更新 远程更新应答
This commit is contained in:
@@ -11,6 +11,7 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import sanbing.jcpp.app.service.PileProtocolService;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@@ -152,4 +153,25 @@ public class TestController {
|
||||
|
||||
return ResponseEntity.ok("success");
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/api/remoteUpdate")
|
||||
public ResponseEntity<String> remoteUpdate() {
|
||||
|
||||
pileProtocolService.remoteUpdate(ProtocolProto.OtaRequest.newBuilder()
|
||||
.setAddress("http://127.0.0.1")
|
||||
.setExecutionControl(1)
|
||||
.setDownloadTimeout(1)
|
||||
.setPassword("123123")
|
||||
.setFilePath("/user/data")
|
||||
.setPileCode("20231212000010")
|
||||
.setPileModel(1)
|
||||
.setPilePower(200)
|
||||
.setPort(8080)
|
||||
.setUsername("bawan")
|
||||
.build());
|
||||
|
||||
return ResponseEntity.ok("success");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
package sanbing.jcpp.app.service;
|
||||
|
||||
import sanbing.jcpp.infrastructure.queue.Callback;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.SetPricingRequest;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.UplinkQueueMessage;
|
||||
|
||||
@@ -112,6 +113,16 @@ public interface PileProtocolService {
|
||||
void onBmsAbort(UplinkQueueMessage uplinkQueueMessage, Callback callback);
|
||||
|
||||
/**
|
||||
* 远程更新
|
||||
*/
|
||||
void remoteUpdate(ProtocolProto.OtaRequest request);
|
||||
|
||||
/**
|
||||
* 远程更新应答
|
||||
*/
|
||||
void onRemoteUpdate(UplinkQueueMessage uplinkQueueMessage, Callback callback);
|
||||
|
||||
/*
|
||||
* BMS充电握手
|
||||
*/
|
||||
void onBmsHandshake(UplinkQueueMessage uplinkQueueMessage, Callback callback);
|
||||
|
||||
@@ -378,6 +378,35 @@ public class DefaultPileProtocolService implements PileProtocolService {
|
||||
callback.onSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remoteUpdate(OtaRequest request) {
|
||||
|
||||
UUID messageId = UUID.randomUUID();
|
||||
UUID requestId = UUID.randomUUID();
|
||||
|
||||
DownlinkRequestMessage.Builder downlinkRequestMessageBuilder = DownlinkRequestMessage.newBuilder()
|
||||
.setMessageIdMSB(messageId.getMostSignificantBits())
|
||||
.setMessageIdLSB(messageId.getLeastSignificantBits())
|
||||
.setPileCode(request.getPileCode())
|
||||
.setRequestIdMSB(requestId.getMostSignificantBits())
|
||||
.setRequestIdLSB(requestId.getLeastSignificantBits())
|
||||
.setDownlinkCmd(DownlinkCmdEnum.REMOTE_UPDATE.name())
|
||||
.setOtaRequest(request);
|
||||
downlinkCallService.sendDownlinkMessage(downlinkRequestMessageBuilder,request.getPileCode());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoteUpdate(UplinkQueueMessage uplinkQueueMessage, Callback callback) {
|
||||
|
||||
log.info("接收到充电桩更新应答 {}", uplinkQueueMessage);
|
||||
|
||||
// TODO 处理相关业务逻辑
|
||||
|
||||
callback.onSuccess();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBmsHandshake(UplinkQueueMessage uplinkQueueMessage, Callback callback) {
|
||||
log.info("接收到BMS充电握手信息 {}", uplinkQueueMessage);
|
||||
@@ -424,4 +453,8 @@ public class DefaultPileProtocolService implements PileProtocolService {
|
||||
builder.setRequestData(uplinkQueueMessage.getRequestData());
|
||||
return builder;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -216,6 +216,10 @@ public class ProtocolUplinkConsumerService extends AbstractConsumerService imple
|
||||
|
||||
pileProtocolService.onBmsHandshake(uplinkQueueMsg, callback);
|
||||
|
||||
} else if (uplinkQueueMsg.hasOtaResponse()) {
|
||||
|
||||
pileProtocolService.onRemoteUpdate(uplinkQueueMsg, callback);
|
||||
|
||||
} else {
|
||||
|
||||
callback.onSuccess();
|
||||
|
||||
Reference in New Issue
Block a user