From 96cfc17f191fee0a05070ec8e7bb6fb099f0231c Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期三, 24 十二月 2025 14:28:42 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/ServerBootstrap.java | 166 ++++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 120 insertions(+), 46 deletions(-)
diff --git a/src/main/java/com/zy/core/ServerBootstrap.java b/src/main/java/com/zy/core/ServerBootstrap.java
index 5420fbd..4912e40 100644
--- a/src/main/java/com/zy/core/ServerBootstrap.java
+++ b/src/main/java/com/zy/core/ServerBootstrap.java
@@ -1,22 +1,24 @@
package com.zy.core;
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.exception.CoolException;
+import com.zy.asrs.entity.DeviceConfig;
+import com.zy.asrs.service.DeviceConfigService;
import com.zy.common.utils.RedisUtil;
import com.zy.core.cache.MessageQueue;
import com.zy.core.cache.SlaveConnection;
import com.zy.core.enums.SlaveType;
-import com.zy.core.model.*;
-import com.zy.core.properties.SlaveProperties;
-import com.zy.core.thread.*;
-import com.zy.core.thread.impl.NyShuttleThread;
-import com.zy.core.thread.impl.ZyForkLiftThread;
+import com.zy.core.thread.impl.ZySiemensCrnThread;
+import com.zy.core.thread.impl.ZySiemensDualCrnThread;
+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;
/**
* Created by vincent on 2020/8/4
@@ -26,18 +28,15 @@
public class ServerBootstrap {
@Autowired
- private SlaveProperties slaveProperties;
- @Autowired
private MainProcess mainProcess;
@Autowired
private RedisUtil redisUtil;
+ @Autowired
+ private DeviceConfigService deviceConfigService;
-
- @PostConstruct
@Async
public void init() throws InterruptedException {
News.info("鏍稿績鎺у埗灞傚紑濮嬪垵濮嬪寲...............................................");
- Thread.sleep(2000);
// 鍒濆鍖栨秷鎭槦鍒�
initMq();
// 鍒濆鍖栦笅浣嶆満绾跨▼
@@ -48,50 +47,125 @@
}
private void initMq(){
- // 鍒濆鍖栬揣鍙夋彁鍗囨満mq
- for (Slave forkLift : slaveProperties.getForkLift()) {
- MessageQueue.init(SlaveType.ForkLift, forkLift);
+ // 鍒濆鍖栧爢鍨涙満mq
+ List<DeviceConfig> crnList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+ .eq("device_type", String.valueOf(SlaveType.Crn)));
+ for (DeviceConfig crn : crnList) {
+ MessageQueue.init(SlaveType.Crn, crn.getDeviceNo());
}
- // 鍒濆鍖栧洓鍚戠┛姊溅mq
- for (Slave shuttle : slaveProperties.getShuttle()) {
- MessageQueue.init(SlaveType.Shuttle, shuttle);
+ // 鍒濆鍖栧弻宸ヤ綅鍫嗗灈鏈簃q
+ List<DeviceConfig> dualCrnList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+ .eq("device_type", String.valueOf(SlaveType.DualCrn)));
+ for (DeviceConfig crn : dualCrnList) {
+ MessageQueue.init(SlaveType.DualCrn, crn.getDeviceNo());
+ }
+ // 鍒濆鍖朢gv灏忚溅mq
+ List<DeviceConfig> rgvList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+ .eq("device_type", String.valueOf(SlaveType.Rgv)));
+ for (DeviceConfig rgv : rgvList) {
+ MessageQueue.init(SlaveType.Rgv, rgv.getDeviceNo());
+ }
+ // 鍒濆鍖栬緭閫佺嚎mq
+ List<DeviceConfig> devpList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+ .eq("device_type", String.valueOf(SlaveType.Devp)));
+ for (DeviceConfig devp : devpList) {
+ MessageQueue.init(SlaveType.Devp, devp.getDeviceNo());
+ }
+ // 鍒濆鍖栨潯鐮佹壂鎻忎华mq
+ List<DeviceConfig> barcodeList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+ .eq("device_type", String.valueOf(SlaveType.Barcode)));
+ for (DeviceConfig barcode : barcodeList) {
+ MessageQueue.init(SlaveType.Barcode, barcode.getDeviceNo());
+ }
+ // 鍒濆鍖朙ed鐏痬q
+ List<DeviceConfig> ledList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+ .eq("device_type", String.valueOf(SlaveType.Led)));
+ for (DeviceConfig led : ledList) {
+ MessageQueue.init(SlaveType.Led, led.getDeviceNo());
}
}
private void initThread(){
- // 鍒濆鍖栬揣鍙夋彁鍗囨満
- News.info("鍒濆鍖栬揣鍙夋彁鍗囨満........................................................");
- for (ForkLiftSlave forkLiftSlave : slaveProperties.getForkLift()) {
- ThreadHandler thread = null;
- if (forkLiftSlave.getThreadImpl().equals("ZyForkLiftThread")) {
- thread = new ZyForkLiftThread(forkLiftSlave, redisUtil);
- } else {
- throw new CoolException("鏈煡鐨勭嚎绋嬪疄鐜�");
- }
+ List<DeviceConfig> crnList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+ .eq("device_type", String.valueOf(SlaveType.Crn)));
+ if(!crnList.isEmpty()) {
+ News.info("鍒濆鍖栧爢鍨涙満........................................................");
+ for (DeviceConfig deviceConfig : crnList) {
+ ThreadHandler thread = null;
+ if (deviceConfig.getThreadImpl().equals("ZySiemensCrnThread")) {
+ thread = new ZySiemensCrnThread(deviceConfig, redisUtil);
+ } else {
+ throw new CoolException("鏈煡鐨勭嚎绋嬪疄鐜�");
+ }
- new Thread(thread).start();
- SlaveConnection.put(SlaveType.ForkLift, forkLiftSlave.getId(), thread);
+ Thread t = new Thread(thread);
+ t.setName("CrnThread-" + deviceConfig.getDeviceNo());
+ t.setDaemon(true);
+ t.start();
+ SlaveConnection.put(SlaveType.Crn, deviceConfig.getDeviceNo(), thread);
+ }
}
- // 鍒濆鍖栧洓鍚戠┛姊溅
- News.info("鍒濆鍖栧洓鍚戠┛姊溅......................................................");
- for (ShuttleSlave shuttleSlave : slaveProperties.getShuttle()) {
- ThreadHandler thread = null;
- if (shuttleSlave.getThreadImpl().equals("NyShuttleThread")) {
- thread = new NyShuttleThread(shuttleSlave, redisUtil);
- } else {
- throw new CoolException("鏈煡鐨勭嚎绋嬪疄鐜�");
+ List<DeviceConfig> dualCrnList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+ .eq("device_type", String.valueOf(SlaveType.DualCrn)));
+ if(!dualCrnList.isEmpty()) {
+ News.info("鍒濆鍖栧弻宸ヤ綅鍫嗗灈鏈�........................................................");
+ for (DeviceConfig deviceConfig : dualCrnList) {
+ ThreadHandler thread = null;
+ if (deviceConfig.getThreadImpl().equals("ZySiemensDualCrnThread")) {
+ thread = new ZySiemensDualCrnThread(deviceConfig, redisUtil);
+ } else {
+ throw new CoolException("鏈煡鐨勭嚎绋嬪疄鐜�");
+ }
+
+ Thread t = new Thread(thread);
+ t.setName("DualCrnThread-" + deviceConfig.getDeviceNo());
+ t.setDaemon(true);
+ t.start();
+ SlaveConnection.put(SlaveType.DualCrn, deviceConfig.getDeviceNo(), thread);
}
-
- new Thread(thread).start();
- SlaveConnection.put(SlaveType.Shuttle, shuttleSlave.getId(), thread);
}
+
+ List<DeviceConfig> devpList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+ .eq("device_type", String.valueOf(SlaveType.Devp)));
+ if(!devpList.isEmpty()) {
+ News.info("鍒濆鍖栬緭閫佺珯........................................................");
+ for (DeviceConfig deviceConfig : devpList) {
+ ThreadHandler thread = null;
+ if (deviceConfig.getThreadImpl().equals("ZyStationThread")) {
+ thread = new ZyStationThread(deviceConfig, redisUtil);
+ } else {
+ throw new CoolException("鏈煡鐨勭嚎绋嬪疄鐜�");
+ }
+
+ Thread t = new Thread(thread);
+ t.setName("DevpThread-" + deviceConfig.getDeviceNo());
+ t.setDaemon(true);
+ t.start();
+ SlaveConnection.put(SlaveType.Devp, deviceConfig.getDeviceNo(), thread);
+ }
+ }
+
+ List<DeviceConfig> rgvList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+ .eq("device_type", String.valueOf(SlaveType.Rgv)));
+ if(!rgvList.isEmpty()) {
+ News.info("鍒濆鍖朢GV........................................................");
+ 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() {
- }
-
}
--
Gitblit v1.9.1