Procházet zdrojové kódy

通知公告审批后下发消息通知

临城职教中职
liangkun před 2 roky
rodič
revize
6d67ad1254
7 změnil soubory, kde provedl 231 přidání a 199 odebrání
  1. +1
    -184
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Controllers/NoticeController.cs
  2. +15
    -11
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/Notice/FormFlow.js
  3. +1
    -1
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/News/NewsEntity.cs
  4. +1
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/News/NewsService.cs
  5. +2
    -2
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Notice/NoticeService.cs
  6. +5
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.WorkFlow/Learun.Application.WorkFlow.csproj
  7. +206
    -1
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.WorkFlow/NodeMethod/OA_NewsMethod.cs

+ 1
- 184
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Controllers/NoticeController.cs Zobrazit soubor

@@ -343,111 +343,9 @@ namespace Learun.Application.Web.Areas.LR_OAModule.Controllers
{
entity.F_NewsContent = WebHelper.HtmlEncode(entity.F_NewsContent);
noticeIBLL.SaveEntity(keyValue, entity);
//读取信息推送管理-通知公告推送(01)的配置
var informationPushEntity = sys_InformationPushIBLL.GetEntityByPushItem("01");
if (informationPushEntity != null && informationPushEntity.Status == true)
{
//推送微信和消息提醒表
Task.Run(async () => { await DoWeixinPush(entity); });
}
if (entity.F_IsSendFX.HasValue && entity.F_IsSendFX == true)
{
Task.Run(async () =>
{
using (var hubConnection = new HubConnection(ConfigurationManager.AppSettings["CommunicationServeraddress"]))
{
var hubProxy = hubConnection.CreateHubProxy("SignalRHub");
await hubConnection.Start();
await hubProxy.Invoke("PushAnnouncement", entity.F_NewsId, entity.F_FullHead, Util.Str.ReplaceHtml(HttpUtility.HtmlDecode(entity.F_NewsContent)).Length < 20 ? Util.Str.ReplaceHtml(HttpUtility.HtmlDecode(entity.F_NewsContent)) : Util.Str.ReplaceHtml(HttpUtility.HtmlDecode(entity.F_NewsContent)).Substring(0, 20), "news", entity.F_SendPostId, entity.F_SendDeptId);
}
});
}

return Success("保存成功!");
}

Task DoWeixinPush(NewsEntity entity)
{
//微信推送、消息提醒表
try
{
var allteacherlist = userIbll.GetAllList().Where(m =>
m.F_DeleteMark != 1 && m.F_EnabledMark == 1 && m.F_Description == "教师");
var userralationlist = userRelationIBLL.GetUserIdList("2");
var needpostuserlist = new List<UserEntity>();
if (!string.IsNullOrEmpty(entity.F_SendDeptId))
{
if (!entity.F_SendDeptId.Contains(","))
{
var departteacherlist = allteacherlist.Where(m => entity.F_SendDeptId == m.F_DepartmentId);
needpostuserlist.AddRange(departteacherlist.ToList());
if (!string.IsNullOrEmpty(entity.F_SendPostId))
{
var newpostuserlist = new List<UserEntity>();
foreach (var uuitem in needpostuserlist)
{
var postids = userralationlist?.Count(m => m.F_UserId == uuitem.F_UserId && entity.F_SendPostId.Contains(m.F_ObjectId));
if (postids > 0)
{
newpostuserlist.Add(uuitem);
}
}
needpostuserlist = newpostuserlist;
}
}
else
{
foreach (var senddeptid in entity.F_SendDeptId.Split(','))
{
var departteacherlist = allteacherlist.Where(m => senddeptid == m.F_DepartmentId);
needpostuserlist.AddRange(departteacherlist.ToList());
if (!string.IsNullOrEmpty(entity.F_SendPostId))
{
var newpostuserlist = new List<UserEntity>();
foreach (var uuitem in needpostuserlist)
{
var postids = userralationlist?.Count(m => m.F_UserId == uuitem.F_UserId && entity.F_SendPostId.Contains(m.F_ObjectId));
if (postids > 0)
{
newpostuserlist.Add(uuitem);
}
}
needpostuserlist = newpostuserlist;
}
}
}
}
else
{
if (!string.IsNullOrEmpty(entity.F_SendPostId))
{
//岗位下发
var newpostuserlist = new List<UserEntity>();
foreach (var uuitem in allteacherlist)
{
var postids = userralationlist?.Count(m => m.F_UserId == uuitem.F_UserId && entity.F_SendPostId.Contains(m.F_ObjectId));
if (postids > 0)
{
newpostuserlist.Add(uuitem);
}
}
needpostuserlist = newpostuserlist;
}
else
{
//全员下发
needpostuserlist = allteacherlist.ToList();
}
}
PushWeixin(needpostuserlist, entity.F_FullHead);
//消息提醒表
PushMessageRemind(needpostuserlist, entity);
return Task.CompletedTask;
}
catch (Exception e)
{
return Task.FromException(e);
}
return Success("保存成功!");
}

