调整征信解析返回解析和日志
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.lsfx.client;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.uuid.IdUtils;
|
||||
import com.ruoyi.lsfx.domain.response.CreditParseInvokeResponse;
|
||||
@@ -20,6 +21,9 @@ public class CreditParseClient {
|
||||
@Resource
|
||||
private HttpUtil httpUtil;
|
||||
|
||||
@Resource
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
@Value("${credit-parse.api.url}")
|
||||
private String creditParseUrl;
|
||||
|
||||
@@ -39,8 +43,6 @@ public class CreditParseClient {
|
||||
public CreditParseInvokeResponse parse(String model, String remotePath) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
String actualModel = StringUtils.isBlank(model) ? defaultModel : model;
|
||||
log.info("【征信解析】开始调用: model={}, remotePath={}", actualModel, remotePath);
|
||||
|
||||
try {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("serialNum", buildSerialNum());
|
||||
@@ -49,8 +51,11 @@ public class CreditParseClient {
|
||||
params.put("remotePath", remotePath);
|
||||
params.put("model", actualModel);
|
||||
|
||||
CreditParseInvokeResponse response = httpUtil.postUrlEncodedForm(
|
||||
creditParseUrl, params, null, CreditParseInvokeResponse.class);
|
||||
log.info("【征信解析】调用请求: url={}, params={}", creditParseUrl, toJson(params));
|
||||
String responseJson = httpUtil.postUrlEncodedFormForString(creditParseUrl, params, null);
|
||||
log.info("【征信解析】调用返回JSON: {}", responseJson);
|
||||
|
||||
CreditParseInvokeResponse response = objectMapper.readValue(responseJson, CreditParseInvokeResponse.class);
|
||||
|
||||
long elapsed = System.currentTimeMillis() - startTime;
|
||||
log.info("【征信解析】调用完成: success={}, code={}, businessStatusCode={}, cost={}ms",
|
||||
@@ -70,4 +75,12 @@ public class CreditParseClient {
|
||||
private String buildSerialNum() {
|
||||
return "CCDI_CREDIT_" + System.currentTimeMillis() + "_" + IdUtils.fastSimpleUUID();
|
||||
}
|
||||
|
||||
private String toJson(Object value) {
|
||||
try {
|
||||
return objectMapper.writeValueAsString(value);
|
||||
} catch (Exception e) {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user