This commit is contained in:
linfso 2025-07-11 06:29:15 +08:00
parent 31ab5dce13
commit d10a99cbe8
4 changed files with 50 additions and 15 deletions

View File

@ -95,5 +95,6 @@ public class EmisTmsCostQuotePrice extends BaseEntity
private Date etd;
private BigDecimal transWeight;
private BigDecimal totalWeight;
private BigDecimal totalVolume;
}

View File

@ -10,6 +10,7 @@
*/
package com.xdadan.erp.emis.mapper;
import java.math.BigDecimal;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xdadan.erp.emis.domain.EmisTmsCostQuotePrice;
@ -40,6 +41,13 @@ public interface EmisTmsCostQuotePriceMapper extends BaseMapper<EmisTmsCostQuote
*/
public List<EmisTmsCostQuotePrice> matchBatchFixedQuotePriceByBillCode(@Param("billCode") String bilCode,@Param("feeType") String feeType,@Param("blNeedMatchSupplier") Integer blNeedMatchSupplier);
/**
* 根据批次获取总结算重量
* @param batchNo
* @return
*/
public BigDecimal getTotalSettlementWeightByBatchNo(@Param("batchNo") String batchNo);
/**
* 查询列表
*

View File

@ -602,9 +602,15 @@ public class EmisTmsCostFeeServiceImpl extends EmisBaseService implements IEmisT
}
existsMap.put(uniqKey,1);
// 计算结算重量
BigDecimal transVolume=quotePriceItem.getTotalVolume();
BigDecimal transVolumeWeight=transVolume.multiply(new BigDecimal("333.0"));
BigDecimal transWeight=quotePriceItem.getTransWeight();
if(transVolumeWeight.compareTo(transWeight)>0){
transWeight=transVolumeWeight;
}
// 获取批次结算重量
// BigDecimal totalSettlementWeight=emisTmsCostQuotePriceMapper.getTotalSettlementWeightByBatchNo(quotePriceItem.getBatchNo());
// 计算 机场提货费操作费
EmisTmsCostFeeSplit splitItem = new EmisTmsCostFeeSplit();
@ -618,8 +624,8 @@ public class EmisTmsCostFeeServiceImpl extends EmisBaseService implements IEmisT
splitItem.setBlManual("1"); // 手工计算
splitItem.setCostNo("-1"); // 固定成本
splitItem.setBatchNo(quotePriceItem.getBatchNo());
splitItem.setTransWeight(quotePriceItem.getTransWeight()); // 运输重量
splitItem.setTransVolume(BigDecimal.ZERO); // 运输体积
splitItem.setTransWeight(transWeight); // 运输重量
splitItem.setTransVolume(transVolume); // 运输体积
// 供应商
splitItem.setSupplierCode(quotePriceItem.getSupplierCode()); // 供应商
@ -645,7 +651,7 @@ public class EmisTmsCostFeeServiceImpl extends EmisBaseService implements IEmisT
// 正常计算公式
String calcExprStr = itemCalcExpr.replaceAll("w", waybill.getBillWeight().stripTrailingZeros().toPlainString())
.replaceAll("t", quotePriceItem.getTransWeight().stripTrailingZeros().toPlainString())
.replaceAll("t", transWeight.stripTrailingZeros().toPlainString())
.replaceAll("d", quotePriceItem.getPrice().stripTrailingZeros().toPlainString())
.replaceAll("c", totalDbCostFee.stripTrailingZeros().toPlainString());
@ -655,14 +661,14 @@ public class EmisTmsCostFeeServiceImpl extends EmisBaseService implements IEmisT
totalDbCostFee=quotePriceItem.getLeastPrice(); // 总成本=最低报价
itemCalcExpr="(w/t)*c";
calcExprStr = itemCalcExpr.replaceAll("w", waybill.getBillWeight().stripTrailingZeros().toPlainString())
.replaceAll("t", quotePriceItem.getTransWeight().stripTrailingZeros().toPlainString())
.replaceAll("t", transWeight.stripTrailingZeros().toPlainString())
.replaceAll("c", totalDbCostFee.stripTrailingZeros().toPlainString());
}
Map<String, Object> env = new HashMap<>();
env.put("w", mainWaybill.getBillWeight());
env.put("t", quotePriceItem.getTransWeight());
env.put("t", transWeight);
env.put("d", quotePriceItem.getPrice());
env.put("c", totalDbCostFee);
double costFee = Double.valueOf(AviatorEvaluator.execute(itemCalcExpr,env).toString());
@ -872,6 +878,8 @@ public class EmisTmsCostFeeServiceImpl extends EmisBaseService implements IEmisT
BigDecimal totalWeight = BigDecimal.ZERO;
BigDecimal totalVolume = BigDecimal.ZERO;
// 获取费用列表
List<EmisTmsCostFeeFeeitem> listFeeItemRel=emisTmsCostFeeFeeitemMapper.selectEmisTmsCostFeeFeeitemByCostNo(costNo);
if(CollectionUtil.isEmpty(listFeeItemRel)){
@ -901,6 +909,15 @@ public class EmisTmsCostFeeServiceImpl extends EmisBaseService implements IEmisT
totalVolume=totalVolume.add(emisWaybill.getTotalVolume());
pieceNumber=pieceNumber+emisWaybill.getParcelQty();
}
// 计算结算重量
BigDecimal transVolume=totalVolume;
BigDecimal transVolumeWeight=transVolume.multiply(new BigDecimal("333.0"));
BigDecimal transWeight=totalWeight;
if(transVolumeWeight.compareTo(transWeight)>0){
transWeight=transVolumeWeight;
}
Integer sendPieceSum = listBillCodeRel.size();
// 计算分摊成本
@ -932,11 +949,11 @@ public class EmisTmsCostFeeServiceImpl extends EmisBaseService implements IEmisT
splitItem.setTotalVolume(waybill.getTotalVolume()); // 运单体积
// 运输成本
splitItem.setBlManual("0"); // 手工计算
splitItem.setBlManual("0");
splitItem.setCostNo(billCodeItem.getCostNo()); // 固定成本
splitItem.setBatchNo(oldCostFee.getBatchNo());
splitItem.setTransWeight(costFeeDetail.getRealTotalWeight()); // 运输重量
splitItem.setTransVolume(totalVolume); // 运输体积
splitItem.setTransWeight(transWeight); // 运输重量
splitItem.setTransVolume(transVolume); // 运输体积
// 供应商
splitItem.setSupplierCode(costFeeDetail.getSupplierCode()); // 供应商
@ -969,12 +986,12 @@ public class EmisTmsCostFeeServiceImpl extends EmisBaseService implements IEmisT
if ("1".equals(oldCostFee.getSplitType())) {
itemCalcExpr="(w/t)*c";
calcExprStr=itemCalcExpr.replaceAll("w", waybill.getBillWeight().stripTrailingZeros().toPlainString())
.replaceAll("t", oldCostFee.getRealTotalWeight().stripTrailingZeros().toPlainString())
.replaceAll("t", transWeight.stripTrailingZeros().toPlainString())
.replaceAll("c", totalDbCostFee.stripTrailingZeros().toPlainString());
Map<String, Object> env = new HashMap<>();
env.put("w", waybill.getBillWeight());
env.put("t", oldCostFee.getRealTotalWeight());
env.put("t", transWeight);
env.put("c", totalDbCostFee);
costFee = Double.valueOf(AviatorEvaluator.execute(itemCalcExpr,env).toString());
log.info("按重量分摊:计算公式:" + calcExprStr + ",重量:" + waybill.getBillWeight().stripTrailingZeros().toPlainString());
@ -984,11 +1001,11 @@ public class EmisTmsCostFeeServiceImpl extends EmisBaseService implements IEmisT
else if ("2".equals(oldCostFee.getSplitType())) {
itemCalcExpr="(w/t)*c";
calcExprStr=itemCalcExpr.replaceAll("w", waybill.getTotalVolume().stripTrailingZeros().toPlainString())
.replaceAll("t", oldCostFee.getRealTotalVolume().stripTrailingZeros().toPlainString())
.replaceAll("t", transVolume.stripTrailingZeros().toPlainString())
.replaceAll("c", totalDbCostFee.stripTrailingZeros().toPlainString());
Map<String, Object> env = new HashMap<>();
env.put("w", waybill.getBillWeight());
env.put("t", oldCostFee.getRealTotalVolume());
env.put("t", transVolume);
env.put("c", totalDbCostFee);
costFee = Double.valueOf(AviatorEvaluator.execute(itemCalcExpr,env).toString());
log.info("按体积分摊:计算公式:" + calcExprStr + ",重量:" + waybill.getBillWeight().stripTrailingZeros().toPlainString());

View File

@ -100,7 +100,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
b.car_no,
b.etd,
b.trans_weight,
b.total_weight
b.total_weight,
b.total_volume,
b.total_settlement_weight
FROM
emis_tms_cost_quote_price a,
@ -122,6 +124,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND c.bill_code = #{billCode}
</select>
<select id="getTotalSettlementWeightByBatchNo" parameterType="String" resultType="java.math.BigDecimal">
select sum(settlement_weight) as totalSettlementWeight
from emis_tms_site_batch_dtl a,emis_waybill b
where a.del_flag='0' and b.del_flag='0' and a.bill_code=b.bill_code
and a.batch_no=#{batchNo}
</select>
<select id="checkUnique" parameterType="EmisTmsCostQuotePrice" resultType="int">
select count(1) from emis_tms_cost_quote_price
where del_flag='0'