reduce 求和

if (!BusinessItem.SLS0300501_IMSLINKAGETAX_VAT.equals(imsLinkageTaxType)
                && StringUtils.isNotEmpty(imsLinkageTaxType)
                && CollectionUtils.isNotEmpty(imsSalesTransactionTaxEntityList)) {
            ImsSalesTransactionTax imsSalesTransactionTaxEntity =
                    imsSalesTransactionTaxEntityList.get(0);
            imsSalesTransactionTaxEntity.setImsLinkageTaxType(imsLinkageTaxType);
            imsSalesTransactionTaxEntity.setLotNumber(lotNumber);
            imsSalesTransactionTaxEntity.setCreateUserId(BusinessItem.SLS0300501_USER_ID);
            imsSalesTransactionTaxEntity.setCreateDatetime(systemDateTime);
            imsSalesTransactionTaxEntity.setCreateProgramId(BusinessItem.SLS0300501_PROGRAM_ID);
            imsSalesTransactionTaxEntity.setUpdateUserId(BusinessItem.SLS0300501_USER_ID);
            imsSalesTransactionTaxEntity.setUpdateDatetime(systemDateTime);
            imsSalesTransactionTaxEntity.setUpdateProgramId(BusinessItem.SLS0300501_PROGRAM_ID);
            BigDecimal taxAmountValue = imsSalesTransactionTaxEntityList.stream()
                    .filter(taxEntity -> null != taxEntity.getTaxAmountValue())
                    .map(ImsSalesTransactionTax::getTaxAmountValue)
                    .reduce(BigDecimal::add)
                    .orElse(null);
            imsSalesTransactionTaxEntity.setTaxAmountValue(taxAmountValue);
            imsSalesTransactionTaxMapper.insert(imsSalesTransactionTaxEntity);
        }

你可能感兴趣的:(reduce 求和)