Bladeren bron

【更新】 pom依赖优化

linfutong 3 jaren geleden
bovenliggende
commit
23d49813f6
32 gewijzigde bestanden met toevoegingen van 37 en 2180 verwijderingen
  1. 1 1
      zd-common/pom.xml
  2. 0 1
      zd-modules/pom.xml
  3. 36 10
      zd-modules/zd-algorithm/pom.xml
  4. 0 19
      zd-modules/zd-base/pom.xml
  5. 0 10
      zd-modules/zd-netty/Dockerfile
  6. 0 13
      zd-modules/zd-netty/install.cmd
  7. 0 178
      zd-modules/zd-netty/pom.xml
  8. 0 22
      zd-modules/zd-netty/src/main/java/com/zd/netty/ZdNettyApplication.java
  9. 0 33
      zd-modules/zd-netty/src/main/java/com/zd/netty/base/FridConsumer.java
  10. 0 40
      zd-modules/zd-netty/src/main/java/com/zd/netty/constant/RfidConstants.java
  11. 0 67
      zd-modules/zd-netty/src/main/java/com/zd/netty/controller/FridDeviceController.java
  12. 0 68
      zd-modules/zd-netty/src/main/java/com/zd/netty/enums/ManufacturerTypeEnum.java
  13. 0 107
      zd-modules/zd-netty/src/main/java/com/zd/netty/handler/SocketHandler.java
  14. 0 59
      zd-modules/zd-netty/src/main/java/com/zd/netty/init/NettyStartListener.java
  15. 0 29
      zd-modules/zd-netty/src/main/java/com/zd/netty/init/SocketInitializer.java
  16. 0 63
      zd-modules/zd-netty/src/main/java/com/zd/netty/init/SocketServer.java
  17. 0 172
      zd-modules/zd-netty/src/main/java/com/zd/netty/sdk/DeJuRFIDClientImpl.java
  18. 0 390
      zd-modules/zd-netty/src/main/java/com/zd/netty/sdk/DeJuRFIDServerImpl.java
  19. 0 249
      zd-modules/zd-netty/src/main/java/com/zd/netty/sdk/WuYuanRFIDServiceImpl.java
  20. 0 27
      zd-modules/zd-netty/src/main/java/com/zd/netty/service/IFridService.java
  21. 0 23
      zd-modules/zd-netty/src/main/java/com/zd/netty/service/ISendService.java
  22. 0 29
      zd-modules/zd-netty/src/main/java/com/zd/netty/service/IService.java
  23. 0 58
      zd-modules/zd-netty/src/main/java/com/zd/netty/service/impl/FridServiceImpl.java
  24. 0 139
      zd-modules/zd-netty/src/main/java/com/zd/netty/service/impl/SendServiceImpl.java
  25. 0 78
      zd-modules/zd-netty/src/main/java/com/zd/netty/thread/ThreadPoolTaskConfig.java
  26. 0 10
      zd-modules/zd-netty/src/main/resources/banner.txt
  27. 0 29
      zd-modules/zd-netty/src/main/resources/bootstrap.yml
  28. BIN
      zd-modules/zd-netty/src/main/resources/libs/connect-lib.jar
  29. BIN
      zd-modules/zd-netty/src/main/resources/libs/reader-lib.jar
  30. BIN
      zd-modules/zd-netty/src/main/resources/libs/reader.jar
  31. 0 74
      zd-modules/zd-netty/src/main/resources/logback.xml
  32. 0 182
      zd-modules/zd-netty/wait-for-it.sh

+ 1 - 1
zd-common/pom.xml

@@ -18,7 +18,7 @@
         <module>zd-common-swagger</module>
         <module>zd-common-security</module>
         <module>zd-common-datascope</module>
-	<module>zd-common-datasource</module>
+	    <module>zd-common-datasource</module>
         <module>zd-common-mqtt</module>
     </modules>
 

+ 0 - 1
zd-modules/pom.xml

@@ -19,7 +19,6 @@
         <module>zd-camera</module>
         <module>zd-airbottle</module>
         <module>zd-chemical</module>
-        <module>zd-netty</module>
         <module>zd-bottle-parent</module>
         <module>zd-algorithm</module>
         <module>zd-base</module>

+ 36 - 10
zd-modules/zd-algorithm/pom.xml

@@ -13,6 +13,12 @@
     <description>算法服务</description>
 
     <dependencies>
+        <!-- SpringBoot Web -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+
         <!-- SpringCloud Alibaba Nacos -->
         <dependency>
             <groupId>com.alibaba.cloud</groupId>
@@ -24,11 +30,6 @@
             <groupId>com.alibaba.cloud</groupId>
             <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
         </dependency>
-        <!-- SpringBoot Actuator -->
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-actuator</artifactId>
-        </dependency>
 
         <!-- Mysql Connector -->
         <dependency>
@@ -42,11 +43,6 @@
             <artifactId>zd-common-datasource</artifactId>
         </dependency>
 
-        <!-- SpringBoot Web -->
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-web</artifactId>
-        </dependency>
         <!-- zd Common Log -->
         <dependency>
             <groupId>com.zd</groupId>
@@ -170,4 +166,34 @@
             <systemPath>${project.basedir}/src/main/resources/libs/onvif-java-1.0.2.jar</systemPath>
         </dependency>
     </dependencies>
+
+    <build>
+        <finalName>${project.artifactId}</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <includeSystemScope>true</includeSystemScope>
+                    <fork>true</fork>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <!-- 打包时跳过test插件,不运行test测试用例 -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>${maven-surefire-plugin.version}</version>
+                <configuration>
+                    <skipTests>true</skipTests>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
 </project>

+ 0 - 19
zd-modules/zd-base/pom.xml

@@ -14,7 +14,6 @@
     <description>基础服务</description>
 
     <dependencies>
-
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-web</artifactId>
@@ -29,25 +28,12 @@
             <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
         </dependency>
 
-        <!-- SpringCloud Alibaba Nacos Config -->
-        <dependency>
-            <groupId>com.alibaba.nacos</groupId>
-            <artifactId>nacos-spring-context</artifactId>
-            <version>0.2.3-RC1</version>
-        </dependency>
-
         <!-- SpringCloud Alibaba Sentinel -->
         <dependency>
             <groupId>com.alibaba.cloud</groupId>
             <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
         </dependency>
 
-        <!-- SpringBoot Actuator -->
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-actuator</artifactId>
-        </dependency>
-
         <!-- Mysql Connector -->
         <dependency>
             <groupId>mysql</groupId>
@@ -66,11 +52,6 @@
             <artifactId>zd-common-log</artifactId>
         </dependency>
 
-        <dependency>
-            <groupId>org.projectlombok</groupId>
-            <artifactId>lombok</artifactId>
-        </dependency>
-
         <!-- zd Common DataScope -->
         <dependency>
             <groupId>com.zd</groupId>

File diff suppressed because it is too large
+ 0 - 10
zd-modules/zd-netty/Dockerfile


+ 0 - 13
zd-modules/zd-netty/install.cmd

@@ -1,13 +0,0 @@
-@echo off
-CHCP 65001
-set read=src\main\resources\libs\reader.jar
-if exist %read% (
-    	call mvn install:install-file -Dfile=src/main/resources/libs/reader.jar -DgroupId=com.gg.reader -DartifactId=greader-api -Dversion=1.0 -Dpackaging=jar
-    	echo ===========================%read%安装完成==============================
-    ) else (
-        color 04
-    	echo %read%不存在
-    )
-pause
-exit
-

+ 0 - 178
zd-modules/zd-netty/pom.xml

@@ -1,178 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <parent>
-        <artifactId>zd-modules</artifactId>
-        <groupId>com.zd</groupId>
-        <version>3.1.0</version>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
-    <artifactId>zd-netty</artifactId>
-    <packaging>jar</packaging>
-    <description>netty服务-RFID</description>
-
-    <properties>
-        <maven.compiler.source>8</maven.compiler.source>
-        <maven.compiler.target>8</maven.compiler.target>
-    </properties>
-    <dependencies>
-        <!-- SpringCloud Alibaba Nacos -->
-        <dependency>
-            <groupId>com.alibaba.cloud</groupId>
-            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
-        </dependency>
-
-        <!-- SpringCloud Alibaba Nacos Config -->
-        <dependency>
-            <groupId>com.alibaba.cloud</groupId>
-            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
-        </dependency>
-
-        <!-- SpringCloud Alibaba Nacos Config -->
-
-        <dependency>
-            <groupId>com.alibaba.nacos</groupId>
-            <artifactId>nacos-spring-context</artifactId>
-            <version>0.2.3-RC1</version>
-        </dependency>
-
-        <!-- SpringCloud Alibaba Sentinel -->
-        <dependency>
-            <groupId>com.alibaba.cloud</groupId>
-            <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
-        </dependency>
-
-        <!-- SpringBoot Actuator -->
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-actuator</artifactId>
-        </dependency>
-
-        <!-- Swagger UI -->
-        <dependency>
-            <groupId>io.springfox</groupId>
-            <artifactId>springfox-swagger-ui</artifactId>
-            <version>${swagger.fox.version}</version>
-        </dependency>
-
-        <!-- Mysql Connector -->
-        <dependency>
-            <groupId>mysql</groupId>
-            <artifactId>mysql-connector-java</artifactId>
-        </dependency>
-
-        <!-- zd Common DataSource -->
-        <dependency>
-            <groupId>com.zd</groupId>
-            <artifactId>zd-common-datasource</artifactId>
-        </dependency>
-
-        <!-- zd Common DataScope -->
-        <dependency>
-            <groupId>com.zd</groupId>
-            <artifactId>zd-common-datascope</artifactId>
-        </dependency>
-
-        <!-- zd Common Log -->
-        <dependency>
-            <groupId>com.zd</groupId>
-            <artifactId>zd-common-log</artifactId>
-        </dependency>
-
-        <!-- zd Common Swagger -->
-        <dependency>
-            <groupId>com.zd</groupId>
-            <artifactId>zd-common-swagger</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-test</artifactId>
-            <scope>test</scope>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.junit.vintage</groupId>
-                    <artifactId>junit-vintage-engine</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-        <dependency>
-            <groupId>org.projectlombok</groupId>
-            <artifactId>lombok</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>com.google.code.gson</groupId>
-            <artifactId>gson</artifactId>
-        </dependency>
-
-        <!--mqtt客户端链接服务-->
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-integration</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework.integration</groupId>
-            <artifactId>spring-integration-stream</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework.integration</groupId>
-            <artifactId>spring-integration-mqtt</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>connect</groupId>
-            <artifactId>connect-lib</artifactId>
-            <version>1.0.0</version>
-            <scope>system</scope>
-            <systemPath>${project.basedir}/src/main/resources/libs/connect-lib.jar</systemPath>
-        </dependency>
-        <dependency>
-            <groupId>reader</groupId>
-            <artifactId>reader-lib</artifactId>
-            <version>1.0.0</version>
-            <scope>system</scope>
-            <systemPath>${project.basedir}/src/main/resources/libs/reader-lib.jar</systemPath>
-        </dependency>
-        <dependency>
-            <groupId>com.gg.reader</groupId>
-            <artifactId>greader-api</artifactId>
-            <version>1.0.0</version>
-            <scope>system</scope>
-            <systemPath>${project.basedir}/src/main/resources/libs/reader.jar</systemPath>
-        </dependency>
-        <dependency>
-            <groupId>com.zd</groupId>
-            <artifactId>zd-bottle-api</artifactId>
-            <version>${project.version}</version>
-            <scope>compile</scope>
-        </dependency>
-    </dependencies>
-    <build>
-        <finalName>${project.artifactId}</finalName>
-        <plugins>
-            <plugin>
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-maven-plugin</artifactId>
-                <configuration>
-                    <includeSystemScope>true</includeSystemScope>
-                    <fork>true</fork>
-                </configuration>
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>repackage</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-            <!-- 打包时跳过test插件,不运行test测试用例 -->
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-surefire-plugin</artifactId>
-                <version>${maven-surefire-plugin.version}</version>
-                <configuration>
-                    <skipTests>true</skipTests>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-</project>

