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


-- 生成时间:2017-12-14 17:33:57 by ebs-core  
create  procedure ebs_1_alarm_1(
     @cmpid int, 
     @almid int
  ) 
as  
begin  
set nocount on  
declare @identkey nvarchar(100) 
declare @identkeyold nvarchar(100) 
declare @resultdata1 nvarchar(4000) 
declare @resultdata2 nvarchar(4000) 
declare @resultdata3 nvarchar(4000) 
declare @resultdata4 nvarchar(4000) 
declare @resultdata5 nvarchar(4000) 
declare @resultdata6 nvarchar(4000) 
declare @resultdata7 nvarchar(4000) 
declare @resultdata8 nvarchar(4000)
declare @resultdata9 nvarchar(4000)  
set @resultdata1 = '' 
set @resultdata2 = '' 
set @resultdata3 = '' 
set @resultdata4 = '' 
set @resultdata5 = '' 
set @resultdata6 = '' 
set @resultdata7 = '' 
set @resultdata8 = '' 
set @resultdata9 = '' 

 select @identkey =alm_identkey from mps_alarm where alm_id=@almid 
 set @identkeyold=@identkey
 set @identkey = isnull(@identkey,'none') 
 if (@identkey='') set @identkey = 'noidentkey'
 declare @almtitle nvarchar(100) 
 set @almtitle = ''  
 declare @almcategory nvarchar(100) 
 set @almcategory = ''  
 declare @sourceobjids varchar(MAX) 
 set @sourceobjids = '' 
 
 declare @newordid bigint 
 declare @branchid int 
 declare @userdpid int 
 declare @userotid int 
 declare @useruid int 
 declare @stype varchar(20) 
 declare @sordids varchar(max) 
 
 --- 以下是预处理事件中的临时表
 
-- 生成人员信息 
create table #myuser(pptype varchar(30),cuid int, grp int) 
exec mps_gen_powerusers @cmpid,0,0,0,0,0,0,0,0,'biz',0,0,0,@almid,'alarm' 
select distinct cuid into #user from #myuser
drop table #myuser

 ---- 以下预警事件代码 --------------
 
select cuid,'{alarmtext}' from #master where ord_htjzrq < getdate() + 20 


 ---- 以上预警事件代码 --------------
 
 -- 调整identkey 
 if (@identkey<>@identkeyold and @identkey<>'abort' and @identkey<>'remove') 
 begin
 update mps_alarm set alm_identkey=@identkey where alm_id=@almid 
 end 
 if (@identkey='remove') 
 begin
 update mps_alarm set alm_identkey=''  where alm_id=@almid  
 end 
 
 
 -- 生成新业务


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


set nocount off 
end