從collect集合中,提取所有的元素的id:
public void test(){
List<CashDataPublicReportLineDTO> collect = result.stream().flatMap(headerDTO -> headerDTO.getLineList().stream()).collect(toList());
// getScheduleLineId 爲CashDataPublicReportLineDTO 的某個屬性
List<Long> lineIds = collect.stream().map(CashDataPublicReportLineDTO::getScheduleLineId).collect(toList());
}