|
@@ -20,6 +20,7 @@ import com.fjhx.common.entity.currency.po.CurrencyRate;
|
|
|
import com.fjhx.common.enums.FlowStatusEnum1;
|
|
|
import com.fjhx.common.service.currency.CurrencyRateService;
|
|
|
import com.fjhx.customer.service.customer.CustomerService;
|
|
|
+import com.fjhx.flow.enums.FlowStatusEnum;
|
|
|
import com.fjhx.purchase.entity.pay.po.Pay;
|
|
|
import com.fjhx.purchase.entity.purchase.enums.PurchaseStatusEnum;
|
|
|
import com.fjhx.purchase.entity.purchase.po.Purchase;
|
|
@@ -28,7 +29,9 @@ import com.fjhx.purchase.service.purchase.PurchaseDetailService;
|
|
|
import com.fjhx.purchase.service.purchase.PurchaseService;
|
|
|
import com.fjhx.sale.entity.claim.po.ClaimContract;
|
|
|
import com.fjhx.sale.entity.contract.bo.ContractCurrencyRate;
|
|
|
+import com.fjhx.sale.entity.contract.dto.ContractSelectDto;
|
|
|
import com.fjhx.sale.entity.contract.po.Contract;
|
|
|
+import com.fjhx.sale.entity.contract.vo.ContractBudgetVo;
|
|
|
import com.fjhx.sale.entity.contract.vo.ContractVo;
|
|
|
import com.fjhx.sale.entity.purchase.po.EhsdPurchase;
|
|
|
import com.fjhx.sale.entity.statement.dto.ProfitSettlementDto;
|
|
@@ -98,10 +101,8 @@ public class SaleStatementServiceImpl implements SaleStatementService {
|
|
|
customerService.attributeAssign(list, ProfitSettlementVo::getCustomerId, (item, customer) -> {
|
|
|
item.setCustomerName(customer.getName());
|
|
|
});
|
|
|
- // 获取默认税率
|
|
|
- Map<String, BigDecimal> defaultRateMap = new HashMap<>();
|
|
|
//赋值合同到账金额、退税金额、采购金额
|
|
|
- setContractArrivalAndRefundMoney(list);
|
|
|
+ setContractArrivalAndRefundMoney(list,1);
|
|
|
// 计算
|
|
|
calculation(list);
|
|
|
// 转page
|
|
@@ -109,6 +110,27 @@ public class SaleStatementServiceImpl implements SaleStatementService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 利润结算表头部统计
|
|
|
+ * @param dto
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> getProfitSettlementHead(ProfitSettlementDto dto) {
|
|
|
+ List<ContractVo> records = contractService.getProfitSettlementHead(dto);
|
|
|
+ if (records.size() == 0) {
|
|
|
+ return new HashMap<>();
|
|
|
+ }
|
|
|
+ // 转换为vo
|
|
|
+ List<ProfitSettlementVo> list = createResultList(records);
|
|
|
+ //赋值合同到账金额、退税金额、采购金额
|
|
|
+ setContractArrivalAndRefundMoney(list,2);
|
|
|
+ // 计算
|
|
|
+ calculation(list);
|
|
|
+
|
|
|
+ return sumData(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 获取单条合同汇率
|
|
|
*/
|
|
|
private Map<Long, Map<String, BigDecimal>> getDetailsRateMap(
|
|
@@ -198,8 +220,9 @@ public class SaleStatementServiceImpl implements SaleStatementService {
|
|
|
|
|
|
/**
|
|
|
* 赋值合同到账金额、退税金额、采购金额
|
|
|
+ * type:1 列表 2头部
|
|
|
*/
|
|
|
- private void setContractArrivalAndRefundMoney(List<ProfitSettlementVo> list) {
|
|
|
+ private void setContractArrivalAndRefundMoney(List<ProfitSettlementVo> list,int type) {
|
|
|
List<CurrencyRate> currencyRateList = currencyRateService.list();
|
|
|
|
|
|
List<String> currencyList = new ArrayList<>();
|
|
@@ -214,9 +237,17 @@ public class SaleStatementServiceImpl implements SaleStatementService {
|
|
|
Map<Long, List<TaxRefundDetails>> refundDetailsMap = refundDetails.stream().collect(Collectors.groupingBy(TaxRefundDetails::getContractId));
|
|
|
|
|
|
//通过合同IDS查询出采购数据
|
|
|
- List<Purchase> purchaseList = purchaseService.list(q -> q.in(Purchase::getDataResourceId, contractIdList).ge(Purchase::getPurchaseStatus, PurchaseStatusEnum.PASS.getKey()).lt(Purchase::getPurchaseStatus, PurchaseStatusEnum.CENCELLATION.getKey()));
|
|
|
+ List<Purchase> purchaseList = purchaseService.list(q -> q.in(Purchase::getDataResourceId, contractIdList).ge(Purchase::getPurchaseStatus, PurchaseStatusEnum.PASS.getKey()).lt(Purchase::getPurchaseStatus, FlowStatusEnum1.UPDATE.getKey()));
|
|
|
Map<Long, List<Purchase>> purchaseMap = purchaseList.stream().collect(Collectors.groupingBy(Purchase::getDataResourceId));
|
|
|
|
|
|
+ //通过合同ID查询出请款数据
|
|
|
+ List<AccountRequestFundsDetailVo> accountRequestFundsDetailVoList = accountRequestFundsDetailService.getListByContractIds(contractIdList);
|
|
|
+ Map<Long, List<AccountRequestFundsDetailVo>> accountRequestFundsDetailVoMap = accountRequestFundsDetailVoList.stream().collect(Collectors.groupingBy(AccountRequestFundsDetailVo::getContractId));
|
|
|
+
|
|
|
+ //通过合同ID查询出采购数据
|
|
|
+ List<Pay> pays = payDetailService.getPayDetailListByContractIds(contractIdList);
|
|
|
+ Map<Long, List<Pay>> payMap = pays.stream().collect(Collectors.groupingBy(Pay::getContractId));
|
|
|
+
|
|
|
for (ProfitSettlementVo p : list) {
|
|
|
currencyList.add(p.getCurrency());
|
|
|
if (StringUtil.isNotEmpty(p.getCurrencyRateJson())) {//取设置的汇率
|
|
@@ -236,10 +267,13 @@ public class SaleStatementServiceImpl implements SaleStatementService {
|
|
|
return rate.multiply(money);
|
|
|
}).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
p.setContractArrival(contractArrival);
|
|
|
- // 赋值业务员名称
|
|
|
- UserUtil.assignmentNickName(cList, ClaimContract::getCreateUser, ClaimContract::setUserName);
|
|
|
- p.setClaimList(cList);
|
|
|
- currencyList.addAll(cList.stream().map(ClaimContract::getCurrency).collect(Collectors.toList()));
|
|
|
+ if(type==1){
|
|
|
+ // 赋值业务员名称
|
|
|
+ UserUtil.assignmentNickName(cList, ClaimContract::getCreateUser, ClaimContract::setUserName);
|
|
|
+ p.setClaimList(cList);
|
|
|
+ currencyList.addAll(cList.stream().map(ClaimContract::getCurrency).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
/**
|
|
|
* 处理退税金额
|
|
@@ -255,10 +289,13 @@ public class SaleStatementServiceImpl implements SaleStatementService {
|
|
|
return rate.multiply(money);
|
|
|
}).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
p.setTaxReturnMoney(taxReturnMoney);
|
|
|
- // 赋值业务员名称
|
|
|
- UserUtil.assignmentNickName(rList, TaxRefundDetails::getCreateUser, TaxRefundDetails::setUserName);
|
|
|
- p.setTaxReturnList(rList);
|
|
|
- currencyList.addAll(rList.stream().map(TaxRefundDetails::getCurrency).collect(Collectors.toList()));
|
|
|
+ if(type==1){
|
|
|
+ // 赋值业务员名称
|
|
|
+ UserUtil.assignmentNickName(rList, TaxRefundDetails::getCreateUser, TaxRefundDetails::setUserName);
|
|
|
+ p.setTaxReturnList(rList);
|
|
|
+ currencyList.addAll(rList.stream().map(TaxRefundDetails::getCurrency).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
/**
|
|
|
* 处理采购金额
|
|
@@ -275,23 +312,26 @@ public class SaleStatementServiceImpl implements SaleStatementService {
|
|
|
return rate.multiply(money);
|
|
|
}).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
p.setPurchaseAmount(purchaseAmount);
|
|
|
- p.setPurchaseList(pList);
|
|
|
- currencyList.addAll(pList.stream().map(Purchase::getCurrency).collect(Collectors.toList()));
|
|
|
- /**
|
|
|
- * 处理支付款金额
|
|
|
- */
|
|
|
- List<Long> purchaseIds = pList.stream().map(Purchase::getId).collect(Collectors.toList());
|
|
|
- List<Pay> payList = payDetailService.getSumMoney(purchaseIds);
|
|
|
- if (CollectionUtils.isNotEmpty(payList)) {
|
|
|
- BigDecimal payAmount = payList.stream().map(pay -> {
|
|
|
- //获取汇率
|
|
|
- BigDecimal rate = pay.getRate()==null?BigDecimal.ONE:pay.getRate();
|
|
|
- // 获取金额
|
|
|
- BigDecimal money = pay.getAmount()==null?BigDecimal.ZERO:pay.getAmount();
|
|
|
- // 返回兑人民币后金额
|
|
|
- return rate.multiply(money);
|
|
|
- }).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- p.setPayForGoods(payAmount);
|
|
|
+ if(type==1){
|
|
|
+ p.setPurchaseList(pList);
|
|
|
+ currencyList.addAll(pList.stream().map(Purchase::getCurrency).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 处理支付款金额
|
|
|
+ */
|
|
|
+ List<Pay> payList = payMap.getOrDefault(p.getContractId(), null);
|
|
|
+ if (CollectionUtils.isNotEmpty(payList)) {
|
|
|
+ BigDecimal payAmount = payList.stream().map(pay -> {
|
|
|
+ //获取汇率
|
|
|
+ BigDecimal rate = pay.getRate()==null?BigDecimal.ONE:pay.getRate();
|
|
|
+ // 获取金额
|
|
|
+ BigDecimal money = pay.getAmount()==null?BigDecimal.ZERO:pay.getAmount();
|
|
|
+ // 返回兑人民币后金额
|
|
|
+ return rate.multiply(money);
|
|
|
+ }).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ p.setPayForGoods(payAmount);
|
|
|
+ if(type==1){
|
|
|
// 赋值业务员名称
|
|
|
UserUtil.assignmentNickName(payList, Pay::getCreateUser, Pay::setUserName);
|
|
|
p.setPayList(payList);
|
|
@@ -301,7 +341,8 @@ public class SaleStatementServiceImpl implements SaleStatementService {
|
|
|
/**
|
|
|
* 其他收入金额
|
|
|
*/
|
|
|
- List<AccountRequestFundsDetailVo> accountRequestFundsDetailVos = accountRequestFundsDetailService.getListByContractId(p.getContractId());
|
|
|
+ List<AccountRequestFundsDetailVo> accountRequestFundsDetailVos = accountRequestFundsDetailVoMap.getOrDefault(p.getContractId(), null);
|
|
|
+// List<AccountRequestFundsDetailVo> accountRequestFundsDetailVos = accountRequestFundsDetailService.getListByContractId(p.getContractId());
|
|
|
if (CollectionUtils.isNotEmpty(accountRequestFundsDetailVos)) {
|
|
|
BigDecimal otherExpenses = accountRequestFundsDetailVos.stream().map(acc -> {
|
|
|
//获取汇率
|
|
@@ -312,34 +353,40 @@ public class SaleStatementServiceImpl implements SaleStatementService {
|
|
|
return rate.multiply(money);
|
|
|
}).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
p.setOtherExpenses(otherExpenses);
|
|
|
- // 赋值业务员名称
|
|
|
- UserUtil.assignmentNickName(accountRequestFundsDetailVos, AccountRequestFundsDetailVo::getCreateUser, AccountRequestFundsDetailVo::setUserName);
|
|
|
- p.setAccountRequestFundsDetailList(accountRequestFundsDetailVos);
|
|
|
- currencyList.addAll(accountRequestFundsDetailVos.stream().map(AccountRequestFundsDetailVo::getCurrency).collect(Collectors.toList()));
|
|
|
+ if(type==1){
|
|
|
+ // 赋值业务员名称
|
|
|
+ UserUtil.assignmentNickName(accountRequestFundsDetailVos, AccountRequestFundsDetailVo::getCreateUser, AccountRequestFundsDetailVo::setUserName);
|
|
|
+ p.setAccountRequestFundsDetailList(accountRequestFundsDetailVos);
|
|
|
+ currencyList.addAll(accountRequestFundsDetailVos.stream().map(AccountRequestFundsDetailVo::getCurrency).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
} else {//取数据汇率
|
|
|
/**
|
|
|
* 处理到账金额
|
|
|
*/
|
|
|
List<ClaimContract> cList = claimContractMap.getOrDefault(p.getContractId(), new ArrayList<>());
|
|
|
- List<Long> warterIds = cList.stream().distinct().map(ClaimContract::getBusinessId).collect(Collectors.toList());
|
|
|
- if (CollectionUtils.isNotEmpty(warterIds)) {
|
|
|
- //查出流水
|
|
|
- List<AccountRunningWater> accountRunningWaterList = accountRunningWaterService.list(Wrappers.<AccountRunningWater>query().lambda().in(AccountRunningWater::getId, warterIds));
|
|
|
- Map<Long, BigDecimal> waterMap = accountRunningWaterList.stream().collect(Collectors.toMap(AccountRunningWater::getId, AccountRunningWater::getRate));
|
|
|
+// List<Long> warterIds = cList.stream().distinct().map(ClaimContract::getBusinessId).collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isNotEmpty(cList)) {
|
|
|
+// //查出流水
|
|
|
+// List<AccountRunningWater> accountRunningWaterList = accountRunningWaterService.list(Wrappers.<AccountRunningWater>query().lambda().in(AccountRunningWater::getId, warterIds));
|
|
|
+// Map<Long, BigDecimal> waterMap = accountRunningWaterList.stream().collect(Collectors.toMap(AccountRunningWater::getId, AccountRunningWater::getRate));
|
|
|
BigDecimal contractArrival = cList.stream().map(claimContract -> {
|
|
|
//获取汇率
|
|
|
- BigDecimal rate = waterMap.getOrDefault(claimContract.getBusinessId(), BigDecimal.ONE);
|
|
|
+ BigDecimal rate = claimContract.getRate();
|
|
|
// 获取金额
|
|
|
BigDecimal money = claimContract.getMoney();
|
|
|
// 返回兑人民币后金额
|
|
|
return rate.multiply(money);
|
|
|
}).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
p.setContractArrival(contractArrival);
|
|
|
- // 赋值业务员名称
|
|
|
- UserUtil.assignmentNickName(cList, ClaimContract::getCreateUser, ClaimContract::setUserName);
|
|
|
- p.setClaimList(cList);
|
|
|
- currencyList.addAll(cList.stream().map(ClaimContract::getCurrency).collect(Collectors.toList()));
|
|
|
+ if(type==1){
|
|
|
+ // 赋值业务员名称
|
|
|
+ UserUtil.assignmentNickName(cList, ClaimContract::getCreateUser, ClaimContract::setUserName);
|
|
|
+ p.setClaimList(cList);
|
|
|
+ currencyList.addAll(cList.stream().map(ClaimContract::getCurrency).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
/**
|
|
|
* 处理退税金额
|
|
@@ -355,10 +402,13 @@ public class SaleStatementServiceImpl implements SaleStatementService {
|
|
|
return rate.multiply(money);
|
|
|
}).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
p.setTaxReturnMoney(taxReturnMoney);
|
|
|
- // 赋值业务员名称
|
|
|
- UserUtil.assignmentNickName(rList, TaxRefundDetails::getCreateUser, TaxRefundDetails::setUserName);
|
|
|
- p.setTaxReturnList(rList);
|
|
|
- currencyList.addAll(rList.stream().map(TaxRefundDetails::getCurrency).collect(Collectors.toList()));
|
|
|
+ if(type==1){
|
|
|
+ // 赋值业务员名称
|
|
|
+ UserUtil.assignmentNickName(rList, TaxRefundDetails::getCreateUser, TaxRefundDetails::setUserName);
|
|
|
+ p.setTaxReturnList(rList);
|
|
|
+ currencyList.addAll(rList.stream().map(TaxRefundDetails::getCurrency).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
/**
|
|
|
* 处理采购金额
|
|
@@ -375,23 +425,26 @@ public class SaleStatementServiceImpl implements SaleStatementService {
|
|
|
return rate.multiply(money);
|
|
|
}).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
p.setPurchaseAmount(purchaseAmount);
|
|
|
- p.setPurchaseList(pList);
|
|
|
- currencyList.addAll(pList.stream().map(Purchase::getCurrency).collect(Collectors.toList()));
|
|
|
- /**
|
|
|
- * 处理支付款金额
|
|
|
- */
|
|
|
- List<Long> purchaseIds = pList.stream().map(Purchase::getId).collect(Collectors.toList());
|
|
|
- List<Pay> payList = payDetailService.getSumMoney(purchaseIds);
|
|
|
- if (CollectionUtils.isNotEmpty(payList)) {
|
|
|
- BigDecimal payAmount = payList.stream().map(pay -> {
|
|
|
- //获取汇率
|
|
|
- BigDecimal rate = pay.getRate()==null?BigDecimal.ONE:pay.getRate();
|
|
|
- // 获取认领金额
|
|
|
- BigDecimal money = pay.getAmount()==null?BigDecimal.ZERO:pay.getAmount();
|
|
|
- // 返回兑人民币后金额
|
|
|
- return rate.multiply(money);
|
|
|
- }).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- p.setPayForGoods(payAmount);
|
|
|
+ if(type==1){
|
|
|
+ p.setPurchaseList(pList);
|
|
|
+ currencyList.addAll(pList.stream().map(Purchase::getCurrency).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 处理支付款金额
|
|
|
+ */
|
|
|
+ List<Pay> payList = payMap.getOrDefault(p.getContractId(), null);
|
|
|
+ if (CollectionUtils.isNotEmpty(payList)) {
|
|
|
+ BigDecimal payAmount = payList.stream().map(pay -> {
|
|
|
+ //获取汇率
|
|
|
+ BigDecimal rate = pay.getRate()==null?BigDecimal.ONE:pay.getRate();
|
|
|
+ // 获取认领金额
|
|
|
+ BigDecimal money = pay.getAmount()==null?BigDecimal.ZERO:pay.getAmount();
|
|
|
+ // 返回兑人民币后金额
|
|
|
+ return rate.multiply(money);
|
|
|
+ }).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ p.setPayForGoods(payAmount);
|
|
|
+ if(type==1){
|
|
|
// 赋值业务员名称
|
|
|
UserUtil.assignmentNickName(payList, Pay::getCreateUser, Pay::setUserName);
|
|
|
p.setPayList(payList);
|
|
@@ -401,7 +454,7 @@ public class SaleStatementServiceImpl implements SaleStatementService {
|
|
|
/**
|
|
|
* 其他收入金额
|
|
|
*/
|
|
|
- List<AccountRequestFundsDetailVo> accountRequestFundsDetailVos = accountRequestFundsDetailService.getListByContractId(p.getContractId());
|
|
|
+ List<AccountRequestFundsDetailVo> accountRequestFundsDetailVos = accountRequestFundsDetailVoMap.getOrDefault(p.getContractId(), null);
|
|
|
if (CollectionUtils.isNotEmpty(accountRequestFundsDetailVos)) {
|
|
|
BigDecimal otherExpenses = accountRequestFundsDetailVos.stream().map(acc -> {
|
|
|
//获取汇率
|
|
@@ -412,19 +465,34 @@ public class SaleStatementServiceImpl implements SaleStatementService {
|
|
|
return rate.multiply(money);
|
|
|
}).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
p.setOtherExpenses(otherExpenses);
|
|
|
- // 赋值业务员名称
|
|
|
- UserUtil.assignmentNickName(accountRequestFundsDetailVos, AccountRequestFundsDetailVo::getCreateUser, AccountRequestFundsDetailVo::setUserName);
|
|
|
- p.setAccountRequestFundsDetailList(accountRequestFundsDetailVos);
|
|
|
- currencyList.addAll(accountRequestFundsDetailVos.stream().map(AccountRequestFundsDetailVo::getCurrency).collect(Collectors.toList()));
|
|
|
+ if(type==1){
|
|
|
+ // 赋值业务员名称
|
|
|
+ UserUtil.assignmentNickName(accountRequestFundsDetailVos, AccountRequestFundsDetailVo::getCreateUser, AccountRequestFundsDetailVo::setUserName);
|
|
|
+ p.setAccountRequestFundsDetailList(accountRequestFundsDetailVos);
|
|
|
+ currencyList.addAll(accountRequestFundsDetailVos.stream().map(AccountRequestFundsDetailVo::getCurrency).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
- p.setCurrencyList(currencyRateList.stream()
|
|
|
- .filter((CurrencyRate c) ->currencyList.contains(c.getType()))
|
|
|
- .collect(Collectors.toList()));
|
|
|
+ if(type==1){
|
|
|
+ p.setCurrencyList(currencyRateList.stream()
|
|
|
+ .filter((CurrencyRate c) ->currencyList.contains(c.getType()))
|
|
|
+ .collect(Collectors.toList()));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 利润结算表头部统计
|
|
|
+ * @param dto
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Page<ContractBudgetVo> getProfitClearingPageHeadStatistics(ContractSelectDto dto) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 赋值采购合同金额和支付货款
|
|
|
*/
|
|
|
private void setPurchaseAmountAndPayForGoods(
|
|
@@ -518,6 +586,52 @@ public class SaleStatementServiceImpl implements SaleStatementService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 统计数据
|
|
|
+ */
|
|
|
+ private Map<String,Object> sumData(List<ProfitSettlementVo> list) {
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ BigDecimal contractSumAmount = BigDecimal.ZERO;
|
|
|
+ BigDecimal purchaseSumAmount = BigDecimal.ZERO;
|
|
|
+ BigDecimal contractArrivalSumAmount = BigDecimal.ZERO;
|
|
|
+ BigDecimal taxReturnMoneySumAmount = BigDecimal.ZERO;
|
|
|
+ BigDecimal otherIncomeSumAmount = BigDecimal.ZERO;
|
|
|
+ BigDecimal payForGoodsSumAmount = BigDecimal.ZERO;
|
|
|
+ BigDecimal otherExpensesSumAmount = BigDecimal.ZERO;
|
|
|
+ BigDecimal totalIncomeSumAmount = BigDecimal.ZERO;
|
|
|
+ BigDecimal totalExpensesSumAmount = BigDecimal.ZERO;
|
|
|
+ BigDecimal grossProfitMargin = BigDecimal.ZERO;
|
|
|
+ for (ProfitSettlementVo p : list) {
|
|
|
+ contractSumAmount = contractSumAmount.add(ObjectUtil.isEmpty(p.getContractAmount())?BigDecimal.ZERO:p.getContractAmount());//合同金额
|
|
|
+ contractArrivalSumAmount = contractArrivalSumAmount.add(ObjectUtil.isEmpty(p.getContractArrival())?BigDecimal.ZERO:p.getContractArrival());//合同到账
|
|
|
+ taxReturnMoneySumAmount = taxReturnMoneySumAmount.add(ObjectUtil.isEmpty(p.getTaxReturnMoney())?BigDecimal.ZERO:p.getTaxReturnMoney());//退税
|
|
|
+ otherIncomeSumAmount = otherIncomeSumAmount.add(ObjectUtil.isEmpty(p.getOtherIncome())?BigDecimal.ZERO:p.getOtherIncome());//其他收入
|
|
|
+ payForGoodsSumAmount = payForGoodsSumAmount.add(ObjectUtil.isEmpty(p.getPayForGoods())?BigDecimal.ZERO:p.getPayForGoods());//支付货款
|
|
|
+ otherExpensesSumAmount = otherExpensesSumAmount.add(ObjectUtil.isEmpty(p.getOtherExpenses())?BigDecimal.ZERO:p.getOtherExpenses());//其他支出
|
|
|
+ totalIncomeSumAmount = totalIncomeSumAmount.add(ObjectUtil.isEmpty(p.getTotalIncome())?BigDecimal.ZERO:p.getTotalIncome());//收入
|
|
|
+ totalExpensesSumAmount = totalExpensesSumAmount.add(ObjectUtil.isEmpty(p.getTotalExpenses())?BigDecimal.ZERO:p.getTotalExpenses());//支出
|
|
|
+ purchaseSumAmount = purchaseSumAmount.add(ObjectUtil.isEmpty(p.getPurchaseAmount())?BigDecimal.ZERO:p.getPurchaseAmount());
|
|
|
+ }
|
|
|
+ //计算总毛利和总毛利率
|
|
|
+ BigDecimal grossProfitSum = totalIncomeSumAmount.subtract(totalExpensesSumAmount);//毛利
|
|
|
+ if (totalIncomeSumAmount.compareTo(BigDecimal.ZERO)>0) {
|
|
|
+ grossProfitMargin = new BigDecimal("100").multiply(grossProfitSum).divide(totalIncomeSumAmount, 2, RoundingMode.HALF_UP);//毛利率
|
|
|
+ }
|
|
|
+ map.put("GrossProfitMargin",grossProfitMargin);
|
|
|
+ map.put("contractSumAmount",contractSumAmount);
|
|
|
+ map.put("contractCount",list.size());
|
|
|
+ map.put("purchaseSumAmount",purchaseSumAmount);
|
|
|
+ map.put("contractArrivalSumAmount",contractArrivalSumAmount);
|
|
|
+ map.put("taxReturnMoneySumAmount",taxReturnMoneySumAmount);
|
|
|
+ map.put("otherIncomeSumAmount",otherIncomeSumAmount);
|
|
|
+ map.put("payForGoodsSumAmount",payForGoodsSumAmount);
|
|
|
+ map.put("otherExpensesSumAmount",otherExpensesSumAmount);
|
|
|
+ map.put("totalIncomeSumAmount",totalIncomeSumAmount);
|
|
|
+ map.put("totalExpensesSumAmount",totalExpensesSumAmount);
|
|
|
+ map.put("grossProfitSum",grossProfitSum);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 转page
|
|
|
*/
|
|
|
private Page<ProfitSettlementVo> toPage(Page<ContractVo> contractPage, List<ProfitSettlementVo> list) {
|