2026-03-23 15:59:59 +08:00
|
|
|
package com.ruoyi.lsfx.client;
|
|
|
|
|
|
2026-05-13 14:20:42 +08:00
|
|
|
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;
|
|
|
|
|
|
2026-05-13 14:20:42 +08:00
|
|
|
@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();
|
2026-05-13 14:20:42 +08:00
|
|
|
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<>();
|
2026-05-13 14:20:42 +08:00
|
|
|
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
|
|
|
|
2026-05-13 14:20:42 +08:00
|
|
|
CreditParseInvokeResponse response = httpUtil.postUrlEncodedForm(
|
|
|
|
|
creditParseUrl, params, null, CreditParseInvokeResponse.class);
|
2026-03-23 15:59:59 +08:00
|
|
|
|
|
|
|
|
long elapsed = System.currentTimeMillis() - startTime;
|
2026-05-13 14:20:42 +08:00
|
|
|
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) {
|
2026-05-13 14:20:42 +08:00
|
|
|
log.error("【征信解析】调用失败: model={}, remotePath={}, error={}",
|
|
|
|
|
actualModel, remotePath, e.getMessage(), e);
|
2026-03-23 15:59:59 +08:00
|
|
|
throw new LsfxApiException("征信解析调用失败: " + e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-05-13 14:20:42 +08:00
|
|
|
|
|
|
|
|
private String buildSerialNum() {
|
|
|
|
|
return "CCDI_CREDIT_" + System.currentTimeMillis() + "_" + IdUtils.fastSimpleUUID();
|
|
|
|
|
}
|
2026-03-23 15:59:59 +08:00
|
|
|
}
|