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

38 lines
1.2 KiB
Java
Raw Normal View History

2026-04-27 10:27:57 +08:00
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>
* 定期检查并归档符合条件的标注结果
* 将已完成且超过自动归档超时时间的结果归档到历史表
*/
2026-04-27 10:27:57 +08:00
@Slf4j
@Component
@RequiredArgsConstructor
public class AutoArchiveAnnotationResultJob {
/**
* 标注结果归档服务
*/
2026-04-27 10:27:57 +08:00
private final AnnotationResultArchiveService annotationResultArchiveService;
/**
* 自动归档符合条件的标注结果
* <p>
* 定时执行默认每5分钟执行一次可通过配置调整执行间隔
* 归档完成后记录日志
*/
2026-04-27 10:27:57 +08:00
@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);
}
}
}