Browse Source

消息
修改接口

leiy 1 year ago
parent
commit
f2f4e194fe

+ 69 - 50
OASystem/OASystem.Api/Controllers/SystemController.cs

@@ -5,9 +5,11 @@ using Microsoft.AspNetCore.Mvc.Formatters;
 using Microsoft.AspNetCore.Mvc.ModelBinding;
 using Microsoft.AspNetCore.Mvc.ModelBinding;
 using Newtonsoft.Json.Linq;
 using Newtonsoft.Json.Linq;
 using OASystem.Domain.Dtos.System;
 using OASystem.Domain.Dtos.System;
+using OASystem.Domain.ViewModels.QiYeWeChat;
 using Org.BouncyCastle.Asn1.Cms;
 using Org.BouncyCastle.Asn1.Cms;
 using System.Collections;
 using System.Collections;
 using System.Xml.Linq;
 using System.Xml.Linq;
+using static OASystem.API.OAMethodLib.GeneralMethod;
 using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
 using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
 
 
 namespace OASystem.API.Controllers
 namespace OASystem.API.Controllers
@@ -80,7 +82,7 @@ namespace OASystem.API.Controllers
                 return Ok(JsonView(false, msgData.Msg));
                 return Ok(JsonView(false, msgData.Msg));
             }
             }
 
 
-            return Ok(JsonView(true,"成功", msgData.Data));
+            return Ok(JsonView(msgData.Data));
         }
         }
 
 
         #region 消息列表 - 分开
         #region 消息列表 - 分开
@@ -112,9 +114,11 @@ namespace OASystem.API.Controllers
                 return Ok(JsonView(false, msgData.Msg));
                 return Ok(JsonView(false, msgData.Msg));
             }
             }
 
 
-            return Ok(JsonView(true, "成功", msgData.Data));
+            return Ok(JsonView(msgData.Data));
         }
         }
 
 
+        
+        
         /// <summary>
         /// <summary>
         /// 系统消息
         /// 系统消息
         /// 消息List  2024-03-06 14:54
         /// 消息List  2024-03-06 14:54
@@ -132,69 +136,79 @@ namespace OASystem.API.Controllers
                 return Ok(JsonView(false, "请输入有效的PortType参数。1 Web 2 Android 3 IOS"));
                 return Ok(JsonView(false, "请输入有效的PortType参数。1 Web 2 Android 3 IOS"));
             }
             }
 
 
-            if (dto.Type < 1 || dto.Type > 2)
+            if (dto.Type < 1 || dto.Type > 3)
             {
             {
-                return Ok(JsonView(false, "请输入有效的Type参数。1 团组操作通知 2 任务操作通知"));
+                return Ok(JsonView(false, "请输入有效的Type参数。1 团组操作通知 2 任务操作通知 3 公告通知"));
             }
             }
             if (dto.UserId < 1)
             if (dto.UserId < 1)
             {
             {
                 return Ok(JsonView(false, "请输入有效的UserId参数。"));
                 return Ok(JsonView(false, "请输入有效的UserId参数。"));
             }
             }
 
 
+            if (dto.ReadStatus < 1 || dto.ReadStatus > 3)
+            {
+                return Ok(JsonView(false, "请输入有效的ReadStatus参数。1 全部(包含已读/未读) 2 未读 3 已读"));
+            }
+
             #endregion
             #endregion
 
 
