瀏覽代碼

RFID修正

ty130316261 3 年之前
父節點
當前提交
b108a7f767

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

@@ -3,14 +3,14 @@ package com.zd.netty.init;
 import com.zd.common.core.constant.HttpStatus;
 import com.zd.common.core.constant.HttpStatus;
 import com.zd.common.core.domain.R;
 import com.zd.common.core.domain.R;
 import com.zd.common.core.enums.HardwareOperate;
 import com.zd.common.core.enums.HardwareOperate;
+import com.zd.common.core.utils.SpringUtils;
 import com.zd.netty.service.IFridService;
 import com.zd.netty.service.IFridService;
-import com.zd.netty.thread.ThreadPoolTaskConfig;
 import com.zd.system.api.laboratory.RemoteLaboratoryService;
 import com.zd.system.api.laboratory.RemoteLaboratoryService;
 import com.zd.system.api.laboratory.domain.RemoteLabHardware;
 import com.zd.system.api.laboratory.domain.RemoteLabHardware;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.ApplicationArguments;
 import org.springframework.boot.ApplicationArguments;
 import org.springframework.boot.ApplicationRunner;
 import org.springframework.boot.ApplicationRunner;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
 import org.springframework.util.StringUtils;
 import org.springframework.util.StringUtils;
 
 
@@ -31,14 +31,14 @@ public class NettyStartListener implements ApplicationRunner {
     private RemoteLaboratoryService laboratoryService;
     private RemoteLaboratoryService laboratoryService;
     @Resource
     @Resource
     private SocketServer socketServer;
     private SocketServer socketServer;
-    @Resource
-    private ThreadPoolTaskConfig threadPoolTaskConfig;
+
+    private final ThreadPoolTaskExecutor taskExecutor= SpringUtils.getBean("taskExecutor");
 
 
     @Override
     @Override
     public void run(ApplicationArguments args) {
     public void run(ApplicationArguments args) {
         socketServer.start();
         socketServer.start();
 
 
-        threadPoolTaskConfig.threadPoolTaskExecutor().execute(() -> {
+        taskExecutor.execute(() -> {
             synchronized (this) {
             synchronized (this) {
                 R<List<RemoteLabHardware>> listStart = laboratoryService.listStart();
                 R<List<RemoteLabHardware>> listStart = laboratoryService.listStart();
                 while (listStart.getCode() != HttpStatus.SUCCESS) {
                 while (listStart.getCode() != HttpStatus.SUCCESS) {

+ 8 - 7
zd-modules/zd-netty/src/main/java/com/zd/netty/sdk/DeJuRFIDService.java

@@ -1,8 +1,11 @@
 package com.zd.netty.sdk;
 package com.zd.netty.sdk;
 
 
 import com.gg.reader.api.dal.GClient;
 import com.gg.reader.api.dal.GClient;
+import com.gg.reader.api.dal.HandlerTagEpcLog;
+import com.gg.reader.api.dal.HandlerTagEpcOver;
 import com.gg.reader.api.protocol.gx.*;
 import com.gg.reader.api.protocol.gx.*;
 import com.zd.common.core.exception.ServiceException;
 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.ISendService;
 import com.zd.netty.service.IService;
 import com.zd.netty.service.IService;
 import com.zd.netty.thread.ThreadPoolTaskConfig;
 import com.zd.netty.thread.ThreadPoolTaskConfig;
@@ -11,14 +14,13 @@ import com.zd.system.api.laboratory.domain.RemoteLabHardware;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.scheduling.annotation.Async;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
-import java.util.Hashtable;
-import java.util.Map;
-import java.util.Objects;
-import java.util.TimerTask;
+import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeUnit;
 
 
 @Slf4j
 @Slf4j
@@ -30,8 +32,7 @@ public class DeJuRFIDService implements IService {
 
 
     private final Map<String, GClient> clientMap = new ConcurrentHashMap<>();
     private final Map<String, GClient> clientMap = new ConcurrentHashMap<>();
 
 
-    @Resource
-    private ThreadPoolTaskConfig threadPoolTaskConfig;
+    private final ScheduledExecutorService scheduledExecutorService= SpringUtils.getBean("scheduledExecutorService");
 
 
     @Override
     @Override
     public void start(RemoteLabHardware hardware) {
     public void start(RemoteLabHardware hardware) {
@@ -161,7 +162,7 @@ public class DeJuRFIDService implements IService {
     }
     }
 
 
     public void stopGpo(GClient client){
     public void stopGpo(GClient client){
-        threadPoolTaskConfig.scheduledExecutorService().schedule(new TimerTask() {
+        scheduledExecutorService.schedule(new TimerTask() {
             @Override
             @Override
             public void run() {
             public void run() {
                 changeGpo(0, client);
                 changeGpo(0, client);

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

@@ -21,7 +21,7 @@ public class ThreadPoolTaskConfig {
     private static final int QUEUE_CAPACITY = 200;
     private static final int QUEUE_CAPACITY = 200;
     private static final String THREAD_NAME_PREFIX = "Async-Service-";
     private static final String THREAD_NAME_PREFIX = "Async-Service-";
 
 
-    @Bean
+    @Bean("taskExecutor")
     public ThreadPoolTaskExecutor threadPoolTaskExecutor(){
     public ThreadPoolTaskExecutor threadPoolTaskExecutor(){
         ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
         ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
         executor.setCorePoolSize(CORE_POOL_SIZE);
         executor.setCorePoolSize(CORE_POOL_SIZE);
@@ -40,7 +40,7 @@ public class ThreadPoolTaskConfig {
     /**
     /**
      * 执行定时任务
      * 执行定时任务
      */
      */
-    @Bean
+    @Bean(name = "scheduledExecutorService")
     public ScheduledExecutorService scheduledExecutorService() {
     public ScheduledExecutorService scheduledExecutorService() {
         return new ScheduledThreadPoolExecutor(CORE_POOL_SIZE,
         return new ScheduledThreadPoolExecutor(CORE_POOL_SIZE,
                 new BasicThreadFactory.Builder().namingPattern("schedule-pool-%d").daemon(true).build()) {
                 new BasicThreadFactory.Builder().namingPattern("schedule-pool-%d").daemon(true).build()) {