zhifei 1 год назад
Родитель
Сommit
6fdca84ec6
32 измененных файлов с 2308 добавлено и 0 удалено
  1. 70 0
      warewms-system/src/main/java/com/warewms/hailiang/common/ChannelMap.java
  2. 75 0
      warewms-system/src/main/java/com/warewms/hailiang/common/DtuManage.java
  3. 51 0
      warewms-system/src/main/java/com/warewms/hailiang/common/MyDecoder.java
  4. 90 0
      warewms-system/src/main/java/com/warewms/hailiang/common/MyEncoder.java
  5. 55 0
      warewms-system/src/main/java/com/warewms/hailiang/common/NettyServer.java
  6. 28 0
      warewms-system/src/main/java/com/warewms/hailiang/common/NettyServerChannelInitializer.java
  7. 152 0
      warewms-system/src/main/java/com/warewms/hailiang/common/NettyServerHandler.java
  8. 63 0
      warewms-system/src/main/java/com/warewms/hailiang/config/LaunchRunner.java
  9. 29 0
      warewms-system/src/main/java/com/warewms/hailiang/config/SocketProperties.java
  10. 121 0
      warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader12Connect.java
  11. 121 0
      warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader13Connect.java
  12. 121 0
      warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader14Connect.java
  13. 120 0
      warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader3Connect.java
  14. 121 0
      warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader5Connect.java
  15. 121 0
      warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader6Connect.java
  16. 122 0
      warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader7Connect.java
  17. 121 0
      warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader8Connect.java
  18. 121 0
      warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader9Connect.java
  19. 45 0
      warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader12Handler.java
  20. 45 0
      warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader13Handler.java
  21. 45 0
      warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader14Handler.java
  22. 47 0
      warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader3Handler.java
  23. 45 0
      warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader5Handler.java
  24. 45 0
      warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader6Handler.java
  25. 45 0
      warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader7Handler.java
  26. 45 0
      warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader8Handler.java
  27. 45 0
      warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader9Handler.java
  28. 33 0
      warewms-system/src/main/java/com/warewms/hailiang/contoller/TestContoller.java
  29. 73 0
      warewms-system/src/main/java/com/warewms/hailiang/domian/Device.java
  30. 46 0
      warewms-system/src/main/java/com/warewms/hailiang/domian/DeviceLog.java
  31. 28 0
      warewms-system/src/main/java/com/warewms/hailiang/enums/CodeReaderEnum.java
  32. 19 0
      warewms-system/src/main/java/com/warewms/hailiang/mapper/DeviceLogMapper.java

+ 70 - 0
warewms-system/src/main/java/com/warewms/hailiang/common/ChannelMap.java

@@ -0,0 +1,70 @@
+package com.warewms.hailiang.common;
+
+
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelId;
+import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
+import org.springframework.util.CollectionUtils;
+
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * 功能描述: 管理通道Map类
+ *
+ * @Author keLe
+ * @Date 2022/8/26
+ */
+public class ChannelMap {
+
+    /**
+     * 管理一个全局map,保存连接进服务端的通道数量
+     */
+    private static final ConcurrentHashMap<ChannelId, Channel> CHANNEL_MAP = new ConcurrentHashMap<>(128);
+
+    public static ConcurrentHashMap<ChannelId, Channel> getChannelMap() {
+        return CHANNEL_MAP;
+    }
+
+    /**
+     *  获取指定name的channel
+     */
+    public static Channel getChannelByName(ChannelId channelId){
+        if(CollectionUtils.isEmpty(CHANNEL_MAP)){
+            return null;
+        }
+        return CHANNEL_MAP.get(channelId);
+    }
+
+    /**
+     *  将通道中的消息推送到每一个客户端
+     */
+    public static boolean pushNewsToAllClient(String obj){
+        if(CollectionUtils.isEmpty(CHANNEL_MAP)){
+            return false;
+        }
+        for(ChannelId channelId: CHANNEL_MAP.keySet()) {
+            Channel channel = CHANNEL_MAP.get(channelId);
+            channel.writeAndFlush(new TextWebSocketFrame(obj));
+        }
+        return true;
+    }
+
+    /**
+     *  将channel和对应的name添加到ConcurrentHashMap
+     */
+    public static void addChannel(ChannelId channelId,Channel channel){
+        CHANNEL_MAP.put(channelId,channel);
+    }
+
+    /**
+     *  移除掉name对应的channel
+     */
+    public static boolean removeChannelByName(ChannelId channelId){
+        if(CHANNEL_MAP.containsKey(channelId)){
+            CHANNEL_MAP.remove(channelId);
+            return true;
+        }
+        return false;
+    }
+
+}

+ 75 - 0
warewms-system/src/main/java/com/warewms/hailiang/common/DtuManage.java

@@ -0,0 +1,75 @@
+package com.warewms.hailiang.common;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelFutureListener;
+import io.netty.channel.ChannelId;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+
+import java.util.Arrays;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * 功能描述: 定时发送Dtu报文
+ *
+ * @Author keLe
+ * @Date 2022/8/29
+ */
+@Slf4j
+@Component
+public class DtuManage {
+
+
+    public void sendMsg(){
+        ConcurrentHashMap<ChannelId, Channel> channelMap = ChannelMap.getChannelMap();
+        if(CollectionUtils.isEmpty(channelMap)){
+            return;
+        }
+        ConcurrentHashMap.KeySetView<ChannelId, Channel> channelIds = channelMap.keySet();
+        byte[] msgBytes = {0x01, 0x03, 0x00, 0x02, 0x00, 0x01, 0x25, (byte) 0xCA};
+        for(ChannelId channelId : channelIds){
+            Channel channel = ChannelMap.getChannelByName(channelId);
+            // 判断是否活跃
+            if(channel==null || !channel.isActive()){
+                ChannelMap.getChannelMap().remove(channelId);
+                log.info("客户端:{},连接已经中断",channelId);
+                return ;
+            }
+            // 指令发送
+            ByteBuf buffer = Unpooled.buffer();
+            log.info("开始发送报文:{}",Arrays.toString(msgBytes));
+            buffer.writeBytes(msgBytes);
+            channel.writeAndFlush(buffer).addListener((ChannelFutureListener) future -> {
+                if (future.isSuccess()) {
+                    log.info("客户端:{},回写成功:{}",channelId,Arrays.toString(msgBytes));
+                } else {
+                    log.info("客户端:{},回写失败:{}",channelId,Arrays.toString(msgBytes));
+                }
+            });
+        }
+    }
+
+    /**
+     * 功能描述: 定时删除不活跃的连接
+     * @Author keLe
+     * @Date 2022/8/26
+     * @return void
+     */
+    public void deleteInactiveConnections(){
+        ConcurrentHashMap<ChannelId, Channel> channelMap = ChannelMap.getChannelMap();
+        if(!CollectionUtils.isEmpty(channelMap)){
+            for (Map.Entry<ChannelId, Channel> next : channelMap.entrySet()) {
+                ChannelId channelId = next.getKey();
+                Channel channel = next.getValue();
+                if (!channel.isActive()) {
+                    channelMap.remove(channelId);
+                    log.info("客户端:{},连接已经中断",channelId);
+                }
+            }
+        }
+    }
+}

+ 51 - 0
warewms-system/src/main/java/com/warewms/hailiang/common/MyDecoder.java

@@ -0,0 +1,51 @@
+package com.warewms.hailiang.common;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.ByteToMessageDecoder;
+
+import java.util.List;
+
+/**
+ * 功能描述: 自定义接收消息格式
+ */
+public class MyDecoder extends ByteToMessageDecoder {
+    @Override
+    protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf in, List<Object> out) throws Exception {
+        byte[] data = new byte[in.readableBytes()];
+        in.readBytes(data);
+        String msg = bytesToHexString(data);
+        out.add(msg);
+    }
+
+    public String bytesToHexString(byte[] bArray) {
+        StringBuffer sb = new StringBuffer(bArray.length);
+        String sTemp;
+        for (int i = 0; i < bArray.length; i++) {
+            sTemp = Integer.toHexString(0xFF & bArray[i]);
+            if (sTemp.length() < 2) {
+                sb.append(0);
+            }
+            sb.append(sTemp.toUpperCase());
+        }
+        return sb.toString();
+    }
+
+    public static String toHexString1(byte[] b) {
+        StringBuffer buffer = new StringBuffer();
+        for (int i = 0; i < b.length; ++i) {
+            buffer.append(toHexString1(b[i]));
+        }
+        return buffer.toString();
+    }
+
+    public static String toHexString1(byte b) {
+        String s = Integer.toHexString(b & 0xFF);
+        if (s.length() == 1) {
+            return "0" + s;
+        } else {
+            return s;
+        }
+    }
+
+}

+ 90 - 0
warewms-system/src/main/java/com/warewms/hailiang/common/MyEncoder.java

