Bladeren bron

新增企微通知

jiangjc 6 maanden geleden
bovenliggende
commit
8680b54e3a

+ 5 - 2
OASystem/OASystem.Api/Controllers/PersonnelModuleController.cs

@@ -1734,8 +1734,8 @@ namespace OASystem.API.Controllers
             //推送消息(模板)
 
             //List<string> userList = new List<string>() { "Feint", "huaju.liu", "johnny.yang@pan-american-intl.com" };
-            List<string> userList = new List<string>() { "Feint", "johnny.yang@pan-american-intl.com" };
-            GroupStatus_CreateChatView rst1 = await _qiYeWeChatApiService.GroupStatus_CreateChat("团组费用提示", "Feint", userList, "GuoJiaoChat01");
+            //List<string> userList = new List<string>() { "Feint", "johnny.yang@pan-american-intl.com" };
+            //GroupStatus_CreateChatView rst1 = await _qiYeWeChatApiService.GroupStatus_CreateChat("团组费用提示", "Feint", userList, "GuoJiaoChat01");
 
             //团组出发
             //AppNoticeLibrary.SendUserMsg_GroupStatus_Create(2358, userList);
@@ -1767,6 +1767,9 @@ namespace OASystem.API.Controllers
 
             string q = "";
 
+            DeleReminderMessage.PostMessageByWebhook_CRMStatistics();
+
+
             return Ok(JsonView(true, "操作成功!"));
         }
 

+ 56 - 0
OASystem/OASystem.Api/OAMethodLib/QiYeWeChatAPI/AppNotice/Config.cs

@@ -1,5 +1,6 @@
 using MathNet.Numerics.Statistics;
 using OASystem.Domain.Entities.Groups;
+using OASystem.Domain.ViewModels.CRM;
 using System.ComponentModel;
 
 namespace OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice
@@ -411,6 +412,61 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice
 
             return result;
         }
