Files
ccdi/ccdi-lsfx/src/main/java/com/ruoyi/lsfx/client/CreditParseClient.java

74 lines
2.7 KiB
Java
Raw Normal View History

2026-03-23 15:59:59 +08:00
package com.ruoyi.lsfx.client;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.lsfx.domain.response.CreditParseInvokeResponse;
2026-03-23 15:59:59 +08:00
import com.ruoyi.lsfx.exception.LsfxApiException;
import com.ruoyi.lsfx.util.HttpUtil;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
@Slf4j
@Component
public class CreditParseClient {
@Resource
private HttpUtil httpUtil;
@Value("${credit-parse.api.url}")
private String creditParseUrl;
@Value("${credit-parse.api.org-code:902000}")
private String orgCode;
@Value("${credit-parse.api.run-type:1}")
private String runType;
@Value("${credit-parse.api.model:LXCUSTALL}")
private String defaultModel;
public CreditParseInvokeResponse parse(String remotePath) {
return parse(defaultModel, remotePath);
}
public CreditParseInvokeResponse parse(String model, String remotePath) {
2026-03-23 15:59:59 +08:00
long startTime = System.currentTimeMillis();
String actualModel = StringUtils.isBlank(model) ? defaultModel : model;
log.info("【征信解析】开始调用: model={}, remotePath={}", actualModel, remotePath);
2026-03-23 15:59:59 +08:00
try {
Map<String, Object> params = new HashMap<>();
params.put("serialNum", buildSerialNum());
params.put("orgCode", orgCode);
params.put("runType", runType);
params.put("remotePath", remotePath);
params.put("model", actualModel);
2026-03-23 15:59:59 +08:00
CreditParseInvokeResponse response = httpUtil.postUrlEncodedForm(
creditParseUrl, params, null, CreditParseInvokeResponse.class);
2026-03-23 15:59:59 +08:00
long elapsed = System.currentTimeMillis() - startTime;
log.info("【征信解析】调用完成: success={}, code={}, businessStatusCode={}, cost={}ms",
response != null ? response.getSuccess() : null,
response != null ? response.getCode() : null,
response != null && response.getData() != null && response.getData().getMappingOutputFields() != null
? response.getData().getMappingOutputFields().getStatusCode() : null,
elapsed);
2026-03-23 15:59:59 +08:00
return response;
} catch (Exception e) {
log.error("【征信解析】调用失败: model={}, remotePath={}, error={}",
actualModel, remotePath, e.getMessage(), e);
2026-03-23 15:59:59 +08:00
throw new LsfxApiException("征信解析调用失败: " + e.getMessage(), e);
}
}
private String buildSerialNum() {
return "CCDI_CREDIT_" + System.currentTimeMillis() + "_" + IdUtils.fastSimpleUUID();
}
2026-03-23 15:59:59 +08:00
}