+ 0 - 22
zd-modules/zd-netty/src/main/java/com/zd/netty/ZdNettyApplication.java

@@ -1,22 +0,0 @@
-package com.zd.netty;
-
-import com.alibaba.nacos.spring.context.annotation.config.NacosPropertySource;
-import com.zd.common.security.annotation.EnableCustomConfig;
-import com.zd.common.security.annotation.EnableRyFeignClients;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.scheduling.annotation.EnableScheduling;
-
-@EnableCustomConfig
-@EnableRyFeignClients
-@SpringBootApplication
-@EnableScheduling
-@NacosPropertySource(dataId = "zd-netty", autoRefreshed = true)
-@Slf4j
-public class ZdNettyApplication {
-    public static void main(String[] args) {
-        SpringApplication.run(ZdNettyApplication.class, args);
-        log.info("(♥◠‿◠)ノ゙  netty模块启动成功   ლ(´ڡ`ლ)゙");
-    }
-}

+ 0 - 33
zd-modules/zd-netty/src/main/java/com/zd/netty/base/FridConsumer.java

@@ -1,33 +0,0 @@
-package com.zd.netty.base;
-
-import com.payne.reader.base.Consumer;
-import com.payne.reader.bean.receive.InventoryTag;
-import com.zd.netty.service.ISendService;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.BeanUtils;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * @author Administrator
- */
-@Slf4j
-@Component
-public class FridConsumer implements Consumer<InventoryTag> {
-
-    @Autowired
-    private ISendService sendService;
-
-    @Override
-    public void accept(InventoryTag tag) {
-        try {
-            tag.setEpc(tag.getEpc().replace(" ", ""));
-            com.zd.system.api.domain.InventoryTag  inventoryTag = new com.zd.system.api.domain.InventoryTag ();
-            BeanUtils.copyProperties(tag,inventoryTag);
-            sendService.send(inventoryTag);
-        } catch (BeansException e) {
-            log.error(e.getMessage());
-        }
-    }
-}

+ 0 - 40
zd-modules/zd-netty/src/main/java/com/zd/netty/constant/RfidConstants.java

@@ -1,40 +0,0 @@
-package com.zd.netty.constant;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Administrator
- */
-public class RfidConstants{
-
-    private RfidConstants() {
-        throw new IllegalStateException("RfidConstants class");
-    }
-
-    public static final String ALL_TYPE="0";
-    public static final String BOTTLE_TYPE="1";
-    public static final String CHEMICAL_TYPE="2";
-
-
-    static final List<Map<Integer,String>> LIST =new ArrayList<>();
-
-    static {
-        Map<Integer,String> map;
-        map =new HashMap<>(1);
-        map.put(0, "全部");
-        LIST.add(map);
-        map =new HashMap<>(1);
-        map.put(1,"气瓶");
-        LIST.add(map);
-        map =new HashMap<>(1);
-        map.put(2,"化学品");
-        LIST.add(map);
-    }
-
-    public static List<Map<Integer,String>> getConfig(){
-        return LIST;
-    }
-}

+ 0 - 67
zd-modules/zd-netty/src/main/java/com/zd/netty/controller/FridDeviceController.java

@@ -1,67 +0,0 @@
-package com.zd.netty.controller;
-
-import com.zd.common.core.domain.R;
-import com.zd.netty.constant.RfidConstants;
-import com.zd.netty.service.IFridService;
-import com.zd.system.api.laboratory.domain.RemoteLabHardware;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.*;
-
-import javax.annotation.Resource;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Administrator
- */
-@Api(tags = {"FRID设备控制器"})
-@RestController
-@RequestMapping("/frid")
-public class FridDeviceController {
-
-    @Resource
-    private IFridService service;
-
-    /**
-     * 启动FRID扫描监控
-     *         Session.S0 高频循环返回在辐射区域的数据,距离越近频次越高
-     *         Session.S1 次高频循环返回在辐射区域数据,距离越近频次越高
-     *         Session.S2 在辐射范围内重复出现或停止不动的有且仅返回一次数据,当设备离开辐射区域后重置缓存记录,根据厂商提供的文档和本人结合业务应用实际测试,推荐使用此session
-     *         Session.S3 这个暂时没搞懂,选择此session的时候在没有标签在辐射区域会报错,不知道是因为识别设备不够四个还是其他问题,待确定
-     */
-    @ApiOperation("信道启动FRID扫描监控")
-    @PostMapping("/startMonitorChannels")
-    public R<Boolean> startMonitorChannels(@RequestBody RemoteLabHardware hardware) {
-        service.start(hardware);
-        return R.ok();
-    }
-
-    /**
-     * 断开设备连接
-     */
-    @ApiOperation("断开设备连接")
-    @PostMapping("/disconnect")
-    public R<Boolean> disconnect(@RequestBody RemoteLabHardware hardware) {
-        service.stop(hardware);
-        return R.ok();
-    }
-
-    /**
-     * 开启设备警报
-     */
-    @ApiOperation("开启设备警报")
-    @PostMapping("/alarm")
-    public R<Boolean> alarm(@RequestBody RemoteLabHardware hardware) {
-        return R.ok(service.alarm(hardware));
-    }
-
-    /**
-     * 开启设备警报
-     */
-    @ApiOperation("获取RFID配置")
-    @GetMapping("/config")
-    public R<List<Map<Integer,String>>> config() {
-        return R.ok( RfidConstants.getConfig());
-    }
-}

+ 0 - 68
zd-modules/zd-netty/src/main/java/com/zd/netty/enums/ManufacturerTypeEnum.java

@@ -1,68 +0,0 @@
-package com.zd.netty.enums;
-
-import com.zd.netty.sdk.DeJuRFIDClientImpl;
-import com.zd.netty.sdk.DeJuRFIDServerImpl;
-import com.zd.netty.sdk.WuYuanRFIDServiceImpl;
-import com.zd.netty.service.IService;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-/**
- * @author Administrator
- */
-
-@Getter
-@AllArgsConstructor
-public enum ManufacturerTypeEnum {
-
-    /**
-     * 枚举常量
-     */
-    WU_WEI(1,"无源", WuYuanRFIDServiceImpl.class),
-    DE_JU(2,"惠州德聚服务端", DeJuRFIDServerImpl.class),
-    DE_JU2(3,"惠州德聚客户端", DeJuRFIDClientImpl.class);
-
-    /**
-     * 字典码
-     */
-    private final Integer code;
-    /**
-     * 供应厂商名称
-     */
-    private final String name;
-
-    /**
-     * 接口实现对象
-     */
-    private final Class<? extends IService> service;
-
-    /**
-     * 根据类型返回具体的SubjectType
-     *
-     * @param value value
-     * @return SubjectType
-     */
-    public static ManufacturerTypeEnum matchByValue(Integer value) {
-        for (ManufacturerTypeEnum item : ManufacturerTypeEnum.values()) {
-            if (item.code.equals(value)) {
-                return item;
-            }
-        }
-        return WU_WEI;
-    }
-
-    /**
-     * 根据描述返回具体的SubjectType
-     *
-     * @param name name
-     * @return SubjectType
-     */
-    public static ManufacturerTypeEnum matchByName(String name) {
-        for (ManufacturerTypeEnum item : ManufacturerTypeEnum.values()) {
-            if (item.name.equals(name)) {
-                return item;
-            }
-        }
-        return WU_WEI;
-    }
-}

+ 0 - 107
zd-modules/zd-netty/src/main/java/com/zd/netty/handler/SocketHandler.java

