Files
lablesys_backend/src/main/java/com/labelsys/backend/scheduled/AutoArchiveAnnotationResultJob.java

38 lines
1.2 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.labelsys.backend.scheduled;
import com.labelsys.backend.service.AnnotationResultArchiveService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
/**
* 标注结果自动归档定时任务
* <p>
* 定期检查并归档符合条件的标注结果,
* 将已完成且超过自动归档超时时间的结果归档到历史表。
*/
@Slf4j
@Component
@RequiredArgsConstructor
public class AutoArchiveAnnotationResultJob {
/**
* 标注结果归档服务
*/
private final AnnotationResultArchiveService annotationResultArchiveService;
/**
* 自动归档符合条件的标注结果
* <p>
* 定时执行默认每5分钟执行一次可通过配置调整执行间隔。
* 归档完成后记录日志。
*/
@Scheduled(fixedDelayString = "${labelsys.annotation.auto-archive-fixed-delay:300000}")
public void autoArchiveEligibleResults() {
int archivedCount = annotationResultArchiveService.autoArchiveEligibleResults();
if (archivedCount > 0) {
log.info("auto archived annotation results, count={}", archivedCount);
}
}
}