@ -155,7 +155,7 @@ public class IoSplitDesOrderService extends ServiceImpl<IoSplitDesOrderMapper, I
collectOrder = IoSplitDesOrder . builder ( )
collectOrder = IoSplitDesOrder . builder ( )
. id ( IdUtil . getSnowflakeNextId ( ) )
. id ( IdUtil . getSnowflakeNextId ( ) )
. billNo ( gennerOrderUtils . createWdOrderNo ( new OrderNoTypeBean ( Constant . SPLIT_DES_ORDER , "yyyyMMdd" ) ) )
. billNo ( gennerOrderUtils . createWdOrderNo ( new OrderNoTypeBean ( Constant . SPLIT_DES_ORDER , "yyyyMMdd" ) ) )
. busType ( "1" )
. busType ( addInvDesDetaiRequest . getSplitFifoInv ( ) . getBusType ( ) )
. orderType ( 1 )
. orderType ( 1 )
. workPlaceCode ( addInvDesDetaiRequest . getSplitFifoInv ( ) . getWorkPlaceCode ( ) )
. workPlaceCode ( addInvDesDetaiRequest . getSplitFifoInv ( ) . getWorkPlaceCode ( ) )
. createTime ( new Date ( ) )
. createTime ( new Date ( ) )
@ -178,20 +178,35 @@ public class IoSplitDesOrderService extends ServiceImpl<IoSplitDesOrderMapper, I
throw new JsonException ( 500 , "库存不足" ) ;
throw new JsonException ( 500 , "库存不足" ) ;
}
}
//修改产品 库存 出库数量 可用数量 剩余数量
//修改产品 库存 出库数量 可用数量 剩余数量
//入库数量是否需要更改?
splitFifoInv . setOutCount ( splitFifoInv . getOutCount ( ) + addInvDesDetaiRequest . getOutCount ( ) ) ; //出库数量
splitFifoInv . setOutCount ( splitFifoInv . getOutCount ( ) + addInvDesDetaiRequest . getOutCount ( ) ) ; //出库数量
splitFifoInv . setReCount ( splitFifoInv . getInCount ( ) - splitFifoInv . getOutCount ( ) ) ; //剩余数量
splitFifoInv . setReCount ( splitFifoInv . getInCount ( ) - addInvDesDetaiRequest . getOutCount ( ) ) ; //剩余数量
int availableCount = splitFifoInv . getInCount ( ) - splitFifoInv . getOutCount ( ) - splitFifoInv . getLockCount ( ) ;
int availableCount = splitFifoInv . getInCount ( ) - addInvDesDetaiRequest . getOutCount ( ) - splitFifoInv . getLockCount ( ) ;
if ( availableCount < 0 ) {
if ( availableCount < = - 1 ) {
throw new JsonException ( 500 , "可用数量库存不足" ) ;
throw new JsonException ( 500 , "可用数量库存不足" ) ;
}
}
// 剩余 数量
// 可用 数量
splitFifoInv . setAvailableCount ( availableCount ) ;
splitFifoInv . setAvailableCount ( availableCount ) ;
splitFifoInv . setInCount ( splitFifoInv . getInCount ( ) - addInvDesDetaiRequest . getOutCount ( ) ) ; //入库数量
splitFifoInv . setUpdateTime ( new Date ( ) ) ;
splitFifoInv . setUpdateTime ( new Date ( ) ) ;
//更改 库存
//更改 库存
boolean update = ioSplitFifoInvService . updateById ( splitFifoInv ) ;
boolean update = ioSplitFifoInvService . updateById ( splitFifoInv ) ;
if ( ! update ) {
if ( ! update ) {
return false ;
return false ;
}
}
//todo 码明细删减库存
IoSplitFifoCodeEntity splitFifoCodeEntity = splitFifoCodeService . getOne ( new LambdaQueryWrapper < IoSplitFifoCodeEntity > ( )
. eq ( IoSplitFifoCodeEntity : : getWorkPlaceCode , splitFifoInv . getWorkPlaceCode ( ) )
. eq ( IoSplitFifoCodeEntity : : getBatchNo , splitFifoInv . getBatchNo ( ) )
. eq ( IoSplitFifoCodeEntity : : getRelId , splitFifoInv . getRelId ( ) ) ) ;
if ( splitFifoCodeEntity = = null ) {
throw new JsonException ( "该工位不存在,请检查后重试!" ) ;
}
splitFifoCodeEntity . setTotalCount ( splitFifoCodeEntity . getTotalCount ( ) - addInvDesDetaiRequest . getOutCount ( ) ) ;
boolean b = splitFifoCodeService . updateById ( splitFifoCodeEntity ) ;
if ( ! b ) {
throw new JsonException ( 500 , "追溯码库存删减失败" ) ;
}
// IoSplitFifoInv splitFifoInv = addInvDesDetaiRequest.getSplitFifoInv();
// IoSplitFifoInv splitFifoInv = addInvDesDetaiRequest.getSplitFifoInv();
IoSplitDesOrderDetail splitDesOrderDetail = IoSplitDesOrderDetail . builder ( )
IoSplitDesOrderDetail splitDesOrderDetail = IoSplitDesOrderDetail . builder ( )
. id ( IdUtil . getSnowflakeNextId ( ) )
. id ( IdUtil . getSnowflakeNextId ( ) )
@ -215,6 +230,7 @@ public class IoSplitDesOrderService extends ServiceImpl<IoSplitDesOrderMapper, I
return true ;
return true ;
}
}
@Transactional ( rollbackFor = Exception . class )
public Boolean destroyOutByCode ( AddInvDesDetaiRequest addInvDesDetaiRequest ) {
public Boolean destroyOutByCode ( AddInvDesDetaiRequest addInvDesDetaiRequest ) {
IoSplitFifoCodeEntity splitFifoCodeEntity = splitFifoCodeService . findByCode ( addInvDesDetaiRequest . getCode ( ) , addInvDesDetaiRequest . getSplitFifoInv ( ) . getWorkPlaceCode ( ) ) ;
IoSplitFifoCodeEntity splitFifoCodeEntity = splitFifoCodeService . findByCode ( addInvDesDetaiRequest . getCode ( ) , addInvDesDetaiRequest . getSplitFifoInv ( ) . getWorkPlaceCode ( ) ) ;
if ( splitFifoCodeEntity = = null ) {
if ( splitFifoCodeEntity = = null ) {
@ -224,7 +240,7 @@ public class IoSplitDesOrderService extends ServiceImpl<IoSplitDesOrderMapper, I
collectOrder = IoSplitDesOrder . builder ( )
collectOrder = IoSplitDesOrder . builder ( )
. id ( IdUtil . getSnowflakeNextId ( ) )
. id ( IdUtil . getSnowflakeNextId ( ) )
. billNo ( gennerOrderUtils . createWdOrderNo ( new OrderNoTypeBean ( Constant . SPLIT_DES_ORDER , "yyyyMMdd" ) ) )
. billNo ( gennerOrderUtils . createWdOrderNo ( new OrderNoTypeBean ( Constant . SPLIT_DES_ORDER , "yyyyMMdd" ) ) )
. busType ( "1" )
. busType ( addInvDesDetaiRequest . getSplitFifoInv ( ) . getBusType ( ) )
. orderType ( 1 )
. orderType ( 1 )
. workPlaceCode ( addInvDesDetaiRequest . getSplitFifoInv ( ) . getWorkPlaceCode ( ) )
. workPlaceCode ( addInvDesDetaiRequest . getSplitFifoInv ( ) . getWorkPlaceCode ( ) )
. createTime ( new Date ( ) )
. createTime ( new Date ( ) )
@ -257,14 +273,16 @@ public class IoSplitDesOrderService extends ServiceImpl<IoSplitDesOrderMapper, I
throw new JsonException ( 500 , "库存不足" ) ;
throw new JsonException ( 500 , "库存不足" ) ;
}
}
//修改产品 库存 入库数
//修改产品 库存 入库数
splitFifoInv . setInCount ( splitFifoInv . getInCount ( ) - addInvDesDetaiRequest . getOutCount ( ) ) ;
splitFifoInv . setOutCount ( splitFifoInv . getOutCount ( ) + addInvDesDetaiRequest . getOutCount ( ) ) ; //出库数量
splitFifoInv . setOutCount ( splitFifoInv . getOutCount ( ) + addInvDesDetaiRequest . getOutCount ( ) ) ; //出库数量
splitFifoInv . setReCount ( splitFifoInv . getInCount ( ) - splitFifoInv . getOutCount ( ) ) ; //剩余数量
splitFifoInv . setReCount ( splitFifoInv . getInCount ( ) - addInvDesDetaiRequest . getOutCount ( ) ) ; //剩余数量
int availableCount = splitFifoInv . getInCount ( ) - splitFifoInv . getOutCount ( ) - splitFifoInv . getLockCount ( ) ;
int availableCount = splitFifoInv . getInCount ( ) - addInvDesDetaiRequest . getOutCount ( ) - splitFifoInv . getLockCount ( ) ;
if ( availableCount < 0 ) {
if ( availableCount < = - 1 ) {
throw new JsonException ( 500 , "可用数量库存不足" ) ;
throw new JsonException ( 500 , "可用数量库存不足" ) ;
}
}
// int newAvailableCount = splitFifoInv.getAvailableCount() - availableCount;
splitFifoInv . setAvailableCount ( availableCount ) ; //可用数量
splitFifoInv . setAvailableCount ( availableCount ) ; //可用数量
splitFifoInv . setInCount ( splitFifoInv . getInCount ( ) - addInvDesDetaiRequest . getOutCount ( ) ) ;
splitFifoInv . setUpdateTime ( new Date ( ) ) ;
splitFifoInv . setUpdateTime ( new Date ( ) ) ;
//更改 库存
//更改 库存
boolean update = ioSplitFifoInvService . updateById ( splitFifoInv ) ;
boolean update = ioSplitFifoInvService . updateById ( splitFifoInv ) ;
@ -294,25 +312,27 @@ public class IoSplitDesOrderService extends ServiceImpl<IoSplitDesOrderMapper, I
}
}
@Transactional ( rollbackFor = Exception . class )
public void splitDesOrder ( AddInvDesDetaiRequest addInvDesDetaiRequest ) {
public void splitDesOrder ( AddInvDesDetaiRequest addInvDesDetaiRequest ) {
IoSplitDesOrder collectOrder ;
IoSplitDesOrder collectOrder ;
collectOrder = IoSplitDesOrder . builder ( )
collectOrder = IoSplitDesOrder . builder ( )
. id ( IdUtil . getSnowflakeNextId ( ) )
. billNo ( gennerOrderUtils . createWdOrderNo ( new OrderNoTypeBean ( Constant . SPLIT_DES_ORDER , "yyyyMMdd" ) ) )
. billNo ( gennerOrderUtils . createWdOrderNo ( new OrderNoTypeBean ( Constant . SPLIT_DES_ORDER , "yyyyMMdd" ) ) )
. busType ( "1" )
. busType ( "1" )
. workPlaceCode ( addInvDesDetaiRequest . getWorkPlaceCode ( ) )
. workPlaceCode ( addInvDesDetaiRequest . getWorkPlaceCode ( ) )
. createTime ( new Date ( ) )
. createTime ( new Date ( ) )
. billTime ( new Date ( ) )
. billTime ( new Date ( ) )
. remark ( addInvDesDetaiRequest . getRemark ( ) )
. remark ( addInvDesDetaiRequest . getRemark ( ) )
. status ( 1 )
. status ( 2 )
. createUser ( addInvDesDetaiRequest . getCreateUser ( ) )
. createUser ( addInvDesDetaiRequest . getCreateUser ( ) )
. updateTime ( new Date ( ) )
. updateTime ( new Date ( ) )
. updateUser ( addInvDesDetaiRequest . getUpdateUser ( ) )
. updateUser ( addInvDesDetaiRequest . getUpdateUser ( ) )
. build ( ) ;
. build ( ) ;
save ( collectOrder ) ;
save ( collectOrder ) ;
IoSplitCodeEntity splitCodeEntity = splitCodeService . findByCode ( addInvDesDetaiRequest . getCode ( ) , addInvDesDetaiRequest . get WorkPlaceCode( ) , null ) ;
IoSplitCodeEntity splitCodeEntity = splitCodeService . findByCode ( addInvDesDetaiRequest . getCode ( ) , addInvDesDetaiRequest . get SplitFifoInv( ) . get WorkPlaceCode( ) , null ) ;
if ( splitCodeEntity = = null ) {
if ( splitCodeEntity = = null ) {
throw new RuntimeException( "该追溯码不存在!" ) ;
throw new JsonException( 500 , "该追溯码不存在!" ) ;
}
}
int count = IntUtil . value ( splitCodeEntity . getRemainCount ( ) ) - IntUtil . value ( addInvDesDetaiRequest . getOutCount ( ) ) ;
int count = IntUtil . value ( splitCodeEntity . getRemainCount ( ) ) - IntUtil . value ( addInvDesDetaiRequest . getOutCount ( ) ) ;
if ( count < 0 ) {
if ( count < 0 ) {