Explorar el Código

签证国家时间通知调整,add 签证团组起始时间通知

yuanrf hace 5 meses
padre
commit
8eede6b842

+ 37 - 0
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -644,6 +644,24 @@ namespace OASystem.API.Controllers
                     diId = dto.Id;
                 }
 
+                #region 签证人员团组时间通知
+
+                #region 计算出访起止时间
+                var startTime = new DateTime();
+                var endTime = new DateTime();
+                if (DateTime.TryParse(dto.VisitDate, out startTime))
+                {
+                    endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
+                }
+                #endregion
+
+                if (diId > 0)
+                {
+                    await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
+                }
+
+                #endregion
+
                 #region 团组操作默认添加/修改收款账单
                 if (dto.PayDay > 0 && dto.PaymentMoney > 0)
                 {
@@ -855,6 +873,25 @@ namespace OASystem.API.Controllers
 
                 #endregion
 
+
+                #region 签证人员团组时间通知
+
+                #region 计算出访起止时间
+                var startTime = new DateTime();
+                var endTime = new DateTime();
+                if (DateTime.TryParse(dto.VisitDate, out startTime))
+                {
+                    endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
+                }
+                #endregion
+
+                if (diId > 0)
+                {
+                    await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
+                }
+
+                #endregion
+
                 _sqlSugar.CommitTran();
                 return Ok(JsonView(true, "添加成功"));
             }

+ 4 - 2
OASystem/OASystem.Api/Controllers/ResourceController.cs

@@ -1,6 +1,7 @@
 using Aspose.Words;
 using OASystem.API.OAMethodLib;
 using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
+using OASystem.Domain.Dtos.Groups;
 using OASystem.Domain.Entities.Groups;
 using OASystem.Domain.ViewModels.Groups;
 using OASystem.Infrastructure.Repositories.Groups;
@@ -2716,8 +2717,9 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
                 if (tongzhi.Code == 0)
                 {
                     var info = tongzhi.Data.GetType().GetProperty("info").GetValue(tongzhi.Data) as List<string>;
-                    if (info != null)
-                        await AppNoticeLibrary.SendUserMsg_blackAirInfo_ToVisaUser(dto.DiId, info.ToArray());
+                    var data = tongzhi.Data.GetType().GetProperty("data").GetValue(tongzhi.Data) as List<CountryDataTime>;
+                    if (data != null)
+                        await AppNoticeLibrary.SendUserMsg_blackAirInfo_ToVisaUser(dto.DiId, data);
                 }
 
                 //行程代码变更通知

+ 11 - 3
OASystem/OASystem.Api/OAMethodLib/QiYeWeChatAPI/AppNotice/Config.cs

@@ -1,4 +1,5 @@
-using OASystem.Domain.Entities.Groups;
+using OASystem.Domain.Dtos.Groups;
+using OASystem.Domain.Entities.Groups;
 using OASystem.Domain.ViewModels.CRM;
 using System.ComponentModel;
 
@@ -511,8 +512,15 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice
 
             foreach (var item in info.info)
             {
+                var black = string.Empty;
+                for (int i = 0; i < item.Country.Length * 2; i++)
+                {
+                    black += " ";
+                }
                 result += $@"
-><font color='comment'>{item}</font>";
+><font color='comment'>{item.Country}-抵达:{item.StartTime.ToString("yyyy-MM-dd HH:mm")}</font>
+><font color='comment'>{black} 离开:{item.EndTime.ToString("yyyy-MM-dd HH:mm")}</font>";
+
             }
 
             return result;
@@ -647,7 +655,7 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice
     {
         public string TeamName { get; set; }
 
-        public string[] info { get; set; }
+        public List<CountryDataTime>  info { get; set; }
 
         public string RefreshDate { get; set; }
     }

+ 36 - 2
OASystem/OASystem.Api/OAMethodLib/QiYeWeChatAPI/AppNotice/Library.cs