+            //userId
+            string msgSqlWhere = $" And smra.ReadableUId = {dto.UserId}";
 
 
-            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 
+            string typeStr = "";
-                                                     From Sys_Message sm 
+            List<NotificationTypeView> messageTypeViews = AppSettingsHelper.Get<NotificationTypeView>("MessageNotificationType");
-                                                     Inner Join Sys_MessageReadAuth smra On sm.Id = smra.MsgId
+            if (dto.Type == 1) //团组操作通知
-                                                     Inner Join Sys_Users su On sm.IssuerId = su.Id
+            {
-                                                     Inner Join Sys_Department sd On su.DepId = sd.Id
+                typeStr = String.Join(",", messageTypeViews.Where(it => it.TypeId == 1).FirstOrDefault().MsgTypeIds.ToList());
-                                                     Inner Join Sys_Users suAuth On smra.ReadableUId = suAuth.Id
+            }
-                                                     Where sm.IsDel = 0
+            else if (dto.Type == 2)//任务操作通知
-                                                     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)
             {
             {
+                typeStr = String.Join(",", messageTypeViews.Where(it => it.TypeId == 2).FirstOrDefault().MsgTypeIds.ToList());
+            }
+            else if (dto.Type == 3) //公告消息
+            {
+                typeStr = String.Join(",", messageTypeViews.Where(it => it.TypeId == 0).FirstOrDefault().MsgTypeIds.ToList());
+            }
+            if (!string.IsNullOrEmpty(typeStr))
+            {
+                msgSqlWhere += $" And sm.Type In ({typeStr})";
+            }
 
 
-                if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3)
+            //是否已读处理 1 全部(包含已读/未读) 2 未读 3 已读
-                {
+            if (dto.ReadStatus == 1) msgSqlWhere += "";
-                    int pageSize = dto.PageSize; // 每页显示的记录数量
+            else if (dto.ReadStatus == 2) msgSqlWhere += $" And smra.IsRead = {0}";
-                    int currentPage = dto.PageIndex; // 当前页码(从1开始)
+            else if (dto.ReadStatus == 3) msgSqlWhere += $" And smra.IsRead = {1}";
 
 
-                    if (dto.Type == 1) //团组操作通知
-                    {
-                        //操作通知 OperationNotification
-                        var operationNotificationData = _readableMsgList.Where(it => _operationTypeList.Contains(it.Type)).OrderBy(it => it.IsRead).ToList();
-                        int operationNotificationDataCount = operationNotificationData.Count;
-                        // 计算起始索引和结束索引
-                        int operationStartIndex = (currentPage - 1) * pageSize;
-                        int operationEndIndex = Math.Min(operationStartIndex + pageSize, operationNotificationDataCount);
 
 
-                        var operationNotificationDataView = operationNotificationData.Skip(operationStartIndex).Take(pageSize).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, 
+                                                    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);
 
 
-                        return Ok(JsonView(true, "成功", operationNotificationDataView, operationNotificationDataCount));
-                    }
-                    else if (dto.Type == 2) //2 任务操作通知
-                    {
-                        //任务通知 TaskNotification
-                        var taskNotificationData = _readableMsgList.Where(it => _taskTypeList.Contains(it.Type)).OrderBy(it => it.IsRead).ToList();
-                        int taskNotificationDataCount = taskNotificationData.Count;
-                        // 计算起始索引和结束索引
-                        int taskStartIndex = (currentPage - 1) * pageSize;
-                        int taskEndIndex = Math.Min(taskStartIndex + pageSize, taskNotificationDataCount);
 
 
-                        var taskNotificationDataView = taskNotificationData.Skip(taskStartIndex).Take(pageSize).ToList();
+            try
+            {
+                RefAsync<int> totalCount = 0;
+                var data = await _sqlSugar.SqlQueryable<MessageListView>(msgSql).ToPageListAsync(dto.PageIndex, dto.PageSize, totalCount);
 
 
-                        return Ok(JsonView(true, "成功", taskNotificationDataView, taskNotificationDataCount));
-                    }
 
 
-                }
+                return Ok(JsonView(true, "操作成功!", data, totalCount));
             }
             }
+            catch (Exception ex )
+            {
 
 
-            return Ok(JsonView(true,"操作成功!" ,new List<int>() { }, 0));
+                return Ok(JsonView(false, ex.Message));
+            }
+           
         }
         }
 
 
 
 
@@ -207,8 +221,13 @@ namespace OASystem.API.Controllers
         /// <returns></returns>
         /// <returns></returns>
         [HttpPost]
         [HttpPost]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> GetMsgInfo(MsgInfoDto dto)
+        public async Task<IActionResult> PostMsgInfo(MsgInfoDto dto)
         {
         {
+            if (dto.PortType < 1 || dto.PortType > 3)
+            {
+                return Ok(JsonView(false, "请输入有效的PortType参数。1 Web 2 Android 3 IOS"));
+            }
+
             var msgData = await _messageRep.GetMsgInfo(dto);
             var msgData = await _messageRep.GetMsgInfo(dto);
 
 
             if (msgData.Code != 0)
             if (msgData.Code != 0)
@@ -216,7 +235,7 @@ namespace OASystem.API.Controllers
                 return Ok(JsonView(false, msgData.Msg));
                 return Ok(JsonView(false, msgData.Msg));
             }
             }
 
 
