Переглянути джерело

MessageNotification IOS Update

leiy 1 рік тому
батько
коміт
d23dd102f3

+ 13 - 8
OASystem/OASystem.Api/Controllers/SystemController.cs

@@ -116,8 +116,6 @@ namespace OASystem.API.Controllers
 
             return Ok(JsonView(msgData.Data));
         }
-
-        
         
         /// <summary>
         /// 系统消息
@@ -136,9 +134,15 @@ namespace OASystem.API.Controllers
                 return Ok(JsonView(false, "请输入有效的PortType参数。1 Web 2 Android 3 IOS"));
             }
 
-            if (dto.Type < 1 || dto.Type > 3)
+            var typeData = await _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 77).Select(it => it.Id).ToListAsync();
+            if (typeData.Count < 0)
             {
-                return Ok(JsonView(false, "请输入有效的Type参数。1 团组操作通知 2 任务操作通知 3 公告通知"));
+                return Ok(JsonView(false, "消息类型不存在"));
+            }
+
+            if (!typeData.Contains( dto.Type))
+            {
+                return Ok(JsonView(false, "请输入有效的Type参数。1020 团组操作通知 1021 任务操作通知 "));
             }
             if (dto.UserId < 1)
             {
@@ -158,18 +162,19 @@ namespace OASystem.API.Controllers
             //消息类型
             string typeStr = "";
             List<NotificationTypeView> messageTypeViews = AppSettingsHelper.Get<NotificationTypeView>("MessageNotificationType");
-            if (dto.Type == 1) //团组操作通知
+            if (dto.Type == 1020) //团组操作通知
             {
                 typeStr = String.Join(",", messageTypeViews.Where(it => it.TypeId == 1).FirstOrDefault().MsgTypeIds.ToList());
             }
-            else if (dto.Type == 2)//任务操作通知
+            else if (dto.Type == 1021)//任务操作通知
             {
                 typeStr = String.Join(",", messageTypeViews.Where(it => it.TypeId == 2).FirstOrDefault().MsgTypeIds.ToList());
             }
-            else if (dto.Type == 3) //公告消息
+            else if (dto.Type == 1022)//公告通知
             {
-                typeStr = String.Join(",", messageTypeViews.Where(it => it.TypeId == 0).FirstOrDefault().MsgTypeIds.ToList());
+                typeStr = String.Join(",", messageTypeViews.Where(it => it.TypeId == 2).FirstOrDefault().MsgTypeIds.ToList());
             }
+           
             if (!string.IsNullOrEmpty(typeStr))
             {
                 msgSqlWhere += $" And sm.Type In ({typeStr})";

+ 8 - 6
OASystem/OASystem.Api/OAMethodLib/GeneralMethod.cs

@@ -46,19 +46,21 @@ namespace OASystem.API.OAMethodLib
         /// <param name="content">消息内容</param>
         /// <param name="userIds"></param>
         /// <param name="diId">团组id</param>
+        /// <param name="param">团组id</param>
         /// <returns></returns>
-        public static async Task<bool> MessageIssueAndNotification(MessageTypeEnum msgTypeEnum,string title,string content, List<int> userIds,int diId = 0)
+        public static async Task<bool> MessageIssueAndNotification(MessageTypeEnum msgTypeEnum, string title, string content, List<int> userIds, int diId = 0, string param = "")
         {
-            
+
             MessageDto messageDto = new()
-            { 
+            {
                 Type = msgTypeEnum,
                 IssuerId = 4,//管理员
                 DiId = diId,
                 Title = title,
                 Content = content,
                 ReleaseTime = DateTime.Now,
-                UIdList = userIds
+                UIdList = userIds,
+                Param = param
             };
             var status = await _messageRep.AddMsg(messageDto);//添加消息
 
@@ -76,13 +78,13 @@ namespace OASystem.API.OAMethodLib
                        }
                    );
                 await _hubContext.Clients.Clients(connIds).ReceiveMessage($"您有一条{notificationTypeStr1}相关的消息!");
-                
+
                 return true;
             }
 
             return false;
         }
-        
+
         /// <summary>
         /// 根据消息类型 获取 消息通知类型
         /// </summary>

+ 5 - 0
OASystem/OASystem.Domain/Dtos/System/MessageDto.cs

