#使用技巧#利用二开插件实现:销售订单审核后弹窗提醒+消息通知
一、业务背景
很多企业都有类似需求,希望在某个时机弹窗提醒下,或者是消息提醒,点击消息又可以直接打开单据;
实现效果如下图:
销售订单审核时,相关用户收到弹窗提醒(每次心跳事件触发,所有有延迟)也可以设置声音提醒,同时在信息中心-普通消息内多出一条消息,点击消息上的“查看单据”就可以打开单据
二、关键代码
using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using Kingdee.BOS.Orm.DataEntity; using System.Data; using Kingdee.BOS; using Kingdee.BOS.App.Data; using Kingdee.BOS.Core.DynamicForm.PlugIn.Args; using Kingdee.BOS.Core.DynamicForm.PlugIn; using Kingdee.BOS.Util; using Kingdee.BOS.ServiceHelper; using Kingdee.BOS.Workflow.Models.WindowRemind; using Kingdee.BOS.Core.Msg; using Kingdee.BOS.Orm.Drivers; namespace SX.PC.ServicePlugIn.Sal { [Kingdee.BOS.Util.HotUpdate] [Description("销售订单审核后消息推送")] public class SalOrderSendMsg : AbstractOperationServicePlugIn { public override void AfterExecuteOperationTransaction(AfterExecuteOperationTransaction e) { base.AfterExecuteOperationTransaction(e); if (base.FormOperation.Operation.ToUpper() == "AUDIT") { DynamicObject[] dataEntitys = e.DataEntitys; for (int i = 0; i < e.DataEntitys.Length; i++) { DynamicObject data = dataEntitys[i]; string fid = Convert.ToString(data["Id"]); string fbillno = Convert.ToString(data["BillNo"]); string Fdate = Convert.ToDateTime(data["Date"]).ToString("yyyy-MM-dd"); string FCUSTNAME = data["CustId"] as DynamicObject == null ? "" : (data["CustId"] as DynamicObject)["Name"].ToString(); string sql = string.Format(@" SELECT U.FUSERID,B.F_QYWXID FROM T_SAL_ORDER A INNER JOIN T_BD_STAFF T3 ON T3.FSTAFFID=A.F_TROrder --跟单员 INNER JOIN T_BD_PERSON T1 ON T1.FPERSONID=T3.FPERSONID left JOIN T_SEC_USER U ON U.FLINKOBJECT = T1.FPERSONID --用户 left join T_HR_EMPINFO T8 on T8.fid=T3.FEMPINFOID left JOIN T_HRVSQYXWEntry B ON B.F_KDHR= T8.FID --员工企业微信关联表 WHERE FBILLNO='{0}' ", fbillno); DataTable dt = DBServiceHelper.ExecuteDataSet(Context, sql).Tables[0]; if (dt.Rows.Count > 0) { int userid = Convert.ToInt32(dt.Rows[0]["FUSERID"]); string QYWXID = Convert.ToString(dt.Rows[0]["F_QYWXID"]); //int userid = 1047139; SaveBroadCastMsg(Context, userid); string title = "您有一条新订单,单据编号:" + fbillno + ",客户:" + FCUSTNAME + ",订单日期:" + Fdate + ",请及时处理"; string content = "您有一条新订单,单据编号:" + fbillno + ",客户:" + FCUSTNAME + ",订单日期:" + Fdate + ",请及时处理,点击上方“查看单据”可以直接打开本单据"; SendMessage(Context, "SAL_SaleOrder", fid, title, content, DateTime.Now, userid); //QYWeixinHelper QYWeixinHelper = new QYWeixinHelper(); ////推送企业微信,这里明天讲 //QYWeixinHelper.SendText(QYWXID, title); } } } } /// <summary> /// 弹窗提醒 /// </summary> /// <param name="ctx"></param> /// <param name="userid"></param> public void SaveBroadCastMsg(Context ctx, int userid) { BroadCastMsg msg = new BroadCastMsg(new DynamicObject(Kingdee.BOS.Workflow.Models.WindowRemind.BroadCastMsg.BroadCastMsgType)); msg.Title = new LocaleValue(Kingdee.BOS.Resource.ResManager.LoadKDString("您有新消息", "002406000006760", Kingdee.BOS.Resource.SubSystemType.BOS)); msg.Content = new LocaleValue("您有一条新订单,请点击更多查看"); msg.FailureTime = DateTime.Now.AddMinutes(3); //失效时间必须大于当前时间 msg.SendType = 4; //2=任务消息,3=流程消息,4=普通消息 msg.Id = DBServiceHelper.GetSequenceInt64(ctx, "T_BAS_BROADCASTMSG", 1).FirstOrDefault(); //主键 List<DynamicObject> recList = new List<DynamicObject>(); BroadCastReceiver rec = new BroadCastReceiver(); rec.Receiver = 955382;//FUserId rec.Id = msg.Id; recList.Add(rec); BusinessDataServiceHelper.Save(ctx, new DynamicObject[] { msg }); BusinessDataServiceHelper.Save(ctx, recList.ToArray()); } /// <summary> /// 消息-普通消息,传入id可以打开单据 /// </summary> /// <param name="ctx"></param> /// <param name="formId"></param> /// <param name="billId"></param> /// <param name="title"></param> /// <param name="content"></param> /// <param name="now"></param> /// <param name="receiverId"></param> /// <returns></returns> private Message SendMessage(Context ctx, string formId, string billId, string title, string content, DateTime now, long receiverId) { string messageId = SequentialGuid.NewGuid().ToString(); Message msg = new DynamicObject(Message.MessageDynamicObjectType); msg.MessageId = messageId; msg.Title = title; msg.Content = content; msg.CreateTime = now; msg.SenderId = ctx.UserId; msg.ObjectTypeId = formId; msg.KeyValue = billId; msg.ReceiverId = receiverId; IDbDriver driver = new OLEDbDriver(ctx); var dataManager = Kingdee.BOS.Orm.DataManagerUtils.GetDataManager(Message.MessageDynamicObjectType, driver); dataManager.Save(msg.DataEntity); return msg; } } }
三、小结
新版的也可以通过消息平台实现,此处讲解的方式正好是可以联动的,弹窗,点击就是信息中心--消息 界面;再点击“查看单据”就可以打开对应单据,比较方便。
这个消息代码执行完了,也没有消息提醍,弹窗也没出来
大佬,推送企业微信的教程有吗?
大神,请问这个可以转换为phython语句吗
在哪配置插件呀
这个二开能帮助大家解决实际问题,赞一个!
吸引我的不是你写代码的技术,是你的头像
感谢分享
#使用技巧#利用二开插件实现:销售订单审核后弹窗提醒+消息通知
一、业务背景很多企业都有类似需求,希望在某个时机弹窗提醒下,或者是消息提醒,点击消息又可以直接打开单据;实现效果如下图:销售订单审...
点击下载文档
本文2024-09-16 18:20:39发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-21529.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章