From 7ec503a70d25e089cc008192898d9da3219d2a6b Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期四, 13 十一月 2025 16:38:45 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/ServerBootstrap.java | 106 ++++++++++++++++++++++------------------------------
1 files changed, 45 insertions(+), 61 deletions(-)
diff --git a/src/main/java/com/zy/core/ServerBootstrap.java b/src/main/java/com/zy/core/ServerBootstrap.java
index 003d514..7779d8e 100644
--- a/src/main/java/com/zy/core/ServerBootstrap.java
+++ b/src/main/java/com/zy/core/ServerBootstrap.java
@@ -1,19 +1,16 @@
package com.zy.core;
-import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.exception.CoolException;
-import com.zy.asrs.entity.BasLift;
import com.zy.asrs.entity.DeviceConfig;
-import com.zy.asrs.service.BasLiftService;
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.thread.impl.NyShuttleThread;
-import com.zy.core.thread.impl.ZyForkLiftThread;
-import com.zy.core.utils.DeviceMsgUtils;
+import com.zy.core.thread.impl.ZySiemensCrnThread;
+import com.zy.core.thread.impl.ZyStationThread;
+
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
@@ -21,7 +18,6 @@
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
-import java.util.ArrayList;
import java.util.List;
/**
@@ -37,10 +33,6 @@
private RedisUtil redisUtil;
@Autowired
private DeviceConfigService deviceConfigService;
- @Autowired
- private DeviceMsgUtils deviceMsgUtils;
- @Autowired
- private BasLiftService basLiftService;
@PostConstruct
@Async
@@ -57,77 +49,69 @@
}
private void initMq(){
- // 鍒濆鍖栬揣鍙夋彁鍗囨満mq
- List<DeviceConfig> forkLiftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
- .eq("device_type", String.valueOf(SlaveType.ForkLift)));
- for (DeviceConfig forkLift : forkLiftList) {
- 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
- List<DeviceConfig> shuttleList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
- .eq("device_type", String.valueOf(SlaveType.Shuttle)));
- for (DeviceConfig shuttle : shuttleList) {
- MessageQueue.init(SlaveType.Shuttle, shuttle);
+ // 鍒濆鍖朢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(){
- List<DeviceConfig> allDevices = new ArrayList<>();
- List<DeviceConfig> fakeDevices = new ArrayList<>();
-
- // 鍒濆鍖栬揣鍙夋彁鍗囨満
- News.info("鍒濆鍖栬揣鍙夋彁鍗囨満........................................................");
- List<DeviceConfig> forkLiftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
- .eq("device_type", String.valueOf(SlaveType.ForkLift)));
- for (DeviceConfig deviceConfig : forkLiftList) {
- BasLift basLift = basLiftService.selectOne(new EntityWrapper<BasLift>().eq("lift_no", deviceConfig.getDeviceNo()));
- if (basLift == null) {
- throw new CoolException("鏈厤缃揣鍙夋彁鍗囨満鏁版嵁");
- }
-
+ News.info("鍒濆鍖栧爢鍨涙満........................................................");
+ List<DeviceConfig> crnList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+ .eq("device_type", String.valueOf(SlaveType.Crn)));
+ for (DeviceConfig deviceConfig : crnList) {
ThreadHandler thread = null;
- if (deviceConfig.getThreadImpl().equals("ZyForkLiftThread")) {
- thread = new ZyForkLiftThread(deviceConfig, basLift.getStationList$(), redisUtil);
+ if (deviceConfig.getThreadImpl().equals("ZySiemensCrnThread")) {
+ thread = new ZySiemensCrnThread(deviceConfig, redisUtil);
} else {
throw new CoolException("鏈煡鐨勭嚎绋嬪疄鐜�");
}
new Thread(thread).start();
- SlaveConnection.put(SlaveType.ForkLift, deviceConfig.getDeviceNo(), thread);
-
- if (deviceConfig.getFake() == 1) {
- fakeDevices.add(deviceConfig);
- }else {
- allDevices.add(deviceConfig);
- }
+ SlaveConnection.put(SlaveType.Crn, deviceConfig.getDeviceNo(), thread);
}
- // 鍒濆鍖栧洓鍚戠┛姊溅
- News.info("鍒濆鍖栧洓鍚戠┛姊溅......................................................");
- List<DeviceConfig> shuttleList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
- .eq("device_type", String.valueOf(SlaveType.Shuttle)));
- for (DeviceConfig deviceConfig : shuttleList) {
+ News.info("鍒濆鍖栬緭閫佺珯........................................................");
+ List<DeviceConfig> devpList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+ .eq("device_type", String.valueOf(SlaveType.Devp)));
+ for (DeviceConfig deviceConfig : devpList) {
ThreadHandler thread = null;
- if (deviceConfig.getThreadImpl().equals("NyShuttleThread")) {
- thread = new NyShuttleThread(deviceConfig, redisUtil);
+ if (deviceConfig.getThreadImpl().equals("ZyStationThread")) {
+ thread = new ZyStationThread(deviceConfig, redisUtil);
} else {
throw new CoolException("鏈煡鐨勭嚎绋嬪疄鐜�");
}
new Thread(thread).start();
- SlaveConnection.put(SlaveType.Shuttle, deviceConfig.getDeviceNo(), thread);
-
- if (deviceConfig.getFake() == 1) {
- fakeDevices.add(deviceConfig);
- }else {
- allDevices.add(deviceConfig);
- }
+ SlaveConnection.put(SlaveType.Devp, deviceConfig.getDeviceNo(), thread);
}
-
- //璁惧鍒濆鍖栧畬姣�
- deviceMsgUtils.sendDeviceConfig(JSON.toJSONString(allDevices));
- deviceMsgUtils.sendFakeDeviceConfig(JSON.toJSONString(fakeDevices));
}
--
Gitblit v1.9.1