Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
performance
Overview
Overview
Details
Activity
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zry
performance
Commits
66d7aaa6
Commit
66d7aaa6
authored
Apr 16, 2021
by
lcx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
定时抽取数据
parent
bed6a05a
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
131 additions
and
0 deletions
+131
-0
performance/Performance.Api/Job/ExtractDataJob.cs
+22
-0
performance/Performance.Api/Job/JobRegistry.cs
+12
-0
performance/Performance.Api/Performance.Api.csproj
+1
-0
performance/Performance.Api/Startup.cs
+3
-0
performance/Performance.Services/ExtractExcelService/ExtractJobService.cs
+82
-0
performance/Performance.Services/ServiceLocator.cs
+11
-0
No files found.
performance/Performance.Api/Job/ExtractDataJob.cs
0 → 100644
View file @
66d7aaa6
using
FluentScheduler
;
using
Microsoft.Extensions.DependencyInjection
;
using
Performance.Services
;
using
Performance.Services.ExtractExcelService
;
namespace
Performance.Api
{
public
class
ExtractDataJob
:
IJob
{
private
readonly
ExtractJobService
extractJobService
;
public
ExtractDataJob
()
{
this
.
extractJobService
=
ServiceLocator
.
Instance
.
GetService
<
ExtractJobService
>();
}
public
void
Execute
()
{
extractJobService
.
Execute
();
}
}
}
performance/Performance.Api/Job/JobRegistry.cs
0 → 100644
View file @
66d7aaa6
using
FluentScheduler
;
namespace
Performance.Api
{
public
class
JobRegistry
:
Registry
{
public
JobRegistry
()
{
Schedule
<
ExtractDataJob
>().
ToRunNow
().
AndEvery
(
1
).
Days
().
At
(
23
,
0
);
}
}
}
performance/Performance.Api/Performance.Api.csproj
View file @
66d7aaa6
...
...
@@ -39,6 +39,7 @@
<PackageReference Include="AutoMapper" Version="8.0.0" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="6.0.0" />
<PackageReference Include="CSRedisCore" Version="3.0.45" />
<PackageReference Include="FluentScheduler" Version="5.5.1" />
<PackageReference Include="FluentValidation.AspNetCore" Version="8.1.3" />
<PackageReference Include="GraphQL" Version="2.4.0" />
<PackageReference Include="Hangfire" Version="1.6.22" />
...
...
performance/Performance.Api/Startup.cs
View file @
66d7aaa6
...
...
@@ -209,6 +209,9 @@ public void ConfigureServices(IServiceCollection services)
});
#
endregion
swagger
ServiceLocator
.
Instance
=
services
.
BuildServiceProvider
();
FluentScheduler
.
JobManager
.
Initialize
(
new
JobRegistry
());
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
...
...
performance/Performance.Services/ExtractExcelService/ExtractJobService.cs
0 → 100644
View file @
66d7aaa6
using
Microsoft.Extensions.Logging
;
using
Performance.DtoModels
;
using
Performance.Repository
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
namespace
Performance.Services.ExtractExcelService
{
public
class
ExtractJobService
:
IAutoInjection
{
private
readonly
ILogger
logger
;
private
readonly
AllotService
allotService
;
private
readonly
ConfigService
configService
;
private
readonly
DictionaryService
dictionaryService
;
private
readonly
QueryService
queryService
;
private
readonly
PerforUserRepository
userRepository
;
private
readonly
PerforHospitalRepository
hospitalRepository
;
private
readonly
PerforPerallotRepository
perallotRepository
;
public
ExtractJobService
(
ILogger
<
ExtractJobService
>
logger
,
AllotService
allotService
,
ConfigService
configService
,
DictionaryService
dictionaryService
,
QueryService
queryService
,
PerforUserRepository
userRepository
,
PerforHospitalRepository
hospitalRepository
,
PerforPerallotRepository
perallotRepository
)
{
this
.
logger
=
logger
;
this
.
allotService
=
allotService
;
this
.
configService
=
configService
;
this
.
dictionaryService
=
dictionaryService
;
this
.
queryService
=
queryService
;
this
.
userRepository
=
userRepository
;
this
.
hospitalRepository
=
hospitalRepository
;
this
.
perallotRepository
=
perallotRepository
;
}
public
void
Execute
()
{
var
hospitals
=
hospitalRepository
.
GetEntities
();
if
(
hospitals
==
null
||
!
hospitals
.
Any
())
return
;
var
userId
=
userRepository
.
GetEntity
(
t
=>
t
.
Login
.
ToLower
()
==
"admin"
&&
t
.
States
==
1
&&
t
.
IsDelete
==
1
)?.
ID
??
1
;
var
date
=
DateTime
.
Now
;
var
allots
=
perallotRepository
.
GetEntities
(
t
=>
hospitals
.
Select
(
w
=>
w
.
ID
).
Contains
(
t
.
HospitalId
)
&&
t
.
Year
==
date
.
Year
&&
t
.
Month
==
date
.
Month
);
foreach
(
var
hospital
in
hospitals
)
{
try
{
var
allot
=
allots
?.
FirstOrDefault
(
t
=>
t
.
HospitalId
==
hospital
.
ID
);
if
(
allot
==
null
)
{
allot
=
allotService
.
InsertAllot
(
new
AllotRequest
{
HospitalId
=
hospital
.
ID
,
Year
=
date
.
Year
,
Month
=
date
.
Month
},
userId
);
configService
.
Copy
(
allot
);
}
if
(
allot
==
null
||
allot
.
ID
==
0
)
continue
;
var
dict
=
new
Dictionary
<
ExDataDict
,
object
>();
var
isSingle
=
hospital
.
IsSingleProject
==
1
;
dictionaryService
.
Handler
(
hospital
.
ID
,
allot
,
""
,
isSingle
);
var
data
=
queryService
.
Handler
(
hospital
.
ID
,
allot
,
""
,
isSingle
,
ref
dict
);
}
catch
(
Exception
ex
)
{
logger
.
LogError
(
ex
.
ToString
());
}
}
}
}
}
performance/Performance.Services/ServiceLocator.cs
0 → 100644
View file @
66d7aaa6
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Performance.Services
{
public
static
class
ServiceLocator
{
public
static
IServiceProvider
Instance
{
get
;
set
;
}
}
}
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