mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-03 17:40:13 +08:00
update finalize ykc offline fix baseline
This commit is contained in:
@@ -64,19 +64,16 @@ public class HeartbeatRequestHandler extends AbstractYkcHandler {
|
||||
String connectorStatus = BytesUtil.binary(connectorStatusByte, 16);
|
||||
// log.info("桩号:{}, 枪号:{}, 枪状态:{}", pileSn, pileConnectorNum, connectorStatus);
|
||||
|
||||
// 优化:先构建并返回心跳应答,不阻塞心跳回复
|
||||
// 先构建心跳应答,再同步刷新最后通信时间和连接映射,保证离线确认链路及时收敛
|
||||
byte[] flag = Constants.zeroByteArray;
|
||||
byte[] messageBody = Bytes.concat(pileSnByte, pileConnectorNumByte, flag);
|
||||
byte[] response = getResult(ykcDataProtocol, messageBody);
|
||||
|
||||
// 优化:所有其他操作(Redis、数据库)完全异步化,不阻塞心跳回复
|
||||
// 将 saveLastTimeAndCheckChannel 和 updateStatus 都改为异步执行
|
||||
saveLastTimeAndCheckChannel(pileSn, channel);
|
||||
|
||||
// 数据库状态更新继续异步,避免把心跳回包链路拖长
|
||||
CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
// 异步保存连接时间并检查通道(Redis 操作)
|
||||
saveLastTimeAndCheckChannel(pileSn, channel);
|
||||
|
||||
// 异步更新状态(数据库操作)
|
||||
String frameType = BytesUtil.bcd2Str(ykcDataProtocol.getFrameType());
|
||||
pileBasicInfoService.updateStatus(frameType, pileSn, pileConnectorNum, connectorStatus, null);
|
||||
} catch (Exception e) {
|
||||
|
||||
Reference in New Issue
Block a user