优化三重一大查询接口
This commit is contained in:
@@ -5,7 +5,6 @@ import com.aliyun.bailian20231229.models.RetrieveResponse;
|
||||
import com.aliyun.bailian20231229.models.RetrieveResponseBody;
|
||||
import com.aliyun.bailian20231229.models.RetrieveResponseBody.RetrieveResponseBodyData;
|
||||
import com.aliyun.bailian20231229.models.RetrieveResponseBody.RetrieveResponseBodyDataNodes;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
@@ -14,8 +13,6 @@ import com.gxwebsoft.ai.config.KnowledgeBaseConfig;
|
||||
import com.gxwebsoft.ai.factory.KnowledgeBaseClientFactory;
|
||||
import com.gxwebsoft.ai.service.AuditContent3TripleService;
|
||||
import com.gxwebsoft.ai.util.KnowledgeBaseUtil;
|
||||
import com.gxwebsoft.pwl.entity.PwlProjectLibrary;
|
||||
import com.gxwebsoft.pwl.service.PwlProjectLibraryService;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
@@ -27,7 +24,6 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@@ -40,9 +36,6 @@ public class AuditContent3TripleServiceImpl implements AuditContent3TripleServic
|
||||
@Autowired
|
||||
private KnowledgeBaseConfig config;
|
||||
|
||||
@Autowired
|
||||
private PwlProjectLibraryService pwlProjectLibraryService;
|
||||
|
||||
// 工作流配置
|
||||
private static final String TRIPLE_ONE_WORKFLOW_URL = "http://1.14.159.185:8180/v1/workflows/run";
|
||||
private static final String TRIPLE_ONE_TOKEN = "Bearer app-tjXbmHDE6daMbYOT4O13ev2X";
|
||||
@@ -120,10 +113,10 @@ public class AuditContent3TripleServiceImpl implements AuditContent3TripleServic
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject generateTripleOneTableData(String kbIds, String libraryIds, String projectLibrary,
|
||||
public JSONObject generateTripleOneTableData(String kbIds, String libraryKbIds, String projectLibrary,
|
||||
String userName, String history, String suggestion) {
|
||||
log.info("开始生成三重一大制度对比分析表数据 - 用户: {}, kbIds: {}, libraryIds: {}, projectLibrary: {}",
|
||||
userName, kbIds, libraryIds, projectLibrary);
|
||||
userName, kbIds, libraryKbIds, projectLibrary);
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
long startTime = System.currentTimeMillis();
|
||||
@@ -134,7 +127,7 @@ public class AuditContent3TripleServiceImpl implements AuditContent3TripleServic
|
||||
|
||||
for (String category : CATEGORY_ORDER) {
|
||||
CompletableFuture<JSONArray> future = generateCategoryDataAsync(
|
||||
category, kbIds, libraryIds, projectLibrary, userName, history, suggestion
|
||||
category, kbIds, libraryKbIds, projectLibrary, userName, history, suggestion
|
||||
);
|
||||
futures.put(category, future);
|
||||
}
|
||||
@@ -182,7 +175,7 @@ public class AuditContent3TripleServiceImpl implements AuditContent3TripleServic
|
||||
* 异步生成单个分类的数据
|
||||
*/
|
||||
@Async
|
||||
public CompletableFuture<JSONArray> generateCategoryDataAsync(String category, String kbIds, String libraryIds,
|
||||
public CompletableFuture<JSONArray> generateCategoryDataAsync(String category, String kbIds, String libraryKbIds,
|
||||
String projectLibrary, String userName,
|
||||
String history, String suggestion) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
@@ -191,7 +184,7 @@ public class AuditContent3TripleServiceImpl implements AuditContent3TripleServic
|
||||
|
||||
// 1. 为当前分类召回相关知识
|
||||
Map<String, List<String>> knowledgeSources = retrieveKnowledgeForCategory(
|
||||
category, kbIds, libraryIds, projectLibrary
|
||||
category, kbIds, libraryKbIds, projectLibrary
|
||||
);
|
||||
|
||||
// 2. 生成当前分类的数据
|
||||
@@ -214,7 +207,7 @@ public class AuditContent3TripleServiceImpl implements AuditContent3TripleServic
|
||||
* 为单个分类检索相关知识
|
||||
*/
|
||||
private Map<String, List<String>> retrieveKnowledgeForCategory(String category, String kbIds,
|
||||
String libraryIds, String projectLibrary) {
|
||||
String libraryKbIds, String projectLibrary) {
|
||||
Map<String, List<String>> knowledgeSources = new HashMap<>();
|
||||
knowledgeSources.put("enterprise", new ArrayList<>());
|
||||
knowledgeSources.put("regulation", new ArrayList<>());
|
||||
@@ -233,12 +226,7 @@ public class AuditContent3TripleServiceImpl implements AuditContent3TripleServic
|
||||
}
|
||||
|
||||
// 公共法律法规库检索
|
||||
if (StrUtil.isNotBlank(libraryIds)) {
|
||||
List<String> idList = StrUtil.split(libraryIds, ',');
|
||||
List<PwlProjectLibrary> ret = pwlProjectLibraryService.list(
|
||||
new LambdaQueryWrapper<PwlProjectLibrary>().in(PwlProjectLibrary::getId, idList));
|
||||
String libraryKbIds = ret.stream().map(PwlProjectLibrary::getKbId).collect(Collectors.joining(","));
|
||||
|
||||
if (StrUtil.isNotBlank(libraryKbIds)) {
|
||||
Arrays.stream(libraryKbIds.split(","))
|
||||
.map(String::trim)
|
||||
.filter(StrUtil::isNotBlank)
|
||||
|
||||
Reference in New Issue
Block a user