解决 Netty 合并冲突并添加耗时监控

- 解决 NettyServerHandler.java 的 Git 合并冲突
- 添加消息处理耗时监控到 channelRead 方法
- 更新 improve_record.md 优化记录文档
This commit is contained in:
Lemon
2026-03-21 10:35:59 +08:00
10 changed files with 767 additions and 234 deletions

View File

@@ -168,6 +168,16 @@ public class CacheConstants {
*/
public static final String PILE_LAST_CONNECTION = "pile_last_connection:";
/**
* 充电桩待确认断链标记
*/
public static final String PILE_PENDING_DISCONNECT = "pile_pending_disconnect:";
/**
* 充电桩已确认离线标记
*/
public static final String PILE_OFFLINE_CONFIRMED = "pile_offline_confirmed:";
/**
* 查询枪口信息列表前缀
*/

View File

@@ -153,6 +153,21 @@ public class PileChannelEntity {
}
}
public static boolean removeByPileSnAndChannelId(String pileSn, String expectedChannelId) {
if (StringUtils.isBlank(pileSn) || StringUtils.isBlank(expectedChannelId)) {
return false;
}
ChannelHandlerContext currentCtx = manager.get(pileSn);
if (currentCtx == null || currentCtx.channel() == null) {
return false;
}
String currentChannelId = currentCtx.channel().id().asLongText();
if (!StringUtils.equals(currentChannelId, expectedChannelId)) {
return false;
}
return manager.remove(pileSn, currentCtx);
}
public static void removeByChannelId(String channelId){
if (StringUtils.isBlank(channelId)) {
return;
@@ -165,4 +180,4 @@ public class PileChannelEntity {
}
}
}
}