定点重置数据改成了定时器方式

This commit is contained in:
zlzw 2024-11-29 11:01:22 +08:00
parent 5ae1b474f9
commit 59a6641d50
2 changed files with 22 additions and 5 deletions

View File

@ -0,0 +1,22 @@
package com.yutou.bilibili.Tools;
import com.yutou.bilibili.services.LiveDanmuService;
import com.yutou.bilibili.services.LiveVideoDownloadService;
import jakarta.annotation.Resource;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
@EnableScheduling
public class ApplicationTime {
@Resource
LiveVideoDownloadService videoService;
@Resource
LiveDanmuService danmuService;
@Scheduled(cron = "1 0 * * * *")
public void reset(){
videoService.clearUserStopList();
danmuService.clearUserList();
}
}

View File

@ -37,7 +37,6 @@ public class SystemService {
return config.getTimerLoop(); return config.getTimerLoop();
} }
private final String resetTimer = "00:00:00 - 00:01:00";
public void start() { public void start() {
if (timer == null) { if (timer == null) {
@ -50,10 +49,6 @@ public class SystemService {
scheduled = timer.scheduleAtFixedRate(() -> { scheduled = timer.scheduleAtFixedRate(() -> {
List<LiveConfigDatabaseBean> list = databasesService.getConfigDatabase().getAllConfig(); List<LiveConfigDatabaseBean> list = databasesService.getConfigDatabase().getAllConfig();
Log.i("循环任务:" + list.size()); Log.i("循环任务:" + list.size());
if (DateFormatUtils.getInstance().checkTime(null, resetTimer)) {
videoService.clearUserStopList();
danmuService.clearUserList();
}
for (LiveConfigDatabaseBean bean : list) { for (LiveConfigDatabaseBean bean : list) {
try { try {
// 如果bean需要录制弹幕并且检查录制弹幕时间并且不需要同步直播弹幕则录制弹幕 // 如果bean需要录制弹幕并且检查录制弹幕时间并且不需要同步直播弹幕则录制弹幕