From 05f2733c4cdc4ea0765e08d61273728aebb70d16 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期二, 18 三月 2025 15:51:46 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/cache/MessageQueue.java |  110 ++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 69 insertions(+), 41 deletions(-)

diff --git a/src/main/java/com/zy/core/cache/MessageQueue.java b/src/main/java/com/zy/core/cache/MessageQueue.java
index deb09e8..a7a9efd 100644
--- a/src/main/java/com/zy/core/cache/MessageQueue.java
+++ b/src/main/java/com/zy/core/cache/MessageQueue.java
@@ -14,36 +14,31 @@
  */
 public class MessageQueue {
 
-    // 鍫嗗灈鏈簃q浜ゆ崲鏈�
-    private static final Map<Integer, ConcurrentLinkedQueue<Task>> CRN_EXCHANGE = new ConcurrentHashMap<>();
-    // 杈撻�佺嚎mq浜ゆ崲鏈�
-    private static final Map<Integer, ConcurrentLinkedQueue<Task>> DEVP_EXCHANGE = new ConcurrentHashMap<>();
-    // 鏉$爜鎵弿浠猰q浜ゆ崲鏈�
-    private static final Map<Integer, ConcurrentLinkedQueue<Task>> BARCODE_EXCHANGE = new ConcurrentHashMap<>();
-    // Led鐏� mq浜ゆ崲鏈�
-    private static final Map<Integer, ConcurrentLinkedQueue<Task>> LED_EXCHANGE = new ConcurrentHashMap<>();
-    // 纾呯Оmq浜ゆ崲鏈�
-    private static final Map<Integer, ConcurrentLinkedQueue<Task>> SCALE_EXCHANGE = new ConcurrentHashMap<>();
+    //鍥涘悜绌挎杞q浜ゆ崲鏈�
+    private static final Map<Integer, ConcurrentLinkedQueue<Task>> SHUTTLE_EXCHANGE = new ConcurrentHashMap<>();
+    //鎻愬崌鏈簃q浜ゆ崲鏈�
+    private static final Map<Integer, ConcurrentLinkedQueue<Task>> LIFT_EXCHANGE = new ConcurrentHashMap<>();
+    //璐у弶鎻愬崌鏈簃q浜ゆ崲鏈�
+    private static final Map<Integer, ConcurrentLinkedQueue<Task>> FORK_LIFT_EXCHANGE = new ConcurrentHashMap<>();
+    //璐у弶鎻愬崌鏈篗aster mq浜ゆ崲鏈�
+    private static final Map<Integer, ConcurrentLinkedQueue<Task>> FORK_LIFT_MASTER_EXCHANGE = new ConcurrentHashMap<>();
 
     /**
      * mq 浜ゆ崲鏈哄垵濮嬪寲
      */
     public static void init(SlaveType type, Slave slave) {
         switch (type) {
-            case Crn:
-                CRN_EXCHANGE.put(slave.getId(), new ConcurrentLinkedQueue<>());
+            case Shuttle:
+                SHUTTLE_EXCHANGE.put(slave.getId(), new ConcurrentLinkedQueue<>());
                 break;
-            case Devp:
-                DEVP_EXCHANGE.put(slave.getId(), new ConcurrentLinkedQueue<>());
+            case ForkLift:
+                FORK_LIFT_EXCHANGE.put(slave.getId(), new ConcurrentLinkedQueue<>());
                 break;
-            case Barcode:
-                BARCODE_EXCHANGE.put(slave.getId(), new ConcurrentLinkedQueue<>());
+            case ForkLiftMaster:
+                FORK_LIFT_MASTER_EXCHANGE.put(slave.getId(), new ConcurrentLinkedQueue<>());
                 break;
-            case Led:
-                LED_EXCHANGE.put(slave.getId(), new ConcurrentLinkedQueue<>());
-                break;
-            case Scale:
-                SCALE_EXCHANGE.put(slave.getId(), new ConcurrentLinkedQueue<>());
+            case Lift:
+                LIFT_EXCHANGE.put(slave.getId(), new ConcurrentLinkedQueue<>());
                 break;
             default:
                 break;
@@ -56,16 +51,14 @@
      */
     public static boolean offer(SlaveType type, Integer id, Task task) {
         switch (type) {
-            case Crn:
-                return CRN_EXCHANGE.get(id).offer(task);
-            case Devp:
-                return DEVP_EXCHANGE.get(id).offer(task);
-            case Barcode:
-                return BARCODE_EXCHANGE.get(id).offer(task);
-            case Led:
-                return LED_EXCHANGE.get(id).offer(task);
-            case Scale:
-                return SCALE_EXCHANGE.get(id).offer(task);
+            case Shuttle:
+                return SHUTTLE_EXCHANGE.get(id).offer(task);
+            case ForkLift:
+                return FORK_LIFT_EXCHANGE.get(id).offer(task);
+            case ForkLiftMaster:
+                return FORK_LIFT_MASTER_EXCHANGE.get(id).offer(task);
+            case Lift:
+                return LIFT_EXCHANGE.get(id).offer(task);
             default:
                 return false;
         }
@@ -77,19 +70,54 @@
      */
     public static Task poll(SlaveType type, Integer id) {
         switch (type) {
-            case Crn:
-                return CRN_EXCHANGE.get(id).poll();
-            case Devp:
-                return DEVP_EXCHANGE.get(id).poll();
-            case Barcode:
-                return BARCODE_EXCHANGE.get(id).poll();
-            case Led:
-                return LED_EXCHANGE.get(id).poll();
-            case Scale:
-                return SCALE_EXCHANGE.get(id).poll();
+            case Shuttle:
+                return SHUTTLE_EXCHANGE.get(id).poll();
+            case ForkLift:
+                return FORK_LIFT_EXCHANGE.get(id).poll();
+            case ForkLiftMaster:
+                return FORK_LIFT_MASTER_EXCHANGE.get(id).poll();
+            case Lift:
+                return LIFT_EXCHANGE.get(id).poll();
             default:
                 return null;
         }
     }
 
+    /**
+     * 鍙栧嚭鍏冪礌锛屽苟涓嶅垹闄�.
+     */
+    public static Task peek(SlaveType type, Integer id) {
+        switch (type) {
+            case Shuttle:
+                return SHUTTLE_EXCHANGE.get(id).peek();
+            case ForkLift:
+                return FORK_LIFT_EXCHANGE.get(id).peek();
+            case ForkLiftMaster:
+                return FORK_LIFT_MASTER_EXCHANGE.get(id).peek();
+            case Lift:
+                return LIFT_EXCHANGE.get(id).peek();
+            default:
+                return null;
+        }
+    }
+
+    public static void clear(SlaveType type, Integer id){
+        switch (type) {
+            case Shuttle:
+                SHUTTLE_EXCHANGE.get(id).clear();
+                break;
+            case ForkLift:
+                FORK_LIFT_EXCHANGE.get(id).clear();
+                break;
+            case ForkLiftMaster:
+                FORK_LIFT_MASTER_EXCHANGE.get(id).clear();
+                break;
+            case Lift:
+                LIFT_EXCHANGE.get(id).clear();
+                break;
+            default:
+                break;
+        }
+    }
+
 }

--
Gitblit v1.9.1