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
0db013f1
Commit
0db013f1
authored
Apr 01, 2022
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
页面修改
parent
598fae23
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
79 additions
and
56 deletions
+79
-56
JsonHelper.cs
Edu.Common/Plugin/JsonHelper.cs
+23
-0
Program.cs
Edu.Test/Program.cs
+17
-30
StudentStatController.cs
Edu.WebApi/Controllers/User/StudentStatController.cs
+12
-6
TeacherStaticController.cs
Edu.WebApi/Controllers/User/TeacherStaticController.cs
+6
-2
TimerJobj.cs
Edu.WebApi/Timers/TimerJobj.cs
+21
-18
No files found.
Edu.Common/Plugin/JsonHelper.cs
View file @
0db013f1
...
...
@@ -237,5 +237,28 @@ namespace Edu.Common.Plugin
);
return
JsonConvert
.
DeserializeObject
(
json
);
}
/// <summary>
/// 判断字符串是不是JSON格式
/// </summary>
/// <param name="json"></param>
/// <returns></returns>
public
static
bool
IsJson
(
string
json
)
{
bool
flag
=
false
;
if
(!
string
.
IsNullOrEmpty
(
json
))
{
try
{
_
=
(
JObject
)
JsonConvert
.
DeserializeObject
(
json
);
flag
=
true
;
}
catch
{
flag
=
false
;
}
}
return
flag
;
}
}
}
Edu.Test/Program.cs
View file @
0db013f1
...
...
@@ -19,39 +19,26 @@ namespace Edu.Test
//var list = Common.Plugin.FileHelper.GetFileAllPath(filePath, newPath);
//string str = Common.Plugin.JsonHelper.Serialize(list);
//Console.WriteLine(str);
var
str
=
ConvertStringToDateTime
(
"1492617600"
);
Console
.
WriteLine
(
str
);
var
date
=
new
DateTime
(
2022
,
3
,
21
,
0
,
0
,
0
);
var
res1
=
ConvertDateTimeInt
(
date
);
Console
.
WriteLine
(
res1
);
var
obj
=
new
{
MonthStr
=
"4"
,
YearStr
=
"2022"
,
rowsPerPage
=
0
,
};
string
str
=
"asfasdasd&@!^&*!@&#!@*(#"
;
if
(
Common
.
Plugin
.
JsonHelper
.
IsJson
(
Common
.
Plugin
.
JsonHelper
.
Serialize
(
obj
)))
{
Console
.
WriteLine
(
"111"
);
}
else
{
Console
.
WriteLine
(
"222"
);
}
Console
.
WriteLine
(
"End......"
);
Console
.
ReadKey
();
}
/// <summary>
/// 将c# DateTime时间格式转换为Unix时间戳格式
/// </summary>
/// <param name="time">时间</param>
/// <returns>double</returns>
private
static
double
ConvertDateTimeInt
(
DateTime
time
)
{
DateTime
dd
=
new
DateTime
(
1970
,
1
,
1
,
0
,
0
,
0
,
0
);
TimeSpan
ts
=
(
time
-
dd
);
return
(
Int64
)
ts
.
TotalMilliseconds
;
}
/// <summary>
/// 时间戳转为C#格式时间
/// </summary>
/// <param name=”timeStamp”></param>
/// <returns></returns>
public
static
DateTime
ConvertStringToDateTime
(
string
timeStamp
)
{
DateTime
dtStart
=
TimeZoneInfo
.
ConvertTime
(
new
DateTime
(
1970
,
1
,
1
,
0
,
0
,
0
,
0
,
DateTimeKind
.
Utc
),
TimeZoneInfo
.
Local
);
long
lTime
=
long
.
Parse
(
timeStamp
+
"0000"
);
TimeSpan
toNow
=
new
TimeSpan
(
lTime
);
return
dtStart
.
Add
(
toNow
);
}
}
}
Edu.WebApi/Controllers/User/StudentStatController.cs
View file @
0db013f1
...
...
@@ -2000,10 +2000,13 @@ namespace Edu.WebApi.Controllers.User
}
StartTime
=
"2021-12-21"
;
string
EndTime
=
Common
.
ConvertHelper
.
FormatDate
(
DateTime
.
Now
);
bool
flag
=
studentStatModule
.
CreateStudentCompanyModule
(
userInfo
,
StartTime
,
EndTime
);
flag
=
studentStatModule
.
CreateStudentMarketModule
(
userInfo
,
StartTime
,
EndTime
);
flag
=
studentStatModule
.
CreateStudentStaticModule
(
userInfo
,
StartTime
,
EndTime
);
return
flag
?
ApiResult
.
Success
()
:
ApiResult
.
Failed
();
Task
.
Run
(()
=>
{
studentStatModule
.
CreateStudentCompanyModule
(
userInfo
,
StartTime
,
EndTime
);
studentStatModule
.
CreateStudentMarketModule
(
userInfo
,
StartTime
,
EndTime
);
studentStatModule
.
CreateStudentStaticModule
(
userInfo
,
StartTime
,
EndTime
);
});
return
ApiResult
.
Success
();
}
/// <summary>
...
...
@@ -2013,8 +2016,11 @@ namespace Edu.WebApi.Controllers.User
[
HttpPost
]
public
ApiResult
RefreshStudentNotMoney
()
{
bool
flag
=
studentStatModule
.
CalcStudentNotMoneyModule
();
return
flag
?
ApiResult
.
Success
()
:
ApiResult
.
Failed
();
Task
.
Run
(()
=>
{
studentStatModule
.
CalcStudentNotMoneyModule
();
});
return
ApiResult
.
Success
();
}
#
endregion
}
...
...
Edu.WebApi/Controllers/User/TeacherStaticController.cs
View file @
0db013f1
...
...
@@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Mvc;
using
Newtonsoft.Json.Linq
;
using
System
;
using
System.Collections.Generic
;
using
System.Threading.Tasks
;
namespace
Edu.WebApi.Controllers.User
{
...
...
@@ -497,8 +498,11 @@ namespace Edu.WebApi.Controllers.User
}
StartTime
=
"2021-12-21"
;
string
EndTime
=
Common
.
ConvertHelper
.
FormatDate
(
DateTime
.
Now
);
bool
flag
=
teacherStaticModule
.
CreateTeacherStaticModule
(
userInfo
,
StartTime
,
EndTime
);
return
flag
?
ApiResult
.
Success
()
:
ApiResult
.
Failed
();
Task
.
Run
(()
=>
{
teacherStaticModule
.
CreateTeacherStaticModule
(
userInfo
,
StartTime
,
EndTime
);
});
return
ApiResult
.
Success
();
}
#
endregion
}
...
...
Edu.WebApi/Timers/TimerJobj.cs
View file @
0db013f1
...
...
@@ -161,7 +161,7 @@ namespace Edu.WebApi.Timers
dealStudentNotMoneyTimer
=
new
System
.
Timers
.
Timer
()
{
Interval
=
(
1000
*
60
)
*
(
60
*
4
)
//1小时检查一次
Interval
=
(
1000
*
60
)
*
(
60
*
4
)
//1小时检查一次
};
dealStudentNotMoneyTimer
.
Elapsed
+=
new
System
.
Timers
.
ElapsedEventHandler
(
DealStudentNotMoneyData
);
dealStudentNotMoneyTimer
.
Enabled
=
true
;
...
...
@@ -235,24 +235,27 @@ namespace Edu.WebApi.Timers
if
(
Interlocked
.
Exchange
(
ref
marketconsultant_Timer
,
1
)
==
0
)
{
var
today
=
DateTime
.
Now
;
var
currentDate
=
Common
.
ConvertHelper
.
FormatDate
(
today
);
string
cacheData
=
redis
.
Get
(
createMarkDataKey
);
if
(
string
.
IsNullOrEmpty
(
cacheData
))
{
redis
.
Set
(
createMarkDataKey
,
currentDate
);
cacheData
=
currentDate
;
}
if
(!
string
.
IsNullOrEmpty
(
cacheData
)
&&
cacheData
!=
currentDate
)
if
(
today
.
Hour
>
8
&&
today
.
Hour
<
10
)
{
marketConsultantModule
.
CreateConsultantDataModule
(
today
);
marketConsultantModule
.
CreateMarketDataModule
(
today
);
UserInfo
user
=
UserReidsCache
.
GetUserLoginInfo
(
"1"
);
var
startDate
=
Common
.
ConvertHelper
.
FormatDate
(
today
.
AddDays
(-
1
));
studentStatModule
.
CreateStudentStaticModule
(
user
,
startDate
,
currentDate
,
isInit
:
false
);
studentStatModule
.
CreateStudentMarketModule
(
user
,
startDate
,
currentDate
,
isInit
:
false
);
studentStatModule
.
CreateStudentCompanyModule
(
user
,
startDate
,
currentDate
,
isInit
:
false
);
teacherStaticModule
.
CreateTeacherStaticModule
(
user
,
startDate
,
currentDate
,
isInit
:
false
);
redis
.
Set
(
createMarkDataKey
,
currentDate
);
var
currentDate
=
Common
.
ConvertHelper
.
FormatDate
(
today
);
string
cacheData
=
redis
.
Get
(
createMarkDataKey
);
if
(
string
.
IsNullOrEmpty
(
cacheData
))
{
redis
.
Set
(
createMarkDataKey
,
currentDate
);
cacheData
=
currentDate
;
}
if
(!
string
.
IsNullOrEmpty
(
cacheData
)
&&
cacheData
!=
currentDate
)
{
marketConsultantModule
.
CreateConsultantDataModule
(
today
);
marketConsultantModule
.
CreateMarketDataModule
(
today
);
UserInfo
user
=
UserReidsCache
.
GetUserLoginInfo
(
"1"
);
var
startDate
=
Common
.
ConvertHelper
.
FormatDate
(
today
.
AddDays
(-
1
));
studentStatModule
.
CreateStudentStaticModule
(
user
,
startDate
,
currentDate
,
isInit
:
false
);
studentStatModule
.
CreateStudentMarketModule
(
user
,
startDate
,
currentDate
,
isInit
:
false
);
studentStatModule
.
CreateStudentCompanyModule
(
user
,
startDate
,
currentDate
,
isInit
:
false
);
teacherStaticModule
.
CreateTeacherStaticModule
(
user
,
startDate
,
currentDate
,
isInit
:
false
);
redis
.
Set
(
createMarkDataKey
,
currentDate
);
}
}
Interlocked
.
Exchange
(
ref
marketconsultant_Timer
,
0
);
}
...
...
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