2 Achegas 9c3ffebaf1 ... e2f37761e3

Autor SHA1 Mensaxe Data
  yuanrf e2f37761e3 Merge branch 'develop' of http://132.232.92.186:3000/XinXiBu/OA2023 into develop hai 16 horas
  yuanrf bcc3a6bdb2 市场部ai绩效分析添加,移动端商邀任务Api添加 hai 16 horas

+ 74 - 0
OASystem/OASystem.Api/Controllers/PersonnelModuleController.cs

@@ -3108,5 +3108,79 @@ OPTION (MAXRECURSION 0); -- 允许无限递归      ";
         //}
 
         #endregion
+
+        #region Ai绩效分析
+
+        [HttpGet]
+        public async Task<IActionResult> AiPerformanceAnalysis_JobMarketingAsync(int userId, DateTime start, DateTime end)
+        {
+            var jw = JsonView(false);
+
+            var user_entity = _sqlSugar.Queryable<Sys_Users>()
+                              .First(e => e.Id == userId && e.IsDel == 0);
+
+            if (user_entity == null)
+            {
+                jw.Msg = "用户不存在!";
+                return Ok(jw);
+            }
+
+            List<string> useridlist = new List<string> { user_entity.QiyeChatUserId };
+
+            //获取企微外出打卡信息
+            var checkin_data = await _qiYeWeChatApiService.GetCheckinDataAsync(useridlist, 2, start, end);
+            if (checkin_data.errcode != 0)
+            {
+                jw.Msg = "获取企微外出打卡信息失败!" + checkin_data.errmsg;
+                return Ok(jw);
+            }
+
+            //获取企微外出申请信息
+            var approval_data = await _qiYeWeChatApiService.GetApprovalInfoUpdateAsync(start, end, newCursor: "", size: 100, filters: new List<IQiYeWeChatApiService.FilterCondition>(){
+                 new
+                  IQiYeWeChatApiService.FilterCondition{
+                     key = "creator",
+                     value = user_entity.QiyeChatUserId
+                  },
+                  new IQiYeWeChatApiService.FilterCondition{
+                    key="record_type",
+                    value="4"
+                  }
+            });
+            if (approval_data.errcode != 0)
+            {
+                jw.Msg = "获取企微外出申请信息失败!" + approval_data.errmsg;
+                return Ok(jw);
+            }
+
+            List<ApprovalDetailView> detailViews = new List<ApprovalDetailView>();
+            foreach (var item in approval_data.sp_no_list)
+            {
+                var approval_detail = await _qiYeWeChatApiService.GetApprovalDetailAsync(item);
+                if (approval_detail.errcode != 0)
+                {
+                    jw.Msg = "获取企微外出申请详情失败!" + approval_detail.errmsg;
+                    return Ok(jw);
+                }
+                detailViews.Add(approval_detail);
+            }
+
+            jw.Data = new
+            {
+                checkin_data = checkin_data.checkindata,
+                approval_data = approval_data.sp_no_list,
+                detailViews = detailViews
+            };
+
+            jw.Code = 200;
+            jw.Msg = "查询成功!";
+
+            return Ok(jw);
+        }
+
+
+
+        #endregion
+
     }
 }

+ 29 - 0
OASystem/OASystem.Api/OAMethodLib/QiYeWeChatAPI/IQiYeWeChatApiService.cs

@@ -134,6 +134,13 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
         ///// <returns></returns>
         //Task<ApprovalInfoView> GetApprovalInfoAsync(DateTime startDt, DateTime endDt, int record_type);
 
+        Task<ApprovalInfoView> GetApprovalInfoUpdateAsync(
+        DateTime startTime,
+        DateTime endTime,
+        string newCursor,
+        int size,
+        List<FilterCondition> filters);
+
         //// <summary>
         /// 批量获取审批详情
         /// <param name="startDt"></param>
@@ -210,5 +217,27 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
         /// <returns></returns>
         Task<GroupStatus_SendMessageView> GroupStatus_SendMessage_ToUser_Markdown(List<string> toUser, string msgContent, string msgType = "markdown");
         #endregion