/// <summary>
@@ -477,87 +375,6 @@ namespace Learun.Application.Web.Areas.LR_OAModule.Controllers
noticeIBLL.RecycleForm(keyValue, "0");
return Success("操作成功!");
}
public void PushWeixin(List<UserEntity> needpostuserlist, string title)
{
var WeChatConfigentity = weChatConfigIbll.GetEnableEntity();
string appid = WeChatConfigentity.APPId;
string secret = WeChatConfigentity.secret;
var wechatemplete = weChatTempletIbll.GetWeChatTemplateEntityByCodeConfigId(WeChatConfigentity.ID, "task");
string weixintaskurl = wechatemplete.TUrl;
string weixintasktempid = wechatemplete.TempId;
var responsejson = Util.HttpMethods.HttpGet("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appid + "&secret=" + secret);

OperateLogModel operateLogModel = new OperateLogModel();
operateLogModel.title = title;
operateLogModel.type = OperationType.Other;
operateLogModel.url = "NoticeController";
operateLogModel.sourceObjectId = "002";
operateLogModel.sourceContentJson = responsejson;
OperatorHelper.Instance.WriteOperateLog(operateLogModel);

foreach (UserEntity userinfo in needpostuserlist)
{
if (userinfo != null && !string.IsNullOrEmpty(userinfo.OpenIdForWeixin))
{
//执行推送任务
if (!string.IsNullOrEmpty(appid) && !string.IsNullOrEmpty(secret) && !string.IsNullOrEmpty(weixintaskurl) && !string.IsNullOrEmpty(weixintasktempid))
{
if (!string.IsNullOrEmpty(responsejson))
{
var weixintokenobj = JsonConvert.DeserializeObject<dynamic>(responsejson);
if (string.IsNullOrEmpty(weixintokenobj.errcode))
{
string access_token = weixintokenobj.access_token;
string jsondata = "{\"touser\":\"" + userinfo.OpenIdForWeixin + "\"," +
"\"template_id\":\"" + weixintasktempid + "\"," +
"\"url\":\"" + weixintaskurl + "/#/?page=notice\"," +
"\"data\":{" +
"\"first\": {\"value\":\"您有新的未读通知公告\",\"color\":\"#173177\"}," +
"\"keyword1\":{\"value\":\"未读通知公告\",\"color\":\"#173177\"}," +
"\"keyword2\": {\"value\":\"" + title + "\",\"color\":\"#173177\"}," +
"\"keyword3\": {\"value\":\"待查看\",\"color\":\"#173177\"}," +
"\"keyword4\": {\"value\":\"您有新的未读通知公告【" + title + "】\",\"color\":\"#173177\"}" +
"}" +
"}";
string pushresult = Util.HttpMethods.HttpPost("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + access_token, jsondata);

operateLogModel.title = title;
operateLogModel.type = OperationType.Other;
operateLogModel.url = "NoticeController";
operateLogModel.sourceObjectId = "002";
operateLogModel.sourceContentJson = pushresult;
OperatorHelper.Instance.WriteOperateLog(operateLogModel);
}
}
}
}
}
}

/// <summary>
/// 消息提醒
/// </summary>
/// <param name="needpostuserlist"></param>
/// <param name="title"></param>
public void PushMessageRemind(List<UserEntity> needpostuserlist, NewsEntity model)
{
foreach (UserEntity userinfo in needpostuserlist)
{
MessageRemindEntity entity = new MessageRemindEntity();
entity.ReceiptId = userinfo.F_UserId;
entity.ReceiptName = userinfo.F_RealName;
entity.SenderId = model.F_CreateUserId;
entity.SenderName = model.F_CreateUserName;
entity.TheTitle = "通知公告";
entity.TheContent = model.F_FullHead;
entity.InstanceId = model.F_NewsId;
entity.ConnectionUrl = "/Utility/ListContentIndex?id=";
entity.SendTime = DateTime.Now;
entity.ReadSigns = false;
messageRindIBLL.SaveEntity("", entity);
}

}
#endregion

#region 流程


+ 15
- 11
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/Notice/FormFlow.js Zobrazit soubor

@@ -66,17 +66,21 @@ var bootstrap = function ($, learun) {
setFormData = function (processId) {
if (!!processId) {
$.lrSetForm(top.$.rootUrl + '/LR_OAModule/Notice/GetFormDataByProcessId?processId=' + processId, function (data) {
for (var id in data) {
if (!!data[id] && data[id].length > 0) {
$('#' + id).jfGridSet('refreshdata', data[id]);
}
else {
if (id == 'Sys_ReceiveFile') {
keyValue = data[id].F_DeptRelationId;
}
$('[data-table="' + id + '"]').lrSetFormData(data[id]);
}
}
$('#form').lrSetFormData(data);
setTimeout(function () {
ue.setContent(data.F_NewsContent);
}, 100);
//for (var id in data) {
// if (!!data[id] && data[id].length > 0) {
// $('#' + id).jfGridSet('refreshdata', data[id]);
// }
// else {
// if (id == 'Sys_ReceiveFile') {
// keyValue = data[id].F_DeptRelationId;
// }
// $('[data-table="' + id + '"]').lrSetFormData(data[id]);
// }
//}
});
}
}


+ 1
- 1
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/News/NewsEntity.cs Zobrazit soubor

@@ -225,7 +225,7 @@ namespace Learun.Application.OA
this.F_CreateDate = DateTime.Now;
this.F_ReleaseTime = DateTime.Now;
this.F_DeleteMark = 0;
this.F_EnabledMark = 1;
this.F_EnabledMark = 0;
F_Status = "0";
this.F_PV = 0;



+ 1
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/News/NewsService.cs Zobrazit soubor

@@ -191,6 +191,7 @@ namespace Learun.Application.OA
if (status == 2)
{
newEntity.F_Status = "2";
newEntity.F_EnabledMark = 1;
}
else
{


+ 2
- 2
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Notice/NoticeService.cs Zobrazit soubor

@@ -27,7 +27,7 @@ namespace Learun.Application.OA
try
{
var strSql = new StringBuilder();
strSql.Append("SELECT * FROM LR_OA_News t WHERE t.F_TypeId = 2 and F_Status<>'-1' ");
strSql.Append("SELECT * FROM LR_OA_News t WHERE t.F_TypeId = 2 and F_Status<>'-1' and F_DeleteMark=0");
if (!string.IsNullOrEmpty(keyword))
{
strSql.Append(" AND F_FullHead like @keyword");
@@ -213,7 +213,7 @@ namespace Learun.Application.OA
var strSql = new StringBuilder();
strSql.Append("SELECT t.*,r.RNewsId,r.RTime FROM LR_OA_News t ");
strSql.Append(" left join LR_OA_NewsRead r on t.F_NewsId = r.NewsId and r.RUserId=@userId ");
strSql.Append(" WHERE t.F_TypeId = 2 and F_Status<>'-1' ");
strSql.Append(" WHERE t.F_TypeId = 2 and F_Status<>'-1' and t.F_DeleteMark=0 ");
if (!string.IsNullOrEmpty(categoryId))
{
strSql.Append($" AND F_CategoryId = '{categoryId}'");


+ 5
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.WorkFlow/Learun.Application.WorkFlow.csproj Zobrazit soubor

@@ -77,6 +77,7 @@
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@@ -216,6 +217,10 @@
<Project>{81c03609-ae0d-414c-829b-16b990487add}</Project>
<Name>Learun.Ioc</Name>
</ProjectReference>
<ProjectReference Include="..\..\Learun.Util\Learun.Util.Operat\Learun.Util.Operat.csproj">
<Project>{ad556b7a-e0d1-41bd-9d5b-18f8502e9f33}</Project>
<Name>Learun.Util.Operat</Name>
</ProjectReference>
<ProjectReference Include="..\..\Learun.Util\Learun.Util\Learun.Util.csproj">
<Project>{cf8ae293-88ab-436c-9720-a8386ba5d7b7}</Project>
<Name>Learun.Util</Name>


+ 206
- 1
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.WorkFlow/NodeMethod/OA_NewsMethod.cs Zobrazit soubor

@@ -1,26 +1,231 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using Learun.Application.Base.AuthorizeModule;
using Learun.Application.Base.SystemModule;
using Learun.Application.OA;
using Learun.Application.Organization;
using Learun.Application.TwoDevelopment.EducationalAdministration;
using Learun.Application.TwoDevelopment.LR_Desktop;
using Learun.Util.Operat;
using Microsoft.AspNet.SignalR.Client;
using Newtonsoft.Json;

namespace Learun.Application.WorkFlow
{
public class OA_NewsMethod : IWorkFlowMethod
{

NewsIBLL newsIBLL=new NewsBLL();
NewsIBLL newsIBLL = new NewsBLL();
private NoticeIBLL noticeIBLL = new NoticeBLL();
private WeChatConfigIBLL weChatConfigIbll = new WeChatConfigBLL();
private WeChatTempletIBLL weChatTempletIbll = new WeChatTempletBLL();
private UserIBLL userIbll = new UserBLL();
private UserRelationIBLL userRelationIBLL = new UserRelationBLL();
private Sys_InformationPushIBLL sys_InformationPushIBLL = new Sys_InformationPushBLL();
private MessageRindIBLL messageRindIBLL = new MessageRindBLL();
public void Execute(WfMethodParameter parameter)
{
if (parameter.code == "agree")
{
newsIBLL.ChangeStatusByProcessId(parameter.processId, 2);
var entity = noticeIBLL.GetEntityByProcessId(parameter.processId);
//推送通知
//读取信息推送管理-通知公告推送(01)的配置
var informationPushEntity = sys_InformationPushIBLL.GetEntityByPushItem("01");
if (informationPushEntity != null && informationPushEntity.Status == true)
{
//推送微信
Task.Run(async () => { await DoWeixinPush(entity); });
}
if (entity.F_IsSendFX.HasValue && entity.F_IsSendFX == true)
{
Task.Run(async () =>
{
using (var hubConnection = new HubConnection(ConfigurationManager.AppSettings["CommunicationServeraddress"]))
{
var hubProxy = hubConnection.CreateHubProxy("SignalRHub");
await hubConnection.Start();
await hubProxy.Invoke("PushAnnouncement", entity.F_NewsId, entity.F_FullHead, Util.Str.ReplaceHtml(HttpUtility.HtmlDecode(entity.F_NewsContent)).Length < 20 ? Util.Str.ReplaceHtml(HttpUtility.HtmlDecode(entity.F_NewsContent)) : Util.Str.ReplaceHtml(HttpUtility.HtmlDecode(entity.F_NewsContent)).Substring(0, 20), "news", entity.F_SendPostId, entity.F_SendDeptId);
}
});
}
}
else
{
newsIBLL.ChangeStatusByProcessId(parameter.processId, 0);
}
}

Task DoWeixinPush(NewsEntity entity)
{
//微信推送
try
{
var allteacherlist = userIbll.GetAllList().Where(m =>
m.F_DeleteMark != 1 && m.F_EnabledMark == 1 && m.F_Description == "教师");
var userralationlist = userRelationIBLL.GetUserIdList("2");
var needpostuserlist = new List<UserEntity>();
if (!string.IsNullOrEmpty(entity.F_SendDeptId))
{
if (!entity.F_SendDeptId.Contains(","))
{
var departteacherlist = allteacherlist.Where(m => entity.F_SendDeptId == m.F_DepartmentId);
needpostuserlist.AddRange(departteacherlist.ToList());
if (!string.IsNullOrEmpty(entity.F_SendPostId))
{
var newpostuserlist = new List<UserEntity>();
foreach (var uuitem in needpostuserlist)
{
var postids = userralationlist?.Count(m => m.F_UserId == uuitem.F_UserId && entity.F_SendPostId.Contains(m.F_ObjectId));
if (postids > 0)
{
newpostuserlist.Add(uuitem);
}
}
needpostuserlist = newpostuserlist;
}
}
else
{
foreach (var senddeptid in entity.F_SendDeptId.Split(','))
{
var departteacherlist = allteacherlist.Where(m => senddeptid == m.F_DepartmentId);
needpostuserlist.AddRange(departteacherlist.ToList());
if (!string.IsNullOrEmpty(entity.F_SendPostId))
{
var newpostuserlist = new List<UserEntity>();
foreach (var uuitem in needpostuserlist)
{
var postids = userralationlist?.Count(m => m.F_UserId == uuitem.F_UserId && entity.F_SendPostId.Contains(m.F_ObjectId));
if (postids > 0)
{
newpostuserlist.Add(uuitem);
}
}
needpostuserlist = newpostuserlist;
}
}
}
}
else
{
if (!string.IsNullOrEmpty(entity.F_SendPostId))
{
//岗位下发
var newpostuserlist = new List<UserEntity>();
foreach (var uuitem in allteacherlist)
{
var postids = userralationlist?.Count(m => m.F_UserId == uuitem.F_UserId && entity.F_SendPostId.Contains(m.F_ObjectId));
if (postids > 0)
{
newpostuserlist.Add(uuitem);
}
}
needpostuserlist = newpostuserlist;
}
else
{
//全员下发
needpostuserlist = allteacherlist.ToList();
}
}
PushWeixin(needpostuserlist, entity.F_FullHead);

//消息提醒表
PushMessageRemind(needpostuserlist, entity);
return Task.CompletedTask;
}
catch (Exception e)
{
return Task.FromException(e);
}
}

public void PushWeixin(List<UserEntity> needpostuserlist, string title)
{
var WeChatConfigentity = weChatConfigIbll.GetEnableEntity();
string appid = WeChatConfigentity.APPId;
string secret = WeChatConfigentity.secret;
var wechatemplete = weChatTempletIbll.GetWeChatTemplateEntityByCodeConfigId(WeChatConfigentity.ID, "task");
string weixintaskurl = wechatemplete.TUrl;
string weixintasktempid = wechatemplete.TempId;
var responsejson = Util.HttpMethods.HttpGet("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appid + "&secret=" + secret);

OperateLogModel operateLogModel = new OperateLogModel();
operateLogModel.title = title;
operateLogModel.type = OperationType.Other;
operateLogModel.url = "NoticeController";
operateLogModel.sourceObjectId = "002";
operateLogModel.sourceContentJson = responsejson;
OperatorHelper.Instance.WriteOperateLog(operateLogModel);

foreach (UserEntity userinfo in needpostuserlist)
{
if (userinfo != null && !string.IsNullOrEmpty(userinfo.OpenIdForWeixin))
{
//执行推送任务
if (!string.IsNullOrEmpty(appid) && !string.IsNullOrEmpty(secret) && !string.IsNullOrEmpty(weixintaskurl) && !string.IsNullOrEmpty(weixintasktempid))
{
if (!string.IsNullOrEmpty(responsejson))
{
var weixintokenobj = JsonConvert.DeserializeObject<dynamic>(responsejson);
if (string.IsNullOrEmpty(weixintokenobj.errcode))
{
string access_token = weixintokenobj.access_token;
string jsondata = "{\"touser\":\"" + userinfo.OpenIdForWeixin + "\"," +
"\"template_id\":\"" + weixintasktempid + "\"," +
"\"url\":\"" + weixintaskurl + "\"," +
"\"data\":{" +
"\"first\": {\"value\":\"您有新的未读通知公告\",\"color\":\"#173177\"}," +
"\"keyword1\":{\"value\":\"未读通知公告\",\"color\":\"#173177\"}," +
"\"keyword2\": {\"value\":\"" + title + "\",\"color\":\"#173177\"}," +
"\"keyword3\": {\"value\":\"待查看\",\"color\":\"#173177\"}," +
"\"keyword4\": {\"value\":\"您有新的未读通知公告【" + title + "】\",\"color\":\"#173177\"}" +
"}" +
"}";
string pushresult = Util.HttpMethods.HttpPost("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + access_token, jsondata);

operateLogModel.title = title;
operateLogModel.type = OperationType.Other;
operateLogModel.url = "NoticeController";
operateLogModel.sourceObjectId = "002";
operateLogModel.sourceContentJson = pushresult;
OperatorHelper.Instance.WriteOperateLog(operateLogModel);
}
}
}
}
}
}

/// <summary>
/// 消息提醒
/// </summary>
/// <param name="needpostuserlist"></param>
/// <param name="title"></param>
public void PushMessageRemind(List<UserEntity> needpostuserlist, NewsEntity model)
{
foreach (UserEntity userinfo in needpostuserlist)
{
MessageRemindEntity entity = new MessageRemindEntity();
entity.ReceiptId = userinfo.F_UserId;
entity.ReceiptName = userinfo.F_RealName;
entity.SenderId = model.F_CreateUserId;
entity.SenderName = model.F_CreateUserName;
entity.TheTitle = "通知公告";
entity.TheContent = model.F_FullHead;
entity.InstanceId = model.F_NewsId;
entity.ConnectionUrl = "/Utility/ListContentIndex?id=";
entity.SendTime = DateTime.Now;
entity.ReadSigns = false;
messageRindIBLL.SaveEntity("", entity);
}

}
}
}

Načítá se…
Zrušit
Uložit