索赔检核,retry机制
This commit is contained in:
@@ -19,7 +19,10 @@
|
|||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.retry</groupId>
|
||||||
|
<artifactId>spring-retry</artifactId>
|
||||||
|
</dependency>
|
||||||
<!--sentinel 依赖-->
|
<!--sentinel 依赖-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package com.volvo.ai.analytic.center.feign;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.retry.annotation.Backoff;
|
||||||
|
import org.springframework.retry.annotation.Retryable;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
@@ -16,6 +18,12 @@ public interface DiFyFeign {
|
|||||||
, produces = MediaType.APPLICATION_JSON_VALUE)
|
, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
JSONObject runWorkflows(@RequestHeader(value = "Authorization") String authorization, @RequestBody Map<String, Object> map);
|
JSONObject runWorkflows(@RequestHeader(value = "Authorization") String authorization, @RequestBody Map<String, Object> map);
|
||||||
|
|
||||||
|
@Retryable(maxAttempts = 1, backoff = @Backoff(delay = 1000))
|
||||||
|
@PostMapping(value = "v1/workflows/run"
|
||||||
|
, consumes = MediaType.APPLICATION_JSON_VALUE
|
||||||
|
, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
JSONObject runWorkflowsRetry(@RequestHeader(value = "Authorization") String authorization, @RequestBody Map<String, Object> map);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping(value = "/v1/files/upload" , consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
@PostMapping(value = "/v1/files/upload" , consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ public interface DiFyService {
|
|||||||
|
|
||||||
public Object getDiFyObject(DiFyReq diFyReq);
|
public Object getDiFyObject(DiFyReq diFyReq);
|
||||||
|
|
||||||
|
public Object getDiFyObjectRetry(DiFyReq diFyReq);
|
||||||
|
|
||||||
public JSONObject executeDifyFlow(DiFyReq diFyReq, String businessType, String businessData, String aiAnalysisRequestId);
|
public JSONObject executeDifyFlow(DiFyReq diFyReq, String businessType, String businessData, String aiAnalysisRequestId);
|
||||||
public JSONObject executeDifyFlow(DiFyReq diFyReq);
|
public JSONObject executeDifyFlow(DiFyReq diFyReq);
|
||||||
|
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ public class ClaimVerificationServiceImpl implements ClaimVerificationService {
|
|||||||
diFyReq.setFlowId(verificationToken);
|
diFyReq.setFlowId(verificationToken);
|
||||||
diFyReq.setInputs(parsedAudit);
|
diFyReq.setInputs(parsedAudit);
|
||||||
//调用dify 工作流
|
//调用dify 工作流
|
||||||
diFyObject = (JSONObject) diFyService.getDiFyObject(diFyReq);
|
diFyObject = (JSONObject) diFyService.getDiFyObjectRetry(diFyReq);
|
||||||
//处理结果并推送MQ
|
//处理结果并推送MQ
|
||||||
if (diFyObject == null) {
|
if (diFyObject == null) {
|
||||||
log.error("售后索赔检核审计报告dify返回结果为空");
|
log.error("售后索赔检核审计报告dify返回结果为空");
|
||||||
|
|||||||
@@ -48,6 +48,23 @@ public class DiFyServiceImpl implements DiFyService{
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getDiFyObjectRetry(DiFyReq diFyReq) {
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("inputs",diFyReq.getInputs());
|
||||||
|
map.put("response_mode","blocking");
|
||||||
|
map.put("user",diFyReq.getUser());
|
||||||
|
log.info("请求DiFy入参-Retry:{}",JSON.toJSONString(map));
|
||||||
|
JSONObject difyResult = diFyFeign.runWorkflowsRetry("Bearer "+diFyReq.getFlowId(),map);
|
||||||
|
log.info("请求DiFy响应结果:{}",difyResult.toJSONString());
|
||||||
|
JSONObject data = difyResult.getJSONObject("data");
|
||||||
|
if (data != null && "succeeded".equals(data.get("status"))){
|
||||||
|
JSONObject outputs = data.getJSONObject("outputs");
|
||||||
|
return outputs;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JSONObject executeDifyFlow(DiFyReq diFyReq, String businessType, String businessData, String oldAiAnalysisRequestId) {
|
public JSONObject executeDifyFlow(DiFyReq diFyReq, String businessType, String businessData, String oldAiAnalysisRequestId) {
|
||||||
String aiAnalysisRequestId = StringUtils.isEmpty(oldAiAnalysisRequestId)? AiAnalysisUtils.getAiAnalysisRequestId(businessType):oldAiAnalysisRequestId;
|
String aiAnalysisRequestId = StringUtils.isEmpty(oldAiAnalysisRequestId)? AiAnalysisUtils.getAiAnalysisRequestId(businessType):oldAiAnalysisRequestId;
|
||||||
|
|||||||
Reference in New Issue
Block a user