@@ -49,5 +49,10 @@ namespace OASystem.Domain.Dtos.System
         /// 可阅读员工
         /// </summary>
         public List<int> UIdList { get; set; }
+
+        /// <summary>
+        /// 参数(json存储)
+        /// </summary>
+        public string Param { get; set; }
     }
 }

+ 1 - 1
OASystem/OASystem.Domain/Dtos/System/MsgDto.cs

@@ -46,7 +46,7 @@ namespace OASystem.Domain.Dtos.System
     {
         /// <summary>
         /// 消息类型
-        /// 1 团组操作通知 2 任务操作通知 3 公告消息
+        /// 1020 团组操作通知 1021 任务操作通知
         /// </summary>
         public int Type { get; set; }
 

+ 16 - 8
OASystem/OASystem.Infrastructure/Repositories/System/MessageRepository.cs

@@ -18,8 +18,6 @@ namespace OASystem.Infrastructure.Repositories.System
     public class MessageRepository : BaseRepository<Sys_Message, MessageView>
     {
         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) 
@@ -59,7 +57,8 @@ namespace OASystem.Infrastructure.Repositories.System
                     DeleteTime = "1990-01-01 00:00:00.000",
                     Remark = "",
                     IsDel = 0,
-                    DiId = msgDto.DiId
+                    DiId = msgDto.DiId,
+                    Param = msgDto.Param,
                 };
 
                 int? msgId = await _sqlSugar.Insertable(message).ExecuteReturnIdentityAsync();
@@ -191,7 +190,11 @@ namespace OASystem.Infrastructure.Repositories.System
 
             //消息类型
             List<NotificationTypeView> messageTypeViews = AppSettingsHelper.Get<NotificationTypeView>("MessageNotificationType");
-           
+            List<int> _operationTypeList = messageTypeViews.Where(it =>it.TypeId == 1).FirstOrDefault().MsgTypeIds.ToList();
+            List<int> _taskTypeList = messageTypeViews.Where(it => it.TypeId == 2).FirstOrDefault().MsgTypeIds.ToList();
+            List<int> _noticeTypeList = messageTypeViews.Where(it => it.TypeId == 0).FirstOrDefault().MsgTypeIds.ToList();
+
+
             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, 
@@ -223,14 +226,20 @@ namespace OASystem.Infrastructure.Repositories.System
                 int operationNotificationDataCount = operationNotificationData.Where(it => it.IsRead == 0).ToList().Count;
 
                 //任务通知
-                var taskNotificationData = data.Where(it => _taskTypeList.Contains(it.Type)).OrderBy(it => it.IsRead).ToList();
-                int taskNotificationDataCount = taskNotificationData.Where(it => it.IsRead == 0).ToList().Count;
+                var taskNotificationData = data.Where(it => _taskTypeList.Contains(it.Type)).OrderBy(it => it.IsRead).ToList();//操作通知所属类型
+                int taskNotificationDataCount = taskNotificationData.Where(it => it.IsRead == 0).ToList().Count;               //任务通知 TaskNotification
+
+                //公告通知 notice
+                var noticeNotificationData = data.Where(it => _noticeTypeList.Contains(it.Type)).OrderBy(it => it.IsRead).ToList();//操作通知所属类型
+                int noticeNotificationDataCount = noticeNotificationData.Where(it => it.IsRead == 0).ToList().Count;               //任务通知 TaskNotification
+
 
                 foreach (var item in msgTypeData)
                 {
-                    //1021	团组操作通知 1020	任务操作通知
+                    //1021	团组操作通知 1020	任务操作通知 1022 公告通知
                     if (item.Id == 1020) item.UnReadCount = taskNotificationDataCount;
                     else if (item.Id == 1021) item.UnReadCount = operationNotificationDataCount;
+                    else if (item.Id == 1022) item.UnReadCount = noticeNotificationDataCount;
                 }
 
                 if (dto.PortType == 1 || dto.PortType == 2)  // web/android
@@ -241,7 +250,6 @@ namespace OASystem.Infrastructure.Repositories.System
                 }
                 else if (dto.PortType == 3)
                 {
-
                     result.Code = 0;
                     result.Data = new {
                         MsgTypeData = msgTypeData,