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

-- 生成时间:2018-11-22 18:21:36 by ebs-core  
CREATE  procedure order_268_3493_wrklink_after(
     @cmpid int, 
     @useruid int,
     @bizid int, 
     @ordid bigint, 
     @wrkid int, 
     @jbid bigint, 
     @wsid int, 
     @wsstatus nvarchar(50) 
  ) 
as  
begin  
set nocount on  
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
declare @autoapplycode varchar(50) 
  set @autoapplycode =  ''
declare @nonedate datetime 
set @nonedate = CONVERT(datetime,'1910-1-1')
declare @ord2group2 nvarchar(50) 
set @ord2group2 = '' 
declare @sys_recid bigint 
set @sys_recid = 0 
  
 --- 以下是预处理事件中的临时表
 
exec drop_temp_table '#detail2' 
select *,null recid into #detail2 from order_268_2 with(nolock) where ord2_ordid=@ordid  
update #detail2 set recid=ord2_id 

 ---- 以下是开发人员写的 before link job 事件 --------------
 update order_260 set ord_dqzt = '维修后总部收货', ord_zbsjsjfc = getdate(), ord_cjclff = d.ord2_clff from #detail2 d where ord_dqzt = '待厂家收货维修' and ord_id = d.ord2_mdordid
 ---- 以上是开发人员写的 before libk job 事件 --------------
 
  
 
update old set 
ord2_bz=case when new.ord2_bz is null or new.ord2_bz = '_none_'  then old.ord2_bz else new.ord2_bz end,ord2_caption=case when new.ord2_caption is null or new.ord2_caption = '_none_'  then old.ord2_caption else new.ord2_caption end,ord2_clff=case when new.ord2_clff is null or new.ord2_clff = '_none_'  then old.ord2_clff else new.ord2_clff end,ord2_code=case when new.ord2_code is null or new.ord2_code = '_none_'  then old.ord2_code else new.ord2_code end,ord2_fatherord2id=case when new.ord2_fatherord2id is null or new.ord2_fatherord2id = -999999999  then old.ord2_fatherord2id else new.ord2_fatherord2id end,ord2_fbizid=case when new.ord2_fbizid is null or new.ord2_fbizid = -999999999  then old.ord2_fbizid else new.ord2_fbizid end,ord2_fcbz=case when new.ord2_fcbz is null or new.ord2_fcbz = '_none_'  then old.ord2_fcbz else new.ord2_fcbz end,ord2_fj=case when new.ord2_fj is null or new.ord2_fj = '_none_'  then old.ord2_fj else new.ord2_fj end,ord2_ford2id=case when new.ord2_ford2id is null or new.ord2_ford2id = -999999999  then old.ord2_ford2id else new.ord2_ford2id end,ord2_ford2tag=case when new.ord2_ford2tag is null or new.ord2_ford2tag = -999999999  then old.ord2_ford2tag else new.ord2_ford2tag end,ord2_fordid=case when new.ord2_fordid is null or new.ord2_fordid = -999999999  then old.ord2_fordid else new.ord2_fordid end,ord2_ftype=case when new.ord2_ftype is null or new.ord2_ftype = '_none_'  then old.ord2_ftype else new.ord2_ftype end,ord2_group=case when new.ord2_group is null or new.ord2_group = '_none_'  then old.ord2_group else new.ord2_group end,ord2_gz=case when new.ord2_gz is null or new.ord2_gz = '_none_'  then old.ord2_gz else new.ord2_gz end,ord2_jjlx=case when new.ord2_jjlx is null or new.ord2_jjlx = '_none_'  then old.ord2_jjlx else new.ord2_jjlx end,ord2_jsmd=case when new.ord2_jsmd is null or new.ord2_jsmd = '_none_'  then old.ord2_jsmd else new.ord2_jsmd end,ord2_jsr=case when new.ord2_jsr is null or new.ord2_jsr = '_none_'  then old.ord2_jsr else new.ord2_jsr end,ord2_key=case when new.ord2_key is null or new.ord2_key = '_none_'  then old.ord2_key else new.ord2_key end,ord2_order=case when new.ord2_order is null or new.ord2_order = -999999999  then old.ord2_order else new.ord2_order end,ord2_pp=case when new.ord2_pp is null or new.ord2_pp = '_none_'  then old.ord2_pp else new.ord2_pp end,ord2_rbizid=case when new.ord2_rbizid is null or new.ord2_rbizid = -999999999  then old.ord2_rbizid else new.ord2_rbizid end,ord2_rord2id=case when new.ord2_rord2id is null or new.ord2_rord2id = -999999999  then old.ord2_rord2id else new.ord2_rord2id end,ord2_rord2tag=case when new.ord2_rord2tag is null or new.ord2_rord2tag = -999999999  then old.ord2_rord2tag else new.ord2_rord2tag end,ord2_rordid=case when new.ord2_rordid is null or new.ord2_rordid = -999999999  then old.ord2_rordid else new.ord2_rordid end,ord2_rq=case when new.ord2_rq is null or new.ord2_rq <= @nonedate then old.ord2_rq else new.ord2_rq end,ord2_rtype=case when new.ord2_rtype is null or new.ord2_rtype = '_none_'  then old.ord2_rtype else new.ord2_rtype end,ord2_status=case when new.ord2_status is null or new.ord2_status = '_none_'  then old.ord2_status else new.ord2_status end,ord2_tags=case when new.ord2_tags is null or new.ord2_tags = '_none_'  then old.ord2_tags else new.ord2_tags end,ord2_wxlx=case when new.ord2_wxlx is null or new.ord2_wxlx = '_none_'  then old.ord2_wxlx else new.ord2_wxlx end,ord2_xh=case when new.ord2_xh is null or new.ord2_xh = '_none_'  then old.ord2_xh else new.ord2_xh end,ord2_ximei=case when new.ord2_ximei is null or new.ord2_ximei = '_none_'  then old.ord2_ximei else new.ord2_ximei end,ord2_zdimei=case when new.ord2_zdimei is null or new.ord2_zdimei = '_none_'  then old.ord2_zdimei else new.ord2_zdimei end,ord2_mdordid=case when new.ord2_mdordid is null or new.ord2_mdordid = -999999999  then old.ord2_mdordid else new.ord2_mdordid end
from order_268_2 old with(rowlock) , #detail2 new  
where old.ord2_id=new.ord2_id and (new.recid is not null)   

 
--- 清除临时表 
exec drop_temp_table '#detail2'

set nocount off 
end