@@ -0,0 +1,90 @@
+package com.warewms.hailiang.common;
+
+import cn.hutool.core.util.ByteUtil;
+import cn.hutool.extra.spring.SpringUtil;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.MessageToByteEncoder;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Arrays;
+import java.util.Scanner;
+import java.util.Stack;
+
+/**
+ * 功能描述: 自定义发送消息格式
+ *
+ */
+public class MyEncoder extends MessageToByteEncoder<String> {
+
+    @Override
+    protected void encode(ChannelHandlerContext channelHandlerContext, String s, ByteBuf byteBuf) throws Exception {
+        //将16进制字符串转为数组
+        byteBuf.writeBytes(hexString2Bytes(s));
+    }
+
+    /**
+     * 功能描述: 16进制字符串转字节数组
+     * @param src 16进制字符串
+     * @return byte[]
+     */
+    public static byte[] hexString2Bytes(String src) {
+        int l = src.length() / 2;
+        byte[] ret = new byte[l];
+        for (int i = 0; i < l; i++) {
+            ret[i] = (byte) Integer.valueOf(src.substring(i * 2, i * 2 + 2), 16).byteValue();
+        }
+        return ret;
+    }
+
+    /**
+     * 字符串转16进制字符串
+     * @param str
+     * @return
+     */
+    public static String StringTohexString(String str){
+        StringBuffer sb = new StringBuffer();
+        //将字符串转换为字符数组
+        char ch[] = str.toCharArray();
+        for(int i = 0; i < ch.    length; i++) {
+            String hexString = Integer.toHexString(ch[i]);
+            sb.append(hexString);
+        }
+        return sb.toString();
+    }
+    public static void main(String[] args) throws UnsupportedEncodingException {
+//        String str = "23";
+//        StringBuffer sb = new StringBuffer();
+//        //将字符串转换为字符数组
+//        char ch[] = str.toCharArray();
+//        for(int i = 0; i < ch.    length; i++) {
+//            String hexString = Integer.toHexString(ch[i]);
+//            sb.append(hexString);
+//        }
+//        String result = sb.toString();
+
+//        System.out.println(result);
+//        byte[] bytes = new byte[37];
+//        bytes[0] = 00;
+//        String s ="E800230100063132333332310200173131313131313131313131313131313131313131313131";
+
+//        String s ="E8 00 23 01 00 06 31 32 33 33 32 31 02 00 17 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31";
+//        String[] s2 = s.split(" ");
+//        int i  =Integer.parseInt(s2[0],16) ^ Integer.parseInt(s2[1],16) ;
+//        for (int i1 = 1; i1 < s2.length-1; i1++) {
+//            i = i ^ Integer.parseInt(s2[i1+1],16);
+//        }
+//        System.out.println(Integer.toHexString(i));
+
+//        System.out.println(Integer.parseInt("23",16));
+//        System.out.println(Arrays.toString(hexString2Bytes("8000")));
+
+//        System.out.println(Integer.parseInt("E8",16));
+//        for (int i = 1; i < bytes.length -1; i++) {
+//            y = y ^ bytes[i + 1];
+//            System.out.println(y);
+//        }
+//        System.out.println(Integer.toHexString(y));
+    }
+
+}

+ 55 - 0
warewms-system/src/main/java/com/warewms/hailiang/common/NettyServer.java

@@ -0,0 +1,55 @@
+package com.warewms.hailiang.common;
+
+import io.netty.bootstrap.ServerBootstrap;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelOption;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.nio.NioServerSocketChannel;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+import java.net.InetSocketAddress;
+
+/**
+ * 功能描述: netty服务启动类
+ *
+ */
+@Slf4j
+@Component
+public class NettyServer {
+    public void start(InetSocketAddress address) {
+        //配置服务端的NIO线程组
+        EventLoopGroup bossGroup = new NioEventLoopGroup();
+        EventLoopGroup workerGroup = new NioEventLoopGroup();
+        try {
+            // 绑定线程池,编码解码
+            //服务端接受连接的队列长度,如果队列已满,客户端连接将被拒绝
+            ServerBootstrap bootstrap = new ServerBootstrap()
+                    .group(bossGroup, workerGroup)
+                    // 指定Channel
+                    .channel(NioServerSocketChannel.class)
+                    //使用指定的端口设置套接字地址
+                    .localAddress(address)
+                    //使用自定义处理类
+                    .childHandler(new NettyServerChannelInitializer())
+                    //服务端可连接队列数,对应TCP/IP协议listen函数中backlog参数
+                    .option(ChannelOption.SO_BACKLOG, 128)
+                    //保持长连接,2小时无数据激活心跳机制
+                    .childOption(ChannelOption.SO_KEEPALIVE, true)
+                    //将小的数据包包装成更大的帧进行传送,提高网络的负载
+                    .childOption(ChannelOption.TCP_NODELAY, true);
+            // 绑定端口,开始接收进来的连接
+            ChannelFuture future = bootstrap.bind(address).sync();
+            if (future.isSuccess()) {
+                log.info("netty服务器开始监听端口:{}",address.getPort());
+            }
+            //关闭channel和块,直到它被关闭
+            future.channel().closeFuture().sync();
+        } catch (Exception e) {
+            e.printStackTrace();
+            bossGroup.shutdownGracefully();
+            workerGroup.shutdownGracefully();
+        }
+    }
+}

+ 28 - 0
warewms-system/src/main/java/com/warewms/hailiang/common/NettyServerChannelInitializer.java

@@ -0,0 +1,28 @@
+package com.warewms.hailiang.common;
+
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.ChannelPipeline;
+import io.netty.channel.socket.SocketChannel;
+
+/**
+ * 功能描述: 服务端初始化,客户端与服务器端连接一旦创建,这个类中方法就会被回调,设置出站编码器和入站解码器
+ *
+ * @Author keLe
+ * @Date 2022/8/26
+ */
+public class NettyServerChannelInitializer extends ChannelInitializer<SocketChannel> {
+    @Override
+    protected void initChannel(SocketChannel socketChannel) throws Exception {
+        ChannelPipeline pipeline = socketChannel.pipeline();
+        //接收消息格式,使用自定义解析数据格式
+        pipeline.addLast("decoder",new MyDecoder());
+        //发送消息格式,使用自定义解析数据格式
+        pipeline.addLast("encoder",new MyEncoder());
+
+        //针对客户端,如果在1分钟时没有想服务端发送写心跳(ALL),则主动断开
+        //如果是读空闲或者写空闲,不处理,这里根据自己业务考虑使用
+        //pipeline.addLast(new IdleStateHandler(600,0,0, TimeUnit.SECONDS));
+        //自定义的空闲检测
+        pipeline.addLast(new NettyServerHandler());
+    }
+}

+ 152 - 0
warewms-system/src/main/java/com/warewms/hailiang/common/NettyServerHandler.java

@@ -0,0 +1,152 @@
+package com.warewms.hailiang.common;
+
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelId;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+import io.netty.handler.timeout.IdleState;
+import io.netty.handler.timeout.IdleStateEvent;
+import lombok.extern.slf4j.Slf4j;
+
+import java.net.InetSocketAddress;
+
+/**
+ * 功能描述: netty服务端处理类
+ *
+ */
+@Slf4j
+public class NettyServerHandler extends ChannelInboundHandlerAdapter {
+
+    /**
+     * 功能描述: 有客户端连接服务器会触发此函数
+     *
+     * @param ctx 通道
+     * @return void
+     */
+    @Override
+    public void channelActive(ChannelHandlerContext ctx) {
+        InetSocketAddress insocket = (InetSocketAddress) ctx.channel().remoteAddress();
+        String clientIp = insocket.getAddress().getHostAddress();
+        int clientPort = insocket.getPort();
+        //获取连接通道唯一标识
+        ChannelId channelId = ctx.channel().id();
+        //如果map中不包含此连接,就保存连接
+        if (ChannelMap.getChannelMap().containsKey(channelId)) {
+            log.info("客户端:{},是连接状态,连接通道数量:{} ", channelId, ChannelMap.getChannelMap().size());
+        } else {
+            //保存连接
+            ChannelMap.addChannel(channelId, ctx.channel());
+            log.info("客户端:{},连接netty服务器[IP:{}-->PORT:{}]", channelId, clientIp, clientPort);
+            log.info("连接通道数量: {}", ChannelMap.getChannelMap().size());
+        }
+    }
+
+    /**
+     * 功能描述: 有客户端终止连接服务器会触发此函数
+     *
+     * @param ctx 通道处理程序上下文
+     * @return void
+     */
+    @Override
+    public void channelInactive(ChannelHandlerContext ctx) {
+        InetSocketAddress inSocket = (InetSocketAddress) ctx.channel().remoteAddress();
+        String clientIp = inSocket.getAddress().getHostAddress();
+        ChannelId channelId = ctx.channel().id();
+        //包含此客户端才去删除
+        if (ChannelMap.getChannelMap().containsKey(channelId)) {
+            //删除连接
+            ChannelMap.getChannelMap().remove(channelId);
+            log.info("客户端:{},连接netty服务器[IP:{}-->PORT:{}]", channelId, clientIp, inSocket.getPort());
+            log.info("连接通道数量: " + ChannelMap.getChannelMap().size());
+        }
+    }
+
+    /**
+     * 功能描述: 有客户端发消息会触发此函数
+     *
+     * @param ctx 通道处理程序上下文
+     * @param msg 客户端发送的消息
+     * @return void
+     */
+    @Override
+    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+        log.info("加载客户端报文,客户端id:{},客户端消息:{}", ctx.channel().id(), msg);
+        String data = String.valueOf(msg);
+        Integer water = Integer.parseInt(data.substring(6, 10), 16);
+        log.info("当前水位:{}cm", water);
+        //响应客户端
+        this.channelWrite(ctx.channel().id(), msg);
+    }
+
+    @Override
+    public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
+        String bytes = "01 03 00 02 00 01 25 CA";
+        ctx.writeAndFlush(bytes);
+    }
+
+    /**
+     * 功能描述: 服务端给客户端发送消息
+     *
+     * @param channelId 连接通道唯一id
+     * @param msg       需要发送的消息内容
+     * @return void
+     */
+    public void channelWrite(ChannelId channelId, Object msg) throws Exception {
+        Channel channel = ChannelMap.getChannelMap().get(channelId);
+        if (channel == null) {
+            log.info("通道:{},不存在", channelId);
+            return;
+        }
+        if (msg == null || msg == "") {
+            log.info("服务端响应空的消息");
+            return;
+        }
+        //将客户端的信息直接返回写入ctx
+        channel.write(msg);
+        //刷新缓存区
+        channel.flush();
+    }
+
+    @Override
+    public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
+        String socketString = ctx.channel().remoteAddress().toString();
+        if (evt instanceof IdleStateEvent) {
+            IdleStateEvent event = (IdleStateEvent) evt;
+            if (event.state() == IdleState.READER_IDLE) {
+                log.info("Client:{},READER_IDLE 读超时", socketString);
+                ctx.disconnect();
+                Channel channel = ctx.channel();
+                ChannelId id = channel.id();
+                ChannelMap.removeChannelByName(id);
+            } else if (event.state() == IdleState.WRITER_IDLE) {
+                log.info("Client:{}, WRITER_IDLE 写超时", socketString);
+                ctx.disconnect();
+                Channel channel = ctx.channel();
+                ChannelId id = channel.id();
+                ChannelMap.removeChannelByName(id);
+            } else if (event.state() == IdleState.ALL_IDLE) {
+                log.info("Client:{},ALL_IDLE 总超时", socketString);
+                ctx.disconnect();
+                Channel channel = ctx.channel();
+                ChannelId id = channel.id();
+                ChannelMap.removeChannelByName(id);
+            }
+        }
+    }
+
+    /**
+     * 功能描述: 发生异常会触发此函数
+     *
+     * @param ctx   通道处理程序上下文
+     * @param cause 异常
+     * @return void
+     * @Author keLe
+     * @Date 2022/8/26
+     */
+    @Override
+    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
+        ctx.close();
+        log.info("{}:发生了错误,此连接被关闭。此时连通数量:{}", ctx.channel().id(), ChannelMap.getChannelMap().size());
+    }
+
+}

