|
@@ -46,7 +46,6 @@ import com.fjhx.purchase.entity.arrival.po.ArrivalDetail;
|
|
|
import com.fjhx.purchase.entity.pay.po.Pay;
|
|
|
import com.fjhx.purchase.entity.purchase.po.Purchase;
|
|
|
import com.fjhx.purchase.entity.purchase.po.PurchaseDetail;
|
|
|
-import com.fjhx.purchase.entity.purchase.vo.PurchaseDetailVo;
|
|
|
import com.fjhx.purchase.entity.quality.po.QualityDetail;
|
|
|
import com.fjhx.purchase.service.arrival.ArrivalDetailService;
|
|
|
import com.fjhx.purchase.service.pay.PayDetailService;
|
|
@@ -66,7 +65,6 @@ import com.fjhx.sale.entity.purchase.po.EhsdPurchase;
|
|
|
import com.fjhx.sale.entity.purchase.po.EhsdPurchaseProduct;
|
|
|
import com.fjhx.sale.entity.purchase.vo.EhsdPurchaseProductVo;
|
|
|
import com.fjhx.sale.entity.sale.vo.SaleQuotationVo;
|
|
|
-import com.fjhx.sale.entity.statement.vo.ProfitSettlementVo;
|
|
|
import com.fjhx.sale.mapper.contract.ContractMapper;
|
|
|
import com.fjhx.sale.service.claim.ClaimContractService;
|
|
|
import com.fjhx.sale.service.contract.*;
|
|
@@ -430,6 +428,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
|
|
|
/**
|
|
|
* 利润预算表头部统计
|
|
|
+ *
|
|
|
* @param dto
|
|
|
* @return
|
|
|
*/
|
|
@@ -459,9 +458,10 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
|
|
|
/**
|
|
|
* 利润预算表统计公共方法
|
|
|
+ *
|
|
|
* @param list
|
|
|
*/
|
|
|
- private void statisticCommon(List<ContractBudgetVo> list){
|
|
|
+ private void statisticCommon(List<ContractBudgetVo> list) {
|
|
|
//取出EHSD采购所有金额和货币-通过合同ID分组
|
|
|
List<Long> contractIds = list.stream().map(ContractBudgetVo::getContractId).collect(Collectors.toList());
|
|
|
List<EhsdPurchaseProductVo> ehsdAmountList = ehsdPurchaseProductService.getPurchaseByContractId(contractIds);
|
|
@@ -478,7 +478,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
*/
|
|
|
List<EhsdPurchaseProductVo> pList = ehsdAmountMap.getOrDefault(v.getContractId(), null);
|
|
|
if (CollectionUtils.isNotEmpty(pList)) {
|
|
|
- for(EhsdPurchaseProductVo e : pList){
|
|
|
+ for (EhsdPurchaseProductVo e : pList) {
|
|
|
//获取汇率
|
|
|
BigDecimal rate = map.getOrDefault(e.getCurrency(), BigDecimal.ONE);
|
|
|
// 获取认领金额
|
|
@@ -486,11 +486,11 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
//总金额
|
|
|
BigDecimal amount = rate.multiply(money);
|
|
|
purchaseAmount = purchaseAmount.add(amount);
|
|
|
- if(ObjectUtil.isNotEmpty(e.getProductCategoryIds())){
|
|
|
- if(e.getProductCategoryIds().contains("1685534140512616449")||e.getProductCategoryId()==1685534140512616449L){//包材
|
|
|
+ if (ObjectUtil.isNotEmpty(e.getProductCategoryIds())) {
|
|
|
+ if (e.getProductCategoryIds().contains("1685534140512616449") || e.getProductCategoryId() == 1685534140512616449L) {//包材
|
|
|
peritectoidAmount = peritectoidAmount.add(amount);
|
|
|
}
|
|
|
- if(e.getProductCategoryIds().contains("1685534141821239297")||e.getProductCategoryId()==1685534141821239297L){//配件
|
|
|
+ if (e.getProductCategoryIds().contains("1685534141821239297") || e.getProductCategoryId() == 1685534141821239297L) {//配件
|
|
|
accessoriesAmount = accessoriesAmount.add(amount);
|
|
|
}
|
|
|
}
|
|
@@ -520,7 +520,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
*/
|
|
|
List<EhsdPurchaseProductVo> pList = ehsdAmountMap.getOrDefault(v.getContractId(), null);
|
|
|
if (CollectionUtils.isNotEmpty(pList)) {
|
|
|
- for(EhsdPurchaseProductVo e : pList){
|
|
|
+ for (EhsdPurchaseProductVo e : pList) {
|
|
|
//获取汇率
|
|
|
BigDecimal rate = e.getRate();
|
|
|
// 获取认领金额
|
|
@@ -528,11 +528,11 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
//总金额
|
|
|
BigDecimal amount = rate.multiply(money);
|
|
|
purchaseAmount = purchaseAmount.add(amount);
|
|
|
- if(ObjectUtil.isNotEmpty(e.getProductCategoryIds())){
|
|
|
- if(e.getProductCategoryIds().contains("1685534140512616449")||e.getProductCategoryId()==1685534140512616449L){//包材
|
|
|
+ if (ObjectUtil.isNotEmpty(e.getProductCategoryIds())) {
|
|
|
+ if (e.getProductCategoryIds().contains("1685534140512616449") || e.getProductCategoryId() == 1685534140512616449L) {//包材
|
|
|
peritectoidAmount = peritectoidAmount.add(amount);
|
|
|
}
|
|
|
- if(e.getProductCategoryIds().contains("1685534141821239297")||e.getProductCategoryId()==1685534141821239297L){//配件
|
|
|
+ if (e.getProductCategoryIds().contains("1685534141821239297") || e.getProductCategoryId() == 1685534141821239297L) {//配件
|
|
|
accessoriesAmount = accessoriesAmount.add(amount);
|
|
|
}
|
|
|
}
|
|
@@ -566,12 +566,14 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
v.setGrossRate(v.getGross().divide(v.getIncomeAmount(), RoundingMode.CEILING).multiply(new BigDecimal("100")));
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 统计金额
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
- private Map<String,Object> sumStatistic(List<ContractBudgetVo> list){
|
|
|
- Map<String,Object> map = new HashMap<>();
|
|
|
+ private Map<String, Object> sumStatistic(List<ContractBudgetVo> list) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
BigDecimal contractSumAmount = BigDecimal.ZERO;
|
|
|
BigDecimal taxReturnMoneySumAmount = BigDecimal.ZERO;
|
|
|
BigDecimal purchaseSumAmount = BigDecimal.ZERO;
|
|
@@ -588,44 +590,45 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
BigDecimal totalExpensesSumAmount = BigDecimal.ZERO;
|
|
|
BigDecimal grossProfitMargin = BigDecimal.ZERO;
|
|
|
for (ContractBudgetVo p : list) {
|
|
|
- contractSumAmount = contractSumAmount.add(ObjectUtil.isEmpty(p.getRmbContractAmount())?BigDecimal.ZERO:p.getRmbContractAmount());//合同金额
|
|
|
- taxReturnMoneySumAmount = taxReturnMoneySumAmount.add(ObjectUtil.isEmpty(p.getRefundableAmount())?BigDecimal.ZERO:p.getRefundableAmount());//退税
|
|
|
- purchaseSumAmount = purchaseSumAmount.add(ObjectUtil.isEmpty(p.getEhsdSumAmount())?BigDecimal.ZERO:p.getEhsdSumAmount());//采购金额
|
|
|
- peritectoidSumAmount = peritectoidSumAmount.add(ObjectUtil.isEmpty(p.getPeritectoidAmount())?BigDecimal.ZERO:p.getPeritectoidAmount());//包材
|
|
|
- accessoriesSumAmount = accessoriesSumAmount.add(ObjectUtil.isEmpty(p.getAccessoriesAmount())?BigDecimal.ZERO:p.getAccessoriesAmount());//配件
|
|
|
- trailerFeeSumAmount = trailerFeeSumAmount.add(ObjectUtil.isEmpty(p.getTrailerFee())?BigDecimal.ZERO:p.getTrailerFee());//拖车费
|
|
|
- customsFeeSumAmount = customsFeeSumAmount.add(ObjectUtil.isEmpty(p.getCustomsFee())?BigDecimal.ZERO:p.getCustomsFee());//报关费
|
|
|
- agencyFeeSumAmount = agencyFeeSumAmount.add(ObjectUtil.isEmpty(p.getAgencyFee())?BigDecimal.ZERO:p.getAgencyFee());//代理费
|
|
|
- portMixedFeeSumAmount = portMixedFeeSumAmount.add(ObjectUtil.isEmpty(p.getProfitAgencyFee())?BigDecimal.ZERO:p.getProfitAgencyFee());//港杂费
|
|
|
- inspectionRedPackSumAmount = inspectionRedPackSumAmount.add(ObjectUtil.isEmpty(p.getInspectionRedPack())?BigDecimal.ZERO:p.getInspectionRedPack());//验货红包
|
|
|
- commissionSumAmount = commissionSumAmount.add(ObjectUtil.isEmpty(p.getCommission())?BigDecimal.ZERO:p.getCommission());//佣金
|
|
|
- otherSumAmount = otherSumAmount.add(ObjectUtil.isEmpty(p.getOther())?BigDecimal.ZERO:p.getOther());//其他
|
|
|
- totalIncomeSumAmount = totalIncomeSumAmount.add(ObjectUtil.isEmpty(p.getIncomeAmount())?BigDecimal.ZERO:p.getIncomeAmount());//总收入
|
|
|
- totalExpensesSumAmount = totalExpensesSumAmount.add(ObjectUtil.isEmpty(p.getExpenditureAmount())?BigDecimal.ZERO:p.getExpenditureAmount());//总支出
|
|
|
+ contractSumAmount = contractSumAmount.add(ObjectUtil.isEmpty(p.getRmbContractAmount()) ? BigDecimal.ZERO : p.getRmbContractAmount());//合同金额
|
|
|
+ taxReturnMoneySumAmount = taxReturnMoneySumAmount.add(ObjectUtil.isEmpty(p.getRefundableAmount()) ? BigDecimal.ZERO : p.getRefundableAmount());//退税
|
|
|
+ purchaseSumAmount = purchaseSumAmount.add(ObjectUtil.isEmpty(p.getEhsdSumAmount()) ? BigDecimal.ZERO : p.getEhsdSumAmount());//采购金额
|
|
|
+ peritectoidSumAmount = peritectoidSumAmount.add(ObjectUtil.isEmpty(p.getPeritectoidAmount()) ? BigDecimal.ZERO : p.getPeritectoidAmount());//包材
|
|
|
+ accessoriesSumAmount = accessoriesSumAmount.add(ObjectUtil.isEmpty(p.getAccessoriesAmount()) ? BigDecimal.ZERO : p.getAccessoriesAmount());//配件
|
|
|
+ trailerFeeSumAmount = trailerFeeSumAmount.add(ObjectUtil.isEmpty(p.getTrailerFee()) ? BigDecimal.ZERO : p.getTrailerFee());//拖车费
|
|
|
+ customsFeeSumAmount = customsFeeSumAmount.add(ObjectUtil.isEmpty(p.getCustomsFee()) ? BigDecimal.ZERO : p.getCustomsFee());//报关费
|
|
|
+ agencyFeeSumAmount = agencyFeeSumAmount.add(ObjectUtil.isEmpty(p.getAgencyFee()) ? BigDecimal.ZERO : p.getAgencyFee());//代理费
|
|
|
+ portMixedFeeSumAmount = portMixedFeeSumAmount.add(ObjectUtil.isEmpty(p.getProfitAgencyFee()) ? BigDecimal.ZERO : p.getProfitAgencyFee());//港杂费
|
|
|
+ inspectionRedPackSumAmount = inspectionRedPackSumAmount.add(ObjectUtil.isEmpty(p.getInspectionRedPack()) ? BigDecimal.ZERO : p.getInspectionRedPack());//验货红包
|
|
|
+ commissionSumAmount = commissionSumAmount.add(ObjectUtil.isEmpty(p.getCommission()) ? BigDecimal.ZERO : p.getCommission());//佣金
|
|
|
+ otherSumAmount = otherSumAmount.add(ObjectUtil.isEmpty(p.getOther()) ? BigDecimal.ZERO : p.getOther());//其他
|
|
|
+ totalIncomeSumAmount = totalIncomeSumAmount.add(ObjectUtil.isEmpty(p.getIncomeAmount()) ? BigDecimal.ZERO : p.getIncomeAmount());//总收入
|
|
|
+ totalExpensesSumAmount = totalExpensesSumAmount.add(ObjectUtil.isEmpty(p.getExpenditureAmount()) ? BigDecimal.ZERO : p.getExpenditureAmount());//总支出
|
|
|
}
|
|
|
//计算总毛利和总毛利率
|
|
|
BigDecimal grossProfitSum = totalIncomeSumAmount.subtract(totalExpensesSumAmount);//毛利
|
|
|
- if (totalIncomeSumAmount.compareTo(BigDecimal.ZERO)>0) {
|
|
|
+ if (totalIncomeSumAmount.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
grossProfitMargin = new BigDecimal("100").multiply(grossProfitSum).divide(totalIncomeSumAmount, 2, RoundingMode.HALF_UP);//毛利率
|
|
|
}
|
|
|
- map.put("contractSumAmount",contractSumAmount.setScale(2, RoundingMode.HALF_UP));
|
|
|
- map.put("taxReturnMoneySumAmount",taxReturnMoneySumAmount.setScale(2, RoundingMode.HALF_UP));
|
|
|
- map.put("purchaseSumAmount",purchaseSumAmount.setScale(2, RoundingMode.HALF_UP));
|
|
|
- map.put("peritectoidSumAmount",peritectoidSumAmount.setScale(2, RoundingMode.HALF_UP));
|
|
|
- map.put("accessoriesSumAmount",accessoriesSumAmount.setScale(2, RoundingMode.HALF_UP));
|
|
|
- map.put("trailerFeeSumAmount",trailerFeeSumAmount.setScale(2, RoundingMode.HALF_UP));
|
|
|
- map.put("customsFeeSumAmount",customsFeeSumAmount.setScale(2, RoundingMode.HALF_UP));
|
|
|
- map.put("agencyFeeSumAmount",agencyFeeSumAmount.setScale(2, RoundingMode.HALF_UP));
|
|
|
- map.put("portMixedFeeSumAmount",portMixedFeeSumAmount.setScale(2, RoundingMode.HALF_UP));
|
|
|
- map.put("inspectionRedPackSumAmount",inspectionRedPackSumAmount.setScale(2, RoundingMode.HALF_UP));
|
|
|
- map.put("commissionSumAmount",commissionSumAmount.setScale(2, RoundingMode.HALF_UP));
|
|
|
- map.put("otherSumAmount",otherSumAmount.setScale(2, RoundingMode.HALF_UP));
|
|
|
- map.put("totalIncomeSumAmount",totalIncomeSumAmount.setScale(2, RoundingMode.HALF_UP));
|
|
|
- map.put("totalExpensesSumAmount",totalExpensesSumAmount.setScale(2, RoundingMode.HALF_UP));
|
|
|
- map.put("grossProfitMargin",grossProfitMargin.setScale(2, RoundingMode.HALF_UP));
|
|
|
- map.put("grossProfitSum",grossProfitSum.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ map.put("contractSumAmount", contractSumAmount.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ map.put("taxReturnMoneySumAmount", taxReturnMoneySumAmount.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ map.put("purchaseSumAmount", purchaseSumAmount.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ map.put("peritectoidSumAmount", peritectoidSumAmount.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ map.put("accessoriesSumAmount", accessoriesSumAmount.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ map.put("trailerFeeSumAmount", trailerFeeSumAmount.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ map.put("customsFeeSumAmount", customsFeeSumAmount.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ map.put("agencyFeeSumAmount", agencyFeeSumAmount.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ map.put("portMixedFeeSumAmount", portMixedFeeSumAmount.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ map.put("inspectionRedPackSumAmount", inspectionRedPackSumAmount.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ map.put("commissionSumAmount", commissionSumAmount.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ map.put("otherSumAmount", otherSumAmount.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ map.put("totalIncomeSumAmount", totalIncomeSumAmount.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ map.put("totalExpensesSumAmount", totalExpensesSumAmount.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ map.put("grossProfitMargin", grossProfitMargin.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ map.put("grossProfitSum", grossProfitSum.setScale(2, RoundingMode.HALF_UP));
|
|
|
return map;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 利润结算表分页
|
|
|
*
|
|
@@ -1748,17 +1751,16 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
*/
|
|
|
private BigDecimal getSumClaimMoney(List<ClaimContract> claimContractList, Map<String, BigDecimal> assignCurrencyRatesMap) {
|
|
|
BigDecimal sumClaimMoney = BigDecimal.ZERO;
|
|
|
- if (CollectionUtils.isEmpty(claimContractList)) {
|
|
|
- return BigDecimal.ZERO;
|
|
|
- }
|
|
|
- if (MapUtils.isNotEmpty(assignCurrencyRatesMap)) {
|
|
|
- for (ClaimContract c : claimContractList) {
|
|
|
- sumClaimMoney = sumClaimMoney.add(c.getMoney().multiply(assignCurrencyRatesMap.getOrDefault(c.getCurrency(), BigDecimal.ONE)));
|
|
|
+ for (ClaimContract c : claimContractList) {
|
|
|
+ BigDecimal rate = c.getRate();
|
|
|
+ if (MapUtils.isNotEmpty(assignCurrencyRatesMap)) {
|
|
|
+ rate = assignCurrencyRatesMap.getOrDefault(c.getCurrency(), BigDecimal.ONE);
|
|
|
}
|
|
|
- } else {
|
|
|
- for (ClaimContract c : claimContractList) {
|
|
|
- sumClaimMoney = sumClaimMoney.add(c.getMoney().multiply(c.getRate()));
|
|
|
+ BigDecimal moneyCny = c.getMoneyCny();
|
|
|
+ if (ObjectUtil.isEmpty(moneyCny)) {
|
|
|
+ moneyCny = c.getMoney().multiply(rate);
|
|
|
}
|
|
|
+ sumClaimMoney = sumClaimMoney.add(moneyCny);
|
|
|
}
|
|
|
return sumClaimMoney;
|
|
|
}
|
|
@@ -2026,9 +2028,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
public Page<ContractVo> getExportCopyList(ContractSelectDto dto) {
|
|
|
IWrapper<Contract> wrapper = getWrapper();
|
|
|
SysUser sysUser = UserUtil.getUserInfo();
|
|
|
- if (StringUtils.isEmpty(sysUser.getUserCode())) {//不是业务员看所有
|
|
|
- return pageCommon(dto, wrapper);
|
|
|
- } else {//是业务员
|
|
|
+ if (StringUtils.isNotEmpty(sysUser.getUserCode())) {//是业务员 过滤权限
|
|
|
List<Long> authIdList = customerService.getAuthIdList();
|
|
|
if (authIdList.size() == 0) {
|
|
|
return new Page<>();
|