Browse Source

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

yuanrf 1 month ago
parent
commit
b9daa3ba74

+ 4 - 0
OASystem/OASystem.Api/Controllers/FinancialController.cs

@@ -198,6 +198,8 @@ namespace OASystem.API.Controllers
                 string content = $"[新增-日付申请]一项费用:[费用说明:{dailyInfo.Instructions}]{dailyInfo.SumPrice.ToString("#0.00")} CNY;";
 
                 await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.DailyPayment, title, content, userIds, 0);
+
+                await GeneralMethod.iOS_PushNotifications("051", $"日付费用审核", "", content);
             }
             catch (Exception ex)
             {
@@ -239,6 +241,8 @@ namespace OASystem.API.Controllers
                 string content = $"[更新-日付申请]一项费用:[费用说明:{dailyInfo.Instructions}]{dailyInfo.SumPrice.ToString("#0.00")} CNY;";
 
                 await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.DailyPayment, title, content, userIds, 0);
+
+                await GeneralMethod.iOS_PushNotifications("051", $"日付费用审核", "", content);
             }
             catch (Exception ex)
             {

+ 114 - 75
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -1,4 +1,5 @@
 using Aspose.Cells;
+using Aspose.Cells.Charts;
 using Aspose.Words;
 using Aspose.Words.Drawing;
 using Aspose.Words.Tables;
@@ -30,6 +31,7 @@ using OASystem.Domain.ViewModels.Statistics;
 using OASystem.Infrastructure.Repositories.Financial;
 using OASystem.Infrastructure.Repositories.Groups;
 using OfficeOpenXml;
+using Org.BouncyCastle.Asn1.Ocsp;
 using Quartz.Util;
 using SqlSugar;
 using SqlSugar.Extensions;
@@ -108,39 +110,39 @@ namespace OASystem.API.Controllers
         private readonly OpinionaireRepository _opinionaireRep;  //对外收款账单仓库
 
         public GroupsController(
-            ILogger<GroupsController> logger, 
+            ILogger<GroupsController> logger,
             IMapper mapper,
             IHubContext<ChatHub, IChatClient> hubContext,
-            SqlSugarClient sqlSugar, 
-            GrpScheduleRepository grpScheduleRep, 
+            SqlSugarClient sqlSugar,
+            GrpScheduleRepository grpScheduleRep,
             DelegationInfoRepository groupRepository,
-            TaskAssignmentRepository taskAssignmentRep, 
-            AirTicketResRepository airTicketResRep, 
+            TaskAssignmentRepository taskAssignmentRep,
+            AirTicketResRepository airTicketResRep,
             DecreasePaymentsRepository decreasePaymentsRep,
-            InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, 
-            DelegationEnDataRepository delegationEnDataRep, 
-            EnterExitCostRepository enterExitCostRep, 
+            InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
+            DelegationEnDataRepository delegationEnDataRep,
+            EnterExitCostRepository enterExitCostRep,
             DelegationVisaRepository delegationVisaRep,
-            MessageRepository message, 
-            VisaPriceRepository visaPriceRep, 
+            MessageRepository message,
+            VisaPriceRepository visaPriceRep,
             CarTouristGuideGroundRepository carTouristGuideGroundRep,
-            CheckBoxsRepository checkBoxs, 
-            GroupCostRepository GroupCostRepository, 
+            CheckBoxsRepository checkBoxs,
+            GroupCostRepository GroupCostRepository,
             CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
             GroupCostParameterRepository GroupCostParameterRepository,
-            HotelPriceRepository hotelPriceRep, 
-            CustomersRepository customersRep, 
+            HotelPriceRepository hotelPriceRep,
+            CustomersRepository customersRep,
             SetDataRepository setDataRep,
-            TourClientListRepository tourClientListRep, 
+            TourClientListRepository tourClientListRep,
             TeamRateRepository teamRateRep,
             UsersRepository usersRep, IJuHeApiService juHeApi,
-            InvertedListRepository invertedListRep, 
-            VisaFeeInfoRepository visaFeeInfoRep, 
-            TicketBlackCodeRepository ticketBlackCodeRep, 
+            InvertedListRepository invertedListRep,
+            VisaFeeInfoRepository visaFeeInfoRep,
+            TicketBlackCodeRepository ticketBlackCodeRep,
             HotelInquiryRepository hotelInquiryRep,
-            ThreeCodeRepository threeCodeRepository, 
-            FeeAuditRepository feeAuditRep, 
-            VisaCommissionRepository visaCommissionRep, 
+            ThreeCodeRepository threeCodeRepository,
+            FeeAuditRepository feeAuditRep,
+            VisaCommissionRepository visaCommissionRep,
             ForeignReceivablesRepository ffrRep,
             OpinionaireRepository opinionaireRep
             )
@@ -820,7 +822,7 @@ namespace OASystem.API.Controllers
                     await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
 
                     //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
-                    List<int> _managerIds = new List<int>() { 21,22, 32 };
+                    List<int> _managerIds = new List<int>() { 21, 22, 32 };
                     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)
                     {
@@ -1881,7 +1883,7 @@ FROM
                             entity.PayMoney = czInfo.Price * czInfo.PriceCount;
                             entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
                         }