+ 63 - 0
warewms-system/src/main/java/com/warewms/hailiang/config/LaunchRunner.java

@@ -0,0 +1,63 @@
+/*
+package com.warewms.hailiang.config;
+
+
+import cn.hutool.cron.CronUtil;
+import com.warewms.hailiang.common.NettyServer;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.core.annotation.Order;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.net.InetSocketAddress;
+
+*/
+/**
+ * 功能描述: 任务队列
+ * @Author keLe
+ * @Date 2022/7/20
+ *//*
+
+@Component
+@Order(2)
+@Slf4j
+public class LaunchRunner implements CommandLineRunner {
+
+    @Resource
+    private NettyServer nettyServer;
+
+    @Resource
+    private SocketProperties socketProperties;
+
+
+    @Override
+    public void run(String... args) throws Exception {
+        TaskRunner();
+        InetSocketAddress address = new InetSocketAddress(socketProperties.getHost(),socketProperties.getPort());
+        log.info("netty服务器启动地址:"+socketProperties.getHost());
+        nettyServer.start(address);
+    }
+    */
+/**
+     * 执行正在运行的任务
+     *//*
+
+    private  void TaskRunner() {
+        */
+/**
+         * 任务队列启动
+         *//*
+
+        CronUtil.setMatchSecond(true);
+        CronUtil.start();
+        log.info("\n-----------------------任务服务启动------------------------\n\t" +
+                        "当前正在启动的{}个任务"+
+                        "\n-----------------------------------------------------------\n\t"
+                , CronUtil.getScheduler().size()
+
+        );
+
+    }
+}
+*/

+ 29 - 0
warewms-system/src/main/java/com/warewms/hailiang/config/SocketProperties.java

@@ -0,0 +1,29 @@
+package com.warewms.hailiang.config;
+
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.stereotype.Component;
+
+/**
+ * 功能描述: 配置类
+ *
+ * @Author keLe
+ * @Date 2022/8/26
+ */
+@Setter
+@Getter
+@ToString
+@Component
+@Configuration
+@PropertySource("classpath:application.yml")
+@ConfigurationProperties(prefix = "socket")
+public class SocketProperties {
+    private Integer port;
+    private String host;
+
+}

+ 121 - 0
warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader12Connect.java

@@ -0,0 +1,121 @@
+package com.warewms.hailiang.connect;
+
+import cn.hutool.extra.spring.SpringUtil;
+import com.github.rholder.retry.*;
+import com.warewms.hailiang.connect.handler.CodeReader12Handler;
+import com.warewms.hailiang.connect.handler.CodeReader3Handler;
+import com.warewms.hailiang.domian.Device;
+import io.netty.bootstrap.Bootstrap;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.ChannelOption;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.SocketChannel;
+import io.netty.channel.socket.nio.NioSocketChannel;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * Created with IntelliJ IDEA.
+ *
+ * @author: liuzhifei
+ * Date: 2023/8/9
+ * Time: 15:45
+ * To change this template use File | Settings | File Templates.
+ * Description:倒角读码器连接
+ **/
+@Slf4j
+public class CodeReader12Connect implements TCPConnectBase {
+
+    private final String IP_ADDR = "172.20.27.12";
+
+    private final int PORT = 51236;
+
+    private final String deviceName ="CodeReader12";
+
+    private boolean enable = false;
+
+    private ChannelFuture future;
+
+    private Bootstrap bootstrap;
+
+    private EventLoopGroup group;
+
+
+
+    @Override
+    public void init() throws InterruptedException {
+        if (enable) {
+            log.info("ip:{},deviceName:{}正在进行连接", IP_ADDR, deviceName);
+            group = new NioEventLoopGroup();
+            try {
+                bootstrap = new Bootstrap();
+                bootstrap.group(group).channel(NioSocketChannel.class)
+                        .option(ChannelOption.TCP_NODELAY, true)
+                        .handler(new ChannelInitializer<SocketChannel>() {
+                            @Override
+                            protected void initChannel(SocketChannel socketChannel) throws Exception {
+                                socketChannel.pipeline().addLast(new CodeReader12Handler());
+                            }
+                        });
+                future = bootstrap.connect(IP_ADDR, PORT).sync();
+                future.addListener((channelFuture) -> {
+                    if (channelFuture.isSuccess()) {
+                        SpringUtil.getApplicationContext().publishEvent(new Device(deviceName, "1"));
+                        log.info("ip:{},deviceName:{}连接成功", IP_ADDR, deviceName);
+                    } else {
+                        log.info("ip:{},deviceName:{}连接失败等待重试!", IP_ADDR, deviceName);
+                        retry();
+                    }
+                });
+            } catch (Exception e) {
+                log.error("ip:{},deviceName:{}连接异常,{},准备重试", IP_ADDR, deviceName, e.getMessage());
+                retry();
+            }
+        }
+    }
+
+    @Override
+    public void retry() {
+        Retryer<Boolean> retryer = RetryerBuilder.<Boolean>newBuilder()
+                .retryIfResult(Boolean.FALSE::equals)
+                .retryIfExceptionOfType(Exception.class)
+                .withStopStrategy(StopStrategies.neverStop())
+                .withWaitStrategy(WaitStrategies.fixedWait(5, TimeUnit.SECONDS))
+                .build();
+        try {
+            retryer.call(new Callable<Boolean>() {
+                AtomicBoolean isSuccess = new AtomicBoolean(false);
+                @Override
+                public Boolean call() throws Exception {
+                    log.info("ip:{},deviceName:{}连接重试",IP_ADDR,deviceName);
+                    future = bootstrap.connect(IP_ADDR, PORT).sync();
+                    future.addListener((channelFuture) -> {
+                        isSuccess.set(channelFuture.isSuccess());
+                        if (channelFuture.isSuccess()) {
+                            SpringUtil.getApplicationContext().publishEvent(new Device(deviceName,"1"));
+                            log.info("ip:{},deviceName:{}连接成功",IP_ADDR,deviceName);
+                        }else {
+                            log.info("ip:{},deviceName:{}连接失败等待重试!",IP_ADDR,deviceName);
+                        }
+                    });
+                    Thread.sleep(3000);
+                    return isSuccess.get();
+                }
+            });
+        } catch (RetryException | ExecutionException e) {
+            e.printStackTrace();
+        }
+    }
+
+    @Override
+    public void close() {
+        group.shutdownGracefully();
+    }
+
+}

+ 121 - 0
warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader13Connect.java

