標籤:array ppi contains stream npos osi filter hash tst
1、從List<Staff>篩選合格List<String>:
List<Staff> staffListtemp=Lists.newArrayList();List<String> staffIdList=staffListtemp.stream().filter(staff->deptIdSet.contains(staff.getDeptId())).map(staffId->staffId.getStaffId()).collect(Collectors.toList());
2、從List<PositionRealtime>轉為Map<String,PositionRealtime>:
List<PositionRealtime> prListMap<String,PositionRealtime> prMap=prList.stream().collect(Collectors.toMap(PositionRealtime::getStaffId, PositionRealtime->PositionRealtime));
3、從Set<String>轉為拼接後的String:
Set<String> inPostStaffIds = Sets.newHashSet();String inPostIds = inPostStaffIds.stream().reduce((a,b)->a+","+b).get();
4、從List<StaffGpsTimeDTO>通過StaffId作為分組條件分組為Map<String,List<StaffGpsTimeDTO>>對象:
List<StaffGpsTimeDTO> positionHistoryTimeList = positionHistoryManageDao.getPositionHistoryTimeList(filterPropertyMap2);for(StaffGpsTimeDTO staffGpsTimeDTO : positionHistoryTimeList){ List<Date> list = Lists.newArrayList(); if(gpsMap.get(staffGpsTimeDTO.getStaffId()) != null){ list = gpsMap.get(staffGpsTimeDTO.getStaffId()); } list.add(staffGpsTimeDTO.getGpsTime()); gpsMap.put(staffGpsTimeDTO.getStaffId(), list);}Map<string,List<>> aaa=positionHistoryTimeList.stream().collect(Collectors.groupingBy(StaffGpsTimeDTO::getStaffId,Collectors.mapping(StaffGpsTimeDTO::getGpsTime, Collectors.toList())));
java stream操作案例