//List1
List<FaultReport> reportDetail = reportMapper.getReportDetail(pagePo);
List<Long> collect = reportDetail.stream().map(FaultReport::getId).collect(Collectors.toList());
//List2
List<FaultApproval> approvalDetail = approvalMapper.getApprovalDetail(pagePo.getRepairPeople(), collect);
//拼接
List<FaultPageVo> faultPageVos = approvalDetail.stream().flatMap(approval -> reportDetail.stream()
.filter(report -> Objects.equals(approval.getReportId(), report.getId()))
.map(report -> {
FaultPageVo faultPageVo = new FaultPageVo();
faultPageVo.setId(report.getId());
faultPageVo.setCode(report.getCode());
......
return faultPageVo;
})
).collect(Collectors.toList());
标签:stream,List,collect,拼接,report,放入,faultPageVo
From: https://www.cnblogs.com/psuitj/p/18025652