38 lines
1.2 KiB
Java
38 lines
1.2 KiB
Java
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);
|
||
}
|
||
}
|
||
} |