HashMap<String, LogisticsShipmentDTO.LogisticsShipmentOpt> map = Maps.newHashMap(); //根据sku+ 市场--合并入库数量及总运费 shipmentOptList.stream().forEach(shipmentOpt -> { LogisticsShipmentDTO.LogisticsShipmentOpt opt = map.get(shipmentOpt.getSku()); if (Objects.nonNull(opt)) { shipmentOpt.setQty(new BigDecimal(shipmentOpt.getQty()).add(new BigDecimal(opt.getQty())).toString()); shipmentOpt.setTotalFeight(shipmentOpt.getTotalFeight().subtract(opt.getTotalFeight())); map.put(shipmentOpt.getSku(), shipmentOpt); } else { map.put(shipmentOpt.getSku(), shipmentOpt); } });