Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Education
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄奎
Education
Commits
66fe96be
Commit
66fe96be
authored
Mar 31, 2022
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
页面修改
parent
b80b32fe
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
153 additions
and
15 deletions
+153
-15
ConvertHelper.cs
Edu.Common/Plugin/ConvertHelper.cs
+23
-0
TeacherStaticModule.cs
Edu.Module.User/TeacherStaticModule.cs
+33
-7
QYWeiXinHelper.cs
Edu.ThirdCore/QYWinXin/QYWeiXinHelper.cs
+96
-8
TeacherStaticController.cs
Edu.WebApi/Controllers/User/TeacherStaticController.cs
+1
-0
No files found.
Edu.Common/Plugin/ConvertHelper.cs
View file @
66fe96be
...
...
@@ -644,7 +644,30 @@ namespace Edu.Common
break
;
}
return
intDayOfWeek
;
}
/// <summary>
/// DateTime时间格式转换为10位不带毫秒的Unix时间戳
/// </summary>
/// <param name="time">DateTime时间格式</param>
/// <returns>Unix时间戳格式</returns>
public
static
long
ConvertDateTimeInt
(
DateTime
dateTime
)
{
DateTime
startTime
=
TimeZone
.
CurrentTimeZone
.
ToLocalTime
(
new
DateTime
(
1970
,
1
,
1
));
return
(
int
)(
dateTime
-
startTime
).
TotalSeconds
;
}
/// <summary>
/// 时间戳转为C#格式时间
/// </summary>
/// <param name="timeStamp">Unix时间戳格式</param>
/// <returns>C#格式时间</returns>
public
static
DateTime
GetTime
(
string
timeStamp
)
{
DateTime
dtStart
=
TimeZone
.
CurrentTimeZone
.
ToLocalTime
(
new
DateTime
(
1970
,
1
,
1
));
long
lTime
=
long
.
Parse
(
timeStamp
+
"0000000"
);
TimeSpan
toNow
=
new
TimeSpan
(
lTime
);
return
dtStart
.
Add
(
toNow
);
}
}
}
\ No newline at end of file
Edu.Module.User/TeacherStaticModule.cs
View file @
66fe96be
using
Edu.Model.CacheModel
;
using
Edu.Model.ViewModel.User
;
using
Edu.Model.ViewModel.WeChat
;
using
Edu.Repository.User
;
using
System
;
using
System.Collections.Generic
;
...
...
@@ -17,6 +18,11 @@ namespace Edu.Module.User
/// </summary>
private
readonly
RB_Teacher_StaticRepository
teacher_StaticRepository
=
new
RB_Teacher_StaticRepository
();
/// <summary>
/// 员工信息仓储层对象
/// </summary>
private
readonly
RB_AccountRepository
accountRepository
=
new
RB_AccountRepository
();
/// <summary>
/// 教师行为数据数据每日统计
/// </summary>
...
...
@@ -2539,16 +2545,30 @@ namespace Edu.Module.User
public
bool
CreateTeacherStaticModule
(
UserInfo
user
,
string
StartTime
,
string
EndTime
,
bool
isInit
=
true
)
{
bool
flag
=
true
;
var
teacherList
=
accountRepository
.
GetEmployeeListRepository
(
new
Employee_ViewModel
()
{
AccountTypeStr
=
"2"
,
Group_Id
=
user
.
Group_Id
,
IsLeave
=
1
});
int
teacherCount
=
teacherList
?.
Count
()
??
1
;
List
<
WechatCheck_ViewModel
>
checkList
=
new
List
<
WechatCheck_ViewModel
>();
if
(
isInit
)
{
teacher_StaticRepository
.
DeleteTeacherStaticByProcRepository
();
}
var
date
=
Convert
.
ToDateTime
(
StartTime
);
var
endTime
=
Convert
.
ToDateTime
(
EndTime
);
string
tempStr
=
string
.
Join
(
","
,
teacherList
.
Where
(
qitem
=>
!
string
.
IsNullOrEmpty
(
qitem
.
WorkUserId
)).
Select
(
qitem
=>
qitem
.
WorkUserId
));
List
<
string
>
workUserIds
=
Common
.
ConvertHelper
.
StringToFileList
(
tempStr
);
int
Days
=
(
endTime
-
date
).
Days
;
for
(
int
i
=
0
;
i
<
Days
;
i
++)
{
var
newDate
=
date
.
AddDays
(
i
);
//获取老师迟到早退信息
checkList
=
Edu
.
ThirdCore
.
QYWinXin
.
QYWeiXinHelper
.
GetWeChatCheckList
(
workUserIds
,
newDate
);
//获取老师与学员沟通次数
int
message_cnt
=
Edu
.
ThirdCore
.
QYWinXin
.
QYWeiXinHelper
.
GetWechatStudentStatic
(
workUserIds
,
newDate
);
var
procModel
=
teacher_StaticRepository
.
GetTeacherStaticByProcRepository
(
Common
.
ConvertHelper
.
FormatDate
(
newDate
));
var
newModel
=
new
RB_Teacher_Static_Extend
()
{
...
...
@@ -2557,8 +2577,6 @@ namespace Edu.Module.User
StudentCount
=
procModel
?.
StudentCount
??
0
,
AttendClassHour
=
procModel
?.
AttendClassHour
??
0
,
AttendClassHourScore
=
procModel
?.
AttendClassHourScore
??
0
,
OnLineInteractive
=
procModel
?.
OnLineInteractive
??
0
,
OnLineInteractiveScore
=
procModel
?.
OnLineInteractiveScore
??
0
,
Renew
=
procModel
?.
Renew
??
0
,
RenewScore
=
procModel
?.
RenewScore
??
0
,
Upgrade
=
procModel
?.
Upgrade
??
0
,
...
...
@@ -2573,8 +2591,6 @@ namespace Edu.Module.User
WithdrawsScore
=
procModel
?.
WithdrawsScore
??
0
,
Complaint
=
procModel
?.
Complaint
??
0
,
ComplaintScore
=
procModel
?.
ComplaintScore
??
0
,
TeacherBeLate
=
procModel
?.
TeacherBeLate
??
0
,
TeacherBeLateScore
=
procModel
?.
TeacherBeLateScore
??
0
,
N5ClassHours
=
procModel
?.
N5ClassHours
??
0
,
N5ClassHoursScore
=
procModel
?.
N5ClassHoursScore
??
0
,
N4ClassHours
=
procModel
?.
N4ClassHours
??
0
,
...
...
@@ -2589,13 +2605,23 @@ namespace Edu.Module.User
MiniAppPractiseScore
=
procModel
?.
MiniAppPractiseScore
??
0
,
MiniAppTime
=
procModel
?.
MiniAppTime
??
0
,
MiniAppTimeScore
=
procModel
?.
MiniAppTimeScore
??
0
,
TotalScore
=
procModel
?.
TotalScore
??
0
,
AvgScore
=
procModel
?.
AvgScore
??
0
,
ScoreGap
=
procModel
?.
ScoreGap
??
0
,
ActivityNum
=
procModel
?.
ActivityNum
??
0
,
YearStr
=
newDate
.
Year
,
MonthStr
=
newDate
.
Month
,
};
newModel
.
OnLineInteractive
=
message_cnt
;
newModel
.
OnLineInteractiveScore
=
newModel
.
OnLineInteractive
;
newModel
.
TeacherBeLate
=
checkList
?.
Where
(
qitem
=>
qitem
.
ExceptionCount
>
0
)?.
Count
()
??
0
;
newModel
.
TeacherBeLateScore
=
newModel
.
TeacherBeLate
;
newModel
.
TotalScore
=
(
newModel
.
StudentCount
+
newModel
.
AttendClassHourScore
+
newModel
.
OnLineInteractiveScore
+
newModel
.
RenewScore
+
newModel
.
UpgradeScore
+
newModel
.
TransScore
+
newModel
.
TrialSpeakScore
-
newModel
.
TruancyScore
-
newModel
.
WithdrawsScore
-
newModel
.
ComplaintScore
-
newModel
.
TeacherBeLateScore
+
newModel
.
N2ClassHoursScore
+
newModel
.
N1ClassHoursScore
+
newModel
.
MiniAppPractiseScore
+
newModel
.
MiniAppTimeScore
+
newModel
.
ActivityNum
);
newModel
.
AvgScore
=
Math
.
Round
(
newModel
.
TotalScore
/
teacherCount
,
2
);
newModel
.
ScoreGap
=
newModel
.
TotalScore
-
newModel
.
AvgScore
;
int
times
=
1
;
int
newDay
=
newDate
.
Day
;
//本月最后一天
...
...
Edu.ThirdCore/QYWinXin/QYWeiXinHelper.cs
View file @
66fe96be
...
...
@@ -19,6 +19,8 @@ using Senparc.Weixin.Work.CommonAPIs;
using
Senparc.Weixin.Work.AdvancedAPIs.OAuth2
;
using
Senparc.Weixin.Work.Containers
;
using
Senparc.Weixin.Work.Entities
;
using
Newtonsoft.Json.Linq
;
using
Edu.Model.ViewModel.WeChat
;
namespace
Edu.ThirdCore.QYWinXin
{
...
...
@@ -677,23 +679,109 @@ namespace Edu.ThirdCore.QYWinXin
/// <summary>
/// 获取企业微信打卡信息
/// </summary>
public
static
void
GetWeChatCheck
()
/// <param name="userIds"></param>
/// <returns></returns>
public
static
List
<
WechatCheck_ViewModel
>
GetWeChatCheckList
(
List
<
string
>
userIds
,
DateTime
day
)
{
List
<
WechatCheck_ViewModel
>
list
=
new
List
<
WechatCheck_ViewModel
>();
string
WX_CorpId
=
"ww8418f1889fdded76"
;
string
Employee_Secret
=
"mfqSiSVkQYg94wFEFN9koOK0DUQczXN-sADLE2L3gsQ"
;
//打卡的密钥
string
Employee_Secret
=
"T1t9ZtxxGeiURYc-l72HWZPa41ep5lTtLBc3hpPvYCM"
;
string
token
=
GetToken
(
WX_CorpId
,
Employee_Secret
,
newToken
:
false
);
DateTime
start
=
new
DateTime
(
day
.
Year
,
day
.
Month
,
day
.
Day
,
0
,
0
,
0
);
long
startt
=
Common
.
ConvertHelper
.
ConvertDateTimeInt
(
start
);
long
endt
=
Common
.
ConvertHelper
.
ConvertDateTimeInt
(
start
);
var
request
=
new
{
starttime
=
1599062400
,
endtime
=
1599062400
,
useridlist
=
new
List
<
string
>()
starttime
=
startt
,
endtime
=
endt
,
useridlist
=
userIds
};
string
url
=
string
.
Format
(
"https://qyapi.weixin.qq.com/cgi-bin/checkin/getcheckin_daydata?access_token={0}"
,
token
);
var
Rmsg
=
HttpHelper
.
HttpPost
(
url
,
JsonHelper
.
Serialize
(
request
),
""
);
if
(!
string
.
IsNullOrEmpty
(
Rmsg
))
{
JObject
jobj
=
JObject
.
Parse
(
Rmsg
);
if
(
jobj
.
GetInt
(
"errcode"
)
==
0
)
{
"PengMengQiu"
JArray
jarray
=
JArray
.
Parse
(
jobj
.
GetStringValue
(
"datas"
));
if
(
jarray
!=
null
&&
jarray
.
Count
>
0
)
{
foreach
(
var
jItem
in
jarray
)
{
JObject
subObj
=
JObject
.
Parse
(
jItem
.
ToString
());
WechatCheck_ViewModel
model
=
new
WechatCheck_ViewModel
();
JObject
base_info
=
JObject
.
Parse
(
subObj
.
GetStringValue
(
"base_info"
));
JObject
rule_info
=
JObject
.
Parse
(
base_info
.
GetStringValue
(
"rule_info"
));
model
.
Acctid
=
base_info
.
GetStringValue
(
"acctid"
);
model
.
Name
=
base_info
.
GetStringValue
(
"name"
);
model
.
Date
=
Common
.
ConvertHelper
.
GetTime
(
base_info
.
GetStringValue
(
"date"
));
model
.
Scheduleid
=
rule_info
.
GetInt
(
"scheduleid"
);
model
.
ExceptionCount
=
0
;
string
exceptionStr
=
""
;
if
(
model
.
Scheduleid
>
0
)
{
JArray
exception_infos
=
JArray
.
Parse
(
subObj
.
GetStringValue
(
"exception_infos"
));
if
(
exception_infos
!=
null
&&
exception_infos
.
Count
>
0
)
{
foreach
(
var
sItem
in
exception_infos
)
{
JObject
exObj
=
JObject
.
Parse
(
sItem
.
ToString
());
model
.
ExceptionCount
+=
exObj
.
GetInt
(
"count"
);
exceptionStr
+=
exObj
.
GetStringValue
(
"exception"
)
+
","
;
}
}
}
model
.
ExceptionStr
=
exceptionStr
.
TrimEnd
(
','
);
list
.
Add
(
model
);
}
}
}
}
return
list
;
}
/// <summary>
/// 获取老师与学员线上沟通次数
/// </summary>
/// <param name="userIds"></param>
/// <param name="day"></param>
public
static
int
GetWechatStudentStatic
(
List
<
string
>
userIds
,
DateTime
day
)
{
int
message_cnt
=
0
;
string
WX_CorpId
=
"ww8418f1889fdded76"
;
//客户联系秘钥
string
Employee_Secret
=
"Jpn1_rq00KHuCef4fGAjcsg1dH02ncTPvH5rxshyD9c"
;
string
token
=
GetToken
(
WX_CorpId
,
Employee_Secret
,
newToken
:
false
);
DateTime
start
=
new
DateTime
(
day
.
Year
,
day
.
Month
,
day
.
Day
,
0
,
0
,
0
);
long
startt
=
Common
.
ConvertHelper
.
ConvertDateTimeInt
(
start
);
long
endt
=
Common
.
ConvertHelper
.
ConvertDateTimeInt
(
start
);
var
request
=
new
{
start_time
=
startt
,
end_time
=
endt
,
userid
=
userIds
,
partyid
=
new
List
<
int
>()
};
string
url
=
string
.
Format
(
"https://qyapi.weixin.qq.com/cgi-bin/
checkin/getcheckin_day
data?access_token={0}"
,
token
);
string
url
=
string
.
Format
(
"https://qyapi.weixin.qq.com/cgi-bin/
externalcontact/get_user_behavior_
data?access_token={0}"
,
token
);
var
Rmsg
=
HttpHelper
.
HttpPost
(
url
,
JsonHelper
.
Serialize
(
request
),
""
);
Console
.
WriteLine
(
"Rmsg:"
+
Rmsg
);
if
(!
string
.
IsNullOrEmpty
(
Rmsg
))
{
JObject
root
=
JObject
.
Parse
(
Rmsg
);
if
(
root
.
GetInt
(
"errcode"
)
==
0
)
{
JArray
behavior_data
=
JArray
.
Parse
(
root
.
GetStringValue
(
"behavior_data"
));
if
(
behavior_data
!=
null
&&
behavior_data
.
Count
>
0
)
{
foreach
(
var
jItem
in
behavior_data
)
{
JObject
sObj
=
JObject
.
Parse
(
jItem
.
ToString
());
message_cnt
+=
sObj
.
GetInt
(
"message_cnt"
);
}
}
}
}
return
message_cnt
;
}
#
endregion
}
...
...
Edu.WebApi/Controllers/User/TeacherStaticController.cs
View file @
66fe96be
...
...
@@ -496,6 +496,7 @@ namespace Edu.WebApi.Controllers.User
StartTime
=
Common
.
ConvertHelper
.
FormatDate
(
DateTime
.
Now
);
}
StartTime
=
"2021-12-21"
;
StartTime
=
"2022-03-21"
;
string
EndTime
=
Common
.
ConvertHelper
.
FormatDate
(
DateTime
.
Now
);
bool
flag
=
teacherStaticModule
.
CreateTeacherStaticModule
(
userInfo
,
StartTime
,
EndTime
);
return
flag
?
ApiResult
.
Success
()
:
ApiResult
.
Failed
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment