diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisCommissionProfitServiceImpl.java b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisCommissionProfitServiceImpl.java index b3e126c16..c14a4034d 100644 --- a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisCommissionProfitServiceImpl.java +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisCommissionProfitServiceImpl.java @@ -11,10 +11,7 @@ package com.xdadan.erp.emis.service.impl; import java.math.BigDecimal; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -546,14 +543,19 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements } // 重量计算 else if ("2".equals(quoteItem.getCalcType())) { - if( isValueInExprScope(waybill.getBillWeight().doubleValue(),exprItem) ){ - calcExprStr = getCalcFeeExpStr(waybill.getBillWeight(),exprItem); - log.info("按重量计算:计算公式:" + calcExprStr + ",重量:" + waybill.getBillWeight().stripTrailingZeros().toPlainString()); + String transType = waybill.getTransType(); + BigDecimal usedWeight = ("1".equals(transType) || "2".equals(transType)) + ? waybill.getSettlementWeight() + : waybill.getBillWeight(); + if (isValueInExprScope(usedWeight != null ? usedWeight.doubleValue() : 0.0, exprItem)) { + calcExprStr = getCalcFeeExpStr(usedWeight, exprItem); + log.info("按重量计算:计算公式:" + calcExprStr + ",重量:" + + (usedWeight != null ? usedWeight.stripTrailingZeros().toPlainString() : "0")); Map env = new HashMap<>(); - env.put("w", waybill.getBillWeight()); + env.put("w", usedWeight); env.put("s", exprItem.getInitialWeight()); env.put("d", exprItem.getAdditionalWeight()); - profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExp,env).toString()); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExp, env).toString()); } } @@ -680,14 +682,19 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements } // 重量计算 else if ("2".equals(quoteItem.getCalcType())) { - if( isValueInExprScope(waybill.getBillWeight().doubleValue(),exprItem) ) { - calcExprStr = getCalcFeeExpStr(waybill.getBillWeight(),exprItem); - log.info("按重量计算:计算公式:" + calcExprStr + ",重量:" + waybill.getBillWeight().stripTrailingZeros().toPlainString()); + String transType = waybill.getTransType(); + BigDecimal usedWeight = ("1".equals(transType) || "2".equals(transType)) + ? waybill.getSettlementWeight() + : waybill.getBillWeight(); + if (isValueInExprScope(usedWeight != null ? usedWeight.doubleValue() : 0.0, exprItem)) { + calcExprStr = getCalcFeeExpStr(usedWeight, exprItem); + log.info("按重量计算:计算公式:" + calcExprStr + ",重量:" + + (usedWeight != null ? usedWeight.stripTrailingZeros().toPlainString() : "0")); Map env = new HashMap<>(); - env.put("w", waybill.getBillWeight()); + env.put("w", usedWeight); env.put("s", exprItem.getInitialWeight()); env.put("d", exprItem.getAdditionalWeight()); - profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExp,env).toString()); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExp, env).toString()); } } @@ -823,15 +830,19 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements } // 重量计算-结算重量 else if ("2".equals(quoteItem.getCalcType())) { - - if( isValueInExprScope(waybill.getBillWeight().doubleValue(),exprItem) ) { - calcExprStr = getCalcFeeExpStr(waybill.getBillWeight(),exprItem); - log.info("按重量计算:计算公式:" + calcExprStr + ",重量:" + waybill.getBillWeight().stripTrailingZeros().toPlainString()); + String transType = waybill.getTransType(); + BigDecimal usedWeight = ("1".equals(transType) || "2".equals(transType)) + ? waybill.getSettlementWeight() + : waybill.getBillWeight(); + if (isValueInExprScope(usedWeight != null ? usedWeight.doubleValue() : 0.0, exprItem)) { + calcExprStr = getCalcFeeExpStr(usedWeight, exprItem); + log.info("按重量计算:计算公式:" + calcExprStr + ",重量:" + + (usedWeight != null ? usedWeight.stripTrailingZeros().toPlainString() : "0")); Map env = new HashMap<>(); - env.put("w", waybill.getBillWeight()); + env.put("w", usedWeight); env.put("s", exprItem.getInitialWeight()); env.put("d", exprItem.getAdditionalWeight()); - profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExp,env).toString()); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExp, env).toString()); } } @@ -975,16 +986,20 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements } // 重量计算 else if ("2".equals(quoteItem.getCalcType())) { - - if( isValueInExprScope(waybill.getBillWeight().doubleValue(),exprItem) ) { - calcExprStr = getCalcFeeExpStr(waybill.getBillWeight(), exprItem); - log.info("按重量计算:计算公式:" + calcExprStr + ",重量:"+waybill.getBillWeight().stripTrailingZeros().toPlainString()); + String transType = waybill.getTransType(); + BigDecimal usedWeight = ("1".equals(transType) || "2".equals(transType)) + ? waybill.getSettlementWeight() + : waybill.getBillWeight(); + if (isValueInExprScope(usedWeight != null ? usedWeight.doubleValue() : 0.0, exprItem)) { + calcExprStr = getCalcFeeExpStr(usedWeight, exprItem); + log.info("按重量计算:计算公式:" + calcExprStr + ",重量:" + + waybill.getBillWeight().stripTrailingZeros().toPlainString()); Map env = new HashMap<>(); - env.put("w", waybill.getBillWeight()); + env.put("w", usedWeight); env.put("s", exprItem.getInitialWeight()); env.put("d", exprItem.getAdditionalWeight()); - profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExp,env).toString()); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExp, env).toString()); } } @@ -1121,16 +1136,21 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements } // 重量计算 else if ("2".equals(quoteItem.getCalcType())) { - if( isValueInExprScope(waybill.getBillWeight().doubleValue(),exprItem) ) { - calcExprStr = getCalcFeeExpStr(waybill.getBillWeight(), exprItem); - log.info("按重量计算:计算公式:" + calcExprStr + ",重量:"+waybill.getBillWeight().stripTrailingZeros().toPlainString()); + String transType = waybill.getTransType(); + BigDecimal usedWeight = ("1".equals(transType) || "2".equals(transType)) + ? waybill.getSettlementWeight() + : waybill.getBillWeight(); + if (isValueInExprScope(usedWeight != null ? usedWeight.doubleValue() : 0.0, exprItem)) { + calcExprStr = getCalcFeeExpStr(usedWeight, exprItem); + log.info("按重量计算:计算公式:" + calcExprStr + ",重量:" + + waybill.getBillWeight().stripTrailingZeros().toPlainString()); Map env = new HashMap<>(); - env.put("w", waybill.getBillWeight()); + env.put("w", usedWeight); env.put("s", exprItem.getInitialWeight()); env.put("d", exprItem.getAdditionalWeight()); - profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExp,env).toString()); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExp, env).toString()); } @@ -1263,18 +1283,22 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements } // 重量计算 else if ("2".equals(quoteItem.getCalcType())) { + String transType = waybill.getTransType(); + BigDecimal usedWeight = ("1".equals(transType) || "2".equals(transType)) + ? waybill.getSettlementWeight() + : waybill.getBillWeight(); + if (isValueInExprScope(usedWeight != null ? usedWeight.doubleValue() : 0.0, exprItem)) { + calcExprStr = getCalcFeeExpStr(usedWeight, exprItem); - if( isValueInExprScope(waybill.getBillWeight().doubleValue(),exprItem) ) { - calcExprStr = getCalcFeeExpStr(waybill.getBillWeight(), exprItem); - - log.info("按重量计算:计算公式:" + calcExprStr + ",重量:"+waybill.getBillWeight().stripTrailingZeros().toPlainString()); + log.info("按重量计算:计算公式:" + calcExprStr + ",重量:" + + waybill.getBillWeight().stripTrailingZeros().toPlainString()); Map env = new HashMap<>(); - env.put("w", waybill.getBillWeight()); + env.put("w", usedWeight); env.put("s", exprItem.getInitialWeight()); env.put("d", exprItem.getAdditionalWeight()); - profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExp,env).toString()); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExp, env).toString()); } @@ -1424,18 +1448,25 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements } // 重量计算 else if ("2".equals(quoteItem.getCalcType())) { - calcExprStr = calcExp.replaceAll("w", waybill.getBillWeight().stripTrailingZeros().toPlainString()) + String transType = waybill.getTransType(); + BigDecimal usedWeight = ("1".equals(transType) || "2".equals(transType)) + ? waybill.getSettlementWeight() + : waybill.getBillWeight(); + calcExprStr = calcExp + .replaceAll("w", + usedWeight != null ? usedWeight.stripTrailingZeros().toPlainString() : "0") .replaceAll("s", exprItem.getInitialWeight().toString()) .replaceAll("d", exprItem.getAdditionalWeight().toString()); - log.info("按重量计算:计算公式:" + calcExprStr + ",重量:"+waybill.getBillWeight().stripTrailingZeros().toPlainString()); + log.info("按重量计算:计算公式:" + calcExprStr + ",重量:" + + waybill.getBillWeight().stripTrailingZeros().toPlainString()); Map env = new HashMap<>(); - env.put("w", waybill.getBillWeight()); + env.put("w", usedWeight); env.put("s", exprItem.getInitialWeight()); env.put("d", exprItem.getAdditionalWeight()); - profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExp,env).toString()); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExp, env).toString()); } // 体积计算