提交 87edd04e authored 作者: liuhaiquan's avatar liuhaiquan

修改磅单审核借吨逻辑

上级 d84ee3a2
package com.clx.performance.service; package com.clx.performance.service;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.clx.performance.model.OrderChild; import com.clx.performance.model.OrderChild;
import com.clx.performance.model.OrderGoods;
import com.clx.performance.param.app.*; import com.clx.performance.param.app.*;
import com.clx.performance.param.pc.OrderChildCarrierCancelParam; import com.clx.performance.param.pc.OrderChildCarrierCancelParam;
import com.clx.performance.param.pc.PageCarrierOrderChildParam; import com.clx.performance.param.pc.PageCarrierOrderChildParam;
...@@ -11,6 +11,7 @@ import com.clx.performance.param.pc.PagePoundAuditParam; ...@@ -11,6 +11,7 @@ import com.clx.performance.param.pc.PagePoundAuditParam;
import com.clx.performance.vo.app.*; import com.clx.performance.vo.app.*;
import com.clx.performance.vo.pc.*; import com.clx.performance.vo.pc.*;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
...@@ -81,4 +82,6 @@ public interface OrderChildService { ...@@ -81,4 +82,6 @@ public interface OrderChildService {
DriverCancelOrderChildInfo driverCancelOrderChildInfo(String orderChildNo); DriverCancelOrderChildInfo driverCancelOrderChildInfo(String orderChildNo);
void updateOrderGoodsAmountLoad(OrderGoods orderGoods,String childNo, BigDecimal dif, Integer orderGoodsStatus);
} }
package com.clx.performance.service; package com.clx.performance.service;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.clx.performance.model.OrderChild; import com.clx.performance.model.OrderChild;
import com.clx.performance.param.pc.*;
import com.clx.performance.model.OrderGoods; import com.clx.performance.model.OrderGoods;
import com.clx.performance.param.app.OrderGoodsListPageParam; import com.clx.performance.param.app.OrderGoodsListPageParam;
import com.clx.performance.param.pc.*;
import com.clx.performance.vo.app.OrderGoodsAPPVO; import com.clx.performance.vo.app.OrderGoodsAPPVO;
import com.clx.performance.vo.feign.FreightEstimateVO; import com.clx.performance.vo.feign.FreightEstimateVO;
import com.clx.performance.vo.feign.OrderGoodsFeignVO; import com.clx.performance.vo.feign.OrderGoodsFeignVO;
import com.clx.performance.vo.pc.OrderGoodsEditVO; import com.clx.performance.vo.pc.OrderGoodsEditVO;
import com.clx.performance.vo.pc.OrderGoodsVO; import com.clx.performance.vo.pc.OrderGoodsVO;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
...@@ -32,6 +28,11 @@ public interface OrderGoodsService { ...@@ -32,6 +28,11 @@ public interface OrderGoodsService {
IPage<OrderGoodsVO> pageOrderGoodsList(PageOrderGoodsListParam param); IPage<OrderGoodsVO> pageOrderGoodsList(PageOrderGoodsListParam param);
void updateOrderGoodsReduceWeightAndStatusAmountLoad(OrderGoods orderGoods, BigDecimal orderChildWeight, Integer orderGoodsStatus); void updateOrderGoodsReduceWeightAndStatusAmountLoad(OrderGoods orderGoods, BigDecimal orderChildWeight, Integer orderGoodsStatus);
void borrowWeight(OrderGoods orderGoods,String orderChildNo,BigDecimal subOrderGoodsResidue, BigDecimal addAlready,BigDecimal borrowOrderWeight,
Integer orderGoodsStatus);
void updateOrderGoodsReduceWeightAndStatus(OrderGoods orderGoods, OrderChild orderChild, Integer orderGoodsStatus); void updateOrderGoodsReduceWeightAndStatus(OrderGoods orderGoods, OrderChild orderChild, Integer orderGoodsStatus);
IPage<OrderGoodsAPPVO> indexOrderGoodsList(OrderGoodsListPageParam orderGoodsListParam); IPage<OrderGoodsAPPVO> indexOrderGoodsList(OrderGoodsListPageParam orderGoodsListParam);
......
package com.clx.performance.service.impl; package com.clx.performance.service.impl;
import com.clx.performance.dao.*; import com.clx.performance.dao.*;
import com.clx.performance.enums.*; import com.clx.performance.enums.*;
import com.clx.performance.model.*; import com.clx.performance.model.*;
import com.clx.performance.param.pc.PoundAuditParam; import com.clx.performance.param.pc.PoundAuditParam;
import com.clx.performance.service.OrderChildLogService; import com.clx.performance.service.OrderChildLogService;
import com.clx.performance.service.OrderChildPoundAuditService; import com.clx.performance.service.OrderChildPoundAuditService;
import com.clx.performance.service.OrderChildService;
import com.clx.performance.service.OrderGoodsService; import com.clx.performance.service.OrderGoodsService;
import com.clx.performance.vo.pc.OrderChildPoundAuditDetailVO; import com.clx.performance.vo.pc.OrderChildPoundAuditDetailVO;
import com.msl.common.exception.ServiceSystemException; import com.msl.common.exception.ServiceSystemException;
...@@ -47,6 +47,7 @@ public class OrderChildPoundAuditServiceImpl implements OrderChildPoundAuditSer ...@@ -47,6 +47,7 @@ public class OrderChildPoundAuditServiceImpl implements OrderChildPoundAuditSer
private final OrderGoodsService orderGoodsService; private final OrderGoodsService orderGoodsService;
private final OrderChildLogService orderChildLogService; private final OrderChildLogService orderChildLogService;
private final OrderChildService orderChildService;
@Override @Override
...@@ -95,7 +96,7 @@ public class OrderChildPoundAuditServiceImpl implements OrderChildPoundAuditSer ...@@ -95,7 +96,7 @@ public class OrderChildPoundAuditServiceImpl implements OrderChildPoundAuditSer
BigDecimal dif = param.getLoadNet().subtract(orderChild.getLoadNet()); BigDecimal dif = param.getLoadNet().subtract(orderChild.getLoadNet());
Integer type = OrderChildLogEnum.Type.POUND_AUDIT.getCode(); int type = OrderChildLogEnum.Type.POUND_AUDIT.getCode();
if(Objects.equals(param.getStatus(), OrderChildPoundAuditEnum.Status.REJECT.getCode())){ if(Objects.equals(param.getStatus(), OrderChildPoundAuditEnum.Status.REJECT.getCode())){
type = OrderChildLogEnum.Type.POUND_AUDIT_REJECT.getCode(); type = OrderChildLogEnum.Type.POUND_AUDIT_REJECT.getCode();
}else{ }else{
...@@ -113,7 +114,7 @@ public class OrderChildPoundAuditServiceImpl implements OrderChildPoundAuditSer ...@@ -113,7 +114,7 @@ public class OrderChildPoundAuditServiceImpl implements OrderChildPoundAuditSer
orderChild.setFreight(orderChildFreightCalc(orderChild)); orderChild.setFreight(orderChildFreightCalc(orderChild));
// 更新装车净重 // 更新装车净重
updateOrderGoodsAmountLoad(orderGoods, dif); updateOrderGoodsAmountLoad(orderGoods,orderChild.getChildNo(), dif);
//更新运单数据 //更新运单数据
orderChild.setPoundStatus(param.getStatus()); orderChild.setPoundStatus(param.getStatus());
...@@ -138,34 +139,15 @@ public class OrderChildPoundAuditServiceImpl implements OrderChildPoundAuditSer ...@@ -138,34 +139,15 @@ public class OrderChildPoundAuditServiceImpl implements OrderChildPoundAuditSer
/** /**
* 装车补偿 * 装车补偿
*/ */
private void updateOrderGoodsAmountLoad(OrderGoods orderGoods, BigDecimal dif){ private void updateOrderGoodsAmountLoad(OrderGoods orderGoods,String childNo, BigDecimal dif){
int i = dif.compareTo(BigDecimal.ZERO);
if (i == 0){
return;
} else if (i > 0) {
if (orderGoods.getOrderGoodsStatus().equals(OrderGoodsStatusEnum.Status.CANCEL.getCode())
|| orderGoods.getOrderGoodsStatus().equals(OrderGoodsStatusEnum.Status.COMPLETED.getCode())
|| orderGoods.getOrderGoodsStatus().equals(OrderGoodsStatusEnum.Status.SUCCESS.getCode())
) {
throw new ServiceSystemException(PerformanceResultEnum.ORDER_GOODS_STATUS_NOT_GET);
}
if (orderGoods.getResidueTransportWeight().compareTo(dif) < 0) {
throw new ServiceSystemException(PerformanceResultEnum.ORDER_GOODS_WEIGHT_NOT_HAVE);
}
}
int count = orderChildDao.countValidByOrderGoodsNo(orderGoods.getOrderGoodsNo())-1; int count = orderChildDao.countValidByOrderGoodsNo(orderGoods.getOrderGoodsNo())-1;
Integer status; Integer status;
if (count == 0){ if (count == 0){
status = OrderGoodsStatusEnum.Status.PAYING.getCode(); status = OrderGoodsStatusEnum.Status.PAYING.getCode();
} }else{
else {
status = OrderGoodsStatusEnum.Status.GO_TO_SEND.getCode(); status = OrderGoodsStatusEnum.Status.GO_TO_SEND.getCode();
} }
orderChildService.updateOrderGoodsAmountLoad(orderGoods,childNo,dif,status);
orderGoodsService.updateOrderGoodsReduceWeightAndStatusAmountLoad(orderGoods, dif, status);
} }
/** /**
......
...@@ -706,9 +706,8 @@ public class OrderChildServiceImpl implements OrderChildService { ...@@ -706,9 +706,8 @@ public class OrderChildServiceImpl implements OrderChildService {
BigDecimal dif = param.getLoadNet().subtract(orderChild.getWeight()); BigDecimal dif = param.getLoadNet().subtract(orderChild.getWeight());
if (orderGoods.getResidueTransportWeight().compareTo(dif) < 0) { //更新货单吨数
throw new ServiceSystemException(PerformanceResultEnum.ORDER_GOODS_WEIGHT_NOT_HAVE); updateOrderGoodsAmountLoad(orderGoods, childNo,dif,OrderGoodsStatusEnum.Status.GO_TO_SEND.getCode());
}
orderChild.setLoadRough(param.getLoadRough()); orderChild.setLoadRough(param.getLoadRough());
orderChild.setLoadTare(param.getLoadTare()); orderChild.setLoadTare(param.getLoadTare());
...@@ -718,9 +717,6 @@ public class OrderChildServiceImpl implements OrderChildService { ...@@ -718,9 +717,6 @@ public class OrderChildServiceImpl implements OrderChildService {
orderChild.setFreight(orderChildFreightCalc(orderChild)); orderChild.setFreight(orderChildFreightCalc(orderChild));
orderChild.setStatus(OrderChildEnum.Status.LOAD.getCode()); orderChild.setStatus(OrderChildEnum.Status.LOAD.getCode());
// 更新装车净重
updateOrderGoodsAmountLoad(orderGoods, dif);
orderChildDao.updateLoad(orderChild); orderChildDao.updateLoad(orderChild);
orderChildImageDao.batchSaveEntity(imageList); orderChildImageDao.batchSaveEntity(imageList);
...@@ -750,8 +746,8 @@ public class OrderChildServiceImpl implements OrderChildService { ...@@ -750,8 +746,8 @@ public class OrderChildServiceImpl implements OrderChildService {
orderChild.setWeight(orderChildWeightCalc(orderChild)); orderChild.setWeight(orderChildWeightCalc(orderChild));
orderChild.setFreight(orderChildFreightCalc(orderChild)); orderChild.setFreight(orderChildFreightCalc(orderChild));
// 更新装车净重 //更新货单吨数
updateOrderGoodsAmountLoad(orderGoods, dif); updateOrderGoodsAmountLoad(orderGoods,childNo, dif,OrderGoodsStatusEnum.Status.GO_TO_SEND.getCode());
orderChildDao.updateLoad(orderChild); orderChildDao.updateLoad(orderChild);
...@@ -981,7 +977,7 @@ public class OrderChildServiceImpl implements OrderChildService { ...@@ -981,7 +977,7 @@ public class OrderChildServiceImpl implements OrderChildService {
audit.setUnloadPoundNo(orderChild.getUnloadPoundNo()); audit.setUnloadPoundNo(orderChild.getUnloadPoundNo());
// 更新装车净重 // 更新装车净重
updateOrderGoodsAmountLoad(orderGoods, dif); updateOrderGoodsAmountLoad(orderGoods, childNo,dif,OrderGoodsStatusEnum.Status.GO_TO_SEND.getCode());
orderChildDao.updateLoadAndUnload(orderChild); orderChildDao.updateLoadAndUnload(orderChild);
...@@ -1416,28 +1412,22 @@ public class OrderChildServiceImpl implements OrderChildService { ...@@ -1416,28 +1412,22 @@ public class OrderChildServiceImpl implements OrderChildService {
} }
/** /**
* 装车补偿 * 更新货单吨数
*/ */
private void updateOrderGoodsAmountLoad(OrderGoods orderGoods, BigDecimal dif) { @Override
int i = dif.compareTo(BigDecimal.ZERO); public void updateOrderGoodsAmountLoad(OrderGoods orderGoods,String childNo, BigDecimal dif, Integer orderGoodsStatus) {
if (i == 0){ if(dif.compareTo(BigDecimal.ZERO) != 0 ){
return; //判断是从订单借吨还是直接货单进行扣减(货单剩余吨数小于本运单的修改后的吨数差值)
} else if (i > 0) {
if (orderGoods.getOrderGoodsStatus().equals(OrderGoodsStatusEnum.Status.CANCEL.getCode())
|| orderGoods.getOrderGoodsStatus().equals(OrderGoodsStatusEnum.Status.COMPLETED.getCode())
|| orderGoods.getOrderGoodsStatus().equals(OrderGoodsStatusEnum.Status.SUCCESS.getCode())
) {
throw new ServiceSystemException(PerformanceResultEnum.ORDER_GOODS_STATUS_NOT_GET);
}
if (orderGoods.getResidueTransportWeight().compareTo(dif) < 0) { if (orderGoods.getResidueTransportWeight().compareTo(dif) < 0) {
throw new ServiceSystemException(PerformanceResultEnum.ORDER_GOODS_WEIGHT_NOT_HAVE); //货单吨数不够扣减,从订单进行借吨数
orderGoodsService.borrowWeight(orderGoods,childNo,orderGoods.getResidueTransportWeight(),dif,
dif.subtract(orderGoods.getResidueTransportWeight()),
OrderGoodsStatusEnum.Status.GO_TO_SEND.getCode());
}else{
// 货单吨数够扣减,直接更新货单剩余吨数和已拉运吨数和状态
orderGoodsDao.updateOrderGoodsReduceWeightAndStatus(orderGoods.getId(), dif, orderGoodsStatus);
} }
} }
Integer status = OrderGoodsStatusEnum.Status.GO_TO_SEND.getCode();
orderGoodsService.updateOrderGoodsReduceWeightAndStatusAmountLoad(orderGoods, dif, status);
} }
/** /**
......
...@@ -749,4 +749,20 @@ public class OrderGoodsServiceImpl implements OrderGoodsService { ...@@ -749,4 +749,20 @@ public class OrderGoodsServiceImpl implements OrderGoodsService {
freightEstimateVO.setFreightPriceList(freightPrice); freightEstimateVO.setFreightPriceList(freightPrice);
return freightEstimateVO; return freightEstimateVO;
} }
@Override
public void borrowWeight(OrderGoods orderGoods,String orderChildNo, BigDecimal subOrderGoodsResidue, BigDecimal addAlready,BigDecimal borrowOrderWeight,
Integer orderGoodsStatus) {
log.info("运单号:{} 进行订单借量,货单剩余吨数需扣减:{} 吨,货单已拉运吨数需增加:{} 吨,订单借用吨数:{} 吨",orderChildNo,
subOrderGoodsResidue,addAlready,borrowOrderWeight);
//更新订单吨数
orderCancelComponent.backFillOrderWeight(orderGoods,borrowOrderWeight, UpdateEnum.SUB.getCode());
//更新货单吨数
orderGoodsDao.updateOrderGoodsWeightResidueAndAlreadyAndStatus(orderGoods.getId(),subOrderGoodsResidue,addAlready,orderGoodsStatus);
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论