lsfx请求方式修改

This commit is contained in:
wkc
2026-03-03 14:51:46 +08:00
parent 44ff30755f
commit beead1c908
3 changed files with 127 additions and 15 deletions

View File

@@ -1,16 +1,19 @@
package com.ruoyi.lsfx.client;
import com.ruoyi.lsfx.constants.LsfxConstants;
import com.ruoyi.lsfx.domain.request.*;
import com.ruoyi.lsfx.domain.request.FetchInnerFlowRequest;
import com.ruoyi.lsfx.domain.request.GetBankStatementRequest;
import com.ruoyi.lsfx.domain.request.GetTokenRequest;
import com.ruoyi.lsfx.domain.response.*;
import com.ruoyi.lsfx.exception.LsfxApiException;
import com.ruoyi.lsfx.util.HttpUtil;
import com.ruoyi.lsfx.util.MD5Util;
import com.ruoyi.lsfx.util.ObjectUtil;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import jakarta.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
@@ -64,18 +67,17 @@ public class LsfxAnalysisClient {
request.getEntityName(),
appSecret
);
request.setAppSecretCode(secretCode);
request.setAppId(appId);
if (request.getAnalysisType() == null) {
request.setAnalysisType(LsfxConstants.ANALYSIS_TYPE);
}
if (request.getRole() == null) {
request.setRole(LsfxConstants.DEFAULT_ROLE);
}
// 构建form-data参数使用ObjectUtil简化代码
Map<String, Object> params = ObjectUtil.toMapIgnoreNull(request);
// 添加特殊字段
params.put("appId", appId);
params.put("appSecretCode", secretCode);
params.put("role", request.getRole() != null ? request.getRole() : LsfxConstants.DEFAULT_ROLE);
params.put("analysisType", request.getAnalysisType() != null ? request.getAnalysisType() : LsfxConstants.ANALYSIS_TYPE);
String url = baseUrl + getTokenEndpoint;
GetTokenResponse response = httpUtil.postJson(url, request, null, GetTokenResponse.class);
GetTokenResponse response = httpUtil.postFormData(url, params, null, GetTokenResponse.class);
long elapsed = System.currentTimeMillis() - startTime;
if (response != null && response.getData() != null) {
@@ -142,10 +144,13 @@ public class LsfxAnalysisClient {
try {
String url = baseUrl + fetchInnerFlowEndpoint;
// 构建form-data参数使用ObjectUtil简化代码
Map<String, Object> params = ObjectUtil.toMapIgnoreNull(request);
Map<String, String> headers = new HashMap<>();
headers.put(LsfxConstants.HEADER_CLIENT_ID, clientId);
FetchInnerFlowResponse response = httpUtil.postJson(url, request, headers, FetchInnerFlowResponse.class);
FetchInnerFlowResponse response = httpUtil.postFormData(url, params, headers, FetchInnerFlowResponse.class);
long elapsed = System.currentTimeMillis() - startTime;
if (response != null && response.getData() != null) {
@@ -175,6 +180,7 @@ public class LsfxAnalysisClient {
try {
String url = baseUrl + checkParseStatusEndpoint;
// 构建form-data参数
Map<String, Object> params = new HashMap<>();
params.put("groupId", groupId);
params.put("inprogressList", inprogressList);
@@ -182,7 +188,7 @@ public class LsfxAnalysisClient {
Map<String, String> headers = new HashMap<>();
headers.put(LsfxConstants.HEADER_CLIENT_ID, clientId);
CheckParseStatusResponse response = httpUtil.postJson(url, params, headers, CheckParseStatusResponse.class);
CheckParseStatusResponse response = httpUtil.postFormData(url, params, headers, CheckParseStatusResponse.class);
long elapsed = System.currentTimeMillis() - startTime;
if (response != null && response.getData() != null) {
@@ -219,10 +225,13 @@ public class LsfxAnalysisClient {
try {
String url = baseUrl + getBankStatementEndpoint;
// 构建form-data参数使用ObjectUtil简化代码
Map<String, Object> params = ObjectUtil.toMapIgnoreNull(request);
Map<String, String> headers = new HashMap<>();
headers.put(LsfxConstants.HEADER_CLIENT_ID, clientId);
GetBankStatementResponse response = httpUtil.postJson(url, request, headers, GetBankStatementResponse.class);
GetBankStatementResponse response = httpUtil.postFormData(url, params, headers, GetBankStatementResponse.class);
long elapsed = System.currentTimeMillis() - startTime;
if (response != null && response.getData() != null) {