Explorar el Código

Merge branch 'master' of http://git.aseanbusiness.cn/qzyReal/gather-server

# Conflicts:
#	src/main/java/com/gzlh/api/OpenApi.java
#	src/main/java/com/gzlh/event/EventThread.java
qzyReal hace 1 año
padre
commit
bce6438dde

+ 28 - 1
src/main/java/com/gzlh/event/EventBus.java

@@ -1,15 +1,42 @@
 package com.gzlh.event;
 
 import com.gzlh.dto.EventDTO;
+import com.gzlh.infrared.config.RedPropertiesConfig;
+import com.gzlh.infrared.factory.RedFactory;
+import com.gzlh.led.factory.LedFactory;
+import com.gzlh.led.properties.LedPropertiesConfig;
+import com.gzlh.weighbridge.config.WeighbridgePropertiesConfig;
+import com.gzlh.weighbridge.factory.WeighbridgeFactory;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
 
+import javax.annotation.Resource;
 import java.util.List;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
 
 @Component
 @Slf4j
 public class EventBus {
     private List<EventDTO> eventDTOList;
+    @Resource
+    private LedFactory ledFactory;
+    @Resource
+    private RedFactory redFactory;
+    @Resource
+    WeighbridgeFactory weighbridgeFactory;
+
+    @Resource
+    private WeighbridgePropertiesConfig weighbridgePropertiesConfig;
+    @Resource
+    private RedPropertiesConfig redPropertiesConfig;
+    @Resource
+    private LedPropertiesConfig ledPropertiesConfig;
+
+    ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(10, 20,
+            10L, TimeUnit.SECONDS,
+            new LinkedBlockingQueue(100));
 
     public void setEventDTOList(List<EventDTO> eventDTOList) {
         this.eventDTOList = eventDTOList;
@@ -18,6 +45,6 @@ public class EventBus {
     public void start(String eventName){
         EventThread thread = new EventThread(eventName);
         thread.setEventDTOList(eventDTOList);
-        thread.start();
+        threadPoolExecutor.execute(thread);
     }
 }

+ 2 - 3
src/main/java/com/gzlh/event/EventThread.java

@@ -4,7 +4,6 @@ import cn.hutool.core.thread.ThreadUtil;
 import cn.hutool.core.util.NumberUtil;
 import cn.hutool.core.util.RandomUtil;
 import cn.hutool.core.util.StrUtil;
-import cn.hutool.extra.spring.SpringUtil;
 import com.gzlh.config.ModuleEnum;
 import com.gzlh.dto.EventDTO;
 import com.gzlh.infrared.config.RedPropertiesConfig;
@@ -20,7 +19,7 @@ import java.util.Date;
 import java.util.List;
 
 @Slf4j
-public class EventThread extends Thread{
+public class EventThread implements Runnable{
     private List<EventDTO> eventDTOList;
     private String eventName;
     private final LedFactory ledFactory=SpringUtil.getBean(LedFactory.class);
@@ -31,7 +30,6 @@ public class EventThread extends Thread{
     private final LedPropertiesConfig ledPropertiesConfig=SpringUtil.getBean(LedPropertiesConfig.class);
 
     public EventThread(String eventName) {
-        this.setName(eventName);
         this.eventName=eventName;
     }
 
@@ -98,6 +96,7 @@ public class EventThread extends Thread{
         }
     }
 
+    @Override
     public void run(){
         handlerEvent(eventName);
     }