调整代码不让MQ重试,只记录
This commit is contained in:
@@ -81,15 +81,14 @@ public class ClaimVerificationServiceImpl implements ClaimVerificationService {
|
||||
|
||||
@Override
|
||||
public void consumerMessageByMQ(String message) {
|
||||
|
||||
// 生成ai分析请求id
|
||||
String aiAnalysisRequestId = AiAnalysisUtils.getAiAnalysisRequestId(BusinessTypeEnum.CLAIM_VERIFICATION.getCode());
|
||||
log.info("售后索赔检核MQ message: {}", message);
|
||||
ClaimVerificationFileDTO claimVerificationFileAnalysisDTO = JSON.parseObject(message, ClaimVerificationFileDTO.class);
|
||||
if (claimVerificationFileAnalysisDTO == null) {
|
||||
log.error(" 售后索赔检核文件入参 is null");
|
||||
throw new RuntimeException(" 售后索赔检核文件分析入参为空");
|
||||
log.error("售后索赔检核文件入参为空: {}", claimVerificationFileAnalysisDTO.toString());
|
||||
saveException("售后索赔检核文件分析入参为空", aiAnalysisRequestId, null);
|
||||
}
|
||||
// 生成ai分析请求id
|
||||
String aiAnalysisRequestId = AiAnalysisUtils.getAiAnalysisRequestId(BusinessTypeEnum.CLAIM_VERIFICATION.getCode());
|
||||
JSONObject diFyObject = new JSONObject();
|
||||
try {
|
||||
// 异步保存请求日志
|
||||
@@ -131,7 +130,7 @@ public class ClaimVerificationServiceImpl implements ClaimVerificationService {
|
||||
//处理结果并推送MQ
|
||||
if (diFyObject == null) {
|
||||
log.error(" 售后索赔检核文件分析dify返回结果为空");
|
||||
throw new RuntimeException(" 售后索赔检核文件分析dify返回结果为空");
|
||||
saveException("售后索赔检核文件分析dify返回结果为空", aiAnalysisRequestId, null);
|
||||
} else {
|
||||
//解析dify返回结果
|
||||
JSONObject data = analyzeParameters(diFyObject, claimVerificationFileAnalysisDTO, aiAnalysisRequestId);
|
||||
@@ -159,13 +158,13 @@ public class ClaimVerificationServiceImpl implements ClaimVerificationService {
|
||||
DiFyReq diFyReq = new DiFyReq();
|
||||
diFyReq.setUser(BusinessTypeEnum.CLAIM_VERIFICATION.getCode());
|
||||
diFyReq.setFlowId(verificationToken);
|
||||
diFyReq.setInputs(parsedAudit);
|
||||
diFyReq.setInputs(parsedAudit.toString());
|
||||
//调用dify 工作流
|
||||
diFyObject = (JSONObject) diFyService.getDiFyObject(diFyReq);
|
||||
//处理结果并推送MQ
|
||||
if (diFyObject == null) {
|
||||
log.error("售后索赔检核审计报告dify返回结果为空");
|
||||
throw new RuntimeException(" 售后索赔检核审计报告dify返回结果为空");
|
||||
saveException("售后索赔检核审计报告dify返回结果为空", aiAnalysisRequestId, null);
|
||||
} else {
|
||||
JSONObject data = getJsonObjectToNewBie(diFyObject, claimVerificationFileAnalysisDTO, aiAnalysisRequestId);
|
||||
//返回结果推送到Newbie的MQ
|
||||
@@ -177,27 +176,37 @@ public class ClaimVerificationServiceImpl implements ClaimVerificationService {
|
||||
saveAuditCount(claimVerificationFileAnalysisDTO);
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException("售后索赔检核业务类型错误");
|
||||
saveException("售后索赔检核业务类型错误", aiAnalysisRequestId, null);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("售后索赔检核异常:{}", e.getMessage());
|
||||
//保存错误日志
|
||||
aiAnalysisErrorsMapper.insert(AiAnalysisErrors.builder()
|
||||
.aiAnalysisRequestId(aiAnalysisRequestId)
|
||||
.difyResponse(diFyObject.toString())
|
||||
.aiAnalysisErrorMessage(e.getMessage())
|
||||
.aiAnalysisRequestType(BusinessTypeEnum.CLAIM_VERIFICATION.getCode())
|
||||
.build());
|
||||
saveException(e.getMessage(), aiAnalysisRequestId, diFyObject);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存异常日志
|
||||
* @param errorMessage
|
||||
* @param aiAnalysisRequestId
|
||||
* @param diFyObject
|
||||
*/
|
||||
private void saveException(String errorMessage, String aiAnalysisRequestId, JSONObject diFyObject) {
|
||||
aiAnalysisErrorsMapper.insert(AiAnalysisErrors.builder()
|
||||
.aiAnalysisRequestId(aiAnalysisRequestId)
|
||||
.difyResponse(diFyObject == null ? null : diFyObject.toJSONString())
|
||||
.aiAnalysisErrorMessage(errorMessage)
|
||||
.aiAnalysisRequestType(BusinessTypeEnum.CLAIM_VERIFICATION.getCode())
|
||||
.build());
|
||||
}
|
||||
|
||||
private JSONObject buildAuditToDify(String configDataString, ClaimVerificationFileDTO claimVerificationFileAnalysisDTO) {
|
||||
JSONObject audit = new JSONObject();
|
||||
audit.put("analysisRules", configDataString);
|
||||
audit.put("diagnosticReport", claimVerificationFileAnalysisDTO.getDiagnosticReport().toString());
|
||||
audit.put("preCheckReport", claimVerificationFileAnalysisDTO.getPreCheckReport().toString());
|
||||
audit.put("dtcReport", claimVerificationFileAnalysisDTO.getDtcReport().toString());
|
||||
audit.put("diagnosticReport", claimVerificationFileAnalysisDTO.getDiagnosticReport());
|
||||
audit.put("preCheckReport", claimVerificationFileAnalysisDTO.getPreCheckReport());
|
||||
audit.put("dtcReport", claimVerificationFileAnalysisDTO.getDtcReport());
|
||||
|
||||
//脱敏处理
|
||||
List<DataMaskingRule> maskingRuleItems = dataMaskingRuleService.getDataMaskingRuleListByApplicationChannel(Constant.CHANNEL_DCC);
|
||||
@@ -285,6 +294,7 @@ public class ClaimVerificationServiceImpl implements ClaimVerificationService {
|
||||
Wrappers.<AiAnalyticWarrantyAudit>lambdaQuery()
|
||||
.eq(AiAnalyticWarrantyAudit::getNewBieAfterSalesId, claimVerificationFileAnalysisDTO.getNewBieAfterSalesId())
|
||||
.eq(AiAnalyticWarrantyAudit::getIsDeleted, 0)
|
||||
.last("for update") // 添加悲观锁
|
||||
);
|
||||
if (warrantyAudit != null) {
|
||||
//存在则auditCount+1
|
||||
|
||||
Reference in New Issue
Block a user