@@ -1,4 +1,5 @@
-using OASystem.Domain.Entities.Financial;
+using OASystem.Domain.Dtos.Groups;
+using OASystem.Domain.Entities.Financial;
 using OASystem.Domain.Entities.Groups;
 using OASystem.Domain.ViewModels.CRM;
 using OASystem.Domain.ViewModels.Groups;
@@ -1076,7 +1077,7 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice
             return true;
         }
 
-        public static async Task<bool> SendUserMsg_blackAirInfo_ToVisaUser(int diId , string[] arr)
+        public static async Task<bool> SendUserMsg_blackAirInfo_ToVisaUser(int diId , List<CountryDataTime> arr)
         {
             Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
 
@@ -1085,6 +1086,7 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice
                 .ToList();
 
             List<string> userIds = new List<string>() { "235" };
+            userIds.AddRange(visaUser.Select(x=>x.ToString()));
             List<string> qwUserIdList = GetQiyeChatUserIdList(userIds);
 
             BlackCodeInfo_ToVisaUser info = new BlackCodeInfo_ToVisaUser()
@@ -1107,6 +1109,38 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice
             return true;
         }
 
+        public static async Task<bool> SendUserMsg_GroupTimeInfo_ToVisaUser(int diId,  string startTime, string endTime)
+        {
+            Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
+
+            var visaUser = _grpDeleRep.Query<Sys_Users>(x => x.IsDel == 0 && x.JobPostId == 26)
+                .Select(x => x.Id)
+                .ToList();
+
+            List<string> userIds = new List<string>() { "235" };
+            userIds.AddRange(visaUser.Select(x => x.ToString()));
+            List<string> qwUserIdList = GetQiyeChatUserIdList(userIds);
+
+            GroupDateTime_ToVisaUser info = new GroupDateTime_ToVisaUser()
+            {
+                RefreshDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
+                TeamName = groupInfo.TeamName,
+                EndTime = endTime,
+                StartTime = startTime,
+            };
+
+            if (qwUserIdList.Count > 0)
+            {
+                ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.GroupDateTime_ToVisaUser(info));
+                if (result.errcode != 0)
+                {
+                    //抄送日志 
+                    return false;
+                }
+            }
+
+            return true;
+        }
 
         #endregion
 

+ 23 - 0
OASystem/OASystem.Domain/Dtos/Groups/AirTicketResDto.cs

@@ -327,4 +327,27 @@ namespace OASystem.Domain.Dtos.Groups
 
     }
 
+    /// <summary>
+    /// 国家出入时间
+    /// </summary>
+    public class CountryDataTime
+    {
+        // 定义属性
+        public string Code { get; set; } = string.Empty;
+        public DateTime StartTime { get; set; } = DateTime.MinValue;
+        public DateTime EndTime { get; set; } = DateTime.MinValue;
+        public string Country { get; set; } = string.Empty;
+
+        // 构造函数(可选)
+        public CountryDataTime() { }
+
+        public CountryDataTime(string code, DateTime startTime, DateTime endTime, string country)
+        {
+            this.Code = code;
+            StartTime = startTime;
+            EndTime = endTime;
+            Country = country;
+        }
+    }
+
 }

+ 28 - 34
OASystem/OASystem.Infrastructure/Repositories/Resource/TicketBlackCodeRepository.cs

@@ -2,6 +2,7 @@
 using EyeSoft.Collections.Generic;
 using EyeSoft.Extensions;
 using OASystem.Domain;
+using OASystem.Domain.Dtos.Groups;
 using OASystem.Domain.Dtos.Resource;
 using OASystem.Domain.Entities.Groups;
 using OASystem.Domain.Entities.Resource;
@@ -240,14 +241,7 @@ namespace OASystem.Infrastructure.Repositories.Resource
                     string[] CodeList = Regex.Split(blackCode.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase)
                         .Where(str => !string.IsNullOrWhiteSpace(str)).ToArray();
 
