|
@@ -1,4 +1,5 @@
|
|
|
-using OASystem.Domain.Dtos.QiYeWeChat;
|
|
|
+using EyeSoft.Extensions;
|
|
|
+using OASystem.Domain.Dtos.QiYeWeChat;
|
|
|
using OASystem.Domain.ViewModels.QiYeWeChat;
|
|
|
using System.Diagnostics;
|
|
|
using System.Text.Json;
|
|
@@ -669,6 +670,125 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
|
|
|
return checkInView;
|
|
|
}
|
|
|
|
|
|
+ public async Task<object> QueryAssessmentByUser(DateTime startDt, DateTime endDt, List<string> qiyeUidList)
|
|
|
+ {
|
|
|
+ AssessmentByUserListView assessmentByUserListView = new AssessmentByUserListView();
|
|
|
+ List<AssessmentByUserView> AssessmentByUserView = new List<AssessmentByUserView>();
|
|
|
+ assessmentByUserListView.Data = AssessmentByUserView;
|
|
|
+ assessmentByUserListView.errcode = 0;
|
|
|
+ assessmentByUserListView.errmsg = "成功";
|
|
|
+
|
|
|
+ CheckInView? checkInView = new CheckInView();
|
|
|
+
|
|
|
+ //获取打卡数据 token
|
|
|
+ Access_TokenView access_Token = await GetTokenAsync(2);
|
|
|
+ if (access_Token.errcode != 0)
|
|
|
+ {
|
|
|
+ assessmentByUserListView.errcode = access_Token.errcode;
|
|
|
+ assessmentByUserListView.errmsg = string.Format("【企业微信】【获取月打卡数据】【Token】【Msg】{0}", access_Token.errmsg);
|
|
|
+ return assessmentByUserListView;
|
|
|
+ }
|
|
|
+
|
|
|
+ string url = string.Format("/cgi-bin/checkin/getcheckin_monthdata?access_token={0}", access_Token.access_token);
|
|
|
+
|
|
|
+ Checkin_MonthData_Request checkInReq = new Checkin_MonthData_Request();
|
|
|
+ checkInReq.access_token = access_Token.access_token;
|
|
|
+
|
|
|
+ checkInReq.starttime = (uint)(startDt - _1970).TotalSeconds;
|
|
|
+ checkInReq.endtime = (uint)(endDt - _1970).TotalSeconds;
|
|
|
+ checkInReq.useridlist = qiyeUidList;
|
|
|
+
|
|
|
+ var json = System.Text.Json.JsonSerializer.Serialize(checkInReq);
|
|
|
+ var content = new StringContent(json, Encoding.UTF8, "application/json");
|
|
|
+ var create_Req = await _httpClient.PostAsync(url, content);
|
|
|
+ var stringResponse = await create_Req.Content.ReadAsStringAsync();
|
|
|
+
|
|
|
+ checkInView = System.Text.Json.JsonSerializer.Deserialize<CheckInView>(stringResponse,
|
|
|
+ new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase });
|
|
|
+
|
|
|
+ if (checkInView == null)
|
|
|
+ {
|
|
|
+ assessmentByUserListView.errcode = -1;
|
|
|
+ assessmentByUserListView.errmsg = "checkInView Deserialize Error";
|
|
|
+ return assessmentByUserListView;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (checkInView.errcode != 0)
|
|
|
+ {
|
|
|
+ assessmentByUserListView.errcode = checkInView.errcode;
|
|
|
+ assessmentByUserListView.errmsg = checkInView.errmsg;
|
|
|
+ return assessmentByUserListView;
|
|
|
+ }
|
|
|
+
|
|
|
+ var errorUserList = new List<string>();
|
|
|
+
|
|
|
+ //遍历用户数据
|
|
|
+ foreach (var item in checkInView.datas)
|
|
|
+ {
|
|
|
+
|
|
|
+ //有异常状态的情况下获取具体异常信息
|
|
|
+ if (item.summary_info.except_days > 0)
|
|
|
+ {
|
|
|
+ errorUserList.Add(item.base_info.acctid);
|
|
|
+ }
|
|
|
+
|
|
|
+ assessmentByUserListView.Data.Add(new Domain.ViewModels.QiYeWeChat.AssessmentByUserView
|
|
|
+ {
|
|
|
+ Accid = item.base_info.acctid,
|
|
|
+ Except_days = item.summary_info.except_days,
|
|
|
+ Name = item.base_info.name,
|
|
|
+ Regular_days = item.summary_info.regular_days,
|
|
|
+ Exception_info_List = new List<Exception_info>(),
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ if (errorUserList.Count > 0) {
|
|
|
+
|
|
|
+ var dayInfo = await GetCheckinDataAsync(errorUserList, 3, startDt, endDt);
|
|
|
+
|
|
|
+ if (dayInfo.errcode != 0)
|
|
|
+ {
|
|
|
+ assessmentByUserListView.errcode = dayInfo.errcode;
|
|
|
+ assessmentByUserListView.errmsg = dayInfo.errmsg;
|
|
|
+ assessmentByUserListView.Data = new List<AssessmentByUserView>();
|
|
|
+ return assessmentByUserListView;
|
|
|
+ }
|
|
|
+
|
|
|
+ var dic = new Dictionary<ErrorType, List<string>>()
|
|
|
+ {
|
|
|
+ { ErrorType.迟到 , new List<string>{ "时间异常" } },
|
|
|
+ { ErrorType.缺卡 , new List<string>{ "未打卡" } },
|
|
|
+ };
|
|
|
+
|
|
|
+ foreach (var item in dayInfo.checkindata)
|
|
|
+ {
|
|
|
+ foreach (var user in assessmentByUserListView.Data)
|
|
|
+ {
|
|
|
+ if (user.Accid == item.userid)
|
|
|
+ {
|
|
|
+ //遍历异常信息
|
|
|
+ if (!item.exception_type.IsNullOrWhiteSpace())
|
|
|
+ {
|
|
|
+ var linqFind = dic.First(x => x.Value.Contains(item.exception_type));
|
|
|
+
|
|
|
+ var errinfo = new Exception_info
|
|
|
+ {
|
|
|
+ Date = item.checkin_time_dt,
|
|
|
+ Type = linqFind.Key,
|
|
|
+ Info = item.exception_type
|
|
|
+ };
|
|
|
+
|
|
|
+ user.Exception_info_List.Add(errinfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return assessmentByUserListView;
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 获取打卡记录数据
|
|
|
/// </summary>
|
|
@@ -1561,6 +1681,6 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
|
|
|
return (dt.ToUniversalTime().Ticks - 621355968000000000) / 10000000;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|