|
@@ -1,4 +1,5 @@
|
|
-using NPOI.POIFS.Crypt.Dsig;
|
|
|
|
|
|
+using Newtonsoft.Json;
|
|
|
|
+using NPOI.POIFS.Crypt.Dsig;
|
|
using NPOI.SS.Formula.Functions;
|
|
using NPOI.SS.Formula.Functions;
|
|
using OASystem.Domain;
|
|
using OASystem.Domain;
|
|
using OASystem.Domain.Dtos.System;
|
|
using OASystem.Domain.Dtos.System;
|
|
@@ -15,7 +16,15 @@ namespace OASystem.Infrastructure.Repositories.System
|
|
{
|
|
{
|
|
public class MessageRepository : BaseRepository<Sys_Message, MessageView>
|
|
public class MessageRepository : BaseRepository<Sys_Message, MessageView>
|
|
{
|
|
{
|
|
- public MessageRepository(SqlSugarClient sqlSugar) : base(sqlSugar) { }
|
|
|
|
|
|
+ private readonly SetDataRepository _setData;
|
|
|
|
+ private readonly List<int> _operationTypeList = new List<int>() { 1, 2, 3, 4, 5 }; //操作通知所属类型
|
|
|
|
+ private readonly List<int> _taskTypeList = new List<int>() { 6 };//任务通知 TaskNotification
|
|
|
|
+
|
|
|
|
+ public MessageRepository(SqlSugarClient sqlSugar, SetDataRepository setData)
|
|
|
|
+ : base(sqlSugar)
|
|
|
|
+ {
|
|
|
|
+ _setData = setData;
|
|
|
|
+ }
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 发布消息
|
|
/// 发布消息
|
|
@@ -121,36 +130,36 @@ namespace OASystem.Infrastructure.Repositories.System
|
|
|
|
|
|
//操作通知 OperationNotification
|
|
//操作通知 OperationNotification
|
|
List<int> operationTypeList = new List<int>() {1,2,3,4,5 };
|
|
List<int> operationTypeList = new List<int>() {1,2,3,4,5 };
|
|
- var operationNotificatioData = _readableMsgList.Where(it => operationTypeList.Contains(it.Type)).OrderBy(it => it.IsRead).ToList();
|
|
|
|
- int operationNotificatioDataCount = operationNotificatioData.Count;
|
|
|
|
|
|
+ var operationNotificationData = _readableMsgList.Where(it => operationTypeList.Contains(it.Type)).OrderBy(it => it.IsRead).ToList();
|
|
|
|
+ int operationNotificationDataCount = operationNotificationData.Count;
|
|
// 计算起始索引和结束索引
|
|
// 计算起始索引和结束索引
|
|
int operationStartIndex = (currentPage - 1) * pageSize;
|
|
int operationStartIndex = (currentPage - 1) * pageSize;
|
|
- int operationEndIndex = Math.Min(operationStartIndex + pageSize, operationNotificatioDataCount);
|
|
|
|
|
|
+ int operationEndIndex = Math.Min(operationStartIndex + pageSize, operationNotificationDataCount);
|
|
|
|
|
|
- var operationNotificatioDataView = new {
|
|
|
|
- Count = operationNotificatioDataCount,
|
|
|
|
- UnReadCount = operationNotificatioData.Where(it => it.IsRead == 0).Count(),
|
|
|
|
- OperationNotificatioData = operationNotificatioData.Skip(operationStartIndex).Take(pageSize).ToList()
|
|
|
|
|
|
+ var operationNotificationDataView = new {
|
|
|
|
+ Count = operationNotificationDataCount,
|
|
|
|
+ UnReadCount = operationNotificationData.Where(it => it.IsRead == 0).Count(),
|
|
|
|
+ OperationNotificatioData = operationNotificationData.Skip(operationStartIndex).Take(pageSize).ToList()
|
|
};
|
|
};
|
|
|
|
|
|
//任务通知 TaskNotification
|
|
//任务通知 TaskNotification
|
|
List<int> taskTypeList = new List<int>() { 6 };
|
|
List<int> taskTypeList = new List<int>() { 6 };
|
|
- var taskNotificatioData = _readableMsgList.Where(it => taskTypeList.Contains(it.Type)).OrderBy(it => it.IsRead).ToList();
|
|
|
|
- int taskNotificatioDataCount = taskNotificatioData.Count;
|
|
|
|
|
|
+ var taskNotificationData = _readableMsgList.Where(it => taskTypeList.Contains(it.Type)).OrderBy(it => it.IsRead).ToList();
|
|
|
|
+ int taskNotificationDataCount = taskNotificationData.Count;
|
|
// 计算起始索引和结束索引
|
|
// 计算起始索引和结束索引
|
|
int taskStartIndex = (currentPage - 1) * pageSize;
|
|
int taskStartIndex = (currentPage - 1) * pageSize;
|
|
- int taskEndIndex = Math.Min(operationStartIndex + pageSize, operationNotificatioDataCount);
|
|
|
|
|
|
+ int taskEndIndex = Math.Min(taskStartIndex + pageSize, taskNotificationDataCount);
|
|
|
|
|
|
- var taskNotificatioDataView = new
|
|
|
|
|
|
+ var taskNotificationDataView = new
|
|
{
|
|
{
|
|
- Count = taskNotificatioDataCount,
|
|
|
|
- UnReadCount = taskNotificatioData.Where(it => it.IsRead == 0).Count(),
|
|
|
|
- TaskNotificatioData = taskNotificatioData.Skip(taskStartIndex).Take(pageSize).ToList()
|
|
|
|
|
|
+ Count = taskNotificationDataCount,
|
|
|
|
+ UnReadCount = taskNotificationData.Where(it => it.IsRead == 0).Count(),
|
|
|
|
+ TaskNotificationData = taskNotificationData.Skip(taskStartIndex).Take(pageSize).ToList()
|
|
};
|
|
};
|
|
|
|
|
|
var _view = new {
|
|
var _view = new {
|
|
- OperationNotificatio = operationNotificatioDataView,
|
|
|
|
- TaskNotificatio = taskNotificatioDataView
|
|
|
|
|
|
+ OperationNotification = operationNotificationDataView,
|
|
|
|
+ TaskNotification = taskNotificationDataView
|
|
};
|
|
};
|
|
|
|
|
|
result.Code = 0;
|
|
result.Code = 0;
|
|
@@ -166,6 +175,71 @@ namespace OASystem.Infrastructure.Repositories.System
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 获取消息列表
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="uId">可读用户Id</param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ public async Task<Result> PotsMsgTypeData(MsgTypeDto dto)
|
|
|
|
+ {
|
|
|
|
+ Result result = new Result() { Code = -1, Msg = "未知错误", Data = null };
|
|
|
|
+
|
|
|
|
+ if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/android
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ var msgTypeResult = await _setData.GetSetDataBySTId(_setData, 77);
|
|
|
|
+ if (msgTypeResult.Code != 0)
|
|
|
|
+ {
|
|
|
|
+ result.Msg = "消息类型不存在!";
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ 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;
|
|
|
|
+
|
|
|
|
+ foreach (var item in msgTypeData)
|
|
|
|
+ {
|
|
|
|
+ //1021 团组操作通知 1020 任务操作通知
|
|
|
|
+ if (item.Id == 1020) item.UnReadCount = operationNotificationDataCount;
|
|
|
|
+ else if (item.Id == 1021) item.UnReadCount = taskNotificationDataCount;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ result.Code = 0;
|
|
|
|
+ result.Msg = "成功!";
|
|
|
|
+ result.Data = msgTypeData;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ result.Msg = "暂无该用户相关消息!";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 获取消息未读消息条数
|
|
/// 获取消息未读消息条数
|
|
/// </summary>
|
|
/// </summary>
|