@@ -1,107 +0,0 @@
-package com.zd.netty.handler;
-
-import com.zd.common.core.utils.SpringUtils;
-import com.zd.common.core.utils.StringUtils;
-import com.zd.common.redis.service.RedisService;
-import io.netty.channel.Channel;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
-import io.netty.channel.group.ChannelGroup;
-import io.netty.channel.group.DefaultChannelGroup;
-import io.netty.util.concurrent.GlobalEventExecutor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Socket拦截器,用于处理客户端的行为
- *
- * @author dgs
- **/
-public class SocketHandler extends ChannelInboundHandlerAdapter {
-    protected static final ChannelGroup clients = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
-
-    private static final Logger log = LoggerFactory.getLogger(SocketHandler.class);
-
-    private static ConcurrentHashMap<String, ChannelHandlerContext> map = new ConcurrentHashMap<>();
-
-    private static final String RFID_CODE="RFID:";
-
-    /**
-     * 读取到客户端发来的消息
-     *
-     * @param ctx ChannelHandlerContext
-     * @param msg msg
-     */
-    @Override
-    public void channelRead(ChannelHandlerContext ctx, Object msg) {
-        byte[] data = (byte[]) msg;
-        String str=byte2Hex(data);
-        if(StringUtils.isEmpty(str)){
-             return;
-        }
-        String upperCase=str.toUpperCase();
-        log.info("转换后消息:{}",upperCase);
-        upperCase=upperCase.substring(8,32);
-        log.info("截取后:{}",upperCase);
-        RedisService redisService = SpringUtils.getBean(RedisService.class);
-        String t= redisService.getCacheObject(RFID_CODE+upperCase);
-        if(StringUtils.isNotNull(t)){
-            return;
-        }
-        redisService.setCacheObject(RFID_CODE+upperCase,upperCase,5L, TimeUnit.MINUTES);
-        log.info("需要存入数据");
-        synchronized (this){
-            // 根据实际业务应用实现下方接口,进行业务操作,可根据type多方实现,多方发送接收到的编码
-            // TODO document why this method is empty
-
-//            ISendService sendService = SpringUtils.getBean(ISendService.class);
-//            sendService.send(upperCase,0);
-        }
-    }
-
-    /**
-        * 将byte转为16进制
-        * @param bytes
-        * @return
-        */
-    public static String byte2Hex(byte[] bytes){
-        StringBuilder builder = new StringBuilder();
-        String temp;
-        for (byte aByte : bytes) {
-            temp = Integer.toHexString(aByte & 0xFF);
-            if (temp.length() == 1) {
-                //1得到一位的进行补0操作
-                builder.append("0");
-            }
-            builder.append(temp);
-        }
-        return builder.toString();
-    }
-
-    @Override
-    public void handlerAdded(ChannelHandlerContext ctx) {
-        Channel channel = ctx.channel();
-        String s = channel.id().asShortText();
-        log.info("新的客户端链接:{}" , s);
-        clients.add(channel);
-        String uuid = ctx.channel().id().asLongText();
-        map.put(uuid, ctx);
-    }
-
-    @Override
-    public void handlerRemoved(ChannelHandlerContext ctx) {
-        clients.remove(ctx.channel());
-        String uuid = ctx.channel().id().asLongText();
-        map.remove(uuid);
-    }
-
-    @Override
-    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause){
-        cause.printStackTrace();
-        ctx.channel().close();
-        clients.remove(ctx.channel());
-    }
-}

+ 0 - 59
zd-modules/zd-netty/src/main/java/com/zd/netty/init/NettyStartListener.java

@@ -1,59 +0,0 @@
-package com.zd.netty.init;
-
-import com.zd.common.core.constant.HttpStatus;
-import com.zd.common.core.domain.R;
-import com.zd.netty.service.IFridService;
-import com.zd.system.api.laboratory.RemoteLaboratoryService;
-import com.zd.system.api.laboratory.domain.RemoteLabHardware;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.boot.ApplicationArguments;
-import org.springframework.boot.ApplicationRunner;
-import org.springframework.stereotype.Component;
-import org.springframework.util.StringUtils;
-
-import javax.annotation.Resource;
-import java.util.List;
-
-/**
- * 监听Spring容器启动完成,完成后启动Netty服务器
- *
- * @author dgs
- **/
-@Component
-@Slf4j
-public class NettyStartListener implements ApplicationRunner {
-    @Resource
-    private IFridService fridService;
-    @Resource
-    private RemoteLaboratoryService laboratoryService;
-    @Resource
-    private SocketServer socketServer;
-
-
-    @Override
-    public void run(ApplicationArguments args) {
-        R<List<RemoteLabHardware>> listStart = laboratoryService.listStart();
-        synchronized (this){
-            while (listStart.getCode() != HttpStatus.SUCCESS) {
-                try {
-                    log.error("com.zd.system.api.laboratory.RemoteLaboratoryService:远程接口调用异常");
-                    //防止laboratory模块未启动完成,故每30秒执行一次程序,直到接口可以正常访问
-                    this.wait(30 * 1000L);
-                    NettyStartListener.this.run(args);
-                } catch (InterruptedException e) {
-                    Thread.currentThread().interrupt();
-                }
-            }
-            List<RemoteLabHardware> unitVos = listStart.getData();
-            if (!unitVos.isEmpty()) {
-                try {
-                    unitVos.stream()
-                            .filter(u -> StringUtils.hasLength(u.getIpAddress()))
-                            .forEach(u -> fridService.start(u));
-                } catch (Exception e) {
-                    e.fillInStackTrace();
-                }
-            }
-        }
-    }
-}

+ 0 - 29
zd-modules/zd-netty/src/main/java/com/zd/netty/init/SocketInitializer.java

@@ -1,29 +0,0 @@
-package com.zd.netty.init;
-
-import com.zd.netty.handler.SocketHandler;
-import io.netty.channel.ChannelInitializer;
-import io.netty.channel.ChannelPipeline;
-import io.netty.channel.socket.SocketChannel;
-import io.netty.handler.codec.FixedLengthFrameDecoder;
-import io.netty.handler.codec.bytes.ByteArrayDecoder;
-import io.netty.handler.codec.bytes.ByteArrayEncoder;
-import org.springframework.stereotype.Component;
-
-/**
- * Socket 初始化器
- * @author dgs
- **/
-@Component
-public class SocketInitializer extends ChannelInitializer<SocketChannel> {
-    @Override
-    protected void initChannel(SocketChannel socketChannel) {
-        ChannelPipeline pipeline = socketChannel.pipeline();
-        // 将FixedLengthFrameDecoder添加到pipeline中,定长18
-        pipeline.addLast(new FixedLengthFrameDecoder(18));
-        // 添加对byte数组的编解码,netty提供了很多编解码器,你们可以根据需要选择
-        pipeline.addLast(new ByteArrayDecoder());
-        pipeline.addLast(new ByteArrayEncoder());
-        // 最后添加上自己的处理器
-        pipeline.addLast(new SocketHandler());
-    }
-}

+ 0 - 63
zd-modules/zd-netty/src/main/java/com/zd/netty/init/SocketServer.java

@@ -1,63 +0,0 @@
-package com.zd.netty.init;
-
-import io.netty.bootstrap.ServerBootstrap;
-import io.netty.channel.nio.NioEventLoopGroup;
-import io.netty.channel.socket.nio.NioServerSocketChannel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-
-/**
- * @author Gjing
- **/
-@Component
-public class SocketServer {
-
-    private static final Logger log = LoggerFactory.getLogger(SocketServer.class);
-
-    @Resource
-    private SocketInitializer socketInitializer;
-
-    private ServerBootstrap serverBootstrap;
-
-    public ServerBootstrap getServerBootstrap() {
-        return serverBootstrap;
-    }
-
-    /**
-     * netty服务监听端口
-     */
-    @Value("${netty.port:6453}")
-    private int port;
-    /**
-     * 主线程组数量
-     */
-    @Value("${netty.bossThread:1}")
-    private int bossThread;
-
-    /**
-     * 启动netty服务器
-     */
-    public void start() {
-        this.init();
-        this.serverBootstrap.bind(this.port);
-        log.info("================================>Netty started on port: {} (TCP) with boss thread {}", this.port, this.bossThread);
-    }
-
-    /**
-     * 初始化netty配置
-     */
-    private void init() {
-        // 创建两个线程组,bossGroup为接收请求的线程组,一般1-2个就行
-        NioEventLoopGroup bossGroup = new NioEventLoopGroup(this.bossThread);
-        // 实际工作的线程组
-        NioEventLoopGroup workerGroup = new NioEventLoopGroup();
-        this.serverBootstrap = new ServerBootstrap();
-        this.serverBootstrap.group(bossGroup, workerGroup) // 两个线程组加入进来
-                .channel(NioServerSocketChannel.class)  // 配置为nio类型
-                .childHandler(this.socketInitializer); // 加入自己的初始化器
-    }
-}

+ 0 - 172
zd-modules/zd-netty/src/main/java/com/zd/netty/sdk/DeJuRFIDClientImpl.java