+
+        /// <summary>
+        /// 筛选条件
+        /// </summary>
+        public class FilterCondition
+        {
+            /// <summary>
+            /// 筛选类型
+            /// template_id - 模板类型/模板id
+            /// creator - 申请人
+            /// department - 审批单提单者所在部门
+            /// sp_status - 审批状态
+            /// record_type - 审批单类型属性
+            /// </summary>
+            public string key { get; set; }
+
+            /// <summary>
+            /// 筛选值
+            /// </summary>
+            public string value { get; set; }
+        }
+
     }
 }

+ 47 - 5
OASystem/OASystem.Api/OAMethodLib/QiYeWeChatAPI/QiYeWeChatApiService.cs

@@ -674,9 +674,9 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
         public async Task<object> QueryAssessmentByUser(DateTime startDt, DateTime endDt, List<string> qiyeUidList)
         {
             AssessmentByUserListView assessmentByUserListView = new AssessmentByUserListView();
-            List<AssessmentByUserView> AssessmentByUserView = new  List<AssessmentByUserView>();
+            List<AssessmentByUserView> AssessmentByUserView = new List<AssessmentByUserView>();
             assessmentByUserListView.Data = AssessmentByUserView;
-            assessmentByUserListView.errcode = 0;  
+            assessmentByUserListView.errcode = 0;
             assessmentByUserListView.errmsg = "成功";
 
             CheckInView? checkInView = new CheckInView();
@@ -744,7 +744,8 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
                 });
             }
 
-            if (errorUserList.Count > 0) {
+            if (errorUserList.Count > 0)
+            {
 
                 var dayInfo = await GetCheckinDataAsync(errorUserList, 3, startDt, endDt);
 
@@ -773,7 +774,7 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
                             {
                                 var linqFind = dic.First(x => x.Value.Contains(item.exception_type));
 
-                                var errinfo =  new Exception_info
+                                var errinfo = new Exception_info
                                 {
                                     Date = item.checkin_time_dt,
                                     Type = linqFind.Key,
@@ -1338,6 +1339,47 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
             return approvalInfoView;
         }
 
+        public async Task<ApprovalInfoView> GetApprovalInfoUpdateAsync(
+        DateTime startTime,
+        DateTime endTime,
+        string newCursor = "",
+        int size = 100,
+        List<IQiYeWeChatApiService.FilterCondition> filters = null)
+        {
+
+            long starttime = (long)(startTime - _1970).TotalSeconds;
+            long endtime = (long)(endTime - _1970).TotalSeconds;
+            var requestData = new
+            {
+                starttime = starttime,
+                endtime = endtime,
+                new_cursor = newCursor,
+                size = size,
+                filters = filters ?? new List<IQiYeWeChatApiService.FilterCondition>()
+            };
+
+            string jsonContent = JsonConvert.SerializeObject(requestData);
+            var httpContent = new StringContent(jsonContent, Encoding.UTF8, "application/json");
+            var token = await GetTokenAsync(5);
+
+            try
+            {
+                string url = "/cgi-bin/oa/getapprovalinfo?access_token=" + token.access_token;
+                HttpResponseMessage response = await _httpClient.PostAsync(url, httpContent);
+                response.EnsureSuccessStatusCode();
+                string responseContent = await response.Content.ReadAsStringAsync();
+                var result = JsonConvert.DeserializeObject<ApprovalInfoView>(responseContent);
+                return result;
+            }
+            catch (Exception ex)
+            {
+                ApprovalInfoView approvalInfoView = new ApprovalInfoView();
+                approvalInfoView.errcode = -1;
+                approvalInfoView.errmsg = ex.Message;
+                return approvalInfoView;
+            }
+        }
+
         /// <summary>
         /// 获取审批申请详情
         /// </summary>
@@ -1683,6 +1725,6 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
             return (dt.ToUniversalTime().Ticks - 621355968000000000) / 10000000;
         }
 
-       
+
     }
 }