|
|
|
@ -1,5 +1,6 @@ |
|
|
|
package com.project.interaction.domain.service.impl; |
|
|
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
|
import com.project.information.domain.dto.KnowledgePointDTO; |
|
|
|
import com.project.interaction.domain.dto.ClusterQueryDTO; |
|
|
|
import com.project.interaction.domain.dto.ClusterResultDTO; |
|
|
|
@ -9,6 +10,7 @@ import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.web.reactive.function.client.WebClient; |
|
|
|
import reactor.core.publisher.Mono; |
|
|
|
|
|
|
|
import java.util.Collections; |
|
|
|
import java.util.List; |
|
|
|
@ -36,7 +38,16 @@ public class PostToClusteringDomainServiceImpl implements PostToClusteringDomain |
|
|
|
.uri(clusterUrl) |
|
|
|
.bodyValue(requestBody) |
|
|
|
.retrieve() |
|
|
|
.bodyToMono(ClusterResultDTO.class)// 错误处理
|
|
|
|
.bodyToMono(String.class) |
|
|
|
.flatMap(jsonStr -> Mono.fromCallable(() -> { |
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
// 第一次 readValue:去掉外层引号和转义符,把字符串变成正常的 JSON 格式
|
|
|
|
// 此时 unescapedJson 的值会变成 {"code": 200, "message": "请求成功!"}
|
|
|
|
String unescapedJson = mapper.readValue(jsonStr, String.class); |
|
|
|
|
|
|
|
// 第二次 readValue:将标准的 JSON 字符串解析为 DTO
|
|
|
|
return mapper.readValue(unescapedJson, ClusterResultDTO.class); |
|
|
|
})) |
|
|
|
.doOnError(error -> log.error(">>> [Interactor] 算法端推送异常, TaskId: {}, 原因: {}", |
|
|
|
taskId, error.getMessage())) |
|
|
|
// 结果处理(非阻塞订阅)
|
|
|
|
|