zhaowenyu
2025-10-15 a9780c49f8cf587af26cc83d439320ad02b8668f
ard-work/src/main/java/com/ard/work/component/netty/TyTcpClientManager.java
@@ -7,7 +7,7 @@
import com.ard.work.component.netty.handler.MessageProtocolEncoder;
import com.ard.work.domain.cache.TyTcpServerCache;
import com.ard.work.domain.entity.ArdServerInfo;
import com.ard.work.service.IArdServerService;
import com.ard.work.service.IArdServerInfoService;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.*;
import io.netty.channel.nio.NioEventLoopGroup;
@@ -36,7 +36,7 @@
    private final EventLoopGroup eventLoopGroup = new NioEventLoopGroup();
    @Resource
    private IArdServerService ardServerService; // ← 从数据库读取边缘服务器配置
    private IArdServerInfoService ardServerService; // ← 从数据库读取边缘服务器配置
    @Resource
    private ClientHandler clientHandler;
@@ -140,7 +140,7 @@
    @PostConstruct
    public void initConnectServers() {
        try {
            var serverList = ardServerService.selectArdServerManagementList(new ArdServerInfo()); // ← 从数据库查询所有服务器配置
            var serverList = ardServerService.selectArdServerInfoList(new ArdServerInfo()); // ← 从数据库查询所有服务器配置
            if (serverList == null || serverList.isEmpty()) {
                log.warn("未在数据库中找到边缘服务器配置,跳过连接初始化");
                return;
@@ -160,7 +160,7 @@
    public void reconnectFailedServers() {
        TyTcpServerCache.getTcpServerCacheMap().forEach((key, state) -> {
            if (Boolean.FALSE.equals(state)) { // 连接失败的服务器
                ArdServerInfo serverInfo = ardServerService.selectArdServerManagementById(key);
                ArdServerInfo serverInfo = ardServerService.selectArdServerInfoById(key);
                if (serverInfo != null) {
                    connectServer(serverInfo);
                }