This commit is contained in:
linfso 2025-06-30 19:32:36 +08:00
parent 293f424070
commit 6592fb2599
2 changed files with 30 additions and 10 deletions

View File

@ -100,7 +100,7 @@ public interface IEmisTmsCostFeeService
* @return * @return
* @throws EmisBizError * @throws EmisBizError
*/ */
public int reCalcSplitCostFee(String costNo) throws EmisBizError; public int reCalcSplitCostFee(String costNo,String billCode) throws EmisBizError;
/** /**

View File

@ -30,6 +30,7 @@ import com.xdadan.erp.emis.utils.WaybillHelper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections4.ListUtils; import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -390,7 +391,6 @@ public class EmisTmsCostFeeServiceImpl implements IEmisTmsCostFeeService
log.info("网点机场短驳费:计算公式:" + calcExprStr + ",重量:" + waybill.getBillWeight().stripTrailingZeros().toPlainString()); log.info("网点机场短驳费:计算公式:" + calcExprStr + ",重量:" + waybill.getBillWeight().stripTrailingZeros().toPlainString());
splitItem.setCostFee(BigDecimal.valueOf(costFee)); splitItem.setCostFee(BigDecimal.valueOf(costFee));
splitItem.setCalcExpr(calcExprStr); splitItem.setCalcExpr(calcExprStr);
splitItem.setCalcRemark(calcExprStr+"="+String.valueOf(costFee)); splitItem.setCalcRemark(calcExprStr+"="+String.valueOf(costFee));
@ -431,7 +431,7 @@ public class EmisTmsCostFeeServiceImpl implements IEmisTmsCostFeeService
if(!CollectionUtil.isEmpty(listCostFee)){ if(!CollectionUtil.isEmpty(listCostFee)){
for(EmisTmsCostFee item:listCostFee){ for(EmisTmsCostFee item:listCostFee){
try { try {
reCalcSplitCostFee(item.getCostNo()); reCalcSplitCostFee(item.getCostNo(),null);
}catch (Exception ex){ }catch (Exception ex){
ex.printStackTrace(); ex.printStackTrace();
} }
@ -539,7 +539,7 @@ public class EmisTmsCostFeeServiceImpl implements IEmisTmsCostFeeService
* @throws EmisBizError * @throws EmisBizError
*/ */
@Override @Override
public int reCalcSplitCostFee(String costNo) throws EmisBizError { public int reCalcSplitCostFee(String costNo,String calcBillCode) throws EmisBizError {
// 获取最新的数据 // 获取最新的数据
EmisTmsCostFee oldCostFee = emisTmsCostFeeMapper.selectEmisTmsCostFeeByCostNo(costNo); EmisTmsCostFee oldCostFee = emisTmsCostFeeMapper.selectEmisTmsCostFeeByCostNo(costNo);
// /* 总票数 总重量 总体积 */ // /* 总票数 总重量 总体积 */
@ -562,13 +562,17 @@ public class EmisTmsCostFeeServiceImpl implements IEmisTmsCostFeeService
} }
// 删除与该成本关联的费用 // 删除与该成本关联的费用
emisTmsCostFeeSplitMapper.deleteEmisTmsCostFeeSplitByCostNo(costNo); if(StringUtils.isEmpty(calcBillCode)) {
emisTmsCostFeeSplitMapper.deleteEmisTmsCostFeeSplitByCostNo(costNo);
}else{
emisTmsCostFeeSplitMapper.deleteEmisTmsCostFeeSplitByBillCode(calcBillCode);
}
Integer pieceNumber = 0; Integer pieceNumber = 0;
// 计算总重量 // 计算总重量
for (CostFeeWaybillRel billCodeRel: listBillCodeRel) { for (CostFeeWaybillRel billCodeItem: listBillCodeRel) {
// 获取运单信息 // 获取运单信息
EmisWaybill emisWaybill=billCodeRel.getWaybillDetail(); EmisWaybill emisWaybill=billCodeItem.getWaybillDetail();
// 累加应收 // 累加应收
totalWeight=totalWeight.add(emisWaybill.getBillWeight()); totalWeight=totalWeight.add(emisWaybill.getBillWeight());
totalVolume=totalVolume.add(emisWaybill.getTotalVolume()); totalVolume=totalVolume.add(emisWaybill.getTotalVolume());
@ -578,8 +582,14 @@ public class EmisTmsCostFeeServiceImpl implements IEmisTmsCostFeeService
// 计算分摊成本 // 计算分摊成本
for (CostFeeWaybillRel billCodeItem: listBillCodeRel) { for (CostFeeWaybillRel billCodeItem: listBillCodeRel) {
String billCode=billCodeItem.getBillCode(); String billCode=billCodeItem.getBillCode();
// 如果指定单号,则其他单号做过滤
if(!StringUtils.isEmpty(calcBillCode)) {
if(!billCode.equals(calcBillCode)){
continue;
}
}
EmisWaybill waybill = billCodeItem.getWaybillDetail(); EmisWaybill waybill = billCodeItem.getWaybillDetail();
EmisTmsCostFee costFeeDetail= billCodeItem.getCostFeeDetail(); EmisTmsCostFee costFeeDetail= billCodeItem.getCostFeeDetail();
@ -673,9 +683,19 @@ public class EmisTmsCostFeeServiceImpl implements IEmisTmsCostFeeService
emisTmsCostFeeMapper.updateEmisTmsCostFee(emisTmsCostFee); emisTmsCostFeeMapper.updateEmisTmsCostFee(emisTmsCostFee);
// 合并单个运单费用 // 合并单个运单费用
for (CostFeeWaybillRel feeRel: listBillCodeRel) { for (CostFeeWaybillRel billCodeItem: listBillCodeRel) {
try { try {
mergeCostFeeByBillCode(feeRel.getBillCode());
String billCode=billCodeItem.getBillCode();
// 如果指定单号,则其他单号做过滤
if(!StringUtils.isEmpty(calcBillCode)) {
if(!billCode.equals(calcBillCode)){
continue;
}
}
mergeCostFeeByBillCode(billCode);
}catch (Exception ex){ }catch (Exception ex){
ex.printStackTrace(); ex.printStackTrace();
} }