mirror of
https://gitee.com/san-bing/JChargePointProtocol
synced 2026-05-04 09:59:55 +08:00
!29 云快充主动对时设置0x56、对时应答0x55
* 删除错误代码 * 修改冲突编号 * Merge branch 'master' into Feat_TimeSync * 修改冲突编号 * Merge branch 'master' into Feat_TimeSync * 云快充对时设置 * 云快充对时设置
This commit is contained in:
@@ -16,6 +16,7 @@ import sanbing.jcpp.proto.gen.ProtocolProto;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@@ -205,4 +206,10 @@ public class TestController {
|
||||
return ResponseEntity.ok("success");
|
||||
}
|
||||
|
||||
@GetMapping("/api/timeSync")
|
||||
public ResponseEntity<String> timeSync() {
|
||||
pileProtocolService.timeSync("20231212000010", LocalDateTime.now());
|
||||
return ResponseEntity.ok("success");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import sanbing.jcpp.proto.gen.ProtocolProto.SetPricingRequest;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.UplinkQueueMessage;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author baigod
|
||||
@@ -157,4 +158,8 @@ public interface PileProtocolService {
|
||||
* 离线卡数据同步应答
|
||||
*/
|
||||
void onOfflineCardSyncResponse(UplinkQueueMessage uplinkQueueMessage, Callback callback);
|
||||
void timeSync(String pileCode, LocalDateTime time);
|
||||
|
||||
void onTimeSync(UplinkQueueMessage uplinkQueueMessage, Callback callback);
|
||||
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
package sanbing.jcpp.app.service.impl;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -27,6 +28,7 @@ import sanbing.jcpp.proto.gen.ProtocolProto.*;
|
||||
import sanbing.jcpp.protocol.domain.DownlinkCmdEnum;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.*;
|
||||
|
||||
@@ -430,7 +432,37 @@ public class DefaultPileProtocolService implements PileProtocolService {
|
||||
bmsBatteryType, bmsPowerCapacity, additionalInfo);
|
||||
|
||||
// TODO 处理相关业务逻辑,比如保存握手信息到数据库
|
||||
|
||||
|
||||
callback.onSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void timeSync(String pileCode, LocalDateTime time) {
|
||||
UUID messageId = UUID.randomUUID();
|
||||
UUID requestId = UUID.randomUUID();
|
||||
DownlinkRequestMessage.Builder downlinkRequestMessageBuilder = DownlinkRequestMessage.newBuilder()
|
||||
.setMessageIdMSB(messageId.getMostSignificantBits())
|
||||
.setMessageIdLSB(messageId.getLeastSignificantBits())
|
||||
.setPileCode(pileCode)
|
||||
.setRequestIdMSB(requestId.getMostSignificantBits())
|
||||
.setRequestIdLSB(requestId.getLeastSignificantBits())
|
||||
.setDownlinkCmd(DownlinkCmdEnum.SYNC_TIME_REQUEST.name())
|
||||
.setTimeSyncRequest(TimeSyncRequest.newBuilder()
|
||||
.setPileCode(pileCode)
|
||||
.setTime(DateUtil.formatLocalDateTime(time))
|
||||
.build());
|
||||
downlinkCallService.sendDownlinkMessage(downlinkRequestMessageBuilder, pileCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeSync(UplinkQueueMessage uplinkQueueMessage, Callback callback) {
|
||||
log.info("对时设置应答 {}", uplinkQueueMessage);
|
||||
TimeSyncResponse timeSyncResponse = uplinkQueueMessage.getTimeSyncResponse();
|
||||
String pileCode = timeSyncResponse.getPileCode();
|
||||
String time = timeSyncResponse.getTime();
|
||||
log.info("对时设置应答: 桩编码: {}, 时间: {}", pileCode, time);
|
||||
// TODO 处理相关业务逻辑
|
||||
|
||||
callback.onSuccess();
|
||||
}
|
||||
|
||||
@@ -450,6 +482,7 @@ public class DefaultPileProtocolService implements PileProtocolService {
|
||||
|
||||
// TODO 处理相关业务逻辑,比如保存地锁状态信息到数据库
|
||||
|
||||
|
||||
callback.onSuccess();
|
||||
}
|
||||
|
||||
|
||||
@@ -232,6 +232,10 @@ public class ProtocolUplinkConsumerService extends AbstractConsumerService imple
|
||||
|
||||
pileProtocolService.onOfflineCardSyncResponse(uplinkQueueMsg, callback);
|
||||
|
||||
} else if (uplinkQueueMsg.hasTimeSyncResponse()) {
|
||||
|
||||
pileProtocolService.onTimeSync(uplinkQueueMsg, callback);
|
||||
|
||||
} else {
|
||||
|
||||
callback.onSuccess();
|
||||
|
||||
Reference in New Issue
Block a user