JDK的Stream流解决合并两个相同主键集合里的数据
List list = allList.stream().collect(
Collectors.collectingAndThen(Collectors.toMap(x -> (x.getInsuranceId() + x.getCropId()), Function.identity(), (a, b) -> {
ArchiveInsuranceCropYear result = new ArchiveInsuranceCropYear();
BeanUtils.copyProperties(a, result);
result.setPickOutput(b.getPickOutput());
return result;
}), m -> new ArrayList<>(m.values())));
listPlantArea和listPickOutput两个list合并为同一个list,根据两个id确定唯一键,然后对相同数据进行合并成一条再转为list;