@@ -1,172 +0,0 @@
-package com.zd.netty.sdk;
-
-import com.gg.reader.api.dal.GClient;
-import com.gg.reader.api.dal.GServer;
-import com.gg.reader.api.protocol.gx.MsgBaseInventoryEpc;
-import com.gg.reader.api.protocol.gx.MsgBaseSetBaseband;
-import com.gg.reader.api.protocol.gx.MsgBaseSetPower;
-import com.zd.common.core.enums.HardwareOperate;
-import com.zd.common.core.exception.ServiceException;
-import com.zd.common.core.utils.SpringUtils;
-import com.zd.netty.service.IService;
-import com.zd.system.api.laboratory.RemoteLaboratoryService;
-import com.zd.system.api.laboratory.domain.RemoteLabHardware;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-
-/**
- * @author Administrator
- */
-@Slf4j
-@Service
-public class DeJuRFIDClientImpl implements IService {
-
-    private final Map<String, GServer> serverMap = new ConcurrentHashMap<>();
-    @Resource
-    private RemoteLaboratoryService remoteLaboratoryService;
-    @Resource
-    private DeJuRFIDServerImpl service;
-
-    @Resource
-    private RedisTemplate<String,RemoteLabHardware> redisTemplate;
-
-    private static final ScheduledExecutorService scheduledExecutorService = SpringUtils.getBean("scheduledExecutorService");
-
-    @Override
-    public void start(RemoteLabHardware hardware) {
-        String ipAddress = hardware.getIpAddress();
-        GServer server;
-        if (serverMap.containsKey(ipAddress)) {
-            server = serverMap.get(ipAddress);
-            boolean listen = server.isListend();
-            if (listen) {
-                server.close();
-            }
-        } else {
-            server = new GServer();
-            serverMap.put(ipAddress, server);
-        }
-        String[] ip = ipAddress.split(":");
-        int port=8160;
-        if (ip.length>1){
-            port= Integer.parseInt(ip[1]);
-        }
-        if (server.open(port)) {
-            log.info("开始监听:"+ipAddress);
-            subscribeServerHandler(server, hardware);
-        } else {
-            log.info("监听失败:"+ipAddress);
-            throw new ServiceException("监听失败,请稍后进行设备重连。。。");
-        }
-    }
-
-    @Override
-    public void disconnect(RemoteLabHardware hardware) {
-        String ipAddress = hardware.getIpAddress();
-        if (serverMap.containsKey(ipAddress)) {
-            GServer server = serverMap.get(ipAddress);
-            service.close(hardware);
-            server.close();
-            serverMap.remove(ipAddress);
-            log.info(ipAddress + "---监听结束");
-        }
-    }
-
-    @Override
-    public boolean alarm(RemoteLabHardware hardware) {
-        return service.alarm(hardware);
-    }
-
-    /**
-     * 订阅监听上报
-     *
-     * @param server   服务对象
-     * @param hardware 设备对象
-     */
-    public void subscribeServerHandler(GServer server, RemoteLabHardware hardware) {
-        server.onGClientConnected = (client, serialNumber) -> {
-            redisTemplate.opsForValue().set(client.getSerialNumber(),hardware);
-            client.setSendHeartBeat(true);//开启心跳检测Tcp连接状态
-            subscribeTcpHandler(client);//订阅Tcp断连上报
-            client.setPrint(true);
-            reSet(hardware, client);
-            service.subscribeHandler(client, hardware);
-            subscribeHandlerTagEpcOver(client);
-            remoteLaboratoryService.update(HardwareOperate.OPEN, hardware.getIpAddress());
-            log.info(client.getName() + "---监听成功");
-        };
-    }
-
-    /**
-     * 订阅6c标签信息上报停止事件
-     *
-     * @param client   客户端
-     */
-    public void subscribeHandlerTagEpcOver(GClient client) {
-        client.onTagEpcOver= (s, logBaseEpcInfo) -> {
-            log.info("HandlerTagEpcOver:"+s);
-            RemoteLabHardware labHardware = redisTemplate.opsForValue().get(client.getSerialNumber());
-            if (labHardware==null){
-                return;
-            }
-            disconnect(labHardware);
-            start(labHardware);
-        };
-    }
-
-    private void reSet(RemoteLabHardware hardware, GClient client) {
-        MsgBaseSetBaseband msgBaseSetBaseband = DeJuRFIDServerImpl.setSession(hardware, client);
-        if (0 != msgBaseSetBaseband.getRtCode()) {
-            log.error("Session configuration error.");
-            reConnect(hardware, client);
-            return;
-        }
-        MsgBaseSetPower msgBaseSetPower = DeJuRFIDServerImpl.setPower(hardware, client);
-        if (0 != msgBaseSetPower.getRtCode()) {
-            log.error("Power configuration error.");
-            reConnect(hardware, client);
-            return;
-        }
-        MsgBaseInventoryEpc msgBaseInventoryEpc = DeJuRFIDServerImpl.setInventory(hardware, client);
-        if (0 != msgBaseInventoryEpc.getRtCode()) {
-            log.error("Inventory epc error.");
-            reConnect(hardware, client);
-            return;
-        }
-        boolean changeGpi = DeJuRFIDServerImpl.setGpi(client);
-        if (!changeGpi){
-            reConnect(hardware,client);
-        }
-    }
-
-    private void reConnect(RemoteLabHardware hardware, GClient client) {
-        DeJuRFIDServerImpl.stopMsg(client);
-        reSet(hardware, client);
-    }
-
-    /**
-     * 订阅TCP断开连接上报
-     *
-     * @param client   客户端对象
-     */
-    private void subscribeTcpHandler(GClient client) {
-        RemoteLabHardware labHardware = redisTemplate.opsForValue().get(client.getSerialNumber());
-        client.onDisconnected = s -> {
-            log.info("连接" + s + "已断开");
-            if (labHardware!=null){
-                disconnect(labHardware);
-                remoteLaboratoryService.update(HardwareOperate.CLOSE, labHardware.getIpAddress());
-                log.info("连接" + s + "重连中。。。");
-                scheduledExecutorService.schedule(()-> start(labHardware),30, TimeUnit.SECONDS);
-            }
-        };
-    }
-}

+ 0 - 390
zd-modules/zd-netty/src/main/java/com/zd/netty/sdk/DeJuRFIDServerImpl.java

