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

-- 生成时间:2018-06-27 12:21:10 by ebs-core  
create  procedure order_238_startmessage_3173(
     @cmpid int, 
     @ordid bigint,
     @jbid bigint
  ) 
  as  
  begin  
set nocount on  

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

insert into ebs_kernel.dbo.pub_message(msg_cmpid,msg_mpid,msg_text,msg_senddate,msg_type,msg_target,msg_cuid)  
select @cmpid,11,'你有一项新的工作('+jb_title+')需要及时处理
单据名称：【'+ord_type+'】
单据编号：【'+ord_no+'】
创建人名：【'+ord_creator+'】
创建部门：【'+ord_createdepart+'】
查看详情点我'
+'{title}工作提醒:'+ord_type+char(9)+'('+ord_creator+')'+
+'{url}/order/biztop.mobile.htm?crmid='+CONVERT(varchar,ord_bizid)+'&ordid='+CONVERT(varchar,ord_id)+'&jbid='+CONVERT(varchar,jb_id),getdate(),'QYH',substring(cu_qyh , 20,50)  ,cu_id 
from order_238,mps_job,mps_login,mps_job_users 
where  ord_id=@ordid and  jb_id=@jbid and  jp_type='wrkexecutor' and jp_jbid=@jbid and jp_cuid=cu_id and 
cu_type=0 and cu_qyh>'' 

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,11,',','message','工作提醒','工作提醒',cu_id,'你有一项新的工作('+jb_title+')需要及时处理
单据名称：【'+ord_type+'】
单据编号：【'+ord_no+'】
创建人：【'+ord_creator+'】
点我查看详情'
+'{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_238,mps_job,mps_login,mps_job_users 
where  ord_id=@ordid and  jb_id=@jbid and  jp_type='wrkexecutor' and jp_jbid=@jbid and jp_cuid=cu_id and cu_type=0  

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

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

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

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

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

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

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


set nocount off  
end