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
f7c5bf9d
Commit
f7c5bf9d
authored
Feb 25, 2021
by
钟博
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'v2020morge' into 多角色登录
parents
adefae09
fe4853ca
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
5 deletions
+49
-5
performance/Performance.Api/Controllers/TemplateController.cs
+1
-1
performance/Performance.Repository/BaseRepository.cs
+44
-1
performance/Performance.Repository/Performance.Repository.csproj
+1
-0
performance/Performance.Services/ReportGlobalService.cs
+3
-3
No files found.
performance/Performance.Api/Controllers/TemplateController.cs
View file @
f7c5bf9d
...
...
@@ -176,7 +176,7 @@ public ApiResponse Prejudge([FromRoute] int allotId)
if
(!
string
.
IsNullOrEmpty
(
filePath
)
&&
FileHelper
.
IsExistFile
(
filePath
))
{
var
data
=
configService
.
CheckHasNewDepartmentOrCategory
(
allotId
);
return
new
ApiResponse
(
ResponseType
.
Fail
,
data
);
return
new
ApiResponse
(
ResponseType
.
OK
,
new
{
haserror
=
(
data
!=
null
&&
data
.
Any
()),
data
}
);
}
return
new
ApiResponse
(
ResponseType
.
OK
);
}
...
...
performance/Performance.Repository/BaseRepository.cs
View file @
f7c5bf9d
...
...
@@ -4,8 +4,8 @@
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Linq.Expressions
;
using
System.Text
;
using
System.Threading.Tasks
;
using
Z.EntityFramework.Extensions
;
namespace
Performance.Repository
{
...
...
@@ -23,18 +23,22 @@ public TEntity DapperQueryFirst(string sql, object param)
{
return
context
.
Database
.
GetDbConnection
().
QueryFirst
<
TEntity
>(
sql
,
param
);
}
public
IEnumerable
<
TEntity
>
DapperQuery
(
string
sql
,
object
param
)
{
return
context
.
Database
.
GetDbConnection
().
Query
<
TEntity
>(
sql
,
param
);
}
public
IEnumerable
<
TEntity
>
DapperQuery
(
string
sql
,
object
param
,
int
?
commandTimeout
=
null
)
{
return
context
.
Database
.
GetDbConnection
().
Query
<
TEntity
>(
sql
,
param
,
commandTimeout
:
commandTimeout
);
}
public
IEnumerable
<
T
>
DapperQuery
<
T
>(
string
sql
,
object
param
)
where
T
:
class
,
new
()
{
return
context
.
Database
.
GetDbConnection
().
Query
<
T
>(
sql
,
param
);
}
public
T
DapperQueryFirstOrDefault
<
T
>(
string
sql
,
object
param
)
{
return
context
.
Database
.
GetDbConnection
().
QueryFirstOrDefault
<
T
>(
sql
,
param
);
...
...
@@ -79,11 +83,13 @@ public bool Remove(TEntity entity)
context
.
Set
<
TEntity
>().
Remove
(
entity
);
return
context
.
SaveChanges
()
>
0
;
}
public
bool
RemoveRange
(
params
TEntity
[]
entities
)
{
context
.
Set
<
TEntity
>().
RemoveRange
(
entities
);
return
context
.
SaveChanges
()
>
0
;
}
public
bool
RemoveRange
(
Expression
<
Func
<
TEntity
,
bool
>>
exp
)
{
var
query
=
CompileQuery
(
exp
);
...
...
@@ -144,5 +150,42 @@ private TEntity CompileQuerySingle(Expression<Func<TEntity, bool>> exp)
var
func
=
EF
.
CompileQuery
((
DbContext
context
,
Expression
<
Func
<
TEntity
,
bool
>>
exps
)
=>
context
.
Set
<
TEntity
>().
FirstOrDefault
(
exp
));
return
func
(
context
,
exp
);
}
#
region
Bulk
public
void
BulkInsert
(
IEnumerable
<
TEntity
>
entities
)
{
EntityFrameworkManager
.
ContextFactory
=
factory
=>
context
;
context
.
Set
<
TEntity
>().
BulkInsert
(
entities
);
context
.
BulkSaveChanges
();
}
public
async
Task
BulkInsertAsync
(
IEnumerable
<
TEntity
>
entities
)
{
EntityFrameworkManager
.
ContextFactory
=
factory
=>
context
;
await
context
.
Set
<
TEntity
>().
BulkInsertAsync
(
entities
);
await
context
.
BulkSaveChangesAsync
();
}
public
int
DeleteFromQuery
(
Expression
<
Func
<
TEntity
,
bool
>>
exp
)
{
return
context
.
Set
<
TEntity
>().
Where
(
exp
).
DeleteFromQuery
();
}
public
void
BulkDelete
(
IEnumerable
<
TEntity
>
entities
)
{
EntityFrameworkManager
.
ContextFactory
=
factory
=>
context
;
context
.
Set
<
TEntity
>().
BulkDelete
(
entities
);
context
.
BulkSaveChanges
();
}
public
async
Task
BulkDeleteAsync
(
IEnumerable
<
TEntity
>
entities
)
{
EntityFrameworkManager
.
ContextFactory
=
factory
=>
context
;
await
context
.
Set
<
TEntity
>().
BulkDeleteAsync
(
entities
);
await
context
.
BulkSaveChangesAsync
();
}
#
endregion
Bulk
}
}
performance/Performance.Repository/Performance.Repository.csproj
View file @
f7c5bf9d
...
...
@@ -10,6 +10,7 @@
<PackageReference Include="MySql.Data" Version="8.0.15" />
<PackageReference Include="MySql.Data.EntityFrameworkCore" Version="8.0.15" />
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="2.19.60" />
<PackageReference Include="Z.EntityFramework.Extensions.EFCore" Version="2.8.20" />
</ItemGroup>
<ItemGroup>
...
...
performance/Performance.Services/ReportGlobalService.cs
View file @
f7c5bf9d
...
...
@@ -7,6 +7,7 @@
using
Performance.Services.ExtractExcelService
;
using
System
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.Linq
;
using
System.Text
;
...
...
@@ -204,10 +205,9 @@ public void ImportAllotData(int hospitalId, string filePath)
var
years
=
data
.
Select
(
t
=>
t
.
Year
).
Distinct
();
var
months
=
data
.
Select
(
t
=>
t
.
Month
).
Distinct
();
var
historyData
=
hisimportdataRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
hospitalId
&&
years
.
Contains
(
t
.
Year
)
&&
months
.
Contains
(
t
.
Month
)
&&
t
.
Category
==
sheetName
);
if
(
historyData
!=
null
&&
historyData
.
Any
())
hisimportdataRepository
.
RemoveRange
(
historyData
.
ToArray
());
hisimportdataRepository
.
AddRange
(
data
.
Where
(
t
=>
t
.
Year
!=
0
&&
t
.
Month
!=
0
).
ToArray
());
hisimportdataRepository
.
DeleteFromQuery
(
t
=>
t
.
HospitalId
==
hospitalId
&&
years
.
Contains
(
t
.
Year
)
&&
months
.
Contains
(
t
.
Month
)
&&
t
.
Category
==
sheetName
);
hisimportdataRepository
.
BulkInsert
(
data
.
Where
(
t
=>
t
.
Year
!=
0
&&
t
.
Month
!=
0
));
}
}
catch
(
Exception
ex
)
...
...
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