@@ -1,390 +0,0 @@
-package com.zd.netty.sdk;
-
-import com.gg.reader.api.dal.GClient;
-import com.gg.reader.api.protocol.gx.*;
-import com.zd.common.core.enums.HardwareOperate;
-import com.zd.common.core.exception.ServiceException;
-import com.zd.common.core.utils.SpringUtils;
-import com.zd.netty.service.ISendService;
-import com.zd.netty.service.IService;
-import com.zd.system.api.domain.InventoryTag;
-import com.zd.system.api.laboratory.RemoteLaboratoryService;
-import com.zd.system.api.laboratory.domain.RemoteLabHardware;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.BeanUtils;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.stereotype.Service;
-import org.springframework.util.StringUtils;
-
-import javax.annotation.Resource;
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-/**
- * @author Administrator
- */
-@Slf4j
-@Service
-public class DeJuRFIDServerImpl implements IService {
-
-    private static final ISendService sendService = SpringUtils.getBean("sendService");
-
-    private final Map<String, GClient> clientMap = new ConcurrentHashMap<>();
-
-    private final Map<String, Boolean> alarmMap = new ConcurrentHashMap<>();
-
-    private final Map<String, Integer> stopMap = new ConcurrentHashMap<>();
-    private static final Integer TIME_OUT = 2000;
-
-    private static final Integer MAX_RETRY = 3;
-
-    private static final ScheduledExecutorService scheduledExecutorService = SpringUtils.getBean("scheduledExecutorService");
-
-    @Resource
-    private RedisTemplate<String, RemoteLabHardware> redisTemplate;
-
-    @Resource
-    private RemoteLaboratoryService remoteLaboratoryService;
-
-    @Override
-    public void start(RemoteLabHardware hardware) {
-        open(hardware);
-    }
-
-    private void open(RemoteLabHardware hardware) {
-        GClient client;
-        String ipAddress = hardware.getIpAddress();
-        if (clientMap.containsKey(ipAddress)) {
-            client = clientMap.get(ipAddress);
-        } else {
-            client = new GClient();
-            clientMap.put(ipAddress, client);
-        }
-        String[] ip = ipAddress.split(":");
-        int port=8160;
-        if (ip.length==1){
-            ipAddress+=":"+port;
-        }
-        if (client.openTcp(ipAddress, TIME_OUT)) {
-            stopMsg(client);
-            boolean change = setGpi(client);
-            if (!change){
-                log.info("GPI epc error.");
-                close(hardware);
-                open(hardware);
-                return;
-            }
-            MsgBaseSetBaseband msgBaseSetBaseband = setSession(hardware, client);
-            if (0 != msgBaseSetBaseband.getRtCode()) {
-                log.info("Session epc error.");
-                close(hardware);
-                open(hardware);
-                return;
-            }
-            // 功率配置, 将4个天线功率都设置为30dBm.
-            MsgBaseSetPower msgBaseSetPower = setPower(hardware, client);
-            if (0 != msgBaseSetPower.getRtCode()) {
-                log.info("Power configuration error.");
-                close(hardware);
-                open(hardware);
-                return;
-            }
-            //天线读卡, 读取EPC数据区以及TID数据区
-            MsgBaseInventoryEpc msgBaseInventoryEpc = setInventory(hardware, client);
-            if (0 != msgBaseInventoryEpc.getRtCode()) {
-                log.info("Inventory epc error.");
-                close(hardware);
-                open(hardware);
-                return;
-            }
-
-            // 订阅标签上报事件
-            subscribeHandler(client, hardware);
-            subscribeHandlerTagEpcOver(client,hardware);
-            subscribeTcpHandler(client);
-            String serialNumber = client.getSerialNumber();
-            if (StringUtils.hasLength(serialNumber)){
-                redisTemplate.opsForValue().set(serialNumber, hardware);
-            }
-        } else {
-            throw new ServiceException("Connect failure.");
-        }
-    }
-
-    /**
-     * 订阅TCP断开连接上报
-     *
-     * @param client   客户端对象
-     */
-    public void subscribeTcpHandler(GClient client) {
-        RemoteLabHardware labHardware = redisTemplate.opsForValue().get(client.getSerialNumber());
-        client.onDisconnected = s -> {
-            log.info("连接" + s + "已断开");
-            if (labHardware!=null){
-                client.close();
-                remoteLaboratoryService.update(HardwareOperate.CLOSE, labHardware.getIpAddress());
-                log.info("连接" + s + "重连中。。。");
-                start(labHardware);
-            }
-        };
-    }
-
-    public static MsgBaseInventoryEpc setInventory(RemoteLabHardware hardware, GClient client) {
-        MsgBaseInventoryEpc msgBaseInventoryEpc = new MsgBaseInventoryEpc();
-        switch (hardware.getChannels()) {
-            case 4:
-                msgBaseInventoryEpc.setAntennaEnable(EnumG.AntennaNo_1 | EnumG.AntennaNo_2 | EnumG.AntennaNo_3 | EnumG.AntennaNo_4);
-                break;
-            case 8:
-                msgBaseInventoryEpc.setAntennaEnable(EnumG.AntennaNo_1 | EnumG.AntennaNo_2 | EnumG.AntennaNo_3 | EnumG.AntennaNo_4 | EnumG.AntennaNo_5 | EnumG.AntennaNo_6 | EnumG.AntennaNo_7 | EnumG.AntennaNo_8);
-                break;
-            case 16:
-                msgBaseInventoryEpc.setAntennaEnable(EnumG.AntennaNo_1 | EnumG.AntennaNo_2 | EnumG.AntennaNo_3 | EnumG.AntennaNo_4 | EnumG.AntennaNo_5 | EnumG.AntennaNo_6 | EnumG.AntennaNo_7 | EnumG.AntennaNo_8 | EnumG.AntennaNo_9 | EnumG.AntennaNo_10 | EnumG.AntennaNo_11 | EnumG.AntennaNo_12 | EnumG.AntennaNo_13 | EnumG.AntennaNo_14 | EnumG.AntennaNo_15 | EnumG.AntennaNo_16);
-                break;
-            case 1:
-            default:
-                msgBaseInventoryEpc.setAntennaEnable(EnumG.AntennaNo_1);
-        }
-        msgBaseInventoryEpc.setInventoryMode(EnumG.InventoryMode_Inventory);
-
-        client.sendSynMsg(msgBaseInventoryEpc);
-        if (0 == msgBaseInventoryEpc.getRtCode()) {
-            log.info("Inventory epc success.");
-        }
-        return msgBaseInventoryEpc;
-    }
-
-    public static MsgBaseSetPower setPower(RemoteLabHardware hardware, GClient client) {
-        String uniformPower = hardware.getUniformPower();
-        MsgBaseGetPower msgBaseGetPower = new MsgBaseGetPower();
-        client.sendSynMsg(msgBaseGetPower);
-        MsgBaseSetPower msgBaseSetPower = new MsgBaseSetPower();
-        if (0 == msgBaseGetPower.getRtCode()) {
-            sendPower(hardware, client, uniformPower, msgBaseGetPower, msgBaseSetPower);
-        } else {
-            log.info("==============获取输出功率失败==============");
-        }
-        return msgBaseSetPower;
-    }
-
-    private static void sendPower(RemoteLabHardware hardware, GClient client, String uniformPower, MsgBaseGetPower msgBaseGetPower, MsgBaseSetPower msgBaseSetPower) {
-        if (StringUtils.hasLength(uniformPower)) {
-            editAndSendPower(hardware, client, uniformPower, msgBaseSetPower, msgBaseGetPower);
-        } else {
-            msgBaseSetPower.setRtCode((byte) 0);
-        }
-    }
-
-    private static void editAndSendPower(RemoteLabHardware hardware, GClient client, String uniformPower, MsgBaseSetPower msgBaseSetPower, MsgBaseGetPower msgBaseGetPower) {
-        Hashtable<Integer, Integer> dicPower = msgBaseGetPower.getDicPower();
-        Integer channels = hardware.getChannels();
-        String[] uniformPowers = uniformPower.split(",");
-        for (int i = 1; i <= channels; i++) {
-            Integer power = dicPower.get(i);
-            String tempUniformPower = uniformPowers[i - 1];
-            String[] tempUniformPowers = tempUniformPower.split(":");
-            String temp = tempUniformPowers[0];
-            if (power == null || !Objects.equals(power, Integer.valueOf(temp))) {
-                dicPower.put(i, Integer.valueOf(temp));
-            }
-        }
-        msgBaseSetPower.setDicPower(dicPower);
-        client.sendSynMsg(msgBaseSetPower);
-        if (0 == msgBaseSetPower.getRtCode()) {
-            log.info("Power epc success.");
-        } else {
-            log.info("==============设置输出功率失败==============");
-        }
-    }
-
-    public static MsgBaseSetBaseband setSession(RemoteLabHardware hardware, GClient client) {
-        MsgBaseGetBaseband msgBaseGetBaseband = new MsgBaseGetBaseband();
-        MsgBaseSetBaseband msgBaseSetBaseband = new MsgBaseSetBaseband();
-        client.sendSynMsg(msgBaseGetBaseband);
-        if (0 == msgBaseGetBaseband.getRtCode()) {
-            int session = msgBaseGetBaseband.getSession();
-            log.info("Session index is:==============》{}", session);
-            if (session != hardware.getSessionIndex()) {
-                msgBaseSetBaseband.setSession(hardware.getSessionIndex());
-                client.sendSynMsg(msgBaseSetBaseband);
-                if (0 != msgBaseSetBaseband.getRtCode()) {
-                    log.info("Session epc error.");
-                } else {
-                    log.info("Session epc success.");
-                }
-            } else {
-                msgBaseSetBaseband.setRtCode((byte) 0);
-            }
-        }
-        return msgBaseSetBaseband;
-    }
-
-    public static boolean setGpi(GClient client) {
-        MsgAppGetGpiState gpiState=new MsgAppGetGpiState();
-        client.sendSynMsg(gpiState);
-        HashMap<Integer, Integer> hashMap = gpiState.getHpGpiState();
-        boolean change=true;
-        for (Map.Entry<Integer,Integer> entry:hashMap.entrySet()) {
-            Integer k = entry.getKey();
-            MsgAppGetGpiTrigger getGpiTrigger = new MsgAppGetGpiTrigger();
-            getGpiTrigger.setGpiPort(k-1);
-            client.sendSynMsg(getGpiTrigger);
-            if (getGpiTrigger.getRtCode()==0){
-                int triggerOver = getGpiTrigger.getTriggerOver();
-                int triggerStart = getGpiTrigger.getTriggerStart();
-                if (triggerStart!=0|| triggerOver!=0){
-                    MsgAppSetGpiTrigger gpiTrigger = new MsgAppSetGpiTrigger();
-                    gpiTrigger.setGpiPort(getGpiTrigger.getGpiPort());
-                    gpiTrigger.setTriggerOver(0);
-                    gpiTrigger.setTriggerStart(0);
-                    client.sendSynMsg(gpiTrigger);
-                    if (0 != gpiTrigger.getRtCode()) {
-                        log.info("GPI epc error.");
-                        change=false;
-                    } else {
-                        log.info("GPI epc success.");
-                    }
-                }
-            }
-        }
-        return change;
-    }
-
-    @Override
-    public void disconnect(RemoteLabHardware hardware) {
-        close(hardware);
-    }
-
-    @Override
-    public boolean alarm(RemoteLabHardware hardware) {
-        //灯带设置
-        String ipAddress = hardware.getIpAddress();
-        if (clientMap.containsKey(ipAddress)) {
-            GClient client = clientMap.get(ipAddress);
-            boolean alarm = false;
-            synchronized (this.alarmMap){
-                if (alarmMap.containsKey(ipAddress)) {
-                    alarm = alarmMap.get(ipAddress);
-                }
-                log.info("报警状态:==============》{},设备IP:{}", alarm, ipAddress);
-                if (!alarm) {
-                    alarmMap.putIfAbsent(ipAddress,true);
-                    return changeGpo(ipAddress, 1, client, 10);
-                }
-            }
-        }
-        return false;
-    }
-
-    public void close(RemoteLabHardware hardware) {
-        String ipAddress = hardware.getIpAddress();
-        if (clientMap.containsKey(ipAddress)) {
-            GClient client = clientMap.get(ipAddress);
-            changeGpo(ipAddress, 0, client, 0);
-            stopMsg(client);
-            log.error("client.close()");
-            client.close();
-            clientMap.remove(ipAddress);
-        }
-    }
-
-    public static void stopMsg(GClient client) {
-        MsgBaseStop msg = new MsgBaseStop();
-        // 停止读卡,空闲态
-        client.sendSynMsg(msg);
-        String result = msg.getRtCode() == 0 ? "成功" : "失败";
-        log.info("客户端停止读卡{}", result);
-    }
-
-    private boolean changeGpo(String ipAddress, int state, GClient client, int delayTime) {
-        MsgAppSetGpo msgAppSetGpo = new MsgAppSetGpo();
-        msgAppSetGpo.setGpo1(state);
-        msgAppSetGpo.setGpo2(state);
-        msgAppSetGpo.setGpo3(state);
-        msgAppSetGpo.setGpo4(state);
-        client.sendSynMsg(msgAppSetGpo);
-        String status = state == 1 ? "start" : "stop";
-        if (0 == msgAppSetGpo.getRtCode()) {
-            log.info("============》灯带{}成功.", status);
-            if (state == 1) {
-                stopGpo(ipAddress, client, delayTime);
-            } else {
-                alarmMap.remove(ipAddress);
-                stopMap.remove(ipAddress);
-            }
-            return true;
-        } else {
-            log.info("Gpo epc {} error.", status);
-            if (stopMap.containsKey(ipAddress)){
-                stopMap.put(ipAddress,stopMap.get(ipAddress)+1);
-            }else {
-                stopMap.put(ipAddress,1);
-            }
-            if (stopMap.get(ipAddress) <= MAX_RETRY) {
-                stopGpo(ipAddress, client, delayTime);
-            }
-            return false;
-        }
-    }
-
-    public void stopGpo(String ipAddress, GClient client, int delayTime) {
-        scheduledExecutorService.schedule(new TimerTask() {
-            @Override
-            public void run() {
-                changeGpo(ipAddress, 0, client, 0);
-            }
-        }, delayTime, TimeUnit.SECONDS);
-    }
-
-    /**
-     * 订阅6c标签信息上报
-     *
-     * @param client   客户端
-     * @param hardware 设备数据
-     */
-    public void subscribeHandler(GClient client, RemoteLabHardware hardware) {
-        String ipAddress = hardware.getIpAddress();
-        clientMap.computeIfAbsent(ipAddress, f -> client);
-        String serialNumber = client.getSerialNumber();
-        client.onTagEpcLog = (s, logBaseEpcInfo) -> {
-            if (logBaseEpcInfo.getResult() == 0) {
-                int antId = logBaseEpcInfo.getAntId();
-                String epc = logBaseEpcInfo.getEpc();
-                String key=epc+antId;
-                if (Boolean.FALSE.equals(redisTemplate.hasKey(key))){
-                    log.info("===========》{},index: {}", epc, antId);
-                    redisTemplate.opsForValue().set(key,hardware,30,TimeUnit.SECONDS);
-                    scheduledExecutorService.execute(()->{
-                        InventoryTag tag = new InventoryTag();
-                        BeanUtils.copyProperties(logBaseEpcInfo, tag);
-                        String readerSerialNumber = logBaseEpcInfo.getReaderSerialNumber();
-                        log.info("===========》读取器设备编码:{}", readerSerialNumber);
-                        if (StringUtils.hasLength(serialNumber)){
-                            tag.setSerialNumber(serialNumber);
-                            tag.setRemoteLabHardware(redisTemplate.opsForValue().get(serialNumber));
-                        }else {
-                            tag.setRemoteLabHardware(hardware);
-                        }
-                        sendService.send(tag);
-                    });
-                }
-            }
-        };
-    }
-
-    /**
-     * 订阅6c标签信息上报停止事件
-     *
-     * @param client   客户端
-     * @param hardware 设备数据
-     */
-    public void subscribeHandlerTagEpcOver(GClient client, RemoteLabHardware hardware) {
-        client.onTagEpcOver= (s, logBaseEpcInfo) -> {
-            log.info("HandlerTagEpcOver:"+s);
-            close(hardware);
-            open(hardware);
-        };
-    }
-}

+ 0 - 249
zd-modules/zd-netty/src/main/java/com/zd/netty/sdk/WuYuanRFIDServiceImpl.java

