Skip to content

Commit

Permalink
异常列表排序处理!
Browse files Browse the repository at this point in the history
  • Loading branch information
liuchuan committed Dec 13, 2021
1 parent d7fb0bd commit f492ede
Showing 1 changed file with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,7 @@ public List<ApplicationErrorOutput> list(ApplicationErrorQueryInput queryRequest
convertNodeUploadDataList(responseList, nodeUploadDataDTOList);
}

// 按照时间倒序输出
return responseList.stream().filter(response -> StrUtil.isNotBlank(response.getTime()))
.sorted((a1, a2) -> a2.getTime().compareTo(a1.getTime()))
.collect(Collectors.toList());
return this.processErrorList(responseList);
}

private ApplicationDetailResult ensureApplicationExist(ApplicationErrorQueryInput queryRequest) {
Expand Down Expand Up @@ -247,4 +244,29 @@ private ApplicationErrorOutput getNodeErrorResponse(String applicationName, Inte
return applicationErrorResponse;
}

/**
* 错误列表排序处理
*
* @param responseList 错误列表
* @return 排序好的错误列表
*/
private List<ApplicationErrorOutput> processErrorList(List<ApplicationErrorOutput> responseList) {
// 按照时间倒序输出
List<ApplicationErrorOutput> sortedList = responseList.stream().filter(
response -> StrUtil.isNotBlank(response.getTime()))
.sorted((a1, a2) -> a2.getTime().compareTo(a1.getTime()))
.collect(Collectors.toList());

List<ApplicationErrorOutput> noTimeList = responseList.stream()
.filter(response -> StrUtil.isNotBlank(response.getTime()))
.collect(Collectors.toList());

if (sortedList.isEmpty()) {
return noTimeList;
}

sortedList.addAll(noTimeList);
return sortedList;
}

}

0 comments on commit f492ede

Please sign in to comment.