ソースを参照

Merge branch 'develop' of http://132.232.92.186:3000/XinXiBu/OA2023 into develop

yuanrf 1 年間 前
コミット
ed5e0f0f9a
共有20 個のファイルを変更した558 個の追加311 個の削除を含む
  1. 29 5
      OASystem/OASystem.Api/Controllers/GroupsController.cs
  2. 115 51
      OASystem/OASystem.Api/Controllers/SystemController.cs
  3. 9 31
      OASystem/OASystem.Api/OAMethodLib/GeneralMethod.cs
  4. 0 12
      OASystem/OASystem.Api/OAMethodLib/Quartz/Business/TaskNewsFeedJob.cs
  5. 141 0
      OASystem/OASystem.Api/OAMethodLib/Quartz/Business/TaskNotification.cs
  6. 6 131
      OASystem/OASystem.Api/OAMethodLib/Quartz/Jobs/TaskNewsFeedJob.cs
  7. 3 3
      OASystem/OASystem.Api/OAMethodLib/Quartz/QuartzFactory.cs
  8. 2 2
      OASystem/OASystem.Api/appsettings.json
  9. 5 0
      OASystem/OASystem.Domain/Dtos/System/MessageDto.cs
  10. 34 3
      OASystem/OASystem.Domain/Dtos/System/MsgDto.cs
  11. 1 1
      OASystem/OASystem.Domain/Entities/Groups/Grp_CreditCardPayment.cs
  12. 15 2
      OASystem/OASystem.Domain/Entities/System/Sys_Message.cs
  13. 80 9
      OASystem/OASystem.Domain/ViewModels/System/MessageView.cs
  14. 1 1
      OASystem/OASystem.Infrastructure/Repositories/CRM/VisaDeleClientCompanyRepository.cs
  15. 1 1
      OASystem/OASystem.Infrastructure/Repositories/CRM/VisaDeleClientRepository.cs
  16. 1 1
      OASystem/OASystem.Infrastructure/Repositories/Financial/DailyFeePaymentRepository.cs
  17. 9 9
      OASystem/OASystem.Infrastructure/Repositories/Groups/DelegationInfoRepository.cs
  18. 9 3
      OASystem/OASystem.Infrastructure/Repositories/Groups/HotelPriceRepository.cs
  19. 25 0
      OASystem/OASystem.Infrastructure/Repositories/Groups/TourClientListRepository.cs
  20. 72 46
      OASystem/OASystem.Infrastructure/Repositories/System/MessageRepository.cs

+ 29 - 5
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -79,7 +79,6 @@ namespace OASystem.API.Controllers
         private readonly TourClientListRepository _tourClientListRep;
         private readonly TeamRateRepository _teamRateRep;
 
-
         #region 成本相关
         private readonly CheckBoxsRepository _checkBoxs;
         private readonly GroupCostRepository _GroupCostRepository;
@@ -522,6 +521,7 @@ namespace OASystem.API.Controllers
                     var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
                     if (userIds.Count > 0)
                     {
+                        userIds.Add(208);
                         //创建团组管控
                         GroupStepForDelegation.CreateWorkStep(diId);
                         //发送消息
@@ -1340,8 +1340,12 @@ namespace OASystem.API.Controllers
                         PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
                         hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
                         hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
+                        if (hotelCurrncyCode.Equals("CNY"))
+                        {
+                            entity.DayRate = 1.0000M;
+                        }
                     }
