|  |  | 
 |  |  | package com.zy.core.cache; | 
 |  |  |  | 
 |  |  | import com.zy.asrs.utils.CommandUtils; | 
 |  |  | import com.zy.core.Slave; | 
 |  |  | import com.zy.core.enums.SlaveType; | 
 |  |  | import com.zy.core.model.Task; | 
 |  |  | 
 |  |  | public class MessageQueue { | 
 |  |  |  | 
 |  |  |     // 堆垛机mq交换机 | 
 |  |  |     private static final Map<Integer, ConcurrentLinkedQueue<Task>> CRN_EXCHANGE = new ConcurrentHashMap<>(); | 
 |  |  |     private static final Map<Integer, LinkedBlockingQueue<Task>> CRN_EXCHANGE = new ConcurrentHashMap<>(); | 
 |  |  |     // 输送线mq交换机 | 
 |  |  |     private static final Map<Integer, ConcurrentLinkedQueue<Task>> DEVP_EXCHANGE = new ConcurrentHashMap<>(); | 
 |  |  |     // 条码扫描仪mq交换机 | 
 |  |  | 
 |  |  |     public static void init(SlaveType type, Slave slave) { | 
 |  |  |         switch (type) { | 
 |  |  |             case Crn: | 
 |  |  |                 CRN_EXCHANGE.put(slave.getId(), new ConcurrentLinkedQueue<>()); | 
 |  |  |                 CRN_EXCHANGE.put(slave.getId(), new LinkedBlockingQueue<>(1)); | 
 |  |  |                 break; | 
 |  |  |             case Devp: | 
 |  |  |                 DEVP_EXCHANGE.put(slave.getId(), new ConcurrentLinkedQueue<>()); | 
 |  |  | 
 |  |  |      * 如果发现队列已满无法添加的话,会直接返回false。 | 
 |  |  |      */ | 
 |  |  |     public static boolean offer(SlaveType type, Integer id, Task task) { | 
 |  |  |         CommandUtils.offer(type, id, task); | 
 |  |  |         switch (type) { | 
 |  |  |             case Crn: | 
 |  |  |                 return CRN_EXCHANGE.get(id).offer(task); | 
 |  |  | 
 |  |  |     public static void clear(SlaveType type, Integer id){ | 
 |  |  |         switch (type) { | 
 |  |  |             case Crn: | 
 |  |  |                  | 
 |  |  |                 CRN_EXCHANGE.get(id).clear(); | 
 |  |  |                 break; | 
 |  |  |             case Devp: |