@@ -0,0 +1,121 @@
+package com.warewms.hailiang.connect;
+
+import cn.hutool.extra.spring.SpringUtil;
+import com.github.rholder.retry.*;
+import com.warewms.hailiang.connect.handler.CodeReader13Handler;
+import com.warewms.hailiang.connect.handler.CodeReader3Handler;
+import com.warewms.hailiang.domian.Device;
+import io.netty.bootstrap.Bootstrap;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.ChannelOption;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.SocketChannel;
+import io.netty.channel.socket.nio.NioSocketChannel;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * Created with IntelliJ IDEA.
+ *
+ * @author: liuzhifei
+ * Date: 2023/8/9
+ * Time: 15:45
+ * To change this template use File | Settings | File Templates.
+ * Description:倒角读码器连接
+ **/
+@Slf4j
+public class CodeReader13Connect implements TCPConnectBase {
+
+    private final String IP_ADDR = "172.20.27.13";
+
+    private final int PORT = 51236;
+
+    private final String deviceName ="CodeReader13";
+
+    private boolean enable = false;
+
+    private ChannelFuture future;
+
+    private Bootstrap bootstrap;
+
+    private EventLoopGroup group;
+
+
+
+    @Override
+    public void init() throws InterruptedException {
+        if (enable) {
+            log.info("ip:{},deviceName:{}正在进行连接", IP_ADDR, deviceName);
+            group = new NioEventLoopGroup();
+            try {
+                bootstrap = new Bootstrap();
+                bootstrap.group(group).channel(NioSocketChannel.class)
+                        .option(ChannelOption.TCP_NODELAY, true)
+                        .handler(new ChannelInitializer<SocketChannel>() {
+                            @Override
+                            protected void initChannel(SocketChannel socketChannel) throws Exception {
+                                socketChannel.pipeline().addLast(new CodeReader13Handler());
+                            }
+                        });
+                future = bootstrap.connect(IP_ADDR, PORT).sync();
+                future.addListener((channelFuture) -> {
+                    if (channelFuture.isSuccess()) {
+                        SpringUtil.getApplicationContext().publishEvent(new Device(deviceName, "1"));
+                        log.info("ip:{},deviceName:{}连接成功", IP_ADDR, deviceName);
+                    } else {
+                        log.info("ip:{},deviceName:{}连接失败等待重试!", IP_ADDR, deviceName);
+                        retry();
+                    }
+                });
+            } catch (Exception e) {
+                log.error("ip:{},deviceName:{}连接异常,{},准备重试", IP_ADDR, deviceName, e.getMessage());
+                retry();
+            }
+        }
+    }
+
+    @Override
+    public void retry() {
+        Retryer<Boolean> retryer = RetryerBuilder.<Boolean>newBuilder()
+                .retryIfResult(Boolean.FALSE::equals)
+                .retryIfExceptionOfType(Exception.class)
+                .withStopStrategy(StopStrategies.neverStop())
+                .withWaitStrategy(WaitStrategies.fixedWait(5, TimeUnit.SECONDS))
+                .build();
+        try {
+            retryer.call(new Callable<Boolean>() {
+                AtomicBoolean isSuccess = new AtomicBoolean(false);
+                @Override
+                public Boolean call() throws Exception {
+                    log.info("ip:{},deviceName:{}连接重试",IP_ADDR,deviceName);
+                    future = bootstrap.connect(IP_ADDR, PORT).sync();
+                    future.addListener((channelFuture) -> {
+                        isSuccess.set(channelFuture.isSuccess());
+                        if (channelFuture.isSuccess()) {
+                            SpringUtil.getApplicationContext().publishEvent(new Device(deviceName,"1"));
+                            log.info("ip:{},deviceName:{}连接成功",IP_ADDR,deviceName);
+                        }else {
+                            log.info("ip:{},deviceName:{}连接失败等待重试!",IP_ADDR,deviceName);
+                        }
+                    });
+                    Thread.sleep(3000);
+                    return isSuccess.get();
+                }
+            });
+        } catch (RetryException | ExecutionException e) {
+            e.printStackTrace();
+        }
+    }
+
+    @Override
+    public void close() {
+        group.shutdownGracefully();
+    }
+
+}

+ 121 - 0
warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader14Connect.java

@@ -0,0 +1,121 @@
+package com.warewms.hailiang.connect;
+
+import cn.hutool.extra.spring.SpringUtil;
+import com.github.rholder.retry.*;
+import com.warewms.hailiang.connect.handler.CodeReader14Handler;
+import com.warewms.hailiang.connect.handler.CodeReader3Handler;
+import com.warewms.hailiang.domian.Device;
+import io.netty.bootstrap.Bootstrap;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.ChannelOption;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.SocketChannel;
+import io.netty.channel.socket.nio.NioSocketChannel;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * Created with IntelliJ IDEA.
+ *
+ * @author: liuzhifei
+ * Date: 2023/8/9
+ * Time: 15:45
+ * To change this template use File | Settings | File Templates.
+ * Description:倒角读码器连接
+ **/
+@Slf4j
+public class CodeReader14Connect implements TCPConnectBase {
+
+    private final String IP_ADDR = "172.20.27.14";
+
+    private final int PORT = 51236;
+
+    private final String deviceName ="CodeReader14";
+
+    private boolean enable = false;
+
+    private ChannelFuture future;
+
+    private Bootstrap bootstrap;
+
+    private EventLoopGroup group;
+
+
+
+    @Override
+    public void init() throws InterruptedException {
+        if (enable) {
+            log.info("ip:{},deviceName:{}正在进行连接", IP_ADDR, deviceName);
+            group = new NioEventLoopGroup();
+            try {
+                bootstrap = new Bootstrap();
+                bootstrap.group(group).channel(NioSocketChannel.class)
+                        .option(ChannelOption.TCP_NODELAY, true)
+                        .handler(new ChannelInitializer<SocketChannel>() {
+                            @Override
+                            protected void initChannel(SocketChannel socketChannel) throws Exception {
+                                socketChannel.pipeline().addLast(new CodeReader14Handler());
+                            }
+                        });
+                future = bootstrap.connect(IP_ADDR, PORT).sync();
+                future.addListener((channelFuture) -> {
+                    if (channelFuture.isSuccess()) {
+                        SpringUtil.getApplicationContext().publishEvent(new Device(deviceName, "1"));
+                        log.info("ip:{},deviceName:{}连接成功", IP_ADDR, deviceName);
+                    } else {
+                        log.info("ip:{},deviceName:{}连接失败等待重试!", IP_ADDR, deviceName);
+                        retry();
+                    }
+                });
+            } catch (Exception e) {
+                log.error("ip:{},deviceName:{}连接异常,{},准备重试", IP_ADDR, deviceName, e.getMessage());
+                retry();
+            }
+        }
+    }
+
+    @Override
+    public void retry() {
+        Retryer<Boolean> retryer = RetryerBuilder.<Boolean>newBuilder()
+                .retryIfResult(Boolean.FALSE::equals)
+                .retryIfExceptionOfType(Exception.class)
+                .withStopStrategy(StopStrategies.neverStop())
+                .withWaitStrategy(WaitStrategies.fixedWait(5, TimeUnit.SECONDS))
+                .build();
+        try {
+            retryer.call(new Callable<Boolean>() {
+                AtomicBoolean isSuccess = new AtomicBoolean(false);
+                @Override
+                public Boolean call() throws Exception {
+                    log.info("ip:{},deviceName:{}连接重试",IP_ADDR,deviceName);
+                    future = bootstrap.connect(IP_ADDR, PORT).sync();
+                    future.addListener((channelFuture) -> {
+                        isSuccess.set(channelFuture.isSuccess());
+                        if (channelFuture.isSuccess()) {
+                            SpringUtil.getApplicationContext().publishEvent(new Device(deviceName,"1"));
+                            log.info("ip:{},deviceName:{}连接成功",IP_ADDR,deviceName);
+                        }else {
+                            log.info("ip:{},deviceName:{}连接失败等待重试!",IP_ADDR,deviceName);
+                        }
+                    });
+                    Thread.sleep(3000);
+                    return isSuccess.get();
+                }
+            });
+        } catch (RetryException | ExecutionException e) {
+            e.printStackTrace();
+        }
+    }
+
+    @Override
+    public void close() {
+        group.shutdownGracefully();
+    }
+
+}

+ 120 - 0
warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader3Connect.java

@@ -0,0 +1,120 @@
+package com.warewms.hailiang.connect;
+
+import cn.hutool.extra.spring.SpringUtil;
+import com.github.rholder.retry.*;
+import com.warewms.hailiang.connect.handler.CodeReader3Handler;
+import com.warewms.hailiang.domian.Device;
+import io.netty.bootstrap.Bootstrap;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.ChannelOption;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.SocketChannel;
+import io.netty.channel.socket.nio.NioSocketChannel;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * Created with IntelliJ IDEA.
+ *
+ * @author: liuzhifei
+ * Date: 2023/8/9
+ * Time: 15:45
+ * To change this template use File | Settings | File Templates.
+ * Description:倒角读码器连接
+ **/
+@Slf4j
+public class CodeReader3Connect implements TCPConnectBase {
+
+    private final String IP_ADDR = "172.20.27.3";
+
+    private final String deviceName ="CodeReader3";
+
+    private final int PORT = 51236;
+
+    private boolean enable = false;
+
+    private ChannelFuture future;
+
+    private Bootstrap bootstrap;
+
+    private EventLoopGroup group;
+
+
+
+    @Override
+    public void init() throws InterruptedException {
+        if (enable){
+            log.info("ip:{},deviceName:{}正在进行连接",IP_ADDR,deviceName);
+            group = new NioEventLoopGroup();
+            try {
+                bootstrap = new Bootstrap();
+                bootstrap.group(group).channel(NioSocketChannel.class)
+                        .option(ChannelOption.TCP_NODELAY, true)
+                        .handler(new ChannelInitializer<SocketChannel>() {
+                            @Override
+                            protected void initChannel(SocketChannel socketChannel) throws Exception {
+                                socketChannel.pipeline().addLast(new CodeReader3Handler());
+                            }
+                        });
+                future = bootstrap.connect(IP_ADDR, PORT).sync();
+                future.addListener((channelFuture) -> {
+                    if (channelFuture.isSuccess()) {
+                        SpringUtil.getApplicationContext().publishEvent(new Device(deviceName,"1"));
+                        log.info("ip:{},deviceName:{}连接成功",IP_ADDR,deviceName);
+                    }else {
+                        log.info("ip:{},deviceName:{}连接失败等待重试!",IP_ADDR,deviceName);
+                        retry();
+                    }
+                });
+            } catch (Exception e) {
+                log.error("ip:{},deviceName:{}连接异常,{},准备重试",IP_ADDR,deviceName, e.getMessage());
+                retry();
+            }
+        }
+    }
+
+    @Override
+    public void retry() {
+        Retryer<Boolean> retryer = RetryerBuilder.<Boolean>newBuilder()
+                .retryIfResult(Boolean.FALSE::equals)
+                .retryIfExceptionOfType(Exception.class)
+                .withStopStrategy(StopStrategies.neverStop())
+                .withWaitStrategy(WaitStrategies.fixedWait(5, TimeUnit.SECONDS))
+                .build();
+        try {
+            retryer.call(new Callable<Boolean>() {
+                AtomicBoolean isSuccess = new AtomicBoolean(false);
+                @Override
+                public Boolean call() throws Exception {
+                    log.info("ip:{},deviceName:{}连接重试",IP_ADDR,deviceName);
+                    future = bootstrap.connect(IP_ADDR, PORT).sync();
+                    future.addListener((channelFuture) -> {
+                        isSuccess.set(channelFuture.isSuccess());
+                        if (channelFuture.isSuccess()) {
+                            SpringUtil.getApplicationContext().publishEvent(new Device(deviceName,"1"));
+                            log.info("ip:{},deviceName:{}连接成功",IP_ADDR,deviceName);
+                        }else {
+                            log.info("ip:{},deviceName:{}连接失败等待重试!",IP_ADDR,deviceName);
+                        }
+                    });
+                    Thread.sleep(3000);
+                    return isSuccess.get();
+                }
+            });
+        } catch (RetryException | ExecutionException e) {
+            e.printStackTrace();
+        }
+    }
+
+    @Override
+    public void close() {
+        group.shutdownGracefully();
+    }
+
+}

