From f51ddc3cf55f904f7043773c1ce0f4ca5f829799 Mon Sep 17 00:00:00 2001 From: aike <17730485278@139.com> Date: Fri, 8 Aug 2025 09:29:06 +0800 Subject: [PATCH] =?UTF-8?q?demand:=20=20=20=20tms=E7=B3=BB=E7=BB=9F-?= =?UTF-8?q?=E6=88=90=E6=9C=AC=E7=AE=A1=E7=90=86-=E7=BD=91=E7=82=B9?= =?UTF-8?q?=E5=9B=BA=E5=AE=9A=E6=88=90=E6=9C=AC=E3=80=81=E6=89=B9=E6=AC=A1?= =?UTF-8?q?=E5=88=86=E6=91=8A=E6=88=90=E6=9C=AC=E6=A0=B9=E6=8D=AE=E7=BB=84?= =?UTF-8?q?=E6=89=B9=E6=AC=A1=E8=87=AA=E7=94=B1=E8=AE=BE=E5=AE=9A=E7=9A=84?= =?UTF-8?q?=E9=87=8D=E9=87=8F=E3=80=81=E4=BD=93=E7=A7=AF=E5=88=86=E6=91=8A?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=20=20=20tms=E7=B3=BB=E7=BB=9F-=E6=88=90?= =?UTF-8?q?=E6=9C=AC=E7=AE=A1=E7=90=86-=E8=BF=90=E5=8D=95=E6=88=90?= =?UTF-8?q?=E6=9C=AC=E6=98=8E=E7=BB=86=E8=B4=B9=E7=94=A8=E3=80=81=E5=88=86?= =?UTF-8?q?=E6=91=8A=E9=87=8D=E9=87=8F=E3=80=81=E8=AE=A1=E7=AE=97=E5=A4=87?= =?UTF-8?q?=E6=B3=A8=E5=8F=96=E6=89=B9=E6=AC=A1=E8=AE=BE=E5=AE=9A=E7=9A=84?= =?UTF-8?q?=E5=80=BC=E9=80=82=E5=BA=94=E8=B0=83=E6=95=B4=20=20=E7=BB=84?= =?UTF-8?q?=E6=89=B9=E6=AC=A1=E5=A4=8D=E5=88=B6=E6=89=B9=E6=AC=A1=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E4=BF=9D=E5=AD=98bug=E4=BF=AE=E6=94=B9=20committer:?= =?UTF-8?q?=20heyu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../emis/domain/EmisTmsCostQuotePrice.java | 7 +++ .../domain/vo/cost/CostFeeWaybillRel.java | 9 ++++ .../impl/EmisTmsCostFeeServiceImpl.java | 54 +++++++++++++++++-- .../impl/EmisTmsSiteBatchServiceImpl.java | 19 +++++-- .../resources/mapper/EmisTmsCostFeeMapper.xml | 6 +++ .../mapper/EmisTmsCostQuotePriceMapper.xml | 10 +++- 6 files changed, 95 insertions(+), 10 deletions(-) diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/domain/EmisTmsCostQuotePrice.java b/emis-biz/src/main/java/com/xdadan/erp/emis/domain/EmisTmsCostQuotePrice.java index ca8d1520a..17d7359f3 100644 --- a/emis-biz/src/main/java/com/xdadan/erp/emis/domain/EmisTmsCostQuotePrice.java +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/domain/EmisTmsCostQuotePrice.java @@ -98,4 +98,11 @@ public class EmisTmsCostQuotePrice extends BaseEntity private BigDecimal totalVolume; private String transType; + /* 分批体积 */ + private BigDecimal batchVolume; + /* 分批件数 */ + private Integer batchParcelQty; + /* 分批重量 */ + private BigDecimal batchWeight; + } diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/domain/vo/cost/CostFeeWaybillRel.java b/emis-biz/src/main/java/com/xdadan/erp/emis/domain/vo/cost/CostFeeWaybillRel.java index 0a214518e..69116da57 100644 --- a/emis-biz/src/main/java/com/xdadan/erp/emis/domain/vo/cost/CostFeeWaybillRel.java +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/domain/vo/cost/CostFeeWaybillRel.java @@ -17,6 +17,8 @@ import com.xdadan.erp.emis.domain.EmisTmsCostFee; import com.xdadan.erp.emis.domain.EmisWaybill; import lombok.Data; +import java.math.BigDecimal; + /** * @ClassName EmisTmsCostFeeRel @@ -37,6 +39,13 @@ public class CostFeeWaybillRel extends BaseEntity /* 批次号 */ private String batchNo; + /* 分批体积 */ + private BigDecimal batchVolume; + /* 分批件数 */ + private Integer batchParcelQty; + /* 分批重量 */ + private BigDecimal batchWeight; + // 扩展参数 private EmisWaybill waybillDetail; private EmisTmsCostFee costFeeDetail; diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisTmsCostFeeServiceImpl.java b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisTmsCostFeeServiceImpl.java index 81c49f8f5..c4af43761 100644 --- a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisTmsCostFeeServiceImpl.java +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisTmsCostFeeServiceImpl.java @@ -551,7 +551,15 @@ public class EmisTmsCostFeeServiceImpl extends EmisBaseService implements IEmisT .replaceAll("c", totalDbCostFee.stripTrailingZeros().toPlainString()); Map env = new HashMap<>(); - env.put("w", mainWaybill.getBillWeight()); + env.put("w", waybill.getBillWeight()); + if (quotePriceItem.getBatchWeight() != null) { + env.put("w", quotePriceItem.getBatchWeight()); + splitItem.setBillWeight(quotePriceItem.getBatchWeight()); + splitItem.setTotalVolume(quotePriceItem.getBatchVolume()); + calcExprStr = itemCalcExpr.replaceAll("w", quotePriceItem.getBatchWeight().stripTrailingZeros().toPlainString()) + .replaceAll("t", quotePriceItem.getTransWeight().stripTrailingZeros().toPlainString()) + .replaceAll("c", totalDbCostFee.stripTrailingZeros().toPlainString()); + } env.put("t", quotePriceItem.getTransWeight()); env.put("c", totalDbCostFee); double costFee = Double.valueOf(AviatorEvaluator.execute(itemCalcExpr,env).toString()); @@ -647,8 +655,14 @@ public class EmisTmsCostFeeServiceImpl extends EmisBaseService implements IEmisT String itemCalcExpr = quotePriceItem.getCalculateExpression(); + String calcWeight = waybill.getSettlementWeight().stripTrailingZeros().toPlainString(); + if (quotePriceItem.getBatchWeight() != null) { + calcWeight = quotePriceItem.getBatchWeight().stripTrailingZeros().toPlainString(); + + } + // 正常计算公式 - String calcExprStr = itemCalcExpr.replaceAll("w", waybill.getSettlementWeight().stripTrailingZeros().toPlainString()) + String calcExprStr = itemCalcExpr.replaceAll("w", calcWeight) .replaceAll("t", transWeight.stripTrailingZeros().toPlainString()) .replaceAll("d", quotePriceItem.getPrice().stripTrailingZeros().toPlainString()) .replaceAll("c", totalDbCostFee.stripTrailingZeros().toPlainString()); @@ -658,7 +672,7 @@ public class EmisTmsCostFeeServiceImpl extends EmisBaseService implements IEmisT totalDbCostFee=quotePriceItem.getLeastPrice(); // 总成本=最低报价 itemCalcExpr="(w/t)*c"; - calcExprStr = itemCalcExpr.replaceAll("w", mainWaybill.getSettlementWeight().stripTrailingZeros().toPlainString()) + calcExprStr = itemCalcExpr.replaceAll("w", calcWeight) .replaceAll("t", transWeight.stripTrailingZeros().toPlainString()) .replaceAll("c", totalDbCostFee.stripTrailingZeros().toPlainString()); @@ -666,6 +680,12 @@ public class EmisTmsCostFeeServiceImpl extends EmisBaseService implements IEmisT Map env = new HashMap<>(); env.put("w", waybill.getSettlementWeight()); + if (quotePriceItem.getBatchWeight() != null) { + env.put("w", quotePriceItem.getBatchWeight()); + splitItem.setBillWeight(quotePriceItem.getBatchWeight()); + splitItem.setTotalVolume(quotePriceItem.getBatchVolume()); + + } env.put("t", transWeight); env.put("d", quotePriceItem.getPrice()); env.put("c", totalDbCostFee); @@ -763,12 +783,20 @@ public class EmisTmsCostFeeServiceImpl extends EmisBaseService implements IEmisT String itemCalcExpr = quotePriceItem.getCalculateExpression(); - String calcExprStr = itemCalcExpr.replaceAll("w", mainWaybill.getSettlementWeight().stripTrailingZeros().toPlainString()) + String calcExprStr = itemCalcExpr.replaceAll("w", waybill.getSettlementWeight().stripTrailingZeros().toPlainString()) .replaceAll("t", transWeight.stripTrailingZeros().toPlainString()) .replaceAll("c", totalDbCostFee.stripTrailingZeros().toPlainString()); Map env = new HashMap<>(); env.put("w", waybill.getSettlementWeight()); + if (quotePriceItem.getBatchWeight() != null) { + env.put("w", quotePriceItem.getBatchWeight()); + splitItem.setBillWeight(quotePriceItem.getBatchWeight()); + splitItem.setTotalVolume(quotePriceItem.getBatchVolume()); + calcExprStr = itemCalcExpr.replaceAll("w", quotePriceItem.getBatchWeight().stripTrailingZeros().toPlainString()) + .replaceAll("t", transWeight.stripTrailingZeros().toPlainString()) + .replaceAll("c", totalDbCostFee.stripTrailingZeros().toPlainString()); + } env.put("t", transWeight); env.put("c", totalDbCostFee); double costFee = Double.valueOf(AviatorEvaluator.execute(itemCalcExpr,env).toString()); @@ -1087,6 +1115,14 @@ public class EmisTmsCostFeeServiceImpl extends EmisBaseService implements IEmisT Map env = new HashMap<>(); env.put("w", waybill.getSettlementWeight()); + if (billCodeItem.getBatchWeight() != null) { + env.put("w", billCodeItem.getBatchWeight()); + splitItem.setBillWeight(billCodeItem.getBatchWeight()); + splitItem.setTotalVolume(billCodeItem.getBatchVolume()); + calcExprStr = itemCalcExpr.replaceAll("w", billCodeItem.getBatchWeight().stripTrailingZeros().toPlainString()) + .replaceAll("t", transWeight.stripTrailingZeros().toPlainString()) + .replaceAll("c", totalDbCostFee.stripTrailingZeros().toPlainString()); + } env.put("t", transWeight); env.put("c", totalDbCostFee); costFee = Double.valueOf(AviatorEvaluator.execute(itemCalcExpr,env).toString()); @@ -1100,7 +1136,15 @@ public class EmisTmsCostFeeServiceImpl extends EmisBaseService implements IEmisT .replaceAll("t", transVolume.stripTrailingZeros().toPlainString()) .replaceAll("c", totalDbCostFee.stripTrailingZeros().toPlainString()); Map env = new HashMap<>(); - env.put("w", waybill.getSettlementWeight()); + env.put("w", waybill.getTotalVolume()); + if (billCodeItem.getBatchWeight() != null) { + env.put("w", billCodeItem.getBatchVolume()); + splitItem.setBillWeight(billCodeItem.getBatchWeight()); + splitItem.setTotalVolume(billCodeItem.getBatchVolume()); + calcExprStr = itemCalcExpr.replaceAll("w", billCodeItem.getBatchVolume().stripTrailingZeros().toPlainString()) + .replaceAll("t", transVolume.stripTrailingZeros().toPlainString()) + .replaceAll("c", totalDbCostFee.stripTrailingZeros().toPlainString()); + } env.put("t", transVolume); env.put("c", totalDbCostFee); costFee = Double.valueOf(AviatorEvaluator.execute(itemCalcExpr,env).toString()); diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisTmsSiteBatchServiceImpl.java b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisTmsSiteBatchServiceImpl.java index 5ddba0c9e..99969f255 100644 --- a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisTmsSiteBatchServiceImpl.java +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisTmsSiteBatchServiceImpl.java @@ -191,10 +191,11 @@ public class EmisTmsSiteBatchServiceImpl extends EmisBaseService implements IEmi throw new EmisBizError(EmisBizErrorType.FAIL, itemDtl.getBillCode() + "的批次体积必须大于0"); } - compareWaybillAndBatch(oldSiteBatch, itemDtl, emisWaybill, rule,true); + compareWaybillAndBatch(oldSiteBatch, itemDtl, emisWaybill, rule, true); } - private void compareWaybillAndBatch(EmisTmsSiteBatch oldSiteBatch, EmisTmsSiteBatchDtl itemDtl, EmisWaybill emisWaybill, EmisTransPlanRule rule, boolean isBatch) throws EmisBizError { + private void compareWaybillAndBatch(EmisTmsSiteBatch oldSiteBatch, EmisTmsSiteBatchDtl itemDtl, + EmisWaybill emisWaybill, EmisTransPlanRule rule, boolean isBatch) throws EmisBizError { // 根据起始网点、下一网点和运单号查询TMS组批次 List existingBatches = selectTmsSiteBatchBySiteAndBillCode( oldSiteBatch.getStartSiteCode(), @@ -252,8 +253,18 @@ public class EmisTmsSiteBatchServiceImpl extends EmisBaseService implements IEmi // 将allBatches根据起始网点、下一网点、批次重量、件数、体积分组去重 Map> groupedBatches = allBatches.stream() - .collect(Collectors.groupingBy(batch -> batch.getStartSiteCode() + "_" + batch.getNextSiteCode() + "_" + - batch.getTotalWeight() + "_" + batch.getTotalParcelQty() + "_" + batch.getTotalVolume())); + .collect(Collectors.groupingBy(batch -> { + // 去除重量和体积的多余0 + String weightStr = batch.getTotalWeight() != null + ? batch.getTotalWeight().stripTrailingZeros().toPlainString() + : "0"; + String volumeStr = batch.getTotalVolume() != null + ? batch.getTotalVolume().stripTrailingZeros().toPlainString() + : "0"; + + return batch.getStartSiteCode() + "_" + batch.getNextSiteCode() + "_" + + weightStr + "_" + batch.getTotalParcelQty() + "_" + volumeStr; + })); // 计算去重后的批次总重量、总件数、总体积 BigDecimal totalWeight = groupedBatches.values().stream() diff --git a/emis-biz/src/main/resources/mapper/EmisTmsCostFeeMapper.xml b/emis-biz/src/main/resources/mapper/EmisTmsCostFeeMapper.xml index 4fc735cdc..aaf245326 100644 --- a/emis-biz/src/main/resources/mapper/EmisTmsCostFeeMapper.xml +++ b/emis-biz/src/main/resources/mapper/EmisTmsCostFeeMapper.xml @@ -72,6 +72,9 @@ + + + + + + + @@ -104,7 +108,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" b.total_weight, b.total_volume, b.trans_type, - b.total_settlement_weight + b.total_settlement_weight, + + c.batch_volume, + c.batch_parcel_qty, + c.batch_weight FROM emis_tms_cost_quote_price a,