@@ -1,249 +0,0 @@
-package com.zd.netty.sdk;
-
-import com.payne.connect.net.NetworkHandle;
-import com.payne.reader.Reader;
-import com.payne.reader.base.BaseInventory;
-import com.payne.reader.bean.config.AntennaCount;
-import com.payne.reader.bean.config.ProfileId;
-import com.payne.reader.bean.config.Session;
-import com.payne.reader.bean.receive.Failure;
-import com.payne.reader.bean.receive.Success;
-import com.payne.reader.bean.send.*;
-import com.payne.reader.process.ReaderImpl;
-import com.zd.common.core.enums.HardwareOperate;
-import com.zd.common.core.exception.ServiceException;
-import com.zd.netty.base.FridConsumer;
-import com.zd.netty.service.ISendService;
-import com.zd.netty.service.IService;
-import com.zd.system.api.laboratory.RemoteLaboratoryService;
-import com.zd.system.api.laboratory.domain.RemoteLabHardware;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Service;
-import org.springframework.util.StringUtils;
-
-import javax.annotation.Resource;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-@Slf4j
-@Service
-public class WuYuanRFIDServiceImpl implements IService {
-
-    private final Map<String, Reader> readerMap = new ConcurrentHashMap<>();
-    private final Map<String, NetworkHandle> handleMap = new ConcurrentHashMap<>();
-    private static final String MSG = "请先连接设备";
-    private static final String SCANNER_MSG = "服务已断开,请检查连接状态正常后重启程序:";
-    @Resource
-    private FridConsumer fridConsumer;
-    @Resource
-    private ISendService sendService;
-    @Resource
-    private RemoteLaboratoryService laboratoryService;
-
-    @Override
-    public void start(RemoteLabHardware hardware) {
-        String ipAddress = hardware.getIpAddress();
-        if (!StringUtils.hasLength(ipAddress)){
-            return;
-        }
-        Integer channels = hardware.getChannels();
-        channels=channels==null?1:channels;
-        Byte sessionIndex = hardware.getSessionIndex();
-        sessionIndex=sessionIndex==null?0:sessionIndex;
-        if (Boolean.FALSE.equals(deviceStatus(hardware))){
-            connect(hardware);
-            setDevice(hardware);
-        }
-
-        Reader reader;
-        if (readerMap.containsKey(ipAddress)) {
-            reader = readerMap.get(ipAddress);
-        } else {
-            throw new ServiceException(MSG);
-        }
-        if (reader == null || !reader.isConnected()) {
-            throw new ServiceException(MSG);
-        }
-        stopMonitor(hardware);
-        Session session = Session.valueOf(sessionIndex);
-        BaseInventory inventory;
-        switch (channels){
-            case 4:
-                inventory=new FastSwitchFourAntennaInventory.Builder().session(session)
-                        .build();
-                break;
-            case 8:
-                inventory=new FastSwitchEightAntennaInventory.Builder().session(session)
-                        .build();
-                break;
-            case 16:
-                inventory=new FastSwitchSixteenAntennaInventory.Builder().session(session)
-                        .build();
-                break;
-            case 1:
-            default:
-                inventory=new FastSwitchSingleAntennaInventory.Builder().session(session)
-                        .build();
-
-        }
-        log.info("============================>" + session);
-
-        Byte index = sessionIndex;
-        InventoryConfig config = new InventoryConfig.Builder()
-                .setInventory(inventory)
-                .setOnInventoryTagSuccess(fridConsumer)
-                //读取失败
-                .setOnFailure(failure -> errorMsg(failure, index, SCANNER_MSG, hardware))
-                .build();
-        reader.setInventoryConfig(config);
-        //true -- 开启循环调用
-        reader.startInventory(true);
-        laboratoryService.update(HardwareOperate.OPEN,ipAddress);
-    }
-
-    @Override
-    public void disconnect(RemoteLabHardware hardware) {
-        Reader reader = null;
-        String ipAddress = hardware.getIpAddress();
-        stopMonitor(hardware);
-        if (readerMap.containsKey(ipAddress)) {
-            reader = readerMap.get(ipAddress);
-        }
-        if (reader != null && reader.isConnected()) {
-            reader.disconnect();
-        }
-
-        handleMap.remove(ipAddress);
-        readerMap.remove(ipAddress);
-    }
-
-    @Override
-    public boolean alarm(RemoteLabHardware hardware) {
-        // TODO document why this method is empty
-        return false;
-    }
-
-    public Boolean deviceStatus(RemoteLabHardware hardware) {
-        Reader reader = null;
-        String ipAddress = hardware.getIpAddress();
-        if (readerMap.containsKey(ipAddress)) {
-            reader = readerMap.get(ipAddress);
-        }
-        return reader != null && reader.isConnected();
-    }
-
-    public void connect(RemoteLabHardware hardware) {
-        Reader reader = null;
-        String host = hardware.getIpAddress();
-        Integer port = hardware.getPort();
-        if (readerMap.containsKey(host)) {
-            reader = readerMap.get(host);
-        }
-        if (reader != null && reader.isConnected()) {
-            throw new ServiceException("设备已连接");
-        }
-        if (reader == null) {
-            reader = ReaderImpl.create(AntennaCount.FOUR_CHANNELS);
-        }
-        NetworkHandle handle;
-        if (handleMap.containsKey(host)) {
-            handle = handleMap.get(host);
-        } else {
-            handle = new NetworkHandle(host, port);
-            handleMap.put(host, handle);
-        }
-        if (reader.connect(handle)) {
-            reader.getFirmwareVersion(version -> log.info("==========================reader1 version:\t" + version.getVersion()),
-                    failure -> errorMsg(failure, (byte) -1, "版本获取异常:", hardware));
-        } else {
-            throw new ServiceException("读写器连接失败");
-        }
-        if (!readerMap.containsKey(host)) {
-            readerMap.put(host, reader);
-        }
-    }
-
-    public void setDevice(RemoteLabHardware hardware) {
-        Reader reader;
-        String ipAddress = hardware.getIpAddress();
-        int power=33;
-        String uniformPower = hardware.getUniformPower();
-        String index = uniformPower.split(",")[0].split(":")[0];
-        if (StringUtils.hasLength(index)){
-            power= Integer.parseInt(index);
-        }
-        if (readerMap.containsKey(ipAddress)) {
-            reader = readerMap.get(ipAddress);
-        } else {
-            throw new ServiceException(MSG);
-        }
-
-        stopMonitor(hardware);
-        reader.setOutputPowerUniformly(
-                (byte) Integer.parseInt(Integer.toHexString(power)),
-                true,
-                success -> successMsg(success, "设置读写器的射频输出功率"),
-                failure -> errorMsg(failure, (byte) -1, "设置读写器的射频输出功率失败:", hardware));
-
-        reader.setOutputPower(
-                OutputPowerConfig.outputPower(new PowerFourAntenna.Builder().build()),
-                success -> successMsg(success, "设置每个天线的射频输出功率"),
-                failure -> errorMsg(failure, (byte) -1, "设置每个天线的射频输出功率失败:", hardware));
-
-        reader.setFrequencyRegion(
-                new FreqNormal.Builder().build(),
-                success -> successMsg(success, "设置读写器的工作频率范围"),
-                failure -> errorMsg(failure, (byte) -1, "设置读写器的工作频率范围失败:", hardware));
-
-        reader.setRfLinkProfile(
-                ProfileId.Profile1,
-                success -> successMsg(success, "设置射频链路配置"),
-                failure -> errorMsg(failure, (byte) -1, "设置射频链路配置失败:", hardware));
-
-    }
-
-    private void errorMsg(Failure failure, byte index, String msg, RemoteLabHardware hardware) {
-        byte errorCode = failure.getErrorCode();
-        if (errorCode == -34 && msg.equals(SCANNER_MSG) && index != -1) {
-            deviceRestart(hardware);
-        }
-        if (errorCode == -79) {
-            sendService.sendError(msg + "\t" + failure);
-            stopMonitor(hardware);
-            disconnect(hardware);
-            if (index != -1) {
-                deviceRestart(hardware);
-            }
-        }
-    }
-
-    public void deviceRestart(RemoteLabHardware hardware) {
-        connect(hardware);
-        String ipAddress = hardware.getIpAddress();
-        if (readerMap.containsKey(ipAddress)) {
-            Reader reader = readerMap.get(ipAddress);
-            if (reader.isConnected()) {
-                sendService.sendError("重连成功");
-                start(hardware);
-            }
-            return;
-        }
-        throw new ServiceException("设备未连接");
-    }
-
-    public void stopMonitor(RemoteLabHardware hardware) {
-        Reader reader = null;
-        String ipAddress = hardware.getIpAddress();
-        if (readerMap.containsKey(ipAddress)) {
-            reader = readerMap.get(ipAddress);
-        }
-        if (reader != null && reader.isConnected()) {
-            reader.stopInventory();
-        }
-        laboratoryService.update(HardwareOperate.CLOSE,ipAddress);
-    }
-
-    private void successMsg(Success success, String msg) {
-        log.info("=========================={}:\t {}", msg, success.toString());
-    }
-}

+ 0 - 27
zd-modules/zd-netty/src/main/java/com/zd/netty/service/IFridService.java

@@ -1,27 +0,0 @@
-package com.zd.netty.service;
-
-import com.zd.system.api.laboratory.domain.RemoteLabHardware;
-
-/**
- * @author Administrator
- */
-public interface IFridService {
-    /**
-     * 启动RFID扫描器
-     * @param hardware 设备数据
-     */
-    void start(RemoteLabHardware hardware);
-
-    /**
-     * 关闭RFID扫描器
-     * @param hardware  设备数据
-     */
-    void stop(RemoteLabHardware hardware);
-
-    /**
-     * 启动警报
-     * @param hardware 设备数据
-     * @return boolean
-     */
-    boolean alarm(RemoteLabHardware hardware);
-}

+ 0 - 23
zd-modules/zd-netty/src/main/java/com/zd/netty/service/ISendService.java

@@ -1,23 +0,0 @@
-package com.zd.netty.service;
-
-import com.zd.system.api.domain.InventoryTag;
-
-/**
- * @author Administrator
- */
-public interface ISendService {
-
-    /**
-     * 发送读取到的编码
-     *
-     * @param tag    frid数据
-     * @return boolean
-     */
-    boolean send(InventoryTag tag);
-
-    /**
-     * 发送异常信息
-     * @param msg 异常消息
-     */
-    void sendError(String msg);
-}

+ 0 - 29
zd-modules/zd-netty/src/main/java/com/zd/netty/service/IService.java

@@ -1,29 +0,0 @@
-package com.zd.netty.service;
-
-import com.zd.system.api.laboratory.domain.RemoteLabHardware;
-
-/**
- * RFID接口类
- * @author Administrator
- */
-public interface IService {
-
-    /**
-     * 启动RFID读写器
-     * @param hardware 设备数据
-     */
-    void start(RemoteLabHardware hardware);
-
-    /**
-     * 断开RFID读写器
-     * @param hardware 设备数据
-     */
-    void disconnect(RemoteLabHardware hardware);
-
-    /**
-     * 启动警报
-     * @param hardware 设备数据
-     * @return boolean
-     */
-    boolean alarm(RemoteLabHardware hardware);
-}

