diff --git a/device-manager/src/main/java/com/mortals/xhx/common/utils/SmsQueueManager.java b/device-manager/src/main/java/com/mortals/xhx/common/utils/SmsQueueManager.java new file mode 100644 index 0000000000000000000000000000000000000000..07627821ae07477d8f7da02eb6b0c9202ddc4b83 --- /dev/null +++ b/device-manager/src/main/java/com/mortals/xhx/common/utils/SmsQueueManager.java @@ -0,0 +1,79 @@ +package com.mortals.xhx.common.utils; + +import com.mortals.xhx.module.alarm.model.AlarmSmsSendEntity; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.Queue; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.atomic.AtomicInteger; + + + +@Slf4j +@Data +public class SmsQueueManager { + /** + * 鍝嶅簲闃熷垪 + */ + public static Queue<AlarmSmsSendEntity> respQueue = new ConcurrentLinkedQueue<>(); + + /** + * 寰呮彁浜ょ煭淇$綉鍏抽槦鍒楀ぇ灏� 鍔犲叆闃熷垪鏃跺鍔狅紝鍙栧嚭闃熷垪鏃跺噺灏� + */ + public static AtomicInteger sendQueueSize = new AtomicInteger(0); + + /** + * 鐘舵€佹姤鍛婇槦鍒� + */ + public static Queue<AlarmSmsSendEntity> rptQueue = new ConcurrentLinkedQueue<>(); + + /** + * 鐘舵€佹姤鍛婃洿鏂伴槦鍒� + */ + public static Queue<AlarmSmsSendEntity> rptUpdateQueue = new ConcurrentLinkedQueue<>(); + + + /** + * 鑾峰彇鍙戦€侀槦鍒楀ぇ灏� + * + * @return + */ + public static int getSendQueueSize() { + return sendQueueSize.get(); + } + + + /** + * 鍙栧搷搴旈槦鍒楀ぇ灏� + * + * @return + */ + public static int getRespQueueSize() { + return respQueue.size(); + } + + /** + * 鍙栧嚭 鍝嶅簲 + * + * @return + */ + public static AlarmSmsSendEntity pollRespQueue() { + return respQueue.poll(); + } + + /** + * 鏀惧叆鍝嶅簲 + * + * @param SmsGateRespQueueEntity + */ + public static void offerRespQueue(AlarmSmsSendEntity SmsGateRespQueueEntity) { + if (null == SmsGateRespQueueEntity) { + return; + } + respQueue.offer(SmsGateRespQueueEntity); + } + + +}