-                    var threeCodeList = new int[10].Select(x => new
-                    {
-                        code = "",
-                        startTime = DateTime.MinValue,
-                        endTime = DateTime.MinValue,
-                        country = ""
-                    }).ToArray();
-                    
+                    var threeCodeList = new List<CountryDataTime>();
 
                     //读取单条黑屏代码
                     for (int j = 0; j < CodeList.Count(); j++)
@@ -274,55 +268,55 @@ namespace OASystem.Infrastructure.Repositories.Resource
                         {
                             var start = threeCode.Substring(0, 3).ToLower();
                             var end = threeCode.Substring(3, 3).ToLower();
-                            if (!threeCodeList.Select(x => x.code).Contains(end)) {
+                            if (!threeCodeList.Select(x => x.Code).Contains(end)) {
 
-                                var temp = threeCodeList[0] with
+                                var temp = new CountryDataTime
                                 {
-                                    code = end,
-                                    startTime = startTime,
-                                    endTime = endTime,
-                                    country = ""
+                                    Code = end,
+                                    StartTime = startTime,
+                                    EndTime = endTime,
+                                    Country = ""
                                 };
 
-                                for (int i = 0; i < threeCodeList.Length; i++)
-                                {
-                                    if (threeCodeList[i].code.IsNullOrWhiteSpace())
-                                    {
-                                        threeCodeList[i] = temp;
-                                        break;
-                                    }
-                                }
+                                threeCodeList.Add(temp);
                             }
                         }
                     }
 
                     var dbThreeCode = _sqlSugar.Queryable<Res_ThreeCode>()
-                                        .Where(x => x.IsDel == 0 && threeCodeList.Select(x => x.code).Contains(x.Three.ToLower()))
+                                        .Where(x => x.IsDel == 0 && threeCodeList.Select(x => x.Code).Contains(x.Three.ToLower()))
                                         .ToList();
-                    var data = new ArrayList();
+                    var data = new List<CountryDataTime>();
                     var info = new List<string>();
 
                     foreach (var code in dbThreeCode)
                     {
-                        for (int i = 0; i < threeCodeList.Length; i++)
+                        for (int i = 0; i < threeCodeList.Count; i++)
                         {
-                            if (threeCodeList[i].code == code.Three.ToLower()) {
-                                threeCodeList[i] = threeCodeList[i] with
-                                {
-                                     country = code.Country,
-                                };
+                            if (threeCodeList[i].Code == code.Three.ToLower()) {
+                                threeCodeList[i].Country = code.Country;
                                 if (countryArr.Contains(code.Country))
                                 {
-                                    data.Add(threeCodeList[i]);
+                                    var copy = new CountryDataTime
+                                    {
+                                        Code = threeCodeList[i].Code,
+                                        EndTime = threeCodeList[i].EndTime,
+                                        StartTime = threeCodeList[i].StartTime,
+                                        Country = threeCodeList[i].Country,
+                                    };
+
                                     try
                                     {
-                                        info.Add($@"{code.Country} 抵达:{threeCodeList[i].endTime.ToString("yyyy-MM-dd HH:mm")}  离开:{threeCodeList[i + 1].startTime.ToString("yyyy-MM-dd HH:mm")} ");
+                                        threeCodeList[i].StartTime = threeCodeList[i].EndTime;
+                                        threeCodeList[i].EndTime = threeCodeList[i + 1].StartTime;
+                                        info.Add($@"{code.Country} 抵达:{threeCodeList[i].EndTime.ToString("yyyy-MM-dd HH:mm")}  离开:{threeCodeList[i + 1].StartTime.ToString("yyyy-MM-dd HH:mm")} ");
                                     }
                                     catch (Exception)
                                     {
-                                        info.Add($@"{code.Country} 抵达:{threeCodeList[i].endTime.ToString("yyyy-MM-dd HH:mm")}  离开: 未知 ");
+                                        threeCodeList[i] = copy;
+                                        info.Add($@"{code.Country} 抵达:{threeCodeList[i].EndTime.ToString("yyyy-MM-dd HH:mm")}  离开: 未知 ");
                                     }
-                                   
+                                    data.Add(threeCodeList[i]);
                                 }
                                 break;
                             }