如果list中的对像的编号相同就把对像合并,并将数量相加

https://blog.csdn.net/winter_chen001/article/details/72648512

以下个人使用,感觉原作者的第五行Object o = map.get("obj");有错误

// region 同物料合并
Map<String, BOMVersionDetail> resultMap = new HashMap<>();
for (BOMVersionDetail bomVersionDetail : orderBomList){
    
    
	if (resultMap.containsKey(bomVersionDetail.material)){
    
    
		String material = bomVersionDetail.material;
		BOMVersionDetail b = resultMap.get(material);
		b.unitQty += bomVersionDetail.unitQty;
		resultMap.put(bomVersionDetail.material, b);
	} else {
    
    
		resultMap.put(bomVersionDetail.material, bomVersionDetail);
	}
}
//endregion

猜你喜欢

转载自blog.csdn.net/weixin_46099269/article/details/111245195