|  |  | 
 |  |  | 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交换机 | 
 |  |  | 
 |  |  |     private static final Map<Integer, ConcurrentLinkedQueue<Task>> SCALE_EXCHANGE = new ConcurrentHashMap<>(); | 
 |  |  |     // 台车mq交换机 | 
 |  |  |     private static final Map<Integer, ConcurrentLinkedQueue<Task>> CAR_EXCHANGE = new ConcurrentHashMap<>(); | 
 |  |  |     private static final Map<Integer, LinkedBlockingQueue<Task>> RGV_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 Rgv: | 
 |  |  |                 RGV_EXCHANGE.put(slave.getId(), new LinkedBlockingQueue<>(1)); | 
 |  |  |                 break; | 
 |  |  |             case Devp: | 
 |  |  |                 DEVP_EXCHANGE.put(slave.getId(), new ConcurrentLinkedQueue<>()); | 
 |  |  | 
 |  |  |         switch (type) { | 
 |  |  |             case Crn: | 
 |  |  |                 return CRN_EXCHANGE.get(id).offer(task); | 
 |  |  |             case Rgv: | 
 |  |  |                 return RGV_EXCHANGE.get(id).offer(task); | 
 |  |  |             case Devp: | 
 |  |  |                 return DEVP_EXCHANGE.get(id).offer(task); | 
 |  |  |             case Barcode: | 
 |  |  | 
 |  |  |         switch (type) { | 
 |  |  |             case Crn: | 
 |  |  |                 return CRN_EXCHANGE.get(id).poll(); | 
 |  |  |             case Rgv: | 
 |  |  |                 return RGV_EXCHANGE.get(id).poll(); | 
 |  |  |             case Devp: | 
 |  |  |                 return DEVP_EXCHANGE.get(id).poll(); | 
 |  |  |             case Barcode: | 
 |  |  | 
 |  |  |         switch (type) { | 
 |  |  |             case Crn: | 
 |  |  |                 return CRN_EXCHANGE.get(id).peek(); | 
 |  |  |             case Rgv: | 
 |  |  |                 return RGV_EXCHANGE.get(id).peek(); | 
 |  |  |             case Devp: | 
 |  |  |                 return DEVP_EXCHANGE.get(id).peek(); | 
 |  |  |             case Barcode: | 
 |  |  | 
 |  |  |             case Crn: | 
 |  |  |                 CRN_EXCHANGE.get(id).clear(); | 
 |  |  |                 break; | 
 |  |  |             case Rgv: | 
 |  |  |                 RGV_EXCHANGE.get(id).clear(); | 
 |  |  |                 break; | 
 |  |  |             case Devp: | 
 |  |  |                 DEVP_EXCHANGE.get(id).clear(); | 
 |  |  |                 break; |