+ 121 - 0
warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader5Connect.java

@@ -0,0 +1,121 @@
+package com.warewms.hailiang.connect;
+
+import cn.hutool.extra.spring.SpringUtil;
+import com.github.rholder.retry.*;
+import com.warewms.hailiang.connect.handler.CodeReader3Handler;
+import com.warewms.hailiang.connect.handler.CodeReader5Handler;
+import com.warewms.hailiang.domian.Device;
+import io.netty.bootstrap.Bootstrap;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.ChannelOption;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.SocketChannel;
+import io.netty.channel.socket.nio.NioSocketChannel;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * Created with IntelliJ IDEA.
+ *
+ * @author: liuzhifei
+ * Date: 2023/8/9
+ * Time: 15:45
+ * To change this template use File | Settings | File Templates.
+ * Description:倒角读码器连接
+ **/
+@Slf4j
+public class CodeReader5Connect implements TCPConnectBase {
+
+    private final String IP_ADDR = "172.20.27.5";
+
+    private final int PORT = 51236;
+
+    private final String deviceName ="CodeReader5";
+
+    private boolean enable = false;
+
+    private ChannelFuture future;
+
+    private Bootstrap bootstrap;
+
+    private EventLoopGroup group;
+
+
+
+    @Override
+    public void init() throws InterruptedException {
+        if (enable) {
+            log.info("ip:{},deviceName:{}正在进行连接", IP_ADDR, deviceName);
+            group = new NioEventLoopGroup();
+            try {
+                bootstrap = new Bootstrap();
+                bootstrap.group(group).channel(NioSocketChannel.class)
+                        .option(ChannelOption.TCP_NODELAY, true)
+                        .handler(new ChannelInitializer<SocketChannel>() {
+                            @Override
+                            protected void initChannel(SocketChannel socketChannel) throws Exception {
+                                socketChannel.pipeline().addLast(new CodeReader5Handler());
+                            }
+                        });
+                future = bootstrap.connect(IP_ADDR, PORT).sync();
+                future.addListener((channelFuture) -> {
+                    if (channelFuture.isSuccess()) {
+                        SpringUtil.getApplicationContext().publishEvent(new Device(deviceName, "1"));
+                        log.info("ip:{},deviceName:{}连接成功", IP_ADDR, deviceName);
+                    } else {
+                        log.info("ip:{},deviceName:{}连接失败等待重试!", IP_ADDR, deviceName);
+                        retry();
+                    }
+                });
+            } catch (Exception e) {
+                log.error("ip:{},deviceName:{}连接异常,{},准备重试", IP_ADDR, deviceName, e.getMessage());
+                retry();
+            }
+        }
+    }
+
+    @Override
+    public void retry() {
+        Retryer<Boolean> retryer = RetryerBuilder.<Boolean>newBuilder()
+                .retryIfResult(Boolean.FALSE::equals)
+                .retryIfExceptionOfType(Exception.class)
+                .withStopStrategy(StopStrategies.neverStop())
+                .withWaitStrategy(WaitStrategies.fixedWait(5, TimeUnit.SECONDS))
+                .build();
+        try {
+            retryer.call(new Callable<Boolean>() {
+                AtomicBoolean isSuccess = new AtomicBoolean(false);
+                @Override
+                public Boolean call() throws Exception {
+                    log.info("ip:{},deviceName:{}连接重试",IP_ADDR,deviceName);
+                    future = bootstrap.connect(IP_ADDR, PORT).sync();
+                    future.addListener((channelFuture) -> {
+                        isSuccess.set(channelFuture.isSuccess());
+                        if (channelFuture.isSuccess()) {
+                            SpringUtil.getApplicationContext().publishEvent(new Device(deviceName,"1"));
+                            log.info("ip:{},deviceName:{}连接成功",IP_ADDR,deviceName);
+                        }else {
+                            log.info("ip:{},deviceName:{}连接失败等待重试!",IP_ADDR,deviceName);
+                        }
+                    });
+                    Thread.sleep(3000);
+                    return isSuccess.get();
+                }
+            });
+        } catch (RetryException | ExecutionException e) {
+            e.printStackTrace();
+        }
+    }
+
+    @Override
+    public void close() {
+        group.shutdownGracefully();
+    }
+
+}

+ 121 - 0
warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader6Connect.java

@@ -0,0 +1,121 @@
+package com.warewms.hailiang.connect;
+
+import cn.hutool.extra.spring.SpringUtil;
+import com.github.rholder.retry.*;
+import com.warewms.hailiang.connect.handler.CodeReader3Handler;
+import com.warewms.hailiang.connect.handler.CodeReader6Handler;
+import com.warewms.hailiang.domian.Device;
+import io.netty.bootstrap.Bootstrap;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.ChannelOption;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.SocketChannel;
+import io.netty.channel.socket.nio.NioSocketChannel;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * Created with IntelliJ IDEA.
+ *
+ * @author: liuzhifei
+ * Date: 2023/8/9
+ * Time: 15:45
+ * To change this template use File | Settings | File Templates.
+ * Description:倒角读码器连接
+ **/
+@Slf4j
+public class CodeReader6Connect implements TCPConnectBase {
+
+    private final String IP_ADDR = "172.20.27.6";
+
+    private final int PORT = 51236;
+
+    private final String deviceName ="CodeReader6";
+
+    private boolean enable = false;
+
+    private ChannelFuture future;
+
+    private Bootstrap bootstrap;
+
+    private EventLoopGroup group;
+
+
+
+    @Override
+    public void init() throws InterruptedException {
+        if (enable) {
+            log.info("ip:{},deviceName:{}正在进行连接", IP_ADDR, deviceName);
+            group = new NioEventLoopGroup();
+            try {
+                bootstrap = new Bootstrap();
+                bootstrap.group(group).channel(NioSocketChannel.class)
+                        .option(ChannelOption.TCP_NODELAY, true)
+                        .handler(new ChannelInitializer<SocketChannel>() {
+                            @Override
+                            protected void initChannel(SocketChannel socketChannel) throws Exception {
+                                socketChannel.pipeline().addLast(new CodeReader6Handler());
+                            }
+                        });
+                future = bootstrap.connect(IP_ADDR, PORT).sync();
+                future.addListener((channelFuture) -> {
+                    if (channelFuture.isSuccess()) {
+                        SpringUtil.getApplicationContext().publishEvent(new Device(deviceName, "1"));
+                        log.info("ip:{},deviceName:{}连接成功", IP_ADDR, deviceName);
+                    } else {
+                        log.info("ip:{},deviceName:{}连接失败等待重试!", IP_ADDR, deviceName);
+                        retry();
+                    }
+                });
+            } catch (Exception e) {
+                log.error("ip:{},deviceName:{}连接异常,{},准备重试", IP_ADDR, deviceName, e.getMessage());
+                retry();
+            }
+        }
+    }
+
+    @Override
+    public void retry() {
+        Retryer<Boolean> retryer = RetryerBuilder.<Boolean>newBuilder()
+                .retryIfResult(Boolean.FALSE::equals)
+                .retryIfExceptionOfType(Exception.class)
+                .withStopStrategy(StopStrategies.neverStop())
+                .withWaitStrategy(WaitStrategies.fixedWait(5, TimeUnit.SECONDS))
+                .build();
+        try {
+            retryer.call(new Callable<Boolean>() {
+                AtomicBoolean isSuccess = new AtomicBoolean(false);
+                @Override
+                public Boolean call() throws Exception {
+                    log.info("ip:{},deviceName:{}连接重试",IP_ADDR,deviceName);
+                    future = bootstrap.connect(IP_ADDR, PORT).sync();
+                    future.addListener((channelFuture) -> {
+                        isSuccess.set(channelFuture.isSuccess());
+                        if (channelFuture.isSuccess()) {
+                            SpringUtil.getApplicationContext().publishEvent(new Device(deviceName,"1"));
+                            log.info("ip:{},deviceName:{}连接成功",IP_ADDR,deviceName);
+                        }else {
+                            log.info("ip:{},deviceName:{}连接失败等待重试!",IP_ADDR,deviceName);
+                        }
+                    });
+                    Thread.sleep(3000);
+                    return isSuccess.get();
+                }
+            });
+        } catch (RetryException | ExecutionException e) {
+            e.printStackTrace();
+        }
+    }
+
+    @Override
+    public void close() {
+        group.shutdownGracefully();
+    }
+
+}

+ 122 - 0
warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader7Connect.java

