fix:工位排序
This commit is contained in:
@@ -372,10 +372,30 @@ public class DataAnalysisServiceImpl implements IDataAnalysisService {
|
||||
return;
|
||||
}
|
||||
|
||||
Comparator<SimulationTaskResultCurveResp> comparator = Comparator.comparing(
|
||||
item -> getSortableValue(item, orderBy),
|
||||
Comparator.nullsLast(String.CASE_INSENSITIVE_ORDER)
|
||||
);
|
||||
Comparator<SimulationTaskResultCurveResp> comparator;
|
||||
if ("createTime".equalsIgnoreCase(orderBy)) {
|
||||
comparator = Comparator.comparing(
|
||||
SimulationTaskResultCurveResp::getCreateTime,
|
||||
Comparator.nullsLast(Comparator.naturalOrder())
|
||||
);
|
||||
} else if ("formatFileSize".equalsIgnoreCase(orderBy)) {
|
||||
// 按「字节数」做数值排序
|
||||
comparator = Comparator.comparing(
|
||||
item -> {
|
||||
if (ObjectUtils.isEmpty(item) || StringUtils.isBlank(item.getFormatFileSize())) {
|
||||
return null;
|
||||
}
|
||||
return FileSizeUtils.parseFileSizeToBytes(item.getFormatFileSize());
|
||||
},
|
||||
Comparator.nullsLast(Comparator.naturalOrder())
|
||||
);
|
||||
} else {
|
||||
// 其他 TAG 字段按字符串字典序排序
|
||||
comparator = Comparator.comparing(
|
||||
item -> getSortableStringValue(item, orderBy),
|
||||
Comparator.nullsLast(String.CASE_INSENSITIVE_ORDER)
|
||||
);
|
||||
}
|
||||
|
||||
if ("desc".equalsIgnoreCase(orderType)) {
|
||||
comparator = comparator.reversed();
|
||||
@@ -384,20 +404,14 @@ public class DataAnalysisServiceImpl implements IDataAnalysisService {
|
||||
data.sort(comparator);
|
||||
}
|
||||
|
||||
private String getSortableValue(SimulationTaskResultCurveResp item, String orderBy) {
|
||||
private String getSortableStringValue(SimulationTaskResultCurveResp item, String orderBy) {
|
||||
if (ObjectUtils.isEmpty(item)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ("createTime".equalsIgnoreCase(orderBy)) {
|
||||
return ObjectUtils.isNotEmpty(item.getCreateTime()) ? item.getCreateTime().toString() : null;
|
||||
}
|
||||
if ("originalName".equalsIgnoreCase(orderBy)) {
|
||||
return item.getOriginalName();
|
||||
}
|
||||
if ("formatFileSize".equalsIgnoreCase(orderBy)) {
|
||||
return String.valueOf(FileSizeUtils.parseFileSizeToBytes(item.getFormatFileSize()));
|
||||
}
|
||||
|
||||
TagReq tagReq = item.getTagReq();
|
||||
if (ObjectUtils.isEmpty(tagReq)) {
|
||||
|
||||
Reference in New Issue
Block a user