QA问答对审核功能以及历史记录归档管理优化
This commit is contained in:
@@ -25,7 +25,6 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -48,6 +47,7 @@ public class AnnotationResultService {
|
||||
boolean shouldFilterByUserId = dataPermissionService.shouldFilterByUserId(currentUser);
|
||||
|
||||
var wrapper = new LambdaQueryWrapper<AnnotationResult>()
|
||||
.eq(AnnotationResult::getIsDeleted, Boolean.FALSE)
|
||||
.eq(AnnotationResult::getCompanyId, currentUser.companyId())
|
||||
.eq(query.taskId() != null, AnnotationResult::getTaskId, query.taskId())
|
||||
.eq(query.resourceId() != null, AnnotationResult::getResourceId, query.resourceId())
|
||||
@@ -95,7 +95,7 @@ public class AnnotationResultService {
|
||||
//assertResultPermission(currentUser, result);
|
||||
|
||||
QaContent qaContent = loadQaContent(result);
|
||||
DiffContent diffContent = StringUtils.hasText(result.getDiffSummaryFilePath()) ?
|
||||
DiffContent diffContent = Boolean.TRUE.equals(result.getRequiresManualReview()) ?
|
||||
loadDiffSummary(result) : null;
|
||||
|
||||
SourceResource resource = sourceResourceMapper.selectById(result.getResourceId());
|
||||
@@ -170,14 +170,15 @@ public class AnnotationResultService {
|
||||
saveQaContent(result, updatedQaContent);
|
||||
|
||||
// 更新数据库记录
|
||||
result.setIsDeleted(Boolean.TRUE);
|
||||
result.setReviewerId(currentUser.userId());
|
||||
result.setReviewComment(request.reviewComment());
|
||||
result.setReviewedAt(LocalDateTime.now());
|
||||
result.setRequiresManualReview(false);
|
||||
annotationResultMapper.updateById(result);
|
||||
|
||||
// 归档到历史表
|
||||
archiveToHistory(result, currentUser, "审核通过后归档");
|
||||
// 归档到历史表(人工审核后归档)
|
||||
archiveToHistory(result, currentUser, "审核通过后归档", false);
|
||||
|
||||
log.info("merged review result, companyId={}, userId={}, resultId={}",
|
||||
currentUser.companyId(), currentUser.userId(), resultId);
|
||||
@@ -187,7 +188,9 @@ public class AnnotationResultService {
|
||||
return new AnnotationResultResponse(
|
||||
result.getId(),
|
||||
result.getTaskId(),
|
||||
result.getTaskName(), // 新增
|
||||
result.getResourceId(),
|
||||
result.getResourceName(), // 新增
|
||||
deriveStatus(result),
|
||||
result.getRequiresManualReview(),
|
||||
result.getIsDeleted(),
|
||||
@@ -262,31 +265,55 @@ public class AnnotationResultService {
|
||||
}
|
||||
}
|
||||
|
||||
private void archiveToHistory(AnnotationResult result, LoginUser currentUser, String archiveReason) {
|
||||
/**
|
||||
* 归档到历史表
|
||||
* @param result 标注结果
|
||||
* @param currentUser 当前用户
|
||||
* @param archiveReason 归档原因
|
||||
* @param isAutoArchive 是否自动归档(true=自动归档,false=人工审核后归档)
|
||||
*/
|
||||
private void archiveToHistory(AnnotationResult result, LoginUser currentUser, String archiveReason, boolean isAutoArchive) {
|
||||
try {
|
||||
// 读取 qa.json 内容用于归档
|
||||
QaContent qaContent = loadQaContent(result);
|
||||
|
||||
// 构建归档记录
|
||||
AnnotationResultHistory history = AnnotationResultHistory.builder()
|
||||
AnnotationResultHistory.AnnotationResultHistoryBuilder historyBuilder = AnnotationResultHistory.builder()
|
||||
.id(IdGenerator.nextId())
|
||||
.companyId(result.getCompanyId())
|
||||
.creatorId(currentUser.userId())
|
||||
.creatorRole(currentUser.role().name())
|
||||
.creatorId(result.getCreatorId())
|
||||
.creatorRole(result.getCreatorRole())
|
||||
.sourceResultId(result.getId())
|
||||
.taskId(result.getTaskId())
|
||||
.taskName(result.getTaskName())
|
||||
.resourceId(result.getResourceId())
|
||||
.resourceName(result.getResourceName())
|
||||
//.qaContentJson(objectMapper.writeValueAsString(qaContent))
|
||||
.qaContentFilePath(result.getQaContentFilePath())
|
||||
.archiveReason(archiveReason)
|
||||
.archivedBy(currentUser.userId())
|
||||
.archivedAt(LocalDateTime.now())
|
||||
.createdAt(LocalDateTime.now())
|
||||
.build();
|
||||
.createdAt(LocalDateTime.now());
|
||||
|
||||
annotationResultHistoryMapper.insert(history);
|
||||
// 根据归档类型设置审核人信息
|
||||
if (isAutoArchive) {
|
||||
// 自动归档:reviewer_id为NULL,name和comment为"auto"
|
||||
historyBuilder
|
||||
.reviewerId(null)
|
||||
.reviewerName("auto")
|
||||
.reviewerComment("auto");
|
||||
} else {
|
||||
// 人工审核后归档:使用审核人信息
|
||||
historyBuilder
|
||||
.reviewerId(result.getReviewerId())
|
||||
.reviewerName(currentUser.realName())
|
||||
.reviewerComment(result.getReviewComment());
|
||||
}
|
||||
|
||||
log.info("archived result to history, resultId={}, historyId={}", result.getId(), history.getId());
|
||||
annotationResultHistoryMapper.insert(historyBuilder.build());
|
||||
|
||||
log.info("archived result to history, resultId={}, historyId={}, isAutoArchive={}",
|
||||
result.getId(), historyBuilder.build().getId(), isAutoArchive);
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to archive result to history, resultId={}", result.getId(), e);
|
||||
throw new BusinessException(ResultCode.ERROR, "归档失败");
|
||||
|
||||
Reference in New Issue
Block a user