Parcourir la source

利润结算表功能修正

yzc il y a 1 an
Parent
commit
817a1995d4

+ 1 - 2
hx-iot/src/main/java/com/fjhx/iot/listener/DtaListener.java

@@ -24,7 +24,6 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-import javax.annotation.PostConstruct;
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.MessageConsumer;
@@ -53,7 +52,7 @@ public class DtaListener {
 
     public static final Map<Long, MessageConsumer> listenerMap = new ConcurrentHashMap<>();
 
-    @PostConstruct
+//    @PostConstruct
     public void listener() {
 
         TenantHolder.setIgnore(true);

+ 6 - 0
hx-sale/src/main/java/com/fjhx/sale/entity/purchase/po/EhsdPurchase.java

@@ -218,8 +218,14 @@ public class EhsdPurchase extends BasePo {
     /**
      * 税率
      */
+    private BigDecimal taxRate;
+
+    /**
+     * 汇率
+     */
     private BigDecimal rate;
 
+
     /**
      * 流程实例
      */

+ 56 - 120
hx-sale/src/main/java/com/fjhx/sale/service/contract/impl/ContractServiceImpl.java

@@ -25,7 +25,6 @@ import com.fjhx.area.utils.CustomizeAreaUtil;
 import com.fjhx.common.constant.SourceConstant;
 import com.fjhx.common.entity.contract.po.ContractTemplate;
 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.enums.FlowStatusEnum1;
 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));
         for (ContractBudgetVo v : list) {
+            v.setDataJson(null);
             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()));
             //计算支出总计 除合同金额(转人民币)+应退税金额(转人民币)+其他收入(转人民币) 其他金额相加
@@ -865,6 +837,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
                     (v.getFreight()).add
                     (v.getCertificateOfOrigin()).add
                     (v.getAccountPaid()).add
+                    (v.getAgencyFee()).add
                     (v.getProfitAgencyFee()));
             //计算毛利 收入-支出
             v.setGross(v.getIncomeAmount().subtract(v.getExpenditureAmount()));
@@ -1900,22 +1873,17 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
      * 统计到账认领总金额
      *
      * @param claimContractList
-     * @param assignCurrencyRatesMap 汇率JSON
      * @return
      */
-    private BigDecimal getSumClaimMoney(List<ClaimContract> claimContractList, Map<String, BigDecimal> assignCurrencyRatesMap) {
+    private BigDecimal getSumClaimMoney(List<ClaimContract> claimContractList) {
         BigDecimal sumClaimMoney = BigDecimal.ZERO;
         if (ObjectUtil.isEmpty(claimContractList)) {
             return BigDecimal.ZERO;
         }
         for (ClaimContract c : claimContractList) {
-            BigDecimal rate = c.getRate();
-            if (MapUtils.isNotEmpty(assignCurrencyRatesMap)) {
-                rate = assignCurrencyRatesMap.getOrDefault(c.getCurrency(), BigDecimal.ONE);
-            }
             BigDecimal moneyCny = c.getMoneyCny();
             if (ObjectUtil.isEmpty(moneyCny)) {
-                moneyCny = c.getMoney().multiply(rate);
+                moneyCny = BigDecimal.ZERO;
             }
             sumClaimMoney = sumClaimMoney.add(moneyCny);
         }
@@ -1927,10 +1895,9 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
      *
      * @param v
      * @param purchaseList
-     * @param assignCurrencyRatesMap 汇率JSON
      * @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);
         BigDecimal purchaseSumMoney = BigDecimal.ZERO;
         if (CollectionUtils.isEmpty(purchaseList)) {
@@ -1938,57 +1905,32 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
             return;
         }
         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());
         /**
          * 拖车费
@@ -1999,6 +1941,10 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
          * 报关费
          */
         BigDecimal customsFee = BigDecimal.ZERO;
+        /**
+         * 代理费
+         */
+        BigDecimal agencyFee = BigDecimal.ZERO;
 
         /**
          * 港杂费
@@ -2042,12 +1988,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
 
         for (AccountRequestFundsDetailVo c : list) {
             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) {
                 case "0"://拖车费
                     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));
                     break;
                 case "2"://代理费
-                    customsFee = customsFee.add(c.getAmount().multiply(rate));
+                    agencyFee = agencyFee.add(c.getAmount().multiply(rate));
                     break;
                 case "3"://港杂费
                     portMixedFee = portMixedFee.add(c.getAmount().multiply(rate));
@@ -2067,7 +2008,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
                 case "5"://佣金
                     commission = commission.add(c.getAmount().multiply(rate));
                     break;
-                case "6"://检测费
+                case "6"://其他
                     other = other.add(c.getAmount().multiply(rate));
                     break;
                 case "7"://检测费
@@ -2089,6 +2030,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
         }
         v.setTrailerFee(trailerFee);
         v.setCustomsFee(customsFee);
+        v.setAgencyFee(agencyFee);
         v.setPortMixedFee(portMixedFee);
         v.setInspectionRedPack(inspectionRedPack);
         v.setCommission(commission);
@@ -2308,12 +2250,6 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
         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);
-    }
-
     /**
      * 合同结清
      */

+ 2 - 1
hx-sale/src/main/resources/mapper/contract/ContractMapper.xml

@@ -79,7 +79,8 @@
                t1.rate                                                                   AS rate,
                t2.*,
                IFNULL(t1.budget_money, 0)                                                AS budgetMoney,
-               cu.name                                                                      customerName
+               cu.name                                                                      customerName,
+               t1.is_settled
         FROM contract t1
                  LEFT JOIN contract_budget t2 ON t1.id = t2.contract_id
                  LEFT JOIN bytesailing_customer.customer cu on t1.buy_corporation_id = cu.id and cu.del_flag = 0