2026-03-02 10:14:09 +08:00
|
|
|
|
package com.ruoyi.lsfx.controller;
|
|
|
|
|
|
|
2026-03-03 16:11:03 +08:00
|
|
|
|
import com.ruoyi.common.annotation.Anonymous;
|
2026-03-02 10:14:09 +08:00
|
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
2026-03-03 09:35:27 +08:00
|
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
2026-03-02 10:14:09 +08:00
|
|
|
|
import com.ruoyi.lsfx.client.LsfxAnalysisClient;
|
2026-03-04 16:28:17 +08:00
|
|
|
|
import com.ruoyi.lsfx.constants.LsfxConstants;
|
2026-03-04 16:25:19 +08:00
|
|
|
|
import com.ruoyi.lsfx.domain.request.DeleteFilesRequest;
|
2026-03-03 16:11:03 +08:00
|
|
|
|
import com.ruoyi.lsfx.domain.request.FetchInnerFlowRequest;
|
|
|
|
|
|
import com.ruoyi.lsfx.domain.request.GetBankStatementRequest;
|
2026-03-04 16:25:19 +08:00
|
|
|
|
import com.ruoyi.lsfx.domain.request.GetFileUploadStatusRequest;
|
2026-03-03 16:11:03 +08:00
|
|
|
|
import com.ruoyi.lsfx.domain.request.GetTokenRequest;
|
2026-03-02 10:14:09 +08:00
|
|
|
|
import com.ruoyi.lsfx.domain.response.*;
|
|
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
2026-03-03 16:11:03 +08:00
|
|
|
|
import jakarta.annotation.Resource;
|
2026-03-02 10:14:09 +08:00
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 流水分析平台接口测试控制器
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Tag(name = "流水分析平台接口测试", description = "用于测试流水分析平台的7个接口")
|
2026-03-03 16:11:03 +08:00
|
|
|
|
@Anonymous
|
2026-03-02 10:14:09 +08:00
|
|
|
|
@RestController
|
|
|
|
|
|
@RequestMapping("/lsfx/test")
|
|
|
|
|
|
public class LsfxTestController {
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
private LsfxAnalysisClient lsfxAnalysisClient;
|
|
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "获取Token", description = "创建项目并获取访问Token")
|
|
|
|
|
|
@PostMapping("/getToken")
|
|
|
|
|
|
public AjaxResult getToken(@RequestBody GetTokenRequest request) {
|
2026-03-03 09:35:27 +08:00
|
|
|
|
// 参数校验
|
|
|
|
|
|
if (StringUtils.isBlank(request.getProjectNo())) {
|
|
|
|
|
|
return AjaxResult.error("参数不完整:projectNo为必填");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isBlank(request.getEntityName())) {
|
|
|
|
|
|
return AjaxResult.error("参数不完整:entityName为必填");
|
|
|
|
|
|
}
|
2026-03-04 16:28:17 +08:00
|
|
|
|
|
|
|
|
|
|
// 必填字段设置默认值
|
2026-03-03 09:35:27 +08:00
|
|
|
|
if (StringUtils.isBlank(request.getUserId())) {
|
2026-03-04 16:28:17 +08:00
|
|
|
|
request.setUserId(LsfxConstants.DEFAULT_USER_ID);
|
2026-03-03 09:35:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isBlank(request.getUserName())) {
|
2026-03-04 16:28:17 +08:00
|
|
|
|
request.setUserName(LsfxConstants.DEFAULT_USER_NAME);
|
2026-03-03 09:35:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isBlank(request.getOrgCode())) {
|
2026-03-04 16:28:17 +08:00
|
|
|
|
request.setOrgCode(LsfxConstants.DEFAULT_ORG_CODE);
|
2026-03-03 09:35:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isBlank(request.getDepartmentCode())) {
|
2026-03-04 16:28:17 +08:00
|
|
|
|
request.setDepartmentCode(LsfxConstants.DEFAULT_DEPARTMENT_CODE);
|
2026-03-03 09:35:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-02 10:14:09 +08:00
|
|
|
|
GetTokenResponse response = lsfxAnalysisClient.getToken(request);
|
|
|
|
|
|
return AjaxResult.success(response);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "上传流水文件", description = "上传银行流水文件到流水分析平台")
|
|
|
|
|
|
@PostMapping("/uploadFile")
|
|
|
|
|
|
public AjaxResult uploadFile(
|
|
|
|
|
|
@Parameter(description = "项目ID") @RequestParam Integer groupId,
|
|
|
|
|
|
@Parameter(description = "流水文件") @RequestParam("file") MultipartFile file
|
|
|
|
|
|
) {
|
2026-03-03 09:35:27 +08:00
|
|
|
|
// 参数校验
|
|
|
|
|
|
if (groupId == null || groupId <= 0) {
|
|
|
|
|
|
return AjaxResult.error("参数不完整:groupId为必填且大于0");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (file == null || file.isEmpty()) {
|
|
|
|
|
|
return AjaxResult.error("参数不完整:文件不能为空");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (file.getSize() > 10 * 1024 * 1024) { // 10MB限制
|
|
|
|
|
|
return AjaxResult.error("文件大小超过限制:最大10MB");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-03 16:25:53 +08:00
|
|
|
|
UploadFileResponse response = lsfxAnalysisClient.uploadFile(groupId, file);
|
2026-03-02 10:14:09 +08:00
|
|
|
|
return AjaxResult.success(response);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "拉取行内流水", description = "从数仓拉取行内流水数据")
|
|
|
|
|
|
@PostMapping("/fetchInnerFlow")
|
|
|
|
|
|
public AjaxResult fetchInnerFlow(@RequestBody FetchInnerFlowRequest request) {
|
2026-03-03 09:35:27 +08:00
|
|
|
|
// 参数校验
|
|
|
|
|
|
if (request.getGroupId() == null || request.getGroupId() <= 0) {
|
|
|
|
|
|
return AjaxResult.error("参数不完整:groupId为必填且大于0");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isEmpty(request.getCustomerNo())) {
|
|
|
|
|
|
return AjaxResult.error("参数不完整:customerNo为必填");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (request.getRequestDateId() == null) {
|
|
|
|
|
|
return AjaxResult.error("参数不完整:requestDateId为必填");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (request.getDataStartDateId() == null) {
|
|
|
|
|
|
return AjaxResult.error("参数不完整:dataStartDateId为必填");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (request.getDataEndDateId() == null) {
|
|
|
|
|
|
return AjaxResult.error("参数不完整:dataEndDateId为必填");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (request.getDataStartDateId() > request.getDataEndDateId()) {
|
|
|
|
|
|
return AjaxResult.error("参数错误:开始日期不能大于结束日期");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-04 16:28:17 +08:00
|
|
|
|
// 设置dataChannelCode默认值
|
|
|
|
|
|
if (StringUtils.isEmpty(request.getDataChannelCode())) {
|
|
|
|
|
|
request.setDataChannelCode(LsfxConstants.DEFAULT_DATA_CHANNEL_CODE);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-02 10:14:09 +08:00
|
|
|
|
FetchInnerFlowResponse response = lsfxAnalysisClient.fetchInnerFlow(request);
|
|
|
|
|
|
return AjaxResult.success(response);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "检查文件解析状态", description = "轮询检查上传文件的解析状态")
|
|
|
|
|
|
@PostMapping("/checkParseStatus")
|
|
|
|
|
|
public AjaxResult checkParseStatus(
|
|
|
|
|
|
@Parameter(description = "项目ID") @RequestParam Integer groupId,
|
|
|
|
|
|
@Parameter(description = "文件ID列表") @RequestParam String inprogressList
|
|
|
|
|
|
) {
|
2026-03-03 09:35:27 +08:00
|
|
|
|
// 参数校验
|
|
|
|
|
|
if (groupId == null || groupId <= 0) {
|
|
|
|
|
|
return AjaxResult.error("参数不完整:groupId为必填且大于0");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isEmpty(inprogressList)) {
|
|
|
|
|
|
return AjaxResult.error("参数不完整:inprogressList为必填");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-02 10:14:09 +08:00
|
|
|
|
CheckParseStatusResponse response = lsfxAnalysisClient.checkParseStatus(groupId, inprogressList);
|
|
|
|
|
|
return AjaxResult.success(response);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-02 22:10:10 +08:00
|
|
|
|
@Operation(summary = "获取银行流水列表(新版)",
|
|
|
|
|
|
description = "分页获取指定文件的银行流水数据,需要提供logId参数")
|
2026-03-02 10:14:09 +08:00
|
|
|
|
@PostMapping("/getBankStatement")
|
|
|
|
|
|
public AjaxResult getBankStatement(@RequestBody GetBankStatementRequest request) {
|
2026-03-02 22:10:10 +08:00
|
|
|
|
// 参数校验
|
|
|
|
|
|
if (request.getGroupId() == null) {
|
|
|
|
|
|
return AjaxResult.error("参数不完整:groupId为必填");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (request.getLogId() == null) {
|
|
|
|
|
|
return AjaxResult.error("参数不完整:logId为必填(文件ID)");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (request.getPageNow() == null || request.getPageNow() < 1) {
|
|
|
|
|
|
return AjaxResult.error("参数不完整:pageNow为必填且大于0");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (request.getPageSize() == null || request.getPageSize() < 1) {
|
|
|
|
|
|
return AjaxResult.error("参数不完整:pageSize为必填且大于0");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-02 10:14:09 +08:00
|
|
|
|
GetBankStatementResponse response = lsfxAnalysisClient.getBankStatement(request);
|
|
|
|
|
|
return AjaxResult.success(response);
|
|
|
|
|
|
}
|
2026-03-04 16:25:19 +08:00
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "获取单个文件上传状态",
|
|
|
|
|
|
description = "获取文件解析后的主体名称和账号等信息。status=-5且uploadStatusDesc='data.wait.confirm.newaccount'表示解析成功")
|
|
|
|
|
|
@GetMapping("/getFileUploadStatus")
|
|
|
|
|
|
public AjaxResult getFileUploadStatus(
|
|
|
|
|
|
@Parameter(description = "项目ID") @RequestParam Integer groupId,
|
|
|
|
|
|
@Parameter(description = "文件ID(可选,不传则查询所有)") @RequestParam(required = false) Integer logId
|
|
|
|
|
|
) {
|
|
|
|
|
|
// 参数校验
|
|
|
|
|
|
if (groupId == null || groupId <= 0) {
|
|
|
|
|
|
return AjaxResult.error("参数不完整:groupId为必填且大于0");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GetFileUploadStatusRequest request = new GetFileUploadStatusRequest();
|
|
|
|
|
|
request.setGroupId(groupId);
|
|
|
|
|
|
request.setLogId(logId);
|
|
|
|
|
|
|
|
|
|
|
|
GetFileUploadStatusResponse response = lsfxAnalysisClient.getFileUploadStatus(request);
|
|
|
|
|
|
return AjaxResult.success(response);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "删除文件",
|
|
|
|
|
|
description = "删除解析失败或不需要的流水文件")
|
|
|
|
|
|
@PostMapping("/deleteFiles")
|
|
|
|
|
|
public AjaxResult deleteFiles(@RequestBody DeleteFilesRequest request) {
|
|
|
|
|
|
// 参数校验
|
|
|
|
|
|
if (request.getGroupId() == null || request.getGroupId() <= 0) {
|
|
|
|
|
|
return AjaxResult.error("参数不完整:groupId为必填且大于0");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (request.getLogIds() == null || request.getLogIds().length == 0) {
|
|
|
|
|
|
return AjaxResult.error("参数不完整:logIds为必填且不能为空");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (request.getUserId() == null) {
|
|
|
|
|
|
return AjaxResult.error("参数不完整:userId为必填");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DeleteFilesResponse response = lsfxAnalysisClient.deleteFiles(request);
|
|
|
|
|
|
return AjaxResult.success(response);
|
|
|
|
|
|
}
|
2026-03-02 10:14:09 +08:00
|
|
|
|
}
|