fix:工位排序
This commit is contained in:
@@ -441,6 +441,14 @@ public class DimensionTemplateServiceImpl extends ServiceImpl<DimensionTemplateM
|
|||||||
if (dataType1 != null && dataType2 != null && !dataType1.equals(dataType2)) {
|
if (dataType1 != null && dataType2 != null && !dataType1.equals(dataType2)) {
|
||||||
return dataType1.compareTo(dataType2); // 升序:1(文件夹) < 2(文件)
|
return dataType1.compareTo(dataType2); // 升序:1(文件夹) < 2(文件)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isWorkspace1 = dto1.getMergeSameNameChildren().stream()
|
||||||
|
.anyMatch(child -> NodeTypeEnum.WORKSPACE.getValue().equals(child.getRelatedResourceUuidOwnType()));
|
||||||
|
boolean isWorkspace2 = dto2.getMergeSameNameChildren().stream()
|
||||||
|
.anyMatch(child -> NodeTypeEnum.WORKSPACE.getValue().equals(child.getRelatedResourceUuidOwnType()));
|
||||||
|
if (isWorkspace1 && isWorkspace2) {
|
||||||
|
return compareWorkspaceNodeCode(dto1.getNodeCode(), dto2.getNodeCode());
|
||||||
|
}
|
||||||
|
|
||||||
// 如果存在PHASE类型节点,dataType相同时按主键ID正序排序
|
// 如果存在PHASE类型节点,dataType相同时按主键ID正序排序
|
||||||
if (hasPhaseNode) {
|
if (hasPhaseNode) {
|
||||||
@@ -475,10 +483,60 @@ public class DimensionTemplateServiceImpl extends ServiceImpl<DimensionTemplateM
|
|||||||
"批量设置文件的节点信息tag1-tag10:" + (start5-start4) + "毫秒," +
|
"批量设置文件的节点信息tag1-tag10:" + (start5-start4) + "毫秒," +
|
||||||
"批量填充文件类型标签信息:" + (start6-start5) + "毫秒," +
|
"批量填充文件类型标签信息:" + (start6-start5) + "毫秒," +
|
||||||
"结果排序:" + (System.currentTimeMillis() - start6) + "毫秒");
|
"结果排序:" + (System.currentTimeMillis() - start6) + "毫秒");
|
||||||
|
|
||||||
|
// 特殊的定制逻辑,工位需要排序
|
||||||
|
moveWorkspaceToFirst(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void moveWorkspaceToFirst(List<FileMetadataChildrenDTO> result) {
|
||||||
|
if (CollectionUtils.isEmpty(result)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FileMetadataChildrenDTO specialWorkspace = result.stream()
|
||||||
|
.filter(this::isWorkspaceNode)
|
||||||
|
.filter(dto -> StringUtils.contains(dto.getNodeCode(), "-M"))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
if (specialWorkspace != null) {
|
||||||
|
result.remove(specialWorkspace);
|
||||||
|
result.add(0, specialWorkspace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isWorkspaceNode(FileMetadataChildrenDTO dto) {
|
||||||
|
return dto != null && CollectionUtils.isNotEmpty(dto.getMergeSameNameChildren())
|
||||||
|
&& dto.getMergeSameNameChildren().stream()
|
||||||
|
.anyMatch(child -> NodeTypeEnum.WORKSPACE.getValue().equals(child.getRelatedResourceUuidOwnType()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private int compareWorkspaceNodeCode(String nodeCode1, String nodeCode2) {
|
||||||
|
if (nodeCode1 == null || nodeCode2 == null) {
|
||||||
|
return String.valueOf(nodeCode1).compareTo(String.valueOf(nodeCode2));
|
||||||
|
}
|
||||||
|
if (nodeCode1.contains("-M") || nodeCode2.contains("-M")) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
String[] workspaceNode1 = nodeCode1.split("-");
|
||||||
|
String[] workspaceNode2 = nodeCode2.split("-");
|
||||||
|
if (workspaceNode1.length != 2 || workspaceNode2.length != 2) {
|
||||||
|
return nodeCode1.compareTo(nodeCode2);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
int prefix1 = Integer.parseInt(workspaceNode1[0]);
|
||||||
|
int prefix2 = Integer.parseInt(workspaceNode2[0]);
|
||||||
|
if (prefix1 != prefix2) {
|
||||||
|
return Integer.compare(prefix1, prefix2);
|
||||||
|
}
|
||||||
|
int suffix1 = Integer.parseInt(workspaceNode1[1]);
|
||||||
|
int suffix2 = Integer.parseInt(workspaceNode2[1]);
|
||||||
|
return Integer.compare(suffix1, suffix2);
|
||||||
|
} catch (NumberFormatException ex) {
|
||||||
|
return nodeCode1.compareTo(nodeCode2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取节点文件列表
|
* 获取节点文件列表
|
||||||
|
|||||||
Reference in New Issue
Block a user