-            return Ok(JsonView(true, msgData.Data));
+            return Ok(JsonView(true, "操作成功!",msgData.Data));
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -235,11 +254,11 @@ namespace OASystem.API.Controllers
                 return Ok(JsonView(false, msgData.Msg));
                 return Ok(JsonView(false, msgData.Msg));
             }
             }
 
 
-            return Ok(JsonView(true, msgData.Data));
+            return Ok(JsonView(true));
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// 消息设置已读
+        /// 消息 删除
         /// </summary>
         /// </summary>
         /// <param name="dto"></param>
         /// <param name="dto"></param>
         /// <returns></returns>
         /// <returns></returns>
@@ -254,7 +273,7 @@ namespace OASystem.API.Controllers
                 return Ok(JsonView(false, msgData.Msg));
                 return Ok(JsonView(false, msgData.Msg));
             }
             }
 
 
-            return Ok(JsonView(true, msgData.Data));
+            return Ok(JsonView(true));
         }
         }
         #endregion
         #endregion
 
 

+ 1 - 14
OASystem/OASystem.Api/OAMethodLib/GeneralMethod.cs

@@ -100,20 +100,7 @@ namespace OASystem.API.OAMethodLib
             return notificationStr;
             return notificationStr;
         }
         }
 
 
-        public class NotificationTypeView
+        
-        {
-            /// <summary>
-            /// 通知类型
-            /// 1 操作通知
-            /// 2 任务通知
-            /// </summary>
-            public int TypeId { get; set; }
-
-            /// <summary>
-            /// 消息类型id
-            /// </summary>
-            public List<int> MsgTypeIds { get; set; }
-        }
 
 
         #endregion
         #endregion
 
 

+ 2 - 2
OASystem/OASystem.Api/OAMethodLib/Quartz/QuartzFactory.cs

@@ -34,11 +34,11 @@ namespace QuzrtzJob.Factory
             
             
             var taskTrigger = TriggerBuilder.Create()
             var taskTrigger = TriggerBuilder.Create()
                             //.WithSimpleSchedule(x => x.WithIntervalInSeconds(2).RepeatForever())//每两秒执行一次
                             //.WithSimpleSchedule(x => x.WithIntervalInSeconds(2).RepeatForever())//每两秒执行一次
-                            .WithCronSchedule("0 0 18 * * ?")
+                            .WithCronSchedule("0 0 9,18 * * ?") //每天早上九点和下午六点触发
                             .Build();
                             .Build();
             var taskMsgTrigger = TriggerBuilder.Create()
             var taskMsgTrigger = TriggerBuilder.Create()
                             //.WithSimpleSchedule(x => x.WithIntervalInSeconds(60).RepeatForever())//每六十秒执行一次
                             //.WithSimpleSchedule(x => x.WithIntervalInSeconds(60).RepeatForever())//每六十秒执行一次
-                            .WithCronSchedule("0 0 18 * * ?")
+                            .WithCronSchedule("0 0 9,18 * * ?") //每天早上九点和下午六点触发
                             .Build();
                             .Build();
 
 
             //5、创建任务
             //5、创建任务

+ 2 - 2
OASystem/OASystem.Api/appsettings.json

@@ -201,8 +201,8 @@
       "MsgTypeIds": [
       "MsgTypeIds": [
         2, // 团组流程管控消息
         2, // 团组流程管控消息
         3, // 团组业务操作消息
         3, // 团组业务操作消息
-        4, // 费用审核消息
+        4, // 团组费用审核消息
-        5  // 签证进度更新消息
+        5  // 团组签证进度更新消息
       ]
       ]
     },
     },
     {
     {

+ 28 - 3
OASystem/OASystem.Domain/Dtos/System/MsgDto.cs

@@ -29,28 +29,48 @@ namespace OASystem.Domain.Dtos.System
         /// </summary>
         /// </summary>
         public int UserId { get; set; }
         public int UserId { get; set; }
     }
     }
