獲取對象屬性id爲key,值爲當前對象
List<BatchLibraryRule> genRules = libraryRule.getRules();
Map<Integer,BatchLibraryRule> categoryRuleMap = null;
if(CollectionUtils.isNotEmpty(genRules)) {
categoryRuleMap = genRules.stream().collect(Collectors.toMap(BatchLibraryRule::getRuleCategory,g -> g));
}else {
genRules = new ArrayList<>();
categoryRuleMap = new HashMap<>();
}
獲取集合的對象的某列組成新的集合
List<BatchInventory> allInventorys = batchInventoryDao.findBatchInventorysByJobId(jobId);
Set<Integer> inventoryIds = allInventorys.stream().map(BatchInventory::getId).collect(Collectors.toSet());