fix:数据查询支持列头无关联,基于tag查询 查询
This commit is contained in:
@@ -61,4 +61,10 @@ public class GetSimulationTaskFileReq extends BaseReq {
|
||||
|
||||
@Schema(description = "标签筛选参数")
|
||||
private TagReq tagReq;
|
||||
|
||||
@Schema(description = "排序字段名(如: tag1Name、tag2Name...taskName、runName)")
|
||||
private String orderBy;
|
||||
|
||||
@Schema(description = "排序类型:Asc/Desc")
|
||||
private String orderType;
|
||||
}
|
||||
|
||||
@@ -117,7 +117,9 @@ public class DataAnalysisServiceImpl implements IDataAnalysisService {
|
||||
BeanUtils.copyProperties(file, resp);
|
||||
hierarchyHelper.setTagReqFromFileMetadata(file, resp);
|
||||
return resp;
|
||||
}).toList();
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
sortByTagFieldInCurrentPage(finalResultList, req.getOrderBy(), req.getOrderType());
|
||||
|
||||
PageInfo<SimulationTaskResultCurveResp> pageInfo = new PageInfo<>(finalResultList);
|
||||
pageInfo.setTotal(page.getTotal());
|
||||
@@ -271,6 +273,49 @@ public class DataAnalysisServiceImpl implements IDataAnalysisService {
|
||||
}
|
||||
}
|
||||
|
||||
private void sortByTagFieldInCurrentPage(List<SimulationTaskResultCurveResp> data, String orderBy, String orderType) {
|
||||
if (CollectionUtils.isEmpty(data) || StringUtils.isBlank(orderBy)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Comparator<SimulationTaskResultCurveResp> comparator = Comparator.comparing(
|
||||
item -> getSortableValue(item, orderBy),
|
||||
Comparator.nullsLast(String.CASE_INSENSITIVE_ORDER)
|
||||
);
|
||||
|
||||
if ("desc".equalsIgnoreCase(orderType)) {
|
||||
comparator = comparator.reversed();
|
||||
}
|
||||
|
||||
data.sort(comparator);
|
||||
}
|
||||
|
||||
private String getSortableValue(SimulationTaskResultCurveResp item, String orderBy) {
|
||||
if (ObjectUtils.isEmpty(item)) {
|
||||
return null;
|
||||
}
|
||||
TagReq tagReq = item.getTagReq();
|
||||
if (ObjectUtils.isEmpty(tagReq)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return switch (orderBy) {
|
||||
case "tag1Name" -> tagReq.getTag1Name();
|
||||
case "tag2Name" -> tagReq.getTag2Name();
|
||||
case "tag3Name" -> tagReq.getTag3Name();
|
||||
case "tag4Name" -> tagReq.getTag4Name();
|
||||
case "tag5Name" -> tagReq.getTag5Name();
|
||||
case "tag6Name" -> tagReq.getTag6Name();
|
||||
case "tag7Name" -> tagReq.getTag7Name();
|
||||
case "tag8Name" -> tagReq.getTag8Name();
|
||||
case "tag9Name" -> tagReq.getTag9Name();
|
||||
case "tag10Name" -> tagReq.getTag10Name();
|
||||
case "taskName" -> tagReq.getTaskName();
|
||||
case "runName" -> tagReq.getRunName();
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
||||
private SdmResponse<PageDataResp<List<SimulationTaskResultCurveResp>>> getTaskLevelFile(GetSimulationTaskFileReq req, QueryBigFileReq queryBigFileReq) {
|
||||
// level=task,查task下的交付物文件夹 再根据fileType查具体的云图文件、曲线文件夹下的文件
|
||||
List<FileMetadataInfo> deliverableFileInfoList = fileMetadataInfoService.lambdaQuery()
|
||||
@@ -315,12 +360,13 @@ public class DataAnalysisServiceImpl implements IDataAnalysisService {
|
||||
|
||||
setTagReqForSimulationResult(finalResultList, fileIdList);
|
||||
|
||||
sortByTagFieldInCurrentPage(finalResultList, req.getOrderBy(), req.getOrderType());
|
||||
List<SimulationTaskResultCurveResp> sortedList = finalResultList.stream()
|
||||
.sorted(
|
||||
// 第一步:按 createTime 排序(null 排最后)
|
||||
Comparator.comparing(SimulationTaskResultCurveResp::getCreateTime, Comparator.nullsLast(LocalDateTime::compareTo))
|
||||
// 第二步:createTime 相同时,按 sortOrder 排序(null 排最后)
|
||||
.thenComparing(SimulationTaskResultCurveResp::getSortOrder, Comparator.nullsLast(Integer::compare))
|
||||
.thenComparing(SimulationTaskResultCurveResp::getSortOrder, Comparator.nullsLast(Integer::compare))
|
||||
).toList();
|
||||
|
||||
PageInfo<SimulationTaskResultCurveResp> page1 = new PageInfo<>(sortedList);
|
||||
|
||||
@@ -364,7 +364,7 @@ public class FileMetadataHierarchyHelper {
|
||||
String tagName = uuidChain.stream()
|
||||
.map(uuidNameMap::get)
|
||||
.filter(StringUtils::isNotBlank)
|
||||
.collect(Collectors.joining("-"));
|
||||
.collect(Collectors.joining("/"));
|
||||
tagReqClass.getMethod("setTag" + i + "Name", String.class).invoke(tagReq, tagName);
|
||||
}
|
||||
tagReqClass.getMethod("setTaskName", String.class).invoke(tagReq, uuidNameMap.get(taskId));
|
||||
|
||||
Reference in New Issue
Block a user