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,