md
This commit is contained in:
parent
aea06188e6
commit
66d6ae20af
@ -32,11 +32,13 @@ public interface EmisTmsCostQuotePriceMapper extends BaseMapper<EmisTmsCostQuote
|
||||
|
||||
|
||||
/**
|
||||
* 匹配运单号对应的短驳费报价
|
||||
* @param bilCode
|
||||
* 匹配运单号对应批次固定费用报价
|
||||
* @param bilCode 运单号
|
||||
* @param feeType 费用类型
|
||||
* @param blNeedMatchSupplier T-需要匹配对应的供应商
|
||||
* @return
|
||||
*/
|
||||
public List<EmisTmsCostQuotePrice> matchTmsCostQuotePriceListByBillCode(@Param("billCode") String bilCode);
|
||||
public List<EmisTmsCostQuotePrice> matchBatchFixedQuotePriceByBillCode(@Param("billCode") String bilCode,@Param("feeType") String feeType,@Param("blNeedMatchSupplier") String blNeedMatchSupplier);
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
|
||||
@ -13,9 +13,7 @@ package com.xdadan.erp.emis.service.impl;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.ParseException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@ -277,7 +275,9 @@ public class EmisTmsCostFeeServiceImpl implements IEmisTmsCostFeeService
|
||||
double costFee = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString());
|
||||
log.info("网点取件费:计算公式:" + calcExprStr + ",重量:" + waybill.getBillWeight().stripTrailingZeros().toPlainString());
|
||||
|
||||
BigDecimal splitCostFee = BigDecimal.valueOf(costFee).setScale(2,BigDecimal.ROUND_HALF_UP);
|
||||
// 取件费按进1获取
|
||||
costFee=WaybillHelper.calcSettledFee(costFee,"5");
|
||||
BigDecimal splitCostFee = BigDecimal.valueOf(costFee).setScale(0,BigDecimal.ROUND_HALF_UP);
|
||||
splitItem.setCostFee(splitCostFee);
|
||||
splitItem.setCurrency("CNY");
|
||||
splitItem.setCalcExpr(itemCalcExpr);
|
||||
@ -349,6 +349,8 @@ public class EmisTmsCostFeeServiceImpl implements IEmisTmsCostFeeService
|
||||
double costFee = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString());
|
||||
log.info("网点派送费:计算公式:" + calcExprStr + ",重量:" + waybill.getBillWeight().stripTrailingZeros().toPlainString());
|
||||
|
||||
costFee=WaybillHelper.calcSettledFee(costFee,"5");
|
||||
|
||||
BigDecimal splitCostFee = BigDecimal.valueOf(costFee).setScale(2,BigDecimal.ROUND_HALF_UP);
|
||||
splitItem.setCostFee(splitCostFee);
|
||||
splitItem.setCurrency("CNY");
|
||||
@ -365,72 +367,178 @@ public class EmisTmsCostFeeServiceImpl implements IEmisTmsCostFeeService
|
||||
emisTmsCostFeeSplitMapper.insertEmisTmsCostFeeSplit(splitItem);
|
||||
}
|
||||
|
||||
// 网点机场短驳费
|
||||
// 网点机场短驳费 - 1002
|
||||
// (2)新创建表(短驳费):机场到网点之间的距离表;记录 起始网点、下一网点、开始日期、结束日期、公里数、单价、供应商、计费类型:按公斤
|
||||
// 从起始网点获取第一段批次
|
||||
// 根据单号和起始网点和短驳费用表找到是否有短驳费,获取短驳费单价
|
||||
List<EmisTmsCostQuotePrice> quotePriceList=emisTmsCostQuotePriceMapper.matchTmsCostQuotePriceListByBillCode(billCode);
|
||||
if(!CollectionUtils.isEmpty(quotePriceList)){
|
||||
EmisTmsCostQuotePrice quotePrice0=quotePriceList.get(0);
|
||||
List<EmisTmsCostQuotePrice> fixedQuotePrice1002List=emisTmsCostQuotePriceMapper.matchBatchFixedQuotePriceByBillCode(billCode,"1002","T");
|
||||
if(!CollectionUtils.isEmpty(fixedQuotePrice1002List)){
|
||||
|
||||
EmisTmsCostFeeSplit splitItem = new EmisTmsCostFeeSplit();
|
||||
// 检查重复
|
||||
Map existsMap = new HashMap();
|
||||
for (EmisTmsCostQuotePrice quotePriceItem : fixedQuotePrice1002List) {
|
||||
|
||||
splitItem.setBillCode(billCode);
|
||||
splitItem.setMainBillCode(billCode);
|
||||
splitItem.setBillWeight(waybill.getBillWeight()); // 运单重量
|
||||
splitItem.setTotalVolume(waybill.getTotalVolume()); // 运单体积
|
||||
// 如果网点重复就忽略
|
||||
String uniqKey = quotePriceItem.getStartSiteCode() + "-"+quotePriceItem.getNextSiteCode();
|
||||
if(existsMap.containsKey(uniqKey)){
|
||||
continue;
|
||||
}
|
||||
existsMap.put(uniqKey,1);
|
||||
|
||||
// 运输成本
|
||||
splitItem.setBlManual("1"); // 手工计算
|
||||
splitItem.setCostNo("-1"); // 固定成本
|
||||
splitItem.setBatchNo(quotePrice0.getBatchNo());
|
||||
splitItem.setTransWeight(quotePrice0.getTransWeight()); // 运输重量
|
||||
splitItem.setTransVolume(BigDecimal.ZERO); // 运输体积
|
||||
EmisTmsCostFeeSplit splitItem = new EmisTmsCostFeeSplit();
|
||||
|
||||
// 供应商
|
||||
splitItem.setSupplierCode(quotePrice0.getSupplierCode()); // 供应商
|
||||
splitItem.setTransSignNo(quotePrice0.getCarNo()); // 运输号
|
||||
splitItem.setBillCode(billCode);
|
||||
splitItem.setMainBillCode(billCode);
|
||||
splitItem.setBillWeight(waybill.getBillWeight()); // 运单重量
|
||||
splitItem.setTotalVolume(waybill.getTotalVolume()); // 运单体积
|
||||
|
||||
// 起点到目的点
|
||||
splitItem.setSendPlace(quotePrice0.getStartSiteName());
|
||||
splitItem.setDestPlace(quotePrice0.getNextSiteName());
|
||||
// 运输成本
|
||||
splitItem.setBlManual("1"); // 手工计算
|
||||
splitItem.setCostNo("-1"); // 固定成本
|
||||
splitItem.setBatchNo(quotePriceItem.getBatchNo());
|
||||
splitItem.setTransWeight(quotePriceItem.getTransWeight()); // 运输重量
|
||||
splitItem.setTransVolume(BigDecimal.ZERO); // 运输体积
|
||||
|
||||
splitItem.setBillMonth(DateUtils.parseDateToStr(DateUtils.YYYY_MM,waybill.getSendDate()));
|
||||
splitItem.setTradeDate(waybill.getSignDate());
|
||||
// 供应商
|
||||
splitItem.setSupplierCode(quotePriceItem.getSupplierCode()); // 供应商
|
||||
splitItem.setTransSignNo(quotePriceItem.getCarNo()); // 运输号
|
||||
|
||||
// 成本分摊
|
||||
splitItem.setFeeType("1002"); // 网点机场短驳费
|
||||
splitItem.setSplitType("1"); // 按重量分摊
|
||||
splitItem.setFeeItemId(-1L); // 无成本费用项来源
|
||||
splitItem.setSplitValue(waybill.getBillWeight()); // 分摊重量
|
||||
// 起点到目的点
|
||||
splitItem.setSendPlace(quotePriceItem.getStartSiteName());
|
||||
splitItem.setDestPlace(quotePriceItem.getNextSiteName());
|
||||
|
||||
// 计算公式 首重1Kg 10元,续重1kg 1元
|
||||
// 总费用=单价*公里数
|
||||
BigDecimal totalDbCostFee = quotePrice0.getPrice().multiply(quotePrice0.getDistance());
|
||||
// 按总重量分摊
|
||||
splitItem.setBillMonth(DateUtils.parseDateToStr(DateUtils.YYYY_MM, waybill.getSendDate()));
|
||||
splitItem.setTradeDate(waybill.getSignDate());
|
||||
|
||||
String itemCalcExpr = "(w/t)*c";
|
||||
String calcExprStr=itemCalcExpr.replaceAll("w", waybill.getBillWeight().stripTrailingZeros().toPlainString())
|
||||
.replaceAll("t", quotePrice0.getTransWeight().stripTrailingZeros().toPlainString())
|
||||
.replaceAll("c", totalDbCostFee.stripTrailingZeros().toPlainString());
|
||||
// 成本分摊
|
||||
splitItem.setFeeType("1002"); // 网点机场短驳费
|
||||
splitItem.setSplitType("1"); // 按重量分摊
|
||||
splitItem.setFeeItemId(-1L); // 无成本费用项来源
|
||||
splitItem.setSplitValue(waybill.getBillWeight()); // 分摊重量
|
||||
|
||||
double costFee = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString());
|
||||
// 计算公式 首重1Kg 10元,续重1kg 1元
|
||||
// 总费用=单价*公里数
|
||||
BigDecimal totalDbCostFee = quotePriceItem.getPrice().multiply(quotePriceItem.getDistance());
|
||||
// 按总重量分摊
|
||||
|
||||
log.info("网点机场短驳费:计算公式:" + calcExprStr + ",重量:" + waybill.getBillWeight().stripTrailingZeros().toPlainString());
|
||||
String itemCalcExpr = quotePriceItem.getCalculateExpression();
|
||||
String calcExprStr = itemCalcExpr.replaceAll("w", waybill.getBillWeight().stripTrailingZeros().toPlainString())
|
||||
.replaceAll("t", quotePriceItem.getTransWeight().stripTrailingZeros().toPlainString())
|
||||
.replaceAll("c", totalDbCostFee.stripTrailingZeros().toPlainString());
|
||||
|
||||
BigDecimal splitCostFee = BigDecimal.valueOf(costFee).setScale(2,BigDecimal.ROUND_HALF_UP);
|
||||
splitItem.setCostFee(splitCostFee);
|
||||
splitItem.setCurrency("CNY");
|
||||
splitItem.setCalcExpr(itemCalcExpr);
|
||||
splitItem.setCalcRemark(calcExprStr+"="+splitCostFee.stripTrailingZeros().toPlainString());
|
||||
splitItem.setRemark("网点机场短驳费");
|
||||
double costFee = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString());
|
||||
|
||||
// 总成本费用
|
||||
splitItem.setTransCostFee(totalDbCostFee);
|
||||
splitItem.setCnyFee(totalDbCostFee);
|
||||
log.info("网点机场短驳费:计算公式:" + calcExprStr + ",重量:" + waybill.getBillWeight().stripTrailingZeros().toPlainString());
|
||||
|
||||
// 插入分摊明细数据
|
||||
emisTmsCostFeeSplitMapper.insertEmisTmsCostFeeSplit(splitItem);
|
||||
costFee = WaybillHelper.calcSettledFee(costFee, quotePriceItem.getPriceType());
|
||||
|
||||
BigDecimal splitCostFee = BigDecimal.valueOf(costFee);
|
||||
splitItem.setCostFee(splitCostFee);
|
||||
splitItem.setCurrency("CNY");
|
||||
splitItem.setCalcExpr(itemCalcExpr);
|
||||
splitItem.setCalcRemark(calcExprStr + "=" + splitCostFee.stripTrailingZeros().toPlainString());
|
||||
splitItem.setRemark("网点机场短驳费");
|
||||
|
||||
// 总成本费用
|
||||
splitItem.setTransCostFee(totalDbCostFee);
|
||||
splitItem.setCnyFee(totalDbCostFee);
|
||||
|
||||
// 插入分摊明细数据
|
||||
emisTmsCostFeeSplitMapper.insertEmisTmsCostFeeSplit(splitItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 机场提货费操作费 - 1004
|
||||
List<EmisTmsCostQuotePrice> fixedQuotePrice1004List=emisTmsCostQuotePriceMapper.matchBatchFixedQuotePriceByBillCode(billCode,"1004","T");
|
||||
if(!CollectionUtils.isEmpty(fixedQuotePrice1004List)){
|
||||
|
||||
// 检查重复
|
||||
Map existsMap = new HashMap();
|
||||
for (EmisTmsCostQuotePrice quotePriceItem : fixedQuotePrice1004List) {
|
||||
|
||||
// 如果网点重复就忽略
|
||||
String uniqKey = quotePriceItem.getStartSiteCode() + "-"+quotePriceItem.getNextSiteCode();
|
||||
if(existsMap.containsKey(uniqKey)){
|
||||
continue;
|
||||
}
|
||||
existsMap.put(uniqKey,1);
|
||||
|
||||
// 计算 机场提货费操作费
|
||||
EmisTmsCostFeeSplit splitItem = new EmisTmsCostFeeSplit();
|
||||
splitItem.setBillCode(billCode);
|
||||
splitItem.setMainBillCode(billCode);
|
||||
splitItem.setBillWeight(waybill.getBillWeight()); // 运单重量
|
||||
splitItem.setTotalVolume(waybill.getTotalVolume()); // 运单体积
|
||||
|
||||
// 运输成本
|
||||
splitItem.setBlManual("1"); // 手工计算
|
||||
splitItem.setCostNo("-1"); // 固定成本
|
||||
splitItem.setBatchNo(quotePriceItem.getBatchNo());
|
||||
splitItem.setTransWeight(quotePriceItem.getTransWeight()); // 运输重量
|
||||
splitItem.setTransVolume(BigDecimal.ZERO); // 运输体积
|
||||
|
||||
// 供应商
|
||||
splitItem.setSupplierCode(quotePriceItem.getSupplierCode()); // 供应商
|
||||
splitItem.setTransSignNo(quotePriceItem.getCarNo()); // 运输号
|
||||
|
||||
// 起点到目的点
|
||||
splitItem.setSendPlace(quotePriceItem.getStartSiteName());
|
||||
splitItem.setDestPlace(quotePriceItem.getNextSiteName());
|
||||
|
||||
splitItem.setBillMonth(DateUtils.parseDateToStr(DateUtils.YYYY_MM, waybill.getSendDate()));
|
||||
splitItem.setTradeDate(waybill.getSignDate());
|
||||
|
||||
// 成本分摊
|
||||
splitItem.setFeeType("1004"); // 网点机场操作费
|
||||
splitItem.setSplitType("1"); // 按重量分摊
|
||||
splitItem.setFeeItemId(-1L); // 无成本费用项来源
|
||||
splitItem.setSplitValue(waybill.getBillWeight()); // 分摊重量
|
||||
|
||||
// 总费用=单价*公里数
|
||||
BigDecimal totalDbCostFee = quotePriceItem.getPrice().multiply(quotePriceItem.getDistance());
|
||||
|
||||
String itemCalcExpr = quotePriceItem.getCalculateExpression();
|
||||
|
||||
// 正常计算公司
|
||||
String calcExprStr = itemCalcExpr.replaceAll("w", waybill.getBillWeight().stripTrailingZeros().toPlainString())
|
||||
.replaceAll("t", quotePriceItem.getTransWeight().stripTrailingZeros().toPlainString())
|
||||
.replaceAll("d", quotePriceItem.getPrice().stripTrailingZeros().toPlainString())
|
||||
.replaceAll("c", totalDbCostFee.stripTrailingZeros().toPlainString());
|
||||
|
||||
// 计算单次成本: 如果低于最低报价,则使用最低成本来分摊
|
||||
BigDecimal totalCost =quotePriceItem.getTransWeight().multiply(quotePriceItem.getPrice());
|
||||
if(totalCost.compareTo(quotePriceItem.getLeastPrice())<0){
|
||||
|
||||
totalDbCostFee=quotePriceItem.getLeastPrice(); // 总成本=最低报价
|
||||
|
||||
itemCalcExpr="(w/t)*c";
|
||||
calcExprStr = itemCalcExpr.replaceAll("w", waybill.getBillWeight().stripTrailingZeros().toPlainString())
|
||||
.replaceAll("t", quotePriceItem.getTransWeight().stripTrailingZeros().toPlainString())
|
||||
.replaceAll("c", totalDbCostFee.stripTrailingZeros().toPlainString());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
double costFee = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString());
|
||||
|
||||
log.info("机场提货费操作费:计算公式:" + calcExprStr + ",重量:" + waybill.getBillWeight().stripTrailingZeros().toPlainString());
|
||||
|
||||
costFee = WaybillHelper.calcSettledFee(costFee, quotePriceItem.getPriceType());
|
||||
|
||||
BigDecimal splitCostFee = BigDecimal.valueOf(costFee);
|
||||
splitItem.setCostFee(splitCostFee);
|
||||
splitItem.setCurrency("CNY");
|
||||
splitItem.setCalcExpr(itemCalcExpr);
|
||||
splitItem.setCalcRemark(calcExprStr + "=" + splitCostFee.stripTrailingZeros().toPlainString());
|
||||
splitItem.setRemark("机场提货费操作费");
|
||||
|
||||
// 总成本费用
|
||||
splitItem.setTransCostFee(totalDbCostFee);
|
||||
splitItem.setCnyFee(totalDbCostFee);
|
||||
|
||||
// 插入分摊明细数据
|
||||
emisTmsCostFeeSplitMapper.insertEmisTmsCostFeeSplit(splitItem);
|
||||
}
|
||||
}
|
||||
|
||||
// 搜索已录入成本的费用分摊
|
||||
@ -444,6 +552,8 @@ public class EmisTmsCostFeeServiceImpl implements IEmisTmsCostFeeService
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mergeCostFeeByBillCode(billCode);
|
||||
|
||||
return 1;
|
||||
@ -956,4 +1066,12 @@ public class EmisTmsCostFeeServiceImpl implements IEmisTmsCostFeeService
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
double costFee=WaybillHelper.calcSettledFee(0.001,"5");
|
||||
// BigDecimal splitCostFee = BigDecimal.valueOf(costFee).setScale(0,BigDecimal.ROUND_HALF_UP);
|
||||
System.out.println(costFee);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -27,7 +27,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="endDate" column="end_date" />
|
||||
<result property="blOpen" column="bl_open" />
|
||||
|
||||
|
||||
<result property="batchNo" column="batch_no" />
|
||||
<result property="carNo" column="car_no" />
|
||||
<result property="etd" column="etd" />
|
||||
@ -74,7 +73,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</select>
|
||||
|
||||
|
||||
<select id="matchTmsCostQuotePriceListByBillCode" parameterType="String" resultMap="EmisTmsCostQuotePriceResult">
|
||||
<select id="matchBatchFixedQuotePriceByBillCode" parameterType="String" resultMap="EmisTmsCostQuotePriceResult">
|
||||
SELECT
|
||||
DISTINCT
|
||||
a.start_site_code,
|
||||
@ -108,54 +107,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
AND c.del_flag = '0'
|
||||
AND a.start_site_code = b.start_site_code
|
||||
AND a.next_site_code = b.next_site_code
|
||||
AND a.supplier_code = b.supplier_code
|
||||
<if test="blNeedMatchSupplier != null and blNeedMatchSupplier == 'T'">
|
||||
AND a.supplier_code = b.supplier_code
|
||||
</if>
|
||||
AND b.batch_no = c.batch_no
|
||||
and a.start_date <![CDATA[ <= ]]> b.etd and b.etd <![CDATA[ < ]]> a.end_date
|
||||
and a.fee_type = #{feeType}
|
||||
AND c.bill_code = #{billCode}
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="matchCostQuotePriceByBillAndSite" parameterType="String" resultMap="EmisTmsCostQuotePriceResult">
|
||||
SELECT
|
||||
DISTINCT
|
||||
a.start_site_code,
|
||||
a.next_site_code,
|
||||
a.distance,
|
||||
a.least_price,
|
||||
a.price_type,
|
||||
a.fee,
|
||||
a.price,
|
||||
a.fee_type,
|
||||
a.currency,
|
||||
a.bill_type,
|
||||
a.supplier_code,
|
||||
a.start_date,
|
||||
a.end_date,
|
||||
a.calculate_expression,
|
||||
|
||||
b.batch_no,
|
||||
b.car_no,
|
||||
b.etd,
|
||||
b.trans_weight,
|
||||
b.total_weight
|
||||
|
||||
FROM
|
||||
emis_tms_cost_quote_price a,
|
||||
emis_tms_site_batch b,
|
||||
emis_tms_site_batch_dtl c
|
||||
WHERE
|
||||
a.del_flag = '0'
|
||||
AND b.del_flag = '0'
|
||||
AND c.del_flag = '0'
|
||||
AND a.start_site_code = b.start_site_code
|
||||
AND a.next_site_code = b.next_site_code
|
||||
AND b.batch_no = c.batch_no
|
||||
and a.start_date <![CDATA[ <= ]]> b.etd and b.etd <![CDATA[ < ]]> a.end_date
|
||||
AND c.bill_code = #{billCode}
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
|
||||
<select id="checkUnique" parameterType="EmisTmsCostQuotePrice" resultType="int">
|
||||
select count(1) from emis_tms_cost_quote_price
|
||||
where del_flag='0'
|
||||
|
||||
Loading…
Reference in New Issue
Block a user