package com.ruoyi.common.event; import java.util.concurrent.atomic.AtomicInteger; import org.springframework.context.ApplicationEvent; /** *
* - 每秒都会触发的事件 * Author : J.L.Zhou * E-Mail : 2233875735@qq.com * Tel : 151 1104 7708 * Date : 2022年12月27日 下午3:10:39 * Version : 1.0 * Copyright 2022 jlzhou.top Inc. All rights reserved. * Warning: this content is only for internal circulation of the company. * It is forbidden to divulge it or use it for other commercial purposes. **/ public class PerSecondEvent extends ApplicationEvent { /** * */ private static final long serialVersionUID = 1752655123185832181L; private static AtomicInteger globalCount = new AtomicInteger(0); private static final int MAX = 24*365*60*60; private int count; public PerSecondEvent() { super(0); if(globalCount.incrementAndGet()>MAX) { globalCount.set(0); } count=globalCount.get(); super.source= count; } public int getCount() { return count; } @Override public String toString() { return " 每秒都会触发的事件: " + count; } }