QA问答对审核功能以及历史记录归档管理优化
This commit is contained in:
@@ -9,6 +9,7 @@ import com.labelsys.backend.context.LoginUser;
|
||||
import com.labelsys.backend.dto.common.PageResult;
|
||||
import com.labelsys.backend.dto.request.AnnotationResultHistoryPageQuery;
|
||||
import com.labelsys.backend.dto.response.AnnotationResultHistoryResponse;
|
||||
import com.labelsys.backend.dto.response.FileContentResponse;
|
||||
import com.labelsys.backend.dto.response.MergeReviewResultResponse;
|
||||
import com.labelsys.backend.entity.AnnotationResult;
|
||||
import com.labelsys.backend.entity.AnnotationResultHistory;
|
||||
@@ -91,14 +92,19 @@ public class AnnotationResultArchiveService {
|
||||
private AnnotationResultHistoryResponse toResponse(AnnotationResultHistory history) {
|
||||
return new AnnotationResultHistoryResponse(
|
||||
history.getId(),
|
||||
history.getSourceResultId(),
|
||||
// history.getSourceResultId(),
|
||||
history.getTaskId(),
|
||||
history.getTaskName(), // 新增
|
||||
history.getResourceId(),
|
||||
history.getResourceName(), // 新增
|
||||
history.getQaContentFilePath(),
|
||||
history.getArchiveReason(),
|
||||
history.getArchivedBy(),
|
||||
history.getArchivedAt(),
|
||||
history.getCreatedAt()
|
||||
history.getCreatedAt(),
|
||||
history.getReviewerId(),
|
||||
history.getReviewerName(),
|
||||
history.getReviewerComment()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -135,7 +141,7 @@ public class AnnotationResultArchiveService {
|
||||
LocalDateTime archivedAt = LocalDateTime.now();
|
||||
|
||||
// 从对象存储读取 qa.json 内容
|
||||
String qaContentJson = loadQaContentJson(result);
|
||||
// String qaContentJson = loadQaContentJson(result);
|
||||
|
||||
AnnotationResultHistory history = AnnotationResultHistory.builder()
|
||||
.id(IdGenerator.nextId())
|
||||
@@ -144,12 +150,17 @@ public class AnnotationResultArchiveService {
|
||||
.creatorRole(result.getCreatorRole())
|
||||
.sourceResultId(result.getId())
|
||||
.taskId(result.getTaskId())
|
||||
.taskName(result.getTaskName())
|
||||
.resourceId(result.getResourceId())
|
||||
.resourceName(result.getResourceName())
|
||||
//.qaContentJson(qaContentJson) // 使用从对象存储读取的内容
|
||||
.qaContentFilePath(result.getQaContentFilePath())
|
||||
.archiveReason(archiveReason)
|
||||
.archivedBy(reviewerId)
|
||||
.archivedAt(archivedAt)
|
||||
.reviewerId(null)
|
||||
.reviewerName("auto")
|
||||
.reviewerComment("auto")
|
||||
.build();
|
||||
annotationResultHistoryMapper.insert(history);
|
||||
|
||||
@@ -208,4 +219,35 @@ public class AnnotationResultArchiveService {
|
||||
int firstSlash = filePath.indexOf('/');
|
||||
return firstSlash > 0 ? filePath.substring(firstSlash + 1) : "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载归档记录的文件内容
|
||||
* @param currentUser 当前用户
|
||||
* @param historyId 历史记录ID
|
||||
* @return 文件内容响应
|
||||
*/
|
||||
public FileContentResponse loadFileContent(LoginUser currentUser, Long historyId) {
|
||||
AnnotationResultHistory history = annotationResultHistoryMapper.selectById(historyId);
|
||||
if (history == null || !history.getCompanyId().equals(currentUser.companyId())) {
|
||||
throw new BusinessException(ResultCode.NOT_FOUND, "历史记录不存在");
|
||||
}
|
||||
//assertHistoryPermission(currentUser, history);
|
||||
|
||||
String filePath = history.getQaContentFilePath();
|
||||
if (filePath == null || filePath.isEmpty()) {
|
||||
throw new BusinessException(ResultCode.ERROR, "文件路径为空");
|
||||
}
|
||||
|
||||
try {
|
||||
String bucketName = extractBucketName(filePath);
|
||||
String objectKey = extractObjectKey(filePath);
|
||||
byte[] content = objectStorageService.download(bucketName, objectKey);
|
||||
String contentStr = new String(content, StandardCharsets.UTF_8);
|
||||
|
||||
return new FileContentResponse(filePath, contentStr, content.length);
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to load file content, historyId={}, filePath={}", historyId, filePath, e);
|
||||
throw new BusinessException(ResultCode.ERROR, "加载文件内容失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user