| | |
| | | import com.zy.asrs.service.BasLiftService; |
| | | import com.zy.asrs.service.DeviceConfigService; |
| | | import com.zy.common.utils.RedisUtil; |
| | | import com.zy.core.action.ShuttleAction; |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.task.ShuttleExecuteScheduler; |
| | | import com.zy.core.thread.TrafficControlThread; |
| | | import com.zy.core.thread.impl.NyLiftThread; |
| | | import com.zy.core.thread.impl.NyShuttleThread; |
| | | import com.zy.core.thread.impl.TrafficControlImplThread; |
| | | import com.zy.core.thread.impl.ZyForkLiftThread; |
| | | import com.zy.core.utils.DeviceMsgUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | |
| | | @Component |
| | | public class ServerBootstrap { |
| | | |
| | | @Value("${deviceExecuteConfig.threadControlCount}") |
| | | private int threadControlCount; |
| | | |
| | | @Autowired |
| | | private MainProcess mainProcess; |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | @Autowired |
| | | private DeviceConfigService deviceConfigService; |
| | | @Autowired |
| | | private ShuttleAction shuttleAction; |
| | | @Autowired |
| | | private DeviceMsgUtils deviceMsgUtils; |
| | | @Autowired |
| | |
| | | .eq("device_type", String.valueOf(SlaveType.ForkLift))); |
| | | for (DeviceConfig forkLift : forkLiftList) { |
| | | MessageQueue.init(SlaveType.ForkLift, forkLift.getDeviceNo()); |
| | | } |
| | | // 初始化提升机mq |
| | | List<DeviceConfig> liftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() |
| | | .eq("device_type", String.valueOf(SlaveType.Lift))); |
| | | for (DeviceConfig lift : liftList) { |
| | | MessageQueue.init(SlaveType.Lift, lift.getDeviceNo()); |
| | | } |
| | | // 初始化四向穿梭车mq |
| | | List<DeviceConfig> shuttleList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() |
| | |
| | | } |
| | | } |
| | | |
| | | // 初始化提升机 |
| | | News.info("初始化提升机........................................................"); |
| | | List<DeviceConfig> liftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() |
| | | .eq("device_type", String.valueOf(SlaveType.Lift))); |
| | | for (DeviceConfig deviceConfig : liftList) { |
| | | BasLift basLift = basLiftService.selectOne(new EntityWrapper<BasLift>().eq("lift_no", deviceConfig.getDeviceNo())); |
| | | if (basLift == null) { |
| | | throw new CoolException("未配置提升机数据"); |
| | | } |
| | | |
| | | ThreadHandler thread = null; |
| | | if (deviceConfig.getThreadImpl().equals("NyLiftThread")) { |
| | | thread = new NyLiftThread(deviceConfig, basLift.getPoint$(), basLift.getStationList$(), redisUtil); |
| | | } else { |
| | | throw new CoolException("未知的线程实现"); |
| | | } |
| | | |
| | | new Thread(thread).start(); |
| | | SlaveConnection.put(SlaveType.Lift, deviceConfig.getDeviceNo(), thread); |
| | | |
| | | if (deviceConfig.getFake() == 1) { |
| | | fakeDevices.add(deviceConfig); |
| | | }else { |
| | | allDevices.add(deviceConfig); |
| | | } |
| | | } |
| | | |
| | | // 初始化四向穿梭车 |
| | | News.info("初始化四向穿梭车......................................................"); |
| | | List<DeviceConfig> shuttleList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() |
| | |
| | | TrafficControlThread trafficControlThread = new TrafficControlImplThread(redisUtil); |
| | | new Thread(trafficControlThread).start(); |
| | | SlaveConnection.put(SlaveType.TrafficControl, 1, trafficControlThread); |
| | | |
| | | ShuttleExecuteScheduler shuttleExecuteScheduler = new ShuttleExecuteScheduler(shuttleAction, deviceConfigService, redisUtil, threadControlCount); |
| | | new Thread(shuttleExecuteScheduler).start(); |
| | | } |
| | | |
| | | |