例如:
plants 和houses 两个集合,进行对比过滤,取出plants里和houses不同的部分,并返回。
List<ImprovedSeedPlant> plants = improvedSeedPlantMapper.selectList(spWrapper);
List<StudsheepSheepHouse> houses = houseMapper.selectList(houseWrapper);
List<ImprovedSeedPlant> dataList = new ArrayList<>();
Map<String,StudsheepSheepHouse> resultMap = houses.stream().collect(Collectors.toMap(StudsheepSheepHouse::getHouseNum, Function.identity()));
if (!org.springframework.util.StringUtils.isEmpty(plants)){
for (ImprovedSeedPlant p : plants) {
String key = p.getSheepHouseName();
if(!resultMap.containsKey(key)){
dataList.add(p);
}
}
}