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