|
|
@@ -19,15 +19,10 @@ import org.apache.http.impl.client.HttpClients;
|
|
|
import org.apache.http.util.EntityUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.util.StringUtils;
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.net.URLEncoder;
|
|
|
-import java.nio.charset.StandardCharsets;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.UUID;
|
|
|
+
|
|
|
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
@@ -42,13 +37,6 @@ public class FastApiServiceImpl implements FastApiService {
|
|
|
|
|
|
@Override
|
|
|
public AiTaggingResponseVo tagging(AiTaggingRequestDto request) {
|
|
|
- // 如果 businessAttr 为空,生成 UUID
|
|
|
- if (!StringUtils.hasText(request.getBusinessAttr())) {
|
|
|
- String uuid = UUID.randomUUID().toString();
|
|
|
- request.setBusinessAttr(uuid);
|
|
|
- log.info("服务层自动生成 businessAttr: {}", uuid);
|
|
|
- }
|
|
|
-
|
|
|
String url = fastApiConfig.getUrl() + TAGGING_PATH;
|
|
|
log.info("调用 AI 打标接口:{}", url);
|
|
|
|
|
|
@@ -64,18 +52,13 @@ public class FastApiServiceImpl implements FastApiService {
|
|
|
String responseBody = EntityUtils.toString(response.getEntity(), "UTF-8");
|
|
|
log.info("AI 打标接口响应:{}", responseBody);
|
|
|
|
|
|
- AiTaggingResponseVo resultVo = JSON.parseObject(responseBody, AiTaggingResponseVo.class);
|
|
|
- // 将生成的 UUID 返回给前端
|
|
|
- resultVo.setBusinessAttr(request.getBusinessAttr());
|
|
|
- return resultVo;
|
|
|
+ return JSON.parseObject(responseBody, AiTaggingResponseVo.class);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
log.error("调用 AI 打标接口失败", e);
|
|
|
AiTaggingResponseVo errorResponse = new AiTaggingResponseVo();
|
|
|
errorResponse.setCode("500");
|
|
|
errorResponse.setMessage("调用 AI 打标接口失败:" + e.getMessage());
|
|
|
- // 错误时也要返回 UUID
|
|
|
- errorResponse.setBusinessAttr(request.getBusinessAttr());
|
|
|
return errorResponse;
|
|
|
}
|
|
|
}
|