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);
    }


}
