瀏覽代碼

通知公告增加直接发布不走流程版本

新疆影视学院高职
liangkun 3 年之前
父節點
當前提交
e4dc8f6d75
共有 5 個文件被更改,包括 251 次插入2 次删除
  1. +200
    -1
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Controllers/NoticeController.cs
  2. +1
    -1
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/Notice/Form.js
  3. +19
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Notice/NoticeBLL.cs
  4. +1
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Notice/NoticeIBLL.cs
  5. +30
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Notice/NoticeService.cs

+ 200
- 1
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Controllers/NoticeController.cs 查看文件

@@ -31,6 +31,12 @@ namespace Learun.Application.Web.Areas.LR_OAModule.Controllers
{
private NoticeIBLL noticeIBLL = new NoticeBLL();
private DataItemIBLL dataItemIbll = new DataItemBLL();
private Sys_InformationPushIBLL sys_InformationPushIBLL = new Sys_InformationPushBLL();
private MessageRindIBLL messageRindIBLL = new MessageRindBLL();
private WeChatConfigIBLL weChatConfigIbll = new WeChatConfigBLL();
private WeChatTempletIBLL weChatTempletIbll = new WeChatTempletBLL();
private UserIBLL userIbll = new UserBLL();
private UserRelationIBLL userRelationIBLL = new UserRelationBLL();

private DepartmentReleasePermissionsIBLL departmentReleasePermissionsIbll =
new DepartmentReleasePermissionsBLL();
@@ -316,7 +322,200 @@ namespace Learun.Application.Web.Areas.LR_OAModule.Controllers
return Success("保存成功!");
}

[HttpPost, ValidateAntiForgeryToken, AjaxOnly, ValidateInput(false)]
public ActionResult SaveFormAndSubmit(string keyValue, NewsEntity entity)
{
entity.F_NewsContent = WebHelper.HtmlEncode(entity.F_NewsContent);
noticeIBLL.SaveFormAndSubmit(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);
}
}

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);
}

}


/// <summary>
/// 删除表单数据


+ 1
- 1
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/Notice/Form.js 查看文件

@@ -56,7 +56,7 @@ var bootstrap = function ($, learun) {

var postData = $('#form').lrGetFormData(keyValue);
postData["F_NewsContent"] = ue.getContent(null, null, true);
$.lrSaveForm(top.$.rootUrl + '/LR_OAModule/Notice/SaveForm?keyValue=' + keyValue, postData, function (res) {
$.lrSaveForm(top.$.rootUrl + '/LR_OAModule/Notice/SaveFormAndSubmit?keyValue=' + keyValue, postData, function (res) {
// 保存成功后才回调
if (!!callBack) {
callBack();


+ 19
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Notice/NoticeBLL.cs 查看文件

@@ -181,6 +181,25 @@ namespace Learun.Application.OA
}
}

public void SaveFormAndSubmit(string keyValue, NewsEntity entity)
{
try
{
noticeService.SaveFormAndSubmit(keyValue, entity);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}

#endregion
}
}

+ 1
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Notice/NoticeIBLL.cs 查看文件

@@ -55,5 +55,6 @@ namespace Learun.Application.OA

void ChangeStatusById(string keyValue, int i, string processId);
NewsEntity GetEntityByProcessId(string processId);
void SaveFormAndSubmit(string keyValue, NewsEntity entity);
}
}

+ 30
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Notice/NoticeService.cs 查看文件

@@ -218,5 +218,35 @@ namespace Learun.Application.OA
}
}
}

public void SaveFormAndSubmit(string keyValue, NewsEntity entity)
{
try
{
entity.F_TypeId = 2;
if (!string.IsNullOrEmpty(keyValue))
{
entity.Modify(keyValue);
this.BaseRepository().Update(entity);
}
else
{
entity.Create();
entity.F_EnabledMark = 1;
this.BaseRepository().Insert(entity);
}
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
}
}

Loading…
取消
儲存