|
@@ -25,7 +25,6 @@ import com.fjhx.area.utils.CustomizeAreaUtil;
|
|
import com.fjhx.common.constant.SourceConstant;
|
|
import com.fjhx.common.constant.SourceConstant;
|
|
import com.fjhx.common.entity.contract.po.ContractTemplate;
|
|
import com.fjhx.common.entity.contract.po.ContractTemplate;
|
|
import com.fjhx.common.entity.corporation.po.Corporation;
|
|
import com.fjhx.common.entity.corporation.po.Corporation;
|
|
-import com.fjhx.common.entity.currency.po.CurrencyRate;
|
|
|
|
import com.fjhx.common.entity.documentary.bo.DocumentaryData;
|
|
import com.fjhx.common.entity.documentary.bo.DocumentaryData;
|
|
import com.fjhx.common.enums.FlowStatusEnum1;
|
|
import com.fjhx.common.enums.FlowStatusEnum1;
|
|
import com.fjhx.common.service.contract.ContractTemplateService;
|
|
import com.fjhx.common.service.contract.ContractTemplateService;
|
|
@@ -797,60 +796,33 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
);
|
|
);
|
|
Map<Long, List<EhsdPurchase>> purchaseMap = purchaseList.stream().collect(Collectors.groupingBy(EhsdPurchase::getDataResourceId));
|
|
Map<Long, List<EhsdPurchase>> purchaseMap = purchaseList.stream().collect(Collectors.groupingBy(EhsdPurchase::getDataResourceId));
|
|
for (ContractBudgetVo v : list) {
|
|
for (ContractBudgetVo v : list) {
|
|
|
|
+ v.setDataJson(null);
|
|
v.setOtherIncomeAmount(BigDecimal.ZERO);//暂时先设置其他收入为0
|
|
v.setOtherIncomeAmount(BigDecimal.ZERO);//暂时先设置其他收入为0
|
|
- if (StringUtils.isNotEmpty(v.getCurrencyRateJson())) {//如果此条合同有汇率了
|
|
|
|
- //取出汇率
|
|
|
|
- List<CurrencyRate> assignCurrencyRatesList = JSON.parseArray(v.getCurrencyRateJson(), CurrencyRate.class);
|
|
|
|
- Map<String, BigDecimal> assignCurrencyRatesMap = assignCurrencyRatesList.stream().collect(Collectors.toMap(CurrencyRate::getType, CurrencyRate::getRate));
|
|
|
|
- //计算合同人民币总额
|
|
|
|
- v.setRmbContractAmount(v.getAmount().multiply(assignCurrencyRatesMap.getOrDefault(v.getCurrency(), BigDecimal.ONE)));
|
|
|
|
- /**
|
|
|
|
- * 处理退税金额
|
|
|
|
- */
|
|
|
|
- v.setRefundableAmount(BigDecimal.ZERO);
|
|
|
|
- List<TaxRefundDetails> rList = refundDetailsMap.getOrDefault(v.getContractId(), null);
|
|
|
|
- if (CollectionUtils.isNotEmpty(rList)) {
|
|
|
|
- BigDecimal taxReturnMoney = rList.stream().map(taxRefundDetails -> {
|
|
|
|
- //获取汇率
|
|
|
|
- BigDecimal rate = assignCurrencyRatesMap.getOrDefault(taxRefundDetails.getCurrency(), BigDecimal.ONE);
|
|
|
|
- // 获取认领金额
|
|
|
|
- BigDecimal money = taxRefundDetails.getAmount();
|
|
|
|
- // 返回兑人民币后金额
|
|
|
|
- return rate.multiply(money);
|
|
|
|
- }).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
- v.setRefundableAmount(taxReturnMoney);
|
|
|
|
- }
|
|
|
|
- //处理到账总金额
|
|
|
|
- v.setSumClaimMoney(getSumClaimMoney(claimMap.getOrDefault(v.getContractId(), null), assignCurrencyRatesMap));
|
|
|
|
- //采购合同总金额
|
|
|
|
- getSumPurchaseContractMoney(v, purchaseMap.getOrDefault(v.getContractId(), null), assignCurrencyRatesMap);
|
|
|
|
- //支出费用
|
|
|
|
- this.getGroupTypeMoney(v, assignCurrencyRatesMap);
|
|
|
|
- } else {
|
|
|
|
- v.setRmbContractAmount(v.getAmount().multiply(v.getRate()));//计算汇算人民币
|
|
|
|
- /**
|
|
|
|
- * 处理退税金额
|
|
|
|
- */
|
|
|
|
- v.setRefundableAmount(BigDecimal.ZERO);
|
|
|
|
- List<TaxRefundDetails> rList = refundDetailsMap.getOrDefault(v.getContractId(), null);
|
|
|
|
- if (CollectionUtils.isNotEmpty(rList)) {
|
|
|
|
- BigDecimal taxReturnMoney = rList.stream().map(taxRefundDetails -> {
|
|
|
|
- //获取汇率
|
|
|
|
- BigDecimal rate = taxRefundDetails.getRate();
|
|
|
|
- // 获取认领金额
|
|
|
|
- BigDecimal money = taxRefundDetails.getAmount();
|
|
|
|
- // 返回兑人民币后金额
|
|
|
|
- return rate.multiply(money);
|
|
|
|
- }).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
- v.setRefundableAmount(taxReturnMoney);
|
|
|
|
- }
|
|
|
|
- //处理到账总金额
|
|
|
|
- v.setSumClaimMoney(getSumClaimMoney(claimMap.getOrDefault(v.getContractId(), null), null));
|
|
|
|
- //采购合同总金额
|
|
|
|
- getSumPurchaseContractMoney(v, purchaseMap.getOrDefault(v.getContractId(), null), null);
|
|
|
|
- //支出费用
|
|
|
|
- this.getGroupTypeMoney(v, null);
|
|
|
|
|
|
+
|
|
|
|
+ v.setRmbContractAmount(v.getAmount().multiply(v.getRate()));//计算汇算人民币
|
|
|
|
+ /**
|
|
|
|
+ * 处理退税金额
|
|
|
|
+ */
|
|
|
|
+ v.setRefundableAmount(BigDecimal.ZERO);
|
|
|
|
+ List<TaxRefundDetails> rList = refundDetailsMap.getOrDefault(v.getContractId(), null);
|
|
|
|
+ if (CollectionUtils.isNotEmpty(rList)) {
|
|
|
|
+ BigDecimal taxReturnMoney = rList.stream().map(taxRefundDetails -> {
|
|
|
|
+ //获取汇率
|
|
|
|
+ BigDecimal rate = taxRefundDetails.getRate();
|
|
|
|
+ // 获取认领金额
|
|
|
|
+ BigDecimal money = taxRefundDetails.getAmount();
|
|
|
|
+ // 返回兑人民币后金额
|
|
|
|
+ return rate.multiply(money);
|
|
|
|
+ }).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
+ v.setRefundableAmount(taxReturnMoney);
|
|
}
|
|
}
|
|
|
|
+ //处理到账总金额
|
|
|
|
+ v.setSumClaimMoney(getSumClaimMoney(claimMap.getOrDefault(v.getContractId(), null)));
|
|
|
|
+ //采购合同总金额
|
|
|
|
+ getSumPurchaseContractMoney(v, purchaseMap.getOrDefault(v.getContractId(), null));
|
|
|
|
+ //支出费用
|
|
|
|
+ this.getGroupTypeMoney(v);
|
|
|
|
+
|
|
//计算收入总计=合同金额(转人民币)+应退税金额(转人民币)+其他收入(转人民币)
|
|
//计算收入总计=合同金额(转人民币)+应退税金额(转人民币)+其他收入(转人民币)
|
|
v.setIncomeAmount(v.getSumClaimMoney() == null ? BigDecimal.ZERO : v.getSumClaimMoney().add(v.getRefundableAmount()).add(v.getOtherIncomeAmount()));
|
|
v.setIncomeAmount(v.getSumClaimMoney() == null ? BigDecimal.ZERO : v.getSumClaimMoney().add(v.getRefundableAmount()).add(v.getOtherIncomeAmount()));
|
|
//计算支出总计 除合同金额(转人民币)+应退税金额(转人民币)+其他收入(转人民币) 其他金额相加
|
|
//计算支出总计 除合同金额(转人民币)+应退税金额(转人民币)+其他收入(转人民币) 其他金额相加
|
|
@@ -865,6 +837,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
(v.getFreight()).add
|
|
(v.getFreight()).add
|
|
(v.getCertificateOfOrigin()).add
|
|
(v.getCertificateOfOrigin()).add
|
|
(v.getAccountPaid()).add
|
|
(v.getAccountPaid()).add
|
|
|
|
+ (v.getAgencyFee()).add
|
|
(v.getProfitAgencyFee()));
|
|
(v.getProfitAgencyFee()));
|
|
//计算毛利 收入-支出
|
|
//计算毛利 收入-支出
|
|
v.setGross(v.getIncomeAmount().subtract(v.getExpenditureAmount()));
|
|
v.setGross(v.getIncomeAmount().subtract(v.getExpenditureAmount()));
|
|
@@ -1900,22 +1873,17 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
* 统计到账认领总金额
|
|
* 统计到账认领总金额
|
|
*
|
|
*
|
|
* @param claimContractList
|
|
* @param claimContractList
|
|
- * @param assignCurrencyRatesMap 汇率JSON
|
|
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- private BigDecimal getSumClaimMoney(List<ClaimContract> claimContractList, Map<String, BigDecimal> assignCurrencyRatesMap) {
|
|
|
|
|
|
+ private BigDecimal getSumClaimMoney(List<ClaimContract> claimContractList) {
|
|
BigDecimal sumClaimMoney = BigDecimal.ZERO;
|
|
BigDecimal sumClaimMoney = BigDecimal.ZERO;
|
|
if (ObjectUtil.isEmpty(claimContractList)) {
|
|
if (ObjectUtil.isEmpty(claimContractList)) {
|
|
return BigDecimal.ZERO;
|
|
return BigDecimal.ZERO;
|
|
}
|
|
}
|
|
for (ClaimContract c : claimContractList) {
|
|
for (ClaimContract c : claimContractList) {
|
|
- BigDecimal rate = c.getRate();
|
|
|
|
- if (MapUtils.isNotEmpty(assignCurrencyRatesMap)) {
|
|
|
|
- rate = assignCurrencyRatesMap.getOrDefault(c.getCurrency(), BigDecimal.ONE);
|
|
|
|
- }
|
|
|
|
BigDecimal moneyCny = c.getMoneyCny();
|
|
BigDecimal moneyCny = c.getMoneyCny();
|
|
if (ObjectUtil.isEmpty(moneyCny)) {
|
|
if (ObjectUtil.isEmpty(moneyCny)) {
|
|
- moneyCny = c.getMoney().multiply(rate);
|
|
|
|
|
|
+ moneyCny = BigDecimal.ZERO;
|
|
}
|
|
}
|
|
sumClaimMoney = sumClaimMoney.add(moneyCny);
|
|
sumClaimMoney = sumClaimMoney.add(moneyCny);
|
|
}
|
|
}
|
|
@@ -1927,10 +1895,9 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
*
|
|
*
|
|
* @param v
|
|
* @param v
|
|
* @param purchaseList
|
|
* @param purchaseList
|
|
- * @param assignCurrencyRatesMap 汇率JSON
|
|
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- private void getSumPurchaseContractMoney(ContractBudgetVo v, List<EhsdPurchase> purchaseList, Map<String, BigDecimal> assignCurrencyRatesMap) {
|
|
|
|
|
|
+ private void getSumPurchaseContractMoney(ContractBudgetVo v, List<EhsdPurchase> purchaseList) {
|
|
v.setAccountPaid(BigDecimal.ZERO);
|
|
v.setAccountPaid(BigDecimal.ZERO);
|
|
BigDecimal purchaseSumMoney = BigDecimal.ZERO;
|
|
BigDecimal purchaseSumMoney = BigDecimal.ZERO;
|
|
if (CollectionUtils.isEmpty(purchaseList)) {
|
|
if (CollectionUtils.isEmpty(purchaseList)) {
|
|
@@ -1938,57 +1905,32 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
List<Long> purchaseIds = purchaseList.stream().map(EhsdPurchase::getId).collect(Collectors.toList());
|
|
List<Long> purchaseIds = purchaseList.stream().map(EhsdPurchase::getId).collect(Collectors.toList());
|
|
- if (MapUtils.isNotEmpty(assignCurrencyRatesMap)) {
|
|
|
|
- for (EhsdPurchase c : purchaseList) {
|
|
|
|
- purchaseSumMoney = purchaseSumMoney.add(c.getAmount().multiply(assignCurrencyRatesMap.getOrDefault(c.getCurrency(), BigDecimal.ONE)));
|
|
|
|
- }
|
|
|
|
- /**
|
|
|
|
- * 处理支付款金额
|
|
|
|
- */
|
|
|
|
- List<Pay> payList = payDetailService.getSumMoney(purchaseIds);
|
|
|
|
- if (CollectionUtils.isNotEmpty(payList)) {
|
|
|
|
- BigDecimal payAmount = payList.stream().map(pay -> {
|
|
|
|
- //获取汇率
|
|
|
|
- BigDecimal rate = assignCurrencyRatesMap.getOrDefault(pay.getCurrency(), BigDecimal.ONE);
|
|
|
|
- // 获取认领金额
|
|
|
|
- BigDecimal money = pay.getAmount();
|
|
|
|
- // 返回兑人民币后金额
|
|
|
|
- return rate.multiply(money);
|
|
|
|
- }).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
- v.setAccountPaid(payAmount);
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- for (EhsdPurchase c : purchaseList) {
|
|
|
|
- purchaseSumMoney = purchaseSumMoney.add(c.getAmount().multiply(c.getRate()));
|
|
|
|
- }
|
|
|
|
- v.setSumPurchaseContractMoney(purchaseSumMoney);
|
|
|
|
- /**
|
|
|
|
- * 处理支付款金额
|
|
|
|
- */
|
|
|
|
- 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();
|
|
|
|
- // 返回兑人民币后金额
|
|
|
|
- return rate.multiply(money);
|
|
|
|
- }).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
- v.setAccountPaid(payAmount);
|
|
|
|
- }
|
|
|
|
|
|
+ for (EhsdPurchase c : purchaseList) {
|
|
|
|
+ purchaseSumMoney = purchaseSumMoney.add(c.getAmount());
|
|
|
|
+ }
|
|
|
|
+ v.setSumPurchaseContractMoney(purchaseSumMoney);
|
|
|
|
+ /**
|
|
|
|
+ * 处理支付款金额
|
|
|
|
+ */
|
|
|
|
+ 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.getMoney();
|
|
|
|
+ // 返回兑人民币后金额
|
|
|
|
+ return rate.multiply(money);
|
|
|
|
+ }).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
+ v.setAccountPaid(payAmount);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 统计支出各种费用
|
|
* 统计支出各种费用
|
|
- *
|
|
|
|
- * @param v
|
|
|
|
- * @param currencyRatesMap 汇率JSON
|
|
|
|
- * @return
|
|
|
|
*/
|
|
*/
|
|
- private void getGroupTypeMoney(ContractBudgetVo v, Map<String, BigDecimal> currencyRatesMap) {
|
|
|
|
|
|
+ private void getGroupTypeMoney(ContractBudgetVo v) {
|
|
List<AccountRequestFundsDetailVo> list = accountRequestFundsDetailService.getListByContractId(v.getContractId());
|
|
List<AccountRequestFundsDetailVo> list = accountRequestFundsDetailService.getListByContractId(v.getContractId());
|
|
/**
|
|
/**
|
|
* 拖车费
|
|
* 拖车费
|
|
@@ -1999,6 +1941,10 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
* 报关费
|
|
* 报关费
|
|
*/
|
|
*/
|
|
BigDecimal customsFee = BigDecimal.ZERO;
|
|
BigDecimal customsFee = BigDecimal.ZERO;
|
|
|
|
+ /**
|
|
|
|
+ * 代理费
|
|
|
|
+ */
|
|
|
|
+ BigDecimal agencyFee = BigDecimal.ZERO;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 港杂费
|
|
* 港杂费
|
|
@@ -2042,12 +1988,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
|
|
|
for (AccountRequestFundsDetailVo c : list) {
|
|
for (AccountRequestFundsDetailVo c : list) {
|
|
String costType = c.getCostType() == null ? "" : c.getCostType();
|
|
String costType = c.getCostType() == null ? "" : c.getCostType();
|
|
- BigDecimal rate;
|
|
|
|
- if (MapUtils.isNotEmpty(currencyRatesMap)) {
|
|
|
|
- rate = currencyRatesMap.getOrDefault(c.getCurrency(), null);
|
|
|
|
- } else {
|
|
|
|
- rate = c.getRate();
|
|
|
|
- }
|
|
|
|
|
|
+ BigDecimal rate = c.getRate();
|
|
switch (costType) {
|
|
switch (costType) {
|
|
case "0"://拖车费
|
|
case "0"://拖车费
|
|
trailerFee = trailerFee.add(c.getAmount().multiply(rate));
|
|
trailerFee = trailerFee.add(c.getAmount().multiply(rate));
|
|
@@ -2056,7 +1997,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
customsFee = customsFee.add(c.getAmount().multiply(rate));
|
|
customsFee = customsFee.add(c.getAmount().multiply(rate));
|
|
break;
|
|
break;
|
|
case "2"://代理费
|
|
case "2"://代理费
|
|
- customsFee = customsFee.add(c.getAmount().multiply(rate));
|
|
|
|
|
|
+ agencyFee = agencyFee.add(c.getAmount().multiply(rate));
|
|
break;
|
|
break;
|
|
case "3"://港杂费
|
|
case "3"://港杂费
|
|
portMixedFee = portMixedFee.add(c.getAmount().multiply(rate));
|
|
portMixedFee = portMixedFee.add(c.getAmount().multiply(rate));
|
|
@@ -2067,7 +2008,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
case "5"://佣金
|
|
case "5"://佣金
|
|
commission = commission.add(c.getAmount().multiply(rate));
|
|
commission = commission.add(c.getAmount().multiply(rate));
|
|
break;
|
|
break;
|
|
- case "6"://检测费
|
|
|
|
|
|
+ case "6"://其他
|
|
other = other.add(c.getAmount().multiply(rate));
|
|
other = other.add(c.getAmount().multiply(rate));
|
|
break;
|
|
break;
|
|
case "7"://检测费
|
|
case "7"://检测费
|
|
@@ -2089,6 +2030,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
}
|
|
}
|
|
v.setTrailerFee(trailerFee);
|
|
v.setTrailerFee(trailerFee);
|
|
v.setCustomsFee(customsFee);
|
|
v.setCustomsFee(customsFee);
|
|
|
|
+ v.setAgencyFee(agencyFee);
|
|
v.setPortMixedFee(portMixedFee);
|
|
v.setPortMixedFee(portMixedFee);
|
|
v.setInspectionRedPack(inspectionRedPack);
|
|
v.setInspectionRedPack(inspectionRedPack);
|
|
v.setCommission(commission);
|
|
v.setCommission(commission);
|
|
@@ -2308,12 +2250,6 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
ObsFileUtil.saveFile(contractVo.getRemarkFileList(), contractVo.getId(), 30);
|
|
ObsFileUtil.saveFile(contractVo.getRemarkFileList(), contractVo.getId(), 30);
|
|
}
|
|
}
|
|
|
|
|
|
- public static void main(String[] args) {
|
|
|
|
- BigDecimal a = null;
|
|
|
|
- double d1 = a.doubleValue() * 0.13;
|
|
|
|
- System.out.println(d1);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 合同结清
|
|
* 合同结清
|
|
*/
|
|
*/
|