+
+        /// <summary>
+        /// CRM统计通知(周)
+        /// </summary>
+        /// <param name="info"></param>
+        /// <returns></returns>
+        public static string CRMStatistics_ToUser(List<CRMWeekStatisticsView> list, string beginDt, string endDt)
+        {
+            string users = "暂无";
+            if (list.Count > 0)
+            {
+                users = "";
+                foreach (var item in list)
+                {
+                    users += ">【" + item.UserName + "】 - 新增 " + item.InsertNum + " 条,删除 " + item.DeleteNum + " 条\n\n";
+                }
+            }
+
+
+            string result = string.Format(@" `市场客户资料周统计({0} - {1})`  
+
+{2}
+
+[详细信息请前往OA系统查看](http://oa.pan-american-intl.com:4399/)  ", beginDt, endDt, users);
+
+            return result;
+        }
+
+        /// <summary>
+        /// CRM统计通知(月)
+        /// </summary>
+        /// <param name="info"></param>
+        /// <returns></returns>
+        public static string CRMStatistics_Month_ToUser(List<CRMWeekStatisticsView> list, string beginDt, string endDt,int totalInsert, int totalDelete)
+        {
+            string users = "暂无";
+            if (list.Count > 0)
+            {
+                users = "";
+                foreach (var item in list)
+                {
+                    users += ">【" + item.UserName + "】 - 新增 " + item.InsertNum + " 条,删除 " + item.DeleteNum + " 条\n\n";
+                }
+            }
+
+
+            string result = string.Format(@" `市场客户资料月统计({0} - {1})`  
+> 总共 - 新增 <font color='info'>{3}</font> 条,删除 <font color='warning'> {4}</font> 条
+
+{2}
+
+[详细信息请前往OA系统查看](http://oa.pan-american-intl.com:4399/)  ", beginDt, endDt, users, totalInsert, totalDelete);
+
+            return result;
+        }
     }
 
 

+ 55 - 0
OASystem/OASystem.Api/OAMethodLib/QiYeWeChatAPI/AppNotice/Library.cs

@@ -2,6 +2,7 @@
 using NPOI.SS.Formula.Functions;
 using OASystem.Domain.Entities.Financial;
 using OASystem.Domain.Entities.Groups;
+using OASystem.Domain.ViewModels.CRM;
 using OASystem.Domain.ViewModels.Groups;
 using OASystem.Domain.ViewModels.QiYeWeChat;
 using OASystem.Infrastructure.Repositories.Groups;
@@ -648,6 +649,60 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice
 
         #endregion
 
+        #region 市场部新增客户资源统计
+
+        /// <summary>
+        /// 周统计
+        /// </summary>
+        /// <param name="sourceList"></param>
+        /// <param name="userId"></param>
+        /// <param name="begin"></param>
+        /// <param name="end"></param>
+        /// <returns></returns>
+        public static async Task<bool> SendUserMsg_CRMStatistics_ToHR(List<CRMWeekStatisticsView> sourceList, List<string> userId, string begin, string end)
+        {
+            //发送信息
+            List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
+            if (qwUserIdList.Count > 0)
+            {
+                ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.CRMStatistics_ToUser(sourceList, begin, end));
+
+                if (result.errcode != 0)
+                {
+                    //抄送日志 
+                    return false;
+                }
+            }
+            return true;
+        }
+
+        /// <summary>
+        /// 月统计
+        /// </summary>
+        /// <param name="sourceList"></param>
+        /// <param name="userId"></param>
+        /// <param name="begin"></param>
+        /// <param name="end"></param>
+        /// <returns></returns>
+        public static async Task<bool> SendUserMsg_CRMStatistics_Month_ToHR(List<CRMWeekStatisticsView> sourceList, List<string> userId, string begin, string end, int totalInsert,int totalDelete)
+        {
+            //发送信息
+            List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
+            if (qwUserIdList.Count > 0)
+            {
+                ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, MarkdownLib.CRMStatistics_Month_ToUser(sourceList, begin, end, totalInsert, totalDelete));
+
+                if (result.errcode != 0)
+                {
+                    //抄送日志 
+                    return false;
+                }
+            }
+            return true;
+        }
+
+        #endregion
+
         #region 日付申请审核
 
         /// <summary>

+ 84 - 0
OASystem/OASystem.Api/OAMethodLib/Quartz/Business/DeleReminderMessage.cs

@@ -3,8 +3,10 @@ using OASystem.API.OAMethodLib.QiYeWeChatAPI;
 using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
 using OASystem.Domain.Dtos.Business;
 using OASystem.Domain.Entities.Business;
+using OASystem.Domain.Entities.Customer;
 using OASystem.Domain.Entities.Groups;
 using OASystem.Domain.Entities.PersonnelModule;
+using OASystem.Domain.ViewModels.CRM;
 using OASystem.Domain.ViewModels.Groups;
 using OASystem.Infrastructure.Repositories.Groups;
 using OASystem.Infrastructure.Repositories.PersonnelModule;
@@ -115,5 +117,87 @@ namespace OASystem.API.OAMethodLib.Quartz.Business
             await AppNoticeLibrary.SendChatMsg_GroupRemindersToGuojiao(listAdd3day, QiyeWeChatEnum.GuoJiaoChat01);
 
         }