+ 0 - 58
zd-modules/zd-netty/src/main/java/com/zd/netty/service/impl/FridServiceImpl.java

@@ -1,58 +0,0 @@
-package com.zd.netty.service.impl;
-
-import com.zd.common.core.utils.SpringUtils;
-import com.zd.netty.enums.ManufacturerTypeEnum;
-import com.zd.netty.service.IFridService;
-import com.zd.netty.service.IService;
-import com.zd.system.api.laboratory.domain.RemoteLabHardware;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
-import org.springframework.stereotype.Service;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import static com.zd.common.core.constant.Constants.MAP_INIT_SIZE;
-
-/**
- * @author Administrator
- */
-@Service
-@Slf4j
-public class FridServiceImpl implements IFridService {
-
-    private final ThreadPoolTaskExecutor taskExecutor = SpringUtils.getBean("taskExecutor");
-
-    private final Map<String, Thread> threadMap = new HashMap<>(MAP_INIT_SIZE);
-
-    private IService rfidService(Integer type) {
-        return SpringUtils.getBean(ManufacturerTypeEnum.matchByValue(type).getService());
-    }
-
-    @Override
-    public void start(RemoteLabHardware hardware) {
-        synchronized (this){
-            taskExecutor.execute(() -> {
-                rfidService(hardware.getManufacturerType()).start(hardware);
-                log.info("===================thread name:{}===============", Thread.currentThread().getName());
-                threadMap.computeIfAbsent(hardware.getIpAddress(), f -> Thread.currentThread());
-                log.info("==============>线程数量:{}",threadMap.size());
-            });
-        }
-    }
-
-    @Override
-    public void stop(RemoteLabHardware hardware) {
-        rfidService(hardware.getManufacturerType()).disconnect(hardware);
-        Thread thread = threadMap.get(hardware.getIpAddress());
-        if (thread != null && thread.isAlive()) {
-            thread.interrupt();
-            threadMap.remove(hardware.getIpAddress());
-        }
-    }
-
-    @Override
-    public boolean alarm(RemoteLabHardware hardware) {
-       return rfidService(hardware.getManufacturerType()).alarm(hardware);
-    }
-}

+ 0 - 139
zd-modules/zd-netty/src/main/java/com/zd/netty/service/impl/SendServiceImpl.java

@@ -1,139 +0,0 @@
-package com.zd.netty.service.impl;
-
-import com.zd.bottle.feign.service.RemoteBottleService;
-import com.zd.common.core.constant.HttpStatus;
-import com.zd.common.core.domain.R;
-import com.zd.netty.service.IFridService;
-import com.zd.netty.service.ISendService;
-import com.zd.system.api.airbottle.RemoteAirBottleService;
-import com.zd.system.api.chemical.RemoteStockService;
-import com.zd.system.api.domain.InventoryTag;
-import com.zd.system.api.laboratory.domain.RemoteLabHardware;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.stereotype.Service;
-import org.springframework.util.StringUtils;
-
-import javax.annotation.Resource;
-
-import static com.zd.netty.constant.RfidConstants.*;
-
-/**
- * @author Administrator
- */
-@Slf4j
-@Service(value = "sendService")
-public class SendServiceImpl implements ISendService {
-
-    @Resource
-    private RemoteStockService remoteStockService;
-    @Resource
-    private RemoteAirBottleService bottleService;
-
-    @Resource
-    private RemoteBottleService remoteBottleService;
-
-    @Resource
-    private RedisTemplate<String,RemoteLabHardware> redisTemplate;
-
-    @Override
-    public boolean send(InventoryTag tag) {
-        String serialNumber = tag.getSerialNumber();
-        RemoteLabHardware hardware = tag.getRemoteLabHardware();
-        if (StringUtils.hasLength(serialNumber)){
-            log.info("===============》设备编码:{}",serialNumber);
-            hardware = redisTemplate.opsForValue().get(serialNumber);
-        }
-        if (hardware!=null){
-            log.info("=========ip:{},设备编码:{}=========",hardware.getIpAddress(),serialNumber);
-            int antId = tag.getAntId();
-            String uniformPower = hardware.getUniformPower();
-            String[] uniformPowers = uniformPower.split(",");
-            return handleTag(tag, antId, uniformPowers);
-        }
-        log.info("=========未获取到设备信息=========");
-        return sendTag(tag,null);
-    }
-
-    private boolean handleTag(InventoryTag tag, int antId, String[] uniformPowers) {
-        // 判断有设备配置和触发的天线编码等与配置天线编号
-        if (uniformPowers.length > 0) {
-            String tempUniformPower = uniformPowers[antId - 1];
-            if (StringUtils.hasLength(tempUniformPower)) {
-                String[] tempUniformPowers = tempUniformPower.split(":");
-                if (tempUniformPowers.length > 1) {
-                    String temp = tempUniformPowers[1];
-                    return sendTag(tag, temp);
-                } else {
-                    return sendTag(tag, null);
-                }
-            }
-        }
-        return false;
-    }
-
-    private boolean sendTag(InventoryTag tag, String temp) {
-        if (temp == null) {
-            boolean b = sendBottle(tag);
-            if (b){
-                return true;
-            }
-            return sendStock(tag);
-        }
-        if (ALL_TYPE.equals(temp)) {
-            boolean b = sendBottle(tag);
-            if (b){
-                return true;
-            }
-            return sendStock(tag);
-        }
-        if (BOTTLE_TYPE.equals(temp)) {
-            return sendBottle(tag);
-        }
-        if (CHEMICAL_TYPE.equals(temp)) {
-            return sendStock(tag);
-        }
-        return false;
-    }
-
-    private boolean sendStock(InventoryTag tag) {
-        try {
-            R<Boolean> result = remoteStockService.rfidCheck(tag);
-            log.info("化学品服务调用:" + result.getData());
-            if (result.getCode() == HttpStatus.SUCCESS) {
-                return result.getData();
-            }
-        } catch (Exception e) {
-            log.info("化学品服务异常:" + e.getMessage());
-        }
-        return false;
-    }
-
-    private boolean sendBottle(InventoryTag tag) {
-        R<Boolean> result;
-        try {
-            result = bottleService.remoteAdd(tag);
-            log.info("气瓶服务调用:" + result.getData());
-            if (result.getCode() == HttpStatus.SUCCESS) {
-               return result.getData();
-            }
-        } catch (Exception e) {
-            log.info("气瓶服务异常:" + e.getMessage());
-        }
-        try {
-            result = remoteBottleService.remoteAdd(tag);
-            log.info("气瓶服务调用:" + result.getData());
-            if (result.getCode() == HttpStatus.SUCCESS) {
-                return result.getData();
-            }
-        } catch (Exception e) {
-            log.info("新气瓶服务异常:" + e.getMessage());
-        }
-        return false;
-    }
-
-    @Override
-    public void sendError(String msg) {
-        log.info(msg);
-    }
-}

+ 0 - 78
zd-modules/zd-netty/src/main/java/com/zd/netty/thread/ThreadPoolTaskConfig.java

@@ -1,78 +0,0 @@
-package com.zd.netty.thread;
-
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.concurrent.BasicThreadFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
-
-import java.util.concurrent.*;
-
-/**
- * @author Administrator
- */
-@Configuration
-@Slf4j
-public class ThreadPoolTaskConfig {
-
-    private static final int CORE_POOL_SIZE = 10;
-    private static final int MAX_POOL_SIZE = 100;
-    private static final int KEEP_ALIVE_TIME = 10;
-    private static final int QUEUE_CAPACITY = 200;
-    private static final String THREAD_NAME_PREFIX = "Async-Service-";
-
-    @Bean("taskExecutor")
-    public ThreadPoolTaskExecutor threadPoolTaskExecutor(){
-        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
-        executor.setCorePoolSize(CORE_POOL_SIZE);
-        executor.setMaxPoolSize(MAX_POOL_SIZE);
-        executor.setQueueCapacity(QUEUE_CAPACITY);
-        executor.setKeepAliveSeconds(KEEP_ALIVE_TIME);
-        executor.setThreadNamePrefix(THREAD_NAME_PREFIX);
-
-        // 线程池对拒绝任务的处理策略
-        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
-        // 初始化
-        executor.initialize();
-        return executor;
-    }
-
-    /**
-     * 执行定时任务
-     */
-    @Bean(name = "scheduledExecutorService")
-    public ScheduledExecutorService scheduledExecutorService() {
-        return new ScheduledThreadPoolExecutor(CORE_POOL_SIZE,
-                new BasicThreadFactory.Builder().namingPattern("schedule-pool-%d").daemon(true).build()) {
-            @Override
-            protected void afterExecute(Runnable r, Throwable t) {
-                super.afterExecute(r, t);
-                printException(r, t);
-            }
-        };
-    }
-
-
-    /**
-     * 打印线程异常信息
-     */
-    public static void printException(Runnable r, Throwable t) {
-        if (t == null && r instanceof Future<?>) {
-            try {
-                Future<?> future = (Future<?>) r;
-                if (future.isDone()) {
-                    future.get();
-                }
-            } catch (CancellationException ce) {
-                t = ce;
-            } catch (ExecutionException ee) {
-                t = ee.getCause();
-            } catch (InterruptedException ie) {
-                Thread.currentThread().interrupt();
-            }
-        }
-        if (t != null) {
-            log.error(t.getMessage(), t);
-        }
-    }
-}

+ 0 - 10
zd-modules/zd-netty/src/main/resources/banner.txt

