You've already forked FrameTour-BE
fix(task): 优化下载通知任务的执行频率和时间范围
- 移除未使用的ZtMessageProducerService和NotificationAuthUtils依赖注入 - 将定时任务执行时间从每天21点调整为每天9点和21点 - 将查询时间范围从24小时缩短为12小时,提高查询效率 - 保持用户去重逻辑以避免重复发送通知
This commit is contained in:
@@ -46,18 +46,14 @@ public class DownloadNotificationTasker {
|
||||
@Autowired
|
||||
private WechatSubscribeNotifyTriggerService notifyTriggerService;
|
||||
@Autowired
|
||||
private ZtMessageProducerService ztMessageProducerService;
|
||||
@Autowired
|
||||
private NotificationAuthUtils notificationAuthUtils;
|
||||
@Autowired
|
||||
private VideoTaskRepository videoTaskRepository;
|
||||
|
||||
@Scheduled(cron = "0 0 21 * * *")
|
||||
@Scheduled(cron = "0 0 9,21 * * *")
|
||||
public void sendDownloadNotification() {
|
||||
log.info("开始执行定时任务");
|
||||
// 用于记录已发送通知的用户ID,避免重复发送
|
||||
Set<Long> sentMemberIds = ConcurrentHashMap.newKeySet();
|
||||
videoMapper.listRelationByCreateTime(new Date(System.currentTimeMillis() - 24 * 60 * 60 * 1000), new Date())
|
||||
videoMapper.listRelationByCreateTime(new Date(System.currentTimeMillis() - 12 * 60 * 60 * 1000), new Date())
|
||||
.forEach(item -> {
|
||||
// 检查该用户是否已经发送过通知,避免重复发送
|
||||
if (sentMemberIds.contains(item.getMemberId())) {
|
||||
|
||||
Reference in New Issue
Block a user