数据总览优化

优化文件检索
This commit is contained in:
2025-11-06 16:18:40 +08:00
parent 4f224f37ef
commit 76b132b580
31 changed files with 623 additions and 532 deletions

View File

@@ -2,6 +2,8 @@ package com.sdm.data.controller;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.sdm.common.common.SdmResponse;
import com.sdm.common.entity.resp.PageDataResp;
import com.sdm.data.model.entity.FileStorage;
import com.sdm.data.model.req.AddUserQuotaEntity;
import com.sdm.data.model.req.ListUserQuotaReq;
import com.sdm.data.model.req.QueryBigFileReq;
@@ -28,26 +30,26 @@ public class DataStorageAnalysisController {
/**
* 根据nodeId(项目nodeId)获取指定查询类型queryNodeType文件空间占用(近几个月、增量查询)
* 查询项目存储空间占用:项目nodeId+项目queryNodeType
* 查询学科存储空间占用:项目nodeId+学科queryNodeType
* 查询项目存储空间占用:项目Uuid+项目queryNodeType
* 查询学科存储空间占用:项目Uuid+学科queryNodeType
*
* @param queryNodeType 需要统计的节点类型
* @param nodeId 节点id
* @param uuid 节点uuid
* @return
*/
@GetMapping("/getNodeSizeByNodeType")
@Operation(summary = "根据nodeId(项目nodeId)获取指定查询类型queryNodeType文件空间占用")
public SdmResponse getNodeSizeByNodeType(
@Parameter(description = "查询节点类型project,discipline") @RequestParam(value = "queryNodeType", required = false) String queryNodeType,
@Parameter(description = "节点id:项目nodeId") @RequestParam(value = "nodeId", required = false) Long nodeId,
@Parameter(description = "节点id:项目Uuid") @RequestParam(value = "uuid", required = false) String uuid,
@Parameter(description = "查询时间间隔(月)") @RequestParam(value = "intervalMonths", required = false) Integer intervalMonths,
@Parameter(description = "增量查询指定的月2025-06") @RequestParam(value = "targetYm", required = false) String targetYm
) {
try {
if (ObjectUtils.isEmpty(queryNodeType) || ObjectUtils.isEmpty(nodeId)) {
if (ObjectUtils.isEmpty(queryNodeType) || ObjectUtils.isEmpty(uuid)) {
return SdmResponse.success();
}
return dataStorageAnalysis.getNodeSizeByNodeType(queryNodeType, nodeId, intervalMonths, targetYm);
return dataStorageAnalysis.getNodeSizeByNodeType(queryNodeType, uuid, intervalMonths, targetYm);
} catch (Exception e) {
log.error("获取文件空间占用失败", e);
return SdmResponse.failed("获取文件空间占用");
@@ -71,7 +73,7 @@ public class DataStorageAnalysisController {
// 存储系统大文件筛选
@PostMapping("/listBigFile")
@Operation(summary = "存储系统大文件筛选")
public SdmResponse listBigFile(@RequestBody QueryBigFileReq queryBigFileReq){
public SdmResponse<PageDataResp<List<FileStorage>>> listBigFile(@RequestBody QueryBigFileReq queryBigFileReq){
return dataStorageAnalysis.listBigFile(queryBigFileReq);
}

View File

@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@@ -38,7 +37,11 @@ public class FileMetadataInfo implements Serializable {
@ApiModelProperty(value = "simulation_node关联的节点id")
@TableField("nodeId")
private Long nodeId;
private String relatedResourceUuid;
@ApiModelProperty(value = "关联对象类型node,task,run,performance")
@TableField("relatedResourceUuidOwnType")
private String relatedResourceUuidOwnType;
@ApiModelProperty(value = "逻辑文件组ID同一文件的所有版本共享一个ID")
@TableField("fileGroupId")
@@ -126,14 +129,6 @@ public class FileMetadataInfo implements Serializable {
@TableField("fileSize")
private Long fileSize;
@ApiModelProperty(value = "任务ID")
@TableField("taskId")
private String taskId;
@ApiModelProperty(value = "算列ID")
@TableField("runId")
private String runId;
@ApiModelProperty(value = "tag1")
@TableField("tag1")
private String tag1;

View File

@@ -53,9 +53,17 @@ public class FileStorage implements Serializable {
@TableField("dirId")
private Long dirId;
@ApiModelProperty(value = "文件类型如txt、jpg、pdf")
@TableField("fileType")
private String fileType;
@ApiModelProperty(value = "文件是否最新0-否1-是")
@TableField("isLatest")
private Integer isLatest;
@ApiModelProperty(value = "文件后缀如txt、jpg、pdf")
@TableField("fileSuffix")
private String fileSuffix;
@ApiModelProperty(value = "文件业务类型(如模型文件、仿真报告、计算文件、曲线文件、云图文件)")
@TableField("fileBizType")
private String fileBizType;
@ApiModelProperty(value = "文件大小(字节数,存储占用计算依据)")
@TableField("fileSize")

View File

@@ -9,6 +9,12 @@ public class DelDirReq {
@Schema(description = "删除的文件夹id", requiredMode = Schema.RequiredMode.REQUIRED)
private Long delDirId;
@Schema(description = "删除的项目节点id", requiredMode = Schema.RequiredMode.REQUIRED)
private String delUuid;
@Schema(description = "当前待删除节点uuid所属类型:node,task,run,performance")
private String delUuIdOwnType;
@Schema(description = "父路径")
private String parentPath;

View File

@@ -3,6 +3,8 @@ package com.sdm.data.model.req;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@Data
@Schema(description = "文件搜索请求参数")
public class FileSearchReq extends BaseReq {
@@ -34,7 +36,7 @@ public class FileSearchReq extends BaseReq {
* 父节点id
*/
@Schema(description = "父节点id")
private Long parentNodeId;
private String parentUuid;
/**
* 文件名称
@@ -43,4 +45,32 @@ public class FileSearchReq extends BaseReq {
private String fileName;
private Long createrId;
@Schema(description = "文件后缀")
private String fileSuffix;
/**
* 文件大小
*/
@Schema(description = "文件大小")
private Long fileSize;
/**
* 文件大小单位
*/
@Schema(description = "文件大小单位")
private String fileSizeUnit;
@Schema(description = "文件创建时间")
private LocalDateTime createTime;
@Schema(description = "文件业务类型1模型文件 2仿真报告、3计算文件、4曲线文件、5云图文件6网格文件7计算过程文件")
private String fileBizType;
/**
* 是否过滤空数据
*/
@Schema(description = "是否过滤空数据")
private boolean filterEmptyData;
}

View File

@@ -17,7 +17,7 @@ public class GetSimulationNodeTreeReq {
* 选择的节点ID
*/
@Schema(description = "选择的节点ID选中节点时才同时传chooseNodeId和chooseNodeType")
private Long chooseNodeId;
private String chooseUuid;
/**
* 选择的节点类型

View File

@@ -9,14 +9,11 @@ import java.time.LocalDateTime;
@Data
public class GetSimulationTaskFileReq extends BaseReq {
@Schema(description = "任务工况ID(simulationtTask的id)")
String taskId;
@Schema(description = "文件所属项目节点uuid")
private String uuid;
@Schema(description = "算列ID")
String runId;
@Schema(description = "文件类型", implementation = Constants.FileType.class)
Integer fileType;
@Schema(description = "文件类型", implementation = Constants.FileBizType.class)
Integer fileBizType;
@Schema(description = "文件名")
private String fileName;

View File

@@ -1,5 +1,6 @@
package com.sdm.data.model.req;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@@ -14,21 +15,31 @@ public class QueryBigFileReq extends BaseReq{
/**
* 文件名称
*/
@Schema(description = "文件名称")
private String fileName;
/**
* 文件创建时间 createTime
*/
@Schema(description = "文件创建时间")
private LocalDateTime createTime;
/**
* 文件大小
*/
@Schema(description = "文件大小")
private Long fileSize;
/**
* 文件大小单位
*/
@Schema(description = "文件大小单位")
private String fileSizeUnit;
@Schema(description = "文件后缀")
private String fileSuffix;
@Schema(description = "文件业务类型1模型文件 2仿真报告、3计算文件、4曲线文件、5云图文件6网格文件7计算过程文件")
private String fileBizType;
}

View File

@@ -32,10 +32,10 @@ public class QueryDirReq extends BaseReq{
Long fileId;
/**
* 节点ID
* 节点uuid
*/
@Schema(description = "节点ID")
Long nodeId;
String uuid;
// 查询文件或文件夹
@Schema(description = "查询文件或文件夹: 1-文件夹2-文件 不传查询全部 DataType ")

View File

@@ -7,9 +7,15 @@ import lombok.Data;
@Data
@Schema(description = "重命名文件夹请求参数")
public class RenameDirReq {
@Schema(description = "文件夹id", requiredMode = Schema.RequiredMode.REQUIRED)
@Schema(description = "待重命名文件夹id", requiredMode = Schema.RequiredMode.REQUIRED)
private Long dirId;
@Schema(description = "待重命名节点id", requiredMode = Schema.RequiredMode.REQUIRED)
private String uuid;
@Schema(description = "当前待重命名节点uuid所属类型:node,task,run,performance")
private String uuIdOwnType;
@Schema(description = "父路径", requiredMode = Schema.RequiredMode.REQUIRED)
private String parentPath;

View File

@@ -51,12 +51,12 @@ public class UploadFilesReq {
private Long dirId;
@Schema(description = "节点id")
private Long nodeId;
private String uuid;
@Schema(description = "文件名")
private String fileName;
@Schema(description = "文件类型 1模型文件 2仿真报告 3计算文件 4曲线文件 5云图文件",implementation = Constants.FileType.class)
@Schema(description = "文件类型 1模型文件 2仿真报告 3计算文件 4曲线文件 5云图文件",implementation = Constants.FileBizType.class)
private Integer fileType;
/**

View File

@@ -1,6 +1,8 @@
package com.sdm.data.service;
import com.sdm.common.common.SdmResponse;
import com.sdm.common.entity.resp.PageDataResp;
import com.sdm.data.model.entity.FileStorage;
import com.sdm.data.model.req.AddUserQuotaEntity;
import com.sdm.data.model.req.ListUserQuotaReq;
import com.sdm.data.model.req.QueryBigFileReq;
@@ -11,13 +13,13 @@ public interface DataStorageAnalysis {
/**
* 根据类型获取文件空间占用
*
* @param queryNodeType 节点类型(project,discipline)
* @param nodeId 节点id
* @param queryNodeType 节点类型(project,discipline)
* @param uuid 节点id
* @param intervalMonths 查询时间间隔(月)
* @param targetYm 增量查询指定的月2025-06
* @param targetYm 增量查询指定的月2025-06
* @return 文件总大小(字节)
*/
SdmResponse getNodeSizeByNodeType(String queryNodeType, Long nodeId, Integer intervalMonths, String targetYm);
SdmResponse getNodeSizeByNodeType(String queryNodeType, String uuid, Integer intervalMonths, String targetYm);
/**
* 根据用户id获取用户的空间占用
@@ -31,7 +33,7 @@ public interface DataStorageAnalysis {
/**
* 存储系统大文件筛选
*/
SdmResponse listBigFile(QueryBigFileReq queryBigFileReq);
SdmResponse<PageDataResp<List<FileStorage>>> listBigFile(QueryBigFileReq queryBigFileReq);
SdmResponse batchDeleteBigFile(List<Long> fileIds);

View File

@@ -36,11 +36,62 @@ public interface IDataFileService {
SdmResponse delDir(DelDirReq req);
/**
* 递归删除数据文件
* @param file 要删除的文件或目录
* @return 删除是否成功
* 查询文件夹下文件信息
* 1、知识库根据filedid查询
* 2、项目文件根据nodeId查询
* @param req 查询目录请求参数
* @return 目录信息响应
*/
boolean reverseDeleteDataFiles(File file);
SdmResponse queryDir(QueryDirReq req);
/**
* 下一层级目录树查询
*
* @param dirType
* @param parentDirId 父目录ID
* @return 目录内容列表响应
*/
default SdmResponse<List<FileMetadataInfoResp>> listDir(Integer dirType, Long parentDirId){
return null;
}
/**
* 重命名目录
* @param filePath 目录路径
* @param newName 新名称
* @param type 类型
* @return 重命名结果响应
*/
SdmResponse renameDir(String filePath, String newName, Integer type);
/**
* 重命名目录(新版本)
* @param req 重命名目录请求参数
* @return 重命名结果响应
*/
default SdmResponse renameDirNew(RenameDirReq req){
return null;
}
/**
* 上传文件
* @param req 上传文件请求参数
* @return 上传结果响应
*/
SdmResponse uploadFiles(UploadFilesReq req);
/**
* 更新文件信息
* 涉及更新文件版本号,支持历史文件版本的留存
* @param req 更新文件请求参数
* @return 更新结果响应
*/
default SdmResponse updateFile(UpdateFileReq req){
return null;
}
/**
* 删除文件
@@ -57,33 +108,13 @@ public interface IDataFileService {
SdmResponse fileSearch(FileSearchReq req);
/**
* 停止文件搜索
* @return 操作结果响应
* 重命名文件
* @param req 重命名文件请求参数
* @return 重命名结果响应
*/
SdmResponse fileSearchStop();
SdmResponse renameFile(RenameFileReq req);
/**
* 获取文件基本信息
* @param req 获取文件基本信息请求参数
* @return 文件基本信息响应
*/
SdmResponse getFileBaseInfo(GetFileBaseInfoReq req);
/**
* 查询文件夹下文件信息
* 1、知识库根据filedid查询
* 2、项目文件根据nodeId查询
* @param req 查询目录请求参数
* @return 目录信息响应
*/
SdmResponse queryDir(QueryDirReq req);
/**
* 查询文件权限值
* @param req 查询文件权限值请求参数
* @return 文件权限值响应
*/
SdmResponse queryFilePermValue(QueryFilePermValueReq req);
/**
* 查询权限信息
@@ -92,19 +123,6 @@ public interface IDataFileService {
*/
SdmResponse queryPermission(QueryPermissionReq req);
/**
* 查询用户文件权限
* @param req 查询用户文件权限请求参数
* @return 用户文件权限响应
*/
SdmResponse queryUserFilePermission(QueryUserFilePermissionReq req);
/**
* 重命名文件
* @param req 重命名文件请求参数
* @return 重命名结果响应
*/
SdmResponse renameFile(RenameFileReq req);
/**
* 更新权限信息
@@ -113,12 +131,6 @@ public interface IDataFileService {
*/
SdmResponse updatePermission(UpdatePermissionReq req);
/**
* 检查文件是否存在
* @param path 文件路径
* @return 文件存在性检查结果响应
*/
SdmResponse fileExists(String path);
/**
* 初始化系统目录
@@ -127,28 +139,7 @@ public interface IDataFileService {
*/
boolean initSystemDirectory(String company);
/**
* 复制文件
* @param req 复制文件请求参数
* @return 复制结果响应
*/
SdmResponse copyFile(CopyFileReq req);
/**
* 重命名目录
* @param filePath 目录路径
* @param newName 新名称
* @param type 类型
* @return 重命名结果响应
*/
SdmResponse renameDir(String filePath, String newName, Integer type);
/**
* 压缩文件
* @param req 压缩文件请求参数
* @return 压缩结果响应
*/
SdmResponse zipFiles(ZipFilesReq req);
/**
* 下载文件
@@ -164,26 +155,7 @@ public interface IDataFileService {
return null;
}
/**
* 上传文件
* @param req 上传文件请求参数
* @return 上传结果响应
*/
SdmResponse uploadFiles(UploadFilesReq req);
/**
* 添加下载记录
* @param req 添加下载记录请求参数
* @return 添加结果响应
*/
SdmResponse downloadRecord(AddDownloadRecordReq req);
/**
* 复制路由
* @param req 复制路由请求参数
* @return 复制结果响应
*/
SdmResponse copyRoute(CopyRouteReq req);
/**
* 初始化所有系统目录
@@ -191,35 +163,9 @@ public interface IDataFileService {
*/
SdmResponse initSystemDirectoryAll();
/**
* 目录树查询
*
* @param dirType
* @param parentDirId 父目录ID
* @return 目录内容列表响应
*/
default SdmResponse<List<FileMetadataInfoResp>> listDir(Integer dirType, Long parentDirId){
return null;
}
/**
* 重命名目录(新版本)
* @param req 重命名目录请求参数
* @return 重命名结果响应
*/
default SdmResponse renameDirNew(RenameDirReq req){
return null;
}
/**
* 更新文件信息
* 涉及更新文件版本号,支持历史文件版本的留存
* @param req 更新文件请求参数
* @return 更新结果响应
*/
default SdmResponse updateFile(UpdateFileReq req){
return null;
}
/**
* 上传头像
@@ -258,8 +204,87 @@ public interface IDataFileService {
return;
}
/**
* 获取文件预览URL
* @param fileId 文件id
* @return 文件预览URL响应
*/
default SdmResponse<KKFileViewURLFromMinioResp> getKKFileViewURLFromMinio(Long fileId){
return null;
}
/**
* 递归删除数据文件
* @param file 要删除的文件或目录
* @return 删除是否成功
*/
boolean reverseDeleteDataFiles(File file);
/**
* 停止文件搜索
* @return 操作结果响应
*/
SdmResponse fileSearchStop();
/**
* 获取文件基本信息
* @param req 获取文件基本信息请求参数
* @return 文件基本信息响应
*/
SdmResponse getFileBaseInfo(GetFileBaseInfoReq req);
/**
* 检查文件是否存在
* @param path 文件路径
* @return 文件存在性检查结果响应
*/
SdmResponse fileExists(String path);
/**
* 添加下载记录
* @param req 添加下载记录请求参数
* @return 添加结果响应
*/
SdmResponse downloadRecord(AddDownloadRecordReq req);
/**
* 复制路由
* @param req 复制路由请求参数
* @return 复制结果响应
*/
SdmResponse copyRoute(CopyRouteReq req);
/**
* 查询文件权限值
* @param req 查询文件权限值请求参数
* @return 文件权限值响应
*/
SdmResponse queryFilePermValue(QueryFilePermValueReq req);
/**
* 查询用户文件权限
* @param req 查询用户文件权限请求参数
* @return 用户文件权限响应
*/
SdmResponse queryUserFilePermission(QueryUserFilePermissionReq req);
/**
* 复制文件
* @param req 复制文件请求参数
* @return 复制结果响应
*/
SdmResponse copyFile(CopyFileReq req);
/**
* 压缩文件
* @param req 压缩文件请求参数
* @return 压缩结果响应
*/
SdmResponse zipFiles(ZipFilesReq req);
}

View File

@@ -5,15 +5,20 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sdm.common.common.SdmResponse;
import com.sdm.common.entity.resp.PageDataResp;
import com.sdm.common.utils.FileSizeUtils;
import com.sdm.common.utils.PageUtils;
import com.sdm.data.model.entity.FileMetadataInfo;
import com.sdm.data.model.entity.FileStorage;
import com.sdm.data.model.req.GetSimulationTaskFileReq;
import com.sdm.data.model.req.QueryBigFileReq;
import com.sdm.data.model.resp.SimulationTaskResultCurveResp;
import com.sdm.data.service.DataStorageAnalysis;
import com.sdm.data.service.IDataAnalysisService;
import com.sdm.data.service.IFileMetadataInfoService;
import com.sdm.data.service.IMinioService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -32,32 +37,42 @@ public class DataAnalysisServiceImpl implements IDataAnalysisService {
@Autowired
private IFileMetadataInfoService fileMetadataInfoService;
@Autowired
private DataStorageAnalysis dataStorageAnalysis;
@Autowired
private IMinioService MinIOService;
@Override
public SdmResponse getSimulationTaskFile(GetSimulationTaskFileReq getSimulationTaskFileReq) {
PageHelper.startPage(getSimulationTaskFileReq.getCurrent(), getSimulationTaskFileReq.getSize());
List<FileMetadataInfo> simulationTaskFileMetadataInfos = fileMetadataInfoService.lambdaQuery()
.eq(ObjectUtils.isNotNull(getSimulationTaskFileReq.getRunId()), FileMetadataInfo::getRunId, getSimulationTaskFileReq.getRunId())
.eq(ObjectUtils.isNotNull(getSimulationTaskFileReq.getTaskId()), FileMetadataInfo::getTaskId, getSimulationTaskFileReq.getTaskId())
.eq(ObjectUtils.isNotNull(getSimulationTaskFileReq.getTag1()), FileMetadataInfo::getTag1, getSimulationTaskFileReq.getTag1())
.eq(ObjectUtils.isNotNull(getSimulationTaskFileReq.getTag2()), FileMetadataInfo::getTag2, getSimulationTaskFileReq.getTag2())
.eq(ObjectUtils.isNotNull(getSimulationTaskFileReq.getTag3()), FileMetadataInfo::getTag3, getSimulationTaskFileReq.getTag3())
.eq(ObjectUtils.isNotNull(getSimulationTaskFileReq.getTag4()), FileMetadataInfo::getTag4, getSimulationTaskFileReq.getTag4())
.eq(ObjectUtils.isNotNull(getSimulationTaskFileReq.getTag5()), FileMetadataInfo::getTag5, getSimulationTaskFileReq.getTag5())
.eq(ObjectUtils.isNotNull(getSimulationTaskFileReq.getTag6()), FileMetadataInfo::getTag6, getSimulationTaskFileReq.getTag6())
.eq(ObjectUtils.isNotNull(getSimulationTaskFileReq.getTag7()), FileMetadataInfo::getTag7, getSimulationTaskFileReq.getTag7())
.eq(ObjectUtils.isNotNull(getSimulationTaskFileReq.getTag8()), FileMetadataInfo::getTag8, getSimulationTaskFileReq.getTag8())
.eq(ObjectUtils.isNotNull(getSimulationTaskFileReq.getTag9()), FileMetadataInfo::getTag9, getSimulationTaskFileReq.getTag9())
.eq(ObjectUtils.isNotNull(getSimulationTaskFileReq.getTag10()), FileMetadataInfo::getTag10, getSimulationTaskFileReq.getTag10())
.eq(ObjectUtils.isNotNull(getSimulationTaskFileReq.getFileType()), FileMetadataInfo::getFileType, getSimulationTaskFileReq.getFileType())
.like(ObjectUtils.isNotNull(getSimulationTaskFileReq.getFileName()), FileMetadataInfo::getOriginalName, getSimulationTaskFileReq.getFileName())
.ge(ObjectUtils.isNotNull(getSimulationTaskFileReq.getStartTime()), FileMetadataInfo::getCreateTime, getSimulationTaskFileReq.getStartTime())
.le(ObjectUtils.isNotNull(getSimulationTaskFileReq.getEndTime()), FileMetadataInfo::getCreateTime, getSimulationTaskFileReq.getEndTime())
FileMetadataInfo fileMetadataInfo = fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getRelatedResourceUuid, getSimulationTaskFileReq.getUuid()).one();
if(fileMetadataInfo == null) {
return SdmResponse.success();
}
QueryBigFileReq queryBigFileReq = new QueryBigFileReq();
BeanUtils.copyProperties(getSimulationTaskFileReq, queryBigFileReq);
queryBigFileReq.setDirId(fileMetadataInfo.getId());
SdmResponse<PageDataResp<List<FileStorage>>> searchResult = dataStorageAnalysis.listBigFile(queryBigFileReq);
PageDataResp<List<FileStorage>> pageDataResp = searchResult.getData();
List<FileStorage> data = pageDataResp.getData();
if(CollectionUtils.isEmpty(data)) {
return SdmResponse.success();
}
List<Long> fileIdList = data.stream().map(FileStorage::getFileId).toList();
List<FileMetadataInfo> simulationTaskFileMetadataInfos = fileMetadataInfoService
.lambdaQuery()
.in(FileMetadataInfo::getId, fileIdList)
.list();
PageInfo<FileMetadataInfo> pageInfo = new PageInfo<>(simulationTaskFileMetadataInfos);
pageInfo.setTotal(pageInfo.getTotal());
pageInfo.setPageNum(pageInfo.getPageNum());
pageInfo.setPages(pageInfo.getPages());
List<SimulationTaskResultCurveResp> taskResultCurveResps = simulationTaskFileMetadataInfos.stream().map(simulationTaskFile -> {
SimulationTaskResultCurveResp taskResultCurveResp = new SimulationTaskResultCurveResp();

View File

@@ -3,6 +3,7 @@ package com.sdm.data.service.impl;
import com.alibaba.fastjson2.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sdm.common.common.Constants;
import com.sdm.common.common.SdmResponse;
import com.sdm.common.common.ThreadLocalContext;
import com.sdm.common.entity.req.system.UserListReq;
@@ -11,7 +12,7 @@ import com.sdm.common.entity.resp.AllNodeByProjectIdAndTypeResp;
import com.sdm.common.entity.resp.PageDataResp;
import com.sdm.common.entity.resp.system.CIDUserResp;
import com.sdm.common.utils.FileSizeUtils;
import com.sdm.common.feign.impl.project.SimuluationNodeFeignClientImpl;
import com.sdm.common.feign.impl.project.SimulationNodeFeignClientImpl;
import com.sdm.common.feign.impl.system.SysUserFeignClientImpl;
import com.sdm.common.utils.PageUtils;
import com.sdm.data.model.dto.NodeSizeDTO;
@@ -26,7 +27,6 @@ import com.sdm.data.model.req.QueryBigFileReq;
import com.sdm.data.service.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@@ -48,7 +48,7 @@ public class DataStorageAnalysisImpl implements DataStorageAnalysis {
IFileStorageService fileStorageService;
@Autowired
SimuluationNodeFeignClientImpl simuluationNodeFeignClient;
SimulationNodeFeignClientImpl simuluationNodeFeignClient;
@Autowired
SysUserFeignClientImpl sysUserFeignClient;
@@ -59,8 +59,8 @@ public class DataStorageAnalysisImpl implements DataStorageAnalysis {
@Autowired
IFileStorageQuotaService fileStorageQuotaService;
public SdmResponse getNodeSizeByNodeType(String queryNodeType, Long nodeId, Integer intervalMonths, String targetYm) {
SdmResponse<List<AllNodeByProjectIdAndTypeResp>> response = simuluationNodeFeignClient.getAllNodeByProjectIdAndType(nodeId, queryNodeType);
public SdmResponse getNodeSizeByNodeType(String queryNodeType, String uuid, Integer intervalMonths, String targetYm) {
SdmResponse<List<AllNodeByProjectIdAndTypeResp>> response = simuluationNodeFeignClient.getAllNodeByProjectIdAndType(uuid, queryNodeType);
if (!response.isSuccess()) {
return SdmResponse.failed("获取节点信息失败");
}
@@ -68,27 +68,27 @@ public class DataStorageAnalysisImpl implements DataStorageAnalysis {
List<AllNodeByProjectIdAndTypeResp> nodeLists = response.getData();
// nodeid1-学科1 nodeid2-学科1 转换成 valueToKeysMap: 学科1->[nodeid1,nodeid2] 学科2->[nodeid3,nodeid4]
Map<String, List<Long>> valueToKeysMap = nodeLists.stream()
// uuid1-学科1 uuid2-学科1 转换成 valueToKeysMap: 学科1->[uuid1,uuid2] 学科2->[uuid3,uuid4]
Map<String, List<String>> nodeNameToUuidListMap = nodeLists.stream()
.collect(Collectors.groupingBy(
AllNodeByProjectIdAndTypeResp::getNodeName,
Collectors.mapping(AllNodeByProjectIdAndTypeResp::getId, Collectors.toList())
Collectors.mapping(AllNodeByProjectIdAndTypeResp::getUuid, Collectors.toList())
));
List<JSONObject> result = new ArrayList<>();
//nodeIds获取所有节点id: [nodeid1,nodeid2,nodeid3,nodeid4]
List<Long> nodeIds = nodeLists.stream().map(AllNodeByProjectIdAndTypeResp::getId).collect(Collectors.toList());
if (ObjectUtils.isNotEmpty(nodeIds)) {
// nodeIdToNodeDirIdMap :获取nodeid->fileID映射
Map<Long, Long> nodeIdToNodeDirIdMap = fileMetadataInfoService.lambdaQuery().select(FileMetadataInfo::getId, FileMetadataInfo::getNodeId)
.in(FileMetadataInfo::getNodeId, nodeIds)
.list().stream().collect(Collectors.toMap(FileMetadataInfo::getNodeId, FileMetadataInfo::getId));
if (CollectionUtils.isEmpty(nodeIdToNodeDirIdMap)) {
List<String> uuids = nodeLists.stream().map(AllNodeByProjectIdAndTypeResp::getUuid).collect(Collectors.toList());
if (ObjectUtils.isNotEmpty(uuids)) {
// uuidToDirIdMap :获取uuid->fileID映射
Map<String, Long> uuidToDirIdMap = fileMetadataInfoService.lambdaQuery().select(FileMetadataInfo::getId, FileMetadataInfo::getRelatedResourceUuid)
.in(FileMetadataInfo::getRelatedResourceUuid, uuids)
.list().stream().collect(Collectors.toMap(FileMetadataInfo::getRelatedResourceUuid, FileMetadataInfo::getId));
if (CollectionUtils.isEmpty(uuidToDirIdMap)) {
return SdmResponse.failed("获取节点信息失败");
}
// fileMetadIds: nodeid对应的fileid结合
List<Long> fileMetadIds = new ArrayList<>(nodeIdToNodeDirIdMap.values());
// fileMetadIds: uuid对应的fileid结合
List<Long> fileMetadIds = new ArrayList<>(uuidToDirIdMap.values());
// nodeSizeDTOS: 获取所有node节点目录空间
List<NodeSizeDTO> nodeSizeDTOS = null;
@@ -108,10 +108,10 @@ public class DataStorageAnalysisImpl implements DataStorageAnalysis {
// nodeSizeDTOMaps: 节点的fileid --> filesize
Map<Long, Long> nodeSizeDTOMaps = nodeSizeDTOS.stream().collect(Collectors.toMap(NodeSizeDTO::getDirId, NodeSizeDTO::getTotalSize));
valueToKeysMap.forEach((nodeName, nodeIdList) -> {
nodeNameToUuidListMap.forEach((nodeName, uuidList) -> {
AtomicLong totalSize = new AtomicLong();
nodeIdList.forEach(nodeid -> {
Long dirId = nodeIdToNodeDirIdMap.get(nodeid);
uuidList.forEach(uuidItem -> {
Long dirId = uuidToDirIdMap.get(uuidItem);
Long filesize = nodeSizeDTOMaps.get(dirId);
if (ObjectUtils.isNotEmpty(filesize)) {
totalSize.addAndGet(filesize);
@@ -165,7 +165,7 @@ public class DataStorageAnalysisImpl implements DataStorageAnalysis {
}
@Override
public SdmResponse listBigFile(QueryBigFileReq queryBigFileReq) {
public SdmResponse<PageDataResp<List<FileStorage>>> listBigFile(QueryBigFileReq queryBigFileReq) {
// 将前端传入的 fileSize 和 fileSizeUnit 转换为字节(B)
Long fileSizeInBytes = null;
if (queryBigFileReq.getFileSize() != null && queryBigFileReq.getFileSizeUnit() != null) {
@@ -174,7 +174,10 @@ public class DataStorageAnalysisImpl implements DataStorageAnalysis {
PageHelper.startPage(queryBigFileReq.getCurrent(), queryBigFileReq.getSize());
List<FileStorage> list = fileStorageService.lambdaQuery()
.eq(FileStorage::getIsLatest, Constants.FileIsLast.YES.getValue())
.eq(ObjectUtils.isNotEmpty(queryBigFileReq.getDirId()), FileStorage::getDirId, queryBigFileReq.getDirId())
.eq(ObjectUtils.isNotEmpty(queryBigFileReq.getFileSuffix()), FileStorage::getFileSuffix, queryBigFileReq.getFileSuffix())
.eq(ObjectUtils.isNotEmpty(queryBigFileReq.getFileBizType()), FileStorage::getFileBizType, queryBigFileReq.getFileBizType())
.like(ObjectUtils.isNotEmpty(queryBigFileReq.getFileName()), FileStorage::getFileName, queryBigFileReq.getFileName())
.gt(ObjectUtils.isNotEmpty(queryBigFileReq.getCreateTime()), FileStorage::getCreateTime, queryBigFileReq.getCreateTime())
.gt(ObjectUtils.isNotEmpty(fileSizeInBytes), FileStorage::getFileSize, fileSizeInBytes).list();

View File

@@ -4,7 +4,7 @@ import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.sdm.common.common.SdmResponse;
import com.sdm.common.entity.resp.AllNodeByProjectIdAndTypeResp;
import com.sdm.common.feign.impl.project.SimuluationNodeFeignClientImpl;
import com.sdm.common.feign.impl.project.SimulationNodeFeignClientImpl;
import com.sdm.data.model.entity.DimensionTemplate;
import com.sdm.data.dao.DimensionTemplateMapper;
import com.sdm.data.model.entity.DimensionTemplateHierarchy;
@@ -37,7 +37,7 @@ public class DimensionTemplateServiceImpl extends ServiceImpl<DimensionTemplateM
private IDimensionTemplateHierarchyService dimensionTemplateHierarchyService;
@Autowired
SimuluationNodeFeignClientImpl simuluationNodeFeignClient;
SimulationNodeFeignClientImpl simuluationNodeFeignClient;
@Override
@Transactional(rollbackFor = Exception.class)
@@ -142,9 +142,9 @@ public class DimensionTemplateServiceImpl extends ServiceImpl<DimensionTemplateM
queryWrapper.eq(DimensionTemplateHierarchy::getTemplateId, dimensionTemplateId).orderByAsc(DimensionTemplateHierarchy::getSortOrder);
List<String> dimensionNodeTyepOrderList = dimensionTemplateHierarchyService.list(queryWrapper).stream().map(DimensionTemplateHierarchy::getDisplayName).toList();
Long chooseNodeId = req.getChooseNodeId();
String chooseUuid = req.getChooseUuid();
String chooseNodeType = req.getChooseNodeType();
if(chooseNodeId==null){
if(chooseUuid==null){
// 选中维度了,没有选节点,按照模版,展示模版的第一层节点数据
String rootNodeType = dimensionNodeTyepOrderList.get(0);
SdmResponse<List<AllNodeByProjectIdAndTypeResp>> allNodeByNodeTypeResponse = simuluationNodeFeignClient.getAllNodeByNodeType(null,rootNodeType);
@@ -169,7 +169,7 @@ public class DimensionTemplateServiceImpl extends ServiceImpl<DimensionTemplateM
// 获取dimensionNodeTyepOrderList的index+1位置的节点类型
String nextNodeType = dimensionNodeTyepOrderList.get(index + 1);
SdmResponse<List<AllNodeByProjectIdAndTypeResp>> allNodeByProjectIdAndType = simuluationNodeFeignClient.getAllNodeByProjectIdAndType(chooseNodeId, nextNodeType);
SdmResponse<List<AllNodeByProjectIdAndTypeResp>> allNodeByProjectIdAndType = simuluationNodeFeignClient.getAllNodeByProjectIdAndType(chooseUuid, nextNodeType);
if(!allNodeByProjectIdAndType.isSuccess()){
return SdmResponse.success();
}

View File

@@ -10,13 +10,17 @@ import com.sdm.common.common.Constants;
import com.sdm.common.common.SdmResponse;
import com.sdm.common.common.ThreadLocalContext;
import com.sdm.common.entity.req.data.CreateDirReq;
import com.sdm.common.entity.req.project.DelNodeReq;
import com.sdm.common.entity.req.project.RenameNodeReq;
import com.sdm.common.entity.req.system.UserListReq;
import com.sdm.common.entity.resp.PageDataResp;
import com.sdm.common.entity.resp.system.CIDUserResp;
import com.sdm.common.feign.impl.project.SimulationNodeFeignClientImpl;
import com.sdm.common.utils.PageUtils;
import com.sdm.common.feign.impl.system.SysUserFeignClientImpl;
import com.sdm.data.model.entity.FileMetadataExtension;
import com.sdm.data.model.entity.FileMetadataInfo;
import com.sdm.data.model.entity.FileStorage;
import com.sdm.data.model.entity.FileUserPermission;
import com.sdm.data.model.req.*;
import com.sdm.common.entity.resp.data.FileMetadataInfoResp;
@@ -24,6 +28,7 @@ import com.sdm.data.model.resp.KKFileViewURLFromMinioResp;
import com.sdm.data.service.*;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.assertj.core.util.DateUtil;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.BeanUtils;
@@ -76,6 +81,13 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
@Autowired
private IMinioService minioService;
@Autowired
SimulationNodeFeignClientImpl simulationNodeFeignClient;
@Autowired
private DataStorageAnalysis dataStorageAnalysis;
@Override
public String getType() {
return type;
@@ -90,7 +102,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
try {
// 处理根目录创建逻辑(知识库根目录创建逻辑和项目节点目录创建)
if (ObjectUtils.isNull(req.getParDirId()) && ObjectUtils.isNull(req.getParentNodeId())) {
if (ObjectUtils.isNull(req.getParDirId()) && ObjectUtils.isNull(req.getParentUuId())) {
return createRootDir(req);
} else {
// 处理子目录创建逻辑
@@ -110,7 +122,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
*/
public SdmResponse<?> createRootDir(CreateDirReq req) {
if(ObjectUtils.isNull(req.getDirType())){
if (ObjectUtils.isNull(req.getDirType())) {
return SdmResponse.failed("请选择目录类型:1 知识库文件夹2 项目节点文件夹3 头像库文件夹4 仿真参数库文件夹,5 训练模型文件夹");
}
@@ -132,8 +144,9 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
Long rootDirId = rootDirMetadataInfo.getId();
String dirName = req.getDirName();
String dirMinioObjectKey = getDirMinioObjectKey(rootDirMetadataInfo.getObjectKey()+dirName);
Long nodeId = req.getNodeId();
String dirMinioObjectKey = getDirMinioObjectKey(rootDirMetadataInfo.getObjectKey() + dirName);
String uuId = req.getUuId();
String uuIdOwnType = req.getUuIdOwnType();
try {
// 检查目录是否已存在
@@ -145,7 +158,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
minioService.createDirectoryByObjectKey(dirMinioObjectKey);
// 创建目录元数据并保存到数据库
FileMetadataInfo dirInfo = createDirectoryMetadata(dirMinioObjectKey, dirName, false, rootDirId, nodeId,req.getDirType());
FileMetadataInfo dirInfo = createDirectoryMetadata(dirMinioObjectKey, dirName, false, rootDirId, uuId, uuIdOwnType, req.getDirType());
fileMetadataInfoService.save(dirInfo);
// 创建默认权限记录
@@ -172,8 +185,8 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
*/
public SdmResponse<Object> createChildDir(CreateDirReq req) {
Long parDirId = null;
if (req.getParentNodeId() != null) {
FileMetadataInfo node = fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getNodeId, req.getParentNodeId()).one();
if (req.getParentUuId() != null) {
FileMetadataInfo node = fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getRelatedResourceUuid, req.getParentUuId()).one();
parDirId = node.getId();
} else {
parDirId = req.getParDirId();
@@ -202,7 +215,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
minioService.createDirectoryByObjectKey(childDirMinioObjectKey);
// 创建子目录元数据并保存到数据库
FileMetadataInfo dirInfo = createDirectoryMetadata(childDirMinioObjectKey, req.getDirName(), false, parDirId, req.getNodeId(),parDirInfo.getDirType());
FileMetadataInfo dirInfo = createDirectoryMetadata(childDirMinioObjectKey, req.getDirName(), false, parDirId, req.getUuId(), req.getUuIdOwnType(), parDirInfo.getDirType());
fileMetadataInfoService.save(dirInfo);
// 创建默认权限记录
@@ -229,10 +242,13 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
* @param originalName 原始名称
* @param isRoot 是否为根目录
* @param parentId 父目录ID根目录为null
* @param nodeId 节点ID
* @param uuid 节点ID
* @param uuIdOwnType
* @return 目录元数据对象
*/
private FileMetadataInfo createDirectoryMetadata(String minioObjectKey, String originalName, boolean isRoot, Long parentId, Long nodeId, Integer dirType) {
private FileMetadataInfo createDirectoryMetadata(String minioObjectKey, String originalName,
boolean isRoot, Long parentId, String uuid,
String uuIdOwnType, Integer dirType) {
FileMetadataInfo dirInfo = new FileMetadataInfo();
dirInfo.setObjectKey(minioObjectKey);
dirInfo.setBucketName(minioService.getBucketName());
@@ -243,8 +259,11 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
if (!isRoot && parentId != null) {
dirInfo.setParentId(parentId);
}
if (nodeId != null) {
dirInfo.setNodeId(nodeId);
if (uuid != null) {
dirInfo.setRelatedResourceUuid(uuid);
}
if (uuIdOwnType != null) {
dirInfo.setRelatedResourceUuidOwnType(uuIdOwnType);
}
return dirInfo;
}
@@ -285,7 +304,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
* @param directoryId 目录ID
*/
private void createDirectoryPermission(Long directoryId) {
if(StringUtils.hasText(ThreadLocalContext.getCommonHeader().getJobNumber())) {
if (StringUtils.hasText(ThreadLocalContext.getCommonHeader().getJobNumber())) {
FileUserPermission permission = new FileUserPermission();
permission.setTFilemetaId(directoryId);
permission.setPermission(Constants.FilePermission.ALL.getValue());
@@ -343,7 +362,13 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
@Transactional(rollbackFor = Exception.class)
public SdmResponse delDir(DelDirReq req) {
try {
FileMetadataInfo deleteDirMetadataInfo = fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getId, req.getDelDirId()).one();
FileMetadataInfo deleteDirMetadataInfo = null;
if (req.getDelUuid() != null) {
deleteDirMetadataInfo = fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getRelatedResourceUuid, req.getDelUuid()).one();
} else {
deleteDirMetadataInfo = fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getId, req.getDelDirId()).one();
}
if (ObjectUtils.isNull(deleteDirMetadataInfo)) {
return SdmResponse.failed("目录不存在");
}
@@ -367,6 +392,13 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
// minio文件系统批量删除文件
minioService.deleteDirectoryRecursively(dirMinioObjectKey);
if (ObjectUtils.isNotNull(req.getDelUuid()) && ObjectUtils.isNotNull(req.getDelUuIdOwnType())) {
DelNodeReq delNodeReq = new DelNodeReq();
delNodeReq.setUuid(req.getDelUuid());
delNodeReq.setUuidOwnType(req.getDelUuIdOwnType());
simulationNodeFeignClient.delteNode(delNodeReq);
}
} catch (Exception e) {
log.error("删除目录失败", e);
// 重新抛出异常,确保事务回滚
@@ -410,42 +442,41 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
@Override
public SdmResponse fileSearch(FileSearchReq minioFileSearchReq) {
LambdaQueryWrapper<FileMetadataInfo> fileMetadataInfoLambdaQuery = new LambdaQueryWrapper<>();
FileMetadataInfo fileMetadataInfo = null;
String dirObjectKey = null;
if (ObjectUtils.isNotNull(minioFileSearchReq.getParentNodeId())) {
if (ObjectUtils.isNotNull(minioFileSearchReq.getParentUuid())) {
// 项目节点下搜索文件
FileMetadataInfo nodeMetadataInfo = fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getNodeId, minioFileSearchReq.getParentNodeId()).one();
if(nodeMetadataInfo != null){
dirObjectKey = nodeMetadataInfo.getObjectKey();
}
fileMetadataInfo = fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getRelatedResourceUuid, minioFileSearchReq.getParentUuid()).one();
} else if (ObjectUtils.isNotNull(minioFileSearchReq.getParentDirId())) {
// 知识库的文件查询
FileMetadataInfo dirMetadataInfo = fileMetadataInfoService.getById(minioFileSearchReq.getParentDirId());
if(dirMetadataInfo != null){
dirObjectKey = dirMetadataInfo.getObjectKey();
}
fileMetadataInfo = fileMetadataInfoService.getById(minioFileSearchReq.getParentDirId());
}
if(dirObjectKey == null){
return SdmResponse.failed("历史目录不存在");
if (fileMetadataInfo != null) {
return SdmResponse.success();
}
QueryBigFileReq queryBigFileReq = new QueryBigFileReq();
BeanUtils.copyProperties(minioFileSearchReq, queryBigFileReq);
queryBigFileReq.setDirId(fileMetadataInfo.getId());
SdmResponse<PageDataResp<List<FileStorage>>> searchResult = dataStorageAnalysis.listBigFile(queryBigFileReq);
PageDataResp<List<FileStorage>> pageDataResp = searchResult.getData();
List<FileStorage> data = pageDataResp.getData();
if(CollectionUtils.isEmpty(data)) {
return SdmResponse.success();
}
List<Long> fileIdList = data.stream().map(FileStorage::getFileId).toList();
// 查询当前文件夹和子文件下的文件,使用 dirObjectKey%
fileMetadataInfoLambdaQuery.likeRight(ObjectUtils.isNotNull(dirObjectKey), FileMetadataInfo::getObjectKey, dirObjectKey)
.eq(ObjectUtils.isNotNull(minioFileSearchReq.getCreaterId()), FileMetadataInfo::getCreatorId, minioFileSearchReq.getCreaterId())
.eq(FileMetadataInfo::getIsLatest, Constants.FileIsLast.YES.getValue())
.like(ObjectUtils.isNotNull(minioFileSearchReq.getFileName()), FileMetadataInfo::getOriginalName, minioFileSearchReq.getFileName());
// 分页处理
PageHelper.startPage(minioFileSearchReq.getCurrent(), minioFileSearchReq.getSize());
List<FileMetadataInfo> files = fileMetadataInfoService.lambdaQuery().in(FileMetadataInfo::getId, fileIdList).list();
PageDataResp<List<FileMetadataInfo>> page = new PageDataResp<>();
page.setData(files);
page.setTotal(pageDataResp.getTotal());
page.setCurrentPage(pageDataResp.getCurrentPage());
page.setPageSize(pageDataResp.getPageSize());
// 使用分页查询
List<FileMetadataInfo> list = fileMetadataInfoService.list(fileMetadataInfoLambdaQuery);
PageInfo<FileMetadataInfo> page = new PageInfo<>(list);
return PageUtils.getJsonObjectSdmResponse(list, page);
return SdmResponse.success(page);
}
@Override
@@ -471,9 +502,9 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
if (ObjectUtils.isNotEmpty(req.getFileId())) {
// 知识库的文件查询
parentId = req.getFileId();
} else if (ObjectUtils.isNotEmpty(req.getNodeId())) {
} else if (ObjectUtils.isNotEmpty(req.getUuid())) {
// 项目节点文件查询
FileMetadataInfo nodeMetadataInfo = fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getNodeId, req.getNodeId()).one();
FileMetadataInfo nodeMetadataInfo = fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getRelatedResourceUuid, req.getUuid()).one();
if (nodeMetadataInfo == null) {
// 项目节点未创建文件夹,返回空
return SdmResponse.success();
@@ -632,7 +663,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
minioService.createDirectoryByObjectKey(dirMinioObjectKey);
// 创建目录元数据并保存到数据库
FileMetadataInfo dirInfo = createDirectoryMetadata(dirMinioObjectKey, dirType.getDirName(), true, null, null,dirType.getValue());
FileMetadataInfo dirInfo = createDirectoryMetadata(dirMinioObjectKey, dirType.getDirName(), true, null, null, null, dirType.getValue());
fileMetadataInfoService.save(dirInfo);
} catch (Exception dbException) {
log.error("创建根目录失败", dbException);
@@ -697,6 +728,14 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
try {
minioService.renameFile(oldDirMinioObjectKey, newDirMinioObjectKey);
fileMetadataInfoService.lambdaUpdate().set(FileMetadataInfo::getObjectKey, newDirMinioObjectKey).set(FileMetadataInfo::getOriginalName, req.getNewName()).eq(FileMetadataInfo::getId, dirMetadataInfo.getId()).update();
if (ObjectUtils.isNotNull(req.getUuid()) && ObjectUtils.isNotNull(req.getUuIdOwnType())) {
RenameNodeReq renameNodeReq = new RenameNodeReq();
renameNodeReq.setUuid(req.getUuid());
renameNodeReq.setUuidOwnType(req.getUuIdOwnType());
renameNodeReq.setNewName(req.getNewName());
simulationNodeFeignClient.renameNode(renameNodeReq);
}
return SdmResponse.success("重命名目录成功");
} catch (Exception e) {
log.error("重命名目录失败", e);
@@ -756,7 +795,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
FileMetadataInfo fileMetadataInfo = fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getId, fileId).one();
if (ObjectUtils.isEmpty(fileMetadataInfo)) {
log.error("文件不存在");
return null;
return null;
}
String fileObjectKey = fileMetadataInfo.getObjectKey();
@@ -768,9 +807,10 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
@Transactional(rollbackFor = Exception.class)
public SdmResponse uploadFiles(UploadFilesReq req) {
Long dirId = null;
if (req.getNodeId() != null) {
// 项目节点文件查询
FileMetadataInfo nodeMetadataInfo = fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getNodeId, req.getNodeId()).one();
String uuid = req.getUuid();
if (uuid != null) {
FileMetadataInfo nodeMetadataInfo = fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getRelatedResourceUuid, req.getUuid()).one();
dirId = nodeMetadataInfo.getId();
} else if (req.getDirId() != null) {
dirId = req.getDirId();
@@ -861,7 +901,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
@Override
public SdmResponse<List<FileMetadataInfoResp>> listDir(Integer dirType, Long parentDirId) {
try {
if(ObjectUtils.isNull(dirType)){
if (ObjectUtils.isNull(dirType)) {
return SdmResponse.failed("请选择目录类型:1 知识库文件夹2 项目节点文件夹3 头像库文件夹4 仿真参数库文件夹,5 训练模型文件夹");
}