@@ -0,0 +1,122 @@
+package com.warewms.hailiang.connect;
+
+import cn.hutool.extra.spring.SpringUtil;
+import com.github.rholder.retry.*;
+import com.warewms.hailiang.connect.handler.CodeReader3Handler;
+import com.warewms.hailiang.connect.handler.CodeReader6Handler;
+import com.warewms.hailiang.connect.handler.CodeReader7Handler;
+import com.warewms.hailiang.domian.Device;
+import io.netty.bootstrap.Bootstrap;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.ChannelOption;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.SocketChannel;
+import io.netty.channel.socket.nio.NioSocketChannel;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * Created with IntelliJ IDEA.
+ *
+ * @author: liuzhifei
+ * Date: 2023/8/9
+ * Time: 15:45
+ * To change this template use File | Settings | File Templates.
+ * Description:倒角读码器连接
+ **/
+@Slf4j
+public class CodeReader7Connect implements TCPConnectBase {
+
+    private final String IP_ADDR = "172.20.27.7";
+
+    private final int PORT = 51236;
+
+    private final String deviceName ="CodeReader7";
+
+    private boolean enable = false;
+
+    private ChannelFuture future;
+
+    private Bootstrap bootstrap;
+
+    private EventLoopGroup group;
+
+
+
+    @Override
+    public void init() throws InterruptedException {
+        if (enable) {
+            log.info("ip:{},deviceName:{}正在进行连接", IP_ADDR, deviceName);
+            group = new NioEventLoopGroup();
+            try {
+                bootstrap = new Bootstrap();
+                bootstrap.group(group).channel(NioSocketChannel.class)
+                        .option(ChannelOption.TCP_NODELAY, true)
+                        .handler(new ChannelInitializer<SocketChannel>() {
+                            @Override
+                            protected void initChannel(SocketChannel socketChannel) throws Exception {
+                                socketChannel.pipeline().addLast(new CodeReader7Handler());
+                            }
+                        });
+                future = bootstrap.connect(IP_ADDR, PORT).sync();
+                future.addListener((channelFuture) -> {
+                    if (channelFuture.isSuccess()) {
+                        SpringUtil.getApplicationContext().publishEvent(new Device(deviceName, "1"));
+                        log.info("ip:{},deviceName:{}连接成功", IP_ADDR, deviceName);
+                    } else {
+                        log.info("ip:{},deviceName:{}连接失败等待重试!", IP_ADDR, deviceName);
+                        retry();
+                    }
+                });
+            } catch (Exception e) {
+                log.error("ip:{},deviceName:{}连接异常,{},准备重试", IP_ADDR, deviceName, e.getMessage());
+                retry();
+            }
+        }
+    }
+
+    @Override
+    public void retry() {
+        Retryer<Boolean> retryer = RetryerBuilder.<Boolean>newBuilder()
+                .retryIfResult(Boolean.FALSE::equals)
+                .retryIfExceptionOfType(Exception.class)
+                .withStopStrategy(StopStrategies.neverStop())
+                .withWaitStrategy(WaitStrategies.fixedWait(5, TimeUnit.SECONDS))
+                .build();
+        try {
+            retryer.call(new Callable<Boolean>() {
+                AtomicBoolean isSuccess = new AtomicBoolean(false);
+                @Override
+                public Boolean call() throws Exception {
+                    log.info("ip:{},deviceName:{}连接重试",IP_ADDR,deviceName);
+                    future = bootstrap.connect(IP_ADDR, PORT).sync();
+                    future.addListener((channelFuture) -> {
+                        isSuccess.set(channelFuture.isSuccess());
+                        if (channelFuture.isSuccess()) {
+                            SpringUtil.getApplicationContext().publishEvent(new Device(deviceName,"1"));
+                            log.info("ip:{},deviceName:{}连接成功",IP_ADDR,deviceName);
+                        }else {
+                            log.info("ip:{},deviceName:{}连接失败等待重试!",IP_ADDR,deviceName);
+                        }
+                    });
+                    Thread.sleep(3000);
+                    return isSuccess.get();
+                }
+            });
+        } catch (RetryException | ExecutionException e) {
+            e.printStackTrace();
+        }
+    }
+
+    @Override
+    public void close() {
+        group.shutdownGracefully();
+    }
+
+}

+ 121 - 0
warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader8Connect.java

@@ -0,0 +1,121 @@
+package com.warewms.hailiang.connect;
+
+import cn.hutool.extra.spring.SpringUtil;
+import com.github.rholder.retry.*;
+import com.warewms.hailiang.connect.handler.CodeReader3Handler;
+import com.warewms.hailiang.connect.handler.CodeReader8Handler;
+import com.warewms.hailiang.domian.Device;
+import io.netty.bootstrap.Bootstrap;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.ChannelOption;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.SocketChannel;
+import io.netty.channel.socket.nio.NioSocketChannel;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * Created with IntelliJ IDEA.
+ *
+ * @author: liuzhifei
+ * Date: 2023/8/9
+ * Time: 15:45
+ * To change this template use File | Settings | File Templates.
+ * Description:倒角读码器连接
+ **/
+@Slf4j
+public class CodeReader8Connect implements TCPConnectBase {
+
+    private final String IP_ADDR = "172.20.27.8";
+
+    private final int PORT = 51236;
+
+    private final String deviceName ="CodeReader8";
+
+    private boolean enable = false;
+
+    private ChannelFuture future;
+
+    private Bootstrap bootstrap;
+
+    private EventLoopGroup group;
+
+
+
+    @Override
+    public void init() throws InterruptedException {
+        if (enable) {
+            log.info("ip:{},deviceName:{}正在进行连接", IP_ADDR, deviceName);
+            group = new NioEventLoopGroup();
+            try {
+                bootstrap = new Bootstrap();
+                bootstrap.group(group).channel(NioSocketChannel.class)
+                        .option(ChannelOption.TCP_NODELAY, true)
+                        .handler(new ChannelInitializer<SocketChannel>() {
+                            @Override
+                            protected void initChannel(SocketChannel socketChannel) throws Exception {
+                                socketChannel.pipeline().addLast(new CodeReader8Handler());
+                            }
+                        });
+                future = bootstrap.connect(IP_ADDR, PORT).sync();
+                future.addListener((channelFuture) -> {
+                    if (channelFuture.isSuccess()) {
+                        SpringUtil.getApplicationContext().publishEvent(new Device(deviceName, "1"));
+                        log.info("ip:{},deviceName:{}连接成功", IP_ADDR, deviceName);
+                    } else {
+                        log.info("ip:{},deviceName:{}连接失败等待重试!", IP_ADDR, deviceName);
+                        retry();
+                    }
+                });
+            } catch (Exception e) {
+                log.error("ip:{},deviceName:{}连接异常,{},准备重试", IP_ADDR, deviceName, e.getMessage());
+                retry();
+            }
+        }
+    }
+
+    @Override
+    public void retry() {
+        Retryer<Boolean> retryer = RetryerBuilder.<Boolean>newBuilder()
+                .retryIfResult(Boolean.FALSE::equals)
+                .retryIfExceptionOfType(Exception.class)
+                .withStopStrategy(StopStrategies.neverStop())
+                .withWaitStrategy(WaitStrategies.fixedWait(5, TimeUnit.SECONDS))
+                .build();
+        try {
+            retryer.call(new Callable<Boolean>() {
+                AtomicBoolean isSuccess = new AtomicBoolean(false);
+                @Override
+                public Boolean call() throws Exception {
+                    log.info("ip:{},deviceName:{}连接重试",IP_ADDR,deviceName);
+                    future = bootstrap.connect(IP_ADDR, PORT).sync();
+                    future.addListener((channelFuture) -> {
+                        isSuccess.set(channelFuture.isSuccess());
+                        if (channelFuture.isSuccess()) {
+                            SpringUtil.getApplicationContext().publishEvent(new Device(deviceName,"1"));
+                            log.info("ip:{},deviceName:{}连接成功",IP_ADDR,deviceName);
+                        }else {
+                            log.info("ip:{},deviceName:{}连接失败等待重试!",IP_ADDR,deviceName);
+                        }
+                    });
+                    Thread.sleep(3000);
+                    return isSuccess.get();
+                }
+            });
+        } catch (RetryException | ExecutionException e) {
+            e.printStackTrace();
+        }
+    }
+
+    @Override
+    public void close() {
+        group.shutdownGracefully();
+    }
+
+}

+ 121 - 0
warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader9Connect.java

@@ -0,0 +1,121 @@
+package com.warewms.hailiang.connect;
+
+import cn.hutool.extra.spring.SpringUtil;
+import com.github.rholder.retry.*;
+import com.warewms.hailiang.connect.handler.CodeReader3Handler;
+import com.warewms.hailiang.connect.handler.CodeReader9Handler;
+import com.warewms.hailiang.domian.Device;
+import io.netty.bootstrap.Bootstrap;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.ChannelOption;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.SocketChannel;
+import io.netty.channel.socket.nio.NioSocketChannel;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * Created with IntelliJ IDEA.
+ *
+ * @author: liuzhifei
+ * Date: 2023/8/9
+ * Time: 15:45
+ * To change this template use File | Settings | File Templates.
+ * Description:倒角读码器连接
+ **/
+@Slf4j
+public class CodeReader9Connect implements TCPConnectBase {
+
+    private final String IP_ADDR = "172.20.27.9";
+
+    private final int PORT = 51236;
+
+    private final String deviceName ="CodeReader9";
+
+    private boolean enable = false;
+
+    private ChannelFuture future;
+
+    private Bootstrap bootstrap;
+
+    private EventLoopGroup group;
+
+
+
+    @Override
+    public void init() throws InterruptedException {
+        if (enable) {
+            log.info("ip:{},deviceName:{}正在进行连接", IP_ADDR, deviceName);
+            group = new NioEventLoopGroup();
+            try {
+                bootstrap = new Bootstrap();
+                bootstrap.group(group).channel(NioSocketChannel.class)
+                        .option(ChannelOption.TCP_NODELAY, true)
+                        .handler(new ChannelInitializer<SocketChannel>() {
+                            @Override
+                            protected void initChannel(SocketChannel socketChannel) throws Exception {
+                                socketChannel.pipeline().addLast(new CodeReader9Handler());
+                            }
+                        });
+                future = bootstrap.connect(IP_ADDR, PORT).sync();
+                future.addListener((channelFuture) -> {
+                    if (channelFuture.isSuccess()) {
+                        SpringUtil.getApplicationContext().publishEvent(new Device(deviceName, "1"));
+                        log.info("ip:{},deviceName:{}连接成功", IP_ADDR, deviceName);
+                    } else {
+                        log.info("ip:{},deviceName:{}连接失败等待重试!", IP_ADDR, deviceName);
+                        retry();
+                    }
+                });
+            } catch (Exception e) {
+                log.error("ip:{},deviceName:{}连接异常,{},准备重试", IP_ADDR, deviceName, e.getMessage());
+                retry();
+            }
+        }
+    }
+
+    @Override
+    public void retry() {
+        Retryer<Boolean> retryer = RetryerBuilder.<Boolean>newBuilder()
+                .retryIfResult(Boolean.FALSE::equals)
+                .retryIfExceptionOfType(Exception.class)
+                .withStopStrategy(StopStrategies.neverStop())
+                .withWaitStrategy(WaitStrategies.fixedWait(5, TimeUnit.SECONDS))
+                .build();
+        try {
+            retryer.call(new Callable<Boolean>() {
+                AtomicBoolean isSuccess = new AtomicBoolean(false);
+                @Override
+                public Boolean call() throws Exception {
+                    log.info("ip:{},deviceName:{}连接重试",IP_ADDR,deviceName);
+                    future = bootstrap.connect(IP_ADDR, PORT).sync();
+                    future.addListener((channelFuture) -> {
+                        isSuccess.set(channelFuture.isSuccess());
+                        if (channelFuture.isSuccess()) {
+                            SpringUtil.getApplicationContext().publishEvent(new Device(deviceName,"1"));
+                            log.info("ip:{},deviceName:{}连接成功",IP_ADDR,deviceName);
+                        }else {
+                            log.info("ip:{},deviceName:{}连接失败等待重试!",IP_ADDR,deviceName);
+                        }
+                    });
+                    Thread.sleep(3000);
+                    return isSuccess.get();
+                }
+            });
+        } catch (RetryException | ExecutionException e) {
+            e.printStackTrace();
+        }
+    }
+
+    @Override
+    public void close() {
+        group.shutdownGracefully();
+    }
+
+}

