优化审计内容生成时文件过滤功能
This commit is contained in:
@@ -85,16 +85,68 @@ public abstract class BaseAuditContentController extends BaseController {
|
|||||||
String libraryKbIds = "";
|
String libraryKbIds = "";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 查询项目库信息
|
// 查询公共库信息
|
||||||
libraryKbIds = getLibraryKbIds(request.getLibraryIds());
|
libraryKbIds = getLibraryKbIds(request.getLibraryIds());
|
||||||
|
|
||||||
|
// 如果有docList/fileList,计算去重的fileIds并设置到ThreadLocal
|
||||||
|
// if (hasUploadedFiles(request)) {
|
||||||
|
// Set<Integer> docIds = request.getDocList().stream().flatMap(docId -> aiCloudDocService.getSelfAndChildren(docId).stream()).map(AiCloudDoc::getId).collect(Collectors.toSet());
|
||||||
|
// List<AiCloudFile> relatedFiles = getRelatedFiles(docIds, request.getFileList());
|
||||||
|
// List<String> fileIds = relatedFiles.stream().map(AiCloudFile::getFileId).distinct().collect(Collectors.toList());
|
||||||
|
// Set<String> mainKbIds = Arrays.stream(request.getKbIds().split(",")).map(String::trim).filter(StrUtil::isNotBlank).collect(Collectors.toSet());
|
||||||
|
// AbstractAuditContentService.setRequestFileIds(mainKbIds, fileIds);
|
||||||
|
// }
|
||||||
|
|
||||||
// 如果有docList/fileList,计算去重的fileIds并设置到ThreadLocal
|
// 如果有docList/fileList,计算去重的fileIds并设置到ThreadLocal
|
||||||
if (hasUploadedFiles(request)) {
|
if (hasUploadedFiles(request)) {
|
||||||
Set<Integer> docIds = request.getDocList().stream().flatMap(docId -> aiCloudDocService.getSelfAndChildren(docId).stream()).map(AiCloudDoc::getId).collect(Collectors.toSet());
|
Set<Integer> docIds = request.getDocList().stream().flatMap(docId -> aiCloudDocService.getSelfAndChildren(docId).stream()).map(AiCloudDoc::getId).collect(Collectors.toSet());
|
||||||
List<AiCloudFile> relatedFiles = getRelatedFiles(docIds, request.getFileList());
|
List<AiCloudFile> relatedFiles = getRelatedFiles(docIds, request.getFileList());
|
||||||
List<String> fileIds = relatedFiles.stream().map(AiCloudFile::getFileId).distinct().collect(Collectors.toList());
|
|
||||||
Set<String> mainKbIds = Arrays.stream(request.getKbIds().split(",")).map(String::trim).filter(StrUtil::isNotBlank).collect(Collectors.toSet());
|
// 查询这些文件所属的目录类型
|
||||||
AbstractAuditContentService.setRequestFileIds(mainKbIds, fileIds);
|
Set<Integer> fileDocIds = relatedFiles.stream().map(AiCloudFile::getDocId).collect(Collectors.toSet());
|
||||||
|
Map<Integer, Integer> docTypeMap = aiCloudDocService.list(
|
||||||
|
new LambdaQueryWrapper<AiCloudDoc>()
|
||||||
|
.select(AiCloudDoc::getId, AiCloudDoc::getDocType)
|
||||||
|
.in(AiCloudDoc::getId, fileDocIds)
|
||||||
|
).stream().collect(Collectors.toMap(AiCloudDoc::getId, AiCloudDoc::getDocType));
|
||||||
|
|
||||||
|
// 区分项目库文件和公共库文件 (docType=3 为公共目录)
|
||||||
|
List<String> projectFileIds = new ArrayList<>();
|
||||||
|
List<String> libraryFileIds = new ArrayList<>();
|
||||||
|
for (AiCloudFile file : relatedFiles) {
|
||||||
|
Integer docType = docTypeMap.get(file.getDocId());
|
||||||
|
if (docType != null && docType == 3) {
|
||||||
|
libraryFileIds.add(file.getFileId());
|
||||||
|
} else {
|
||||||
|
projectFileIds.add(file.getFileId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
projectFileIds = projectFileIds.stream().distinct().collect(Collectors.toList());
|
||||||
|
libraryFileIds = libraryFileIds.stream().distinct().collect(Collectors.toList());
|
||||||
|
|
||||||
|
// 准备 kbIds 集合
|
||||||
|
Set<String> projectKbIds = Arrays.stream(request.getKbIds().split(","))
|
||||||
|
.map(String::trim).filter(StrUtil::isNotBlank).collect(Collectors.toSet());
|
||||||
|
Set<String> libraryKbIdsSet = Arrays.stream(libraryKbIds.split(","))
|
||||||
|
.map(String::trim).filter(StrUtil::isNotBlank).collect(Collectors.toSet());
|
||||||
|
|
||||||
|
// 确定需要过滤的知识库集合
|
||||||
|
Set<String> mainKbIds = new HashSet<>();
|
||||||
|
List<String> combinedFileIds = new ArrayList<>();
|
||||||
|
|
||||||
|
if (!projectFileIds.isEmpty()) {
|
||||||
|
mainKbIds.addAll(projectKbIds);
|
||||||
|
combinedFileIds.addAll(projectFileIds);
|
||||||
|
}
|
||||||
|
if (!libraryFileIds.isEmpty()) {
|
||||||
|
mainKbIds.addAll(libraryKbIdsSet);
|
||||||
|
combinedFileIds.addAll(libraryFileIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置到ThreadLocal(若mainKbIds为空,表示无需要过滤的文件,可传空集合或跳过)
|
||||||
|
if (!mainKbIds.isEmpty()) {
|
||||||
|
AbstractAuditContentService.setRequestFileIds(mainKbIds, combinedFileIds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成数据(使用原来的默认知识库)
|
// 生成数据(使用原来的默认知识库)
|
||||||
@@ -228,12 +280,25 @@ public abstract class BaseAuditContentController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 获取项目库KB IDs
|
* 获取项目库KB IDs
|
||||||
*/
|
*/
|
||||||
|
// protected String getLibraryKbIds(String libraryIds) {
|
||||||
|
// if (StrUtil.isBlank(libraryIds)) {
|
||||||
|
// return "";
|
||||||
|
// }
|
||||||
|
// List<String> idList = StrUtil.split(libraryIds, ',');
|
||||||
|
// List<PwlProjectLibrary> ret = pwlProjectLibraryService.list(new LambdaQueryWrapper<PwlProjectLibrary>().in(PwlProjectLibrary::getId, idList));
|
||||||
|
// return ret.stream().map(PwlProjectLibrary::getKbId).filter(StrUtil::isNotBlank).collect(Collectors.joining(","));
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取公共库KB IDs
|
||||||
|
*/
|
||||||
protected String getLibraryKbIds(String libraryIds) {
|
protected String getLibraryKbIds(String libraryIds) {
|
||||||
if (StrUtil.isBlank(libraryIds)) {
|
LambdaQueryWrapper<PwlProjectLibrary> wrapper = new LambdaQueryWrapper<>();
|
||||||
return "";
|
if (StrUtil.isNotBlank(libraryIds)) {
|
||||||
}
|
|
||||||
List<String> idList = StrUtil.split(libraryIds, ',');
|
List<String> idList = StrUtil.split(libraryIds, ',');
|
||||||
List<PwlProjectLibrary> ret = pwlProjectLibraryService.list(new LambdaQueryWrapper<PwlProjectLibrary>().in(PwlProjectLibrary::getId, idList));
|
wrapper.in(PwlProjectLibrary::getId, idList);
|
||||||
|
}
|
||||||
|
List<PwlProjectLibrary> ret = pwlProjectLibraryService.list(wrapper);
|
||||||
return ret.stream().map(PwlProjectLibrary::getKbId).filter(StrUtil::isNotBlank).collect(Collectors.joining(","));
|
return ret.stream().map(PwlProjectLibrary::getKbId).filter(StrUtil::isNotBlank).collect(Collectors.joining(","));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class AuditContentRequest {
|
|||||||
private Long projectId;
|
private Long projectId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 企业库
|
* 项目库
|
||||||
*/
|
*/
|
||||||
private String kbIds;
|
private String kbIds;
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ public class AuditContent11HistoryServiceImpl extends AbstractAuditContentServic
|
|||||||
.addAll(queryKnowledgeBase(kbId, queries, 150)));
|
.addAll(queryKnowledgeBase(kbId, queries, 150)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 审计报告库检索
|
// 法律法规库检索
|
||||||
if (StrUtil.isNotBlank(libraryKbIds)) {
|
if (StrUtil.isNotBlank(libraryKbIds)) {
|
||||||
Arrays.stream(libraryKbIds.split(","))
|
Arrays.stream(libraryKbIds.split(","))
|
||||||
.map(String::trim)
|
.map(String::trim)
|
||||||
@@ -92,7 +92,7 @@ public class AuditContent11HistoryServiceImpl extends AbstractAuditContentServic
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 法律法规库检索(从项目库)
|
// 审计报告库检索(从案例库)
|
||||||
if (StrUtil.isNotBlank(projectLibrary)) {
|
if (StrUtil.isNotBlank(projectLibrary)) {
|
||||||
knowledgeSources.get("regulations").addAll(
|
knowledgeSources.get("regulations").addAll(
|
||||||
queryKnowledgeBase(projectLibrary,
|
queryKnowledgeBase(projectLibrary,
|
||||||
|
|||||||
Reference in New Issue
Block a user