初次提交代码

This commit is contained in:
2026-01-11 15:33:22 +08:00
commit 6603c6f4a1
455 changed files with 32175 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
package com.common.schedule;
import com.common.service.EsToDbSyncService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
//众诚运维日志数据计划任务
@Slf4j
//@Component
public class ScheduledTask {
@Autowired
private EsToDbSyncService esToDbSyncService;
private static final DateTimeFormatter INDEX_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd");
/**
* 每天1点同步昨天的数据
*/
//c
public void syncYesterdayData() {
log.info("开始执行昨天数据同步任务");
LocalDate yesterday = LocalDate.now().minusDays(1);
String indexName = "applog-" + yesterday.format(INDEX_FORMATTER);
esToDbSyncService.syncEsLogsByIndexToDatabase(indexName);
log.info("昨天数据同步任务完成");
}
/**
* 每天1,5,9,13,17,21点同步今天的数据
*/
// @Scheduled(cron = "0 0 1,5,9,13,17,21 * * ?")
public void syncTodayData() {
log.info("开始执行今天数据同步任务");
LocalDate today = LocalDate.now();
String indexName = "applog-" + today.format(INDEX_FORMATTER);
esToDbSyncService.syncEsLogsByIndexToDatabase(indexName);
log.info("今天数据同步任务完成");
}
/**
* 手动同步指定日期的数据(可用于测试)
*/
public void syncSpecificDateData(LocalDate date) {
log.info("开始执行指定日期数据同步任务: {}", date);
String indexName = "applog-" + date.format(INDEX_FORMATTER);
esToDbSyncService.syncEsLogsByIndexToDatabase(indexName);
log.info("指定日期数据同步任务完成: {}", date);
}
}