过滤相同数据 currentYearDeptNames=currentYearDeptNamesstream distinct collectCollectorstoList; 获取所有部门数据 list2 得到list2含list1的数据的新集合 ListJSONObject
可以使用filter方法来过滤相同数据,并生成新的集合。修改代码如下:
// 过滤相同数据
currentYearDeptNames = currentYearDeptNames.stream()
.distinct()
.collect(Collectors.toList());
// 获取所有部门数据 list2
List<JSONObject> deptList = v_queue_number_recordMapper.getDeptList();
// 得到list2含list1的数据的新集合
List<JSONObject> filteredDeptList = deptList.stream()
.filter(s -> currentYearDeptNames.contains(s.getString("DEPT_NAME")))
.collect(Collectors.toList());
return filteredDeptList;
原文地址: https://www.cveoy.top/t/topic/i4f7 著作权归作者所有。请勿转载和采集!