异常处理保存

This commit is contained in:
lxu75
2025-04-27 18:40:08 +08:00
parent 5ba35fa6a4
commit 89a12f94c6

View File

@@ -146,13 +146,33 @@ public class MqMessageRecordServiceImpl extends ServiceImpl<MqMessageRecordMappe
}
private void processDify(DiFyReq diFyReq, JSONArray difyResult, String aiAnalysisRequestId) throws InterruptedException, ExecutionException {
// 并行调用三个workflow
//舆情案件分析
CompletableFuture<JSONObject> caseWorkFlow = CompletableFuture.supplyAsync(() -> callCommunityWorkFlow(diFyReq,caseToken));
CompletableFuture<JSONObject> caseWorkFlow = CompletableFuture.supplyAsync(() -> callCommunityWorkFlow(diFyReq, caseToken))
.exceptionally(ex -> {
log.error("舆情案件分析失败: {}", ex.getMessage());
JSONObject errorResult = new JSONObject();
errorResult.put("error", "舆情案件分析失败: " + ex.getMessage());
return errorResult;
});
// 内容主题关键词打标
CompletableFuture<JSONObject> keywordWorkFlow = CompletableFuture.supplyAsync(() -> callCommunityWorkFlow(diFyReq,keywordToken));
CompletableFuture<JSONObject> keywordWorkFlow = CompletableFuture.supplyAsync(() -> callCommunityWorkFlow(diFyReq, keywordToken))
.exceptionally(ex -> {
log.error("内容主题关键词打标失败: {}", ex.getMessage());
JSONObject errorResult = new JSONObject();
errorResult.put("error", "内容主题关键词打标失败: " + ex.getMessage());
return errorResult;
});
// litecrm线索分析
CompletableFuture<JSONObject> clueAnalysisWorkFlow = CompletableFuture.supplyAsync(() -> callCommunityWorkFlow(diFyReq,clueAnalysisToken));
CompletableFuture<JSONObject> clueAnalysisWorkFlow = CompletableFuture.supplyAsync(() -> callCommunityWorkFlow(diFyReq, clueAnalysisToken))
.exceptionally(ex -> {
log.error("litecrm线索分析失败: {}", ex.getMessage());
JSONObject errorResult = new JSONObject();
errorResult.put("error", "litecrm线索分析失败: " + ex.getMessage());
return errorResult;
});
CompletableFuture<Void> allFutures = CompletableFuture.allOf(caseWorkFlow, keywordWorkFlow, clueAnalysisWorkFlow);
// 等待所有API调用完成
allFutures.get();