获取某个字段的值
List<Integer> num = modelList.stream().map(model::getID).collect(Collectors.toList());
根据某个字段去重再获取某个字段的值。
List<CallBillModel> studentList = CBModels.stream()
.collect(Collectors.collectingAndThen(
Collectors.toCollection(
() -> new TreeSet<>(Comparator.comparing(CallBillModel::getCallUuid))),
ArrayList::new));
去重,取最后一条
hisLabReportModelList = new ArrayList<>(hisLabReportModelList.stream()
.collect(Collectors.toMap(HisLabReportModel::getCheckNo, Function.identity(), (key1, key2) -> key2))
.values());
根据某个字段 分组构造数据、统计数量,然后排序
List<WardDurationCall> durationNameList = wardCallStatistics.getDurations().stream()
.collect(Collectors.groupingBy(
item -> StringHelper.format("{0}_{1}", item.getDurationName(), item.getDurationOrder()),
Collectors.counting()))
.entrySet().stream().map(item ->
{
WardDurationCall wardDurationCall = new WardDurationCall();
String[] keyData = item.getKey().split("_");
wardDurationCall.setDurationName(keyData[0]);
wardDurationCall.setCount(item.getValue());
wardDurationCall.setDurationOrder(Integer.parseInt(keyData[1]));
return wardDurationCall;
}).sorted(Comparator.comparing(WardDurationCall::getDurationOrder))
.collect(Collectors.toList());