1、筛选出workGroupEquipmentVOS中RoomVid相同的元素,最后在返回去重的list
//去掉在不同群组的同一个设备
List<WorkGroupDeviceVO> uniqueList = workGroupEquipmentVOS.stream().collect(Collectors.collectingAndThen(
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WorkGroupDeviceVO::getRoomVid))),
ArrayList::new));
uniqueList.sort((m1, m2) -> m2.getCreateTime().compareTo(m1.getCreateTime()));
2、uniqueList中的某字段是否包含了abilityConfigs中的任何一个值,返回的布尔类型
//typeName为空默认查询等于E8的数据,否则查询E8的数据再加上终端能力的筛选
List<String> abilityConfigs = pageClassRoomCondition.getAbilityConfig();
List<WorkGroupDeviceVO> workGroupEquipmentVOSVO = new ArrayList<>();
if (!StrUtil.hasBlank(pageClassRoomCondition.getTypeName())) {
//终端设备能力为attendancer,speecher,listener,caller,callee,interacter如果搜索条件为listener,interacter也应该都包含返回数据
uniqueList.forEach(workGroupEquipmentVO->{
boolean flag = abilityConfigs.stream().allMatch(str -> workGroupEquipmentVO.getAbilityConfig().contains(str));
if (flag){
workGroupEquipmentVOSVO.add(workGroupEquipmentVO);
}
});
page.setRecords(workGroupEquipmentVOSVO);
}else {
//typeName为空默认原逻辑不变
page.setRecords(uniqueList);
}
3、将一个list的值赋到另一个list
List<Object> collect = demoList.stream().map(result -> new DemoListVO(result.getKeyNo(), result.getName())).collect(Collectors.toList());
后续遇到别的高级操作再继续完善。。。。。。