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

   

-- 生成时间:2017-12-14 15:47:18 by ebs-core  
CREATE  procedure [dbo].[report_1_1](
     @cmpid int, 
     @rptid 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 =rpt_identkey from mps_report where rpt_id=@rptid 
 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,@rptid,'report' 
select cu_id as cuid,a.* into #user from #myuser , mps_login a where cu_id=cuid 
drop table #myuser

 ---- 以下预警事件代码 --------------
 
if (@identkey<>@identkeyold and @identkey<>'abort' and @identkey<>'remove') 
 insert into ebs_kernel.dbo.pub_message(
 msg_cmpid,msg_mpid,msg_senddate,msg_type,msg_target,msg_cuid,msg_text) 
 select @cmpid,1,getdate(),'GZH',
case when cu_gzh1 like '5432543254325%'  then substring(cu_gzh1,15,50) 
when cu_gzh2 like '5432543254325%'  then substring(cu_gzh2,15,50) 
when cu_gzh3 like '5432543254325%'  then substring(cu_gzh3,15,50) 
when cu_gzh4 like '5432543254325%'  then substring(cu_gzh4,15,50) 
when cu_gzh5 like '5432543254325%'  then substring(cu_gzh5,15,50) end, cuid,'gsgfsdgfdsgfdsf' from #user 
if (@identkey<>@identkeyold and @identkey<>'abort' and @identkey<>'remove') 
 insert into ebs_kernel.dbo.pub_message(
 msg_cmpid,
msg_mpid,msg_senddate,msg_type,msg_target,msg_cuid,msg_text) 
 select @cmpid,1,getdate(),'QYH',
substring(cu_qyh , 17,50), cuid,'gfdsgdsgfdsgfds' from #user 
if (@identkey<>@identkeyold and @identkey<>'abort' and @identkey<>'remove') 
 insert into ebs_kernel.dbo.pub_message(
 msg_cmpid,msg_mpid,msg_senddate,msg_type,msg_target,msg_cuid,msg_text) 
 select @cmpid,1,getdate(),'QYH',
substring(cu_ding , 17,50), cuid,'gfdsgfdsgfdsgfdsgfdsgfdsgfds' from #user 

delete #user where len(cu_mobile)<11 
if (3>0) delete #user where (cu_ding+cu_qyh+cu_gzh1+cu_gzh2+cu_gzh3+cu_gzh4+cu_gzh5)>'' 
if (@identkey<>@identkeyold and @identkey<>'abort' and @identkey<>'remove') 
 insert into ebs_kernel.dbo.pub_message(
 msg_cmpid,msg_mpid,msg_senddate,msg_type,msg_target,msg_cuid,msg_text) 
 select @cmpid,1,getdate(),'QYH',
cu_mobile, cuid,'gfdsgfdsgfdsgf'+ord_no from #user 
if (@identkey<>@identkeyold and @identkey<>'abort' and @identkey<>'remove') 
 insert into mps_alarm_message(
 almmsg_cmpid,
almmsg_almid,almmsg_identkey,almmsg_type,almmsg_title,almmsg_category,almmsg_cuid,almmsg_text) 
 select @cmpid,1,@identkey,'alarm','测试报表','业务类报表', cuid,'fdasfdsafd'+'fdsafdsafds' from #user 


 ---- 以上预警事件代码 --------------
 
 -- 调整identkey 
 if (@identkey<>@identkeyold and @identkey<>'abort' and @identkey<>'remove') 
 begin
 update mps_report set rpt_identkey=@identkey where rpt_id=@rptid 
 end 
 if (@identkey='remove') 
 begin
 update mps_report set rpt_identkey=''  where rpt_id=@rptid  
 end 
 
 

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


set nocount off 
end