Browse Source

企业微信Api-自动发送团组提醒信息

jiangjc 10 months ago
parent
commit
dab5a960a9

+ 3 - 9
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -65,6 +65,7 @@ using static NPOI.POIFS.Crypt.CryptoFunctions;
 using Aspose.Words.Lists;
 using OASystem.API.OAMethodLib.YouDaoAPI;
 using NPOI.XSSF.Streaming.Values;
+using OASystem.API.OAMethodLib.Quartz.Business;
 
 namespace OASystem.API.Controllers
 {
@@ -10912,16 +10913,9 @@ namespace OASystem.API.Controllers
         /// <returns></returns>
         [HttpPost]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> ChangeDataBase_Offi(PostTourClientListDownloadFile _dto)
+        public async Task<IActionResult> Test_SendMsg(PostTourClientListDownloadFile _dto)
         {
-            _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
-
-            string sqlOld = string.Format(@" Select * From AirTicketReservations With(nolock) ");
-
-            List<oa2021_AirTicketReservations> listOld = _airTicketResRep._sqlSugar.SqlQueryable<oa2021_AirTicketReservations>(sqlOld).ToList();
-
-
-            _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
+            DeleReminderMessage.PostMessageByWebhook();
 
             return Ok(JsonView(true, "操作成功!"));
         }

+ 3 - 3
OASystem/OASystem.Api/OAMethodLib/QiYeWeChatAPI/QiYeWeChatApiService.cs

@@ -1298,17 +1298,17 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
         public async Task<ResponseBase> RobotSendMsg_GroupInfo(string msg)
         {
             string key = "b4fe152f-a97a-48b1-830f-ab447f6d2f5f";
-            string url = string.Format("/webhook/send?key={0}", key);
+            string url = string.Format("/cgi-bin/webhook/send?key={0}", key);
 
             RobotSendMsg_GroupInfo_Content contentStr = new RobotSendMsg_GroupInfo_Content() { content = msg };
 
-            RobotSendMsg_GroupInfo reqJson = new RobotSendMsg_GroupInfo()
+            RobotSendMsg_GroupInfo_Param reqJson = new RobotSendMsg_GroupInfo_Param()
             {
                 msgtype = "markdown",
                 markdown = contentStr
             };
 
-            var json = System.Text.Json.JsonSerializer.Serialize(RobotSendMsg_GroupInfo);
+            var json = System.Text.Json.JsonSerializer.Serialize(reqJson);
             var content = new StringContent(json, Encoding.UTF8, "application/json");
             var create_Req = await _httpClient.PostAsync(url, content);
             var stringResponse = await create_Req.Content.ReadAsStringAsync();

+ 12 - 7
OASystem/OASystem.Api/OAMethodLib/Quartz/Business/DeleReminderMessage.cs

@@ -1,4 +1,5 @@
 using OASystem.API.OAMethodLib.ALiYun;
+using OASystem.API.OAMethodLib.QiYeWeChatAPI;
 using OASystem.Domain.Dtos.Business;
 using OASystem.Domain.Entities.Business;
 using OASystem.Domain.Entities.Groups;
@@ -12,6 +13,7 @@ namespace OASystem.API.OAMethodLib.Quartz.Business
     public static class DeleReminderMessage
     {
         private readonly static DelegationInfoRepository _grpDeleRep = AutofacIocManager.Instance.GetService<DelegationInfoRepository>();
+        private static readonly IQiYeWeChatApiService _qiYeWeChatApiService = AutofacIocManager.Instance.GetService<IQiYeWeChatApiService>();
 
         /// <summary>
         /// 检查团组结束日期,将当天和2天后的团组整理并发送短信提醒
@@ -100,24 +102,27 @@ namespace OASystem.API.OAMethodLib.Quartz.Business
                 List<Grp_DelegationInfo> listAdd7day = list_source.Where(s => s.VisitStartDate.Equals(add7day)).ToList();
                 List<Grp_DelegationInfo> listAdd2day = list_source.Where(s => s.VisitEndDate.Equals(add2day)).ToList();
                 string dayStr = dtNow.ToString("yyyy年MM月dd日");
-                string content = string.Format(@" 今天是{0},\n ");
+                string content = string.Format(@" 今天是{0},\n ", dayStr);
 
                 if (listAdd7day.Count > 0)
                 {
-                    
-                    string tempStr1 = string.Format(@" 检查到7天后开始的团组数量: <font color='warning'>{1}</font>\n ", dayStr,listAdd7day.Count);
-                    listAdd7day.ForEach(s => tempStr1 += string.Format(@"> {0}", s.TeamName));
+
+                    string tempStr1 = string.Format(@" \n\n检查到7天后开始的团组数量: <font color='warning'>** {1} **</font>\n ", dayStr, listAdd7day.Count);
+                    listAdd7day.ForEach(s => tempStr1 += string.Format(@">{0} \n", s.TeamName));
                     content += tempStr1;
                 }
 
                 if (listAdd2day.Count > 0)
                 {
-                    string tempStr2 = string.Format(@" 检查到3天后结束的团组数量: <font color='warning'>{1}</font>\n ", dayStr, listAdd2day.Count);
-                    listAdd7day.ForEach(s => tempStr2 += string.Format(@"> {0}", s.TeamName));
+                    string tempStr2 = string.Format(@" \n\n检查到3天后结束的团组数量: <font color='info'>** {1} **</font>\n ", dayStr, listAdd2day.Count);
+                    listAdd7day.ForEach(s => tempStr2 += string.Format(@">{0} \n", s.TeamName));
                     content += tempStr2;
                 }
 
-                content += string.Format(@"");
+                content += string.Format(@"\n\n请注检查合同、款项等信息");
+
+
+                OASystem.Domain.ViewModels.QiYeWeChat.ResponseBase result = await _qiYeWeChatApiService.RobotSendMsg_GroupInfo(content);
             }
         }
     }

+ 1 - 1
OASystem/OASystem.Domain/Dtos/QiYeWeChat/ApprovalData_Request.cs

@@ -108,7 +108,7 @@ namespace OASystem.Domain.Dtos.QiYeWeChat
 
     }
 
-    public class RobotSendMsg_GroupInfo
+    public class RobotSendMsg_GroupInfo_Param
     {
         public string msgtype { get; set; } = "markdown";