数据总览多维度合并展示
This commit is contained in:
8
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
8
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="AutoCloseableResource" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="METHOD_MATCHER_CONFIG" value="java.util.Formatter,format,java.io.Writer,append,com.google.common.base.Preconditions,checkNotNull,org.hibernate.Session,close,java.io.PrintWriter,printf,java.io.PrintStream,printf,java.lang.foreign.Arena,ofAuto,java.lang.foreign.Arena,global,com.github.pagehelper.page.PageMethod,startPage" />
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
||||
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"java.compile.nullAnalysis.mode": "automatic"
|
||||
}
|
||||
@@ -35,9 +35,6 @@ public interface IDimensionTemplateService extends IService<DimensionTemplate> {
|
||||
|
||||
/**
|
||||
* 根据数据显示维度展示左侧节点树
|
||||
* dimensionTemplateId+chooseUuid+chooseNodeType根据数据显示维度查询当前节点下的文件夹和文件,
|
||||
* dimensionTemplateId+fileId支持进入普通文件夹和节点文件夹查询下一层,
|
||||
* 支持分页查询
|
||||
*
|
||||
* @param req 获取模拟节点树的请求参数
|
||||
* @return SdmResponse 响应对象,包含模拟节点树数据或错误信息
|
||||
|
||||
@@ -16,6 +16,7 @@ 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.PageDataResp;
|
||||
import com.sdm.common.entity.resp.data.FileMetadataInfoResp;
|
||||
import com.sdm.common.entity.resp.system.CIDUserResp;
|
||||
import com.sdm.common.feign.impl.project.SimulationNodeFeignClientImpl;
|
||||
@@ -39,6 +40,7 @@ import com.sdm.data.service.IFileMetadataInfoService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -240,19 +242,19 @@ public class DimensionTemplateServiceImpl extends ServiceImpl<DimensionTemplateM
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 3、获取当前节点下的任务、算列
|
||||
SdmResponse<List<AllNodeByProjectIdAndTypeResp>> nodeTaskList = simuluationNodeFeignClient.getNodeTaskList(chooseUuids);
|
||||
if (nodeTaskList.isSuccess()) {
|
||||
uuids.addAll(nodeTaskList.getData().stream().map(AllNodeByProjectIdAndTypeResp::getUuid).toList());
|
||||
log.info("获取节点下task的uudis:{}", uuids);
|
||||
}
|
||||
// 3、获取当前节点下的任务、算列
|
||||
SdmResponse<List<AllNodeByProjectIdAndTypeResp>> nodeTaskList = simuluationNodeFeignClient.getNodeTaskList(chooseUuids);
|
||||
if (nodeTaskList.isSuccess()) {
|
||||
uuids.addAll(nodeTaskList.getData().stream().map(AllNodeByProjectIdAndTypeResp::getUuid).toList());
|
||||
log.info("获取节点下task的uudis:{}", uuids);
|
||||
}
|
||||
|
||||
SdmResponse<List<AllNodeByProjectIdAndTypeResp>> taskRunList = simuluationNodeFeignClient.getTaskRunList(chooseUuids);
|
||||
if (taskRunList.isSuccess()) {
|
||||
uuids.addAll(taskRunList.getData().stream().map(AllNodeByProjectIdAndTypeResp::getUuid).toList());
|
||||
log.info("获取节点下taskRun的uudis:{}", uuids);
|
||||
SdmResponse<List<AllNodeByProjectIdAndTypeResp>> taskRunList = simuluationNodeFeignClient.getTaskRunList(chooseUuids);
|
||||
if (taskRunList.isSuccess()) {
|
||||
uuids.addAll(taskRunList.getData().stream().map(AllNodeByProjectIdAndTypeResp::getUuid).toList());
|
||||
log.info("获取节点下taskRun的uudis:{}", uuids);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -318,55 +320,104 @@ public class DimensionTemplateServiceImpl extends ServiceImpl<DimensionTemplateM
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取节点文件列表
|
||||
* 按照显示维度展示后,会打乱原本的文件夹父子关系,需要重新构建父子关系:
|
||||
* 先调用 getSimulationNodeTree 按照维度查询项目子节点node,根据node-uuid获取fileId
|
||||
* @param req 请求参数
|
||||
* @return 文件列表
|
||||
*/
|
||||
@Override
|
||||
public SdmResponse listSimulationNodeFiles(ListSimulationNodeTreeReq req) {
|
||||
Long tenantId = ThreadLocalContext.getTenantId();
|
||||
// 按照显示维度展示后,会打乱原本的文件夹父子关系,需要重新构建父子关系:
|
||||
// 1、先调用 getSimulationNodeTree 按照维度查询项目子节点node,根据node-uuid获取fileId
|
||||
// 2、再查询原本的普通文件夹信息,需要isProjectDimension=true 只查询普通文件夹,不查询节点文件夹,union all 查询node的fileId 后 分页查询
|
||||
Long parentDirId;
|
||||
List<Long> dirInfos = null;
|
||||
if(ObjectUtils.isEmpty(req.getFileId()) && ObjectUtils.isEmpty(req.getFileIds())){
|
||||
|
||||
// 处理空参数情况
|
||||
if (ObjectUtils.isEmpty(req.getFileId()) && ObjectUtils.isEmpty(req.getFileIds())) {
|
||||
// 第一次进入数据总览页面,右侧不展示文件和文件夹
|
||||
return SdmResponse.success();
|
||||
}
|
||||
|
||||
if(0L==req.getFileId()){
|
||||
// 处理根目录情况
|
||||
if (0L == req.getFileId()) {
|
||||
// 和前端规定 0=触发根目录按钮,相当于获取左侧文件树的根节点文件夹
|
||||
GetSimulationNodeTreeReq getSimulationNodeTreeReq = new GetSimulationNodeTreeReq();
|
||||
getSimulationNodeTreeReq.setDimensionTemplateId(req.getDimensionTemplateId());
|
||||
getSimulationNodeTreeReq.setFileIds(null);
|
||||
SdmResponse<List<FileMetadataChildrenDTO>> nodeDirInfos = getSimulationNodeTree(getSimulationNodeTreeReq);
|
||||
if (nodeDirInfos.isSuccess() && ObjectUtils.isNotEmpty(nodeDirInfos.getData())) {
|
||||
dirInfos = nodeDirInfos.getData().stream().flatMap(fileMetadataChildrenDTO -> fileMetadataChildrenDTO.getChildren().stream()).map(FileMetadataInfoResp::getId).toList();
|
||||
}
|
||||
|
||||
PageHelper.startPage(req.getCurrent(), req.getSize());
|
||||
List<FileMetadataInfo> fileMetadataInfos = fileMetadataInfoService.listSimulationNodeDir(dirInfos, req.isFilterEmptyData(), tenantId);
|
||||
|
||||
PageInfo<FileMetadataInfo> page = new PageInfo<>(fileMetadataInfos);
|
||||
return PageUtils.getJsonObjectSdmResponse(fileMetadataInfos, page);
|
||||
return handleRootDirectory(req, tenantId);
|
||||
}
|
||||
|
||||
//fileId 不为空也不为0,是右侧点击进入文件夹下一层级查询
|
||||
// relatedResourceUuid和relatedResourceUuidOwnType不为空才是节点文件夹,才需要查询子节点文件夹文件
|
||||
// 处理普通目录情况
|
||||
return handleNormalDirectory(req, tenantId);
|
||||
}
|
||||
|
||||
private SdmResponse handleRootDirectory(ListSimulationNodeTreeReq req, Long tenantId) {
|
||||
GetSimulationNodeTreeReq getSimulationNodeTreeReq = new GetSimulationNodeTreeReq();
|
||||
getSimulationNodeTreeReq.setDimensionTemplateId(req.getDimensionTemplateId());
|
||||
getSimulationNodeTreeReq.setFileIds(null);
|
||||
|
||||
SdmResponse<List<FileMetadataChildrenDTO>> nodeDirInfos = getSimulationNodeTree(getSimulationNodeTreeReq);
|
||||
List<Long> dirInfos = extractDirIdsFromResponse(nodeDirInfos);
|
||||
|
||||
// 获取所有数据
|
||||
List<FileMetadataInfo> allFileMetadataInfos = fileMetadataInfoService.listSimulationNodeDir(dirInfos, req.isFilterEmptyData(), tenantId);
|
||||
|
||||
return processAndPageResults(allFileMetadataInfos, req);
|
||||
}
|
||||
|
||||
private SdmResponse handleNormalDirectory(ListSimulationNodeTreeReq req, Long tenantId) {
|
||||
GetSimulationNodeTreeReq getSimulationNodeTreeReq = new GetSimulationNodeTreeReq();
|
||||
getSimulationNodeTreeReq.setDimensionTemplateId(req.getDimensionTemplateId());
|
||||
getSimulationNodeTreeReq.setFileIds(req.getFileIds());
|
||||
|
||||
SdmResponse<List<FileMetadataChildrenDTO>> nodeDirInfos = getSimulationNodeTree(getSimulationNodeTreeReq);
|
||||
if (nodeDirInfos.isSuccess() && ObjectUtils.isNotEmpty(nodeDirInfos.getData())) {
|
||||
dirInfos = nodeDirInfos.getData().stream().flatMap(fileMetadataChildrenDTO -> fileMetadataChildrenDTO.getChildren().stream()).map(FileMetadataInfoResp::getId).toList();
|
||||
List<Long> dirInfos = extractDirIdsFromResponse(nodeDirInfos);
|
||||
|
||||
// 获取所有数据
|
||||
List<FileMetadataInfo> allFileMetadataInfos = fileMetadataInfoService.listSimulationNodeFiles(
|
||||
req.getFileIds(),
|
||||
dirInfos,
|
||||
req.isFilterEmptyData(),
|
||||
tenantId);
|
||||
|
||||
return processAndPageResults(allFileMetadataInfos, req);
|
||||
}
|
||||
|
||||
private List<Long> extractDirIdsFromResponse(SdmResponse<List<FileMetadataChildrenDTO>> response) {
|
||||
if (response.isSuccess() && ObjectUtils.isNotEmpty(response.getData())) {
|
||||
return response.getData().stream()
|
||||
.flatMap(dto -> dto.getChildren().stream())
|
||||
.map(FileMetadataInfoResp::getId)
|
||||
.toList();
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
||||
PageHelper.startPage(req.getCurrent(), req.getSize());
|
||||
List<FileMetadataInfo> fileMetadataInfos = fileMetadataInfoService.listSimulationNodeFiles(req.getFileIds(), dirInfos,req.isFilterEmptyData(),tenantId);
|
||||
private SdmResponse processAndPageResults(List<FileMetadataInfo> fileMetadataInfos, ListSimulationNodeTreeReq req) {
|
||||
// 设置创建者名称
|
||||
setCreatorNames(fileMetadataInfos);
|
||||
|
||||
PageInfo<FileMetadataInfo> page = new PageInfo<>(fileMetadataInfos);
|
||||
return PageUtils.getJsonObjectSdmResponse(fileMetadataInfos, page);
|
||||
// 使用 mergeNodeDirInfos 处理所有数据
|
||||
List<FileMetadataChildrenDTO> mergedResults = mergeNodeDirInfos(fileMetadataInfos);
|
||||
|
||||
// 手动分页
|
||||
int pageSize = req.getSize();
|
||||
int currentPage = req.getCurrent();
|
||||
int fromIndex = (currentPage - 1) * pageSize;
|
||||
int toIndex = Math.min(fromIndex + pageSize, mergedResults.size());
|
||||
|
||||
List<FileMetadataChildrenDTO> pagedResults = new ArrayList<>();
|
||||
if (fromIndex < mergedResults.size()) {
|
||||
pagedResults = mergedResults.subList(fromIndex, toIndex);
|
||||
}
|
||||
|
||||
PageInfo<FileMetadataChildrenDTO> pageInfo = new PageInfo<>(pagedResults);
|
||||
pageInfo.setTotal(mergedResults.size());
|
||||
pageInfo.setPageNum(currentPage);
|
||||
pageInfo.setPageSize(pageSize);
|
||||
|
||||
return PageUtils.getJsonObjectSdmResponse(pagedResults, pageInfo);
|
||||
}
|
||||
|
||||
|
||||
private void setCreatorNames(List<FileMetadataInfo> list) {
|
||||
try {
|
||||
if (ObjectUtils.isNotEmpty(list)) {
|
||||
|
||||
Reference in New Issue
Block a user