+    /// <summary>
+    /// 
+    /// </summary>
+    public class MessageTypeFirstMsgDto : PortDtoBase
+    {
+        /// <summary>
+        /// 消息类型
+        /// 0 全部 1 团组操作通知 2 任务操作通知 3 公告消息
+        /// </summary>
+        public int Type { get; set; }
+        public int UserId { get; set; }
+    }
 
 
     public class PotsMessagePageListDto : DtoBase
     public class PotsMessagePageListDto : DtoBase
     {
     {
         /// <summary>
         /// <summary>
         /// 消息类型
         /// 消息类型
-        /// 1 团组操作通知 2 任务操作通知
+        /// 1 团组操作通知 2 任务操作通知 3 公告消息
         /// </summary>
         /// </summary>
         public int Type { get; set; }
         public int Type { get; set; }
 
 
         public int UserId { get; set; }
         public int UserId { get; set; }
+
+        /// <summary>
+        /// 阅读状态
+        /// 1 全部(包含已读/未读) 2 未读 3 已读
+        /// </summary>
+        public int ReadStatus { get; set; }
     }
     }
 
 
     /// <summary>
     /// <summary>
     /// 消息详细信息
     /// 消息详细信息
     /// 请求dto
     /// 请求dto
     /// </summary>
     /// </summary>
-    public class MsgInfoDto : DtoBase
+    public class MsgInfoDto : PortDtoBase
     {
     {
+        public int UserId { get; set; }
         /// <summary>
         /// <summary>
         /// 消息Id
         /// 消息Id
         /// </summary>
         /// </summary>
         public int MsgId { get; set; }
         public int MsgId { get; set; }
+        
     }
     }
 
 
     /// <summary>
     /// <summary>
@@ -59,10 +79,15 @@ namespace OASystem.Domain.Dtos.System
     /// </summary>
     /// </summary>
     public class MsgSetReadDto : PortDtoBase
     public class MsgSetReadDto : PortDtoBase
     {
     {
+        /// <summary>
+        /// 
+        /// </summary>
+        public int UserId { get; set; }
+
         /// <summary>
         /// <summary>
         /// MsgAnthId
         /// MsgAnthId
         /// </summary>
         /// </summary>
-        public int MsgAnthId { get; set; }
+        public int MsgId { get; set; }
     }
     }
 
 
     /// <summary>
     /// <summary>

+ 15 - 2
OASystem/OASystem.Domain/Entities/System/Sys_Message.cs

@@ -26,6 +26,19 @@ namespace OASystem.Domain.Entities.System
         [SugarColumn(IsNullable = true,ColumnDataType = "int")]
         [SugarColumn(IsNullable = true,ColumnDataType = "int")]
         public MessageTypeEnum Type { get; set; }
         public MessageTypeEnum Type { get; set; }
 
 
+        /// <summary>
+        /// 类型参数(json格式存储)
+        /// 1 系统公告消息
+        /// 2 团组流程管控消息
+        /// 3 团组业务操作消息
+        /// eg:PageId:104,Id:123,paramName:paramValue....
+        /// 4 系统费用审核消息
+        /// 5 签证进度更新消息
+        /// 6 任务进度更新消息
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(200)")]
+        public string? Param { get; set; }
+
         /// <summary>
         /// <summary>
         /// 发布者用户Id
         /// 发布者用户Id
         /// 4 管理员 Id 
         /// 4 管理员 Id 
@@ -36,8 +49,8 @@ namespace OASystem.Domain.Entities.System
         /// <summary>
         /// <summary>
         /// 团组Id,可为0
         /// 团组Id,可为0
         /// </summary>
         /// </summary>
-        [SugarColumn(IsNullable = true,ColumnDataType = "int")]
+        [SugarColumn(IsNullable = true, ColumnDataType = "int")]
-        public int DiId { get; set; }
+        public int DiId { get; set; } = 0;
 
 
         /// <summary>
         /// <summary>
         /// 消息标题
         /// 消息标题

+ 75 - 9
OASystem/OASystem.Domain/ViewModels/System/MessageView.cs

@@ -14,8 +14,9 @@ namespace OASystem.Domain.ViewModels.System
     /// <summary>
     /// <summary>
     /// 用于都消息返回视图
     /// 用于都消息返回视图
     /// </summary>
     /// </summary>