-                    _detail.WaitPay = entity.PayMoney.ConvertToDecimal1() + " " + PaymentCurrency_WaitPay;
+                    _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
 
                     /*
                      * 此次付款金额
@@ -1386,7 +1390,7 @@ namespace OASystem.API.Controllers
                             Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
                             if (hotelReservations != null)
                             {
-                                _detail.PriceMsgContent = "信用卡金额:" + _detail.WaitPay + " " + hotelCurrncyCode + "(" + hotelCurrncyName + ")<br/>" +
+                                _detail.PriceMsgContent = "信用卡金额:" + _detail.WaitPay + " (" + hotelCurrncyName + ")<br/>" +
                                                           "房间说明:" + hotelReservations.Remark;
                                 _detail.PriceNameContent = hotelReservations.HotelName;
                             }
@@ -1727,10 +1731,30 @@ namespace OASystem.API.Controllers
                     var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
                     if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
 
+                    if (creditCurrency.Equals("CNY"))
+                    {
+                        creditData.DayRate = 1.0000M;
+                    }
+
+                    if (creditData.PayPercentage == 0.00M)
+                    {
+                        creditData.PayPercentage = 100M;
+                    }
+
 
                     decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
                     string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
-                    string msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.##")} CNY({creditData.PayMoney.ToString("0.##")} {creditCurrency})) {auditStr}!";
+                    string msgContent = "";
+                    if (creditCurrency.Equals("CNY"))
+                    {
+                        msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
+                    }
+                    else
+                    {
+                        msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
+                    }
+
+                     
                     msgDatas.Add(new {DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
                 }
                 
@@ -1740,7 +1764,7 @@ namespace OASystem.API.Controllers
                 foreach (var item in msgDatas)
                 {
                     //发送消息
-                  await  GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.msgContent, new List<int>() { item.UserId }, item.DiId);
+                    GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
                 }
 
                 _groupRepository.CommitTran();

+ 115 - 51
OASystem/OASystem.Api/Controllers/SystemController.cs

@@ -5,9 +5,11 @@ using Microsoft.AspNetCore.Mvc.Formatters;
 using Microsoft.AspNetCore.Mvc.ModelBinding;
 using Newtonsoft.Json.Linq;
 using OASystem.Domain.Dtos.System;
+using OASystem.Domain.ViewModels.QiYeWeChat;
 using Org.BouncyCastle.Asn1.Cms;
 using System.Collections;
 using System.Xml.Linq;
+using static OASystem.API.OAMethodLib.GeneralMethod;
 using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
 
 namespace OASystem.API.Controllers
@@ -80,7 +82,7 @@ namespace OASystem.API.Controllers
                 return Ok(JsonView(false, msgData.Msg));
             }
 
-            return Ok(JsonView(true,"成功", msgData.Data));
+            return Ok(JsonView(msgData.Data));
         }
 
         #region 消息列表 - 分开
@@ -112,9 +114,9 @@ namespace OASystem.API.Controllers
                 return Ok(JsonView(false, msgData.Msg));
             }
 
-            return Ok(JsonView(true, "成功", msgData.Data));
+            return Ok(JsonView(msgData.Data));
         }
-
+        
         /// <summary>
         /// 系统消息
         /// 消息List  2024-03-06 14:54
@@ -132,72 +134,129 @@ namespace OASystem.API.Controllers
                 return Ok(JsonView(false, "请输入有效的PortType参数。1 Web 2 Android 3 IOS"));
             }
 
-            if (dto.Type < 1 || dto.Type > 2)
+            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, "消息类型不存在"));
+            }
+
+            if (!typeData.Contains( dto.Type))
             {
-                return Ok(JsonView(false, "请输入有效的Type参数。1 团组操作通知 2 任务操作通知"));
+                return Ok(JsonView(false, "请输入有效的Type参数。1020 团组操作通知 1021 任务操作通知 "));
             }
             if (dto.UserId < 1)
             {
                 return Ok(JsonView(false, "请输入有效的UserId参数。"));
             }
 
+            if (dto.ReadStatus < 1 || dto.ReadStatus > 3)
+            {
+                return Ok(JsonView(false, "请输入有效的ReadStatus参数。1 全部(包含已读/未读) 2 未读 3 已读"));
+            }
+
             #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 
-                                                     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)
+            //消息类型
+            string typeStr = "";
+            List<NotificationTypeView> messageTypeViews = AppSettingsHelper.Get<NotificationTypeView>("MessageNotificationType");
+            if (dto.Type == 1020) //任务操作通知 
             {
+                typeStr = String.Join(",", messageTypeViews.Where(it => it.TypeId == 2).FirstOrDefault().MsgTypeIds.ToList());
+            }
+            else if (dto.Type == 1021)//团组操作通知
+            {
+                typeStr = String.Join(",", messageTypeViews.Where(it => it.TypeId == 1).FirstOrDefault().MsgTypeIds.ToList());
+            }
+            else if (dto.Type == 1022)//公告通知
+            {
+                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)
-                {
-                    int pageSize = dto.PageSize; // 每页显示的记录数量
-                    int currentPage = dto.PageIndex; // 当前页码(从1开始)
+            //是否已读处理 1 全部(包含已读/未读) 2 未读 3 已读
+            if (dto.ReadStatus == 1) msgSqlWhere += "";
+            else if (dto.ReadStatus == 2) msgSqlWhere += $" And smra.IsRead = {0}";
+            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));
+            }
+           
         }
 
 
+        /// <summary>
+        /// 系统消息
+        /// 获取消息未读条数
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> PotsMessageUnreadTotalCount(PotsMessageUnreadTotalCountDto dto)
+        {
+            #region 参数验证
+
+            if (dto.UserId < 1)
+            {
+                return Ok(JsonView(false, "请输入有效的UserId参数。"));
+            }
+
+            #endregion
+
+
+            string msgSql = $"Select COUNT(*) As UnreadCount From  Sys_MessageReadAuth Where IsRead = 0 And ReadableUId = {dto.UserId}";
+
+            try
+            {
+                var data = _sqlSugar.SqlQueryable<MessageUnreadTotalCountView>(msgSql).First();
+                if (data != null)
+                {
+                    return Ok(JsonView(true, "操作成功!", data));
+                }
+
+                return Ok(JsonView(false, "操作失败!"));
+            }
+            catch (Exception ex)
+            {
+
+                return Ok(JsonView(false, ex.Message));
+            }
+
+        }
+
         #endregion
 
         /// <summary>
@@ -207,8 +266,13 @@ namespace OASystem.API.Controllers
         /// <returns></returns>
         [HttpPost]
         [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);
 
             if (msgData.Code != 0)
@@ -216,7 +280,7 @@ namespace OASystem.API.Controllers
                 return Ok(JsonView(false, msgData.Msg));
             }
 
-            return Ok(JsonView(true, msgData.Data));
+            return Ok(JsonView(true, "操作成功!",msgData.Data));
         }
 
         /// <summary>
@@ -235,11 +299,11 @@ namespace OASystem.API.Controllers
                 return Ok(JsonView(false, msgData.Msg));
             }
 
-            return Ok(JsonView(true, msgData.Data));
+            return Ok(JsonView(true));
         }
 
         /// <summary>
-        /// 消息设置已读
+        /// 消息 删除
         /// </summary>
         /// <param name="dto"></param>
         /// <returns></returns>
@@ -254,7 +318,7 @@ namespace OASystem.API.Controllers
                 return Ok(JsonView(false, msgData.Msg));
             }
 
-            return Ok(JsonView(true, msgData.Data));
+            return Ok(JsonView(true));
         }
         #endregion
 

+ 9 - 31
OASystem/OASystem.Api/OAMethodLib/GeneralMethod.cs

@@ -1,31 +1,20 @@
-using Microsoft.AspNetCore.Authentication;
-using Microsoft.AspNetCore.Authentication.Cookies;
-using Microsoft.AspNetCore.Mvc.TagHelpers;
+
 using Microsoft.AspNetCore.SignalR;
 using Microsoft.International.Converters.PinYinConverter;
-using NPOI.SS.Formula.PTG;
 using OASystem.API.OAMethodLib.Hub.HubClients;
 using OASystem.API.OAMethodLib.Hub.Hubs;
 using OASystem.API.OAMethodLib.JuHeAPI;
 using OASystem.API.OAMethodLib.SignalR.Hubs;
-using OASystem.Domain;
-using OASystem.Domain.Dtos.Financial;
 using OASystem.Domain.Entities.Customer;
 using OASystem.Domain.Entities.District;
 using OASystem.Domain.Entities.Financial;
 using OASystem.Domain.Entities.Groups;
-using OASystem.Domain.Entities.PersonnelModule;
-using OASystem.Domain.Entities.System;
 using OASystem.Domain.ViewModels.Financial;
 using OASystem.Domain.ViewModels.JuHeExchangeRate;
-using OASystem.Domain.ViewModels.PersonnelModule;
 using OASystem.Infrastructure.Repositories.CRM;
 using OASystem.Infrastructure.Repositories.Groups;
-using System.Collections;
-using System.Collections.Generic;
 using System.IdentityModel.Tokens.Jwt;
 using System.Security.Claims;
-using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
 
 namespace OASystem.API.OAMethodLib
 {
@@ -57,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);//添加消息
 
@@ -93,7 +84,7 @@ namespace OASystem.API.OAMethodLib
 
             return false;
         }
-        
+
         /// <summary>
         /// 根据消息类型 获取 消息通知类型
         /// </summary>
@@ -111,20 +102,7 @@ namespace OASystem.API.OAMethodLib
             return notificationStr;
         }
 
-        public class NotificationTypeView
-        {
-            /// <summary>
-            /// 通知类型
-            /// 1 操作通知
-            /// 2 任务通知
-            /// </summary>
-            public int TypeId { get; set; }
-
-            /// <summary>
-            /// 消息类型id
-            /// </summary>
-            public List<int> MsgTypeIds { get; set; }
-        }
+        
 
         #endregion
 

+ 0 - 12
OASystem/OASystem.Api/OAMethodLib/Quartz/Business/TaskNewsFeedJob.cs

@@ -1,12 +0,0 @@
-using Microsoft.AspNetCore.SignalR;
-using OASystem.Domain.Entities.PersonnelModule;
-using OASystem.Infrastructure.Repositories.PersonnelModule;
-using ILogger = Microsoft.Extensions.Logging.ILogger;
-
-namespace OASystem.API.OAMethodLib.Quartz.Business
-{
-    public static class TaskNewsFeedJob
-    {
-       
-    }
-}

+ 141 - 0
OASystem/OASystem.Api/OAMethodLib/Quartz/Business/TaskNotification.cs

@@ -0,0 +1,141 @@
+using Microsoft.AspNetCore.SignalR;
+using OASystem.API.OAMethodLib.Hub.HubClients;
+using OASystem.API.OAMethodLib.Hub.Hubs;
+using OASystem.API.OAMethodLib.SignalR.Hubs;
+using OASystem.Domain.Entities.PersonnelModule;
+using OASystem.Infrastructure.Repositories.PersonnelModule;
+using ILogger = Microsoft.Extensions.Logging.ILogger;
+
+namespace OASystem.API.OAMethodLib.Quartz.Business
+{
+    public static class TaskNotification
+    {
+
+        private readonly static ILogger _logger;
+        private readonly static TaskAllocationRepository _taskAllocationRep = AutofacIocManager.Instance.GetService<TaskAllocationRepository>();
+        private readonly static IHubContext<ChatHub, IChatClient> _hubContext = AutofacIocManager.Instance.GetService<IHubContext<ChatHub, IChatClient>>();
+
+        /// <summary>
+        /// 任务通知
+        /// </summary>
+        public static async void PostTaskMessageNotification() 
+        {
+            _logger.LogInformation("调用任务消息推送 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "【在线人数】:" + JsonConvert.SerializeObject(UserStore.OnlineUser));
+
+            //在此处编写任务业务代码
+            #region 消息处理
+
+            var data = _taskAllocationRep._sqlSugar
+                                         .Queryable<Domain.Entities.PersonnelModule.Pm_TaskAllocation>()
+                                         .Where(it => it.IsDel == 0 &&
+                                                      !string.IsNullOrEmpty(it.PredictEndTime) &&
+                                                      Convert.ToDateTime(it.PredictEndTime).ToString("yyyy-MM-dd").Equals(DateTime.Now.ToString("yyyy-MM-dd"))
+                                               )
+                                         .ToList();
+            if (data.Count > 0)
+            {
+                //处理要任务提醒的员工
+                List<int> primaryIds = new List<int>();
+                primaryIds = data.Select(it => it.Id).ToList();
+                var subData = _taskAllocationRep._sqlSugar
+                                                .Queryable<Domain.Entities.PersonnelModule.Pm_TaskRelevanceUser>()
+                                                .Where(it => it.IsDel == 0 &&
+                                                             primaryIds.Contains(it.TAId) &&
+                                                             (int)it.TaskStatus <= (int)TaskEnum.UnderWay
+                                                      )
+                                                .ToList();
+
+                _taskAllocationRep._sqlSugar.BeginTran();
+                var depDatas = _taskAllocationRep._sqlSugar.Queryable<Sys_Department>().Where(it => it.IsDel == 0).ToList();
+                var groupDatas = _taskAllocationRep._sqlSugar.Queryable<Domain.Entities.Groups.Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
+                var userDatas = _taskAllocationRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0).ToList();
+
+                List<int> userIds = new List<int>();
+
+                foreach (var item in data)
+                {
+                    string depName = string.Empty;
+                    string groupName = string.Empty;
+                    var depData = depDatas.Where(it => it.Id == item.DepId).FirstOrDefault();
+                    if (depData != null) { depName = depData.DepName; }
+                    if (item.DiId == -1) { groupName = "其他"; }
+                    else
+                    {
+                        var groupData = groupDatas.Where(it => it.Id == item.DiId).FirstOrDefault();
+                        if (groupData != null) { groupName = groupData.TeamName; }
+                    }
+
+                    var subData1 = subData.Where(it => it.TAId == item.Id).ToList();
+
+                    foreach (var subItem in subData1)
+                    {
+                        string realityStartTime = string.Empty;
+                        string userName = string.Empty;
+                        if (!string.IsNullOrEmpty(subItem.BeginTime))
+                        {
+                            realityStartTime = subItem.BeginTime;
+                        }
+                        else
+                        {
+                            if (subItem.TaskStatus == TaskerEnum.NotStarted) realityStartTime = "未开始";
+                            else if (subItem.TaskStatus == TaskerEnum.HaveKnown) realityStartTime = "已知晓";
+                        }
+
+                        var userData = userDatas.Where(it => it.Id == subItem.UserId).FirstOrDefault();
+                        if (userData != null) { userName = userData.CnName; }
+                        string msgContent = string.Format(@"归属团组:{1}<br/>
+                                                            预计起止时间:{2} 至 {3}<br/>
+                                                            任务参与者:{4}",
+                                                            groupName, item.PredictBeginTime, item.PredictEndTime, userName);
+                        Sys_Message _Message = new Sys_Message()
+                        {
+                            Type = MessageTypeEnum.TaskProgressUpdate,
+                            Title = item.TaskName,
+                            IssuerId = 4, //管理员
+                            Content = msgContent,
+                            ReleaseTime = DateTime.Now,
+                            CreateUserId = 4,
+                            CreateTime = DateTime.Now,
+                            DeleteTime = "1990-01-01 00:00:00.000",
+                            DiId = item.DiId,
+                        };
+                        var msgAddId = _taskAllocationRep._sqlSugar.Insertable<Sys_Message>(_Message).ExecuteReturnIdentity();
+                        if (msgAddId < 0)
+                        {
+                            _taskAllocationRep._sqlSugar.RollbackTran();
+                            _logger.LogError("任务通知消息推送失败!");
+                            return;
+                        }
+
+                        Sys_MessageReadAuth _MessageReadAuth = new Sys_MessageReadAuth()
+                        {
+                            MsgId = msgAddId,
+                            ReadableUId = subItem.UserId,
+                            IsRead = 0,
+                            ReadTime = Convert.ToDateTime("1990-01-01 00:00:00.000"),
+                            CreateUserId = 4,
+                            CreateTime = DateTime.Now,
+                            DeleteTime = "1990-01-01 00:00:00.000"
+                        };
+
+                        var msgAuthAddId = _taskAllocationRep._sqlSugar.Insertable<Sys_MessageReadAuth>(_MessageReadAuth).ExecuteReturnIdentity();
+                        if (msgAuthAddId < 0)
+                        {
+                            _taskAllocationRep._sqlSugar.RollbackTran();
+                            _logger.LogError("任务通知消息推送失败!");
+                            return;
+                        }
+                        userIds.Add(subItem.UserId);
+                    }
+                }
+                _taskAllocationRep._sqlSugar.CommitTran();
+                //推送消息
+                _hubContext.Clients.Clients(UserStore.OnlineUser.Where(it => userIds.Contains(it.UserId)).Select(it => it.ConnectionId).ToList()).ReceiveMessage("您有新的任务相关消息");
+
+                _logger.LogInformation("任务消息推送成功 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "【在线人数】:" + JsonConvert.SerializeObject(UserStore.OnlineUser));
+            }
+            #endregion
+        }
+
+    }
+}

+ 6 - 131
OASystem/OASystem.Api/OAMethodLib/Quartz/Jobs/TaskNewsFeedJob.cs

@@ -1,6 +1,8 @@
 using Microsoft.AspNetCore.SignalR;
+using OASystem.API.OAMethodLib.Hub.HubClients;
 using OASystem.API.OAMethodLib.Hub.Hubs;
 using OASystem.API.OAMethodLib.Quartz.Business;
+using OASystem.API.OAMethodLib.SignalR.Hubs;
 using OASystem.Infrastructure.Repositories.PersonnelModule;
 using Quartz;
 
@@ -13,14 +15,11 @@ namespace OASystem.API.OAMethodLib.Quartz.Jobs
     public class TaskNewsFeedJob : IJob
     {
         private readonly ILogger<TaskNewsFeedJob> _logger;
-        private readonly TaskAllocationRepository _taskAllocationRep = AutofacIocManager.Instance.GetService<TaskAllocationRepository>();
 
-        public TaskNewsFeedJob(ILogger<TaskNewsFeedJob> logger, TaskAllocationRepository taskAllocationRep)
+        public TaskNewsFeedJob(ILogger<TaskNewsFeedJob> logger)
         {
             _logger = logger;
-            _taskAllocationRep = taskAllocationRep;
         }
-
         /// <summary>
         /// 任务消息推送
         /// </summary>
@@ -28,136 +27,12 @@ namespace OASystem.API.OAMethodLib.Quartz.Jobs
         /// <returns></returns>
         public async Task Execute(IJobExecutionContext context)
         {
-            //_logger.LogInformation("调用任务消息推送 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")+"【在线人数】:"+JsonConvert.SerializeObject(ServerHub.OnlineUser));
-
-            //在此处编写任务业务代码
-            #region 消息处理
-
-            //var data = _taskAllocationRep._sqlSugar
-            //                             .Queryable<Pm_TaskAllocation>()
-            //                             .Where(it => it.IsDel == 0 &&
-            //                                          !string.IsNullOrEmpty(it.PredictEndTime) &&
-            //                                          Convert.ToDateTime(it.PredictEndTime).ToString("yyyy-MM-dd").Equals(DateTime.Now.ToString("yyyy-MM-dd"))
-            //                                   )
-            //                             .ToList();
-            //if (data.Count > 0)
-            //{
-            //    //处理要任务提醒的员工
-            //    List<int> primaryIds = new List<int>();
-            //    primaryIds = data.Select(it => it.Id).ToList();
-            //    var subData = _taskAllocationRep._sqlSugar
-            //                                    .Queryable<Pm_TaskRelevanceUser>()
-            //                                    .Where(it => it.IsDel == 0 &&
-            //                                                 primaryIds.Contains(it.TAId) &&
-            //                                                 it.TaskStatus <= (int)TaskEnum.UnderWay
-            //                                          )
-            //                                    .ToList();
-
-            //    _taskAllocationRep._sqlSugar.BeginTran();
-            //    var depDatas = _taskAllocationRep._sqlSugar.Queryable<Sys_Department>().Where(it => it.IsDel == 0).ToList();
-            //    var groupDatas = _taskAllocationRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
-            //    var userDatas = _taskAllocationRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0).ToList();
-
-            //    foreach (var item in data)
-            //    {
-            //        string depName = string.Empty;
-            //        string groupName = string.Empty;
-            //        var depData = depDatas.Where(it => it.Id == item.DepId).FirstOrDefault();
-            //        if (depData != null) { depName = depData.DepName; }
-            //        if (item.DiId == -1) { groupName = "其他"; }
-            //        else
-            //        {
-            //            var groupData = groupDatas.Where(it => it.Id == item.DiId).FirstOrDefault();
-            //            if (groupData != null) { groupName = groupData.TeamName; }
-            //        }
 
-            //        var subData1 = subData.Where(it => it.TAId == item.Id).ToList();
+            _logger.LogInformation("调用任务状态变更Function " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
 
-            //        foreach (var subItem in subData1)
-            //        {
-            //            string realityStartTime = string.Empty;
-            //            string userName = string.Empty;
-            //            if (!string.IsNullOrEmpty(subItem.BeginTime))
-            //            {
-            //                realityStartTime = subItem.BeginTime;
-            //            }
-            //            else
-            //            {
-            //                if (subItem.TaskStatus == -1) realityStartTime = "未开始";
-            //                else if (subItem.TaskStatus == 0) realityStartTime = "已知晓";
-            //            }
-
-            //            var userData = userDatas.Where(it => it.Id == subItem.UserId).FirstOrDefault();
-            //            if (userData != null) { userName = userData.CnName; }
-            //            string msgContent = string.Format(@"任务归属:{0}<br/>
-            //                                                归属团组:{1}<br/>
-            //                                                预计起止时间:{2} 至 {3}<br/>
-            //                                                实际开始时间:{4}<br/>
-            //                                                任务优先级:{5}<br/>
-            //                                                任务参与者:{6}<br/>
-            //                                                任务内容:{7}", depName, groupName, item.PredictBeginTime, item.PredictEndTime,
-            //                                                realityStartTime, item.TaskPriority, userName, item.TaskContent);
-            //            Sys_Message _Message = new Sys_Message()
-            //            {
-            //                Type = MessgeTypeEnum.TaskProgressUpdate,
-            //                Title = item.TaskName,
-            //                IssuerId = 4, //管理员
-            //                Content = msgContent,
-            //                ReleaseTime = DateTime.Now,
-            //                CreateUserId = 4,
-            //                CreateTime = DateTime.Now,
-            //                DeleteTime = "1990-01-01 00:00:00.000",
-            //                DiId = item.DiId,
-            //            };
-            //            var msgAddId = _taskAllocationRep._sqlSugar.Insertable<Sys_Message>(_Message).ExecuteReturnIdentity();
-            //            if (msgAddId < 0)
-            //            {
-            //                _taskAllocationRep._sqlSugar.RollbackTran();
-            //                _logger.LogError("任务通知消息推送失败!");
-            //                return;
-            //            }
-
-            //            Sys_MessageReadAuth _MessageReadAuth = new Sys_MessageReadAuth()
-            //            {
-            //                MsgId = msgAddId,
-            //                ReadableUId = subItem.UserId,
-            //                IsRead = 0,
-            //                ReadTime = Convert.ToDateTime("1990-01-01 00:00:00.000"),
-            //                CreateUserId = 4,
-            //                CreateTime = DateTime.Now,
-            //                DeleteTime = "1990-01-01 00:00:00.000"
-            //            };
-
-            //            var msgAuthAddId = _taskAllocationRep._sqlSugar.Insertable<Sys_MessageReadAuth>(_MessageReadAuth).ExecuteReturnIdentity();
-            //            if (msgAuthAddId < 0)
-            //            {
-            //                _taskAllocationRep._sqlSugar.RollbackTran();
-            //                _logger.LogError("任务通知消息推送失败!");
-            //                return;
-            //            }
-            //        }
-            //    }
-            //    _taskAllocationRep._sqlSugar.CommitTran();
-            //}
-            #endregion
-
-            string msg = string.Empty;
-            
-                //查询需要提示的消息 Singlr
-                string sql = string.Format(@"Select smra.Id,su.CnName As Issuer,sm.ReleaseTime,sm.Title,
-										 sm.Content,smra.ReadableUId,smra.IsRead,smra.CreateTime
-										 From Sys_Message sm
-										 Left Join Sys_MessageReadAuth smra On sm.Id = smra.MsgId
-										 Left Join Sys_Users su On sm.IssuerId = su.Id
-										 Where sm.IsDel = 0 And sm.Type = 6 And smra.IsRead = 0
-										 Order By smra.ReadableUId,smra.CreateTime Desc");
-                var datas = _taskAllocationRep._sqlSugar.SqlQueryable<MessageReadAuthPushView>(sql).ToList();
-                msg = JsonConvert.SerializeObject(datas);
+            //在此处编写任务业务代码
+             TaskNotification.PostTaskMessageNotification();
 
-                //_hubContext.Clients.All.SendAsync("ReceiveMessage", "系统通知", $"最新消息{DateTime.Now}");
-                //推送给所有连接ID的第一条数据
-           
-            //await _hubContext.Clients.Clients(ServerHub.OnlineUser.Select(q => q.ConnectionId).ToList()).SendAsync("SendMessageResponse", $"最新消息{DateTime.Now}");
             //return Task.CompletedTask;
         }
     }

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

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

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

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

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

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

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

+ 1 - 1
OASystem/OASystem.Domain/Entities/Groups/Grp_CreditCardPayment.cs

@@ -158,7 +158,7 @@ namespace OASystem.Domain.Entities.Groups
         /// 此次付款百分比
         /// </summary>
         [SugarColumn(IsNullable = true, ColumnDataType = "decimal(10, 2)")]
-        public decimal PayPercentage { get; set; }
+        public decimal PayPercentage { get; set; } = 100M;
         /// <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")]
         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>
         /// 发布者用户Id
         /// 4 管理员 Id 
@@ -36,8 +49,8 @@ namespace OASystem.Domain.Entities.System
         /// <summary>
         /// 团组Id,可为0
         /// </summary>
-        [SugarColumn(IsNullable = true,ColumnDataType = "int")]
-        public int DiId { get; set; }
+        [SugarColumn(IsNullable = true, ColumnDataType = "int")]
+        public int DiId { get; set; } = 0;
 
         /// <summary>
         /// 消息标题

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

@@ -11,11 +11,17 @@ namespace OASystem.Domain.ViewModels.System
     {
     }
 
+    public class MessageUnreadTotalCountView
+    {
+        public int UnreadCount { get; set; }
+    }
+
     /// <summary>
     /// 用于都消息返回视图
     /// </summary>
-    public class ReadbleMessageView
+    public class MessageListView
     {
+        public int RowNumber { get; set; }
         public int Id { get; set; }
 
         /// <summary>
@@ -52,22 +58,68 @@ namespace OASystem.Domain.ViewModels.System
         /// </summary>
         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>
-        /// 可阅读员工Id
+        /// 消息类型
+        /// 1 公告消息
+        /// 2 团组流程管控消息
+        /// 3 团组业务操作消息
+        /// 4费用
         /// </summary>
-        public int ReadableUId { get; set; }
+        public int Type { get; set; }
 
         /// <summary>
-        /// 是否阅读
-        /// 0 未阅读
-        /// 1 已阅读
+        /// 消息标题
         /// </summary>
-        public int IsRead { get; set; }
+        public string Title { get; set; }
 
         /// <summary>
-        /// 阅读时间
+        /// 消息内容
         /// </summary>
-        public DateTime? ReadTime { get; set; }
+        public string Content { get; set; }
+
+        /// <summary>
+        /// 发布部门
+        /// </summary>
+        public string IssuerDep { get; set; }
+
+        /// <summary>
+        /// 发布者
+        /// </summary>
+        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 
@@ -127,6 +179,10 @@ namespace OASystem.Domain.ViewModels.System
         /// 1990-01-01 00:00:000 未读
         /// </summary>
         public DateTime ReadTime { get; set; }
+
+        public int DiId { get; set; }
+
+        public string Param { get; set; }
     }
 
     public class MessageTypeView 
@@ -142,4 +198,19 @@ namespace OASystem.Domain.ViewModels.System
         /// </summary>
         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 };
 
-            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
                                              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)
         {
             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,
                                              	    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
 
            
-            if (dto.PortType == 1 || dto.PortType == 2) //web
+            if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //web
             {
                 //Fin_DailyFeePaymentPageCount
                 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 = "未知错误" };
 
-            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,
 	                                                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")
             };
 
-            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 endIndex = startIndex + dto.PageSize - 1;
@@ -220,7 +220,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
         {
             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
                   From  Grp_DelegationInfo gdi
@@ -384,7 +384,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
 
             try
             {
-                if (dto.PortType == 1 || dto.PortType == 2) //web
+                if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //web
                 {
                     dynamic? teamTypeData1 = null;
                     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 = "未知错误" };
 
-            if (dto.PortType == 1 || dto.PortType == 2) //web
+            if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //web
             {
 
                 #region 添加出访起止时间
@@ -630,7 +630,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
         {
             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
                 {
@@ -771,7 +771,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
         {
             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 
                                              Where TeamName != '' And IsDel = 0
@@ -801,7 +801,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
         {
             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 
                                              Where TeamName != '' And IsDel = 0
@@ -835,7 +835,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
         public async Task<Result> GetCrmByGroupId(ClientByGroupIdDto dto)
         {
             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 
                                              From  Grp_DelegationJoinCustomer gdjc

+ 9 - 3
OASystem/OASystem.Infrastructure/Repositories/Groups/HotelPriceRepository.cs

@@ -25,12 +25,14 @@ namespace OASystem.Infrastructure.Repositories.Groups
         private readonly IMapper _mapper;
         private readonly Result _result;
         private readonly TeamRateRepository _teamRateRep;
-        public HotelPriceRepository(SqlSugarClient sqlSugar, IMapper mapper, TeamRateRepository teamRateRep) :
-            base(sqlSugar)
+        private readonly TourClientListRepository _tourClientListRep;
+        public HotelPriceRepository(SqlSugarClient sqlSugar, IMapper mapper, TeamRateRepository teamRateRep, TourClientListRepository tourClientListRep) 
+            :base(sqlSugar)
         {
             this._mapper = mapper;
             _result = new Result() { Code = -1, Msg = "操作失败!" };
             _teamRateRep = teamRateRep;
+            _tourClientListRep = tourClientListRep;
         }
 
         #region 保留
@@ -793,6 +795,9 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     _CheckVolumeNo = checkVoumeNoData.Result.Data;
                 }
 
+                //客户名单
+                var guestNames = await _tourClientListRep._GuestNameItemByDiId(portType, diId);
+
                 var data = new
                 {
                     GuestType = _GuestType, //客人分类
@@ -801,7 +806,8 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     BankCard = _BankCard,
                     BookingWebsite = _BookingWebsite,
                     CheckPerson = _CheckPerson,
-                    CheckVolumeNo = _CheckVolumeNo
+                    CheckVolumeNo = _CheckVolumeNo,
+                    GuestName = guestNames
                 };
 
                 _result.Code = 0;

+ 25 - 0
OASystem/OASystem.Infrastructure/Repositories/Groups/TourClientListRepository.cs

@@ -35,6 +35,31 @@ namespace OASystem.Infrastructure.Repositories.Groups
             _mapper = mapper;
         }
 
+
+
+        /// <summary>
+        /// 根据团组Id客人名单List
+        /// </summary>
+        /// <param name="portId"></param>
+        /// <param name="diId"></param>
+        /// <returns></returns>
+        public async Task<List<SimplClientInfo>> _GuestNameItemByDiId(int portId, int diId)
+        {
+            List<SimplClientInfo> simplClients = new List<SimplClientInfo>();
+            if (portId == 1 || portId == 2 || portId == 3) // 1 web 2 Android 3 ios
+            {
+                string sql = $@"Select b.Id,b.Pinyin,b.lastName,b.firstName,b.phone From  Grp_TourClientList a, Crm_DeleClient b 
+                                Where a.clientid = b.id and a.isdel = 0 and a.diId = {diId}";
+                simplClients = await _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToListAsync();
+            }
+            else
+            {
+                _result.Msg = "请传入有效的PortType参数,1 Web 2 Android 3 IOS!";
+            }
+            return simplClients;
+        }
+
+
         /// <summary>
         /// 根据团组Id查询List
         /// </summary>

+ 72 - 46
OASystem/OASystem.Infrastructure/Repositories/System/MessageRepository.cs

@@ -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;
@@ -17,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) 
@@ -58,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();
@@ -121,7 +121,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 +177,7 @@ namespace OASystem.Infrastructure.Repositories.System
 
 
         /// <summary>
-        /// 获取消息列表
+        /// 获取消息类型列表
         /// </summary>
         /// <param name="uId">可读用户Id</param>
         /// <returns></returns>
@@ -185,9 +185,33 @@ 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");
+            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, 
+                                                    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 +221,41 @@ 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;               //任务通知 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	任务操作通知 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
+                {
                     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 +284,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 +302,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 +314,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 +341,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 +376,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>()