|
|
@@ -3,6 +3,7 @@ package shop.alien.lawyer.service.impl;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.cloud.context.config.annotation.RefreshScope;
|
|
|
import org.springframework.http.HttpEntity;
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
import org.springframework.http.MediaType;
|
|
|
@@ -25,6 +26,7 @@ import java.util.Map;
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
@RequiredArgsConstructor
|
|
|
+@RefreshScope
|
|
|
public class AiUserAuditTaskServiceImpl implements AiUserAuditTaskService {
|
|
|
|
|
|
private final RestTemplate restTemplate;
|
|
|
@@ -32,6 +34,9 @@ public class AiUserAuditTaskServiceImpl implements AiUserAuditTaskService {
|
|
|
@Value("${third-party-ai-auto-review.user-complaint-url:http://192.168.2.250:9100/ai/auto-review/api/v1/lawyer_user_complaint_audit_task/submit}")
|
|
|
private String aiUserAuditTaskUrl;
|
|
|
|
|
|
+ @Value("${third-party-ai-auto-review.lawyer-complaint-url:http://192.168.2.250:9100/ai/auto-review/api/v1/lawyer_complaint_audit_task/submit}")
|
|
|
+ private String aiAutoReviewUrl;
|
|
|
+
|
|
|
@Override
|
|
|
@Async("lawyerTaskExecutor")
|
|
|
public void asyncCallUserAuditTask(Map<String, Object> requestBody, String accessToken) {
|
|
|
@@ -64,5 +69,37 @@ public class AiUserAuditTaskServiceImpl implements AiUserAuditTaskService {
|
|
|
log.error("异步调用AI用户申诉接口异常,URL:{},异常信息:{}", aiUserAuditTaskUrl, e.getMessage(), e);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void asyncAiReview(Map<String, Object> requestBody, String accessToken) {
|
|
|
+ log.info("开始异步调用AI申诉接口,请求URL:{},请求参数:{}", aiUserAuditTaskUrl, requestBody);
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 初始化请求头(使用已获取的访问令牌)
|
|
|
+ HttpHeaders aiHeaders = new HttpHeaders();
|
|
|
+ aiHeaders.setContentType(MediaType.APPLICATION_JSON);
|
|
|
+ aiHeaders.set("Authorization", "Bearer " + accessToken);
|
|
|
+
|
|
|
+ HttpEntity<Map<String, Object>> request = new HttpEntity<>(requestBody, aiHeaders);
|
|
|
+
|
|
|
+ log.info("异步调用AI用户申诉接口,URL:{},请求头:{}", aiUserAuditTaskUrl, aiHeaders);
|
|
|
+
|
|
|
+ // 调用AI服务
|
|
|
+ ResponseEntity<String> responseEntity = restTemplate.postForEntity(
|
|
|
+ aiAutoReviewUrl, request, String.class);
|
|
|
+
|
|
|
+ log.info("异步调用AI用户申诉接口成功,响应状态:{},响应体:{}",
|
|
|
+ responseEntity.getStatusCode(), responseEntity.getBody());
|
|
|
+
|
|
|
+ } catch (HttpServerErrorException e) {
|
|
|
+ log.error("异步调用AI申诉接口返回服务器错误,状态码:{},响应体:{},URL:{}",
|
|
|
+ e.getStatusCode(), e.getResponseBodyAsString(), aiAutoReviewUrl, e);
|
|
|
+ } catch (HttpClientErrorException e) {
|
|
|
+ log.error("异步调用AI用户申诉接口返回客户端错误,状态码:{},响应体:{},URL:{}",
|
|
|
+ e.getStatusCode(), e.getResponseBodyAsString(), aiAutoReviewUrl, e);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("异步调用AI申诉接口异常,URL:{},异常信息:{}", aiAutoReviewUrl, e.getMessage(), e);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|