-    public class ReadbleMessageView
+    public class MessageListView
     {
     {
+        public int RowNumber { get; set; }
         public int Id { get; set; }
         public int Id { get; set; }
 
 
         /// <summary>
         /// <summary>
@@ -52,22 +53,68 @@ namespace OASystem.Domain.ViewModels.System
         /// </summary>
         /// </summary>
         public DateTime ReleaseTime { get; set; }
         public DateTime ReleaseTime { get; set; }
 
 
+
+        /// <summary>
+        /// 是否已读
+        /// 0 未读 1 已读
+        /// </summary>
+        public int IsRead { get; set; }
+
+        //public int DiId { get; set; }
+
+        //public string Param { get; set; }
+    }
+
+    /// <summary>
+    /// 用于都消息返回视图
+    /// </summary>
+    public class ReadbleMessageView
+    {
+        public int RowNumber { get; set; }
+        public int Id { get; set; }
+
         /// <summary>
         /// <summary>
-        /// 可阅读员工Id
+        /// 消息类型
+        /// 1 公告消息
+        /// 2 团组流程管控消息
+        /// 3 团组业务操作消息
+        /// 4费用
         /// </summary>
         /// </summary>
-        public int ReadableUId { get; set; }
+        public int Type { get; set; }
 
 
         /// <summary>
         /// <summary>
-        /// 是否阅读
+        /// 消息标题
-        /// 0 未阅读
-        /// 1 已阅读
         /// </summary>
         /// </summary>
-        public int IsRead { get; set; }
+        public string Title { get; set; }
+
+        /// <summary>
+        /// 消息内容
+        /// </summary>
+        public string Content { get; set; }
+
+        /// <summary>
+        /// 发布部门
+        /// </summary>
+        public string IssuerDep { get; set; }
 
 
         /// <summary>
         /// <summary>
-        /// 阅读时间
+        /// 发布者
         /// </summary>
         /// </summary>
-        public DateTime? ReadTime { get; set; }
+        public string IssuerUser { get; set; }
+
+        /// <summary>
+        /// 发布时间
+        /// </summary>
+        public DateTime ReleaseTime { get; set; }
+
+        public int DiId { get; set; }
+
+        public string Param { get; set; }
+    }
+
+    public class ReadbleMessageView1 : ReadbleMessageView
+    {
+        public int IsRead { get; set; }
     }
     }
 
 
     public class MessageInfoView 
     public class MessageInfoView 
@@ -127,6 +174,10 @@ namespace OASystem.Domain.ViewModels.System
         /// 1990-01-01 00:00:000 未读
         /// 1990-01-01 00:00:000 未读
         /// </summary>
         /// </summary>
         public DateTime ReadTime { get; set; }
         public DateTime ReadTime { get; set; }
+
+        public int DiId { get; set; }
+
+        public string Param { get; set; }
     }
     }
 
 
     public class MessageTypeView 
     public class MessageTypeView 
@@ -142,4 +193,19 @@ namespace OASystem.Domain.ViewModels.System
         /// </summary>
         /// </summary>
         public int UnReadCount { get; set; } = 0;
         public int UnReadCount { get; set; } = 0;
     }
     }
+
+    public class NotificationTypeView
+    {
+        /// <summary>
+        /// 通知类型
+        /// 1 操作通知
+        /// 2 任务通知
+        /// </summary>
+        public int TypeId { get; set; }
+
+        /// <summary>
+        /// 消息类型id
+        /// </summary>
+        public List<int> MsgTypeIds { get; set; }
+    }
 }
 }

+ 1 - 1
OASystem/OASystem.Infrastructure/Repositories/CRM/VisaDeleClientCompanyRepository.cs

