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

-- 生成时间:2018-08-14 15:42:33 by ebs-core  
create  procedure order_246_endmessage_3123_3016(
     @cmpid int, 
     @ordid bigint,
     @jbid bigint
  ) 
  as  
  begin  
set nocount on  

------ 给执行人发消息  ----------  

------ 给监督人发消息  ----------  

------ 给协作人发消息  ----------  

------ 给知会人发消息  ----------  

------ 给日志参与人发消息  ----------  

------ 给员工1发消息  ----------  

insert into ebs_kernel.dbo.pub_message(msg_cmpid,msg_mpid,msg_text,msg_senddate,msg_type,msg_target,msg_cuid)  
select @cmpid,22,ord_creator + '于【'+convert(nvarchar(100),ord_date,120)+'】发起了一项新的通知，请及时查看！'+char(13)+char(10)+
+'{title}通知公告:'+ord_bt+char(9)+
+'{url}/order/biztop.mobile.htm?crmid='+CONVERT(varchar,ord_bizid)+'&ordid='+CONVERT(varchar,ord_id)+'&jbid='+CONVERT(varchar,jb_id),getdate(),'DING',substring(cu_ding , 22,50)    , cu_id 
from order_246,mps_job,order_246_users,mps_login 
where  ord_id=@ordid and  jb_id=@jbid and  ordp_ordid=ord_id and ordp_type='mydocview' and cu_id=ordp_cuid and  
cu_type=0 and cu_ding>'' 

insert into mps_alarm_message(
 almmsg_cmpid,almmsg_almid,almmsg_identkey,almmsg_type,almmsg_title,almmsg_category,almmsg_cuid,almmsg_text,almmsg_objid,almmsg_jbid,almmsg_objtype) 
select @cmpid,22,',','message','通知公告','通知公告',cu_id,'你有一项新的(' + ord_type+char(9) + ')，请及时查看'
+'{title}工作提醒:'+ord_type+char(9)+
+'{url}/order/biztop.mobile.htm?crmid='+CONVERT(varchar,ord_bizid)+'&ordid='+CONVERT(varchar,ord_id)+'&jbid='+CONVERT(varchar,jb_id) , @ordid,@jbid ,'biz' 
from order_246,mps_job,order_246_users,mps_login 
where  ord_id=@ordid and  jb_id=@jbid and  ordp_ordid=ord_id and ordp_type='mydocview' and cu_id=ordp_cuid and  cu_type=0  

------ 给员工2发消息  ----------  

------ 给员工3发消息  ----------  


set nocount off  
end