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 | 99 ++++++++++++++----------------------------------- 1 files changed, 28 insertions(+), 71 deletions(-) diff --git a/src/main/java/com/zy/core/cache/MessageQueue.java b/src/main/java/com/zy/core/cache/MessageQueue.java index ec0be29..a7a9efd 100644 --- a/src/main/java/com/zy/core/cache/MessageQueue.java +++ b/src/main/java/com/zy/core/cache/MessageQueue.java @@ -7,7 +7,6 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.LinkedBlockingQueue; /** * 娑堟伅闃熷垪 @@ -15,43 +14,28 @@ */ public class MessageQueue { - // 杈撻�佺嚎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, LinkedBlockingQueue<Task>> LED_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<>(); //鍥涘悜绌挎杞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 Devp: - DEVP_EXCHANGE.put(slave.getId(), new ConcurrentLinkedQueue<>()); - break; - case Barcode: - BARCODE_EXCHANGE.put(slave.getId(), new ConcurrentLinkedQueue<>()); - break; - case Led: - LED_EXCHANGE.put(slave.getId(), new LinkedBlockingQueue<>(1)); - break; - case Scale: - SCALE_EXCHANGE.put(slave.getId(), new ConcurrentLinkedQueue<>()); - break; - case Car: - CAR_EXCHANGE.put(slave.getId(), new ConcurrentLinkedQueue<>()); - break; case Shuttle: SHUTTLE_EXCHANGE.put(slave.getId(), new ConcurrentLinkedQueue<>()); + break; + case ForkLift: + FORK_LIFT_EXCHANGE.put(slave.getId(), new ConcurrentLinkedQueue<>()); + break; + case ForkLiftMaster: + FORK_LIFT_MASTER_EXCHANGE.put(slave.getId(), new ConcurrentLinkedQueue<>()); break; case Lift: LIFT_EXCHANGE.put(slave.getId(), new ConcurrentLinkedQueue<>()); @@ -67,18 +51,12 @@ */ public static boolean offer(SlaveType type, Integer id, Task task) { switch (type) { - 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 Car: - return CAR_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: @@ -92,18 +70,12 @@ */ public static Task poll(SlaveType type, Integer id) { switch (type) { - 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 Car: - return CAR_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: @@ -116,18 +88,12 @@ */ public static Task peek(SlaveType type, Integer id) { switch (type) { - case Devp: - return DEVP_EXCHANGE.get(id).peek(); - case Barcode: - return BARCODE_EXCHANGE.get(id).peek(); - case Led: - return LED_EXCHANGE.get(id).peek(); - case Scale: - return SCALE_EXCHANGE.get(id).peek(); - case Car: - return CAR_EXCHANGE.get(id).peek(); 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: @@ -137,24 +103,15 @@ public static void clear(SlaveType type, Integer id){ switch (type) { - case Devp: - DEVP_EXCHANGE.get(id).clear(); - break; - case Barcode: - BARCODE_EXCHANGE.get(id).clear(); - break; - case Led: - LED_EXCHANGE.get(id).clear(); - break; - case Scale: - SCALE_EXCHANGE.get(id).clear(); - break; - case Car: - CAR_EXCHANGE.get(id).clear(); - break; 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; -- Gitblit v1.9.1