+ 45 - 0
warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader12Handler.java

@@ -0,0 +1,45 @@
+package com.warewms.hailiang.connect.handler;
+
+import com.warewms.hailiang.connect.InkjetPrintersConnect;
+import com.warewms.hailiang.init.TcpServiceRunner;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+import io.netty.util.CharsetUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+/**
+ * Created with IntelliJ IDEA.
+ *
+ * @author: liuzhifei
+ * Date: 2023/8/9
+ * Time: 17:07
+ * To change this template use File | Settings | File Templates.
+ * Description: 喷码机连接消息处理类
+ **/
+@Slf4j
+@Component
+public class CodeReader12Handler extends ChannelInboundHandlerAdapter  {
+
+
+    @Override
+    public void channelActive(ChannelHandlerContext ctx) throws Exception {
+        ctx.writeAndFlush(Unpooled.copiedBuffer("T", CharsetUtil.UTF_8));
+    }
+
+    @Override
+    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+        ByteBuf byteBuf = (ByteBuf) msg;
+        log.info(String.valueOf(byteBuf.toString(CharsetUtil.UTF_8)));
+    }
+
+    @Override
+    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
+        log.error("倒角读码器连接已断开!");
+        InkjetPrintersConnect inkjetPrintersConnect = (InkjetPrintersConnect) TcpServiceRunner.getTCPInstanceList().get("InkjetPrintersConnect");
+        inkjetPrintersConnect.retry();
+        super.channelInactive(ctx);
+    }
+}

+ 45 - 0
warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader13Handler.java

@@ -0,0 +1,45 @@
+package com.warewms.hailiang.connect.handler;
+
+import com.warewms.hailiang.connect.InkjetPrintersConnect;
+import com.warewms.hailiang.init.TcpServiceRunner;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+import io.netty.util.CharsetUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+/**
+ * Created with IntelliJ IDEA.
+ *
+ * @author: liuzhifei
+ * Date: 2023/8/9
+ * Time: 17:07
+ * To change this template use File | Settings | File Templates.
+ * Description: 喷码机连接消息处理类
+ **/
+@Slf4j
+@Component
+public class CodeReader13Handler extends ChannelInboundHandlerAdapter  {
+
+
+    @Override
+    public void channelActive(ChannelHandlerContext ctx) throws Exception {
+        ctx.writeAndFlush(Unpooled.copiedBuffer("T", CharsetUtil.UTF_8));
+    }
+
+    @Override
+    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+        ByteBuf byteBuf = (ByteBuf) msg;
+        log.info(String.valueOf(byteBuf.toString(CharsetUtil.UTF_8)));
+    }
+
+    @Override
+    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
+        log.error("倒角读码器连接已断开!");
+        InkjetPrintersConnect inkjetPrintersConnect = (InkjetPrintersConnect) TcpServiceRunner.getTCPInstanceList().get("InkjetPrintersConnect");
+        inkjetPrintersConnect.retry();
+        super.channelInactive(ctx);
+    }
+}

+ 45 - 0
warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader14Handler.java

@@ -0,0 +1,45 @@
+package com.warewms.hailiang.connect.handler;
+
+import com.warewms.hailiang.connect.InkjetPrintersConnect;
+import com.warewms.hailiang.init.TcpServiceRunner;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+import io.netty.util.CharsetUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+/**
+ * Created with IntelliJ IDEA.
+ *
+ * @author: liuzhifei
+ * Date: 2023/8/9
+ * Time: 17:07
+ * To change this template use File | Settings | File Templates.
+ * Description: 喷码机连接消息处理类
+ **/
+@Slf4j
+@Component
+public class CodeReader14Handler extends ChannelInboundHandlerAdapter  {
+
+
+    @Override
+    public void channelActive(ChannelHandlerContext ctx) throws Exception {
+        ctx.writeAndFlush(Unpooled.copiedBuffer("T", CharsetUtil.UTF_8));
+    }
+
+    @Override
+    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+        ByteBuf byteBuf = (ByteBuf) msg;
+        log.info(String.valueOf(byteBuf.toString(CharsetUtil.UTF_8)));
+    }
+
+    @Override
+    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
+        log.error("倒角读码器连接已断开!");
+        InkjetPrintersConnect inkjetPrintersConnect = (InkjetPrintersConnect) TcpServiceRunner.getTCPInstanceList().get("InkjetPrintersConnect");
+        inkjetPrintersConnect.retry();
+        super.channelInactive(ctx);
+    }
+}

+ 47 - 0
warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader3Handler.java

@@ -0,0 +1,47 @@
+package com.warewms.hailiang.connect.handler;
+
+import com.warewms.hailiang.connect.InkjetPrintersConnect;
+import com.warewms.hailiang.enums.CodeReaderEnum;
+import com.warewms.hailiang.init.TcpServiceRunner;
+import com.warewms.hailiang.util.ParseMsgTools;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+import io.netty.util.CharsetUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+/**
+ * Created with IntelliJ IDEA.
+ *
+ * @author: liuzhifei
+ * Date: 2023/8/9
+ * Time: 17:07
+ * To change this template use File | Settings | File Templates.
+ * Description: 喷码机连接消息处理类
+ **/
+@Slf4j
+@Component
+public class CodeReader3Handler extends ChannelInboundHandlerAdapter  {
+
+
+    @Override
+    public void channelActive(ChannelHandlerContext ctx) throws Exception {
+        ctx.writeAndFlush(Unpooled.copiedBuffer(CodeReaderEnum.readCode.toString(), CharsetUtil.UTF_8));
+    }
+
+    @Override
+    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+        ByteBuf byteBuf = (ByteBuf) msg;
+        log.info(String.valueOf(byteBuf.toString(CharsetUtil.UTF_8)));
+    }
+
+    @Override
+    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
+        log.error("倒角读码器连接已断开!");
+        InkjetPrintersConnect inkjetPrintersConnect = (InkjetPrintersConnect) TcpServiceRunner.getTCPInstanceList().get("InkjetPrintersConnect");
+        inkjetPrintersConnect.retry();
+        super.channelInactive(ctx);
+    }
+}

+ 45 - 0
warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader5Handler.java

@@ -0,0 +1,45 @@
+package com.warewms.hailiang.connect.handler;
+
+import com.warewms.hailiang.connect.InkjetPrintersConnect;
+import com.warewms.hailiang.init.TcpServiceRunner;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+import io.netty.util.CharsetUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+/**
+ * Created with IntelliJ IDEA.
+ *
+ * @author: liuzhifei
+ * Date: 2023/8/9
+ * Time: 17:07
+ * To change this template use File | Settings | File Templates.
+ * Description: 喷码机连接消息处理类
+ **/
+@Slf4j
+@Component
+public class CodeReader5Handler extends ChannelInboundHandlerAdapter  {
+
+
+    @Override
+    public void channelActive(ChannelHandlerContext ctx) throws Exception {
+        ctx.writeAndFlush(Unpooled.copiedBuffer("T", CharsetUtil.UTF_8));
+    }
+
+    @Override
+    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+        ByteBuf byteBuf = (ByteBuf) msg;
+        log.info(String.valueOf(byteBuf.toString(CharsetUtil.UTF_8)));
+    }
+
+    @Override
+    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
+        log.error("倒角读码器连接已断开!");
+        InkjetPrintersConnect inkjetPrintersConnect = (InkjetPrintersConnect) TcpServiceRunner.getTCPInstanceList().get("InkjetPrintersConnect");
+        inkjetPrintersConnect.retry();
+        super.channelInactive(ctx);
+    }
+}

+ 45 - 0
warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader6Handler.java

