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;
|
|
|
|
|
|
|
2026-05-13 23:29:43 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 标注结果自动归档定时任务
|
|
|
|
|
|
* <p>
|
|
|
|
|
|
* 定期检查并归档符合条件的标注结果,
|
|
|
|
|
|
* 将已完成且超过自动归档超时时间的结果归档到历史表。
|
|
|
|
|
|
*/
|
2026-04-27 10:27:57 +08:00
|
|
|
|
@Slf4j
|
|
|
|
|
|
@Component
|
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
|
public class AutoArchiveAnnotationResultJob {
|
|
|
|
|
|
|
2026-05-13 23:29:43 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 标注结果归档服务
|
|
|
|
|
|
*/
|
2026-04-27 10:27:57 +08:00
|
|
|
|
private final AnnotationResultArchiveService annotationResultArchiveService;
|
|
|
|
|
|
|
2026-05-13 23:29:43 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 自动归档符合条件的标注结果
|
|
|
|
|
|
* <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);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-05-13 23:29:43 +08:00
|
|
|
|
}
|