|
|
|
|
@@ -10,6 +10,7 @@ import com.volvo.ai.analytic.center.constant.ClaimVerificationConstant;
|
|
|
|
|
import com.volvo.ai.analytic.center.constant.Constant;
|
|
|
|
|
import com.volvo.ai.analytic.center.dto.req.ClaimVerificationFileDTO;
|
|
|
|
|
import com.volvo.ai.analytic.center.dto.req.ClaimVerificationFileDTO.ClaimVerificationFile;
|
|
|
|
|
import com.volvo.ai.analytic.center.dto.req.ClaimVerificationPartHoursDTO;
|
|
|
|
|
import com.volvo.ai.analytic.center.dto.req.DiFyReq;
|
|
|
|
|
import com.volvo.ai.analytic.center.dto.req.RunMaskingRuleInput;
|
|
|
|
|
import com.volvo.ai.analytic.center.entity.*;
|
|
|
|
|
@@ -17,6 +18,7 @@ import com.volvo.ai.analytic.center.enums.BusinessTypeEnum;
|
|
|
|
|
import com.volvo.ai.analytic.center.enums.ClaimVerificationFileTypeEnums;
|
|
|
|
|
import com.volvo.ai.analytic.center.mapper.AiAnalysisErrorsMapper;
|
|
|
|
|
import com.volvo.ai.analytic.center.mapper.AiAnalyticWarrantyAuditMapper;
|
|
|
|
|
import com.volvo.ai.analytic.center.mapper.TmClaimVerificationPartHoursMappingMapper;
|
|
|
|
|
import com.volvo.ai.analytic.center.service.DataMaskingRuleService;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.commons.text.StringEscapeUtils;
|
|
|
|
|
@@ -49,6 +51,9 @@ public class ClaimVerificationServiceImpl implements ClaimVerificationService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private AiAnalyticBusinessConfigMapper aiAnalyticBusinessConfigMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private TmClaimVerificationPartHoursMappingMapper tmClaimVerificationPartHoursMappingMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private DiFyFeign diFyFeign;
|
|
|
|
|
|
|
|
|
|
@@ -61,7 +66,7 @@ public class ClaimVerificationServiceImpl implements ClaimVerificationService {
|
|
|
|
|
@Value("${dify.claimVerification.verificationToken}")
|
|
|
|
|
private String verificationToken;
|
|
|
|
|
|
|
|
|
|
@Value("${dify.claimVerification.fileToken}")
|
|
|
|
|
@Value("${dify.claimVerification.fileClassifyToken}")
|
|
|
|
|
private String fileClassifyToken;
|
|
|
|
|
|
|
|
|
|
@Value("${rocketmq.producer.claimVerification}")
|
|
|
|
|
@@ -109,7 +114,7 @@ public class ClaimVerificationServiceImpl implements ClaimVerificationService {
|
|
|
|
|
List<HashMap<String, String>> fileIds = new ArrayList<>();
|
|
|
|
|
log.info("文件分析文件ID:{}", fileObsPath);
|
|
|
|
|
//上传所有文件到dify
|
|
|
|
|
uploadFileToObs(fileObsPath, fileIds);
|
|
|
|
|
uploadFileToObs(fileObsPath, fileIds, fileToken);
|
|
|
|
|
//根据业务线标识和文件配置分类查询配置
|
|
|
|
|
List<AiAnalyticBusinessConfig> aiAnalyticBusinessConfigs = aiAnalyticBusinessConfigMapper.selectList(
|
|
|
|
|
Wrappers.<AiAnalyticBusinessConfig>lambdaQuery()
|
|
|
|
|
@@ -187,15 +192,7 @@ public class ClaimVerificationServiceImpl implements ClaimVerificationService {
|
|
|
|
|
List<HashMap<String, String>> fileIds = new ArrayList<>();
|
|
|
|
|
log.info("文件分类文件ID:{}", fileObsPath);
|
|
|
|
|
//上传所有文件到dify
|
|
|
|
|
uploadFileToObs(fileObsPath, fileIds);
|
|
|
|
|
//根据业务线标识和文件配置分类查询配置
|
|
|
|
|
List<AiAnalyticBusinessConfig> aiAnalyticBusinessConfigs = aiAnalyticBusinessConfigMapper.selectList(
|
|
|
|
|
Wrappers.<AiAnalyticBusinessConfig>lambdaQuery()
|
|
|
|
|
.eq(AiAnalyticBusinessConfig::getBusinessLine, BusinessTypeEnum.CLAIM_VERIFICATION.getCode())
|
|
|
|
|
.eq(AiAnalyticBusinessConfig::getFileConfigCategory, claimVerificationFileAnalysisDTO.getFileType())
|
|
|
|
|
.eq(AiAnalyticBusinessConfig::getIsDeleted, 0)
|
|
|
|
|
.eq(AiAnalyticBusinessConfig::getConfigVersion, 1)
|
|
|
|
|
);
|
|
|
|
|
uploadFileToObs(fileObsPath, fileIds, fileClassifyToken);
|
|
|
|
|
|
|
|
|
|
//组装文件分析workflow入参
|
|
|
|
|
JSONArray files = new JSONArray();
|
|
|
|
|
@@ -207,7 +204,8 @@ public class ClaimVerificationServiceImpl implements ClaimVerificationService {
|
|
|
|
|
files.add(object);
|
|
|
|
|
}
|
|
|
|
|
//构建入参
|
|
|
|
|
JSONObject fileToDifyDTO = buildFileToDifyParameter(files, claimVerificationFileAnalysisDTO, aiAnalyticBusinessConfigs);
|
|
|
|
|
JSONObject fileToDifyDTO = new JSONObject();
|
|
|
|
|
fileToDifyDTO.put("files", files);
|
|
|
|
|
//根据aiAnalysisRequestId更新请求日志表的difyRequest字段
|
|
|
|
|
syncUpdateDiFyRequest(fileToDifyDTO.toString(), aiAnalysisRequestId);
|
|
|
|
|
DiFyReq diFyReq = new DiFyReq();
|
|
|
|
|
@@ -305,9 +303,51 @@ public class ClaimVerificationServiceImpl implements ClaimVerificationService {
|
|
|
|
|
parsedAudit.put("preCheckUndesensitized", claimVerificationFileAnalysisDTO.getPreCheckReport() == null ? " " :claimVerificationFileAnalysisDTO.getPreCheckReport().toString());
|
|
|
|
|
parsedAudit.put("dtcUndesensitized", claimVerificationFileAnalysisDTO.getDtcReport() == null ? " " :claimVerificationFileAnalysisDTO.getDtcReport().toString());
|
|
|
|
|
parsedAudit.put("warrantyUndesensitized", claimVerificationFileAnalysisDTO.getWarrantyReport() == null ? " " :claimVerificationFileAnalysisDTO.getWarrantyReport().toString());
|
|
|
|
|
parsedAudit.put("partHoursConfig", claimVerificationFileAnalysisDTO.getWarrantyReport() == null ? " " :getPartHoursList(claimVerificationFileAnalysisDTO.getWarrantyReport()));
|
|
|
|
|
return parsedAudit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getPartHoursList(JSONObject warrantyJson) {
|
|
|
|
|
if (warrantyJson == null || !warrantyJson.containsKey("warrantyReport")) {
|
|
|
|
|
return " ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取warrantyReport对象
|
|
|
|
|
JSONObject warrantyReport = warrantyJson.getJSONObject("warrantyReport");
|
|
|
|
|
|
|
|
|
|
// 检查partItems是否存在且是数组
|
|
|
|
|
if (!warrantyReport.containsKey("partItems")) {
|
|
|
|
|
return " ";
|
|
|
|
|
} else {
|
|
|
|
|
Object value = warrantyReport.get("partItems");
|
|
|
|
|
if (!(value instanceof JSONArray)) {
|
|
|
|
|
return " ";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取partItems数组
|
|
|
|
|
JSONArray partItems = warrantyReport.getJSONArray("partItems");
|
|
|
|
|
List<String> partNoList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
// 遍历数组并提取partNo
|
|
|
|
|
for (int i = 0; i < partItems.size(); i++) {
|
|
|
|
|
JSONObject partItem = partItems.getJSONObject(i);
|
|
|
|
|
if (partItem.containsKey("partNo")) {
|
|
|
|
|
if (partItem.containsKey("isMain") && "10041001".equals(partItem.getString("isMain"))) {
|
|
|
|
|
partNoList.add(partItem.getString("partNo"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (partNoList.isEmpty()) {
|
|
|
|
|
return " ";
|
|
|
|
|
}
|
|
|
|
|
List<ClaimVerificationPartHoursDTO> result = tmClaimVerificationPartHoursMappingMapper.queryConfigByPartId(partNoList);
|
|
|
|
|
if (result.isEmpty()) {
|
|
|
|
|
return " ";
|
|
|
|
|
}
|
|
|
|
|
return JSONObject.toJSONString(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@NotNull
|
|
|
|
|
private static JSONObject getJsonObjectToNewBie(JSONObject diFyObject, ClaimVerificationFileDTO claimVerificationFileAnalysisDTO, String aiAnalysisRequestId) {
|
|
|
|
|
JSONObject warrantyAuditReport = diFyObject.getJSONObject("warrantyAuditReport");
|
|
|
|
|
@@ -405,15 +445,15 @@ public class ClaimVerificationServiceImpl implements ClaimVerificationService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void uploadFileToObs(List<String> fileObsPath, List<HashMap<String, String>> fileIds) {
|
|
|
|
|
private void uploadFileToObs(List<String> fileObsPath, List<HashMap<String, String>> fileIds, String uploadToken) {
|
|
|
|
|
if (fileObsPath != null && fileObsPath.size() > 0) {
|
|
|
|
|
for (String filePath : fileObsPath) {
|
|
|
|
|
HashMap<String, String> fileToDifyDTO = new HashMap<>();
|
|
|
|
|
ObsObject obsObject = ObsUtil.downloadFile(filePath);
|
|
|
|
|
InputStream inputStream = obsObject.getObjectContent();
|
|
|
|
|
MultipartFile file = ObsUtil.getMultipartFile(inputStream, ObsUtil.getFilenameByUrl(filePath));
|
|
|
|
|
log.info("索赔检核文件上传dify请求参数:{},token:{}", file, fileToken);
|
|
|
|
|
JSONObject fileUploadRes = diFyFeign.fileUpload("Bearer " + fileToken, file);
|
|
|
|
|
log.info("索赔检核文件上传dify请求参数:{},token:{}", file, uploadToken);
|
|
|
|
|
JSONObject fileUploadRes = diFyFeign.fileUpload("Bearer " + uploadToken, file);
|
|
|
|
|
log.info("索赔检核文件上传dify响应结果:{}", fileUploadRes);
|
|
|
|
|
String uploadFileId = fileUploadRes.getString(ClaimVerificationConstant.ID);
|
|
|
|
|
String extension = fileUploadRes.getString(ClaimVerificationConstant.EXTENSION);
|
|
|
|
|
|