package com.zy.ai.timer;
|
|
import com.zy.ai.service.DataAnalysisCoordinatorService;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.stereotype.Component;
|
|
@Slf4j
|
@Component
|
public class DataAnalysisScheduler {
|
|
@Autowired
|
private DataAnalysisCoordinatorService dataAnalysisCoordinatorService;
|
|
@Scheduled(cron = "0 0 1 * * ?")
|
public void runDailyAnalysis() {
|
try {
|
DataAnalysisCoordinatorService.DataAnalysisCoordinatorResult result =
|
dataAnalysisCoordinatorService.runAnalysisIfEligible();
|
if (Boolean.TRUE.equals(result.getSkipped())) {
|
log.debug("Data analysis scheduler skipped, reason={}", result.getReason());
|
return;
|
}
|
log.info("Data analysis scheduler triggered, success={}",
|
result.getAgentResult() == null ? null : result.getAgentResult().getSuccess());
|
} catch (Exception e) {
|
log.error("Data analysis scheduler failed", e);
|
}
|
}
|
}
|