#
Junjie
2 天以前 3c45d4f9f3aba5bc85a9577e43c0dffc71b93a22
src/main/java/com/zy/core/ServerBootstrap.java
@@ -3,17 +3,14 @@
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.model.*;
import com.zy.core.properties.SlaveProperties;
import com.zy.core.thread.*;
import com.zy.core.thread.impl.LfdZyForkLiftMasterThread;
import com.zy.core.thread.impl.LfdZyForkLiftSlaveThread;
import com.zy.core.thread.impl.NyShuttleThread;
import com.zy.core.thread.impl.ZyForkLiftThread;
import com.zy.core.utils.DeviceMsgUtils;
@@ -42,6 +39,8 @@
    private DeviceConfigService deviceConfigService;
    @Autowired
    private DeviceMsgUtils deviceMsgUtils;
    @Autowired
    private BasLiftService basLiftService;
    @PostConstruct
    @Async
@@ -76,44 +75,38 @@
        List<DeviceConfig> allDevices = new ArrayList<>();
        List<DeviceConfig> fakeDevices = new ArrayList<>();
//        // 初始化货叉提升机
//        List<DeviceConfig> forkLiftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
//                .eq("device_type", String.valueOf(SlaveType.ForkLift)));
//        allDevices.addAll(forkLiftList);
//        for (DeviceConfig deviceConfig : forkLiftList) {
//            News.info("初始化货叉提升机........................................................");
//            ThreadHandler thread = null;
//            if (deviceConfig.getThreadImpl().equals("ZyForkLiftThread")) {
//                thread = new ZyForkLiftThread(forkLiftSlave, redisUtil);
//            } else if (deviceConfig.getThreadImpl().equals("LfdZyForkLiftSlaveThread")) {
//                thread = new LfdZyForkLiftSlaveThread(forkLiftSlave, redisUtil, forkLiftSlave.getMasterId());
//            } else {
//                throw new CoolException("未知的线程实现");
//            }
//
//            new Thread(thread).start();
//            SlaveConnection.put(SlaveType.ForkLift, deviceConfig.getDeviceNo(), thread);
//        }
        // 初始化货叉提升机
        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("未配置货叉提升机数据");
            }
//        // 初始化货叉提升机
//        for (ForkLiftSlave forkLiftSlave : slaveProperties.getForkLiftMaster()) {
//            News.info("初始化货叉提升机Master........................................................");
//            ThreadHandler thread = null;
//            if (forkLiftSlave.getThreadImpl().equals("LfdZyForkLiftMasterThread")) {
//                thread = new LfdZyForkLiftMasterThread(forkLiftSlave, redisUtil);
//            } else {
//                throw new CoolException("未知的线程实现");
//            }
//
//            new Thread(thread).start();
//            SlaveConnection.put(SlaveType.ForkLiftMaster, forkLiftSlave.getId(), thread);
//        }
            ThreadHandler thread = null;
            if (deviceConfig.getThreadImpl().equals("ZyForkLiftThread")) {
                thread = new ZyForkLiftThread(deviceConfig, basLift.getStationList$(), 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);
            }
        }
        // 初始化四向穿梭车
        News.info("初始化四向穿梭车......................................................");
        List<DeviceConfig> shuttleList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
                .eq("device_type", String.valueOf(SlaveType.Shuttle)));
        for (DeviceConfig deviceConfig : shuttleList) {
            News.info("初始化四向穿梭车......................................................");
            ThreadHandler thread = null;
            if (deviceConfig.getThreadImpl().equals("NyShuttleThread")) {
                thread = new NyShuttleThread(deviceConfig, redisUtil);