@ -100,96 +100,143 @@ public class WarehouseWarehousingEntryServiceImpl extends BaseServiceImpl<Wareho
@Override
@Transactional ( rollbackFor = Exception . class )
public Boolean saveOrUpdateOwn ( WarehouseWarehousingEntryDTO warehouseWarehousingEntryDTO ) {
List < WarehouseWarehousingDetailEntity > list = warehouseWarehousingEntryDTO . getList ( ) ;
WarehouseWarehousingEntryEntity warehouseWarehousingEntry = new WarehouseWarehousingEntryEntity ( ) ;
BeanUtil . copyProperties ( warehouseWarehousingEntryDTO , warehouseWarehousingEntry ) ;
WarehouseWarehousingEntryEntity entryEntity = new WarehouseWarehousingEntryEntity ( ) ;
entryEntity . setId ( warehouseWarehousingEntryDTO . getId ( ) ) ;
if ( ObjectUtils . isNotNull ( warehouseWarehousingEntryDTO . getId ( ) ) ) {
//修改
List < Long > detailEntityList = new ArrayList < > ( ) ;
List < WarehouseWarehousingDetailEntity > list1 = warehouseWarehousingDetailService . list ( Wrappers . < WarehouseWarehousingDetailEntity > query ( ) . lambda ( )
. eq ( WarehouseWarehousingDetailEntity : : getWarehousingEntryId , warehouseWarehousingEntry . getId ( ) )
. apply ( "conditions in (1,2) " )
) ; //查询不是确定的数据
if ( list1 . size ( ) > 0 ) {
AtomicReference < Integer > num = new AtomicReference < > ( 0 ) ;
list1 . forEach ( i - > {
boolean b = list . stream ( ) . anyMatch ( w - > w . getMaterialId ( ) . equals ( i . getMaterialId ( ) ) ) ;
if ( b ) {
//存在
Iterator < WarehouseWarehousingDetailEntity > iterator = list . iterator ( ) ;
while ( iterator . hasNext ( ) ) {
WarehouseWarehousingDetailEntity next = iterator . next ( ) ;
if ( next . getMaterialId ( ) . equals ( i . getMaterialId ( ) ) ) {
//修改
WarehouseWarehousingDetailEntity detailEntity = new WarehouseWarehousingDetailEntity ( ) ;
detailEntity . setId ( i . getId ( ) ) ;
detailEntity . setActualReceipt ( next . getActualReceipt ( ) ) ; //实际
if ( next . getActualReceipt ( ) . equals ( i . getCreateInventory ( ) ) ) {
detailEntity . setConditions ( "3" ) ;
num . updateAndGet ( v - > v + 1 ) ;
} else {
detailEntity . setConditions ( "2" ) ;
entryEntity . setConditions ( "2" ) ;
warehouseWarehousingEntry . setConditions ( "2" ) ;
if ( ObjectUtils . isNull ( warehouseWarehousingEntryDTO . getType ( ) ) ) {
throw new ServiceException ( "入库类型不能为空!!" ) ;
}
if ( warehouseWarehousingEntryDTO . getType ( ) . equals ( "2" ) ) {
//直接入库
List < WarehouseWarehousingDetailEntity > list = warehouseWarehousingEntryDTO . getList ( ) ;
WarehouseWarehousingEntryEntity warehouseWarehousingEntry = new WarehouseWarehousingEntryEntity ( ) ;
BeanUtil . copyProperties ( warehouseWarehousingEntryDTO , warehouseWarehousingEntry ) ;
WarehouseWarehousingEntryEntity entryEntity = new WarehouseWarehousingEntryEntity ( ) ;
entryEntity . setId ( warehouseWarehousingEntryDTO . getId ( ) ) ;
//添加
//获取当前登录人仓库
BasicdataWarehouseEntity basicdataWarehouseEntity = basicdataWarehouseClient . getMyCurrentWarehouse ( ) ;
if ( Objects . isNull ( basicdataWarehouseEntity ) ) {
log . warn ( "#####操作人,当前未查询到仓库信息" ) ;
return false ;
}
warehouseWarehousingEntry . setWarehouseId ( basicdataWarehouseEntity . getId ( ) ) ;
warehouseWarehousingEntry . setSource ( "添加" ) ;
warehouseWarehousingEntry . setConditions ( "3" ) ;
this . save ( warehouseWarehousingEntry ) ;
list . forEach ( i - > {
//添加库存品
addInventory ( i . getCreateInventory ( ) , warehouseWarehousingEntryDTO , i ) ;
} ) ;
//添加入库明细
// Iterator<WarehouseWarehousingDetailEntity> iterator = list.iterator();
// while (iterator.hasNext()){
// if(ObjectUtils.isNotNull(iterator.next().getConditions() ) && iterator.next().getConditions().equals("3")){
// iterator.remove();
// }
// }
if ( list . size ( ) > 0 ) {
list . forEach ( i - > {
i . setWarehousingEntryId ( warehouseWarehousingEntry . getId ( ) ) ;
i . setConditions ( "3" ) ;
}
) ;
warehouseWarehousingDetailService . saveBatch ( list ) ;
}
return true ;
} else if ( warehouseWarehousingEntryDTO . getType ( ) . equals ( "1" ) ) {
//预计入库
List < WarehouseWarehousingDetailEntity > list = warehouseWarehousingEntryDTO . getList ( ) ;
WarehouseWarehousingEntryEntity warehouseWarehousingEntry = new WarehouseWarehousingEntryEntity ( ) ;
BeanUtil . copyProperties ( warehouseWarehousingEntryDTO , warehouseWarehousingEntry ) ;
WarehouseWarehousingEntryEntity entryEntity = new WarehouseWarehousingEntryEntity ( ) ;
entryEntity . setId ( warehouseWarehousingEntryDTO . getId ( ) ) ;
if ( ObjectUtils . isNotNull ( warehouseWarehousingEntryDTO . getId ( ) ) ) {
//修改
List < Long > detailEntityList = new ArrayList < > ( ) ;
List < WarehouseWarehousingDetailEntity > list1 = warehouseWarehousingDetailService . list ( Wrappers . < WarehouseWarehousingDetailEntity > query ( ) . lambda ( )
. eq ( WarehouseWarehousingDetailEntity : : getWarehousingEntryId , warehouseWarehousingEntry . getId ( ) )
. apply ( "conditions in (1,2) " )
) ; //查询不是确定的数据
if ( list1 . size ( ) > 0 ) {
AtomicReference < Integer > num = new AtomicReference < > ( 0 ) ;
list1 . forEach ( i - > {
boolean b = list . stream ( ) . anyMatch ( w - > w . getMaterialId ( ) . equals ( i . getMaterialId ( ) ) ) ;
if ( b ) {
//存在
Iterator < WarehouseWarehousingDetailEntity > iterator = list . iterator ( ) ;
while ( iterator . hasNext ( ) ) {
WarehouseWarehousingDetailEntity next = iterator . next ( ) ;
if ( next . getMaterialId ( ) . equals ( i . getMaterialId ( ) ) ) {
//修改
WarehouseWarehousingDetailEntity detailEntity = new WarehouseWarehousingDetailEntity ( ) ;
detailEntity . setId ( i . getId ( ) ) ;
detailEntity . setActualReceipt ( next . getActualReceipt ( ) ) ; //实际
if ( next . getActualReceipt ( ) . equals ( i . getCreateInventory ( ) ) ) {
detailEntity . setConditions ( "3" ) ;
num . updateAndGet ( v - > v + 1 ) ;
} else {
detailEntity . setConditions ( "2" ) ;
entryEntity . setConditions ( "2" ) ;
warehouseWarehousingEntry . setConditions ( "2" ) ;
}
warehouseWarehousingDetailService . updateById ( detailEntity ) ; //修改数据
//当前入库数量
int i1 = next . getActualReceipt ( ) - i . getActualReceipt ( ) ;
//添加库存品
addInventory ( i1 , warehouseWarehousingEntryDTO , i ) ;
iterator . remove ( ) ;
}
warehouseWarehousingDetailService . updateById ( detailEntity ) ; //修改数据
//当前入库数量
int i1 = next . getActualReceipt ( ) - i . getActualReceipt ( ) ;
//添加库存品
addInventory ( i1 , warehouseWarehousingEntryDTO , i ) ;
iterator . remove ( ) ;
}
}
} else {
//删除
detailEntityList . add ( i . getId ( ) ) ;
} else {
//删除
detailEntityList . add ( i . getId ( ) ) ;
}
} ) ;
Integer teger = num . get ( ) ;
if ( list1 . size ( ) = = teger ) {
//完成这个任务
entryEntity . setConditions ( "3" ) ;
}
baseMapper . updateById ( entryEntity ) ;
if ( detailEntityList . size ( ) > 0 ) {
//删除多余的
warehouseWarehousingDetailService . deleteLogic ( detailEntityList ) ;
}
} ) ;
Integer teger = num . get ( ) ;
if ( list1 . size ( ) = = teger ) {
//完成这个任务
entryEntity . setConditions ( "3" ) ;
}
baseMapper . updateById ( entryEntity ) ;
if ( detailEntityList . size ( ) > 0 ) {
//删除多余的
warehouseWarehousingDetailService . deleteLogic ( detailEntityList ) ;
}
}
} else {
//添加
//获取当前登录人仓库
BasicdataWarehouseEntity basicdataWarehouseEntity = basicdataWarehouseClient . getMyCurrentWarehouse ( ) ;
if ( Objects . isNull ( basicdataWarehouseEntity ) ) {
log . warn ( "#####操作人,当前未查询到仓库信息" ) ;
return false ;
} else {
//添加
//获取当前登录人仓库
BasicdataWarehouseEntity basicdataWarehouseEntity = basicdataWarehouseClient . getMyCurrentWarehouse ( ) ;
if ( Objects . isNull ( basicdataWarehouseEntity ) ) {
log . warn ( "#####操作人,当前未查询到仓库信息" ) ;
return false ;
}
warehouseWarehousingEntry . setWarehouseId ( basicdataWarehouseEntity . getId ( ) ) ;
warehouseWarehousingEntry . setSource ( "添加" ) ;
warehouseWarehousingEntry . setConditions ( "1" ) ;
this . save ( warehouseWarehousingEntry ) ;
}
warehouseWarehousingEntry . setWarehouseId ( basicdataWarehouseEntity . getId ( ) ) ;
warehouseWarehousingEntry . setSource ( "添加" ) ;
warehouseWarehousingEntry . setConditions ( "1" ) ;
this . save ( warehouseWarehousingEntry ) ;
}
//添加入库明细
Iterator < WarehouseWarehousingDetailEntity > iterator = list . iterator ( ) ;
while ( iterator . hasNext ( ) ) {
if ( ObjectUtils . isNotNull ( iterator . next ( ) . getConditions ( ) ) & & iterator . next ( ) . getConditions ( ) . equals ( "3" ) ) {
iterator . remove ( ) ;
//添加入库明细
Iterator < WarehouseWarehousingDetailEntity > iterator = list . iterator ( ) ;
while ( iterator . hasNext ( ) ) {
if ( ObjectUtils . isNotNull ( iterator . next ( ) . getConditions ( ) ) & & iterator . next ( ) . getConditions ( ) . equals ( "3" ) ) {
iterator . remove ( ) ;
}
}
}
if ( list . size ( ) > 0 ) {
list . forEach ( i - > {
if ( list . size ( ) > 0 ) {
list . forEach ( i - > {
i . setWarehousingEntryId ( warehouseWarehousingEntry . getId ( ) ) ;
i . setConditions ( "1" ) ;
}
) ;
warehouseWarehousingDetailService . saveBatch ( list ) ;
}
return true ;
} else {
return false ;
}
return true ;
}
/ * *