md
This commit is contained in:
parent
d10a99cbe8
commit
49d091c555
@ -96,5 +96,6 @@ public class EmisTmsCostQuotePrice extends BaseEntity
|
|||||||
private BigDecimal transWeight;
|
private BigDecimal transWeight;
|
||||||
private BigDecimal totalWeight;
|
private BigDecimal totalWeight;
|
||||||
private BigDecimal totalVolume;
|
private BigDecimal totalVolume;
|
||||||
|
private String transType;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
package com.xdadan.erp.emis.service.impl;
|
package com.xdadan.erp.emis.service.impl;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -295,6 +296,8 @@ public class EmisTmsCostFeeServiceImpl extends EmisBaseService implements IEmisT
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算固定成本
|
* 计算固定成本
|
||||||
* @param billCode
|
* @param billCode
|
||||||
@ -602,22 +605,18 @@ public class EmisTmsCostFeeServiceImpl extends EmisBaseService implements IEmisT
|
|||||||
}
|
}
|
||||||
existsMap.put(uniqKey,1);
|
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());
|
BigDecimal transVolume=quotePriceItem.getTotalVolume();
|
||||||
|
BigDecimal totalSettlementWeight=emisTmsCostQuotePriceMapper.getTotalSettlementWeightByBatchNo(quotePriceItem.getBatchNo());
|
||||||
|
BigDecimal transWeight=totalSettlementWeight;
|
||||||
|
|
||||||
// 计算 机场提货费操作费
|
// 计算 机场提货费操作费
|
||||||
EmisTmsCostFeeSplit splitItem = new EmisTmsCostFeeSplit();
|
EmisTmsCostFeeSplit splitItem = new EmisTmsCostFeeSplit();
|
||||||
splitItem.setBillCode(billCode.trim());
|
splitItem.setBillCode(billCode.trim());
|
||||||
|
|
||||||
splitItem.setMainBillCode(mainBillCode.trim());
|
splitItem.setMainBillCode(mainBillCode.trim());
|
||||||
splitItem.setBillWeight(waybill.getBillWeight()); // 运单重量
|
splitItem.setBillWeight(waybill.getSettlementWeight()); // 运单重量
|
||||||
splitItem.setTotalVolume(waybill.getTotalVolume()); // 运单体积
|
splitItem.setTotalVolume(waybill.getTotalVolume()); // 运单体积
|
||||||
|
|
||||||
// 运输成本
|
// 运输成本
|
||||||
@ -642,15 +641,15 @@ public class EmisTmsCostFeeServiceImpl extends EmisBaseService implements IEmisT
|
|||||||
splitItem.setFeeType("1004"); // 网点机场操作费
|
splitItem.setFeeType("1004"); // 网点机场操作费
|
||||||
splitItem.setSplitType("1"); // 按重量分摊
|
splitItem.setSplitType("1"); // 按重量分摊
|
||||||
splitItem.setFeeItemId(-1L); // 无成本费用项来源
|
splitItem.setFeeItemId(-1L); // 无成本费用项来源
|
||||||
splitItem.setSplitValue(waybill.getBillWeight()); // 分摊重量
|
splitItem.setSplitValue(waybill.getSettlementWeight()); // 分摊重量
|
||||||
|
|
||||||
// 总费用=单价*公里数
|
// 总费用=单价*公里数
|
||||||
BigDecimal totalDbCostFee = quotePriceItem.getPrice().multiply(quotePriceItem.getTransWeight());
|
BigDecimal totalDbCostFee = quotePriceItem.getPrice().multiply(transWeight);
|
||||||
|
|
||||||
String itemCalcExpr = quotePriceItem.getCalculateExpression();
|
String itemCalcExpr = quotePriceItem.getCalculateExpression();
|
||||||
|
|
||||||
// 正常计算公式
|
// 正常计算公式
|
||||||
String calcExprStr = itemCalcExpr.replaceAll("w", waybill.getBillWeight().stripTrailingZeros().toPlainString())
|
String calcExprStr = itemCalcExpr.replaceAll("w", waybill.getSettlementWeight().stripTrailingZeros().toPlainString())
|
||||||
.replaceAll("t", transWeight.stripTrailingZeros().toPlainString())
|
.replaceAll("t", transWeight.stripTrailingZeros().toPlainString())
|
||||||
.replaceAll("d", quotePriceItem.getPrice().stripTrailingZeros().toPlainString())
|
.replaceAll("d", quotePriceItem.getPrice().stripTrailingZeros().toPlainString())
|
||||||
.replaceAll("c", totalDbCostFee.stripTrailingZeros().toPlainString());
|
.replaceAll("c", totalDbCostFee.stripTrailingZeros().toPlainString());
|
||||||
@ -660,20 +659,20 @@ public class EmisTmsCostFeeServiceImpl extends EmisBaseService implements IEmisT
|
|||||||
|
|
||||||
totalDbCostFee=quotePriceItem.getLeastPrice(); // 总成本=最低报价
|
totalDbCostFee=quotePriceItem.getLeastPrice(); // 总成本=最低报价
|
||||||
itemCalcExpr="(w/t)*c";
|
itemCalcExpr="(w/t)*c";
|
||||||
calcExprStr = itemCalcExpr.replaceAll("w", waybill.getBillWeight().stripTrailingZeros().toPlainString())
|
calcExprStr = itemCalcExpr.replaceAll("w", mainWaybill.getSettlementWeight().stripTrailingZeros().toPlainString())
|
||||||
.replaceAll("t", transWeight.stripTrailingZeros().toPlainString())
|
.replaceAll("t", transWeight.stripTrailingZeros().toPlainString())
|
||||||
.replaceAll("c", totalDbCostFee.stripTrailingZeros().toPlainString());
|
.replaceAll("c", totalDbCostFee.stripTrailingZeros().toPlainString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Object> env = new HashMap<>();
|
Map<String, Object> env = new HashMap<>();
|
||||||
env.put("w", mainWaybill.getBillWeight());
|
env.put("w", waybill.getSettlementWeight());
|
||||||
env.put("t", transWeight);
|
env.put("t", transWeight);
|
||||||
env.put("d", quotePriceItem.getPrice());
|
env.put("d", quotePriceItem.getPrice());
|
||||||
env.put("c", totalDbCostFee);
|
env.put("c", totalDbCostFee);
|
||||||
double costFee = Double.valueOf(AviatorEvaluator.execute(itemCalcExpr,env).toString());
|
double costFee = Double.valueOf(AviatorEvaluator.execute(itemCalcExpr,env).toString());
|
||||||
|
|
||||||
log.info("机场提货费操作费:计算公式:" + calcExprStr + ",重量:" + waybill.getBillWeight().stripTrailingZeros().toPlainString());
|
log.info("机场提货费操作费:计算公式:" + calcExprStr + ",重量:" + waybill.getSettlementWeight().stripTrailingZeros().toPlainString());
|
||||||
|
|
||||||
// 如果计算出来的成本大于单项收费取成本费用
|
// 如果计算出来的成本大于单项收费取成本费用
|
||||||
if(costFee > totalDbCostFee.doubleValue()){
|
if(costFee > totalDbCostFee.doubleValue()){
|
||||||
@ -877,7 +876,7 @@ public class EmisTmsCostFeeServiceImpl extends EmisBaseService implements IEmisT
|
|||||||
// /* 总票数 总重量 总体积 */
|
// /* 总票数 总重量 总体积 */
|
||||||
BigDecimal totalWeight = BigDecimal.ZERO;
|
BigDecimal totalWeight = BigDecimal.ZERO;
|
||||||
BigDecimal totalVolume = BigDecimal.ZERO;
|
BigDecimal totalVolume = BigDecimal.ZERO;
|
||||||
|
BigDecimal totalSettlementWeight = BigDecimal.ZERO;
|
||||||
|
|
||||||
|
|
||||||
// 获取费用列表
|
// 获取费用列表
|
||||||
@ -907,17 +906,13 @@ public class EmisTmsCostFeeServiceImpl extends EmisBaseService implements IEmisT
|
|||||||
// 累加应收
|
// 累加应收
|
||||||
totalWeight=totalWeight.add(emisWaybill.getBillWeight());
|
totalWeight=totalWeight.add(emisWaybill.getBillWeight());
|
||||||
totalVolume=totalVolume.add(emisWaybill.getTotalVolume());
|
totalVolume=totalVolume.add(emisWaybill.getTotalVolume());
|
||||||
|
totalSettlementWeight=totalSettlementWeight.add(emisWaybill.getSettlementWeight());
|
||||||
pieceNumber=pieceNumber+emisWaybill.getParcelQty();
|
pieceNumber=pieceNumber+emisWaybill.getParcelQty();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算结算重量
|
// 计算结算重量
|
||||||
BigDecimal transVolume=totalVolume;
|
BigDecimal transVolume=totalVolume;
|
||||||
BigDecimal transVolumeWeight=transVolume.multiply(new BigDecimal("333.0"));
|
BigDecimal transWeight=totalSettlementWeight;
|
||||||
BigDecimal transWeight=totalWeight;
|
|
||||||
if(transVolumeWeight.compareTo(transWeight)>0){
|
|
||||||
transWeight=transVolumeWeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer sendPieceSum = listBillCodeRel.size();
|
Integer sendPieceSum = listBillCodeRel.size();
|
||||||
|
|
||||||
// 计算分摊成本
|
// 计算分摊成本
|
||||||
@ -945,7 +940,7 @@ public class EmisTmsCostFeeServiceImpl extends EmisBaseService implements IEmisT
|
|||||||
|
|
||||||
splitItem.setBillCode(billCode.trim());
|
splitItem.setBillCode(billCode.trim());
|
||||||
splitItem.setMainBillCode(mainBillCode.trim());
|
splitItem.setMainBillCode(mainBillCode.trim());
|
||||||
splitItem.setBillWeight(waybill.getBillWeight()); // 运单重量
|
splitItem.setBillWeight(waybill.getSettlementWeight()); // 运单重量
|
||||||
splitItem.setTotalVolume(waybill.getTotalVolume()); // 运单体积
|
splitItem.setTotalVolume(waybill.getTotalVolume()); // 运单体积
|
||||||
|
|
||||||
// 运输成本
|
// 运输成本
|
||||||
@ -968,7 +963,7 @@ public class EmisTmsCostFeeServiceImpl extends EmisBaseService implements IEmisT
|
|||||||
splitItem.setFeeType(feeItem.getFeeType()); // 费用类型
|
splitItem.setFeeType(feeItem.getFeeType()); // 费用类型
|
||||||
splitItem.setSplitType(oldCostFee.getSplitType()); // 按重量分摊
|
splitItem.setSplitType(oldCostFee.getSplitType()); // 按重量分摊
|
||||||
splitItem.setFeeItemId(feeItem.getId()); // 无成本费用项来源
|
splitItem.setFeeItemId(feeItem.getId()); // 无成本费用项来源
|
||||||
splitItem.setSplitValue(waybill.getBillWeight());
|
splitItem.setSplitValue(waybill.getSettlementWeight());
|
||||||
splitItem.setPrice(feeItem.getPrice());
|
splitItem.setPrice(feeItem.getPrice());
|
||||||
splitItem.setCurrency(feeItem.getCurrency());
|
splitItem.setCurrency(feeItem.getCurrency());
|
||||||
splitItem.setCurrecyToCnyRate(feeItem.getCurrecyToCnyRate());
|
splitItem.setCurrecyToCnyRate(feeItem.getCurrecyToCnyRate());
|
||||||
@ -985,16 +980,16 @@ public class EmisTmsCostFeeServiceImpl extends EmisBaseService implements IEmisT
|
|||||||
// 按重量分摊
|
// 按重量分摊
|
||||||
if ("1".equals(oldCostFee.getSplitType())) {
|
if ("1".equals(oldCostFee.getSplitType())) {
|
||||||
itemCalcExpr="(w/t)*c";
|
itemCalcExpr="(w/t)*c";
|
||||||
calcExprStr=itemCalcExpr.replaceAll("w", waybill.getBillWeight().stripTrailingZeros().toPlainString())
|
calcExprStr=itemCalcExpr.replaceAll("w", waybill.getSettlementWeight().stripTrailingZeros().toPlainString())
|
||||||
.replaceAll("t", transWeight.stripTrailingZeros().toPlainString())
|
.replaceAll("t", transWeight.stripTrailingZeros().toPlainString())
|
||||||
.replaceAll("c", totalDbCostFee.stripTrailingZeros().toPlainString());
|
.replaceAll("c", totalDbCostFee.stripTrailingZeros().toPlainString());
|
||||||
|
|
||||||
Map<String, Object> env = new HashMap<>();
|
Map<String, Object> env = new HashMap<>();
|
||||||
env.put("w", waybill.getBillWeight());
|
env.put("w", waybill.getSettlementWeight());
|
||||||
env.put("t", transWeight);
|
env.put("t", transWeight);
|
||||||
env.put("c", totalDbCostFee);
|
env.put("c", totalDbCostFee);
|
||||||
costFee = Double.valueOf(AviatorEvaluator.execute(itemCalcExpr,env).toString());
|
costFee = Double.valueOf(AviatorEvaluator.execute(itemCalcExpr,env).toString());
|
||||||
log.info("按重量分摊:计算公式:" + calcExprStr + ",重量:" + waybill.getBillWeight().stripTrailingZeros().toPlainString());
|
log.info("按重量分摊:计算公式:" + calcExprStr + ",重量:" + waybill.getSettlementWeight().stripTrailingZeros().toPlainString());
|
||||||
|
|
||||||
}
|
}
|
||||||
// 按体积
|
// 按体积
|
||||||
@ -1004,7 +999,7 @@ public class EmisTmsCostFeeServiceImpl extends EmisBaseService implements IEmisT
|
|||||||
.replaceAll("t", transVolume.stripTrailingZeros().toPlainString())
|
.replaceAll("t", transVolume.stripTrailingZeros().toPlainString())
|
||||||
.replaceAll("c", totalDbCostFee.stripTrailingZeros().toPlainString());
|
.replaceAll("c", totalDbCostFee.stripTrailingZeros().toPlainString());
|
||||||
Map<String, Object> env = new HashMap<>();
|
Map<String, Object> env = new HashMap<>();
|
||||||
env.put("w", waybill.getBillWeight());
|
env.put("w", waybill.getSettlementWeight());
|
||||||
env.put("t", transVolume);
|
env.put("t", transVolume);
|
||||||
env.put("c", totalDbCostFee);
|
env.put("c", totalDbCostFee);
|
||||||
costFee = Double.valueOf(AviatorEvaluator.execute(itemCalcExpr,env).toString());
|
costFee = Double.valueOf(AviatorEvaluator.execute(itemCalcExpr,env).toString());
|
||||||
|
|||||||
@ -407,6 +407,44 @@ public class WaybillHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 体积重量计算
|
||||||
|
* @param totalVolume
|
||||||
|
* @param transType
|
||||||
|
* 快递 -1 5000
|
||||||
|
* 空运 -2 6000
|
||||||
|
* 陆运 -3 3333
|
||||||
|
* 海运 -4 3333
|
||||||
|
* 铁路 -5 4000
|
||||||
|
* 同行 -6 5000
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static BigDecimal calcVolumeWeight(BigDecimal totalVolume,String transType){
|
||||||
|
// 特殊计泡处理
|
||||||
|
// 6000 167
|
||||||
|
// 3333 300
|
||||||
|
|
||||||
|
BigDecimal volumeWeight=BigDecimal.ZERO;
|
||||||
|
// 快递、同行
|
||||||
|
if("1".equals(transType)||"6".equals(transType)){
|
||||||
|
double mRate=1000000.0 / Double.valueOf("5000");
|
||||||
|
volumeWeight=totalVolume.multiply(BigDecimal.valueOf(mRate));
|
||||||
|
}
|
||||||
|
// 空运 6000
|
||||||
|
else if("2".equals(transType)){
|
||||||
|
volumeWeight=totalVolume.multiply(BigDecimal.valueOf(167.0f));
|
||||||
|
}
|
||||||
|
// 陆运、海运 3333
|
||||||
|
else if("3".equals(transType)||"4".equals(transType)){
|
||||||
|
volumeWeight=totalVolume.multiply(BigDecimal.valueOf(300.0f));
|
||||||
|
}
|
||||||
|
// 铁路 4000
|
||||||
|
else if("5".equals(transType)){
|
||||||
|
double mRate=1000000.0 / Double.valueOf("4000");
|
||||||
|
volumeWeight=totalVolume.multiply(BigDecimal.valueOf(mRate));
|
||||||
|
}
|
||||||
|
return volumeWeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|||||||
@ -34,6 +34,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="transWeight" column="trans_weight" />
|
<result property="transWeight" column="trans_weight" />
|
||||||
<result property="totalVolume" column="total_volume" />
|
<result property="totalVolume" column="total_volume" />
|
||||||
<result property="totalWeight" column="total_weight" />
|
<result property="totalWeight" column="total_weight" />
|
||||||
|
<result property="transType" column="trans_type" />
|
||||||
|
|
||||||
<association property="startSiteName" column="start_site_code" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectSiteNameByCode"/>
|
<association property="startSiteName" column="start_site_code" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectSiteNameByCode"/>
|
||||||
<association property="nextSiteName" column="next_site_code" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectSiteNameByCode"/>
|
<association property="nextSiteName" column="next_site_code" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectSiteNameByCode"/>
|
||||||
@ -102,6 +103,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
b.trans_weight,
|
b.trans_weight,
|
||||||
b.total_weight,
|
b.total_weight,
|
||||||
b.total_volume,
|
b.total_volume,
|
||||||
|
b.trans_type,
|
||||||
b.total_settlement_weight
|
b.total_settlement_weight
|
||||||
|
|
||||||
FROM
|
FROM
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user