这行代码 getSupplierLoginId 可为空时会报这种错误
Map<String, List<PurchaseOrderEntity>> collect = purchaseOrderEntities.stream().collect(Collectors.groupingBy(PurchaseOrderEntity::getSupplierLoginId));
代码修改后对空值进行过滤:
Map<String, List<PurchaseOrderEntity>> collect = purchaseOrderEntities.stream().filter(item-> StringUtil.isNotBlank(item.getSupplierLoginId())).collect(Collectors.groupingBy(PurchaseOrderEntity::getSupplierLoginId));
网友评论