@@ -36,7 +36,7 @@ namespace OASystem.Infrastructure.Repositories.CRM
         {
         {
             Result result = new Result() { Code = -2 };
             Result result = new Result() { Code = -2 };
 
 
-            if (dto.PortType == 1 || dto.PortType == 2)
+            if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3)
             {
             {
                 string sql = string.Format(@"Select ccc.Id,ccc.CompanyName,ccc.Address,ccc.PostCodes,su.CnName UserName,ccc.CreateTime,ccc.Remark
                 string sql = string.Format(@"Select ccc.Id,ccc.CompanyName,ccc.Address,ccc.PostCodes,su.CnName UserName,ccc.CreateTime,ccc.Remark
                                              From Crm_CustomerCompany ccc Inner Join Sys_Users su On ccc.CreateUserId = su.Id where ccc.IsDel=0 order by CreateTime Desc");
                                              From Crm_CustomerCompany ccc Inner Join Sys_Users su On ccc.CreateUserId = su.Id where ccc.IsDel=0 order by CreateTime Desc");

+ 1 - 1
OASystem/OASystem.Infrastructure/Repositories/CRM/VisaDeleClientRepository.cs

@@ -40,7 +40,7 @@ namespace OASystem.Infrastructure.Repositories.CRM
         public async Task<Result> GetCrmList(DtoBase dto)
         public async Task<Result> GetCrmList(DtoBase dto)
         {
         {
             Result result = new Result() { Code = -2 };
             Result result = new Result() { Code = -2 };
-            if (dto.PortType == 1 || dto.PortType == 2) 
+            if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) 
             {
             {
                 string sql = string.Format(@"Select cdc.Id,LastName+FirstName ClientName,ccc.CompanyFullName,Sex,Marriage,
                 string sql = string.Format(@"Select cdc.Id,LastName+FirstName ClientName,ccc.CompanyFullName,Sex,Marriage,
                                              	    Phone LandlinePhone,Tel,crmCard1.CertNo IDNo,crmCard2.CertNo PassportNo
                                              	    Phone LandlinePhone,Tel,crmCard1.CertNo IDNo,crmCard2.CertNo PassportNo

+ 1 - 1
OASystem/OASystem.Infrastructure/Repositories/Financial/DailyFeePaymentRepository.cs

@@ -229,7 +229,7 @@ namespace OASystem.Infrastructure.Repositories.Financial
             #endregion
             #endregion
 
 
            
            
-            if (dto.PortType == 1 || dto.PortType == 2) //web
+            if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //web
             {
             {
                 //Fin_DailyFeePaymentPageCount
                 //Fin_DailyFeePaymentPageCount
                 var dailyFeePaymentCount = await _sqlSugar.SqlQueryable<Fin_DailyFeePaymentPageCount>(sqlCount).FirstAsync();
                 var dailyFeePaymentCount = await _sqlSugar.SqlQueryable<Fin_DailyFeePaymentPageCount>(sqlCount).FirstAsync();

+ 9 - 9
OASystem/OASystem.Infrastructure/Repositories/Groups/DelegationInfoRepository.cs

@@ -116,7 +116,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
         {
         {
             Result result = new Result() { Code = -2, Msg = "未知错误" };
             Result result = new Result() { Code = -2, Msg = "未知错误" };
 
 
-            if (dto.PortType == 1 || dto.PortType == 2) //Web Or Android
+            if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //Web Or Android
             {
             {
                 string sql = string.Format(@"Select Id,SalesQuoteNo,TourCode,JietuanOperator,TeamLevSId,TeamDid,TeamName,ClientName,
                 string sql = string.Format(@"Select Id,SalesQuoteNo,TourCode,JietuanOperator,TeamLevSId,TeamDid,TeamName,ClientName,
 	                                                ClientUnit,VisitCountry,VisitDate,VisitDays,VisitPNumber,TontractTime,
 	                                                ClientUnit,VisitCountry,VisitDate,VisitDays,VisitPNumber,TontractTime,
@@ -153,7 +153,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 ReceiveDt = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                 ReceiveDt = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
             };
             };
 
 
-            if (dto.PortType == 1 || dto.PortType == 2) //web
+            if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //web
             {
             {
                 int startIndex = (dto.PageIndex - 1) * dto.PageSize + 1;
                 int startIndex = (dto.PageIndex - 1) * dto.PageSize + 1;
                 int endIndex = startIndex + dto.PageSize - 1;
                 int endIndex = startIndex + dto.PageSize - 1;
@@ -220,7 +220,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
         {
         {
             Result result = new Result() { Code = -2, Msg = "未知错误" };
             Result result = new Result() { Code = -2, Msg = "未知错误" };
 
 
-            if (dto.PortType == 1 || dto.PortType == 2) //web
+            if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //web
             {
             {
                 string sql = string.Format(@"Select gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure
                 string sql = string.Format(@"Select gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure
                   From  Grp_DelegationInfo gdi
                   From  Grp_DelegationInfo gdi
@@ -384,7 +384,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
 
 
             try
             try
             {
             {
-                if (dto.PortType == 1 || dto.PortType == 2) //web
+                if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //web
                 {
                 {
                     dynamic? teamTypeData1 = null;
                     dynamic? teamTypeData1 = null;
                     string teamTypeSql = string.Format(@"Select Id,Name From  Sys_SetData Where STid = {0} And IsDel = {1}", 10, 0);
                     string teamTypeSql = string.Format(@"Select Id,Name From  Sys_SetData Where STid = {0} And IsDel = {1}", 10, 0);
@@ -439,7 +439,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
         {
         {
             Result result = new Result() { Code = -2, Msg = "未知错误" };
             Result result = new Result() { Code = -2, Msg = "未知错误" };
 
 
-            if (dto.PortType == 1 || dto.PortType == 2) //web
+            if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //web
             {
             {
 
 
                 #region 添加出访起止时间
                 #region 添加出访起止时间
@@ -630,7 +630,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
         {
         {
             Result result = new Result() { Code = -2, Msg = "未知错误" };
             Result result = new Result() { Code = -2, Msg = "未知错误" };
 
 
-            if (dto.PortType == 1 || dto.PortType == 2) //web
+            if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //web
             {
             {
                 var deleteStatus = await UpdateAsync(a => a.Id == dto.Id, a => new Grp_DelegationInfo
                 var deleteStatus = await UpdateAsync(a => a.Id == dto.Id, a => new Grp_DelegationInfo
                 {
                 {
@@ -771,7 +771,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
         {
         {
             Result result = new Result() { Code = -2, Msg = "未知错误" };
             Result result = new Result() { Code = -2, Msg = "未知错误" };
 
 
-            if (dto.PortType == 1 || dto.PortType == 2) //web
+            if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //web
             {
             {
                 string sql = string.Format(@"Select Id,TeamName GroupName From  Grp_DelegationInfo 
                 string sql = string.Format(@"Select Id,TeamName GroupName From  Grp_DelegationInfo 
                                              Where TeamName != '' And IsDel = 0
                                              Where TeamName != '' And IsDel = 0
@@ -801,7 +801,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
         {
         {
             Result result = new Result() { Code = -2, Msg = "未知错误" };
             Result result = new Result() { Code = -2, Msg = "未知错误" };
 
 
-            if (dto.PortType == 1 || dto.PortType == 2) //web
+            if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //web
             {
             {
                 string sql = string.Format(@"Select Id,TeamName GroupName From  Grp_DelegationInfo 
                 string sql = string.Format(@"Select Id,TeamName GroupName From  Grp_DelegationInfo 
                                              Where TeamName != '' And IsDel = 0
                                              Where TeamName != '' And IsDel = 0
@@ -835,7 +835,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
         public async Task<Result> GetCrmByGroupId(ClientByGroupIdDto dto)
         public async Task<Result> GetCrmByGroupId(ClientByGroupIdDto dto)
         {
         {
             Result result = new Result() { Code = -2 };
             Result result = new Result() { Code = -2 };
-            if (dto.PortType == 1 || dto.PortType == 2)
+            if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3)
             {
             {
                 string sql = string.Format(@"Select gdjc.GrpDCId grpId,cdc.Id,cdc.LastName+cdc.FirstName clientName,cdc.Tel,ccc.CertNo CerdNo 
                 string sql = string.Format(@"Select gdjc.GrpDCId grpId,cdc.Id,cdc.LastName+cdc.FirstName clientName,cdc.Tel,ccc.CertNo CerdNo 
                                              From  Grp_DelegationJoinCustomer gdjc
                                              From  Grp_DelegationJoinCustomer gdjc

+ 61 - 43
OASystem/OASystem.Infrastructure/Repositories/System/MessageRepository.cs

@@ -4,6 +4,7 @@ using NPOI.SS.Formula.Functions;
 using OASystem.Domain;
 using OASystem.Domain;
 using OASystem.Domain.Dtos.System;
 using OASystem.Domain.Dtos.System;
 using OASystem.Domain.ViewModels.QiYeWeChat;
 using OASystem.Domain.ViewModels.QiYeWeChat;
+using OASystem.Infrastructure.Tools;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
@@ -121,7 +122,7 @@ namespace OASystem.Infrastructure.Repositories.System
                                                      And smra.IsDel = 0 
                                                      And smra.IsDel = 0 
                                                      And smra.ReadableUId = {0}
                                                      And smra.ReadableUId = {0}
                                                      Order By ReleaseTime Desc ", dto.UserId);
                                                      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)
                 if (_readableMsgList.Count > 0)
                 {
                 {
                     int pageSize = dto.PageSize; // 每页显示的记录数量
                     int pageSize = dto.PageSize; // 每页显示的记录数量
@@ -177,7 +178,7 @@ namespace OASystem.Infrastructure.Repositories.System
 
 
 
 
         /// <summary>
         /// <summary>
-        /// 获取消息列表
+        /// 获取消息类型列表
         /// </summary>
         /// </summary>
         /// <param name="uId">可读用户Id</param>
         /// <param name="uId">可读用户Id</param>
         /// <returns></returns>
         /// <returns></returns>
@@ -185,9 +186,29 @@ namespace OASystem.Infrastructure.Repositories.System
         {
         {
             Result result = new Result() { Code = -1, Msg = "未知错误", Data = null };
             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);
                 var msgTypeResult = await _setData.GetSetDataBySTId(_setData, 77);
                 if (msgTypeResult.Code != 0)
                 if (msgTypeResult.Code != 0)
                 {
                 {
@@ -197,42 +218,36 @@ namespace OASystem.Infrastructure.Repositories.System
                 string msgTypeDataStr = JsonConvert.SerializeObject(msgTypeResult.Data);
                 string msgTypeDataStr = JsonConvert.SerializeObject(msgTypeResult.Data);
                 var msgTypeData = JsonConvert.DeserializeObject<List<MessageTypeView>>(msgTypeDataStr);
                 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, 
+                //操作通知 OperationNotification
-                                                            sm.ReleaseTime,smra.Id AuthId,smra.ReadableUId,smra.IsRead,smra.ReadTime 
+                var operationNotificationData = data.Where(it => _operationTypeList.Contains(it.Type)).OrderBy(it => it.IsRead).ToList();
-                                                     From Sys_Message sm 
+                int operationNotificationDataCount = operationNotificationData.Where(it => it.IsRead == 0).ToList().Count;
-                                                     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)
+                //任务通知
-                    {
+                var taskNotificationData = data.Where(it => _taskTypeList.Contains(it.Type)).OrderBy(it => it.IsRead).ToList();
-                        //1021	团组操作通知 1020	任务操作通知
+                int taskNotificationDataCount = taskNotificationData.Where(it => it.IsRead == 0).ToList().Count;
-                        if (item.Id == 1020) item.UnReadCount = taskNotificationDataCount;
-                        else if (item.Id == 1021) item.UnReadCount = operationNotificationDataCount ;
-                    }
 
 
+                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.Code = 0;
-                    result.Msg = "成功!";
                     result.Data = msgTypeData;
                     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.IsDel = 0 
                                                      And smra.ReadableUId = {0}
                                                      And smra.ReadableUId = {0}
                                                      Order By ReleaseTime Desc ", userId);
                                                      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)
             if (_readableMsgList.Count > 0)
             {
             {
                 _unReadCount = _readableMsgList.Where(it => it.IsRead == 0).Count();
                 _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 };
             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,
                 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
                                                      From Sys_Message sm
                                                      Inner Join Sys_MessageReadAuth smra On sm.Id = smra.MsgId
                                                      Inner Join Sys_MessageReadAuth smra On sm.Id = smra.MsgId
                                                      Inner Join Sys_Users su On sm.IssuerId = su.id
                                                      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
                                                      Inner Join Sys_Company sc On su.CompanyId = sc.Id
                                                      Where sm.IsDel = 0 
                                                      Where sm.IsDel = 0 
                                                      And sm.Id = {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();
                 var _readableMsgInfo = await _sqlSugar.SqlQueryable<MessageInfoView>(msgSqlWhere).FirstAsync();
                 if (_readableMsgInfo != null)
                 if (_readableMsgInfo != null)
                 {
                 {
@@ -317,15 +333,17 @@ namespace OASystem.Infrastructure.Repositories.System
         {
         {
             Result result = new Result() { Code = -1, Msg = "未知错误", Data = null };
             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>()
                 var msgReadStatus = await _sqlSugar.Updateable<Sys_MessageReadAuth>()
-                                    .Where(a => a.Id == dto.MsgAnthId)
                                     .SetColumns(a => new Sys_MessageReadAuth
                                     .SetColumns(a => new Sys_MessageReadAuth
                                     {
                                     {
-                                        IsRead = 1
+                                        IsRead = 1,
-                                    }).ExecuteCommandAsync();
+                                        ReadTime = DateTime.Now,
+                                    })
+                                    .Where(a => a.ReadableUId == dto.UserId && a.MsgId == dto.MsgId)
+                                    .ExecuteCommandAsync();
 
 
                 if (msgReadStatus > 0)
                 if (msgReadStatus > 0)
                 {
                 {
@@ -350,7 +368,7 @@ namespace OASystem.Infrastructure.Repositories.System
         {
         {
             Result result = new Result() { Code = -1, Msg = "未知错误", Data = null };
             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>()
                 var msgReadStatus = await _sqlSugar.Updateable<Sys_Message>()