#
Junjie
3 天以前 877b2519157cea762b1e63e9c57c09614216d684
src/main/java/com/zy/core/cache/MessageQueue.java
@@ -1,6 +1,5 @@
package com.zy.core.cache;
import com.zy.asrs.entity.DeviceConfig;
import com.zy.core.enums.SlaveType;
import com.zy.core.model.Task;
@@ -22,23 +21,28 @@
    private static final Map<Integer, ConcurrentLinkedQueue<Task>> FORK_LIFT_EXCHANGE = new ConcurrentHashMap<>();
    //货叉提升机Master mq交换机
    private static final Map<Integer, ConcurrentLinkedQueue<Task>> FORK_LIFT_MASTER_EXCHANGE = new ConcurrentHashMap<>();
    //Traffic Control mq交换机
    private static final Map<Integer, ConcurrentLinkedQueue<Task>> TRAFFIC_CONTROL_EXCHANGE = new ConcurrentHashMap<>();
    /**
     * mq 交换机初始化
     */
    public static void init(SlaveType type, DeviceConfig deviceConfig) {
    public static void init(SlaveType type, Integer id) {
        switch (type) {
            case Shuttle:
                SHUTTLE_EXCHANGE.put(deviceConfig.getDeviceNo(), new ConcurrentLinkedQueue<>());
                SHUTTLE_EXCHANGE.put(id, new ConcurrentLinkedQueue<>());
                break;
            case ForkLift:
                FORK_LIFT_EXCHANGE.put(deviceConfig.getDeviceNo(), new ConcurrentLinkedQueue<>());
                FORK_LIFT_EXCHANGE.put(id, new ConcurrentLinkedQueue<>());
                break;
            case ForkLiftMaster:
                FORK_LIFT_MASTER_EXCHANGE.put(deviceConfig.getDeviceNo(), new ConcurrentLinkedQueue<>());
                FORK_LIFT_MASTER_EXCHANGE.put(id, new ConcurrentLinkedQueue<>());
                break;
            case Lift:
                LIFT_EXCHANGE.put(deviceConfig.getDeviceNo(), new ConcurrentLinkedQueue<>());
                LIFT_EXCHANGE.put(id, new ConcurrentLinkedQueue<>());
                break;
            case TrafficControl:
                TRAFFIC_CONTROL_EXCHANGE.put(id, new ConcurrentLinkedQueue<>());
                break;
            default:
                break;
@@ -59,6 +63,8 @@
                return FORK_LIFT_MASTER_EXCHANGE.get(id).offer(task);
            case Lift:
                return LIFT_EXCHANGE.get(id).offer(task);
            case TrafficControl:
                return TRAFFIC_CONTROL_EXCHANGE.get(id).offer(task);
            default:
                return false;
        }
@@ -78,6 +84,8 @@
                return FORK_LIFT_MASTER_EXCHANGE.get(id).poll();
            case Lift:
                return LIFT_EXCHANGE.get(id).poll();
            case TrafficControl:
                return TRAFFIC_CONTROL_EXCHANGE.get(id).poll();
            default:
                return null;
        }
@@ -96,6 +104,8 @@
                return FORK_LIFT_MASTER_EXCHANGE.get(id).peek();
            case Lift:
                return LIFT_EXCHANGE.get(id).peek();
            case TrafficControl:
                return TRAFFIC_CONTROL_EXCHANGE.get(id).peek();
            default:
                return null;
        }
@@ -115,6 +125,9 @@
            case Lift:
                LIFT_EXCHANGE.get(id).clear();
                break;
            case TrafficControl:
                TRAFFIC_CONTROL_EXCHANGE.get(id).clear();
                break;
            default:
                break;
        }