使用JAVA8Lambda表达式对集合某字段求和
第一种方式:
Double salesAmount = yearLsit.stream().map(o ->
BigDecimal.valueOf(o.getDeliveryAmount()-ArithUtils.add(o.getRebateApplyAmount(), o.getPriceDifferenceApplyAmount()))).
reduce(BigDecimal::add).orElse(BigDecimal.ZERO).doubleValue();
第二种方式:
salesAmount=yearLsit.stream().mapToDouble(Object::getRepaymentAmount).sum();