Merge branch 'master' of http://git.xdadan.loc/tanex/emis-service into develop

This commit is contained in:
aike 2025-07-02 13:50:14 +08:00
commit 39800dac0c
9 changed files with 411 additions and 118 deletions

View File

@ -72,7 +72,7 @@ public class EmisTransLineController extends EmisBaseController
* 查询线路列表 -- 精简
*/
// @PreAuthorize("@ss.hasPermi('emis:emisTransLine:list')")
@JacksonFilter(include= {"id","lineCode","lineName","lineNameEn","meterRate","transType"},value= EmisTransLine.class,type= JacksonFilter.JscksonFilterType.RESPONSE)
@JacksonFilter(include= {"id","lineCode","lineName","lineNameEn","meterRate","transType","status"},value= EmisTransLine.class,type= JacksonFilter.JscksonFilterType.RESPONSE)
@GetMapping("/listSimple")
public TableDataInfo listSimple(EmisTransLine emisTransLine)
{
@ -86,6 +86,29 @@ public class EmisTransLineController extends EmisBaseController
startPage();
List<EmisTransLine> list = emisTransLineService.selectEmisTransLineList(emisTransLine);
return getDataTable(list);
}
/**
* 全部线路-包含停用
* @param emisTransLine
* @return
*/
@JacksonFilter(include= {"id","lineCode","lineName","lineNameEn","meterRate","transType","status"},value= EmisTransLine.class,type= JacksonFilter.JscksonFilterType.RESPONSE)
@GetMapping("/listSimpleAll")
public TableDataInfo listSimpleAll(EmisTransLine emisTransLine)
{
// 总部不限制
if(!(getLoginUser().getUser().isTopSite())){
EmisSite site=emisBaseService.getSiteByCode(getLoginUser().getUser().getOwnerSiteCode());
emisTransLine.setLogoType(site.getLogoType());
emisTransLine.getParams().put("needFilterLogoTyoe","1");
}
startPage();
List<EmisTransLine> list = emisTransLineService.selectEmisTransLineList(emisTransLine);
return getDataTable(list);

View File

@ -43,10 +43,28 @@ public class EmisTmsCostQuotePrice extends BaseEntity
private BigDecimal distance;
/* 费用类型 运输费 */
private String feeType;
/* 固定总费用 */
private BigDecimal fee;
/* 最低价格 */
private BigDecimal leastPrice;
/* 价格取值 */
private String priceType;
/* 计费单价 */
private BigDecimal price;
/* 费用币种 */
private String currency;
/* 起始重量 */
private Double startWeight;
/* 结束重量 */
private Double endWeight;
/* 首重 */
private Double initialWeight;
/* 续重 */
private Double additionalWeight;
/* 条件表达式 */
private String conditionExpression;
/* 计算表达式 */
private String calculateExpression;
/* 计费类型 1-重量计费 2-体积计费 */
private String billType;
/* 供应商代码 */
@ -57,7 +75,8 @@ public class EmisTmsCostQuotePrice extends BaseEntity
/* 结束日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
private Date endDate;
/* 启用状态 1-启用 0-停用 */
private String blOpen;
// 扩展字段 ------
/** 起始网点名称 */

View File

@ -84,6 +84,8 @@ public interface EmisTmsCostFeeSplitMapper extends BaseMapper<EmisTmsCostFeeSpli
public int deleteByCostNoAndBillCode(@Param("costNo") String costNo,@Param("billCode") String billCode);
public int deleteByBillCodeAndFeeType(@Param("billCode") String billCode,@Param("feeType") String feeType);
public int deleteEmisTmsCostFeeSplitByBillCode(String BillCode);
/**

View File

@ -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") Integer blNeedMatchSupplier);
/**
* 查询列表

View File

@ -470,7 +470,16 @@ public class EmisSettleInvoiceChRecordServiceImpl extends EmisBaseService implem
order.setDetailInfos(goodsList);
JSONObject jRst =HXSdk.asyncOpenBillReceive(order,emisBaseInvoiceChInfo.getToken());
JSONObject jRst = null;
try {
jRst = HXSdk.asyncOpenBillReceive(order, emisBaseInvoiceChInfo.getToken());
}catch(Exception ex){
ex.printStackTrace();
throw new EmisBizError(EmisBizErrorType.FAIL,"航信税金系统出错,请联系航信人员");
}
// 如果token失效则重新获取token再触发一次
/*
"code": "B0301",

View File

@ -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;
@ -228,56 +226,74 @@ public class EmisTmsCostFeeServiceImpl implements IEmisTmsCostFeeService
@Transactional
public int reCalcCostFeeByBillCode(String billCode) throws EmisBizError {
// 根据运单号删除该运单计算的费用
emisTmsCostFeeSplitMapper.deleteEmisTmsCostFeeSplitByBillCode(billCode);
// 计算固定成本费用-取件费
EmisWaybill waybill=emisWaybillMapper.selectEmisWaybillByBillCode(billCode);
if(waybill==null){
throw new EmisBizError(EmisBizErrorType.FAIL,"运单不存在");
}
// 根据运单号删除该运单计算的费用
emisTmsCostFeeSplitMapper.deleteEmisTmsCostFeeSplitByBillCode(billCode);
// 虚拟单取主单
EmisWaybill mainWaybill=null;
String mainBillCode = billCode;
if( "1".equals(waybill.getBlVirtual()) ){
mainBillCode=waybill.getMasterBillCode();
mainWaybill=emisWaybillMapper.selectEmisWaybillByBillCode(mainBillCode);
}else{
mainWaybill=waybill;
}
// bug:1682 (1)快递类型的货(取件费):寄件国家:中国,取件方式:上门取件,取件成本:首重1Kg 10元,续重1kg 1元
// 只有主单才会计算取件费
if("2".equals(waybill.getPickupMethod())
&& !"1".equals(waybill.getBlVirtual())
&& "0086".equals(waybill.getSendCountry()) ){
if("2".equals(mainWaybill.getPickupMethod())
&& !"1".equals(mainWaybill.getBlVirtual())
&& "0086".equals(mainWaybill.getSendCountry()) ){
EmisTmsCostFeeSplit splitItem = new EmisTmsCostFeeSplit();
splitItem.setBillCode(billCode);
splitItem.setMainBillCode(billCode);
splitItem.setBillWeight(waybill.getBillWeight()); // 运单重量
splitItem.setTotalVolume(waybill.getTotalVolume()); // 运单体积
splitItem.setMainBillCode(mainBillCode);
splitItem.setBillWeight(mainWaybill.getBillWeight()); // 运单重量
splitItem.setTotalVolume(mainWaybill.getTotalVolume()); // 运单体积
// 运输成本
splitItem.setBlManual("1"); // 手工计算
splitItem.setCostNo("-1"); // 固定成本
splitItem.setBatchNo("-1");
splitItem.setTransWeight(waybill.getBillWeight()); // 运输重量
splitItem.setTransVolume(waybill.getTotalVolume()); // 运输体积
splitItem.setTransWeight(mainWaybill.getBillWeight()); // 运输重量
splitItem.setTransVolume(mainWaybill.getTotalVolume()); // 运输体积
// 供应商
splitItem.setSupplierCode("10213"); // 供应商
splitItem.setTransSignNo(waybill.getTakePieceEmployeeName()); // 运输号
splitItem.setTransSignNo(mainWaybill.getTakePieceEmployeeName()); // 运输号
splitItem.setSendPlace("客户现场");
splitItem.setDestPlace(waybill.getSendSiteName());
splitItem.setBillMonth(DateUtils.parseDateToStr(DateUtils.YYYY_MM,waybill.getSendDate()));
splitItem.setTradeDate(waybill.getSendDate());
splitItem.setDestPlace(mainWaybill.getSendSiteName());
splitItem.setBillMonth(DateUtils.parseDateToStr(DateUtils.YYYY_MM,mainWaybill.getSendDate()));
splitItem.setTradeDate(mainWaybill.getSendDate());
// 成本分摊
splitItem.setFeeType("1001"); // 网点取件费
splitItem.setSplitType("1"); // 按重量分摊
splitItem.setFeeItemId(-1L); // 无成本费用项来源
splitItem.setSplitValue(waybill.getBillWeight());
splitItem.setSplitValue(mainWaybill.getBillWeight());
// 计算公式 首重1Kg 10元,续重1kg 1元
String itemCalcExpr = "s+(w-1)*d";
if(waybill.getBillWeight().doubleValue() <= 1.0){
if(mainWaybill.getBillWeight().doubleValue() <= 1.0){
itemCalcExpr="s";
}
String calcExprStr=getCalcFeeExpStr(itemCalcExpr,waybill.getBillWeight(),BigDecimal.valueOf(10.0D),BigDecimal.valueOf(1.0D));
String calcExprStr=getCalcFeeExpStr(itemCalcExpr,mainWaybill.getBillWeight(),BigDecimal.valueOf(10.0D),BigDecimal.valueOf(1.0D));
double costFee = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString());
log.info("网点取件费:计算公式:" + calcExprStr + ",重量:" + waybill.getBillWeight().stripTrailingZeros().toPlainString());
log.info("网点取件费:计算公式:" + calcExprStr + ",重量:" + mainWaybill.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);
@ -289,6 +305,9 @@ public class EmisTmsCostFeeServiceImpl implements IEmisTmsCostFeeService
splitItem.setCnyFee(splitCostFee);
// 插入分摊明细数据
// 先删除取件费,再插入
emisTmsCostFeeSplitMapper.deleteByBillCodeAndFeeType(mainBillCode,"1001");
emisTmsCostFeeSplitMapper.insertEmisTmsCostFeeSplit(splitItem);
}
@ -296,58 +315,58 @@ public class EmisTmsCostFeeServiceImpl implements IEmisTmsCostFeeService
// (3)快递类型货(派送费):目的国家(柬埔寨、缅甸、孟加拉、越南、老挝)末端派送费 首重1Kg 2美金 15元,续重1kg 0.2美金/1.5元;
// 派送
if(
"1".equals(waybill.getCarryType()) // 快递
&& "1".equals(waybill.getDispatchMethod()) // 派送
&& !"1".equals(waybill.getBlVirtual())
"1".equals(mainWaybill.getCarryType()) // 快递
&& "1".equals(mainWaybill.getDispatchMethod()) // 派送
&& (
"0855".equals(waybill.getReceiveCountry()) // 柬埔寨
|| "0095".equals(waybill.getReceiveCountry()) // 缅甸
|| "0880".equals(waybill.getReceiveCountry()) // 孟加拉
|| "0084".equals(waybill.getReceiveCountry()) // 越南
|| "0856".equals(waybill.getReceiveCountry()) // 老挝
"0855".equals(mainWaybill.getReceiveCountry()) // 柬埔寨
|| "0095".equals(mainWaybill.getReceiveCountry()) // 缅甸
|| "0880".equals(mainWaybill.getReceiveCountry()) // 孟加拉
|| "0084".equals(mainWaybill.getReceiveCountry()) // 越南
|| "0856".equals(mainWaybill.getReceiveCountry()) // 老挝
)
){
EmisTmsCostFeeSplit splitItem = new EmisTmsCostFeeSplit();
splitItem.setBillCode(billCode);
splitItem.setMainBillCode(billCode);
splitItem.setBillWeight(waybill.getBillWeight()); // 运单重量
splitItem.setTotalVolume(waybill.getTotalVolume()); // 运单体积
splitItem.setMainBillCode(mainBillCode);
splitItem.setBillWeight(mainWaybill.getBillWeight()); // 运单重量
splitItem.setTotalVolume(mainWaybill.getTotalVolume()); // 运单体积
// 运输成本
splitItem.setBlManual("1"); // 手工计算
splitItem.setCostNo("-1"); // 固定成本
splitItem.setBatchNo("-1");
splitItem.setTransWeight(waybill.getBillWeight()); // 运输重量
splitItem.setTransVolume(waybill.getTotalVolume()); // 运输体积
splitItem.setTransWeight(mainWaybill.getBillWeight()); // 运输重量
splitItem.setTransVolume(mainWaybill.getTotalVolume()); // 运输体积
// 供应商
splitItem.setSupplierCode("10214"); // 供应商
splitItem.setTransSignNo(waybill.getDispatchManName()); // 运输号
splitItem.setTransSignNo(mainWaybill.getDispatchManName()); // 运输号
// 目的网点到客户现场
splitItem.setSendPlace(waybill.getDispatchUnderlingSiteName());
splitItem.setSendPlace(mainWaybill.getDispatchUnderlingSiteName());
splitItem.setDestPlace("客户现场");
splitItem.setBillMonth(DateUtils.parseDateToStr(DateUtils.YYYY_MM,waybill.getSendDate()));
splitItem.setTradeDate(waybill.getDispatchDate());
splitItem.setTradeDate(mainWaybill.getDispatchDate());
// 成本分摊
splitItem.setFeeType("1003"); // 网点取件费
splitItem.setSplitType("1"); // 按重量分摊
splitItem.setFeeItemId(-1L); // 无成本费用项来源
splitItem.setSplitValue(waybill.getBillWeight());
splitItem.setSplitValue(mainWaybill.getBillWeight());
// 网点派送费计算公式 首重1Kg 15元,续重1kg 1.5元
String itemCalcExpr = "s+(w-1)*d";
if(waybill.getBillWeight().doubleValue() <= 1.0){
if(mainWaybill.getBillWeight().doubleValue() <= 1.0){
itemCalcExpr="s";
}
String calcExprStr=getCalcFeeExpStr(itemCalcExpr,waybill.getBillWeight(),BigDecimal.valueOf(15.0D),BigDecimal.valueOf(1.5D));
String calcExprStr=getCalcFeeExpStr(itemCalcExpr,mainWaybill.getBillWeight(),BigDecimal.valueOf(15.0D),BigDecimal.valueOf(1.5D));
double costFee = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString());
log.info("网点派送费:计算公式:" + calcExprStr + ",重量:" + waybill.getBillWeight().stripTrailingZeros().toPlainString());
log.info("网点派送费:计算公式:" + calcExprStr + ",重量:" + mainWaybill.getBillWeight().stripTrailingZeros().toPlainString());
costFee=WaybillHelper.calcSettledFee(costFee,"5");
BigDecimal splitCostFee = BigDecimal.valueOf(costFee).setScale(2,BigDecimal.ROUND_HALF_UP);
splitItem.setCostFee(splitCostFee);
@ -361,76 +380,182 @@ public class EmisTmsCostFeeServiceImpl implements IEmisTmsCostFeeService
splitItem.setTransCostFee(splitCostFee);
splitItem.setCnyFee(splitCostFee);
// 先删除取件费,再插入
emisTmsCostFeeSplitMapper.deleteByBillCodeAndFeeType(mainBillCode,"1003");
// 插入分摊明细数据
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",1);
if(!CollectionUtils.isEmpty(fixedQuotePrice1002List)){
// 检查重复
Map existsMap = new HashMap();
for (EmisTmsCostQuotePrice quotePriceItem : fixedQuotePrice1002List) {
EmisTmsCostFeeSplit splitItem = new EmisTmsCostFeeSplit();
// 如果网点重复就忽略
String uniqKey = quotePriceItem.getStartSiteCode() + "-"+quotePriceItem.getNextSiteCode();
if(existsMap.containsKey(uniqKey)){
continue;
}
existsMap.put(uniqKey,1);
splitItem.setBillCode(billCode);
splitItem.setMainBillCode(billCode);
splitItem.setBillWeight(waybill.getBillWeight()); // 运单重量
splitItem.setTotalVolume(waybill.getTotalVolume()); // 运单体积
EmisTmsCostFeeSplit splitItem = new EmisTmsCostFeeSplit();
// 运输成本
splitItem.setBlManual("1"); // 手工计算
splitItem.setCostNo("-1"); // 固定成本
splitItem.setBatchNo(quotePrice0.getBatchNo());
splitItem.setTransWeight(quotePrice0.getTransWeight()); // 运输重量
splitItem.setTransVolume(BigDecimal.ZERO); // 运输体积
splitItem.setBillCode(billCode);
splitItem.setMainBillCode(mainBillCode);
splitItem.setBillWeight(waybill.getBillWeight()); // 运单重量
splitItem.setTotalVolume(waybill.getTotalVolume()); // 运单体积
// 供应商
splitItem.setSupplierCode(quotePrice0.getSupplierCode()); // 供应商
splitItem.setTransSignNo(quotePrice0.getCarNo()); // 运输号
// 运输成本
splitItem.setBlManual("1"); // 手工计算
splitItem.setCostNo("-1"); // 固定成本
splitItem.setBatchNo(quotePriceItem.getBatchNo());
splitItem.setTransWeight(quotePriceItem.getTransWeight()); // 运输重量
splitItem.setTransVolume(BigDecimal.ZERO); // 运输体积
// 起点到目的点
splitItem.setSendPlace(quotePrice0.getStartSiteName());
splitItem.setDestPlace(quotePrice0.getNextSiteName());
// 供应商
splitItem.setSupplierCode(quotePriceItem.getSupplierCode()); // 供应商
splitItem.setTransSignNo(quotePriceItem.getCarNo()); // 运输号
splitItem.setBillMonth(DateUtils.parseDateToStr(DateUtils.YYYY_MM,waybill.getSendDate()));
splitItem.setTradeDate(waybill.getSignDate());
// 起点到目的点
splitItem.setSendPlace(quotePriceItem.getStartSiteName());
splitItem.setDestPlace(quotePriceItem.getNextSiteName());
// 成本分摊
splitItem.setFeeType("1002"); // 网点机场短驳费
splitItem.setSplitType("1"); // 按重量分摊
splitItem.setFeeItemId(-1L); // 无成本费用项来源
splitItem.setSplitValue(waybill.getBillWeight()); // 分摊重量
splitItem.setBillMonth(DateUtils.parseDateToStr(DateUtils.YYYY_MM, waybill.getSendDate()));
splitItem.setTradeDate(waybill.getSignDate());
// 计算公式 首重1Kg 10元,续重1kg 1元
// 总费用=单价*公里数
BigDecimal totalDbCostFee = quotePrice0.getPrice().multiply(quotePrice0.getDistance());
// 按总重量分摊
// 成本分摊
splitItem.setFeeType("1002"); // 网点机场短驳费
splitItem.setSplitType("1"); // 按重量分摊
splitItem.setFeeItemId(-1L); // 无成本费用项来源
splitItem.setSplitValue(waybill.getBillWeight()); // 分摊重量
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());
// 计算公式 首重1Kg 10元,续重1kg 1元
// 总费用=单价*公里数
BigDecimal totalDbCostFee = quotePriceItem.getPrice().multiply(quotePriceItem.getDistance());
// 按总重量分摊
double costFee = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString());
String itemCalcExpr = quotePriceItem.getCalculateExpression();
String calcExprStr = itemCalcExpr.replaceAll("w", waybill.getBillWeight().stripTrailingZeros().toPlainString())
.replaceAll("t", quotePriceItem.getTransWeight().stripTrailingZeros().toPlainString())
.replaceAll("c", totalDbCostFee.stripTrailingZeros().toPlainString());
log.info("网点机场短驳费:计算公式:" + calcExprStr + ",重量:" + waybill.getBillWeight().stripTrailingZeros().toPlainString());
double costFee = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString());
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("网点机场短驳费");
log.info("网点机场短驳费:计算公式:" + calcExprStr + ",重量:" + waybill.getBillWeight().stripTrailingZeros().toPlainString());
// 总成本费用
splitItem.setTransCostFee(totalDbCostFee);
splitItem.setCnyFee(totalDbCostFee);
costFee = WaybillHelper.calcSettledFee(costFee, quotePriceItem.getPriceType());
// 插入分摊明细数据
emisTmsCostFeeSplitMapper.insertEmisTmsCostFeeSplit(splitItem);
BigDecimal splitCostFee = BigDecimal.valueOf(costFee);
splitItem.setCostFee(splitCostFee);
splitItem.setCurrency("CNY");
splitItem.setCalcExpr(itemCalcExpr);
splitItem.setCalcRemark(calcExprStr + "=" + splitCostFee.stripTrailingZeros().toPlainString());
splitItem.setRemark("网点机场短驳费");
splitItem.setBlVirtual(waybill.getBlVirtual());
// 总成本费用
splitItem.setTransCostFee(totalDbCostFee);
splitItem.setCnyFee(totalDbCostFee);
// 插入分摊明细数据
emisTmsCostFeeSplitMapper.insertEmisTmsCostFeeSplit(splitItem);
}
}
// 机场提货费操作费 - 1004
List<EmisTmsCostQuotePrice> fixedQuotePrice1004List=emisTmsCostQuotePriceMapper.matchBatchFixedQuotePriceByBillCode(billCode,"1004",-1);
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(mainBillCode);
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(quotePriceItem.getEtd());
// 成本分摊
splitItem.setFeeType("1004"); // 网点机场操作费
splitItem.setSplitType("1"); // 按重量分摊
splitItem.setFeeItemId(-1L); // 无成本费用项来源
splitItem.setSplitValue(waybill.getBillWeight()); // 分摊重量
// 总费用=单价*公里数
BigDecimal totalDbCostFee = quotePriceItem.getPrice().multiply(quotePriceItem.getTransWeight());
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());
// 计算单次成本: 如果低于最低报价,则使用最低成本来分摊
if( totalDbCostFee.doubleValue() < quotePriceItem.getLeastPrice().doubleValue() ){
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);
splitItem.setPrice(quotePriceItem.getPrice());
splitItem.setBlVirtual(waybill.getBlVirtual());
// 插入分摊明细数据
emisTmsCostFeeSplitMapper.insertEmisTmsCostFeeSplit(splitItem);
}
}
// 搜索已录入成本的费用分摊
@ -444,6 +569,8 @@ public class EmisTmsCostFeeServiceImpl implements IEmisTmsCostFeeService
}
}
}
mergeCostFeeByBillCode(billCode);
return 1;
@ -672,14 +799,21 @@ public class EmisTmsCostFeeServiceImpl implements IEmisTmsCostFeeService
}
EmisWaybill waybill = billCodeItem.getWaybillDetail();
String mainBillCode=waybill.getBillCode();
if("1".equals(waybill.getBlVirtual())){
mainBillCode=waybill.getMasterBillCode();
}
EmisTmsCostFee costFeeDetail= billCodeItem.getCostFeeDetail();
// 循环费用类型
for (EmisTmsCostFeeFeeitem feeItem: listFeeItemRel) {
EmisTmsCostFeeSplit splitItem = new EmisTmsCostFeeSplit();
splitItem.setBillCode(billCode);
splitItem.setMainBillCode(billCode);
splitItem.setMainBillCode(mainBillCode);
splitItem.setBillWeight(waybill.getBillWeight()); // 运单重量
splitItem.setTotalVolume(waybill.getTotalVolume()); // 运单体积
@ -831,12 +965,12 @@ public class EmisTmsCostFeeServiceImpl implements IEmisTmsCostFeeService
updProfit.setBillFee(emisTmsCostProfit.getBillFee());
// 获取主单成本费用
double costFee=emisTmsCostFeeSplitMapper.getCostFeeByMainBillCode(billCode);
double costFee=emisTmsCostFeeSplitMapper.getCostFeeByMainBillCode(mainBillCode);
updProfit.setCostFee(BigDecimal.valueOf(costFee));
updProfit.setBillProfit(emisTmsCostProfit.getBillFee().subtract(updProfit.getCostFee()));
emisTmsCostProfitMapper.updateEmisTmsCostProfit(updProfit);
log.info("==>费用计算:==>:{}: {}-{}=",billCode,updProfit.getBillFee(),updProfit.getCostFee(),updProfit.getBillProfit());
log.info("==>费用计算:==>:{}:{}-{}=",mainBillCode+":"+billCode,updProfit.getBillFee(),updProfit.getCostFee(),updProfit.getBillProfit());
return 1;
}
@ -956,4 +1090,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);
}
}

View File

@ -115,7 +115,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="batchNo != null and batchNo != ''"> and a.batch_no=#{batchNo}</if>
<if test="feeItemId != null "> and a.fee_item_id = #{feeItemId}</if>
<if test="billCode != null and billCode != ''">
and ( FIND_IN_SET(a.main_bill_code,#{billCode}) or a.main_bill_code like concat('%', #{billCode}, '%') )
and ( FIND_IN_SET(a.bill_code,#{billCode}) or a.bill_code like concat('%', #{billCode}, '%') )
</if>
<if test="mainBillCode != null and mainBillCode != ''">
and ( FIND_IN_SET(a.main_bill_code,#{mainBillCode}) or a.main_bill_code like concat('%', #{mainBillCode}, '%') )
</if>
<if test="sendPlace != null and sendPlace != ''"> and a.send_place=#{sendPlace}</if>
<if test="destPlace != null and destPlace != ''"> and a.dest_place=#{destPlace}</if>
@ -345,6 +348,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update emis_tms_cost_fee_split set del_flag='1' where del_flag='0' and cost_no = #{costNo}
</delete>
<delete id="deleteByBillCodeAndFeeType" >
update emis_tms_cost_fee_split set del_flag='1'
where del_flag='0'
and bill_code = #{billCode}
and fee_type = #{feeType}
</delete>
<delete id="deleteByCostNoAndBillCode" >
update emis_tms_cost_fee_split set del_flag='1'
where del_flag='0'

View File

@ -37,7 +37,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<where>
a.bill_code=b.bill_code and a.del_flag='0' and b.del_flag='0'
<if test="id != null "> and b.id = #{id}</if>
<if test="billCode != null and billCode != ''"> and FIND_IN_SET(b.`bill_code`,#{billCode})</if>
<if test="billCode != null and billCode != ''">
and (
FIND_IN_SET(b.`bill_code`,#{billCode}) or
exists (
select 1 from emis_waybill c where c.master_bill_code = a.bill_code and FIND_IN_SET(c.`bill_code`,#{billCode})
)
)</if>
<if test="standardFee != null "> and b.standard_fee = #{standardFee}</if>
<if test="billFee != null "> and b.bill_fee = #{billFee}</if>
<if test="costFee != null "> and b.cost_fee = #{costFee}</if>
@ -100,6 +106,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and a.calc_fee_type = #{params.calcFeeType}
</if>
<!-- 组批次完整: blIsBatchOk=1 blIsBatchOk=-1 不完整 -->
<if test="params.blIsBatchOk != null and params.blIsBatchOk == 1 ">
and exists (
select 1 from emis_waybill_batch_status ewbs where a.bill_code=ewbs.bill_code
)
</if>
<if test="params.blIsBatchOk != null and params.blIsBatchOk == -1 ">
and not exists (
select 1 from emis_waybill_batch_status ewbs where a.bill_code=ewbs.bill_code
)
</if>
<!-- 费用是否录入完整: blIsCostFeeOk=1 blIsCostFeeOk=-1 不完整 -->
<if test="params.blIsCostFeeOk != null and params.blIsCostFeeOk == 1 ">
and exists (
select 1 from emis_waybill_batch_status ewbs where a.bill_code=ewbs.bill_code
)
</if>
<if test="params.blIsCostFeeOk != null and params.blIsCostFeeOk == -1 ">
and not exists (
select 1 from emis_waybill_batch_status ewbs where a.bill_code=ewbs.bill_code
)
</if>
<if test="params.beginSendDate != null and params.beginSendDate != ''">
and a.send_date <![CDATA[ >= ]]> #{params.beginSendDate}
</if>
@ -202,11 +234,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<delete id="deleteEmisTmsCostProfitById" parameterType="Long">
delete from emis_tms_cost_profit where id = #{id}
update emis_tms_cost_profit set del_flag='1' where id = #{id}
</delete>
<delete id="deleteEmisTmsCostProfitByIds" parameterType="String">
delete from emis_tms_cost_profit where id in
update emis_tms_cost_profit set del_flag='1' where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>

View File

@ -10,13 +10,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="nextSiteCode" column="next_site_code" />
<result property="distance" column="distance" />
<result property="feeType" column="fee_type" />
<result property="fee" column="fee" />
<result property="leastPrice" column="least_price" />
<result property="priceType" column="price_type" />
<result property="price" column="price" />
<result property="currency" column="currency" />
<result property="startWeight" column="start_weight" />
<result property="endWeight" column="end_weight" />
<result property="initialWeight" column="initial_weight" />
<result property="additionalWeight" column="additional_weight" />
<result property="conditionExpression" column="condition_expression" />
<result property="calculateExpression" column="calculate_expression" />
<result property="billType" column="bill_type" />
<result property="supplierCode" column="supplier_code" />
<result property="startDate" column="start_date" />
<result property="endDate" column="end_date" />
<result property="blOpen" column="bl_open" />
<result property="batchNo" column="batch_no" />
<result property="carNo" column="car_no" />
@ -32,7 +41,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectEmisTmsCostQuotePriceVo">
select id, start_site_code, next_site_code, distance, fee_type, price, currency, bill_type, supplier_code, start_date, end_date, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site from emis_tms_cost_quote_price
select id, start_site_code, next_site_code, distance, fee_type, fee, least_price, price_type, price, currency, start_weight, end_weight, initial_weight, additional_weight, condition_expression, calculate_expression, bill_type, supplier_code, start_date, end_date, bl_open, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site from emis_tms_cost_quote_price
</sql>
<select id="selectEmisTmsCostQuotePriceList" parameterType="EmisTmsCostQuotePrice" resultMap="EmisTmsCostQuotePriceResult">
@ -64,19 +73,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="matchTmsCostQuotePriceListByBillCode" parameterType="String" resultMap="EmisTmsCostQuotePriceResult">
<select id="matchBatchFixedQuotePriceByBillCode" resultMap="EmisTmsCostQuotePriceResult">
SELECT
DISTINCT
a.start_site_code,
a.next_site_code,
a.distance,
a.fee_type,
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,
@ -94,9 +107,12 @@ 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 == 1 ">
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}
</select>
@ -108,12 +124,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and next_site_code = #{nextSiteCode}
and distance = #{distance}
and fee_type = #{feeType}
and fee = #{fee}
and price = #{price}
and currency = #{currency}
and start_weight = #{startWeight}
and end_weight = #{endWeight}
and initial_weight = #{initialWeight}
and additional_weight = #{additionalWeight}
and condition_expression = #{conditionExpression}
and calculate_expression = #{calculateExpression}
and bill_type = #{billType}
and supplier_code = #{supplierCode}
and start_date = #{startDate}
and end_date = #{endDate}
and bl_open = #{blOpen}
and remark = #{remark}
and tenant_id = #{tenantId}
and del_flag = #{delFlag}
@ -127,11 +151,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectEmisTmsCostQuotePriceById" parameterType="Long" resultMap="EmisTmsCostQuotePriceResult">
select id, start_site_code, next_site_code, distance, fee_type, price, currency, bill_type, supplier_code, start_date, end_date, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
select id, start_site_code, next_site_code, distance, fee_type, fee, least_price, price_type, price, currency, start_weight, end_weight, initial_weight, additional_weight, condition_expression, calculate_expression, bill_type, supplier_code, start_date, end_date, bl_open, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_tms_cost_quote_price a
where a.id = #{id}
</select>
<insert id="insertEmisTmsCostQuotePrice" parameterType="EmisTmsCostQuotePrice" useGeneratedKeys="true" keyProperty="id">
insert into emis_tms_cost_quote_price
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -140,12 +164,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="nextSiteCode != null and nextSiteCode != ''">next_site_code,</if>
<if test="distance != null">distance,</if>
<if test="feeType != null and feeType != ''">fee_type,</if>
<if test="fee != null">fee,</if>
<if test="leastPrice != null">least_price,</if>
<if test="priceType != null and priceType != ''">price_type,</if>
<if test="price != null">price,</if>
<if test="currency != null and currency != ''">currency,</if>
<if test="startWeight != null">start_weight,</if>
<if test="endWeight != null">end_weight,</if>
<if test="initialWeight != null">initial_weight,</if>
<if test="additionalWeight != null">additional_weight,</if>
<if test="conditionExpression != null and conditionExpression != ''">condition_expression,</if>
<if test="calculateExpression != null and calculateExpression != ''">calculate_expression,</if>
<if test="billType != null and billType != ''">bill_type,</if>
<if test="supplierCode != null and supplierCode != ''">supplier_code,</if>
<if test="startDate != null">start_date,</if>
<if test="endDate != null">end_date,</if>
<if test="blOpen != null and blOpen != ''">bl_open,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="tenantId != null and tenantId != ''">tenant_id,</if>
<if test="delFlag != null and delFlag != ''">del_flag,</if>
@ -155,19 +189,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateTime != null">update_time,</if>
<if test="createSite != null and createSite != ''">create_site,</if>
<if test="updateSite != null and updateSite != ''">update_site,</if>
</trim>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="startSiteCode != null and startSiteCode != ''">#{startSiteCode},</if>
<if test="nextSiteCode != null and nextSiteCode != ''">#{nextSiteCode},</if>
<if test="distance != null">#{distance},</if>
<if test="feeType != null and feeType != ''">#{feeType},</if>
<if test="fee != null">#{fee},</if>
<if test="leastPrice != null">#{leastPrice},</if>
<if test="priceType != null and priceType != ''">#{priceType},</if>
<if test="price != null">#{price},</if>
<if test="currency != null and currency != ''">#{currency},</if>
<if test="startWeight != null">#{startWeight},</if>
<if test="endWeight != null">#{endWeight},</if>
<if test="initialWeight != null">#{initialWeight},</if>
<if test="additionalWeight != null">#{additionalWeight},</if>
<if test="conditionExpression != null and conditionExpression != ''">#{conditionExpression},</if>
<if test="calculateExpression != null and calculateExpression != ''">#{calculateExpression},</if>
<if test="billType != null and billType != ''">#{billType},</if>
<if test="supplierCode != null and supplierCode != ''">#{supplierCode},</if>
<if test="startDate != null">#{startDate},</if>
<if test="endDate != null">#{endDate},</if>
<if test="blOpen != null and blOpen != ''">#{blOpen},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="tenantId != null and tenantId != ''">#{tenantId},</if>
<if test="delFlag != null and delFlag != ''">#{delFlag},</if>
@ -177,7 +221,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateTime != null">#{updateTime},</if>
<if test="createSite != null and createSite != ''">#{createSite},</if>
<if test="updateSite != null and updateSite != ''">#{updateSite},</if>
</trim>
</trim>
</insert>
<update id="updateEmisTmsCostQuotePrice" parameterType="EmisTmsCostQuotePrice">
@ -187,12 +231,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="nextSiteCode != null and nextSiteCode != ''">next_site_code = #{nextSiteCode},</if>
<if test="distance != null">distance = #{distance},</if>
<if test="feeType != null and feeType != ''">fee_type = #{feeType},</if>
<if test="fee != null">fee = #{fee},</if>
<if test="leastPrice != null">least_price = #{leastPrice},</if>
<if test="priceType != null and priceType != ''">price_type = #{priceType},</if>
<if test="price != null">price = #{price},</if>
<if test="currency != null and currency != ''">currency = #{currency},</if>
<if test="startWeight != null">start_weight = #{startWeight},</if>
<if test="endWeight != null">end_weight = #{endWeight},</if>
<if test="initialWeight != null">initial_weight = #{initialWeight},</if>
<if test="additionalWeight != null">additional_weight = #{additionalWeight},</if>
<if test="conditionExpression != null and conditionExpression != ''">condition_expression = #{conditionExpression},</if>
<if test="calculateExpression != null and calculateExpression != ''">calculate_expression = #{calculateExpression},</if>
<if test="billType != null and billType != ''">bill_type = #{billType},</if>
<if test="supplierCode != null and supplierCode != ''">supplier_code = #{supplierCode},</if>
<if test="startDate != null">start_date = #{startDate},</if>
<if test="endDate != null">end_date = #{endDate},</if>
<if test="blOpen != null and blOpen != ''">bl_open = #{blOpen},</if>
<if test="remark != null and remark != ''">remark = #{remark},</if>
<if test="tenantId != null and tenantId != ''">tenant_id = #{tenantId},</if>
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
@ -207,11 +261,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<delete id="deleteEmisTmsCostQuotePriceById" parameterType="Long">
delete from emis_tms_cost_quote_price where id = #{id}
update emis_tms_cost_quote_price set del_flag='1' where id = #{id}
</delete>
<delete id="deleteEmisTmsCostQuotePriceByIds" parameterType="String">
delete from emis_tms_cost_quote_price where id in
update emis_tms_cost_quote_price set del_flag='1' where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>