-                        
+
                     }
 
                     /*
@@ -2738,47 +2740,41 @@ FROM
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
         {
-            try
+            Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
+            if (groupData.Code != 0)
             {
-                Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
-                if (groupData.Code != 0)
-                {
-                    return Ok(JsonView(false, groupData.Msg));
-                }
+                return Ok(JsonView(false, groupData.Msg));
+            }
 
-                #region 应用推送
-                try
-                {
-                    int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
-                    int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
+            #region 应用推送
+            try
+            {
+                int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
+                int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
 
-                    await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
+                await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
 
-                    //2024-10-21 新增LZ UID
-                    var userIds = new List<int>() { 21 };
-                    string title = $"系统通知";
-                    string content = "";
-                    var diId = dto.AirTicketResOpData.DiId;
-                    var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
-                    var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
-                    if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
-                    else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
+                //2024-10-21 新增LZ UID
+                var userIds = new List<int>() { 21 };
+                string title = $"系统通知";
+                string content = "";
+                var diId = dto.AirTicketResOpData.DiId;
+                var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
+                var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
+                if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
+                else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
 
-                    await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
+                await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
 
-                }
-                catch (Exception ex)
-                {
-                }
-                #endregion
+                await GeneralMethod.iOS_PushNotifications("051", $"机票费用审核", "", content);
 
-                return Ok(JsonView(true, groupData.Msg, groupData.Data));
             }
             catch (Exception ex)
             {
-                return Ok(JsonView(false, "程序错误!"));
-                throw;
             }
+            #endregion
+
+            return Ok(JsonView(true, groupData.Msg, groupData.Data));
         }
 
         /// <summary>
@@ -3662,6 +3658,10 @@ FROM
 
             await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
 
+            await GeneralMethod.iOS_PushNotifications("051", $"其他款项费用审核", "", content);
+
+
+
             #endregion
 
             return Ok(JsonView(true, groupData.Msg, groupData.Data));
@@ -3806,7 +3806,7 @@ FROM
             foreach (DataRow item in dt.Rows)
             {
                 var otaOrderNo = item["OTAOrderNo"].ToString();
-                var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) &&  x.OTAOrderNo.Contains(otaOrderNo));
+                var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
                 if (oaData == null) continue;
 
                 item["GroupName"] = oaData.TeamName;
@@ -3999,7 +3999,7 @@ FROM
                             catch (Exception)
                             {
 
-                            files = new List<string>() { info.Attachment }.ToArray();
+                                files = new List<string>() { info.Attachment }.ToArray();
                             }
                         }
                         if (files.Length > 0)
@@ -4009,7 +4009,7 @@ FROM
                             string filePath2 = string.Empty;
                             if (files1.Length > 0)
                             {
-                                filePath2 = JsonConvert.SerializeObject( files1);
+                                filePath2 = JsonConvert.SerializeObject(files1);
                             }
 
                             id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
@@ -4018,16 +4018,16 @@ FROM
                                                 .ExecuteCommandAsync();
                         }
                     }
-            }
+                }
                 if (id != 0)
-            {
-                return Ok(JsonView(true, "成功!"));
-            }
-            else
-            {
-                return Ok(JsonView(false, "失败!"));
+                {
+                    return Ok(JsonView(true, "成功!"));
+                }
+                else
+                {
+                    return Ok(JsonView(false, "失败!"));
+                }
             }
-        }
             catch (Exception ex)
             {
                 return Ok(JsonView(false, "程序错误!"));
@@ -4175,7 +4175,7 @@ FROM
                 }
             }
 
-            return Ok(JsonView(new {url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
+            return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
         }
 
         /// <summary>
@@ -4262,6 +4262,8 @@ FROM
                 else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
 
                 await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
+
+                await GeneralMethod.iOS_PushNotifications("051", $"商邀费用审核", "", content);
             }
             catch (Exception ex)
             {
@@ -5231,7 +5233,7 @@ FROM
                 string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
                 await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
                 //汇率信息记录
-                await GeneralMethod.RateRecordSave(dto.UserId,sign,"出入境费用");
+                await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
 
                 return Ok(JsonView(true, data.Msg, data.Data));
             }
@@ -5300,7 +5302,7 @@ FROM
                 var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
                 if (_EnterExitCosts == null)
                 {
-                    return Ok(JsonView(400, "该团组未填写出入境费用;",""));
+                    return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
                 }
 
                 //数据源
@@ -5673,7 +5675,7 @@ FROM
                         string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
 
                         if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
-                        else if (dto.PortType == 2 ) return Ok(JsonView(true, "成功", url));
+                        else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
                     }
                     else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
                     {
@@ -5897,7 +5899,7 @@ FROM
                         string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
 
                         if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
-                        else if (dto.PortType == 2 ) return Ok(JsonView(true, "成功", url));
+                        else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
                     }
                     else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
                     {
@@ -6578,7 +6580,7 @@ FROM
                     {
                         if (DeleClientList.Count < 1)
                         {
-                            return Ok(JsonView(false, "团组成员暂未录入!!!",""));
+                            return Ok(JsonView(false, "团组成员暂未录入!!!", ""));
                         }
 
                         //获取模板
@@ -7138,7 +7140,9 @@ FROM
                 if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
                 else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
 
-                await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
+                await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId); 
+                
+                await GeneralMethod.iOS_PushNotifications("051", $"签证费用审核", "", content);
             }
             catch (Exception ex)
             {
@@ -7511,6 +7515,7 @@ FROM
                     string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage).ToString("#0.00")} CNY;";
 
                     await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
+                    await GeneralMethod.iOS_PushNotifications("051", "OP费用审核", "", content);
                 }
                 catch (Exception ex)
                 {
@@ -10994,6 +10999,9 @@ ORDER by  gctggrc.id DESC
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
         {
+
+          
+
             #region  参数验证
             if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
             if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
@@ -11032,6 +11040,35 @@ ORDER by  gctggrc.id DESC
 
             #region 应用推送
 
+            try
+            {
+
+                int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
+                int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
+                int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
+                _logger.LogInformation($"【iOS推送通知Exception】Begin");
+                //2024-10-21 新增LZ UID
+                var userIds = new List<int>() { 21 };
+                string title = $"费用审核";
+                var diId = _dto.DiId;
+                var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
+                var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
+                string content = "";
+                if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
+                else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
+
+                Logs($"【iOS推送通知Exception】Start");
+                await GeneralMethod.iOS_PushNotifications("051", title, "", content);
+                Logs($"【iOS推送通知Exception】End ");
+
+            }
+            catch (Exception ex)
+            {
+                _logger.LogInformation($"【iOS推送通知Exception】【{ex.Message}】");
+                Log.Error($"【iOS推送通知Exception】【{ex.Message}】");
+                Logs($"【iOS推送通知Exception】【{ex.Message}】");
+            }
+
             try
             {
                 int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
@@ -11057,6 +11094,7 @@ ORDER by  gctggrc.id DESC
                 else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
 
                 await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
+                //await GeneralMethod.iOS_PushNotifications("051", "费用审核", "", content);
 
             }
             catch (Exception ex)
@@ -12264,7 +12302,7 @@ ORDER by  gctggrc.id DESC
             if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
             var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
             var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
-            
+
             var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
             //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
             if (_GroupCostParameter == null)
@@ -12474,7 +12512,7 @@ ORDER by  gctggrc.id DESC
                 var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
                 designer.SetDataSource("TourNo", groupInfo.TourCode);
 
-               var rateDatas1 = rateDatas.Distinct();
+                var rateDatas1 = rateDatas.Distinct();
                 var rateStr = string.Empty;
                 foreach (var item in rateDatas1)
                 {
@@ -13151,6 +13189,7 @@ ORDER by  gctggrc.id DESC
                 else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
 
                 await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
+                await GeneralMethod.iOS_PushNotifications("051", $"保险费用审核", "", content);
             }
             catch (Exception ex)
             {
@@ -15943,7 +15982,7 @@ And (UnitName != '' Or UnitName != null) {sqlWhere}");
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> OpinionaireManageList(int groupId)
         {
-            if (groupId < 1) Ok(JsonView(false,"请传入有效的diId"));
+            if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
 
             var data = await _opinionaireRep.Query(x => x.DiId == groupId)
                  .Select(x => new
@@ -15997,7 +16036,7 @@ And (UnitName != '' Or UnitName != null) {sqlWhere}");
                 var upd = await _opinionaireRep._sqlSugar
                     .Updateable(updData)
                     .UpdateColumns(x => new { x.CityName, x.TourGuideName })
-                    .WhereColumns(x =>new{ x.Id})
+                    .WhereColumns(x => new { x.Id })
                     .ExecuteCommandAsync();
             }
             _opinionaireRep.CommitTran();

+ 1 - 1
OASystem/OASystem.Api/Controllers/PersonnelModuleController.cs

@@ -2344,7 +2344,7 @@ OPTION (MAXRECURSION 0); -- 允许无限递归      ";
             var jw = JsonView(false);
 
 
-            APNsLib.pushMsg("com.panamerican.oa2024", "db151df1d25823f84323c4597c5672460a983d49ba039c7ff54c4c8e36edd5c6", NotificationType.Alert, "测试", "测试字标题", "测试内容");
+            APNsLib.pushMsg("com.panamerican.oa2024", "9a624f38602a8d2cc12b8c44c3cb37633e246963ec2bfd7bca2094b59dc9f09c", NotificationType.Alert, "Ver.Production测试", "测试字标题", "测试内容");
 
             return Ok(jw);
         }

+ 3 - 3
OASystem/OASystem.Api/OAMethodLib/APNs/APNsLib.cs

@@ -5,11 +5,11 @@ namespace OASystem.API.OAMethodLib.APNs
     {
         private static readonly IAPNsService _APNsService = AutofacIocManager.Instance.GetService<IAPNsService>();
 
-        public static bool pushMsg(string apnsTopic, string deviceToken, NotificationType type, string title, string subtitle, string body)
+        public static async Task<Result> pushMsg(string apnsTopic, string deviceToken, NotificationType type, string title, string subtitle, string body)
         {
-            _APNsService.PushNotification(apnsTopic, deviceToken, type, title, subtitle, body);
+            Result rst = await _APNsService.PushNotification(apnsTopic, deviceToken, type, title, subtitle, body);
 
-            return true;
+            return rst;
         }
     }
 }

+ 14 - 4
OASystem/OASystem.Api/OAMethodLib/APNs/APNsService.cs

@@ -111,8 +111,9 @@ namespace OASystem.API.OAMethodLib.APNs
         /// <param name="subtitle">子标题</param>
         /// <param name="body">通知内容</param>
         /// <returns></returns>
-        public async Task<string> PushNotification(string apnsTopic, string deviceToken, NotificationType type, string title, string subtitle, string body)
+        public async Task<Result> PushNotification(string apnsTopic, string deviceToken, NotificationType type, string title, string subtitle, string body)
         {
+            Result result = new Result() { Code = -1, Msg = "未知错误" };
             var responseData = FailedAPNsReponseData();
             var token = this.GetnerateAPNsJWTToken();
             var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, APNsService.baseUrl + deviceToken)
@@ -152,18 +153,27 @@ namespace OASystem.API.OAMethodLib.APNs
                 if (httpResponseMessage.IsSuccessStatusCode)
                 {
                     responseData.Code = 200;
-                    return System.Text.Json.JsonSerializer.Serialize(responseData);
+                    result.Code = 0;
+                    result.Msg = "";
+                    result.Data = responseData;
+                    return result;
                 }
                 else
                 {
                     responseData.Data = httpResponseMessage.StatusCode;
-                    return System.Text.Json.JsonSerializer.Serialize(responseData);
+                    result.Code = -2;
+                    result.Msg = "";
+                    result.Data = responseData;
+                    return result;
                 }
             }
             catch (Exception e)
             {
                 responseData.Data = e.Message;
-                return System.Text.Json.JsonSerializer.Serialize(responseData);
+                result.Code = -3;
+                result.Msg = "";
+                result.Data = responseData;
+                return result;
             }
         }
 

+ 1 - 1
OASystem/OASystem.Api/OAMethodLib/APNs/IAPNsService.cs

@@ -18,6 +18,6 @@
         /// <param name="subtitle">子标题</param>
         /// <param name="body">通知内容</param>
         /// <returns></returns>
-        Task<string> PushNotification(string apnsTopic, string deviceToken, NotificationType type, string title, string subtitle, string body);
+        Task<Result> PushNotification(string apnsTopic, string deviceToken, NotificationType type, string title, string subtitle, string body);
     }
 }

+ 23 - 5
OASystem/OASystem.Api/OAMethodLib/GeneralMethod.cs

@@ -5,6 +5,7 @@ using Aspose.Words.Layout;
 using Aspose.Words.Saving;
 using Microsoft.AspNetCore.SignalR;
 using Microsoft.International.Converters.PinYinConverter;
+using OASystem.API.OAMethodLib.APNs;
 using OASystem.API.OAMethodLib.File;
 using OASystem.API.OAMethodLib.Hub.HubClients;
 using OASystem.API.OAMethodLib.Hub.Hubs;
@@ -19,6 +20,7 @@ using OASystem.Domain.ViewModels.Groups;
 using OASystem.Domain.ViewModels.JuHeExchangeRate;
 using OASystem.Infrastructure.Repositories.CRM;
 using OASystem.Infrastructure.Repositories.Groups;
+using OASystem.Infrastructure.Repositories.Login;
 using OfficeOpenXml;
 using System.Data;
 using System.IdentityModel.Tokens.Jwt;
@@ -36,10 +38,11 @@ namespace OASystem.API.OAMethodLib
         private static readonly SetDataRepository _setDataRep = AutofacIocManager.Instance.GetService<SetDataRepository>();
         private static readonly TableOperationRecordRepository _tableOperationRecordRep = AutofacIocManager.Instance.GetService<TableOperationRecordRepository>();
         private static readonly MessageRepository _messageRep = AutofacIocManager.Instance.GetService<MessageRepository>();
+        private static readonly DeviceTokenRepository _deviceTokenRep = AutofacIocManager.Instance.GetService<DeviceTokenRepository>();
         private static readonly IHubContext<ChatHub, IChatClient> _hubContext = AutofacIocManager.Instance.GetService<IHubContext<ChatHub, IChatClient>>();
 
         private readonly static string[] weekdays = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
-        
+
         #region 员工注册默认添加基础页面
 
         /// <summary>
@@ -436,7 +439,7 @@ namespace OASystem.API.OAMethodLib
         /// <returns></returns>
         public static async Task<List<Web_ShareGroupInfoView>> PostOperationAuthReturnGroupInfosAsync(int userId, int CTable)
         {
-           var shareGroupInfoViews = new List<Web_ShareGroupInfoView>();
+            var shareGroupInfoViews = new List<Web_ShareGroupInfoView>();
             var taskData = _dirRep._sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(it => it.UId == userId && it.CTId == CTable && it.IsDel == 0).ToList();
 
             if (taskData.Count < 1) return shareGroupInfoViews;
@@ -726,8 +729,8 @@ namespace OASystem.API.OAMethodLib
 
 
             //98  其他款项  --> 总经办部门(1) 总经理(1) 岗位/国交部门(7)(ALL) 岗位/财务部门(3)(ALL) 岗位/策划部门(5)(ALL) 岗位/人事部门(4) 采购(74) 岗位
-           var depIds = new List<int>() { 7, 3, 5 };
-           var jobIds = new List<int>() { 1, 74 };
+            var depIds = new List<int>() { 7, 3, 5 };
+            var jobIds = new List<int>() { 1, 74 };
             groupsTaskAssignments.AddRange(
                 usersData
                 .Where(it => depIds.Contains(it.DepId) || jobIds.Contains(it.JobPostId))
@@ -895,7 +898,7 @@ namespace OASystem.API.OAMethodLib
             //数据源
             var stayData = dayAndCosts.Where(it => it.Type == 1).ToList();          //住宿费
             var mealData = dayAndCosts.Where(it => it.Type == 2).ToList();          //伙食费
-            var miscellaneousData =dayAndCosts.Where(it => it.Type == 3).ToList();  //公杂费
+            var miscellaneousData = dayAndCosts.Where(it => it.Type == 3).ToList();  //公杂费
             var trainData = dayAndCosts.Where(it => it.Type == 4).ToList();         //培训费
 
             //筛选 陪同人员 = 1
@@ -4438,6 +4441,21 @@ namespace OASystem.API.OAMethodLib
         }
 
 
+        #endregion
+
+        #region iOS推送通知
+
+        public static async Task<Result> iOS_PushNotifications(string Numbers, string title, string subtitle, string body)
+        {
+            var rst = await _deviceTokenRep.Query(s => s.Number == Numbers).SingleAsync();
+            Result rst2 = new Result() { Code = -1, Msg = "" };
+            if (rst != null) {
+                rst2 = await APNsLib.pushMsg("com.panamerican.oa2024", rst.DeviceToken, NotificationType.Alert, title, subtitle, body);
+            }
+            return rst2;
+        }
+
+
         #endregion
 
     }