160 lines
4.8 KiB
Java
160 lines
4.8 KiB
Java
package com.ruoyi.lsfx.client;
|
|
|
|
import com.ruoyi.lsfx.constants.LsfxConstants;
|
|
import com.ruoyi.lsfx.domain.request.*;
|
|
import com.ruoyi.lsfx.domain.response.*;
|
|
import com.ruoyi.lsfx.util.HttpUtil;
|
|
import com.ruoyi.lsfx.util.MD5Util;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import jakarta.annotation.Resource;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* 流水分析平台客户端
|
|
*/
|
|
@Component
|
|
public class LsfxAnalysisClient {
|
|
|
|
@Resource
|
|
private HttpUtil httpUtil;
|
|
|
|
@Value("${lsfx.api.base-url}")
|
|
private String baseUrl;
|
|
|
|
@Value("${lsfx.api.app-id}")
|
|
private String appId;
|
|
|
|
@Value("${lsfx.api.app-secret}")
|
|
private String appSecret;
|
|
|
|
@Value("${lsfx.api.client-id}")
|
|
private String clientId;
|
|
|
|
@Value("${lsfx.api.endpoints.get-token}")
|
|
private String getTokenEndpoint;
|
|
|
|
@Value("${lsfx.api.endpoints.upload-file}")
|
|
private String uploadFileEndpoint;
|
|
|
|
@Value("${lsfx.api.endpoints.fetch-inner-flow}")
|
|
private String fetchInnerFlowEndpoint;
|
|
|
|
@Value("${lsfx.api.endpoints.check-parse-status}")
|
|
private String checkParseStatusEndpoint;
|
|
|
|
@Value("${lsfx.api.endpoints.generate-report}")
|
|
private String generateReportEndpoint;
|
|
|
|
@Value("${lsfx.api.endpoints.check-report-status}")
|
|
private String checkReportStatusEndpoint;
|
|
|
|
@Value("${lsfx.api.endpoints.get-bank-statement}")
|
|
private String getBankStatementEndpoint;
|
|
|
|
/**
|
|
* 获取Token
|
|
*/
|
|
public GetTokenResponse getToken(GetTokenRequest request) {
|
|
String secretCode = MD5Util.generateSecretCode(
|
|
request.getProjectNo(),
|
|
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);
|
|
}
|
|
|
|
String url = baseUrl + getTokenEndpoint;
|
|
return httpUtil.postJson(url, request, null, GetTokenResponse.class);
|
|
}
|
|
|
|
/**
|
|
* 上传文件
|
|
*/
|
|
public UploadFileResponse uploadFile(Integer groupId, org.springframework.core.io.Resource file) {
|
|
String url = baseUrl + uploadFileEndpoint;
|
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
params.put("groupId", groupId);
|
|
params.put("files", file);
|
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
headers.put(LsfxConstants.HEADER_CLIENT_ID, clientId);
|
|
|
|
return httpUtil.uploadFile(url, params, headers, UploadFileResponse.class);
|
|
}
|
|
|
|
/**
|
|
* 拉取行内流水
|
|
*/
|
|
public FetchInnerFlowResponse fetchInnerFlow(FetchInnerFlowRequest request) {
|
|
String url = baseUrl + fetchInnerFlowEndpoint;
|
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
headers.put(LsfxConstants.HEADER_CLIENT_ID, clientId);
|
|
|
|
return httpUtil.postJson(url, request, headers, FetchInnerFlowResponse.class);
|
|
}
|
|
|
|
/**
|
|
* 检查文件解析状态
|
|
*/
|
|
public CheckParseStatusResponse checkParseStatus(Integer groupId, String inprogressList) {
|
|
String url = baseUrl + checkParseStatusEndpoint;
|
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
params.put("groupId", groupId);
|
|
params.put("inprogressList", inprogressList);
|
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
headers.put(LsfxConstants.HEADER_CLIENT_ID, clientId);
|
|
|
|
return httpUtil.postJson(url, params, headers, CheckParseStatusResponse.class);
|
|
}
|
|
|
|
/**
|
|
* 生成尽调报告
|
|
*/
|
|
public GenerateReportResponse generateReport(GenerateReportRequest request) {
|
|
String url = baseUrl + generateReportEndpoint;
|
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
headers.put(LsfxConstants.HEADER_CLIENT_ID, clientId);
|
|
|
|
return httpUtil.postJson(url, request, headers, GenerateReportResponse.class);
|
|
}
|
|
|
|
/**
|
|
* 检查报告生成状态
|
|
*/
|
|
public CheckReportStatusResponse checkReportStatus(Integer groupId) {
|
|
String url = baseUrl + checkReportStatusEndpoint + "?groupId=" + groupId;
|
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
headers.put(LsfxConstants.HEADER_CLIENT_ID, clientId);
|
|
|
|
return httpUtil.get(url, headers, CheckReportStatusResponse.class);
|
|
}
|
|
|
|
/**
|
|
* 获取银行流水
|
|
*/
|
|
public GetBankStatementResponse getBankStatement(GetBankStatementRequest request) {
|
|
String url = baseUrl + getBankStatementEndpoint;
|
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
headers.put(LsfxConstants.HEADER_CLIENT_ID, clientId);
|
|
|
|
return httpUtil.postJson(url, request, headers, GetBankStatementResponse.class);
|
|
}
|
|
}
|