+
+        public static async void PostMessageByWebhook_CRMStatistics()
+        {
+            DateTime dtNow = DateTime.Now;
+            if (dtNow.DayOfWeek == DayOfWeek.Monday)
+            {
+
+                string dt_1day = dtNow.AddDays(-1).ToString("yyyy-MM-dd");
+                string dt_7day = dtNow.AddDays(-7).ToString("yyyy-MM-dd");
+
+                string sql_users = string.Format(@" Select * From Sys_Users with(Nolock) where IsDel = 0 And DepId = 6 And Id Not In (321) ");
+                List<Sys_Users> userList = _grpDeleRep._sqlSugar.SqlQueryable<Sys_Users>(sql_users).ToList();
+
+                List<CRMWeekStatisticsView> source = new List<CRMWeekStatisticsView>();
+                int total_insert = 0;
+                int total_delete = 0;
+
+                foreach (var u in userList)
+                {
+                    string sql_temp1 = string.Format(@" Select * From Crm_NewClientData With(Nolock) where CreateUserId = {0} And CreateTime Between '{1} 00:00:00' And '{2} 23:59:59' ", u.Id, dt_7day, dt_1day);
+                    List<Crm_NewClientData> crmList = _grpDeleRep._sqlSugar.SqlQueryable<Crm_NewClientData>(sql_temp1).ToList();
+
+                    int iNum = crmList.Where(s => s.IsDel == 0).Count();
+                    int dNum = crmList.Where(s => s.IsDel == 1).Count();
+                    string userName = u.CnName;
+
+                    total_insert += iNum;
+                    total_delete += dNum;
+
+                    CRMWeekStatisticsView sourceItem = new CRMWeekStatisticsView()
+                    {
+                        DeleteNum = dNum,
+                        InsertNum = iNum,
+                        UserName = userName
+                    };
+
+                    source.Add(sourceItem);
+                }
+                List<string> temp = new List<string>() { "234", "309" };
+                await AppNoticeLibrary.SendUserMsg_CRMStatistics_ToHR(source, temp, dt_7day, dt_1day);
+            }
+
+            if (dtNow.Day == 1)
+            {
+                string dt_last = dtNow.AddDays(-1).ToString("yyyy-MM-dd");
+                string dt_first = dtNow.AddDays(-1).ToString("yyyy-MM-01");
+
+                string sql_users = string.Format(@" Select * From Sys_Users with(Nolock) where IsDel = 0 And DepId = 6 And Id Not In (321) ");
+                List<Sys_Users> userList = _grpDeleRep._sqlSugar.SqlQueryable<Sys_Users>(sql_users).ToList();
+
+                List<CRMWeekStatisticsView> source = new List<CRMWeekStatisticsView>();
+                int total_insert = 0;
+                int total_delete = 0;
+
+                foreach (var u in userList)
+                {
+                    string sql_temp1 = string.Format(@" Select * From Crm_NewClientData With(Nolock) where CreateUserId = {0} And CreateTime Between '{1} 00:00:00' And '{2} 23:59:59' ", u.Id, dt_first, dt_last);
+                    List<Crm_NewClientData> crmList = _grpDeleRep._sqlSugar.SqlQueryable<Crm_NewClientData>(sql_temp1).ToList();
+
+                    int iNum = crmList.Where(s => s.IsDel == 0).Count();
+                    int dNum = crmList.Where(s => s.IsDel == 1).Count();
+                    string userName = u.CnName;
+
+                    total_insert += iNum;
+                    total_delete += dNum;
+
+                    CRMWeekStatisticsView sourceItem = new CRMWeekStatisticsView()
+                    {
+                        DeleteNum = dNum,
+                        InsertNum = iNum,
+                        UserName = userName
+                    };
+
+                    source.Add(sourceItem);
+                }
+                List<string> temp = new List<string>() { "234", "309" };
+                await AppNoticeLibrary.SendUserMsg_CRMStatistics_Month_ToHR(source, temp, dt_first, dt_last, total_insert, total_delete);
+            }
+
+        }
     }
 }
+
+

+ 13 - 5
OASystem/OASystem.Domain/ViewModels/CRM/NewClientDataView.cs

@@ -163,7 +163,7 @@ namespace OASystem.Domain.ViewModels.CRM
 
     }
 
-    public class NewClientDataView:Crm_NewClientData
+    public class NewClientDataView : Crm_NewClientData
     {
         /// <summary>
         /// 总条数
@@ -180,8 +180,8 @@ namespace OASystem.Domain.ViewModels.CRM
         public string CategoryStr { get; set; }
 
         /// <summary>
-         /// 地市州Id
-         /// </summary>
+        /// 地市州Id
+        /// </summary>
         public string LvlidStr { get; set; }
 
         /// <summary>
@@ -192,12 +192,12 @@ namespace OASystem.Domain.ViewModels.CRM
         /// <summary>
         /// 归属部门
         /// </summary>
-        public dynamic AscribedDepartment {get; set; }
+        public dynamic AscribedDepartment { get; set; }
     }
     /// <summary>
     ///归属人员
     /// </summary>
-    public class AscribedUser 
+    public class AscribedUser
     {
         /// <summary>
         /// 人员Id
@@ -228,4 +228,12 @@ namespace OASystem.Domain.ViewModels.CRM
 
         public int NewClientDataId { get; set; }
     }
+
+    public class CRMWeekStatisticsView
+    {
+        public string UserName { get; set; }
+        public int InsertNum { get; set; }
+        public int DeleteNum { get; set; }
+    }
+
 }