@ -241,6 +241,8 @@ public class DistributionStockupServiceImpl extends BaseServiceImpl<Distribution
private IBasicMaterialClient basicMaterialClient ;
@Override
public IPage < DistributionStockupVO > selectDistributionStockupPage ( IPage < DistributionStockupVO > page , DistributionStockupVO distributionStockup ) {
return page . setRecords ( baseMapper . selectDistributionStockupPage ( page , distributionStockup ) ) ;
@ -1778,7 +1780,8 @@ public class DistributionStockupServiceImpl extends BaseServiceImpl<Distribution
if ( ObjectUtils . isNotNull ( one ) & & "3" . equals ( one . getStockUpType ( ) ) ) {
//自提
//通过预约单id和订单
Integer num = distributionReservationService . getReservationNumStockSelf ( reservationId , stockListId ) ;
// Integer num = distributionReservationService.getReservationNumStockSelf(reservationId, stockListId);
Integer num = distrilbutionBillLadingMapper . getPlanInventoryNumByInventoryId ( reservationId , stockListId ) ;
if ( packageNum . compareTo ( num ) > 0 ) {
log . warn ( "###################createPackageCode: 包条数量与预约数量不正确" ) ;
throw new CustomerException ( 405 , "包条数量与预约数量不正确" ) ;
@ -2358,8 +2361,6 @@ public class DistributionStockupServiceImpl extends BaseServiceImpl<Distribution
//查询仓库信息 库存品信息
DistributionStockListEntity byId = distributionStockListService . getById ( stockupDTO . getStockListId ( ) ) ;
//有 绑定 查询有没有库存品信息
List < DisStockListDetailEntity > list1 = disStockListDetailService . list ( Wrappers . < DisStockListDetailEntity > query ( ) . lambda ( )
. eq ( DisStockListDetailEntity : : getStockListId , stockupDTO . getStockListId ( ) )
. eq ( DisStockListDetailEntity : : getReservationId , stockupDTO . getReservationId ( ) )
@ -3949,6 +3950,7 @@ public class DistributionStockupServiceImpl extends BaseServiceImpl<Distribution
Long stockupId = stockupDTO . getStockupId ( ) ; //备货区
Long allocationId = stockupDTO . getAllocationId ( ) ; //备货区
Integer stockPrint = stockupDTO . getStockPrint ( ) ; // 库存
BasicdataWarehouseEntity myCurrentWarehouse = basicdataWarehouseClient . getMyCurrentWarehouse ( ) ;
if ( Func . isEmpty ( myCurrentWarehouse ) ) {
return R . data ( 403 , "未授权!!!" ) ;
@ -4015,13 +4017,6 @@ public class DistributionStockupServiceImpl extends BaseServiceImpl<Distribution
. map ( DistributionReservationStocklistEntity : : getStocklistId )
. anyMatch ( s - > s . equals ( finalById . getId ( ) ) ) ;
if ( ! flag ) {
DistributionReservationStocklistEntity rs = getDistributionReservationStocklistEntity ( stockupDTO , byId ) ;
distributionReservationStocklistService . save ( rs ) ;
DistributionStockListEntity stockListEntity = distributionStockListService . getById ( byId . getId ( ) ) ;
stockListEntity . setQuantityOccupied ( stockListEntity . getQuantityOccupied ( ) + 1 ) ;
distributionStockListService . updateById ( stockListEntity ) ;
//原来对应的需要进行计划减少
//收集满足修改条件的计划库存品
List < DistributionReservationStocklistEntity > reservationStocklistEntities = new ArrayList < > ( ) ;
@ -4033,6 +4028,15 @@ public class DistributionStockupServiceImpl extends BaseServiceImpl<Distribution
if ( Func . isEmpty ( reservationStocklistEntities ) ) {
return R . fail ( "该物料库存品备货已完成" ) ;
}
DistributionReservationStocklistEntity rs = getDistributionReservationStocklistEntity ( stockupDTO , byId ) ;
distributionReservationStocklistService . save ( rs ) ;
DistributionStockListEntity stockListEntity = distributionStockListService . getById ( byId . getId ( ) ) ;
stockListEntity . setQuantityOccupied ( stockListEntity . getQuantityOccupied ( ) + 1 ) ;
distributionStockListService . updateById ( stockListEntity ) ;
DistributionReservationStocklistEntity reservationStocklistEntity = reservationStocklistEntities . get ( 0 ) ;
int oldRsNum = reservationStocklistEntity . getReservationNum ( ) - 1 ;
if ( oldRsNum < 0 ) {
@ -4118,6 +4122,121 @@ public class DistributionStockupServiceImpl extends BaseServiceImpl<Distribution
}
}
//当前库位最先入库的批次和计划批次一致
} else {
//查询是否存在于自提的库存品信息中
List < DistributionDeliveryDetailsEntity > billStocklistEntityList = distrilbutionBillLadingMapper . selectInventoryListByIdAndMateriel ( stockupDTO . getReservationId ( ) , stockupDTO . getCargoNumber ( ) ) ;
if ( ! billStocklistEntityList . isEmpty ( ) ) {
DistributionStockListEntity finalById = byId ;
//检测是否存在计划中
boolean flag = billStocklistEntityList . stream ( )
. map ( DistributionDeliveryDetailsEntity : : getStockListId )
. anyMatch ( s - > s . equals ( finalById . getId ( ) ) ) ;
if ( ! flag ) {
//不存在计划中
List < DistributionDeliveryDetailsEntity > targetDeliveryDetailsEntity = new ArrayList < > ( ) ;
for ( DistributionDeliveryDetailsEntity deliveryDetails : billStocklistEntityList ) {
if ( deliveryDetails . getQuantity ( ) > = deliveryDetails . getRealityQuantity ( ) & & deliveryDetails . getRealityQuantity ( ) > 0 ) {
targetDeliveryDetailsEntity . add ( deliveryDetails ) ;
}
}
if ( Func . isEmpty ( targetDeliveryDetailsEntity ) ) {
return R . fail ( "该物料库存品备货已完成" ) ;
}
//新增此物料计划
DistributionDeliveryDetailsEntity distributionBillStocklistEntity = getDistributionBillStocklistEntity ( stockupDTO , byId ) ;
distributionDeliveryDetailsService . save ( distributionBillStocklistEntity ) ;
DistributionStockListEntity stockListEntity = distributionStockListService . getById ( byId . getId ( ) ) ;
stockListEntity . setQuantityOccupied ( stockListEntity . getQuantityOccupied ( ) + 1 ) ;
distributionStockListService . updateById ( stockListEntity ) ;
DistributionDeliveryDetailsEntity deliveryDetails = targetDeliveryDetailsEntity . get ( 0 ) ;
int oldRsNum = deliveryDetails . getQuantity ( ) - 1 ;
if ( oldRsNum < 0 ) {
return R . fail ( "操作数据错误" ) ;
}
deliveryDetails . setQuantity ( oldRsNum ) ;
if ( deliveryDetails . getQuantity ( ) = = 0 ) {
deliveryDetails . setInventoryStatus ( ReservationOrderStatusConstant . quxiao . getValue ( ) ) ;
}
distributionDeliveryDetailsService . updateById ( deliveryDetails ) ;
//维护老的的冻结数量
DistributionStockListEntity oldStockList = distributionStockListService . getById ( deliveryDetails . getStockListId ( ) ) ;
oldStockList . setQuantityOccupied ( oldStockList . getQuantityOccupied ( ) - 1 ) ;
distributionStockListService . updateById ( oldStockList ) ;
//查询对应的包件进行修改
List < DisStockListDetailEntity > stockListDetailEntities = disStockListDetailService . list ( Wrappers . < DisStockListDetailEntity > query ( ) . lambda ( )
. eq ( DisStockListDetailEntity : : getReservationId , stockupDTO . getReservationId ( ) )
. eq ( DisStockListDetailEntity : : getStockListId , oldStockList . getId ( ) )
. ne ( DisStockListDetailEntity : : getStockPackageStatus , ReservationPackageStatusConstant . quxiao . getValue ( ) )
) ;
DisStockListDetailEntity disStockListDetailEntity = stockListDetailEntities . stream ( ) . filter ( s - > Func . isBlank ( s . getStockPackageCode ( ) ) ) . collect ( Collectors . toList ( ) ) . get ( 0 ) ;
disStockListDetailEntity . setStockListId ( distributionBillStocklistEntity . getStockListId ( ) ) ;
// disStockListDetailEntity.setStockStatus(OrderPackageStockupStatusConstant.yibeihu.getValue());
disStockListDetailService . updateById ( disStockListDetailEntity ) ;
} else {
//判断是否是为增加库存品进行数据维护
DistributionStockListEntity finalById1 = byId ;
DistributionDeliveryDetailsEntity deliveryDetails = billStocklistEntityList . stream ( ) . filter ( f - > f . getStockListId ( ) . equals ( finalById1 . getId ( ) ) ) . collect ( Collectors . toList ( ) ) . get ( 0 ) ;
//因为新增库存品的时候会完成扫描 此时的增加数和备货数量时一样的
if ( deliveryDetails . getInventoryStatus ( ) . equals ( ReservationOrderStatusConstant . zengjia . getValue ( ) ) & & Objects . equals ( deliveryDetails . getQuantity ( ) , deliveryDetails . getRealityQuantity ( ) ) ) {
List < DistributionDeliveryDetailsEntity > oldRS = distributionDeliveryDetailsService . selectStockListByReservationIdAndCargoNumber ( deliveryDetails . getBillLadingId ( ) , stockupDTO . getCargoNumber ( ) , deliveryDetails . getStockListId ( ) ) ;
//收集满足条件的库存品
List < DistributionDeliveryDetailsEntity > rs = new ArrayList < > ( ) ;
for ( DistributionDeliveryDetailsEntity oldR : oldRS ) {
if ( oldR . getQuantity ( ) > = oldR . getRealityQuantity ( ) & & oldR . getQuantity ( ) > 0 ) {
rs . add ( oldR ) ;
}
}
if ( Func . isEmpty ( rs ) ) {
//不存在还需要进行备货的库存品
return R . fail ( "该物料库存品备货已完成" ) ;
}
DistributionDeliveryDetailsEntity oldReservationStockList = rs . get ( 0 ) ;
int oldReservationNum = oldReservationStockList . getQuantity ( ) - 1 ;
oldReservationStockList . setQuantity ( oldReservationNum ) ;
if ( oldReservationNum = = 0 ) {
oldReservationStockList . setInventoryStatus ( ReservationOrderStatusConstant . quxiao . getValue ( ) ) ;
}
distributionDeliveryDetailsService . updateById ( oldReservationStockList ) ;
//修改对应库存品数量
DistributionStockListEntity stockListEntity = distributionStockListService . getById ( oldReservationStockList . getStockListId ( ) ) ;
stockListEntity . setQuantityOccupied ( stockListEntity . getQuantityOccupied ( ) - 1 ) ;
distributionStockListService . updateById ( stockListEntity ) ;
//找出对库存品包件信息进行包件的修改
List < DisStockListDetailEntity > oldRsPack = disStockListDetailService . list ( Wrappers . < DisStockListDetailEntity > query ( ) . lambda ( )
. eq ( DisStockListDetailEntity : : getReservationId , oldReservationStockList . getBillLadingId ( ) )
. eq ( DisStockListDetailEntity : : getStockListId , oldReservationStockList . getStockListId ( ) )
. ne ( DisStockListDetailEntity : : getStockPackageStatus , ReservationPackageStatusConstant . quxiao . getValue ( ) )
) ;
if ( Func . isEmpty ( oldRsPack ) ) {
return R . fail ( "该物料库存品备货已完成" ) ;
}
List < DisStockListDetailEntity > collect = oldRsPack . stream ( ) . filter ( f - > Func . isBlank ( f . getStockPackageCode ( ) ) ) . collect ( Collectors . toList ( ) ) ;
DisStockListDetailEntity disStockListDetailEntity = collect . get ( 0 ) ;
disStockListDetailEntity . setStockListId ( deliveryDetails . getStockListId ( ) ) ;
disStockListDetailService . updateById ( disStockListDetailEntity ) ;
deliveryDetails . setQuantity ( deliveryDetails . getQuantity ( ) + 1 ) ;
distributionDeliveryDetailsService . updateById ( deliveryDetails ) ;
//维护库存品在库数量
DistributionStockListEntity newStockList = distributionStockListService . getById ( deliveryDetails . getStockListId ( ) ) ;
newStockList . setQuantityOccupied ( newStockList . getQuantityOccupied ( ) + 1 ) ;
distributionStockListService . updateById ( newStockList ) ;
}
}
}
}
}
if ( Func . isNotEmpty ( byId ) ) {
@ -4542,4 +4661,17 @@ public class DistributionStockupServiceImpl extends BaseServiceImpl<Distribution
rs . setStocklistId ( byId . getId ( ) ) ;
return rs ;
}
@NotNull
private static DistributionDeliveryDetailsEntity getDistributionBillStocklistEntity ( StockupDTO stockupDTO , DistributionStockListEntity byId ) {
DistributionDeliveryDetailsEntity ddd = new DistributionDeliveryDetailsEntity ( ) ;
ddd . setInventoryStatus ( ReservationOrderStatusConstant . zengjia . getValue ( ) ) ;
ddd . setBillLadingId ( stockupDTO . getReservationId ( ) ) ;
ddd . setRealityQuantity ( 0 ) ;
ddd . setConditions ( "10" ) ;
ddd . setStockStatus ( "1" ) ;
ddd . setStockListId ( byId . getId ( ) ) ;
return ddd ;
}
}