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

-- 生成时间:2018-05-08 09:58:29 by ebs-core  
CREATE  procedure mps_customer1_full(
@cmpid int,  
    @ccid bigint, 
    @useruid int,
    @canedit int ) 
as  
begin  
set nocount on 
-- 首先取模板  t1  
declare @ctid int 
declare @cctag int
select @cctag=cc_tag,@ctid=cc_ctid from mps_customer1 where cc_id=@ccid 
if (@canedit=1)
select top 1 * from mps_template where  tmp_cmpid=@cmpid and tmp_type='cstdisp' and tmp_objid=@ctid  
else 
select top 1 * from mps_template where  tmp_cmpid=@cmpid and tmp_type='cst' and tmp_objid=@ctid  


-- 返回客户定义表t2  
   select * from mps_csttype where ct_id=@ctid 
   
  
  -- 返回客户的特殊权限  t3 
    select * from mps_customer1_users where ccp_ccid=@ccid and ccp_cuid=@useruid 
    
    --返回业务单数据 t4
    select * from mps_customer1 where cc_id = @ccid 
    -- 获取业务表主根据扩展数据  t5
    select  * from mps_customer1_0 where cc3_ccid = @ccid 
    
    --返回所有附件  t6
    select *, da_categoryid as datagroup from mps_attach where da_cmpid = @cmpid and da_type = 'cst'+convert(varchar(10),@cctag)   and da_objid = @ccid and da_objid2 = 0 order by da_categoryid 
      
     

--明细表数据
 
----以下是数据源 

--- 以下获取用户自定义SQL afterloaded 


--- 以上获取用户自定义SQL afterloaded 
set nocount off
end