IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[order_265_3322_wrkapply_before]') AND type = 'P')
DROP PROCEDURE [dbo].[order_265_3322_wrkapply_before]
GO

-- 生成时间:2018-11-30 14:40:53 by ebs-core  
CREATE  procedure order_265_3322_wrkapply_before(
     @cmpid int, 
     @useruid int,
     @bizid int, 
     @ordid bigint, 
     @wrkid int, 
     @jbid bigint, 
     @wsid int, 
     @wsstatus nvarchar(50), 
     @operation varchar(50) output, 
     @errorinfo nvarchar(4000) output
  ) 
as  
begin  
set nocount on  
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
declare @nonedate datetime 
set @nonedate = CONVERT(datetime,'1910-1-1')
declare @ord2group2 nvarchar(50) 
set @ord2group2 = '' 
declare @sys_recid bigint 
set @sys_recid = 0 
 set @operation = 'continue'
 set @errorinfo = '' 
 
declare @myallow__time int = 1 
declare @myallow__times varchar(10)=''
declare @myallow__date1 varchar(19)=''
declare @myallow__date2 varchar(19)=''
declare @myallow__week int = 0 
declare @myallow__day int = 0 
set @myallow__times = CONVERT(varchar(5),getdate(),114)
set @myallow__date1 = CONVERT(varchar(10),getdate(),120)
set @myallow__date2 = @myallow__date1 +' 23:59:59'
set @myallow__date1 = @myallow__date1 +' 00:00:00'
set @myallow__week = datepart(dw,getdate()) - 1 
set @myallow__day = day(getdate())
if (@myallow__week=0) set @myallow__week=7  

set @myallow__time=0 
 if (@myallow__time=1) 
 begin
 set @operation='abort'
 if (@errorinfo='') 
 begin
 set @errorinfo = '当前时间不允许操作'
 end 
 return 
 end
  
 --- 以下是预处理事件中的临时表
 
exec drop_temp_table '#master' 
select * into #master from order_265 with(nolock) where ord_id=@ordid 
 ---- 以下是开发人员写的 before apply job 事件 --------------
 if  not exists (select 1 from #master where ord_status = '门店自压')
begin
set @operation='abort'
set @errorinfo = '旧件还没有收货，不能进行后续操作！'
end
 ---- 以上是开发人员写的 before apply job 事件 --------------
 
 if (@operation='continue') 
 begin
 set @nonedate= @nonedate  -- here useless 
 
end 
--- 清除临时表 
exec drop_temp_table '#master' 

set nocount off 
end