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

-- 生成时间:2018-05-28 18:55:05 by ebs-core  
CREATE  procedure order_29_modify_4_after(
     @cmpid int,
     @branchid int,
     @userdpid int,
     @useruid int,
     @userotid int,
     @jbid bigint,
     @ordid bigint,
     @ord2tag int,
     @ord2id bigint
  ) 
as  
begin  
set nocount on  
declare @sys_recid bigint 
set @sys_recid = 0 
 declare @nonedate datetime 
set @nonedate = CONVERT(datetime,'1910-1-1')
declare @ord2group2 nvarchar(50) 
set @ord2group2 = '' 
 --- 以下是预处理事件中的临时表
 --- #old 与 #new 在主体中已经生成
 
exec drop_temp_table '#master' 
select * into #master from order_29 where ord_id=@ordid 
 ---- 以下是开发人员写的 after modify details order 事件 --------------
 /*若全部评估信息都不为空，并且相关简历档案中没有此条评估记录，则插入到简历档案中*/
/*key为0表示当前面试评估表中的评估意见都不为空*/
declare @key int 
select @key = count(ord2_opinion) from order_29_102 where isNULL(ord2_opinion,'') ='' and ord2_ordid = @ordid
/*existlog为0，表示简历档案中不存在此用户的评估信息*/
declare @existlog int 
select @existlog = count(ord2_opinion) from order_30_6 where ord2_fordid = @ordid and ord2_mscuid = @useruid

if @key = 0 and @existlog = 0
begin
    insert into order_30_6 (ord2_mslx,ord2_cuname,ord2_opinion,ord2_ordid,ord2_tag,ord2_fordid,ord2_mscuid)
    select a.ord2_mslx,a.ord2_cuname,a.ord2_opinion,b.ord_fordid,6,@ordid,a.ord2_mscuid
    from order_29_102 a,#master b
    where a.ord2_ordid = b.ord_id and b.ord_id = @ordid
end

/*判断当前评估者信息不为空，在评估信息不为空的情况下删除当前评估者的任务*/
delete mps_task 
from order_29_102 
where   tsk_cuid = ord2_mscuid  
and isnull(ord2_opinion,'') !='' 
and ord2_ordid = @ordid 
and ord2_mscuid = @useruid
and tsk_objid = @ordid
and tsk_objtype='biz'

 ---- 以上是开发人员写的 after modify details order 事件 --------------
 
 
--- 清除临时表 
exec drop_temp_table '#master' 

set nocount off 
end