自动化立体仓库 - WCS系统
zhangc
2025-03-11 d5449236ef0b3adafb3e4cc872f50479efa0ce7b
src/main/java/com/zy/core/netty/handle/PackageServerHandler.java
@@ -1,15 +1,10 @@
package com.zy.core.netty.handle;
import com.core.common.Cools;
import com.zy.core.Slave;
import com.zy.core.cache.SlaveConnection;
import com.zy.core.enums.SlaveType;
import com.zy.core.netty.AbstractInboundHandler;
import com.zy.core.netty.cache.ChannelCache;
import com.zy.core.netty.domain.ChPackage;
import com.zy.core.netty.properties.TcpProperties;
import com.zy.core.properties.SlaveProperties;
import com.zy.core.thread.BarcodeThread;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
@@ -31,6 +26,19 @@
    @Autowired
    private TcpProperties tcpProperties;
    /**
     * 数据下行
     */
    public static void write(ChPackage chPackage) {
        String uuid = chPackage.getUuid();
        Channel channel = ChannelCache.getChannel(uuid);
        if (null == channel) {
            log.warn("通道uuid={} 不在线", uuid);
            return;
        }
        channel.writeAndFlush(chPackage);
    }
    @Override
    protected boolean channelRead0(ChannelHandlerContext ctx, ChPackage pac) {
//        log.info("读码器【IP:{}】 上行数据 ===>> {}", pac.getIp(), pac.getAscii());
@@ -50,18 +58,5 @@
//        }
        return true;
    }
    /**
     * 数据下行
     */
    public static void write(ChPackage chPackage){
        String uuid = chPackage.getUuid();
        Channel channel = ChannelCache.getChannel(uuid);
        if (null == channel){
            log.warn("通道uuid={} 不在线", uuid);
            return;
        }
        channel.writeAndFlush(chPackage);
    }
}