diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 1a4a804a..f6f1da5f 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -14,11 +14,22 @@ - + + + + + + + + + + + + diff --git a/common/src/main/java/com/sdm/common/feign/impl/project/SimulationNodeFeignClientImpl.java b/common/src/main/java/com/sdm/common/feign/impl/project/SimulationNodeFeignClientImpl.java index 32925c5e..b943d6c8 100644 --- a/common/src/main/java/com/sdm/common/feign/impl/project/SimulationNodeFeignClientImpl.java +++ b/common/src/main/java/com/sdm/common/feign/impl/project/SimulationNodeFeignClientImpl.java @@ -43,15 +43,15 @@ public class SimulationNodeFeignClientImpl implements ISimulationNodeFeignClient /** * 根据项目ID和节点类型获取所有节点信息 * - * @param uuid 项目ID + * @param uuids 项目ID * @param nextNodeType 下一级节点类型 * @return SdmResponse 节点信息 */ - public SdmResponse> getAllNodeByProjectIdAndType(String uuid, String nextNodeType) { + public SdmResponse> getAllNodeByProjectIdAndType(List uuids, String nextNodeType) { SdmResponse> response; try { - log.info("根据项目ID和节点类型获取所有节点信息请求参数:uuid={}, nextNodeType={}", uuid, nextNodeType); - response = ISimulationNodeFeignClient.getAllNodeByProjectIdAndType(uuid, nextNodeType); + log.info("根据项目ID和节点类型获取所有节点信息请求参数:uuid={}, nextNodeType={}", uuids, nextNodeType); + response = ISimulationNodeFeignClient.getAllNodeByProjectIdAndType(uuids, nextNodeType); if (!response.isSuccess() || response.getData() == null || response.getData().isEmpty()) { return SdmResponse.failed("获取节点信息失败"); } @@ -65,11 +65,11 @@ public class SimulationNodeFeignClientImpl implements ISimulationNodeFeignClient @Override - public SdmResponse> getNodeTaskList(String uuid) { + public SdmResponse> getNodeTaskList(List uuids) { SdmResponse> response; try { - log.info("获取节点下的task列表请求参数:uuid={}", uuid); - response = ISimulationNodeFeignClient.getNodeTaskList(uuid); + log.info("获取节点下的task列表请求参数:uuid={}", uuids); + response = ISimulationNodeFeignClient.getNodeTaskList(uuids); if (!response.isSuccess() || response.getData() == null || response.getData().isEmpty()) { return SdmResponse.failed("获取节点下的task列表失败"); } @@ -81,11 +81,11 @@ public class SimulationNodeFeignClientImpl implements ISimulationNodeFeignClient } @Override - public SdmResponse> getTaskRunList(String uuid) { + public SdmResponse> getTaskRunList(List uuids) { SdmResponse> response; try { - log.info("获取task下的run请求参数:uuid={}", uuid); - response = ISimulationNodeFeignClient.getTaskRunList(uuid); + log.info("获取task下的run请求参数:uuid={}", uuids); + response = ISimulationNodeFeignClient.getTaskRunList(uuids); if (!response.isSuccess() || response.getData() == null || response.getData().isEmpty()) { return SdmResponse.failed("获取task下的run失败"); } diff --git a/common/src/main/java/com/sdm/common/feign/inter/project/ISimulationNodeFeignClient.java b/common/src/main/java/com/sdm/common/feign/inter/project/ISimulationNodeFeignClient.java index a49ab7b3..00fe8ea5 100644 --- a/common/src/main/java/com/sdm/common/feign/inter/project/ISimulationNodeFeignClient.java +++ b/common/src/main/java/com/sdm/common/feign/inter/project/ISimulationNodeFeignClient.java @@ -5,7 +5,6 @@ import com.sdm.common.entity.req.project.DelNodeReq; import com.sdm.common.entity.req.project.SpdmNodeListReq; import com.sdm.common.entity.resp.AllNodeByProjectIdAndTypeResp; import com.sdm.common.entity.resp.project.SimulationNodeResp; -import io.swagger.v3.oas.annotations.Operation; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -27,24 +26,24 @@ public interface ISimulationNodeFeignClient { /** * 根据项目ID和节点类型获取所有节点信息 * - * @param uuid 项目ID + * @param uuids 项目ID * @param nextNodeType 下一级节点类型 * @return SdmResponse> 节点信息 */ @GetMapping("/node/getAllNodeByProjectIdAndType") - SdmResponse> getAllNodeByProjectIdAndType(@RequestParam(value = "chooseNodeId") String uuid, @RequestParam(value = "nextNodeType") String nextNodeType); + SdmResponse> getAllNodeByProjectIdAndType(@RequestParam(value = "chooseNodeIds") List uuids, @RequestParam(value = "nextNodeType") String nextNodeType); /** * 获取节点下的task列表 */ @GetMapping("/node/getNodeTaskList") - SdmResponse> getNodeTaskList(@RequestParam(value = "uuid") String uuid); + SdmResponse> getNodeTaskList(@RequestParam(value = "uuids") List uuids); /** * 获取task下的run */ @GetMapping("/node/getNodeTaskRunList") - SdmResponse> getTaskRunList(@RequestParam(value = "uuid") String uuid); + SdmResponse> getTaskRunList(@RequestParam(value = "uuids") List uuids); @PostMapping("node/delteNode") SdmResponse delteNode(@RequestBody DelNodeReq req); diff --git a/data/pom.xml b/data/pom.xml index 6722fa82..7cefee39 100644 --- a/data/pom.xml +++ b/data/pom.xml @@ -16,6 +16,9 @@ UTF-8 UTF-8 3.3.5 + 1.5.2.Final + 1.18.30 + 0.2.0 @@ -108,6 +111,13 @@ spring-boot-starter-websocket + + + org.mapstruct + mapstruct + ${org.mapstruct.version} + + @@ -134,6 +144,23 @@ -parameters + + + org.mapstruct + mapstruct-processor + ${org.mapstruct.version} + + + org.projectlombok + lombok + ${lombok.version} + + + org.projectlombok + lombok-mapstruct-binding + ${lombok-mapstruct-binding.version} + + diff --git a/data/src/main/java/com/sdm/data/controller/DataOverviewController.java b/data/src/main/java/com/sdm/data/controller/DataOverviewController.java index 8bbb2ec9..06c83111 100644 --- a/data/src/main/java/com/sdm/data/controller/DataOverviewController.java +++ b/data/src/main/java/com/sdm/data/controller/DataOverviewController.java @@ -4,6 +4,7 @@ package com.sdm.data.controller; import com.sdm.common.common.SdmResponse; import com.sdm.common.entity.req.data.CreateDirReq; import com.sdm.common.entity.req.data.UploadFilesReq; +import com.sdm.data.model.dto.FileMetadataChildrenDTO; import com.sdm.data.model.entity.FileMetadataInfo; import com.sdm.data.model.req.*; import com.sdm.data.service.IDimensionTemplateService; @@ -40,7 +41,7 @@ public class DataOverviewController { */ @PostMapping("/getSimulationNodeTree") @Operation(summary = "根据数据显示维度展示左侧节点树") - public SdmResponse> getSimulationNodeTree(@RequestBody GetSimulationNodeTreeReq req) { + public SdmResponse> getSimulationNodeTree(@RequestBody GetSimulationNodeTreeReq req) { return dimensionTemplateService.getSimulationNodeTree(req); } diff --git a/data/src/main/java/com/sdm/data/convert/FileMetadataConvert.java b/data/src/main/java/com/sdm/data/convert/FileMetadataConvert.java new file mode 100644 index 00000000..aa2f0bb6 --- /dev/null +++ b/data/src/main/java/com/sdm/data/convert/FileMetadataConvert.java @@ -0,0 +1,77 @@ +package com.sdm.data.convert; + +import com.sdm.common.entity.resp.data.FileMetadataInfoResp; +import com.sdm.data.model.dto.FileMetadataChildrenDTO; +import com.sdm.data.model.entity.FileMetadataInfo; +import jdk.jfr.Name; +import org.mapstruct.*; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +@Mapper +public interface FileMetadataConvert { + + FileMetadataConvert INSTANCE = Mappers.getMapper(FileMetadataConvert.class); + + @Named("baseResp") + @Mappings({ + @Mapping(target = "fileUrl", ignore = true), + @Mapping(target = "creatorName", ignore = true), + @Mapping(target = "updaterName", ignore = true), + @Mapping(target = "projectName", ignore = true), + @Mapping(target = "analysisDirectionName", ignore = true), + @Mapping(target = "poolInfos", ignore = true), + @Mapping(target = "approvalStatus", ignore = true), + @Mapping(target = "approveType", ignore = true), + @Mapping(target = "tempMetadata", ignore = true), + @Mapping(target = "cidFlowId", ignore = true), + @Mapping(target = "uploadTaskId", ignore = true), + @Mapping(target = "uploadStatus", ignore = true), + @Mapping(target = "cidFlowReviewer", ignore = true), + @Mapping(target = "tag1", ignore = true), + @Mapping(target = "tag2", ignore = true), + @Mapping(target = "tag3", ignore = true), + @Mapping(target = "tag4", ignore = true), + @Mapping(target = "tag5", ignore = true), + @Mapping(target = "tag6", ignore = true), + @Mapping(target = "tag7", ignore = true), + @Mapping(target = "tag8", ignore = true), + @Mapping(target = "tag9", ignore = true), + @Mapping(target = "tag10", ignore = true) + }) + FileMetadataInfoResp convertToFileMetadataInfoResp(FileMetadataInfo fileMetadataInfo); + + @IterableMapping(qualifiedByName = "baseResp") + List convertToFileMetadataInfoRespList(List fileMetadataInfoList); + + @Named("childrenResp") + @Mappings({ + @Mapping(target = "children", ignore = true), + @Mapping(target = "totalName", ignore = true), + @Mapping(target = "fileUrl", ignore = true), + @Mapping(target = "creatorName", ignore = true), + @Mapping(target = "updaterName", ignore = true), + @Mapping(target = "projectName", ignore = true), + @Mapping(target = "analysisDirectionName", ignore = true), + @Mapping(target = "poolInfos", ignore = true), + @Mapping(target = "approvalStatus", ignore = true), + @Mapping(target = "approveType", ignore = true), + @Mapping(target = "tempMetadata", ignore = true), + @Mapping(target = "cidFlowId", ignore = true), + @Mapping(target = "uploadTaskId", ignore = true), + @Mapping(target = "uploadStatus", ignore = true), + @Mapping(target = "cidFlowReviewer", ignore = true), + @Mapping(target = "tag1", ignore = true), + @Mapping(target = "tag2", ignore = true), + @Mapping(target = "tag3", ignore = true), + @Mapping(target = "tag4", ignore = true), + @Mapping(target = "tag5", ignore = true), + @Mapping(target = "tag6", ignore = true), + @Mapping(target = "tag7", ignore = true), + @Mapping(target = "tag8", ignore = true), + @Mapping(target = "tag9", ignore = true), + @Mapping(target = "tag10", ignore = true) + }) + FileMetadataChildrenDTO convertToFileMetadataChildrenDTO(FileMetadataInfo fileMetadataInfo); +} \ No newline at end of file diff --git a/data/src/main/java/com/sdm/data/dao/FileMetadataInfoMapper.java b/data/src/main/java/com/sdm/data/dao/FileMetadataInfoMapper.java index d7d2f8fc..9d33f282 100644 --- a/data/src/main/java/com/sdm/data/dao/FileMetadataInfoMapper.java +++ b/data/src/main/java/com/sdm/data/dao/FileMetadataInfoMapper.java @@ -16,6 +16,6 @@ import java.util.List; */ public interface FileMetadataInfoMapper extends BaseMapper { List listSimulationNodeDir(@Param("dirIds") List dirIds, @Param("filterEmptyData") boolean filterEmptyData, @Param("tenantId") Long tenantId); - List listSimulationNodeFiles(@Param("parentId") Long parentId,@Param("fileIds") List fileIds, @Param("filterEmptyData") boolean isFilterEmptyData,@Param("tenantId") Long tenantId); + List listSimulationNodeFiles(@Param("parentIds") List parentIds, @Param("fileIds") List fileIds, @Param("filterEmptyData") boolean isFilterEmptyData, @Param("tenantId") Long tenantId); } diff --git a/data/src/main/java/com/sdm/data/model/dto/FileMetadataChildrenDTO.java b/data/src/main/java/com/sdm/data/model/dto/FileMetadataChildrenDTO.java new file mode 100644 index 00000000..c7ec079d --- /dev/null +++ b/data/src/main/java/com/sdm/data/model/dto/FileMetadataChildrenDTO.java @@ -0,0 +1,20 @@ +package com.sdm.data.model.dto; + +import com.sdm.common.entity.resp.data.FileMetadataInfoResp; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + +@Data +@EqualsAndHashCode(callSuper = true) +@Schema(description = "带有子节点的文件元数据信息DTO") +public class FileMetadataChildrenDTO extends FileMetadataInfoResp { + + @Schema(description = "子节点列表") + private List children; + + @Schema(description = "总名称(去除projectNode/前缀的bucketName)") + private String totalName; +} \ No newline at end of file diff --git a/data/src/main/java/com/sdm/data/model/req/GetSimulationNodeTreeReq.java b/data/src/main/java/com/sdm/data/model/req/GetSimulationNodeTreeReq.java index 840cd791..fb71576f 100644 --- a/data/src/main/java/com/sdm/data/model/req/GetSimulationNodeTreeReq.java +++ b/data/src/main/java/com/sdm/data/model/req/GetSimulationNodeTreeReq.java @@ -4,6 +4,8 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import org.hibernate.validator.constraints.NotEmpty; +import java.util.List; + @Data public class GetSimulationNodeTreeReq { /** @@ -14,7 +16,7 @@ public class GetSimulationNodeTreeReq { private Long dimensionTemplateId; /** - * 文件ID + * 聚合文件ID列表 */ - private Long fileId; + private List fileIds; } diff --git a/data/src/main/java/com/sdm/data/model/req/ListSimulationNodeTreeReq.java b/data/src/main/java/com/sdm/data/model/req/ListSimulationNodeTreeReq.java index 68c9ba2a..0b0a85fc 100644 --- a/data/src/main/java/com/sdm/data/model/req/ListSimulationNodeTreeReq.java +++ b/data/src/main/java/com/sdm/data/model/req/ListSimulationNodeTreeReq.java @@ -5,6 +5,8 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import org.hibernate.validator.constraints.NotEmpty; +import java.util.List; + @Data public class ListSimulationNodeTreeReq extends BaseReq { /** @@ -15,11 +17,16 @@ public class ListSimulationNodeTreeReq extends BaseReq { Long dimensionTemplateId; /** - * 文件夹ID + * 文件夹ID 只用来控制根目录 */ @Schema(description = "文件夹ID") Long fileId; + /** + * 聚合文件ID列表 + */ + private List fileIds; + /** * 是否过滤空数据 */ diff --git a/data/src/main/java/com/sdm/data/service/IDimensionTemplateService.java b/data/src/main/java/com/sdm/data/service/IDimensionTemplateService.java index 8e70a055..3e20867b 100644 --- a/data/src/main/java/com/sdm/data/service/IDimensionTemplateService.java +++ b/data/src/main/java/com/sdm/data/service/IDimensionTemplateService.java @@ -3,6 +3,7 @@ package com.sdm.data.service; import com.sdm.common.common.SdmResponse; import com.sdm.common.entity.req.data.CreateDirReq; import com.sdm.common.entity.req.data.UploadFilesReq; +import com.sdm.data.model.dto.FileMetadataChildrenDTO; import com.sdm.data.model.entity.DimensionTemplate; import com.baomidou.mybatisplus.extension.service.IService; import com.sdm.data.model.entity.FileMetadataInfo; @@ -30,7 +31,7 @@ public interface IDimensionTemplateService extends IService { SdmResponse deleteTemplateWithHierarchies(Long id); - SdmResponse> getSimulationNodeTree(GetSimulationNodeTreeReq req); + SdmResponse> getSimulationNodeTree(GetSimulationNodeTreeReq req); /** * 根据数据显示维度展示左侧节点树 diff --git a/data/src/main/java/com/sdm/data/service/IFileMetadataInfoService.java b/data/src/main/java/com/sdm/data/service/IFileMetadataInfoService.java index 9be2115c..35ab5c3c 100644 --- a/data/src/main/java/com/sdm/data/service/IFileMetadataInfoService.java +++ b/data/src/main/java/com/sdm/data/service/IFileMetadataInfoService.java @@ -19,5 +19,5 @@ public interface IFileMetadataInfoService extends IService { * @return */ List listSimulationNodeDir(List dirIds,boolean filterEmptyData,Long tenantId); - List listSimulationNodeFiles(Long parentId, List fileIds, boolean isFilterEmptyData,Long tenantId); + List listSimulationNodeFiles(List parentIds, List fileIds, boolean isFilterEmptyData, Long tenantId); } diff --git a/data/src/main/java/com/sdm/data/service/impl/DataStorageAnalysisImpl.java b/data/src/main/java/com/sdm/data/service/impl/DataStorageAnalysisImpl.java index e6c934a7..106d7a41 100644 --- a/data/src/main/java/com/sdm/data/service/impl/DataStorageAnalysisImpl.java +++ b/data/src/main/java/com/sdm/data/service/impl/DataStorageAnalysisImpl.java @@ -66,7 +66,7 @@ public class DataStorageAnalysisImpl implements DataStorageAnalysis { IFileStorageQuotaService fileStorageQuotaService; public SdmResponse> getNodeSizeByNodeType(String queryNodeType, String uuid, Integer intervalMonths, String targetYm) { - SdmResponse> response = simuluationNodeFeignClient.getAllNodeByProjectIdAndType(uuid, queryNodeType); + SdmResponse> response = simuluationNodeFeignClient.getAllNodeByProjectIdAndType(List.of(uuid), queryNodeType); Long tenantId = ThreadLocalContext.getTenantId(); if (!response.isSuccess()) { log.error("获取节点信息失败"); diff --git a/data/src/main/java/com/sdm/data/service/impl/DimensionTemplateServiceImpl.java b/data/src/main/java/com/sdm/data/service/impl/DimensionTemplateServiceImpl.java index 9b7de3cb..aa063265 100644 --- a/data/src/main/java/com/sdm/data/service/impl/DimensionTemplateServiceImpl.java +++ b/data/src/main/java/com/sdm/data/service/impl/DimensionTemplateServiceImpl.java @@ -16,11 +16,14 @@ import com.sdm.common.entity.req.data.UploadFilesReq; import com.sdm.common.entity.req.project.DelNodeReq; import com.sdm.common.entity.req.system.UserQueryReq; import com.sdm.common.entity.resp.AllNodeByProjectIdAndTypeResp; +import com.sdm.common.entity.resp.data.FileMetadataInfoResp; import com.sdm.common.entity.resp.system.CIDUserResp; import com.sdm.common.feign.impl.project.SimulationNodeFeignClientImpl; import com.sdm.common.feign.impl.system.SysUserFeignClientImpl; import com.sdm.common.utils.CidSysUserUtil; import com.sdm.common.utils.PageUtils; +import com.sdm.data.convert.FileMetadataConvert; +import com.sdm.data.model.dto.FileMetadataChildrenDTO; import com.sdm.data.model.entity.DimensionTemplate; import com.sdm.data.dao.DimensionTemplateMapper; import com.sdm.data.model.entity.DimensionTemplateHierarchy; @@ -38,14 +41,12 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import javax.annotation.Resource; import java.time.LocalDateTime; import java.util.*; -import java.util.stream.Stream; +import java.util.stream.Collectors; /** *

@@ -179,7 +180,7 @@ public class DimensionTemplateServiceImpl extends ServiceImpl> getSimulationNodeTree(GetSimulationNodeTreeReq req) { + public SdmResponse> getSimulationNodeTree(GetSimulationNodeTreeReq req) { Long tenantId = ThreadLocalContext.getTenantId(); // 根据展示维度获取展示节点类型顺序 Long dimensionTemplateId = req.getDimensionTemplateId(); @@ -189,26 +190,26 @@ public class DimensionTemplateServiceImpl extends ServiceImpl uuids = new ArrayList<>(); List resultDir = new ArrayList<>(); - if (ObjectUtils.isEmpty(req.getFileId())) { + if (ObjectUtils.isEmpty(req.getFileIds())) { // 选中维度了,没有选节点,按照模版,展示模版的第一层节点数据 String rootNodeType = dimensionNodeTyepOrderList.get(0); SdmResponse> allNodeByNodeTypeResponse = simuluationNodeFeignClient.getAllNodeByNodeType(null, rootNodeType); if (!allNodeByNodeTypeResponse.isSuccess()) { log.error("获取节点信息失败"); - return SdmResponse.success(); + return SdmResponse.success(Collections.emptyList()); } uuids.addAll(allNodeByNodeTypeResponse.getData().stream().map(AllNodeByProjectIdAndTypeResp::getUuid).toList()); } else { // 选中维度了,也选中了节点,按照模版,展示该节点下的普通文件夹、任务、算列、按照展示模版指定的下一层节点文件夹 - Long fileId = req.getFileId(); + List fileIds = req.getFileIds(); // 1、先获取普通文件夹 List dirInfos = fileMetadataInfoService .lambdaQuery() .eq(FileMetadataInfo::getTenantId, tenantId) - .eq(FileMetadataInfo::getParentId, fileId) + .in(FileMetadataInfo::getParentId, fileIds) .eq(FileMetadataInfo::getDataType, DataTypeEnum.DIRECTORY.getValue()) .isNull(FileMetadataInfo::getRelatedResourceUuid) .list(); @@ -216,46 +217,48 @@ public class DimensionTemplateServiceImpl extends ServiceImpl nodeDirInfos = fileMetadataInfoService.lambdaQuery().in(FileMetadataInfo::getId, fileIds).list(); + if(CollectionUtils.isNotEmpty(nodeDirInfos)) { + String chooseNodeType = nodeDirInfos.get(0).getRelatedResourceUuidOwnType(); + List chooseUuids = nodeDirInfos.stream().map(FileMetadataInfo::getRelatedResourceUuid).toList(); - // chooseUuid和chooseNodeType不为空,并且是node节点类型,才是节点文件夹,才需要查询子节点文件夹文件 - if (ObjectUtils.isNotEmpty(chooseUuid) && ObjectUtils.isNotEmpty(chooseNodeType) && NodeTypeEnum.isNodeType(chooseNodeType)) { - // 从dimensionNodeTyepOrderList中获取chooseNodeType下一个位置的数据,有可能chooseNodeType所在位置就是最后一层节点,SdmResponse返回空数据 - int index = dimensionNodeTyepOrderList.indexOf(chooseNodeType); - if (index == -1) { - return SdmResponse.failed("选中节点类型不在数据展示维度中"); - } - - // 判断是否是最后一层节点,如果是最后一层节点,则不需要查询子节点文件 - if (index != dimensionNodeTyepOrderList.size() - 1) { - // 获取dimensionNodeTyepOrderList的index+1位置的节点类型 - String nextNodeType = dimensionNodeTyepOrderList.get(index + 1); - SdmResponse> allNodeByProjectIdAndType = simuluationNodeFeignClient.getAllNodeByProjectIdAndType(chooseUuid, nextNodeType); - if (allNodeByProjectIdAndType.isSuccess() && ObjectUtils.isNotEmpty(allNodeByProjectIdAndType.getData())) { - uuids.addAll(allNodeByProjectIdAndType.getData().stream().map(AllNodeByProjectIdAndTypeResp::getUuid).toList()); + // chooseUuid和chooseNodeType不为空,并且是node节点类型,才是节点文件夹,才需要查询子节点文件夹文件 + if (ObjectUtils.isNotEmpty(chooseUuids) && ObjectUtils.isNotEmpty(chooseNodeType) && NodeTypeEnum.isNodeType(chooseNodeType)) { + // 从dimensionNodeTyepOrderList中获取chooseNodeType下一个位置的数据,有可能chooseNodeType所在位置就是最后一层节点,SdmResponse返回空数据 + int index = dimensionNodeTyepOrderList.indexOf(chooseNodeType); + if (index == -1) { + return SdmResponse.failed("选中节点类型不在数据展示维度中"); } + // 判断是否是最后一层节点,如果是最后一层节点,则不需要查询子节点文件 + if (index != dimensionNodeTyepOrderList.size() - 1) { + // 获取dimensionNodeTyepOrderList的index+1位置的节点类型 + String nextNodeType = dimensionNodeTyepOrderList.get(index + 1); + SdmResponse> allNodeByProjectIdAndType = simuluationNodeFeignClient.getAllNodeByProjectIdAndType(chooseUuids, nextNodeType); + if (allNodeByProjectIdAndType.isSuccess() && ObjectUtils.isNotEmpty(allNodeByProjectIdAndType.getData())) { + uuids.addAll(allNodeByProjectIdAndType.getData().stream().map(AllNodeByProjectIdAndTypeResp::getUuid).toList()); + } + + } } - } - // 3、获取当前节点下的任务、算列 - SdmResponse> nodeTaskList = simuluationNodeFeignClient.getNodeTaskList(chooseUuid); - if (nodeTaskList.isSuccess()) { - uuids.addAll(nodeTaskList.getData().stream().map(AllNodeByProjectIdAndTypeResp::getUuid).toList()); - log.info("获取节点下task的uudis:{}", uuids); - } + // 3、获取当前节点下的任务、算列 + SdmResponse> nodeTaskList = simuluationNodeFeignClient.getNodeTaskList(chooseUuids); + if (nodeTaskList.isSuccess()) { + uuids.addAll(nodeTaskList.getData().stream().map(AllNodeByProjectIdAndTypeResp::getUuid).toList()); + log.info("获取节点下task的uudis:{}", uuids); + } - SdmResponse> taskRunList = simuluationNodeFeignClient.getTaskRunList(chooseUuid); - if (taskRunList.isSuccess()) { - uuids.addAll(taskRunList.getData().stream().map(AllNodeByProjectIdAndTypeResp::getUuid).toList()); - log.info("获取节点下taskRun的uudis:{}", uuids); + SdmResponse> taskRunList = simuluationNodeFeignClient.getTaskRunList(chooseUuids); + if (taskRunList.isSuccess()) { + uuids.addAll(taskRunList.getData().stream().map(AllNodeByProjectIdAndTypeResp::getUuid).toList()); + log.info("获取节点下taskRun的uudis:{}", uuids); + } } } if (CollectionUtils.isEmpty(uuids)) { - return SdmResponse.success(resultDir); + return SdmResponse.success(Collections.emptyList()); } List nodeDirInfos = fileMetadataInfoService.lambdaQuery() @@ -263,9 +266,58 @@ public class DimensionTemplateServiceImpl extends ServiceImpl mergedResult = mergeNodeDirInfos(resultDir); + return SdmResponse.success(mergedResult); } + /** + * 根据originalName合并FileMetadataInfo列表,并处理bucketName生成totalName + * @param nodeDirInfos 需要合并的FileMetadataInfo列表 + * @return 合并后的结果 + */ + private List mergeNodeDirInfos(List nodeDirInfos) { + // 按originalName分组 + Map> groupedByOriginalName = nodeDirInfos.stream() + .collect(Collectors.groupingBy(FileMetadataInfo::getOriginalName)); + + List result = new ArrayList<>(); + + // 对每组进行处理 + for (Map.Entry> entry : groupedByOriginalName.entrySet()) { + List group = entry.getValue(); + + if (!group.isEmpty()) { + // 使用第一个作为基础对象 + FileMetadataInfo baseInfo = group.get(0); + + // 创建包含children的DTO对象 + FileMetadataChildrenDTO dto = FileMetadataConvert.INSTANCE.convertToFileMetadataChildrenDTO(baseInfo); + + // 转换children列表,并为每个child设置totalName + List children = new ArrayList<>(); + for (FileMetadataInfo fileInfo : group) { + FileMetadataChildrenDTO childDto = FileMetadataConvert.INSTANCE.convertToFileMetadataChildrenDTO(fileInfo); + + // 设置totalName(从bucketName中提取) + String objectKey = fileInfo.getObjectKey(); + String baseDirPath = DirTypeEnum.PROJECT_NODE_DIR.getDirName() + "/"; + if (objectKey != null && objectKey.startsWith(baseDirPath)) { + String totalName = objectKey.substring(baseDirPath.length()); + childDto.setTotalName(totalName); + } + + children.add(childDto); + } + + dto.setChildren(children); + result.add(dto); + } + } + + return result; + } @Override public SdmResponse listSimulationNodeFiles(ListSimulationNodeTreeReq req) { Long tenantId = ThreadLocalContext.getTenantId(); @@ -274,7 +326,7 @@ public class DimensionTemplateServiceImpl extends ServiceImpl dirInfos = null; - if(ObjectUtils.isEmpty(req.getFileId())){ + if(ObjectUtils.isEmpty(req.getFileId()) && ObjectUtils.isEmpty(req.getFileIds())){ // 第一次进入数据总览页面,右侧不展示文件和文件夹 return SdmResponse.success(); } @@ -283,10 +335,10 @@ public class DimensionTemplateServiceImpl extends ServiceImpl> nodeDirInfos = getSimulationNodeTree(getSimulationNodeTreeReq); + getSimulationNodeTreeReq.setFileIds(null); + SdmResponse> nodeDirInfos = getSimulationNodeTree(getSimulationNodeTreeReq); if (nodeDirInfos.isSuccess() && ObjectUtils.isNotEmpty(nodeDirInfos.getData())) { - dirInfos = nodeDirInfos.getData().stream().map(FileMetadataInfo::getId).toList(); + dirInfos = nodeDirInfos.getData().stream().flatMap(fileMetadataChildrenDTO -> fileMetadataChildrenDTO.getChildren().stream()).map(FileMetadataInfoResp::getId).toList(); } PageHelper.startPage(req.getCurrent(), req.getSize()); @@ -297,24 +349,18 @@ public class DimensionTemplateServiceImpl extends ServiceImpl parentDirInfo = fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getId, parentDirId).eq(FileMetadataInfo::getTenantId, tenantId).oneOpt(); - if (!parentDirInfo.isPresent()) { - return SdmResponse.failed("父文件夹不存在"); - } - // relatedResourceUuid和relatedResourceUuidOwnType不为空才是节点文件夹,才需要查询子节点文件夹文件 GetSimulationNodeTreeReq getSimulationNodeTreeReq = new GetSimulationNodeTreeReq(); getSimulationNodeTreeReq.setDimensionTemplateId(req.getDimensionTemplateId()); - getSimulationNodeTreeReq.setFileId(parentDirId); - SdmResponse> nodeDirInfos = getSimulationNodeTree(getSimulationNodeTreeReq); + getSimulationNodeTreeReq.setFileIds(req.getFileIds()); + SdmResponse> nodeDirInfos = getSimulationNodeTree(getSimulationNodeTreeReq); if (nodeDirInfos.isSuccess() && ObjectUtils.isNotEmpty(nodeDirInfos.getData())) { - dirInfos = nodeDirInfos.getData().stream().map(FileMetadataInfo::getId).toList(); + dirInfos = nodeDirInfos.getData().stream().flatMap(fileMetadataChildrenDTO -> fileMetadataChildrenDTO.getChildren().stream()).map(FileMetadataInfoResp::getId).toList(); } PageHelper.startPage(req.getCurrent(), req.getSize()); - List fileMetadataInfos = fileMetadataInfoService.listSimulationNodeFiles(parentDirId, dirInfos,req.isFilterEmptyData(),tenantId); + List fileMetadataInfos = fileMetadataInfoService.listSimulationNodeFiles(req.getFileIds(), dirInfos,req.isFilterEmptyData(),tenantId); setCreatorNames(fileMetadataInfos); PageInfo page = new PageInfo<>(fileMetadataInfos); diff --git a/data/src/main/java/com/sdm/data/service/impl/FileMetadataInfoServiceImpl.java b/data/src/main/java/com/sdm/data/service/impl/FileMetadataInfoServiceImpl.java index 6a08a4bf..463bf03b 100644 --- a/data/src/main/java/com/sdm/data/service/impl/FileMetadataInfoServiceImpl.java +++ b/data/src/main/java/com/sdm/data/service/impl/FileMetadataInfoServiceImpl.java @@ -24,7 +24,7 @@ public class FileMetadataInfoServiceImpl extends ServiceImpl listSimulationNodeFiles(Long parentId, List fileIds, boolean isFilterEmptyData,Long tenantId) { - return this.baseMapper.listSimulationNodeFiles(parentId, fileIds, isFilterEmptyData,tenantId); + public List listSimulationNodeFiles(List parentIds, List fileIds, boolean isFilterEmptyData, Long tenantId) { + return this.baseMapper.listSimulationNodeFiles(parentIds, fileIds, isFilterEmptyData,tenantId); } } diff --git a/data/src/main/resources/mapper/FileMetadataInfoMapper.xml b/data/src/main/resources/mapper/FileMetadataInfoMapper.xml index 18b91862..0767c00a 100644 --- a/data/src/main/resources/mapper/FileMetadataInfoMapper.xml +++ b/data/src/main/resources/mapper/FileMetadataInfoMapper.xml @@ -26,7 +26,11 @@ SELECT distinct file_metadata_info.* FROM file_metadata_info - WHERE parentId = #{parentId} + WHERE parentId IN ( + + #{parentId} + + ) and tenantId = #{tenantId} AND dataType = 2 AND isLatest = true diff --git a/project/src/main/java/com/sdm/project/controller/SimulationNodeController.java b/project/src/main/java/com/sdm/project/controller/SimulationNodeController.java index 6d07a6e8..6905fa9d 100644 --- a/project/src/main/java/com/sdm/project/controller/SimulationNodeController.java +++ b/project/src/main/java/com/sdm/project/controller/SimulationNodeController.java @@ -144,14 +144,14 @@ public class SimulationNodeController implements ISimulationNodeFeignClient { /** * 根据项目ID和节点类型获取所有节点信息 * - * @param uuid 项目ID + * @param uuids 项目ID * @param nextNodeType 下一级节点类型 * @return SdmResponse> 节点信息 */ @GetMapping("/getAllNodeByProjectIdAndType") @Operation(summary = "根据项目ID和节点类型获取所有节点信息", description = "根据项目ID和节点类型获取所有节点信息") - public SdmResponse> getAllNodeByProjectIdAndType(@RequestParam(value = "chooseNodeId") String uuid, @RequestParam(value = "nextNodeType") String nextNodeType) { - return nodeService.getAllNodeByProjectIdAndType(uuid, nextNodeType); + public SdmResponse> getAllNodeByProjectIdAndType(@RequestParam(value = "chooseNodeIds") List uuids, @RequestParam(value = "nextNodeType") String nextNodeType) { + return nodeService.getAllNodeByProjectIdAndType(uuids, nextNodeType); } /** @@ -159,8 +159,8 @@ public class SimulationNodeController implements ISimulationNodeFeignClient { */ @GetMapping("/getNodeTaskList") @Operation(summary = "获取节点下的task列表", description = "获取节点下的task列表") - public SdmResponse> getNodeTaskList(@RequestParam(value = "uuid") String uuid) { - return nodeService.getNodeTaskList(uuid); + public SdmResponse> getNodeTaskList(@RequestParam(value = "uuids") List uuids) { + return nodeService.getNodeTaskList(uuids); } /** @@ -168,8 +168,8 @@ public class SimulationNodeController implements ISimulationNodeFeignClient { */ @GetMapping("/getNodeTaskRunList") @Operation(summary = "获取task下的run", description = "获取task下的run") - public SdmResponse> getTaskRunList(@RequestParam(value = "uuid") String uuid) { - return nodeService.getTaskRunList(uuid); + public SdmResponse> getTaskRunList(@RequestParam(value = "uuids") List uuids) { + return nodeService.getTaskRunList(uuids); } diff --git a/project/src/main/java/com/sdm/project/service/INodeService.java b/project/src/main/java/com/sdm/project/service/INodeService.java index d71617e5..eae5c0d1 100644 --- a/project/src/main/java/com/sdm/project/service/INodeService.java +++ b/project/src/main/java/com/sdm/project/service/INodeService.java @@ -12,11 +12,9 @@ import com.sdm.common.entity.resp.project.SimulationNodeResp; import com.sdm.project.model.entity.SimulationNode; import com.sdm.project.model.req.*; import com.sdm.project.model.req.YA.SyncCidProjectReq; -import com.sdm.project.model.resp.YA.BosimSaveNodeInfoRsp; import com.sdm.project.model.resp.YA.BosimSaveProjectTaskRsp; import jakarta.servlet.http.HttpServletResponse; import org.springframework.stereotype.Service; -import org.springframework.web.bind.annotation.RequestParam; import java.util.List; @@ -39,11 +37,11 @@ public interface INodeService extends IService { SdmResponse> getAllNodeByBodeType(String nodeType, Long nodeId); - SdmResponse> getAllNodeByProjectIdAndType(String uuid, String nextNodeType); + SdmResponse> getAllNodeByProjectIdAndType(List uuids, String nextNodeType); - SdmResponse> getNodeTaskList(String uuid); + SdmResponse> getNodeTaskList(List uuids); - SdmResponse> getTaskRunList(String uuid); + SdmResponse> getTaskRunList(List uuids); SdmResponse getUserGroupProjectStatistics(Long userGroupId, Long userId); diff --git a/project/src/main/java/com/sdm/project/service/impl/NodeServiceImpl.java b/project/src/main/java/com/sdm/project/service/impl/NodeServiceImpl.java index d7c0a465..9c33e06f 100644 --- a/project/src/main/java/com/sdm/project/service/impl/NodeServiceImpl.java +++ b/project/src/main/java/com/sdm/project/service/impl/NodeServiceImpl.java @@ -819,7 +819,7 @@ public class NodeServiceImpl extends ServiceImpl> getAllNodeByProjectIdAndType(String uuid, String nextNodeType) { + public SdmResponse> getAllNodeByProjectIdAndType(List uuids, String nextNodeType) { SdmResponse> tagMapList = sysConfigFeignClient.getDictionaryData(TagConstant.DICTIONARY_TAG_KEY); if (!tagMapList.isSuccess() || ObjectUtils.isEmpty(tagMapList.getData())) { log.error("字典信息查询失败"); @@ -828,7 +828,7 @@ public class NodeServiceImpl extends ServiceImpltag1 phase-->tag2 Map TagMap = tagMapList.getData().stream().collect(Collectors.toMap(DataDictionary::getDictValue, DataDictionary::getDictName)); - Optional simulationNodeOptional = this.lambdaQuery().eq(SimulationNode::getUuid, uuid).oneOpt(); + Optional simulationNodeOptional = this.lambdaQuery().in(SimulationNode::getUuid, uuids).list().stream().findFirst(); if (!simulationNodeOptional.isPresent()) { return SdmResponse.failed("未找到节点"); } @@ -838,16 +838,16 @@ public class NodeServiceImpl extends ServiceImpl simulationNodeList = this.lambdaQuery() - .eq(TagConstant.TAG1.equals(currentNodeTag), SimulationNode::getTag1, uuid) - .eq(TagConstant.TAG2.equals(currentNodeTag), SimulationNode::getTag2, uuid) - .eq(TagConstant.TAG3.equals(currentNodeTag), SimulationNode::getTag3, uuid) - .eq(TagConstant.TAG4.equals(currentNodeTag), SimulationNode::getTag4, uuid) - .eq(TagConstant.TAG5.equals(currentNodeTag), SimulationNode::getTag5, uuid) - .eq(TagConstant.TAG6.equals(currentNodeTag), SimulationNode::getTag6, uuid) - .eq(TagConstant.TAG7.equals(currentNodeTag), SimulationNode::getTag7, uuid) - .eq(TagConstant.TAG8.equals(currentNodeTag), SimulationNode::getTag8, uuid) - .eq(TagConstant.TAG9.equals(currentNodeTag), SimulationNode::getTag9, uuid) - .eq(TagConstant.TAG10.equals(currentNodeTag), SimulationNode::getTag10, uuid) + .in(TagConstant.TAG1.equals(currentNodeTag), SimulationNode::getTag1, uuids) + .in(TagConstant.TAG2.equals(currentNodeTag), SimulationNode::getTag2, uuids) + .in(TagConstant.TAG3.equals(currentNodeTag), SimulationNode::getTag3, uuids) + .in(TagConstant.TAG4.equals(currentNodeTag), SimulationNode::getTag4, uuids) + .in(TagConstant.TAG5.equals(currentNodeTag), SimulationNode::getTag5, uuids) + .in(TagConstant.TAG6.equals(currentNodeTag), SimulationNode::getTag6, uuids) + .in(TagConstant.TAG7.equals(currentNodeTag), SimulationNode::getTag7, uuids) + .in(TagConstant.TAG8.equals(currentNodeTag), SimulationNode::getTag8, uuids) + .in(TagConstant.TAG9.equals(currentNodeTag), SimulationNode::getTag9, uuids) + .in(TagConstant.TAG10.equals(currentNodeTag), SimulationNode::getTag10, uuids) .eq(SimulationNode::getNodeType, nextNodeType) .list(); @@ -866,11 +866,11 @@ public class NodeServiceImpl extends ServiceImpl> getNodeTaskList(String uuid) { - if(ObjectUtils.isEmpty(uuid)){ + public SdmResponse> getNodeTaskList(List uuids) { + if(CollectionUtils.isEmpty(uuids)){ return SdmResponse.success(); } - List simulationTasks = simulationTaskService.lambdaQuery().eq(SimulationTask::getNodeId, uuid).list(); + List simulationTasks = simulationTaskService.lambdaQuery().in(SimulationTask::getNodeId, uuids).list(); if(CollectionUtils.isEmpty(simulationTasks)){ return SdmResponse.success(); } @@ -888,11 +888,11 @@ public class NodeServiceImpl extends ServiceImpl> getTaskRunList(String uuid) { - if(ObjectUtils.isEmpty(uuid)){ + public SdmResponse> getTaskRunList(List uuids) { + if(ObjectUtils.isEmpty(uuids)){ return SdmResponse.success(); } - List simulationRunList = simulationRunService.lambdaQuery().eq(SimulationRun::getTaskId, uuid).list(); + List simulationRunList = simulationRunService.lambdaQuery().eq(SimulationRun::getTaskId, uuids).list(); if(CollectionUtils.isEmpty(simulationRunList)){ return SdmResponse.success(); }