Java8集合分组
通过java8新特性将⼀个list转换为⼀个list包含⼀个⼦list ⼦List也包含⼀个list的形式
private List<RecordExcelVO> convertExcel(List<ProjectDeclaration> projectList) {
List<RecordExcelVO> list = new ArrayList<>();
if (CollectionUtils.isNotEmpty(projectList)) {
// 按照备案⽇期分组
Map<String, List<ProjectDeclaration>> firstGroup = projectList.stream().upingBy(item -> DateFormatUtils.RecordTime(), Constants.YEAR_MONTH)));
for (Map.Entry<String, List<ProjectDeclaration>> first : Set()) {
RecordExcelVO recordExcelVO = new RecordExcelVO();
List<RecordExcelVO.CompanyVO> companies = new ArrayList<>();
recordExcelVO.Key());
recordExcelVO.setCompanies(companies);
if (CollectionUtils.Value())) {
// 按照建设单位分组
Map<String, List<ProjectDeclaration>> secondGroup = Value().stream().upingBy(item -> CompanyName()));
for (Map.Entry<String, List<ProjectDeclaration>> second : Set()) {
RecordExcelVO.CompanyVO company = new RecordExcelVO.CompanyVO();
company.Key());
company.Value());
companies.add(company);
}
}
list.add(recordExcelVO);
}
}
list = list.stream().sorted(Comparatorparing(RecordExcelVO::getMonth)).List());
return list;sortedlist
}

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。