提交 d2e45767 authored 作者: 刘海泉's avatar 刘海泉

修改货单取消状态和需要车数和提取吨数的更新

上级 f7a9251a
...@@ -219,4 +219,6 @@ public interface OrderChildDao extends BaseDao<OrderChildMapper, OrderChild, Int ...@@ -219,4 +219,6 @@ public interface OrderChildDao extends BaseDao<OrderChildMapper, OrderChild, Int
int countLoadByOrderGoodsNo(String orderGoodsNo); int countLoadByOrderGoodsNo(String orderGoodsNo);
Long countNotCancelOrderChild(List<String> cancelOrderGoodsNo); Long countNotCancelOrderChild(List<String> cancelOrderGoodsNo);
Long queryNoCancelChildByOrderGoodsNo(String orderGoodsNo, Integer code);
} }
...@@ -114,4 +114,5 @@ public interface OrderGoodsDao extends BaseDao<OrderGoodsMapper, OrderGoods, Int ...@@ -114,4 +114,5 @@ public interface OrderGoodsDao extends BaseDao<OrderGoodsMapper, OrderGoods, Int
void batchCancelOrderGoodsWeight(List<OrderGoodsCancelWeightDTO> cancelOrderGoodsList); void batchCancelOrderGoodsWeight(List<OrderGoodsCancelWeightDTO> cancelOrderGoodsList);
boolean updateExtractWeightAndNeedTruckNum(String orderGoodsNo, BigDecimal extractWeight, Integer needTruckNum);
} }
...@@ -730,4 +730,11 @@ public class OrderChildDaoImpl extends BaseDaoImpl<OrderChildMapper, OrderChild, ...@@ -730,4 +730,11 @@ public class OrderChildDaoImpl extends BaseDaoImpl<OrderChildMapper, OrderChild,
queryWrapper.le(OrderChild :: getStatus,OrderChildEnum.Status.COMPLETE.getCode()); queryWrapper.le(OrderChild :: getStatus,OrderChildEnum.Status.COMPLETE.getCode());
return baseMapper.selectCount(queryWrapper); return baseMapper.selectCount(queryWrapper);
} }
@Override
public Long queryNoCancelChildByOrderGoodsNo(String orderGoodsNo, Integer status) {
return baseMapper.selectCount(lQrWrapper().eq(OrderChild::getOrderGoodsNo,orderGoodsNo)
.lt(ObjectUtil.isNotEmpty(status),OrderChild::getStatus, status)
);
}
} }
...@@ -312,4 +312,14 @@ public class OrderGoodsDaoImpl extends BaseDaoImpl<OrderGoodsMapper, OrderGoods, ...@@ -312,4 +312,14 @@ public class OrderGoodsDaoImpl extends BaseDaoImpl<OrderGoodsMapper, OrderGoods,
public void batchCancelOrderGoodsWeight(List<OrderGoodsCancelWeightDTO> cancelOrderGoodsList) { public void batchCancelOrderGoodsWeight(List<OrderGoodsCancelWeightDTO> cancelOrderGoodsList) {
baseMapper.batchCancelOrderGoodsWeight(cancelOrderGoodsList); baseMapper.batchCancelOrderGoodsWeight(cancelOrderGoodsList);
} }
@Override
public boolean updateExtractWeightAndNeedTruckNum(String orderGoodsNo, BigDecimal extractWeight,
Integer needTruckNum) {
return update(lUdWrapper()
.in(OrderGoods::getOrderGoodsNo, orderGoodsNo)
.set(OrderGoods::getExtractWeight, extractWeight)
.set(OrderGoods :: getNeedTruckNum,needTruckNum)
);
}
} }
...@@ -39,7 +39,6 @@ public interface OrderGoodsMapper extends BaseMapper<OrderGoods> { ...@@ -39,7 +39,6 @@ public interface OrderGoodsMapper extends BaseMapper<OrderGoods> {
@Update(" update order_goods set " + @Update(" update order_goods set " +
" already_transport_weight = already_transport_weight - #{residueWeight}," + " already_transport_weight = already_transport_weight - #{residueWeight}," +
" extract_weight = already_transport_weight," +
"order_goods_status = #{orderGoodsStatus} " + "order_goods_status = #{orderGoodsStatus} " +
" where id = #{id}") " where id = #{id}")
void updateOrderGoodsWeightAlreadyAndStatus(@Param("id") Integer id, @Param("residueWeight") BigDecimal residueWeight, @Param("orderGoodsStatus") Integer orderGoodsStatus); void updateOrderGoodsWeightAlreadyAndStatus(@Param("id") Integer id, @Param("residueWeight") BigDecimal residueWeight, @Param("orderGoodsStatus") Integer orderGoodsStatus);
......
...@@ -720,9 +720,14 @@ public class OrderGoodsServiceImpl implements OrderGoodsService, InitializingBea ...@@ -720,9 +720,14 @@ public class OrderGoodsServiceImpl implements OrderGoodsService, InitializingBea
OrderGoods orderGoods = dto.getOrderGoods(); OrderGoods orderGoods = dto.getOrderGoods();
List<String> childNoList = dto.getChildNoList(); List<String> childNoList = dto.getChildNoList();
//查询该货单下未取消的运单数量
Long noCancelChildCount = orderChildDao.queryNoCancelChildByOrderGoodsNo(orderGoods.getOrderGoodsNo(),
OrderChildEnum.Status.DRIVER_CANCEL.getCode());
List<OrderChild> orderChildList = orderChildDao.selectResidueWeightByOrderGoodsNo(orderGoods.getOrderGoodsNo(), List<OrderChild> orderChildList = orderChildDao.selectResidueWeightByOrderGoodsNo(orderGoods.getOrderGoodsNo(),
OrderChildEnum.Status.DRIVER_CANCEL.getCode(), dto.getOrderGoodsCancelParam().getTruckList()); OrderChildEnum.Status.DRIVER_CANCEL.getCode(), dto.getOrderGoodsCancelParam().getTruckList());
Long needTruckNum = 0L;
if (CollectionUtils.isNotEmpty(orderChildList)) { if (CollectionUtils.isNotEmpty(orderChildList)) {
List<OrderChild> filterOrderChildList = orderChildList.stream(). List<OrderChild> filterOrderChildList = orderChildList.stream().
filter(item -> item.getStatus() < OrderChildEnum.Status.LOAD.getCode()).collect(Collectors.toList()); filter(item -> item.getStatus() < OrderChildEnum.Status.LOAD.getCode()).collect(Collectors.toList());
...@@ -741,16 +746,32 @@ public class OrderGoodsServiceImpl implements OrderGoodsService, InitializingBea ...@@ -741,16 +746,32 @@ public class OrderGoodsServiceImpl implements OrderGoodsService, InitializingBea
OrderChildEnum.Status.PLATFORM_CANCEL.getCode(),"系统取消", OrderChildEnum.Status.PLATFORM_CANCEL.getCode(),"系统取消",
now, now, childNoList); now, now, childNoList);
orderChildList.removeAll(filterOrderChildList); orderChildList.removeAll(filterOrderChildList);
if (CollectionUtil.isNotEmpty(orderChildList)) { //此次不能取消的运单不为空 || 货单下的未取消的运单数 大于 已经取消的运单数
if (CollectionUtil.isNotEmpty(orderChildList) || noCancelChildCount > filterOrderChildList.size()) {
dto.setOrderGoodsStatus(OrderGoodsStatusEnum.Status.COMPLETED.getCode()); dto.setOrderGoodsStatus(OrderGoodsStatusEnum.Status.COMPLETED.getCode());
} }
needTruckNum = noCancelChildCount-filterOrderChildList.size();
} }
orderGoodsTruckBindDao.updateOrderGoodsBindStatus(orderGoods.getOrderGoodsNo(), OrderGoodsTruckBindEnum.Status.CANCEL.getCode()); orderGoodsTruckBindDao.updateOrderGoodsBindStatus(orderGoods.getOrderGoodsNo(), OrderGoodsTruckBindEnum.Status.CANCEL.getCode());
orderGoodsDao.updateOrderGoodsSetAlreadyWeightAndStatus(sum, dto.getOrderGoodsStatus(), orderGoods.getId()); orderGoodsDao.updateOrderGoodsSetAlreadyWeightAndStatus(sum, dto.getOrderGoodsStatus(), orderGoods.getId());
if(Objects.equals(dto.getOrderGoodsStatus(),OrderGoodsStatusEnum.Status.COMPLETED.getCode())){
updateCompleteNeedTruck(orderGoods.getOrderGoodsNo(),
orderGoods.getAlreadyTransportWeight().subtract(sum),needTruckNum.intValue());
}
} }
//更新取消变成完结的货单的需要车辆数和提取量
public void updateCompleteNeedTruck(String orderGoodsNo,BigDecimal extractWeight,Integer needTruckNum){
log.info("更新货单的需要车辆数和提取量,货单号:{},提取吨数:{},需要车数:{}",orderGoodsNo,extractWeight,needTruckNum);
boolean flag = orderGoodsDao.updateExtractWeightAndNeedTruckNum(orderGoodsNo,extractWeight,needTruckNum);
log.info("更新货单的需要车辆数和提取量,货单号:{},更新结果:{}",orderGoodsNo,flag);
}
private void cancelOperateTwoTypeStrategy(OrderGoodsCancelDTO dto) { private void cancelOperateTwoTypeStrategy(OrderGoodsCancelDTO dto) {
String now = DateUtils.formatDateTime(LocalDateTime.now()).get(); String now = DateUtils.formatDateTime(LocalDateTime.now()).get();
OrderGoods orderGoods = dto.getOrderGoods(); OrderGoods orderGoods = dto.getOrderGoods();
...@@ -759,6 +780,7 @@ public class OrderGoodsServiceImpl implements OrderGoodsService, InitializingBea ...@@ -759,6 +780,7 @@ public class OrderGoodsServiceImpl implements OrderGoodsService, InitializingBea
BigDecimal childResidueWeight = BigDecimal.ZERO; BigDecimal childResidueWeight = BigDecimal.ZERO;
int needTruckNum = 0;
if (CollectionUtils.isNotEmpty(orderChildList)) { if (CollectionUtils.isNotEmpty(orderChildList)) {
List<OrderChild> filterOrderChildList = orderChildList.stream().filter(item -> item.getStatus() < OrderChildEnum.Status.ARRIVE_SEND.getCode()).collect(Collectors.toList()); List<OrderChild> filterOrderChildList = orderChildList.stream().filter(item -> item.getStatus() < OrderChildEnum.Status.ARRIVE_SEND.getCode()).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(filterOrderChildList)) { if (CollectionUtils.isNotEmpty(filterOrderChildList)) {
...@@ -778,11 +800,16 @@ public class OrderGoodsServiceImpl implements OrderGoodsService, InitializingBea ...@@ -778,11 +800,16 @@ public class OrderGoodsServiceImpl implements OrderGoodsService, InitializingBea
} }
orderChildList.removeAll(filterOrderChildList); orderChildList.removeAll(filterOrderChildList);
if (CollectionUtil.isNotEmpty(orderChildList)) { if (CollectionUtil.isNotEmpty(orderChildList)) {
needTruckNum = orderChildList.size();
dto.setOrderGoodsStatus(OrderGoodsStatusEnum.Status.COMPLETED.getCode()); dto.setOrderGoodsStatus(OrderGoodsStatusEnum.Status.COMPLETED.getCode());
} }
} }
orderGoodsTruckBindDao.updateOrderGoodsBindStatus(orderGoods.getOrderGoodsNo(), OrderGoodsTruckBindEnum.Status.CANCEL.getCode()); orderGoodsTruckBindDao.updateOrderGoodsBindStatus(orderGoods.getOrderGoodsNo(), OrderGoodsTruckBindEnum.Status.CANCEL.getCode());
orderGoodsDao.updateOrderGoodsWeightAlreadyAndStatus(orderGoods.getId(),childResidueWeight,OrderGoodsStatusEnum.Status.COMPLETED.getCode()); orderGoodsDao.updateOrderGoodsWeightAlreadyAndStatus(orderGoods.getId(),childResidueWeight,dto.getOrderGoodsStatus());
if(Objects.equals(dto.getOrderGoodsStatus(),OrderGoodsStatusEnum.Status.COMPLETED.getCode())){
updateCompleteNeedTruck(orderGoods.getOrderGoodsNo(),
orderGoods.getAlreadyTransportWeight().subtract(childResidueWeight),needTruckNum);
}
} }
private void cancelOperateOneTypeStrategy(OrderGoodsCancelDTO dto) { private void cancelOperateOneTypeStrategy(OrderGoodsCancelDTO dto) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论