@@ -1,10 +0,0 @@
-Spring Boot Version: ${spring-boot.version}
-Spring Application Name: ${spring.application.name}
-                            _                           _                    
-                           (_)                         | |                   
- _ __  _   _   ___   _   _  _  ______  ___  _   _  ___ | |_   ___  _ __ ___  
-| '__|| | | | / _ \ | | | || ||______|/ __|| | | |/ __|| __| / _ \| '_ ` _ \ 
-| |   | |_| || (_) || |_| || |        \__ \| |_| |\__ \| |_ |  __/| | | | | |
-|_|    \__,_| \___/  \__, ||_|        |___/ \__, ||___/ \__| \___||_| |_| |_|
-                      __/ |                  __/ |                           
-                     |___/                  |___/                            

+ 0 - 29
zd-modules/zd-netty/src/main/resources/bootstrap.yml

@@ -1,29 +0,0 @@
-# Tomcat
-server:
-  port: 9600
-# Spring
-#logging:
-#  level:
-#    root: debug
-spring:
-  application:
-    # 应用名称
-    name: zd-netty
-  profiles:
-    # 环境配置
-    active: dev
-  cloud:
-    nacos:
-      discovery:
-        # 服务注册地址
-        server-addr: ${NACOS_HOST:127.0.0.1}:${NACOS_PORT:8848}
-      config:
-        # 配置中心地址
-        server-addr: ${NACOS_HOST:127.0.0.1}:${NACOS_PORT:8848}
-        # 配置文件格式
-        file-extension: yml
-        # 动态刷新
-        refresh-enabled: true
-        # 共享配置
-        shared-configs:
-          - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}

BIN
zd-modules/zd-netty/src/main/resources/libs/connect-lib.jar


BIN
zd-modules/zd-netty/src/main/resources/libs/reader-lib.jar


BIN
zd-modules/zd-netty/src/main/resources/libs/reader.jar


+ 0 - 74
zd-modules/zd-netty/src/main/resources/logback.xml

@@ -1,74 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<configuration scan="true" scanPeriod="60 seconds" debug="false">
-    <!-- 日志存放路径 -->
-    <property name="log.path" value="logs/zd-netty"/>
-    <!-- 日志输出格式 -->
-    <property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
-
-    <!-- 控制台输出 -->
-    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
-        <encoder>
-            <pattern>${log.pattern}</pattern>
-        </encoder>
-    </appender>
-
-    <!-- 系统日志输出 -->
-    <appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
-        <file>${log.path}/info.log</file>
-        <!-- 循环政策:基于时间创建日志文件 -->
-        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-            <!-- 日志文件名格式 -->
-            <fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
-            <!-- 日志最大的历史 60天 -->
-            <maxHistory>60</maxHistory>
-        </rollingPolicy>
-        <encoder>
-            <pattern>${log.pattern}</pattern>
-        </encoder>
-        <filter class="ch.qos.logback.classic.filter.LevelFilter">
-            <!-- 过滤的级别 -->
-            <level>INFO</level>
-            <!-- 匹配时的操作:接收(记录) -->
-            <onMatch>ACCEPT</onMatch>
-            <!-- 不匹配时的操作:拒绝(不记录) -->
-            <onMismatch>DENY</onMismatch>
-        </filter>
-    </appender>
-
-    <appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
-        <file>${log.path}/error.log</file>
-        <!-- 循环政策:基于时间创建日志文件 -->
-        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-            <!-- 日志文件名格式 -->
-            <fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
-            <!-- 日志最大的历史 60天 -->
-            <maxHistory>60</maxHistory>
-        </rollingPolicy>
-        <encoder>
-            <pattern>${log.pattern}</pattern>
-        </encoder>
-        <filter class="ch.qos.logback.classic.filter.LevelFilter">
-            <!-- 过滤的级别 -->
-            <level>ERROR</level>
-            <!-- 匹配时的操作:接收(记录) -->
-            <onMatch>ACCEPT</onMatch>
-            <!-- 不匹配时的操作:拒绝(不记录) -->
-            <onMismatch>DENY</onMismatch>
-        </filter>
-    </appender>
-
-    <!-- 系统模块日志级别控制  -->
-    <logger name="com.zd" level="info"/>
-    <!-- Spring日志级别控制  -->
-    <logger name="org.springframework" level="error"/>
-
-    <root level="info">
-        <appender-ref ref="console"/>
-    </root>
-
-    <!--系统操作日志-->
-    <root level="info">
-        <appender-ref ref="file_info"/>
-        <appender-ref ref="file_error"/>
-    </root>
-</configuration>

+ 0 - 182
zd-modules/zd-netty/wait-for-it.sh

@@ -1,182 +0,0 @@
-#!/usr/bin/env bash
-# Use this script to test if a given TCP host/port are available
-
-WAITFORIT_cmdname=${0##*/}
-
-echoerr() { if [[ $WAITFORIT_QUIET -ne 1 ]]; then echo "$@" 1>&2; fi }
-
-usage()
-{
-    cat << USAGE >&2
-Usage:
-    $WAITFORIT_cmdname host:port [-s] [-t timeout] [-- command args]
-    -h HOST | --host=HOST       Host or IP under test
-    -p PORT | --port=PORT       TCP port under test
-                                Alternatively, you specify the host and port as host:port
-    -s | --strict               Only execute subcommand if the test succeeds
-    -q | --quiet                Don't output any status messages
-    -t TIMEOUT | --timeout=TIMEOUT
-                                Timeout in seconds, zero for no timeout
-    -- COMMAND ARGS             Execute command with args after the test finishes
-USAGE
-    exit 1
-}
-
-wait_for()
-{
-    if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then
-        echoerr "$WAITFORIT_cmdname: waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT"
-    else
-        echoerr "$WAITFORIT_cmdname: waiting for $WAITFORIT_HOST:$WAITFORIT_PORT without a timeout"
-    fi
-    WAITFORIT_start_ts=$(date +%s)
-    while :
-    do
-        if [[ $WAITFORIT_ISBUSY -eq 1 ]]; then
-            nc -z $WAITFORIT_HOST $WAITFORIT_PORT
-            WAITFORIT_result=$?
-        else
-            (echo -n > /dev/tcp/$WAITFORIT_HOST/$WAITFORIT_PORT) >/dev/null 2>&1
-            WAITFORIT_result=$?
-        fi
-        if [[ $WAITFORIT_result -eq 0 ]]; then
-            WAITFORIT_end_ts=$(date +%s)
-            echoerr "$WAITFORIT_cmdname: $WAITFORIT_HOST:$WAITFORIT_PORT is available after $((WAITFORIT_end_ts - WAITFORIT_start_ts)) seconds"
-            break
-        fi
-        sleep 1
-    done
-    return $WAITFORIT_result
-}
-
-wait_for_wrapper()
-{
-    # In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692
-    if [[ $WAITFORIT_QUIET -eq 1 ]]; then
-        timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --quiet --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT &
-    else
-        timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT &
-    fi
-    WAITFORIT_PID=$!
-    trap "kill -INT -$WAITFORIT_PID" INT
-    wait $WAITFORIT_PID
-    WAITFORIT_RESULT=$?
-    if [[ $WAITFORIT_RESULT -ne 0 ]]; then
-        echoerr "$WAITFORIT_cmdname: timeout occurred after waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT"
-    fi
-    return $WAITFORIT_RESULT
-}
-
-# process arguments
-while [[ $# -gt 0 ]]
-do
-    case "$1" in
-        *:* )
-        WAITFORIT_hostport=(${1//:/ })
-        WAITFORIT_HOST=${WAITFORIT_hostport[0]}
-        WAITFORIT_PORT=${WAITFORIT_hostport[1]}
-        shift 1
-        ;;
-        --child)
-        WAITFORIT_CHILD=1
-        shift 1
-        ;;
-        -q | --quiet)
-        WAITFORIT_QUIET=1
-        shift 1
-        ;;
-        -s | --strict)
-        WAITFORIT_STRICT=1
-        shift 1
-        ;;
-        -h)
-        WAITFORIT_HOST="$2"
-        if [[ $WAITFORIT_HOST == "" ]]; then break; fi
-        shift 2
-        ;;
-        --host=*)
-        WAITFORIT_HOST="${1#*=}"
-        shift 1
-        ;;
-        -p)
-        WAITFORIT_PORT="$2"
-        if [[ $WAITFORIT_PORT == "" ]]; then break; fi
-        shift 2
-        ;;
-        --port=*)
-        WAITFORIT_PORT="${1#*=}"
-        shift 1
-        ;;
-        -t)
-        WAITFORIT_TIMEOUT="$2"
-        if [[ $WAITFORIT_TIMEOUT == "" ]]; then break; fi
-        shift 2
-        ;;
-        --timeout=*)
-        WAITFORIT_TIMEOUT="${1#*=}"
-        shift 1
-        ;;
-        --)
-        shift
-        WAITFORIT_CLI=("$@")
-        break
-        ;;
-        --help)
-        usage
-        ;;
-        *)
-        echoerr "Unknown argument: $1"
-        usage
-        ;;
-    esac
-done
-
-if [[ "$WAITFORIT_HOST" == "" || "$WAITFORIT_PORT" == "" ]]; then
-    echoerr "Error: you need to provide a host and port to test."
-    usage
-fi
-
-WAITFORIT_TIMEOUT=${WAITFORIT_TIMEOUT:-15}
-WAITFORIT_STRICT=${WAITFORIT_STRICT:-0}
-WAITFORIT_CHILD=${WAITFORIT_CHILD:-0}
-WAITFORIT_QUIET=${WAITFORIT_QUIET:-0}
-
-# Check to see if timeout is from busybox?
-WAITFORIT_TIMEOUT_PATH=$(type -p timeout)
-WAITFORIT_TIMEOUT_PATH=$(realpath $WAITFORIT_TIMEOUT_PATH 2>/dev/null || readlink -f $WAITFORIT_TIMEOUT_PATH)
-
-WAITFORIT_BUSYTIMEFLAG=""
-if [[ $WAITFORIT_TIMEOUT_PATH =~ "busybox" ]]; then
-    WAITFORIT_ISBUSY=1
-    # Check if busybox timeout uses -t flag
-    # (recent Alpine versions don't support -t anymore)
-    if timeout &>/dev/stdout | grep -q -e '-t '; then
-        WAITFORIT_BUSYTIMEFLAG="-t"
-    fi
-else
-    WAITFORIT_ISBUSY=0
-fi
-
-if [[ $WAITFORIT_CHILD -gt 0 ]]; then
-    wait_for
-    WAITFORIT_RESULT=$?
-    exit $WAITFORIT_RESULT
-else
-    if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then
-        wait_for_wrapper
-        WAITFORIT_RESULT=$?
-    else
-        wait_for
-        WAITFORIT_RESULT=$?
-    fi
-fi
-
-if [[ $WAITFORIT_CLI != "" ]]; then
-    if [[ $WAITFORIT_RESULT -ne 0 && $WAITFORIT_STRICT -eq 1 ]]; then
-        echoerr "$WAITFORIT_cmdname: strict mode, refusing to execute subprocess"
-        exit $WAITFORIT_RESULT
-    fi
-    exec "${WAITFORIT_CLI[@]}"
-else
-    exit $WAITFORIT_RESULT
-fi