@ -1192,20 +1192,58 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
AtomicInteger packageNum = new AtomicInteger ( ) ;
DistributionStockArticleDTO distributionStockArticleDTO = v . get ( 0 ) ;
if ( distributionStockArticleDTO . getIsZero ( ) . equals ( IsOrNoConstant . no . getValue ( ) ) ) {
List < DistributionParcelListDTO > packageListInfo = distributionStockArticleDTO . getPackageListInfo ( ) ;
packageListInfo . forEach ( p - > {
DistributionReservationPackageEntity reservationPackageEntity = new DistributionReservationPackageEntity ( ) ;
reservationPackageEntity . setStockArticleId ( distributionStockArticleDTO . getId ( ) ) ;
reservationPackageEntity . setPacketBarStatus ( ReservationPackageStatusConstant . xinzeng . getValue ( ) ) ;
reservationPackageEntity . setPacketBarCode ( p . getOrderPackageCode ( ) ) ;
reservationPackageEntity . setParceListId ( p . getId ( ) ) ;
reservationPackageEntity . setReservationId ( id ) ;
distributionReservationPackageService . save ( reservationPackageEntity ) ;
packageNum . getAndAdd ( p . getQuantity ( ) ) ;
DistributionParcelListEntity parcelListEntity = distributionParcelListService . getById ( p . getId ( ) ) ;
parcelListEntity . setOrderPackageReservationStatus ( OrderPackageReservationStatusConstant . yiyueyue . getValue ( ) ) ;
distributionParcelListService . updateById ( parcelListEntity ) ;
} ) ;
if ( Func . isNotEmpty ( distributionStockArticleDTO . getPackageListInfo ( ) ) ) {
List < DistributionParcelListDTO > packageListInfo = distributionStockArticleDTO . getPackageListInfo ( ) ;
packageListInfo . forEach ( p - > {
DistributionReservationPackageEntity reservationPackageEntity = new DistributionReservationPackageEntity ( ) ;
reservationPackageEntity . setStockArticleId ( distributionStockArticleDTO . getId ( ) ) ;
reservationPackageEntity . setPacketBarStatus ( ReservationPackageStatusConstant . xinzeng . getValue ( ) ) ;
reservationPackageEntity . setPacketBarCode ( p . getOrderPackageCode ( ) ) ;
reservationPackageEntity . setParceListId ( p . getId ( ) ) ;
reservationPackageEntity . setReservationId ( id ) ;
distributionReservationPackageService . save ( reservationPackageEntity ) ;
packageNum . getAndAdd ( p . getQuantity ( ) ) ;
DistributionParcelListEntity parcelListEntity = distributionParcelListService . getById ( p . getId ( ) ) ;
parcelListEntity . setOrderPackageReservationStatus ( OrderPackageReservationStatusConstant . yiyueyue . getValue ( ) ) ;
distributionParcelListService . updateById ( parcelListEntity ) ;
distributionAsyncService . checkStockArticleReservationStatus ( p ) ;
} ) ;
} else {
//添加此订单可用所有包件数量
//添加订单下的所有在库订单的包件
List < DistributionParcelListEntity > distributionParcelListEntities = distributionParcelListService . list ( Wrappers . < DistributionParcelListEntity > query ( ) . lambda ( ) . eq ( DistributionParcelListEntity : : getStockArticleId , distributionStockArticleDTO . getId ( ) )
. ne ( DistributionParcelListEntity : : getOrderPackageLoadingStatus , OrderPackageLoadingStatusConstant . yizhuangche . getValue ( ) )
. ne ( DistributionParcelListEntity : : getOrderPackageReservationStatus , OrderPackageReservationStatusConstant . yiyueyue . getValue ( ) )
. notIn ( DistributionParcelListEntity : : getOrderPackageStatus , new String [ ] { OrderPackageStatusConstant . yichuku . getValue ( ) , OrderPackageStatusConstant . yiqianshou . getValue ( ) } ) ) ;
distributionParcelListEntities . forEach ( dp - > {
if ( ! dp . getOrderPackageStatus ( ) . equals ( OrderPackageStatusConstant . yiqianshou . getValue ( ) ) ) {
if ( ! Func . equals ( dp . getOrderPackageFreezeStatus ( ) , OrderPackageFreezeStatusConstant . yidongjie . getValue ( ) ) & & ! Func . equals ( dp . getOrderPackageReservationStatus ( ) , OrderPackageReservationStatusConstant . yiyueyue . getValue ( ) ) ) {
DistributionReservationPackageEntity distributionReservationPackageEntity = new DistributionReservationPackageEntity ( ) ;
distributionReservationPackageEntity . setReservationId ( id ) ;
distributionReservationPackageEntity . setParceListId ( dp . getId ( ) ) ;
distributionReservationPackageEntity . setStockArticleId ( distributionStockArticleDTO . getId ( ) ) ;
distributionReservationPackageEntity . setPacketBarCode ( dp . getOrderPackageCode ( ) ) ;
//维护订单下包件信息
distributionReservationPackageService . save ( distributionReservationPackageEntity ) ;
//此时订单下的所有包件都处于预约状态,可用数为0
packageNum . getAndAdd ( dp . getQuantity ( ) ) ;
//修改订单下的包件状态
// p.setOrderPackageReservationStatus();
dp . setOrderPackageReservationStatus ( OrderPackageReservationStatusConstant . yiyueyue . getValue ( ) ) ;
distributionParcelListService . updateById ( dp ) ;
distributionAsyncService . checkStockArticleReservationStatus ( dp ) ;
}
}
// stockArticleEntity.setReservationStatus(OrderReservationStatusConstant.yiyueyue.getValue());
} ) ;
distributionStockArticleDTO . setReservationStatus ( OrderReservationStatusConstant . yiyueyue . getValue ( ) ) ;
distributionStockArticleDTO . setAvailableQuantity ( 0 ) ;
DistributionStockArticleEntity stockArticleEntity = Func . copy ( distributionStockArticleDTO , DistributionStockArticleEntity . class ) ;
distributionStockArticleService . updateById ( stockArticleEntity ) ;
}
} else {
//新增了零担订单
@ -1285,131 +1323,134 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
} else {
//查询出这个订单原来在这个预约中的勾选情况
DistributionStockArticleDTO distributionStockArticleDTO = v . get ( 0 ) ;
if ( distributionStockArticleDTO . getIsZero ( ) . equals ( IsOrNoConstant . no . getValue ( ) ) ) {
List < DistributionReservationPackageEntity > packageEntityList = distributionReservationPackageMapper . selectPackageByReservationAndStockArticleId ( id , k ) ;
Map < Long , List < DistributionReservationPackageEntity > > oldPackage = packageEntityList . stream ( ) . collect ( Collectors . groupingBy ( DistributionReservationPackageEntity : : getParceListId ) ) ;
Map < Long , List < DistributionParcelListEntity > > newPackage = distributionStockArticleDTO . getPackageListInfo ( ) . stream ( ) . collect ( Collectors . groupingBy ( DistributionParcelListEntity : : getId ) ) ;
AtomicInteger packageNum = new AtomicInteger ( ) ;
AtomicInteger reduceNum = new AtomicInteger ( ) ;
newPackage . forEach ( ( m , n ) - > {
if ( Func . isEmpty ( oldPackage . get ( m ) ) ) {
DistributionParcelListEntity distributionParcelListEntity = n . get ( 0 ) ;
//新增
DistributionReservationPackageEntity reservationPackageEntity = new DistributionReservationPackageEntity ( ) ;
reservationPackageEntity . setStockArticleId ( distributionStockArticleDTO . getId ( ) ) ;
reservationPackageEntity . setPacketBarStatus ( ReservationPackageStatusConstant . xinzeng . getValue ( ) ) ;
reservationPackageEntity . setPacketBarCode ( distributionParcelListEntity . getOrderPackageCode ( ) ) ;
reservationPackageEntity . setParceListId ( distributionParcelListEntity . getId ( ) ) ;
reservationPackageEntity . setReservationId ( id ) ;
distributionReservationPackageService . save ( reservationPackageEntity ) ;
packageNum . getAndAdd ( distributionParcelListEntity . getQuantity ( ) ) ;
DistributionParcelListEntity parcelListEntity = distributionParcelListService . getById ( distributionParcelListEntity . getId ( ) ) ;
parcelListEntity . setOrderPackageReservationStatus ( OrderPackageReservationStatusConstant . yiyueyue . getValue ( ) ) ;
if ( Func . isNotEmpty ( distributionStockArticleDTO . getPackageListInfo ( ) ) ) {
if ( distributionStockArticleDTO . getIsZero ( ) . equals ( IsOrNoConstant . no . getValue ( ) ) ) {
List < DistributionReservationPackageEntity > packageEntityList = distributionReservationPackageMapper . selectPackageByReservationAndStockArticleId ( id , k ) ;
Map < Long , List < DistributionReservationPackageEntity > > oldPackage = packageEntityList . stream ( ) . collect ( Collectors . groupingBy ( DistributionReservationPackageEntity : : getParceListId ) ) ;
Map < Long , List < DistributionParcelListEntity > > newPackage = distributionStockArticleDTO . getPackageListInfo ( ) . stream ( ) . collect ( Collectors . groupingBy ( DistributionParcelListEntity : : getId ) ) ;
AtomicInteger packageNum = new AtomicInteger ( ) ;
AtomicInteger reduceNum = new AtomicInteger ( ) ;
newPackage . forEach ( ( m , n ) - > {
if ( Func . isEmpty ( oldPackage . get ( m ) ) ) {
DistributionParcelListEntity distributionParcelListEntity = n . get ( 0 ) ;
//新增
DistributionReservationPackageEntity reservationPackageEntity = new DistributionReservationPackageEntity ( ) ;
reservationPackageEntity . setStockArticleId ( distributionStockArticleDTO . getId ( ) ) ;
reservationPackageEntity . setPacketBarStatus ( ReservationPackageStatusConstant . xinzeng . getValue ( ) ) ;
reservationPackageEntity . setPacketBarCode ( distributionParcelListEntity . getOrderPackageCode ( ) ) ;
reservationPackageEntity . setParceListId ( distributionParcelListEntity . getId ( ) ) ;
reservationPackageEntity . setReservationId ( id ) ;
distributionReservationPackageService . save ( reservationPackageEntity ) ;
packageNum . getAndAdd ( distributionParcelListEntity . getQuantity ( ) ) ;
DistributionParcelListEntity parcelListEntity = distributionParcelListService . getById ( distributionParcelListEntity . getId ( ) ) ;
parcelListEntity . setOrderPackageReservationStatus ( OrderPackageReservationStatusConstant . yiyueyue . getValue ( ) ) ;
distributionParcelListService . updateById ( parcelListEntity ) ;
} else {
oldPackage . remove ( m ) ;
//移除
}
} ) ;
//移除包件进行取消
oldPackage . forEach ( ( o , p ) - > {
DistributionReservationPackageEntity reservationPackageEntity = p . get ( 0 ) ;
reservationPackageEntity . setPacketBarStatus ( ReservationPackageStatusConstant . quxiao . getValue ( ) ) ;
distributionReservationPackageService . updateById ( reservationPackageEntity ) ;
//统计减少包件数量
reduceNum . getAndAdd ( distributionParcelListService . getById ( reservationPackageEntity . getParceListId ( ) ) . getQuantity ( ) ) ;
DistributionParcelListEntity parcelListEntity = distributionParcelListService . getById ( reservationPackageEntity . getParceListId ( ) ) ;
parcelListEntity . setOrderPackageReservationStatus ( OrderPackageReservationStatusConstant . daiyuyue . getValue ( ) ) ;
distributionParcelListService . updateById ( parcelListEntity ) ;
} else {
oldPackage . remove ( m ) ;
//移除
}
} ) ;
//移除包件进行取消
oldPackage . forEach ( ( o , p ) - > {
DistributionReservationPackageEntity reservationPackageEntity = p . get ( 0 ) ;
reservationPackageEntity . setPacketBarStatus ( ReservationPackageStatusConstant . quxiao . getValue ( ) ) ;
distributionReservationPackageService . updateById ( reservationPackageEntity ) ;
//统计减少包件数量
reduceNum . getAndAdd ( distributionParcelListService . getById ( reservationPackageEntity . getParceListId ( ) ) . getQuantity ( ) ) ;
DistributionParcelListEntity parcelListEntity = distributionParcelListService . getById ( reservationPackageEntity . getParceListId ( ) ) ;
parcelListEntity . setOrderPackageReservationStatus ( OrderPackageReservationStatusConstant . daiyuyue . getValue ( ) ) ;
distributionParcelListService . updateById ( parcelListEntity ) ;
} ) ;
//对存在订单进行维护
DistributionReservationStockarticleEntity reservationStockarticleEntity = oldStockArticle . get ( k ) . get ( 0 ) ;
Integer reservationNum = reservationStockarticleEntity . getReservationNum ( ) ;
reservationStockarticleEntity . setReservationNum ( reservationNum + packageNum . get ( ) - reduceNum . get ( ) ) ;
distributionReservationStockarticleService . updateById ( reservationStockarticleEntity ) ;
packTotal . getAndAdd ( reservationStockarticleEntity . getReservationNum ( ) ) ;
} ) ;
//对存在订单进行维护
DistributionReservationStockarticleEntity reservationStockarticleEntity = oldStockArticle . get ( k ) . get ( 0 ) ;
Integer reservationNum = reservationStockarticleEntity . getReservationNum ( ) ;
reservationStockarticleEntity . setReservationNum ( reservationNum + packageNum . get ( ) - reduceNum . get ( ) ) ;
distributionReservationStockarticleService . updateById ( reservationStockarticleEntity ) ;
packTotal . getAndAdd ( reservationStockarticleEntity . getReservationNum ( ) ) ;
// oldStockArticle.remove(k);
distributionAsyncService . changeOrderReservationStatus ( distributionStockArticleDTO ) ;
oldStockArticle . remove ( k ) ;
} else {
//零担订单出现编辑操作,这里对于零担订单发生编辑操作一定会存在有录入数量的操作
List < DistributionParcelNumberVO > parcelNumberVOS = distributionStockArticleDTO . getParcelNumberVOS ( ) ;
List < DistributionReservationZeroPackageEntity > reservationZeroPackageEntityList = distributionReservationZeroPackageService . list ( Wrappers . < DistributionReservationZeroPackageEntity > query ( ) . lambda ( )
. eq ( DistributionReservationZeroPackageEntity : : getReservationId , id )
. eq ( DistributionReservationZeroPackageEntity : : getStockArticleId , distributionStockArticleDTO . getId ( ) )
. ne ( DistributionReservationZeroPackageEntity : : getZeroPackageStatus , "2" ) ) ;
Map < Long , List < DistributionReservationZeroPackageEntity > > oldZeroPackage = reservationZeroPackageEntityList . stream ( ) . collect ( Collectors . groupingBy ( DistributionReservationZeroPackageEntity : : getParcelListId ) ) ;
if ( Func . isEmpty ( reservationZeroPackageEntityList ) ) {
log . error ( "#############零担订单预约信息数据错误:{}" , distributionStockArticleDTO ) ;
}
AtomicInteger zeroPrderNum = new AtomicInteger ( ) ;
parcelNumberVOS . forEach ( p - > {
List < DistributionReservationZeroPackageEntity > distributionReservationZeroPackageEntities = oldZeroPackage . get ( p . getParcelListId ( ) ) ;
if ( Func . isNotEmpty ( distributionReservationZeroPackageEntities ) ) {
DistributionReservationZeroPackageEntity distributionReservationZeroPackageEntity = distributionReservationZeroPackageEntities . get ( 0 ) ;
Integer quantity = distributionReservationZeroPackageEntity . getQuantity ( ) ;
if ( p . getReservationNum ( ) = = 0 ) {
distributionReservationZeroPackageEntity . setQuantity ( 0 ) ;
distributionReservationZeroPackageEntity . setZeroPackageStatus ( ReservationOrderStatusConstant . quxiao . getValue ( ) ) ;
distributionReservationZeroPackageService . updateById ( distributionReservationZeroPackageEntity ) ;
DistributionParcelNumberEntity parcelNumberEntity = distributionParcelNumberService . getOne ( Wrappers . < DistributionParcelNumberEntity > query ( ) . lambda ( )
. eq ( DistributionParcelNumberEntity : : getParcelListId , distributionReservationZeroPackageEntity . getParcelListId ( ) ) ) ;
parcelNumberEntity . setDeliveryQuantity ( parcelNumberEntity . getDeliveryQuantity ( ) - quantity ) ;
distributionParcelNumberService . updateById ( parcelNumberEntity ) ;
} else if ( p . getReservationNum ( ) ! = quantity ) {
distributionReservationZeroPackageEntity . setQuantity ( p . getReservationNum ( ) ) ;
distributionReservationZeroPackageService . updateById ( distributionReservationZeroPackageEntity ) ;
//进行修改操作
distributionAsyncService . changeOrderReservationStatus ( distributionStockArticleDTO ) ;
oldStockArticle . remove ( k ) ;
} else {
//零担订单出现编辑操作,这里对于零担订单发生编辑操作一定会存在有录入数量的操作
List < DistributionParcelNumberVO > parcelNumberVOS = distributionStockArticleDTO . getParcelNumberVOS ( ) ;
List < DistributionReservationZeroPackageEntity > reservationZeroPackageEntityList = distributionReservationZeroPackageService . list ( Wrappers . < DistributionReservationZeroPackageEntity > query ( ) . lambda ( )
. eq ( DistributionReservationZeroPackageEntity : : getReservationId , id )
. eq ( DistributionReservationZeroPackageEntity : : getStockArticleId , distributionStockArticleDTO . getId ( ) )
. ne ( DistributionReservationZeroPackageEntity : : getZeroPackageStatus , "2" ) ) ;
Map < Long , List < DistributionReservationZeroPackageEntity > > oldZeroPackage = reservationZeroPackageEntityList . stream ( ) . collect ( Collectors . groupingBy ( DistributionReservationZeroPackageEntity : : getParcelListId ) ) ;
if ( Func . isEmpty ( reservationZeroPackageEntityList ) ) {
log . error ( "#############零担订单预约信息数据错误:{}" , distributionStockArticleDTO ) ;
}
AtomicInteger zeroPrderNum = new AtomicInteger ( ) ;
parcelNumberVOS . forEach ( p - > {
List < DistributionReservationZeroPackageEntity > distributionReservationZeroPackageEntities = oldZeroPackage . get ( p . getParcelListId ( ) ) ;
if ( Func . isNotEmpty ( distributionReservationZeroPackageEntities ) ) {
DistributionReservationZeroPackageEntity distributionReservationZeroPackageEntity = distributionReservationZeroPackageEntities . get ( 0 ) ;
Integer quantity = distributionReservationZeroPackageEntity . getQuantity ( ) ;
if ( p . getReservationNum ( ) = = 0 ) {
distributionReservationZeroPackageEntity . setQuantity ( 0 ) ;
distributionReservationZeroPackageEntity . setZeroPackageStatus ( ReservationOrderStatusConstant . quxiao . getValue ( ) ) ;
distributionReservationZeroPackageService . updateById ( distributionReservationZeroPackageEntity ) ;
DistributionParcelNumberEntity parcelNumberEntity = distributionParcelNumberService . getOne ( Wrappers . < DistributionParcelNumberEntity > query ( ) . lambda ( )
. eq ( DistributionParcelNumberEntity : : getParcelListId , distributionReservationZeroPackageEntity . getParcelListId ( ) ) ) ;
parcelNumberEntity . setDeliveryQuantity ( parcelNumberEntity . getDeliveryQuantity ( ) - quantity ) ;
distributionParcelNumberService . updateById ( parcelNumberEntity ) ;
} else if ( p . getReservationNum ( ) ! = quantity ) {
distributionReservationZeroPackageEntity . setQuantity ( p . getReservationNum ( ) ) ;
distributionReservationZeroPackageService . updateById ( distributionReservationZeroPackageEntity ) ;
//进行修改操作
DistributionParcelNumberEntity parcelNumberEntity = distributionParcelNumberService . getOne ( Wrappers . < DistributionParcelNumberEntity > query ( ) . lambda ( )
. eq ( DistributionParcelNumberEntity : : getParcelListId , distributionReservationZeroPackageEntity . getParcelListId ( ) ) ) ;
parcelNumberEntity . setDeliveryQuantity ( parcelNumberEntity . getDeliveryQuantity ( ) - quantity + p . getReservationNum ( ) ) ;
distributionParcelNumberService . updateById ( parcelNumberEntity ) ;
}
zeroPrderNum . getAndAdd ( distributionReservationZeroPackageEntity . getQuantity ( ) ) ;
} else {
//这里就是新增
DistributionReservationZeroPackageEntity zeroPackageEntity = new DistributionReservationZeroPackageEntity ( ) ;
zeroPackageEntity . setParcelListId ( p . getParcelListId ( ) ) ;
zeroPackageEntity . setCategoryName ( p . getFirsts ( ) ) ;
zeroPackageEntity . setQuantity ( p . getReservationNum ( ) ) ;
zeroPackageEntity . setZeroPackageStatus ( ReservationOrderStatusConstant . zengjia . getValue ( ) ) ;
zeroPackageEntity . setType ( DistributionTypeConstant . shipie . getValue ( ) ) ;
zeroPackageEntity . setReservationId ( id ) ;
zeroPackageEntity . setStockArticleId ( distributionStockArticleDTO . getId ( ) ) ;
distributionReservationZeroPackageService . save ( zeroPackageEntity ) ;
DistributionReservationStockarticleEntity reservationStockarticleEntity = distributionReservationStockarticleService . getOne ( Wrappers . < DistributionReservationStockarticleEntity > query ( ) . lambda ( )
. eq ( DistributionReservationStockarticleEntity : : getReservationId , id )
. eq ( DistributionReservationStockarticleEntity : : getStockArticleId , distributionStockArticleDTO . getId ( ) )
. ne ( DistributionReservationStockarticleEntity : : getStockArticleStatus , ReservationOrderStatusConstant . quxiao . getValue ( ) ) ) ;
reservationStockarticleEntity . setReservationNum ( reservationStockarticleEntity . getReservationNum ( ) + zeroPackageEntity . getQuantity ( ) ) ;
distributionReservationStockarticleService . updateById ( reservationStockarticleEntity ) ;
//维护具体的零担订单品类数量
DistributionParcelNumberEntity parcelNumberEntity = distributionParcelNumberService . getOne ( Wrappers . < DistributionParcelNumberEntity > query ( ) . lambda ( )
. eq ( DistributionParcelNumberEntity : : getParcelListId , distributionReservationZeroPackageEntity . getParcelListId ( ) ) ) ;
parcelNumberEntity . setDeliveryQuantity ( parcelNumberEntity . getDeliveryQuantity ( ) - quantity + p . getReservationNum ( ) ) ;
. eq ( DistributionParcelNumberEntity : : getParcelListId , p . getParcelListId ( ) ) ) ;
parcelNumberEntity . setDeliveryQuantity ( parcelNumberEntity . getDeliveryQuantity ( ) + zeroPackageEntity . getQuantity ( ) ) ;
distributionParcelNumberService . updateById ( parcelNumberEntity ) ;
}
zeroPrderNum . getAndAdd ( distributionReservationZeroPackageEntity . getQuantity ( ) ) ;
} else {
//这里就是新增
DistributionReservationZeroPackageEntity zeroPackageEntity = new DistributionReservationZeroPackageEntity ( ) ;
zeroPackageEntity . setParcelListId ( p . getParcelListId ( ) ) ;
zeroPackageEntity . setCategoryName ( p . getFirsts ( ) ) ;
zeroPackageEntity . setQuantity ( p . getReservationNum ( ) ) ;
zeroPackageEntity . setZeroPackageStatus ( ReservationOrderStatusConstant . zengjia . getValue ( ) ) ;
zeroPackageEntity . setType ( DistributionTypeConstant . shipie . getValue ( ) ) ;
zeroPackageEntity . setReservationId ( id ) ;
zeroPackageEntity . setStockArticleId ( distributionStockArticleDTO . getId ( ) ) ;
distributionReservationZeroPackageService . save ( zeroPackageEntity ) ;
DistributionReservationStockarticleEntity reservationStockarticleEntity = distributionReservationStockarticleService . getOne ( Wrappers . < DistributionReservationStockarticleEntity > query ( ) . lambda ( )
. eq ( DistributionReservationStockarticleEntity : : getReservationId , id )
. eq ( DistributionReservationStockarticleEntity : : getStockArticleId , distributionStockArticleDTO . getId ( ) )
. ne ( DistributionReservationStockarticleEntity : : getStockArticleStatus , ReservationOrderStatusConstant . quxiao . getValue ( ) ) ) ;
reservationStockarticleEntity . setReservationNum ( reservationStockarticleEntity . getReservationNum ( ) + zeroPackageEntity . getQuantity ( ) ) ;
distributionReservationStockarticleService . updateById ( reservationStockarticleEntity ) ;
//维护具体的零担订单品类数量
DistributionParcelNumberEntity parcelNumberEntity = distributionParcelNumberService . getOne ( Wrappers . < DistributionParcelNumberEntity > query ( ) . lambda ( )
. eq ( DistributionParcelNumberEntity : : getParcelListId , p . getParcelListId ( ) ) ) ;
parcelNumberEntity . setDeliveryQuantity ( parcelNumberEntity . getDeliveryQuantity ( ) + zeroPackageEntity . getQuantity ( ) ) ;
distributionParcelNumberService . updateById ( parcelNumberEntity ) ;
zeroPrderNum . getAndAdd ( zeroPackageEntity . getQuantity ( ) ) ;
zeroPrderNum . getAndAdd ( zeroPackageEntity . getQuantity ( ) ) ;
}
//考虑情况:1、数量发生修改 2、数量修改为0表示取消该零担订单对应的品类 3、该零担订单新增品类
//该零担订单原有的品类信息
} ) ;
DistributionReservationStockarticleEntity reservationStockarticleEntity = oldStockArticle . get ( k ) . get ( 0 ) ;
reservationStockarticleEntity . setReservationNum ( zeroPrderNum . get ( ) ) ;
distributionReservationStockarticleService . updateById ( reservationStockarticleEntity ) ;
packTotal . getAndAdd ( reservationStockarticleEntity . getReservationNum ( ) ) ;
}
//考虑情况:1、数量发生修改 2、数量修改为0表示取消该零担订单对应的品类 3、该零担订单新增品类
//该零担订单原有的品类信息
} ) ;
DistributionReservationStockarticleEntity reservationStockarticleEntity = oldStockArticle . get ( k ) . get ( 0 ) ;
reservationStockarticleEntity . setReservationNum ( zeroPrderNum . get ( ) ) ;
distributionReservationStockarticleService . updateById ( reservationStockarticleEntity ) ;
packTotal . getAndAdd ( reservationStockarticleEntity . getReservationNum ( ) ) ;
// oldStockArticle.remove(k);
distributionAsyncService . changeOrderReservationStatus ( distributionStockArticleDTO ) ;
oldStockArticle . remove ( k ) ;
}
warehouseNames . add ( distributionStockArticleDTO . getWarehouse ( ) ) ;
mallName . add ( distributionStockArticleDTO . getMallName ( ) ) ;
storeName . add ( distributionStockArticleDTO . getStoreName ( ) ) ;
receivingUnit . add ( distributionStockArticleDTO . getConsigneeUnit ( ) ) ;
distributionAsyncService . changeOrderReservationStatus ( distributionStockArticleDTO ) ;
oldStockArticle . remove ( k ) ;
}
warehouseNames . add ( distributionStockArticleDTO . getWarehouse ( ) ) ;
mallName . add ( distributionStockArticleDTO . getMallName ( ) ) ;
storeName . add ( distributionStockArticleDTO . getStoreName ( ) ) ;
receivingUnit . add ( distributionStockArticleDTO . getConsigneeUnit ( ) ) ;
// DistributionStockArticleEntity stockArticleEntity = distributionStockArticleService.getById(distributionStockArticleDTO.getId());
// stockArticleEntity.setReservationStatus(status);
// distributionStockArticleService.updateById(stockArticleEntity);
}
}
} ) ;
@ -1427,7 +1468,6 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
parcelListEntity . setOrderPackageReservationStatus ( OrderPackageReservationStatusConstant . daiyuyue . getValue ( ) ) ;
distributionParcelListService . updateById ( parcelListEntity ) ;
} ) ;
} else {
//订单零担移除
List < DistributionReservationZeroPackageEntity > reservationZeroPackageEntities = distributionReservationZeroPackageService . list ( Wrappers . < DistributionReservationZeroPackageEntity > query ( ) . lambda ( )
@ -1784,8 +1824,8 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
AtomicInteger reservationOrderNum = new AtomicInteger ( ) ;
if ( s . getIsZero ( ) . equals ( IsOrNoConstant . no . getValue ( ) ) ) {
//现在前端进行订单提交必然会携带包件信息
List < DistributionParcelListDTO > packageListInfo = s . getPackageListInfo ( ) ;
if ( packageListInfo . size ( ) > 0 ) {
if ( Func . isNotEmpty ( s . getPackageListInfo ( ) ) ) {
List < DistributionParcelListDTO > packageListInfo = s . getPackageListInfo ( ) ;
packageListInfo . forEach ( p - > {
reservationOrderNum . getAndAdd ( p . getQuantity ( ) ) ;
DistributionReservationPackageEntity reservationPackageEntity = new DistributionReservationPackageEntity ( ) ;
@ -1800,11 +1840,40 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
//这里根据包件进行订单状态的改变
distributionAsyncService . checkStockArticleReservationStatus ( p ) ;
} ) ;
} else {
log . error ( "订单包件参数有误+{" + packageListInfo + "}" ) ;
return ;
}
} else {
//没有进行包件选择 默认添加可配送的所有包件
//添加订单下的所有在库订单的包件
List < DistributionParcelListEntity > distributionParcelListEntities = distributionParcelListService . list ( Wrappers . < DistributionParcelListEntity > query ( ) . lambda ( ) . eq ( DistributionParcelListEntity : : getStockArticleId , s . getId ( ) )
. ne ( DistributionParcelListEntity : : getOrderPackageLoadingStatus , OrderPackageLoadingStatusConstant . yizhuangche . getValue ( ) )
. ne ( DistributionParcelListEntity : : getOrderPackageReservationStatus , OrderPackageReservationStatusConstant . yiyueyue . getValue ( ) )
. notIn ( DistributionParcelListEntity : : getOrderPackageStatus , new String [ ] { OrderPackageStatusConstant . yichuku . getValue ( ) , OrderPackageStatusConstant . yiqianshou . getValue ( ) } ) ) ;
distributionParcelListEntities . forEach ( dp - > {
if ( ! dp . getOrderPackageStatus ( ) . equals ( OrderPackageStatusConstant . yiqianshou . getValue ( ) ) ) {
if ( ! Func . equals ( dp . getOrderPackageFreezeStatus ( ) , OrderPackageFreezeStatusConstant . yidongjie . getValue ( ) ) & & ! Func . equals ( dp . getOrderPackageReservationStatus ( ) , OrderPackageReservationStatusConstant . yiyueyue . getValue ( ) ) ) {
DistributionReservationPackageEntity distributionReservationPackageEntity = new DistributionReservationPackageEntity ( ) ;
distributionReservationPackageEntity . setReservationId ( reservationEntity . getId ( ) ) ;
distributionReservationPackageEntity . setParceListId ( dp . getId ( ) ) ;
distributionReservationPackageEntity . setStockArticleId ( s . getId ( ) ) ;
distributionReservationPackageEntity . setPacketBarCode ( dp . getOrderPackageCode ( ) ) ;
//维护订单下包件信息
distributionReservationPackageService . save ( distributionReservationPackageEntity ) ;
//此时订单下的所有包件都处于预约状态,可用数为0
reservationOrderNum . getAndAdd ( dp . getQuantity ( ) ) ;
//修改订单下的包件状态
// p.setOrderPackageReservationStatus();
dp . setOrderPackageReservationStatus ( OrderPackageReservationStatusConstant . yiyueyue . getValue ( ) ) ;
distributionParcelListService . updateById ( dp ) ;
distributionAsyncService . checkStockArticleReservationStatus ( dp ) ;
}
}
// stockArticleEntity.setReservationStatus(OrderReservationStatusConstant.yiyueyue.getValue());
} ) ;
s . setReservationStatus ( OrderReservationStatusConstant . yiyueyue . getValue ( ) ) ;
s . setAvailableQuantity ( 0 ) ;
distributionStockArticleService . updateById ( s ) ;
}
} else {
//-----------------------------------------------------------2023-10-11--- 零担商配处理-----------------------------------------------------------------------
List < DistributionParcelNumberVO > parcelNumberVOS = s . getParcelNumberVOS ( ) ;
@ -1813,7 +1882,7 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
parcelNumberVOS . forEach ( p - > {
DistributionReservationZeroPackageEntity distributionReservationZeroPackageEntity = new DistributionReservationZeroPackageEntity ( ) ;
distributionReservationZeroPackageEntity . setZeroPackageStatus ( ReservationOrderStatusConstant . zhengchang . getValue ( ) ) ;
distributionReservationZeroPackageEntity . setQuantity ( p . getHandQuantity ( ) - p . getDeliveryQuantity ( ) - p . getOutboundQuantity ( ) ) ;
distributionReservationZeroPackageEntity . setQuantity ( p . getReservationNum ( ) ) ;
distributionReservationZeroPackageEntity . setStockArticleId ( s . getId ( ) ) ;
distributionReservationZeroPackageEntity . setReservationId ( reservationEntity . getId ( ) ) ;
distributionReservationZeroPackageEntity . setType ( DistributionTypeConstant . shangpei . getValue ( ) ) ;
@ -1953,6 +2022,12 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
} ) ;
distributionDeliveryListEntity . setDistributionCompany ( "汇通" ) ;
distributionDeliveryListEntity . setKind ( ServiceConstant . DELIVERLIST_KIND_SELF ) ;
if ( Func . isEmpty ( driverNames ) ) {
return R . fail ( "请选择配送人员信息!!!" ) ;
}
if ( Func . isEmpty ( vehicleNubs ) ) {
return R . fail ( "请选择配送人员信息!!!" ) ;
}
distributionDeliveryListEntity . setDriverName ( driverNames . deleteCharAt ( driverNames . length ( ) - 1 ) . toString ( ) ) ;
distributionDeliveryListEntity . setVehicleName ( vehicleNubs . deleteCharAt ( vehicleNubs . length ( ) - 1 ) . toString ( ) ) ;
}
@ -2653,22 +2728,24 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
. ne ( DistributionParcelListEntity : : getOrderPackageLoadingStatus , OrderPackageLoadingStatusConstant . yizhuangche . getValue ( ) )
. ne ( DistributionParcelListEntity : : getOrderPackageReservationStatus , OrderPackageReservationStatusConstant . yiyueyue . getValue ( ) )
. notIn ( DistributionParcelListEntity : : getOrderPackageStatus , new String [ ] { OrderPackageStatusConstant . yichuku . getValue ( ) , OrderPackageStatusConstant . yiqianshou . getValue ( ) } ) ) ;
distributionParcelListEntities . forEach ( p - > {
if ( p . getOrderPackageStatus ( ) . equals ( OrderPackageStatusConstant . yiqianshou . getValue ( ) ) ) {
if ( ! Func . equals ( p . getOrderPackageFreezeStatus ( ) , OrderPackageFreezeStatusConstant . yidongjie . getValue ( ) ) & & ! Func . equals ( p . getOrderPackageReservationStatus ( ) , OrderPackageReservationStatusConstant . yiyueyue . getValue ( ) ) ) {
distributionParcelListEntities . forEach ( d p - > {
if ( ! d p. getOrderPackageStatus ( ) . equals ( OrderPackageStatusConstant . yiqianshou . getValue ( ) ) ) {
if ( ! Func . equals ( d p. getOrderPackageFreezeStatus ( ) , OrderPackageFreezeStatusConstant . yidongjie . getValue ( ) ) & & ! Func . equals ( d p. getOrderPackageReservationStatus ( ) , OrderPackageReservationStatusConstant . yiyueyue . getValue ( ) ) ) {
DistributionReservationPackageEntity distributionReservationPackageEntity = new DistributionReservationPackageEntity ( ) ;
distributionReservationPackageEntity . setReservationId ( reservationId ) ;
distributionReservationPackageEntity . setParceListId ( p . getId ( ) ) ;
distributionReservationPackageEntity . setParceListId ( d p. getId ( ) ) ;
distributionReservationPackageEntity . setStockArticleId ( s . getId ( ) ) ;
distributionReservationPackageEntity . setPacketBarCode ( p . getOrderPackageCode ( ) ) ;
distributionReservationPackageEntity . setPacketBarCode ( d p. getOrderPackageCode ( ) ) ;
//维护订单下包件信息
distributionReservationPackageService . save ( distributionReservationPackageEntity ) ;
//此时订单下的所有包件都处于预约状态,可用数为0
packageNum . getAndAdd ( p . getQuantity ( ) ) ;
packageNum . getAndAdd ( d p. getQuantity ( ) ) ;
//修改订单下的包件状态
// p.setOrderPackageReservationStatus();
p . setOrderPackageReservationStatus ( OrderPackageReservationStatusConstant . yiyueyue . getValue ( ) ) ;
distributionParcelListService . updateById ( p ) ;
dp . setOrderPackageReservationStatus ( OrderPackageReservationStatusConstant . yiyueyue . getValue ( ) ) ;
distributionParcelListService . updateById ( dp ) ;
distributionAsyncService . checkStockArticleReservationStatus ( dp ) ;
}
}
@ -2676,6 +2753,8 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
} ) ;
s . setReservationStatus ( OrderReservationStatusConstant . yiyueyue . getValue ( ) ) ;
s . setAvailableQuantity ( 0 ) ;
distributionStockArticleService . updateById ( s ) ;
} else {
//维护选中的包件信息
packageList . forEach ( p - > {
@ -2691,6 +2770,8 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
p . setOrderPackageReservationStatus ( OrderPackageReservationStatusConstant . yiyueyue . getValue ( ) ) ;
// p.setBrandId(p.getBrandId());
distributionParcelListService . updateById ( p ) ;
distributionAsyncService . checkStockArticleReservationStatus ( p ) ;
}
}
} ) ;
@ -2698,17 +2779,16 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
//设置订单可用数量为
// s.setAvailableQuantity(s.getHandQuantity() - s.getReservationNum());
//这里查询到当前订单下的包件信息和选中包件进行比对,如果数量一致那么说明该订单是已预约状态、否则为部分预约状态
LambdaQueryWrapper < DistributionParcelListEntity > qw = new QueryWrapper < DistributionParcelListEntity > ( ) . lambda ( ) . eq ( DistributionParcelListEntity : : getStockArticleId , s . getId ( ) ) ;
List < DistributionParcelListEntity > parcelListEntities = distributionParcelListService . getBaseMapper ( ) . selectList ( qw ) ;
if ( packageList . size ( ) = = parcelListEntities . size ( ) ) {
//这里就是表示进行了包件选取的操作,但是选取的包件数量为全部
s . setReservationStatus ( OrderReservationStatusConstant . yiyueyue . getValue ( ) ) ;
} else {
s . setReservationStatus ( OrderReservationStatusConstant . bufenyuyue . getValue ( ) ) ;
}
// LambdaQueryWrapper<DistributionParcelListEntity> qw = new QueryWrapper<DistributionParcelListEntity>().lambda().eq(DistributionParcelListEntity::getStockArticleId, s.getId());
// List<DistributionParcelListEntity> parcelListEntities = distributionParcelListService.getBaseMapper().selectList(qw);
// if (packageList.size() == parcelListEntities.size()) {
// //这里就是表示进行了包件选取的操作,但是选取的包件数量为全部
// s.setReservationStatus(OrderReservationStatusConstant.yiyueyue.getValue());
// } else {
// s.setReservationStatus(OrderReservationStatusConstant.bufenyuyue.getValue());
// }
}
distributionReservationStockarticleEntity . setReservationNum ( packageNum . get ( ) ) ;
distributionStockArticleService . updateById ( s ) ;
Long stockArticleId = s . getId ( ) ;
distributionReservationStockarticleEntity . setReservationId ( reservationId ) ;
distributionReservationStockarticleEntity . setIsZero ( s . getIsZero ( ) ) ;
@ -2943,4 +3023,34 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
} ) ;
return zeroOrderDetail ;
}
@Override
public R getReservationPackageListByOrderId ( Long orderId , Long reservationId , IPage < DistributionReservationOrderPackageVO > page ) {
List < DistributionParcelListVO > allPackageList = new ArrayList < > ( ) ;
List < DistributionReservationPackageEntity > reservationPackageEntityList = distributionReservationPackageService . list ( Wrappers . < DistributionReservationPackageEntity > query ( ) . lambda ( ) . eq ( DistributionReservationPackageEntity : : getReservationId , reservationId ) . eq ( DistributionReservationPackageEntity : : getStockArticleId , orderId ) . ne ( DistributionReservationPackageEntity : : getPacketBarStatus , ReservationPackageStatusConstant . quxiao . getValue ( ) ) ) ;
DistributionReservationOrderPackageVO reservationOrderPackageVO = new DistributionReservationOrderPackageVO ( ) ;
List < DistributionParcelListEntity > parcelListEntities = distributionParcelListService . list ( Wrappers . < DistributionParcelListEntity > query ( ) . lambda ( ) . eq ( DistributionParcelListEntity : : getStockArticleId , orderId )
. eq ( DistributionParcelListEntity : : getOrderPackageReservationStatus , OrderPackageReservationStatusConstant . daiyuyue . getValue ( ) )
. notIn ( DistributionParcelListEntity : : getOrderPackageStatus , OrderPackageStatusConstant . yiqianshou . getValue ( ) , OrderPackageStatusConstant . yichuku . getValue ( ) ) ) ;
if ( Func . isNotEmpty ( reservationPackageEntityList ) ) {
List < Long > packageIds = reservationPackageEntityList . stream ( ) . map ( DistributionReservationPackageEntity : : getParceListId ) . collect ( Collectors . toList ( ) ) ;
List < DistributionParcelListEntity > reservationPackageList = distributionParcelListService . listByIds ( packageIds ) ;
String packageListIds = reservationPackageEntityList . stream ( ) . map ( DistributionReservationPackageEntity : : getParceListId ) . map ( String : : valueOf ) . collect ( Collectors . joining ( "," ) ) ;
List < DistributionParcelListVO > parcelListVOS = DistributionParcelListWrapper . build ( ) . listVO ( reservationPackageList ) ;
allPackageList . addAll ( parcelListVOS ) ;
reservationOrderPackageVO . setReservationPackageList ( parcelListVOS ) ;
reservationOrderPackageVO . setPackageListIds ( packageListIds ) ;
}
if ( Func . isNotEmpty ( parcelListEntities ) ) {
allPackageList . addAll ( DistributionParcelListWrapper . build ( ) . listVO ( parcelListEntities ) ) ;
}
if ( Func . isEmpty ( allPackageList ) ) {
log . error ( "###########################包件查询结果异常:{}" , allPackageList ) ;
return null ;
}
reservationOrderPackageVO . setPackageList ( allPackageList ) ;
return R . data ( reservationOrderPackageVO ) ;
}
}