#
Junjie
21 小时以前 0c5a58771fcf86ad0b562829fbfa440da9392703
src/main/java/com/zy/core/ServerBootstrap.java
@@ -10,14 +10,13 @@
import com.zy.core.enums.SlaveType;
import com.zy.core.thread.impl.ZySiemensCrnThread;
import com.zy.core.thread.impl.ZyStationThread;
import com.zy.core.thread.impl.ZyRgvThread;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import java.util.List;
/**
@@ -34,7 +33,6 @@
    @Autowired
    private DeviceConfigService deviceConfigService;
    @PostConstruct
    @Async
    public void init() throws InterruptedException {
        News.info("核心控制层开始初始化...............................................");
@@ -93,7 +91,10 @@
                throw new CoolException("未知的线程实现");
            }
            new Thread(thread).start();
            Thread t = new Thread(thread);
            t.setName("CrnThread-" + deviceConfig.getDeviceNo());
            t.setDaemon(true);
            t.start();
            SlaveConnection.put(SlaveType.Crn, deviceConfig.getDeviceNo(), thread);
        }
@@ -108,16 +109,31 @@
                throw new CoolException("未知的线程实现");
            }
            new Thread(thread).start();
            Thread t = new Thread(thread);
            t.setName("DevpThread-" + deviceConfig.getDeviceNo());
            t.setDaemon(true);
            t.start();
            SlaveConnection.put(SlaveType.Devp, deviceConfig.getDeviceNo(), thread);
        }
        News.info("初始化RGV........................................................");
        List<DeviceConfig> rgvList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
                .eq("device_type", String.valueOf(SlaveType.Rgv)));
        for (DeviceConfig deviceConfig : rgvList) {
            ThreadHandler thread = null;
            if (deviceConfig.getThreadImpl().equals("ZyRgvThread")) {
                thread = new ZyRgvThread(deviceConfig, redisUtil);
            } else {
                throw new CoolException("未知的线程实现");
            }
            Thread t = new Thread(thread);
            t.setName("RgvThread-" + deviceConfig.getDeviceNo());
            t.setDaemon(true);
            t.start();
            SlaveConnection.put(SlaveType.Rgv, deviceConfig.getDeviceNo(), thread);
        }
    }
    @PreDestroy
    public void destroy() {
    }
}