From da0ddd434c759a015b58a2f87397d5c08fa0ee41 Mon Sep 17 00:00:00 2001 From: linfso Date: Mon, 9 Jun 2025 22:09:04 +0800 Subject: [PATCH] md --- .../erp/emis/service/EmisBaseService.java | 2 +- .../impl/EmisCommissionProfitServiceImpl.java | 141 ++++++++++-------- 2 files changed, 77 insertions(+), 66 deletions(-) diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/service/EmisBaseService.java b/emis-biz/src/main/java/com/xdadan/erp/emis/service/EmisBaseService.java index ad2b71ce5..a89211b4c 100644 --- a/emis-biz/src/main/java/com/xdadan/erp/emis/service/EmisBaseService.java +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/service/EmisBaseService.java @@ -1812,7 +1812,7 @@ public class EmisBaseService { // 新费用 newTotalFee = emisSettleSubBill.getBillFee(); - // 若果新费用和老费用不相同,需要走审核流程:设置初始账单未确认 + // 如果新费用和老费用不相同,需要走审核流程:设置初始账单未确认 if(oldTotalFee.compareTo(newTotalFee)!=0) { emisSettleSubBill.setBlConfirmSite("0"); emisSettleSubBill.setBlConfirmCenter("0"); 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 ddd2ea7dc..d6d8c2995 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 @@ -291,7 +291,20 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements } + private boolean isValueInExprScope(double checkValue,EmisCommissionExpression exprItem){ + if (exprItem.getStartWeight().doubleValue() < checkValue && exprItem.getEndWeight().doubleValue() >= checkValue) { + return true; + } + else{ + return false; + } + } + private String getCalcFeeExpStr(BigDecimal w,EmisCommissionExpression exprItem){ + return exprItem.getCalculateExpression().replaceAll("w", w.stripTrailingZeros().toPlainString()) + .replaceAll("s", exprItem.getInitialWeight().toString()) + .replaceAll("d", exprItem.getAdditionalWeight().toString()); + } /** * 根据单号重新计算提成 */ @@ -493,21 +506,20 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements } // 重量计算 else if ("2".equals(quoteItem.getCalcType())) { - calcExprStr = calcExp.replaceAll("w", waybill.getSettlementWeight().stripTrailingZeros().toPlainString()) - .replaceAll("s", exprItem.getInitialWeight().toString()) - .replaceAll("d", exprItem.getAdditionalWeight().toString()); - - log.info("按重量计算:计算公式:" + calcExprStr + ",重量:"+waybill.getSettlementWeight().stripTrailingZeros().toPlainString()); - profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + if( isValueInExprScope(waybill.getSettlementWeight().doubleValue(),exprItem) ){ + calcExprStr = getCalcFeeExpStr(waybill.getSettlementWeight(),exprItem); + log.info("按重量计算:计算公式:" + calcExprStr + ",重量:" + waybill.getSettlementWeight().stripTrailingZeros().toPlainString()); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + } } // 体积计算 else if ("3".equals(quoteItem.getCalcType())) { - calcExprStr = calcExp.replaceAll("w", waybill.getTotalVolume().stripTrailingZeros().toPlainString()) - .replaceAll("s", exprItem.getInitialWeight().toString()) - .replaceAll("d", exprItem.getAdditionalWeight().toString()); - log.info("按体积计算:计算公式:" + calcExprStr + ",体积:"+waybill.getTotalVolume().stripTrailingZeros().toPlainString()); - profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + if( isValueInExprScope(waybill.getTotalVolume().doubleValue(),exprItem) ) { + calcExprStr = getCalcFeeExpStr(waybill.getTotalVolume(),exprItem); + log.info("按体积计算:计算公式:" + calcExprStr + ",体积:" + waybill.getTotalVolume().stripTrailingZeros().toPlainString()); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + } } // 包裹数 else if ("4".equals(quoteItem.getCalcType())) { @@ -611,21 +623,20 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements } // 重量计算 else if ("2".equals(quoteItem.getCalcType())) { - calcExprStr = calcExp.replaceAll("w", waybill.getSettlementWeight().stripTrailingZeros().toPlainString()) - .replaceAll("s", exprItem.getInitialWeight().toString()) - .replaceAll("d", exprItem.getAdditionalWeight().toString()); - - log.info("按重量计算:计算公式:" + calcExprStr + ",重量:"+waybill.getSettlementWeight().stripTrailingZeros().toPlainString()); - profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + if( isValueInExprScope(waybill.getSettlementWeight().doubleValue(),exprItem) ) { + calcExprStr = getCalcFeeExpStr(waybill.getSettlementWeight(),exprItem); + log.info("按重量计算:计算公式:" + calcExprStr + ",重量:" + waybill.getSettlementWeight().stripTrailingZeros().toPlainString()); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + } } // 体积计算 else if ("3".equals(quoteItem.getCalcType())) { - calcExprStr = calcExp.replaceAll("w", waybill.getTotalVolume().stripTrailingZeros().toPlainString()) - .replaceAll("s", exprItem.getInitialWeight().toString()) - .replaceAll("d", exprItem.getAdditionalWeight().toString()); - log.info("按体积计算:计算公式:" + calcExprStr + ",体积:"+waybill.getTotalVolume().stripTrailingZeros().toPlainString()); - profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + if( isValueInExprScope(waybill.getTotalVolume().doubleValue(),exprItem) ) { + calcExprStr = getCalcFeeExpStr(waybill.getTotalVolume(),exprItem); + log.info("按体积计算:计算公式:" + calcExprStr + ",体积:" + waybill.getTotalVolume().stripTrailingZeros().toPlainString()); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + } } // 包裹数 else if ("4".equals(quoteItem.getCalcType())) { @@ -721,6 +732,9 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements for (EmisCommissionExpression exprItem : exprList) { log.info("计算项目表达式:" + JSONObject.toJSONString(exprItem)); + double startValue=exprItem.getStartWeight(); + double endValue=exprItem.getEndWeight(); + String calcExp = exprItem.getCalculateExpression(); double profitMoney = 0.0D; @@ -735,21 +749,23 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements } // 重量计算-结算重量 else if ("2".equals(quoteItem.getCalcType())) { - calcExprStr = calcExp.replaceAll("w", waybill.getBillWeight().stripTrailingZeros().toPlainString()) - .replaceAll("s", exprItem.getInitialWeight().toString()) - .replaceAll("d", exprItem.getAdditionalWeight().toString()); - log.info("按重量计算:计算公式:" + calcExprStr + ",重量:"+waybill.getBillWeight().stripTrailingZeros().toPlainString()); - profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + if( isValueInExprScope(waybill.getBillWeight().doubleValue(),exprItem) ) { + calcExprStr = getCalcFeeExpStr(waybill.getBillWeight(),exprItem); + log.info("按重量计算:计算公式:" + calcExprStr + ",重量:" + waybill.getBillWeight().stripTrailingZeros().toPlainString()); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + } } // 体积计算 else if ("3".equals(quoteItem.getCalcType())) { - calcExprStr = calcExp.replaceAll("w", waybill.getTotalVolume().stripTrailingZeros().toPlainString()) - .replaceAll("s", exprItem.getInitialWeight().toString()) - .replaceAll("d", exprItem.getAdditionalWeight().toString()); - log.info("按体积计算:计算公式:" + calcExprStr + ",体积:"+waybill.getTotalVolume().stripTrailingZeros().toPlainString()); - profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + + if( isValueInExprScope(waybill.getTotalVolume().doubleValue(),exprItem) ) { + calcExprStr = getCalcFeeExpStr(waybill.getTotalVolume(),exprItem); + log.info("按体积计算:计算公式:" + calcExprStr + ",体积:"+waybill.getTotalVolume().stripTrailingZeros().toPlainString()); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + } + } // 包裹数 else if ("4".equals(quoteItem.getCalcType())) { @@ -862,21 +878,21 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements } // 重量计算 else if ("2".equals(quoteItem.getCalcType())) { - calcExprStr = calcExp.replaceAll("w", waybill.getSettlementWeight().stripTrailingZeros().toPlainString()) - .replaceAll("s", exprItem.getInitialWeight().toString()) - .replaceAll("d", exprItem.getAdditionalWeight().toString()); - log.info("按重量计算:计算公式:" + calcExprStr + ",重量:"+waybill.getSettlementWeight().stripTrailingZeros().toPlainString()); - profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + if( isValueInExprScope(waybill.getSettlementWeight().doubleValue(),exprItem) ) { + calcExprStr = getCalcFeeExpStr(waybill.getSettlementWeight(), exprItem); + log.info("按重量计算:计算公式:" + calcExprStr + ",重量:"+waybill.getSettlementWeight().stripTrailingZeros().toPlainString()); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + } } // 体积计算 else if ("3".equals(quoteItem.getCalcType())) { - calcExprStr = calcExp.replaceAll("w", waybill.getTotalVolume().stripTrailingZeros().toPlainString()) - .replaceAll("s", exprItem.getInitialWeight().toString()) - .replaceAll("d", exprItem.getAdditionalWeight().toString()); - log.info("按体积计算:计算公式:" + calcExprStr + ",体积:"+waybill.getTotalVolume().stripTrailingZeros().toPlainString()); - profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + if( isValueInExprScope(waybill.getTotalVolume().doubleValue(),exprItem) ) { + calcExprStr = getCalcFeeExpStr(waybill.getTotalVolume(), exprItem); + log.info("按体积计算:计算公式:" + calcExprStr + ",体积:"+waybill.getTotalVolume().stripTrailingZeros().toPlainString()); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + } } // 包裹数 else if ("4".equals(quoteItem.getCalcType())) { @@ -987,21 +1003,23 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements } // 重量计算 else if ("2".equals(quoteItem.getCalcType())) { - calcExprStr = calcExp.replaceAll("w", waybill.getSettlementWeight().stripTrailingZeros().toPlainString()) - .replaceAll("s", exprItem.getInitialWeight().toString()) - .replaceAll("d", exprItem.getAdditionalWeight().toString()); + if( isValueInExprScope(waybill.getSettlementWeight().doubleValue(),exprItem) ) { + calcExprStr = getCalcFeeExpStr(waybill.getSettlementWeight(), exprItem); + log.info("按重量计算:计算公式:" + calcExprStr + ",重量:"+waybill.getSettlementWeight().stripTrailingZeros().toPlainString()); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + } - log.info("按重量计算:计算公式:" + calcExprStr + ",重量:"+waybill.getSettlementWeight().stripTrailingZeros().toPlainString()); - profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); } // 体积计算 else if ("3".equals(quoteItem.getCalcType())) { - calcExprStr = calcExp.replaceAll("w", waybill.getTotalVolume().stripTrailingZeros().toPlainString()) - .replaceAll("s", exprItem.getInitialWeight().toString()) - .replaceAll("d", exprItem.getAdditionalWeight().toString()); - log.info("按体积计算:计算公式:" + calcExprStr + ",体积:"+waybill.getTotalVolume().stripTrailingZeros().toPlainString()); - profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + + if( isValueInExprScope(waybill.getTotalVolume().doubleValue(),exprItem) ) { + calcExprStr = getCalcFeeExpStr(waybill.getTotalVolume(), exprItem); + log.info("按体积计算:计算公式:" + calcExprStr + ",体积:"+waybill.getTotalVolume().stripTrailingZeros().toPlainString()); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + } + } // 包裹数 else if ("4".equals(quoteItem.getCalcType())) { @@ -1102,32 +1120,25 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements // 重量计算 else if ("2".equals(quoteItem.getCalcType())) { - if (exprItem.getStartWeight().doubleValue() < waybill.getSettlementWeight().doubleValue() - && exprItem.getEndWeight().doubleValue() >= waybill.getSettlementWeight().doubleValue() - ) { - calcExprStr = calcExp.replaceAll("w", waybill.getSettlementWeight().stripTrailingZeros().toPlainString()) - .replaceAll("s", exprItem.getInitialWeight().toString()) - .replaceAll("d", exprItem.getAdditionalWeight().toString()); + if( isValueInExprScope(waybill.getSettlementWeight().doubleValue(),exprItem) ) { + calcExprStr = getCalcFeeExpStr(waybill.getSettlementWeight(), exprItem); log.info("按重量计算:计算公式:" + calcExprStr + ",重量:"+waybill.getSettlementWeight().stripTrailingZeros().toPlainString()); profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); } + + } // 体积计算 else if ("3".equals(quoteItem.getCalcType())) { - if (exprItem.getStartWeight().doubleValue() < waybill.getTotalVolume().doubleValue() - && exprItem.getEndWeight().doubleValue() >= waybill.getTotalVolume().doubleValue() - ) { + if( isValueInExprScope(waybill.getTotalVolume().doubleValue(),exprItem) ) { + calcExprStr = getCalcFeeExpStr(waybill.getTotalVolume(), exprItem); - calcExprStr = calcExp.replaceAll("w", waybill.getTotalVolume().stripTrailingZeros().toPlainString()) - .replaceAll("s", exprItem.getInitialWeight().toString()) - .replaceAll("d", exprItem.getAdditionalWeight().toString()); log.info("按体积计算:计算公式:" + calcExprStr + ",体积:"+waybill.getTotalVolume().stripTrailingZeros().toPlainString()); profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); - } }