@ -155,7 +155,7 @@ public class IoSplitDesOrderService extends ServiceImpl<IoSplitDesOrderMapper, I
 
			
		
	
		
			
				
					        collectOrder  =  IoSplitDesOrder . builder ( ) 
 
			
		
	
		
			
				
					                . id ( IdUtil . getSnowflakeNextId ( ) ) 
 
			
		
	
		
			
				
					                . billNo ( gennerOrderUtils . createWdOrderNo ( new  OrderNoTypeBean ( Constant . SPLIT_DES_ORDER ,  "yyyyMMdd" ) ) ) 
 
			
		
	
		
			
				
					                . busType ( "1" ) 
 
			
		
	
		
			
				
					                . busType ( addInvDesDetaiRequest . getSplitFifoInv ( ) . getBusType ( ) ) 
 
			
		
	
		
			
				
					                . orderType ( 1 ) 
 
			
		
	
		
			
				
					                . workPlaceCode ( addInvDesDetaiRequest . getSplitFifoInv ( ) . getWorkPlaceCode ( ) ) 
 
			
		
	
		
			
				
					                . createTime ( new  Date ( ) ) 
 
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -178,20 +178,35 @@ public class IoSplitDesOrderService extends ServiceImpl<IoSplitDesOrderMapper, I
 
			
		
	
		
			
				
					            throw  new  JsonException ( 500 , "库存不足" ) ; 
 
			
		
	
		
			
				
					        } 
 
			
		
	
		
			
				
					        //修改产品 库存 出库数量 可用数量 剩余数量
 
 
			
		
	
		
			
				
					        //入库数量是否需要更改?
 
 
			
		
	
		
			
				
					        splitFifoInv . setOutCount ( splitFifoInv . getOutCount ( )  +  addInvDesDetaiRequest . getOutCount ( ) ) ; //出库数量
 
 
			
		
	
		
			
				
					        splitFifoInv . setReCount ( splitFifoInv . getInCount ( )  -  splitFifoInv . getOutCount ( ) ) ; //剩余数量
 
 
			
		
	
		
			
				
					        int  availableCount  =  splitFifoInv . getInCount ( )  -  splitFifoInv . getOutCount ( )  -  splitFifoInv . getLockCount ( ) ; 
 
			
		
	
		
			
				
					        if  ( availableCount  <  0  ) { 
 
			
		
	
		
			
				
					        splitFifoInv . setReCount ( splitFifoInv . getInCount ( )  -  addInvDesDetaiRequest . getOutCount ( ) ) ; //剩余数量
 
 
			
		
	
		
			
				
					        int  availableCount  =  splitFifoInv . getInCount ( )  -  addInvDesDetaiRequest . getOutCount ( )  -  splitFifoInv . getLockCount ( ) ; 
 
			
		
	
		
			
				
					        if  ( availableCount  < =  - 1 ) { 
 
			
		
	
		
			
				
					            throw  new  JsonException ( 500 , "可用数量库存不足" ) ; 
 
			
		
	
		
			
				
					        } 
 
			
		
	
		
			
				
					        // 剩余 数量
 
			
		
	
		
			
				
					        // 可用 数量
 
			
		
	
		
			
				
					        splitFifoInv . setAvailableCount ( availableCount ) ; 
 
			
		
	
		
			
				
					        splitFifoInv . setInCount ( splitFifoInv . getInCount ( )  -  addInvDesDetaiRequest . getOutCount ( ) ) ; //入库数量
 
 
			
		
	
		
			
				
					        splitFifoInv . setUpdateTime ( new  Date ( ) ) ; 
 
			
		
	
		
			
				
					        //更改 库存
 
 
			
		
	
		
			
				
					        boolean  update  =  ioSplitFifoInvService . updateById ( splitFifoInv ) ; 
 
			
		
	
		
			
				
					        if  ( ! update )  { 
 
			
		
	
		
			
				
					            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();
  
			
		
	
		
			
				
					        IoSplitDesOrderDetail  splitDesOrderDetail  =  IoSplitDesOrderDetail . builder ( ) 
 
			
		
	
		
			
				
					                . id ( IdUtil . getSnowflakeNextId ( ) ) 
 
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -215,6 +230,7 @@ public class IoSplitDesOrderService extends ServiceImpl<IoSplitDesOrderMapper, I
 
			
		
	
		
			
				
					        return  true ; 
 
			
		
	
		
			
				
					    } 
 
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    @Transactional ( rollbackFor  =  Exception . class ) 
 
			
		
	
		
			
				
					    public  Boolean  destroyOutByCode ( AddInvDesDetaiRequest  addInvDesDetaiRequest )  { 
 
			
		
	
		
			
				
					        IoSplitFifoCodeEntity  splitFifoCodeEntity  =  splitFifoCodeService . findByCode ( addInvDesDetaiRequest . getCode ( ) ,  addInvDesDetaiRequest . getSplitFifoInv ( ) . getWorkPlaceCode ( ) ) ; 
 
			
		
	
		
			
				
					        if  ( splitFifoCodeEntity  = =  null )  { 
 
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -224,7 +240,7 @@ public class IoSplitDesOrderService extends ServiceImpl<IoSplitDesOrderMapper, I
 
			
		
	
		
			
				
					        collectOrder  =  IoSplitDesOrder . builder ( ) 
 
			
		
	
		
			
				
					                . id ( IdUtil . getSnowflakeNextId ( ) ) 
 
			
		
	
		
			
				
					                . billNo ( gennerOrderUtils . createWdOrderNo ( new  OrderNoTypeBean ( Constant . SPLIT_DES_ORDER ,  "yyyyMMdd" ) ) ) 
 
			
		
	
		
			
				
					                . busType ( "1" ) 
 
			
		
	
		
			
				
					                . busType ( addInvDesDetaiRequest . getSplitFifoInv ( ) . getBusType ( ) ) 
 
			
		
	
		
			
				
					                . orderType ( 1 ) 
 
			
		
	
		
			
				
					                . workPlaceCode ( addInvDesDetaiRequest . getSplitFifoInv ( ) . getWorkPlaceCode ( ) ) 
 
			
		
	
		
			
				
					                . createTime ( new  Date ( ) ) 
 
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -257,14 +273,16 @@ public class IoSplitDesOrderService extends ServiceImpl<IoSplitDesOrderMapper, I
 
			
		
	
		
			
				
					            throw  new  JsonException ( 500 , "库存不足" ) ; 
 
			
		
	
		
			
				
					        } 
 
			
		
	
		
			
				
					        //修改产品 库存 入库数
 
 
			
		
	
		
			
				
					        splitFifoInv . setInCount ( splitFifoInv . getInCount ( )  -  addInvDesDetaiRequest . getOutCount ( ) ) ;   
			
		
	
		
			
				
					
  
			
		
	
		
			
				
					        splitFifoInv . setOutCount ( splitFifoInv . getOutCount ( )  +  addInvDesDetaiRequest . getOutCount ( ) ) ; //出库数量
 
 
			
		
	
		
			
				
					        splitFifoInv . setReCount ( splitFifoInv . getInCount ( )  -  splitFifoInv . getOutCount ( ) ) ; //剩余数量
 
 
			
		
	
		
			
				
					        int  availableCount  =  splitFifoInv . getInCount ( )  -  splitFifoInv . getOutCount ( )  -  splitFifoInv . getLockCount ( ) ; 
 
			
		
	
		
			
				
					        if  ( availableCount  <  0  ) { 
 
			
		
	
		
			
				
					        splitFifoInv . setReCount ( splitFifoInv . getInCount ( )  -  addInvDesDetaiRequest . getOutCount ( ) ) ; //剩余数量
 
 
			
		
	
		
			
				
					        int  availableCount  =  splitFifoInv . getInCount ( )  -  addInvDesDetaiRequest . getOutCount ( )  -  splitFifoInv . getLockCount ( ) ; 
 
			
		
	
		
			
				
					        if  ( availableCount  < =  - 1 ) { 
 
			
		
	
		
			
				
					            throw  new  JsonException ( 500 , "可用数量库存不足" ) ; 
 
			
		
	
		
			
				
					        } 
 
			
		
	
		
			
				
					//        int newAvailableCount  = splitFifoInv.getAvailableCount() - availableCount;
  
			
		
	
		
			
				
					        splitFifoInv . setAvailableCount ( availableCount ) ; //可用数量
 
 
			
		
	
		
			
				
					        splitFifoInv . setInCount ( splitFifoInv . getInCount ( )  -  addInvDesDetaiRequest . getOutCount ( ) ) ; 
 
			
		
	
		
			
				
					        splitFifoInv . setUpdateTime ( new  Date ( ) ) ; 
 
			
		
	
		
			
				
					        //更改 库存
 
 
			
		
	
		
			
				
					        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 )  { 
 
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					        IoSplitDesOrder  collectOrder ; 
 
			
		
	
		
			
				
					        collectOrder  =  IoSplitDesOrder . builder ( ) 
 
			
		
	
		
			
				
					                . id ( IdUtil . getSnowflakeNextId ( ) ) 
 
			
		
	
		
			
				
					                . billNo ( gennerOrderUtils . createWdOrderNo ( new  OrderNoTypeBean ( Constant . SPLIT_DES_ORDER ,  "yyyyMMdd" ) ) ) 
 
			
		
	
		
			
				
					                . busType ( "1" ) 
 
			
		
	
		
			
				
					                . workPlaceCode ( addInvDesDetaiRequest . getWorkPlaceCode ( ) ) 
 
			
		
	
		
			
				
					                . createTime ( new  Date ( ) ) 
 
			
		
	
		
			
				
					                . billTime ( new  Date ( ) ) 
 
			
		
	
		
			
				
					                . remark ( addInvDesDetaiRequest . getRemark ( ) ) 
 
			
		
	
		
			
				
					                . status ( 1 ) 
 
			
		
	
		
			
				
					                . status ( 2 ) 
 
			
		
	
		
			
				
					                . createUser ( addInvDesDetaiRequest . getCreateUser ( ) ) 
 
			
		
	
		
			
				
					                . updateTime ( new  Date ( ) ) 
 
			
		
	
		
			
				
					                . updateUser ( addInvDesDetaiRequest . getUpdateUser ( ) ) 
 
			
		
	
		
			
				
					                . build ( ) ; 
 
			
		
	
		
			
				
					        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 )  { 
 
			
		
	
		
			
				
					            throw  new  RuntimeException(  "该追溯码不存在!" ) ; 
 
			
		
	
		
			
				
					            throw  new  JsonException( 500 ,  "该追溯码不存在!" ) ; 
 
			
		
	
		
			
				
					        } 
 
			
		
	
		
			
				
					        int  count  =  IntUtil . value ( splitCodeEntity . getRemainCount ( ) )  -  IntUtil . value ( addInvDesDetaiRequest . getOutCount ( ) ) ; 
 
			
		
	
		
			
				
					        if  ( count  <  0 )  {