|
@@ -301,6 +301,61 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
|
|
|
{
|
|
|
CheckInView checkInView = new CheckInView();
|
|
|
|
|
|
+
|
|
|
+ UserIdListView userIdListView = await GetUserIdListAsync();
|
|
|
+ if (userIdListView.errcode != 0)
|
|
|
+ {
|
|
|
+ checkInView.errcode = userIdListView.errcode;
|
|
|
+ checkInView.errmsg = string.Format("【企业微信】【获取员工IdList】【Msg】{0}",userIdListView.errmsg);
|
|
|
+ return checkInView;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (userIdListView.dept_user == null || userIdListView.dept_user.Count <= 0)
|
|
|
+ {
|
|
|
+ checkInView.errmsg = string.Format("【企业微信】【获取员工IdList】【Msg】未查出员工Id");
|
|
|
+ return checkInView;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Access_TokenView access_Token = await GetTokenAsync(2);
|
|
|
+ if (access_Token.errcode != 0)
|
|
|
+ {
|
|
|
+ checkInView.errcode = access_Token.errcode;
|
|
|
+ checkInView.errmsg = string.Format("【企业微信】【获取月打卡数据】【Token】【Msg】{0}", access_Token.errmsg);
|
|
|
+ return checkInView;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 = userIdListView.dept_user.Select(it => it.userid).ToList();
|
|
|
+
|
|
|
+ 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 });
|
|
|
+
|
|
|
+
|
|
|
+ return checkInView;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public async Task<CheckInView> GetCheckin_MonthDataRedisAsync(DateTime startDt, DateTime endDt)
|
|
|
+ {
|
|
|
+ CheckInView checkInView = new CheckInView();
|
|
|
+
|
|
|
string checkInDatastring = await RedisRepository.RedisFactory
|
|
|
.CreateRedisRepository()
|
|
|
.StringGetAsync<string>("Checkin_MonthData");
|
|
@@ -318,7 +373,7 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
|
|
|
if (userIdListView.errcode != 0)
|
|
|
{
|
|
|
checkInView.errcode = userIdListView.errcode;
|
|
|
- checkInView.errmsg = string.Format("【企业微信】【获取员工IdList】【Msg】{0}",userIdListView.errmsg);
|
|
|
+ checkInView.errmsg = string.Format("【企业微信】【获取员工IdList】【Msg】{0}", userIdListView.errmsg);
|
|
|
return checkInView;
|
|
|
}
|
|
|
|
|
@@ -341,7 +396,7 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
|
|
|
|
|
|
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 = userIdListView.dept_user.Select(it => it.userid).ToList();
|
|
@@ -363,7 +418,7 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
|
|
|
.CreateRedisRepository()
|
|
|
.StringSetAsync<string>("Checkin_MonthData", JsonConvert.SerializeObject(checkInView), ts);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
return checkInView;
|
|
|
}
|
|
@@ -442,6 +497,43 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
|
|
|
return approvalDataView;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public async Task<List<Sp_Info>> GetApprovalDatasAsync(DateTime startDt, DateTime endDt)
|
|
|
+ {
|
|
|
+ List<Sp_Info> sp_Infos = new List<Sp_Info>();
|
|
|
+
|
|
|
+
|
|
|
+ DateTime sp_startDt = startDt.AddDays(-10);
|
|
|
+ DateTime sp_centerDt = sp_startDt.AddDays(30);
|
|
|
+ DateTime sp_endDt = endDt.AddDays(10);
|
|
|
+
|
|
|
+ ApprovalDataView approvalData_1 = await GetApprovalDataAsync(sp_startDt, sp_centerDt);
|
|
|
+ ApprovalDataView approvalData_2 = await GetApprovalDataAsync(sp_centerDt, sp_endDt);
|
|
|
+ if (approvalData_1.errcode != 0)
|
|
|
+ {
|
|
|
+ Log.Error("企业微信 获取 " + sp_startDt + " - " + sp_centerDt + " 内审批 Msg:" + approvalData_1.errmsg);
|
|
|
+
|
|
|
+ return sp_Infos;
|
|
|
+ }
|
|
|
+ sp_Infos.AddRange(approvalData_1.data);
|
|
|
+ if (approvalData_2.errcode != 0)
|
|
|
+ {
|
|
|
+ Log.Error("企业微信 获取 " + sp_centerDt + " - " + sp_endDt + " 内审批 Msg:" + approvalData_2.errmsg);
|
|
|
+
|
|
|
+ return sp_Infos;
|
|
|
+ }
|
|
|
+ sp_Infos.AddRange(approvalData_2.data);
|
|
|
+
|
|
|
+ sp_Infos = sp_Infos.Where(it => it.sp_status == 2).ToList();
|
|
|
+
|
|
|
+
|
|
|
+ return sp_Infos;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
@@ -449,7 +541,7 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
|
|
|
|
|
|
|
|
|
|
|
|
- public async Task<List<Sp_Info>> GetApprovalDataRedisAsync(DateTime startDt, DateTime endDt)
|
|
|
+ public async Task<List<Sp_Info>> GetApprovalDatasRedisAsync(DateTime startDt, DateTime endDt)
|
|
|
{
|
|
|
List<Sp_Info> sp_Infos = new List<Sp_Info>();
|
|
|
|
|
@@ -459,10 +551,15 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
|
|
|
DateTime sp_endDt = endDt.AddDays(10);
|
|
|
|
|
|
|
|
|
- string redisName = "ApprovalData_" + sp_startDt.Year + "_" + sp_startDt.Month;
|
|
|
- string sp_InfosString = await RedisRepository.RedisFactory
|
|
|
- .CreateRedisRepository()
|
|
|
- .StringGetAsync<string>(redisName);
|
|
|
+ string redisName = "ApprovalData" + sp_startDt.ToString("yyyyMMdd") + "-" + sp_endDt.ToString("yyyyMMdd");
|
|
|
+ string sp_InfosString = string.Empty;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
if (string.IsNullOrEmpty(sp_InfosString))
|
|
|
{
|
|
|
ApprovalDataView approvalData_1 = await GetApprovalDataAsync(sp_startDt, sp_centerDt);
|
|
@@ -482,6 +579,8 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
|
|
|
}
|
|
|
sp_Infos.AddRange(approvalData_2.data);
|
|
|
|
|
|
+ sp_Infos = sp_Infos.Where(it => it.sp_status == 2).ToList();
|
|
|
+
|
|
|
TimeSpan ts = DateTime.Now.AddMinutes(60) - DateTime.Now;
|
|
|
await RedisRepository
|
|
|
.RedisFactory
|