|
@@ -4,6 +4,7 @@ using NPOI.SS.Formula.Functions;
|
|
|
using OASystem.Domain;
|
|
|
using OASystem.Domain.Dtos.System;
|
|
|
using OASystem.Domain.ViewModels.QiYeWeChat;
|
|
|
+using OASystem.Infrastructure.Tools;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
@@ -121,7 +122,7 @@ namespace OASystem.Infrastructure.Repositories.System
|
|
|
And smra.IsDel = 0
|
|
|
And smra.ReadableUId = {0}
|
|
|
Order By ReleaseTime Desc ", dto.UserId);
|
|
|
- var _readableMsgList = await _sqlSugar.SqlQueryable<ReadbleMessageView>(msgSqlWhere).ToListAsync();
|
|
|
+ var _readableMsgList = await _sqlSugar.SqlQueryable<ReadbleMessageView1>(msgSqlWhere).ToListAsync();
|
|
|
if (_readableMsgList.Count > 0)
|
|
|
{
|
|
|
int pageSize = dto.PageSize; // 每页显示的记录数量
|
|
@@ -177,7 +178,7 @@ namespace OASystem.Infrastructure.Repositories.System
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 获取消息列表
|
|
|
+ /// 获取消息类型列表
|
|
|
/// </summary>
|
|
|
/// <param name="uId">可读用户Id</param>
|
|
|
/// <returns></returns>
|
|
@@ -185,9 +186,29 @@ namespace OASystem.Infrastructure.Repositories.System
|
|
|
{
|
|
|
Result result = new Result() { Code = -1, Msg = "未知错误", Data = null };
|
|
|
|
|
|
- if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/android
|
|
|
+ //userId
|
|
|
+ string msgSqlWhere = $" And smra.ReadableUId = {dto.UserId}";
|
|
|
+
|
|
|
+ //消息类型
|
|
|
+ List<NotificationTypeView> messageTypeViews = AppSettingsHelper.Get<NotificationTypeView>("MessageNotificationType");
|
|
|
+
|
|
|
+ string msgSql = string.Format(@"Select * From(
|
|
|
+ Select row_number() over(order by sm.ReleaseTime Desc) as RowNumber,
|
|
|
+ sm.Id,sm.Type,sm.Title,sm.Content,sd.DepName issuerDep,su.CnName issuerUser,
|
|
|
+ sm.ReleaseTime,smra.ReadableUId,smra.IsRead,sm.DiId,sm.Param
|
|
|
+ From Sys_Message sm
|
|
|
+ Inner Join Sys_MessageReadAuth smra On sm.Id = smra.MsgId
|
|
|
+ Inner Join Sys_Users su On sm.IssuerId = su.Id
|
|
|
+ Inner Join Sys_Department sd On su.DepId = sd.Id
|
|
|
+ Inner Join Sys_Users suAuth On smra.ReadableUId = suAuth.Id
|
|
|
+ Where sm.IsDel = 0
|
|
|
+ And smra.IsDel = 0 {0}
|
|
|
+ ) Temp", msgSqlWhere);
|
|
|
+
|
|
|
+ var data = await _sqlSugar.SqlQueryable<MessageListView>(msgSql).ToListAsync();
|
|
|
+
|
|
|
+ if (data.Count > 0)
|
|
|
{
|
|
|
-
|
|
|
var msgTypeResult = await _setData.GetSetDataBySTId(_setData, 77);
|
|
|
if (msgTypeResult.Code != 0)
|
|
|
{
|
|
@@ -197,42 +218,36 @@ namespace OASystem.Infrastructure.Repositories.System
|
|
|
string msgTypeDataStr = JsonConvert.SerializeObject(msgTypeResult.Data);
|
|
|
var msgTypeData = JsonConvert.DeserializeObject<List<MessageTypeView>>(msgTypeDataStr);
|
|
|
|
|
|
- string msgSqlWhere = string.Format(@"Select sm.Id,sm.Type,sm.Title,sm.Content,sd.DepName issuerDep,su.CnName issuerUser,
|
|
|
- sm.ReleaseTime,smra.Id AuthId,smra.ReadableUId,smra.IsRead,smra.ReadTime
|
|
|
- From Sys_Message sm
|
|
|
- Inner Join Sys_MessageReadAuth smra On sm.Id = smra.MsgId
|
|
|
- Inner Join Sys_Users su On sm.IssuerId = su.Id
|
|
|
- Inner Join Sys_Department sd On su.DepId = sd.Id
|
|
|
- Inner Join Sys_Users suAuth On smra.ReadableUId = suAuth.Id
|
|
|
- Where sm.IsDel = 0
|
|
|
- And smra.IsDel = 0
|
|
|
- And smra.ReadableUId = {0}
|
|
|
- Order By ReleaseTime Desc ", dto.UserId);
|
|
|
- var _readableMsgList = await _sqlSugar.SqlQueryable<ReadbleMessageView>(msgSqlWhere).ToListAsync();
|
|
|
- if (_readableMsgList.Count > 0)
|
|
|
- {
|
|
|
- //操作通知 OperationNotification
|
|
|
- var operationNotificationData = _readableMsgList.Where(it => _operationTypeList.Contains(it.Type)).OrderBy(it => it.IsRead).ToList();
|
|
|
- int operationNotificationDataCount = operationNotificationData.Count;
|
|
|
-
|
|
|
- //任务通知
|
|
|
- var taskNotificationData = _readableMsgList.Where(it => _taskTypeList.Contains(it.Type)).OrderBy(it => it.IsRead).ToList();
|
|
|
- int taskNotificationDataCount = taskNotificationData.Count;
|
|
|
+ //操作通知 OperationNotification
|
|
|
+ var operationNotificationData = data.Where(it => _operationTypeList.Contains(it.Type)).OrderBy(it => it.IsRead).ToList();
|
|
|
+ int operationNotificationDataCount = operationNotificationData.Where(it => it.IsRead == 0).ToList().Count;
|
|
|
|
|
|
- foreach (var item in msgTypeData)
|
|
|
- {
|
|
|
- //1021 团组操作通知 1020 任务操作通知
|
|
|
- if (item.Id == 1020) item.UnReadCount = taskNotificationDataCount;
|
|
|
- else if (item.Id == 1021) item.UnReadCount = operationNotificationDataCount ;
|
|
|
- }
|
|
|
+ //任务通知
|
|
|
+ var taskNotificationData = data.Where(it => _taskTypeList.Contains(it.Type)).OrderBy(it => it.IsRead).ToList();
|
|
|
+ int taskNotificationDataCount = taskNotificationData.Where(it => it.IsRead == 0).ToList().Count;
|
|
|
|
|
|
+ foreach (var item in msgTypeData)
|
|
|
+ {
|
|
|
+ //1021 团组操作通知 1020 任务操作通知
|
|
|
+ if (item.Id == 1020) item.UnReadCount = taskNotificationDataCount;
|
|
|
+ else if (item.Id == 1021) item.UnReadCount = operationNotificationDataCount;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (dto.PortType == 1 || dto.PortType == 2) // web/android
|
|
|
+ {
|
|
|
result.Code = 0;
|
|
|
- result.Msg = "成功!";
|
|
|
result.Data = msgTypeData;
|
|
|
+
|
|
|
}
|
|
|
- else
|
|
|
+ else if (dto.PortType == 3)
|
|
|
{
|
|
|
- result.Msg = "暂无该用户相关消息!";
|
|
|
+
|
|
|
+ result.Code = 0;
|
|
|
+ result.Data = new {
|
|
|
+ MsgTypeData = msgTypeData,
|
|
|
+ FirstUnreadData = data[0],
|
|
|
+ UnreadTotalCount = data.Where(it => it.IsRead == 0).ToList().Count,
|
|
|
+ };
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -261,7 +276,7 @@ namespace OASystem.Infrastructure.Repositories.System
|
|
|
And smra.IsDel = 0
|
|
|
And smra.ReadableUId = {0}
|
|
|
Order By ReleaseTime Desc ", userId);
|
|
|
- var _readableMsgList = await _sqlSugar.SqlQueryable<ReadbleMessageView>(msgSqlWhere).ToListAsync();
|
|
|
+ var _readableMsgList = await _sqlSugar.SqlQueryable<ReadbleMessageView1>(msgSqlWhere).ToListAsync();
|
|
|
if (_readableMsgList.Count > 0)
|
|
|
{
|
|
|
_unReadCount = _readableMsgList.Where(it => it.IsRead == 0).Count();
|
|
@@ -279,10 +294,10 @@ namespace OASystem.Infrastructure.Repositories.System
|
|
|
{
|
|
|
Result result = new Result() { Code = -1, Msg = "未知错误", Data = null };
|
|
|
|
|
|
- if (dto.PortType == 1 || dto.PortType == 2)
|
|
|
+ if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3)
|
|
|
{
|
|
|
string msgSqlWhere = string.Format(@"Select sm.Type,sc.CompanyName,sd.DepName,sjp.JobName,su.CnName,sm.ReleaseTime,
|
|
|
- sm.Title,sm.Content,smra.IsRead,smra.ReadTime
|
|
|
+ sm.Title,sm.Content,smra.IsRead,smra.ReadTime,sm.DiId,sm.Param
|
|
|
From Sys_Message sm
|
|
|
Inner Join Sys_MessageReadAuth smra On sm.Id = smra.MsgId
|
|
|
Inner Join Sys_Users su On sm.IssuerId = su.id
|
|
@@ -291,7 +306,8 @@ namespace OASystem.Infrastructure.Repositories.System
|
|
|
Inner Join Sys_Company sc On su.CompanyId = sc.Id
|
|
|
Where sm.IsDel = 0
|
|
|
And sm.Id = {0}
|
|
|
- And smra.IsDel = 0", dto.MsgId);
|
|
|
+ And smra.IsDel = 0
|
|
|
+ And smra.ReadableUId = {1}", dto.MsgId,dto.UserId);
|
|
|
var _readableMsgInfo = await _sqlSugar.SqlQueryable<MessageInfoView>(msgSqlWhere).FirstAsync();
|
|
|
if (_readableMsgInfo != null)
|
|
|
{
|
|
@@ -317,15 +333,17 @@ namespace OASystem.Infrastructure.Repositories.System
|
|
|
{
|
|
|
Result result = new Result() { Code = -1, Msg = "未知错误", Data = null };
|
|
|
|
|
|
- if (dto.PortType == 1 || dto.PortType == 2)
|
|
|
+ if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3)
|
|
|
{
|
|
|
|
|
|
var msgReadStatus = await _sqlSugar.Updateable<Sys_MessageReadAuth>()
|
|
|
- .Where(a => a.Id == dto.MsgAnthId)
|
|
|
.SetColumns(a => new Sys_MessageReadAuth
|
|
|
{
|
|
|
- IsRead = 1
|
|
|
- }).ExecuteCommandAsync();
|
|
|
+ IsRead = 1,
|
|
|
+ ReadTime = DateTime.Now,
|
|
|
+ })
|
|
|
+ .Where(a => a.ReadableUId == dto.UserId && a.MsgId == dto.MsgId)
|
|
|
+ .ExecuteCommandAsync();
|
|
|
|
|
|
if (msgReadStatus > 0)
|
|
|
{
|
|
@@ -350,7 +368,7 @@ namespace OASystem.Infrastructure.Repositories.System
|
|
|
{
|
|
|
Result result = new Result() { Code = -1, Msg = "未知错误", Data = null };
|
|
|
|
|
|
- if (dto.PortType == 1 || dto.PortType == 2)
|
|
|
+ if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3)
|
|
|
{
|
|
|
|
|
|
var msgReadStatus = await _sqlSugar.Updateable<Sys_Message>()
|