@@ -0,0 +1,45 @@
+package com.warewms.hailiang.connect.handler;
+
+import com.warewms.hailiang.connect.InkjetPrintersConnect;
+import com.warewms.hailiang.init.TcpServiceRunner;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+import io.netty.util.CharsetUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+/**
+ * Created with IntelliJ IDEA.
+ *
+ * @author: liuzhifei
+ * Date: 2023/8/9
+ * Time: 17:07
+ * To change this template use File | Settings | File Templates.
+ * Description: 喷码机连接消息处理类
+ **/
+@Slf4j
+@Component
+public class CodeReader6Handler extends ChannelInboundHandlerAdapter  {
+
+
+    @Override
+    public void channelActive(ChannelHandlerContext ctx) throws Exception {
+        ctx.writeAndFlush(Unpooled.copiedBuffer("T", CharsetUtil.UTF_8));
+    }
+
+    @Override
+    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+        ByteBuf byteBuf = (ByteBuf) msg;
+        log.info(String.valueOf(byteBuf.toString(CharsetUtil.UTF_8)));
+    }
+
+    @Override
+    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
+        log.error("倒角读码器连接已断开!");
+        InkjetPrintersConnect inkjetPrintersConnect = (InkjetPrintersConnect) TcpServiceRunner.getTCPInstanceList().get("InkjetPrintersConnect");
+        inkjetPrintersConnect.retry();
+        super.channelInactive(ctx);
+    }
+}

+ 45 - 0
warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader7Handler.java

@@ -0,0 +1,45 @@
+package com.warewms.hailiang.connect.handler;
+
+import com.warewms.hailiang.connect.InkjetPrintersConnect;
+import com.warewms.hailiang.init.TcpServiceRunner;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+import io.netty.util.CharsetUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+/**
+ * Created with IntelliJ IDEA.
+ *
+ * @author: liuzhifei
+ * Date: 2023/8/9
+ * Time: 17:07
+ * To change this template use File | Settings | File Templates.
+ * Description: 喷码机连接消息处理类
+ **/
+@Slf4j
+@Component
+public class CodeReader7Handler extends ChannelInboundHandlerAdapter  {
+
+
+    @Override
+    public void channelActive(ChannelHandlerContext ctx) throws Exception {
+        ctx.writeAndFlush(Unpooled.copiedBuffer("T", CharsetUtil.UTF_8));
+    }
+
+    @Override
+    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+        ByteBuf byteBuf = (ByteBuf) msg;
+        log.info(String.valueOf(byteBuf.toString(CharsetUtil.UTF_8)));
+    }
+
+    @Override
+    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
+        log.error("倒角读码器连接已断开!");
+        InkjetPrintersConnect inkjetPrintersConnect = (InkjetPrintersConnect) TcpServiceRunner.getTCPInstanceList().get("InkjetPrintersConnect");
+        inkjetPrintersConnect.retry();
+        super.channelInactive(ctx);
+    }
+}

+ 45 - 0
warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader8Handler.java

@@ -0,0 +1,45 @@
+package com.warewms.hailiang.connect.handler;
+
+import com.warewms.hailiang.connect.InkjetPrintersConnect;
+import com.warewms.hailiang.init.TcpServiceRunner;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+import io.netty.util.CharsetUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+/**
+ * Created with IntelliJ IDEA.
+ *
+ * @author: liuzhifei
+ * Date: 2023/8/9
+ * Time: 17:07
+ * To change this template use File | Settings | File Templates.
+ * Description: 喷码机连接消息处理类
+ **/
+@Slf4j
+@Component
+public class CodeReader8Handler extends ChannelInboundHandlerAdapter  {
+
+
+    @Override
+    public void channelActive(ChannelHandlerContext ctx) throws Exception {
+        ctx.writeAndFlush(Unpooled.copiedBuffer("T", CharsetUtil.UTF_8));
+    }
+
+    @Override
+    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+        ByteBuf byteBuf = (ByteBuf) msg;
+        log.info(String.valueOf(byteBuf.toString(CharsetUtil.UTF_8)));
+    }
+
+    @Override
+    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
+        log.error("倒角读码器连接已断开!");
+        InkjetPrintersConnect inkjetPrintersConnect = (InkjetPrintersConnect) TcpServiceRunner.getTCPInstanceList().get("InkjetPrintersConnect");
+        inkjetPrintersConnect.retry();
+        super.channelInactive(ctx);
+    }
+}

+ 45 - 0
warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader9Handler.java

@@ -0,0 +1,45 @@
+package com.warewms.hailiang.connect.handler;
+
+import com.warewms.hailiang.connect.InkjetPrintersConnect;
+import com.warewms.hailiang.init.TcpServiceRunner;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+import io.netty.util.CharsetUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+/**
+ * Created with IntelliJ IDEA.
+ *
+ * @author: liuzhifei
+ * Date: 2023/8/9
+ * Time: 17:07
+ * To change this template use File | Settings | File Templates.
+ * Description: 喷码机连接消息处理类
+ **/
+@Slf4j
+@Component
+public class CodeReader9Handler extends ChannelInboundHandlerAdapter  {
+
+
+    @Override
+    public void channelActive(ChannelHandlerContext ctx) throws Exception {
+        ctx.writeAndFlush(Unpooled.copiedBuffer("T", CharsetUtil.UTF_8));
+    }
+
+    @Override
+    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+        ByteBuf byteBuf = (ByteBuf) msg;
+        log.info(String.valueOf(byteBuf.toString(CharsetUtil.UTF_8)));
+    }
+
+    @Override
+    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
+        log.error("倒角读码器连接已断开!");
+        InkjetPrintersConnect inkjetPrintersConnect = (InkjetPrintersConnect) TcpServiceRunner.getTCPInstanceList().get("InkjetPrintersConnect");
+        inkjetPrintersConnect.retry();
+        super.channelInactive(ctx);
+    }
+}

+ 33 - 0
warewms-system/src/main/java/com/warewms/hailiang/contoller/TestContoller.java

@@ -0,0 +1,33 @@
+package com.warewms.hailiang.contoller;
+
+import com.warewms.hailiang.init.PlcConnectServiceRunner;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * Created with IntelliJ IDEA.
+ *
+ * @author: liuzhifei
+ * Date: 2023/8/7
+ * Time: 16:41
+ * To change this template use File | Settings | File Templates.
+ * Description:
+ **/
+@RestController
+@RequestMapping("/test")
+public class TestContoller {
+
+    @Autowired
+    PlcConnectServiceRunner plcConnectServiceRunner;
+
+    @GetMapping("/pclTest")
+    public Object testPlc(String plcName,String db,String type){
+        db = "V"+db;
+        if (type.equals("1")){
+            return plcConnectServiceRunner.getPlcServer(plcName).readBoolean(db);
+        }
+        return null;
+    }
+}

+ 73 - 0
warewms-system/src/main/java/com/warewms/hailiang/domian/Device.java

@@ -0,0 +1,73 @@
+package com.warewms.hailiang.domian;
+
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.warewms.common.core.domain.base.BaseEntity;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 设备表
+ * @TableName device
+ */
+@Data
+public class Device extends BaseEntity implements Serializable  {
+
+    /**
+     * 设备编号
+     */
+    private String deviceId;
+
+    /**
+     * 设备名称
+     */
+    private String deviceName;
+
+    /**
+     * 简称
+     */
+    private String abbreviation;
+    /**
+     * 产线
+     */
+    private String productionLine;
+    /**
+     * 设备IP
+     */
+    private String ip;
+
+    /**
+     * 端口
+     */
+    private int port;
+
+    /**
+     * 连接方式
+     */
+    private String connectionType;
+
+    /**
+     * 状态(1:连接正常:2.断开)
+     */
+    private String status;
+
+    private static final long serialVersionUID = 1L;
+
+    public Device(String deviceId, String deviceName, String abbreviation, String productionLine, String ip, int port, String connectionType, String status) {
+        this.deviceId = deviceId;
+        this.deviceName = deviceName;
+        this.abbreviation = abbreviation;
+        this.productionLine = productionLine;
+        this.ip = ip;
+        this.port = port;
+        this.connectionType = connectionType;
+    }
+
+    public Device(String deviceName, String status) {
+        this.deviceName = deviceName;
+        this.status = status;
+
+    }
+}

+ 46 - 0
warewms-system/src/main/java/com/warewms/hailiang/domian/DeviceLog.java

@@ -0,0 +1,46 @@
+package com.warewms.hailiang.domian;
+
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.warewms.common.core.domain.base.BaseEntity;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 设备日志表
+ * @TableName device_log
+ */
+@Data
+@TableName("device_log")
+public class DeviceLog extends BaseEntity implements Serializable  {
+    /**
+     * 日志编号
+     */
+    @TableId
+    private Long deviceLogId;
+
+    /**
+     * 设备编号
+     */
+    private String deviceId;
+
+    /**
+     * 设备名称
+     */
+    private String deviceName;
+
+    /**
+     * 日志内容
+     */
+    private String content;
+
+    /**
+     * 状态(1:信息:2报警)
+     */
+    private String status;
+
+    private static final long serialVersionUID = 1L;
+
+}

+ 28 - 0
warewms-system/src/main/java/com/warewms/hailiang/enums/CodeReaderEnum.java

@@ -0,0 +1,28 @@
+package com.warewms.hailiang.enums;
+
+public enum CodeReaderEnum {
+
+    /**
+     * 发起读码信号
+     */
+    readCode("T"),
+
+    /**
+     * 读码失败返回信号
+     */
+    ReadFailed("NG");
+
+    private String code;
+
+    CodeReaderEnum(String code) {
+        this.code = code;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+}

+ 19 - 0
warewms-system/src/main/java/com/warewms/hailiang/mapper/DeviceLogMapper.java

@@ -0,0 +1,19 @@
+package com.warewms.hailiang.mapper;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.warewms.hailiang.domian.DeviceLog;
+
+/**
+* @author AD
+* @description 针对表【device_log(设备日志表)】的数据库操作Mapper
+* @createDate 2023-08-21 13:24:57
+* @Entity  DeviceLog
+*/
+public interface DeviceLogMapper extends BaseMapper<DeviceLog> {
+
+}
+
+
+
+