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

-- 生成时间:2017-12-07 14:17:42 by ebs-core  
CREATE  procedure order_46_1364_wrklink_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  
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 = '' 
 --- 以下是预处理事件中的临时表
 exec drop_temp_table '#task' create table #task(objtype varchar(20),ctgid int,objid bigint,objid2 bigint,cuid int,infotype nvarchar(50),info nvarchar(4000)) exec drop_temp_table '#romaster' select * into #romaster from order_46 where ord_id=@ordid exec drop_temp_table '#rodetail104' select * into #rodetail104 from order_46_104 where ord2_ordid=@ordid  
 ---- 以下是开发人员写的 before link job 事件 --------------
 insert into #task(objtype,ctgid,objid,objid2,cuid,infotype ,info)
select distinct 'biz',ord_bizid,ord_id,ord2_id,ord2_cucuid,'离职交接','请确认离职交接事项'+ord_no+'/'+ord_title
from #rodetail104,#romaster
 ---- 以上是开发人员写的 before libk job 事件 --------------
 
 if (@operation='continue') 
 begin
 set @nonedate= @nonedate  -- here useless 
 
end 
--- 清除临时表 
exec drop_temp_table '#romaster' exec drop_temp_table '#rodetail104' delete #task where cuid is null or info is null or objid is null  or ctgid is null  insert into mps_task(tsk_cmpid,tsk_bcid,tsk_branch,tsk_dpid,tsk_depart,tsk_cuid,tsk_cuname,tsk_date,tsk_type,tsk_objtype,tsk_ctgid,tsk_objid,tsk_objid2,tsk_message)  select distinct cu_cmpid,cu_bcid,cu_branch,cu_dpid,cu_depart,cu_id,cu_callname,getdate(),case when infotype is null then '普通任务' else infotype end , case when objtype is null or objtype='' then 'biz' else objtype end , case when ctgid is null or ctgid=0 then 46 else ctgid end , case when objid  is null or objid=0 then @ordid else objid end , case when objid2  is null then 0 else objid2 end , case when info  is null then '' else info end from #task , mps_login where cu_id=cuid exec drop_temp_table '#task' 
set nocount off 
end