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
90fbff9b
Commit
90fbff9b
authored
Aug 02, 2021
by
lcx
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into feature/审核
parents
dd7ebb36
ee899979
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
39 deletions
+77
-39
performance/Performance.Api/Controllers/TemplateController.cs
+5
-0
performance/Performance.Services/ConfigService.cs
+9
-8
performance/Performance.Services/ExtractExcelService/ExtractService.cs
+2
-2
performance/Performance.Services/ExtractExcelService/QueryService.cs
+61
-29
No files found.
performance/Performance.Api/Controllers/TemplateController.cs
View file @
90fbff9b
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.IO
;
using
System.Linq
;
using
System.Linq
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
namespace
Performance.Api.Controllers
namespace
Performance.Api.Controllers
...
@@ -230,14 +231,18 @@ public ApiResponse NewExtractData([CustomizeValidator, FromBody] ExtractRequest
...
@@ -230,14 +231,18 @@ public ApiResponse NewExtractData([CustomizeValidator, FromBody] ExtractRequest
if
(
isSingle
)
if
(
isSingle
)
{
{
logger
.
LogInformation
(
"同一项目中进行提取"
);
Task
.
Run
(()
=>
Task
.
Run
(()
=>
{
{
using
(
var
scope
=
serviceScopeFactory
.
CreateScope
())
using
(
var
scope
=
serviceScopeFactory
.
CreateScope
())
{
{
var
scopedServices
=
scope
.
ServiceProvider
.
GetRequiredService
<
ExtractService
>();
var
scopedServices
=
scope
.
ServiceProvider
.
GetRequiredService
<
ExtractService
>();
logger
.
LogInformation
(
"提取绩效数据参数:"
+
JsonHelper
.
Serialize
(
new
{
allotId
=
allot
.
ID
,
hospitalId
=
allot
.
HospitalId
,
userId
=
claim
.
GetUserId
()
}));
string
extractFilePath
=
scopedServices
.
Main
(
allot
.
ID
,
allot
.
HospitalId
,
email
,
"User"
+
claim
.
GetUserId
(),
filePath
,
isSingle
);
string
extractFilePath
=
scopedServices
.
Main
(
allot
.
ID
,
allot
.
HospitalId
,
email
,
"User"
+
claim
.
GetUserId
(),
filePath
,
isSingle
);
}
}
});
});
Thread
.
Sleep
(
1000
);
}
}
else
else
{
{
...
...
performance/Performance.Services/ConfigService.cs
View file @
90fbff9b
...
@@ -989,8 +989,8 @@ public void Copy(per_allot allot)
...
@@ -989,8 +989,8 @@ public void Copy(per_allot allot)
var
cofDrugtypeFactor
=
cofdrugtypefactorRepository
.
GetEntities
(
t
=>
t
.
AllotID
==
allot
.
ID
);
var
cofDrugtypeFactor
=
cofdrugtypefactorRepository
.
GetEntities
(
t
=>
t
.
AllotID
==
allot
.
ID
);
if
(
cofDrugtypeFactor
==
null
||
cofDrugtypeFactor
.
Count
==
0
)
if
(
cofDrugtypeFactor
==
null
||
cofDrugtypeFactor
.
Count
==
0
)
{
{
var
drugtypefacto
e
=
cofdrugtypefactorRepository
.
GetEntities
(
t
=>
t
.
AllotID
==
allotId
)
??
cofdrugtypefactorRepository
.
GetEntities
(
t
=>
t
.
AllotID
==
-
1
);
var
drugtypefacto
r
=
cofdrugtypefactorRepository
.
GetEntities
(
t
=>
t
.
AllotID
==
allotId
)
??
cofdrugtypefactorRepository
.
GetEntities
(
t
=>
t
.
AllotID
==
-
1
);
var
new
Agains
=
drugtypefactoe
.
Select
(
t
=>
new
cof_drugtype_factor
var
new
drugtypefactor
=
drugtypefactor
?
.
Select
(
t
=>
new
cof_drugtype_factor
{
{
HospitalId
=
allot
.
HospitalId
,
HospitalId
=
allot
.
HospitalId
,
AllotID
=
allot
.
ID
,
AllotID
=
allot
.
ID
,
...
@@ -1000,7 +1000,8 @@ public void Copy(per_allot allot)
...
@@ -1000,7 +1000,8 @@ public void Copy(per_allot allot)
HLZ
=
t
.
HLZ
,
HLZ
=
t
.
HLZ
,
YJZ
=
t
.
YJZ
,
YJZ
=
t
.
YJZ
,
});
});
cofdrugtypefactorRepository
.
AddRange
(
newAgains
.
ToArray
());
if
(
newdrugtypefactor
!=
null
&&
newdrugtypefactor
.
Any
())
cofdrugtypefactorRepository
.
AddRange
(
newdrugtypefactor
.
ToArray
());
}
}
logger
.
LogInformation
(
$"cofDepttype"
);
logger
.
LogInformation
(
$"cofDepttype"
);
...
@@ -1422,23 +1423,23 @@ public SheetExportResponse GetDrugtypeFactor(AllotDeptRequest request)
...
@@ -1422,23 +1423,23 @@ public SheetExportResponse GetDrugtypeFactor(AllotDeptRequest request)
var
rowcells
=
new
List
<
Cell
>
var
rowcells
=
new
List
<
Cell
>
{
{
new
Cell
{
CellType
=
"body"
,
CellValue
=
index
+
1
,
PointCell
=
0
,
MergeRow
=
1
,
MergeCell
=
1
},
new
Cell
{
CellType
=
"body"
,
CellValue
=
index
+
1
,
PointCell
=
0
,
MergeRow
=
1
,
MergeCell
=
1
},
new
Cell
{
CellType
=
"body"
,
CellValue
=
charge
.
Charge
,
PointCell
=
0
,
MergeRow
=
1
,
MergeCell
=
1
},
new
Cell
{
CellType
=
"body"
,
CellValue
=
charge
.
Charge
,
PointCell
=
1
,
MergeRow
=
1
,
MergeCell
=
1
},
new
Cell
{
CellType
=
"body"
,
CellValue
=
charge
.
ChargeType
,
PointCell
=
1
,
MergeRow
=
1
,
MergeCell
=
1
},
new
Cell
{
CellType
=
"body"
,
CellValue
=
charge
.
ChargeType
,
PointCell
=
2
,
MergeRow
=
1
,
MergeCell
=
1
},
};
};
int
i
=
0
;
int
i
=
1
;
foreach
(
var
model
in
models
)
foreach
(
var
model
in
models
)
{
{
var
modeldata
=
querydata
.
FirstOrDefault
(
t
=>
t
.
Charge
==
charge
.
Charge
&&
t
.
ChargeType
==
charge
.
ChargeType
&&
t
.
ExModuleId
==
model
.
Id
);
var
modeldata
=
querydata
.
FirstOrDefault
(
t
=>
t
.
Charge
==
charge
.
Charge
&&
t
.
ChargeType
==
charge
.
ChargeType
&&
t
.
ExModuleId
==
model
.
Id
);
int
j
=
1
;
int
j
=
0
;
foreach
(
var
column
in
defaultColumns
)
foreach
(
var
column
in
defaultColumns
)
{
{
rowcells
.
Add
(
new
Cell
rowcells
.
Add
(
new
Cell
{
{
CellType
=
"body"
,
CellType
=
"body"
,
CellValue
=
modeldata
==
null
?
null
:
fields
[
column
.
Value
].
Invoke
(
modeldata
),
CellValue
=
modeldata
==
null
?
null
:
fields
[
column
.
Value
].
Invoke
(
modeldata
),
PointCell
=
1
+
i
*
3
+
j
,
PointCell
=
i
*
3
+
j
,
MergeRow
=
1
,
MergeRow
=
1
,
MergeCell
=
1
MergeCell
=
1
});
});
...
...
performance/Performance.Services/ExtractExcelService/ExtractService.cs
View file @
90fbff9b
...
@@ -75,10 +75,10 @@ public string Main(int allotId, int hospitalId, string email, string groupName,
...
@@ -75,10 +75,10 @@ public string Main(int allotId, int hospitalId, string email, string groupName,
IWorkbook
workbook
=
null
;
IWorkbook
workbook
=
null
;
try
try
{
{
logService
.
ReturnTheLog
(
allotId
,
groupName
,
2
,
"等待提取"
,
$"确认配置信息是否可完成数据提取..."
,
1
,
isSingle
);
logService
.
ClearExtractLog
(
allotId
);
logService
.
ClearExtractLog
(
allotId
);
logService
.
ReturnTheLog
(
allotId
,
groupName
,
2
,
"等待提取"
,
$"确认配置信息是否可完成数据提取..."
,
1
,
isSingle
);
var
allots
=
perallotRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
hospitalId
);
var
allots
=
perallotRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
hospitalId
);
if
(
allots
==
null
||
!
allots
.
Any
(
t
=>
t
.
ID
==
allotId
))
throw
new
Exception
(
"绩效不存在"
);
if
(
allots
==
null
||
!
allots
.
Any
(
t
=>
t
.
ID
==
allotId
))
throw
new
Exception
(
"绩效不存在"
);
...
...
performance/Performance.Services/ExtractExcelService/QueryService.cs
View file @
90fbff9b
using
Dapper
;
using
Dapper
;
using
Microsoft.AspNetCore.Mvc.ViewFeatures
;
using
Microsoft.Extensions.Logging
;
using
Microsoft.Extensions.Logging
;
using
Performance.DtoModels
;
using
Performance.DtoModels
;
using
Performance.EntityModels
;
using
Performance.EntityModels
;
using
Performance.Infrastructure
;
using
Performance.Repository
;
using
Performance.Repository
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Data
;
using
System.Linq
;
using
System.Linq
;
using
System.Text
;
using
System.Text
;
using
System.Text.RegularExpressions
;
using
System.Text.RegularExpressions
;
...
@@ -191,36 +194,52 @@ private List<ex_result> ExtractModuleData(per_allot allot, string groupName, boo
...
@@ -191,36 +194,52 @@ private List<ex_result> ExtractModuleData(per_allot allot, string groupName, boo
logService
.
ReturnTheLog
(
allot
.
ID
,
groupName
,
3
,
""
,
ratio
>
20
?
20
:
ratio
,
1
,
isSingle
);
logService
.
ReturnTheLog
(
allot
.
ID
,
groupName
,
3
,
""
,
ratio
>
20
?
20
:
ratio
,
1
,
isSingle
);
logService
.
ReturnTheLog
(
allot
.
ID
,
groupName
,
2
,
"提取数据"
,
$"开始提取模块“
{
string
.
Join
(
"、"
,
thisModules
.
Select
(
t
=>
t
.
ModuleName
))}
”的数据"
,
1
,
isSingle
);
logService
.
ReturnTheLog
(
allot
.
ID
,
groupName
,
2
,
"提取数据"
,
$"开始提取模块“
{
string
.
Join
(
"、"
,
thisModules
.
Select
(
t
=>
t
.
ModuleName
))}
”的数据"
,
1
,
isSingle
);
Dictionary
<
int
,
IDbConnection
>
pools
=
new
Dictionary
<
int
,
IDbConnection
>();
foreach
(
var
script
in
scripts
.
Where
(
t
=>
t
.
TypeId
==
typeId
))
foreach
(
var
script
in
scripts
.
Where
(
t
=>
t
.
TypeId
==
typeId
))
{
{
var
config
=
configs
.
FirstOrDefault
(
t
=>
t
.
Id
==
script
.
ConfigId
)
??
configs
.
FirstOrDefault
(
t
=>
t
.
DataBaseType
==
script
.
DatabaseType
);
var
config
=
configs
.
FirstOrDefault
(
t
=>
t
.
Id
==
script
.
ConfigId
)
??
configs
.
FirstOrDefault
(
t
=>
t
.
DataBaseType
==
script
.
DatabaseType
);
if
(
config
==
null
)
continue
;
if
(
config
==
null
)
continue
;
var
querydata
=
QueryData
(
config
,
allot
,
script
.
ExecScript
);
try
if
(
querydata
!=
null
&&
querydata
.
Any
())
{
{
thisModules
.
ForEach
(
f
=>
if
(!
pools
.
ContainsKey
(
config
.
Id
))
pools
.
Add
(
config
.
Id
,
ConnectionBuilder
.
Create
((
DatabaseType
)
config
.
DataBaseType
,
config
.
DbSource
,
config
.
DbName
,
config
.
DbUser
,
config
.
DbPassword
));
IDbConnection
connection
=
pools
[
config
.
Id
];
var
parameters
=
GetParameters
(
allot
);
var
querydata
=
QueryData
(
connection
,
parameters
,
script
.
ExecScript
);
if
(
querydata
!=
null
&&
querydata
.
Any
())
{
{
var
result
=
querydata
.
Select
(
t
=>
new
ex_result
thisModules
.
ForEach
(
f
=>
{
{
Department
=
t
.
Department
,
var
result
=
querydata
.
Select
(
t
=>
new
ex_result
Category
=
t
.
Category
?.
Trim
(),
{
Fee
=
t
.
Value
,
Department
=
t
.
Department
,
DoctorName
=
t
.
DoctorName
,
Category
=
t
.
Category
?.
Trim
(),
PersonnelNumber
=
t
.
PersonnelNumber
,
Fee
=
t
.
Value
,
Source
=
f
.
ModuleName
,
DoctorName
=
t
.
DoctorName
,
DatabaseType
=
config
.
DataBaseType
,
PersonnelNumber
=
t
.
PersonnelNumber
,
ConfigId
=
config
.
Id
,
Source
=
f
.
ModuleName
,
AllotId
=
allot
.
ID
,
DatabaseType
=
config
.
DataBaseType
,
CreateTime
=
CreateTime
,
ConfigId
=
config
.
Id
,
}).
ToList
();
AllotId
=
allot
.
ID
,
exresultRepository
.
AddRange
(
result
.
ToArray
());
CreateTime
=
CreateTime
,
data
.
AddRange
(
result
);
}).
ToList
();
});
exresultRepository
.
AddRange
(
result
.
ToArray
());
data
.
AddRange
(
result
);
});
}
logService
.
ReturnTheLog
(
allot
.
ID
,
groupName
,
2
,
"提取数据"
,
$"模块“
{
string
.
Join
(
"、"
,
thisModules
.
Select
(
t
=>
t
.
ModuleName
))}
”的数据已完成提取"
,
1
,
isSingle
);
}
catch
(
Exception
)
{
logService
.
ReturnTheLog
(
allot
.
ID
,
groupName
,
2
,
"数据库连接"
,
$"数据库“
{
config
.
DbName
}
”连接失败"
,
3
,
isSingle
);
}
}
}
}
logService
.
ReturnTheLog
(
allot
.
ID
,
groupName
,
2
,
"提取数据"
,
$"模块“
{
string
.
Join
(
"、"
,
thisModules
.
Select
(
t
=>
t
.
ModuleName
))}
”的数据已完成提取"
,
1
,
isSingle
);
}
}
}
}
...
@@ -372,17 +391,30 @@ public IEnumerable<ExtractDto> QueryData(sys_hospitalconfig config, per_allot al
...
@@ -372,17 +391,30 @@ public IEnumerable<ExtractDto> QueryData(sys_hospitalconfig config, per_allot al
var
parameters
=
GetParameters
(
allot
);
var
parameters
=
GetParameters
(
allot
);
using
(
var
connection
=
ConnectionBuilder
.
Create
((
DatabaseType
)
config
.
DataBaseType
,
config
.
DbSource
,
config
.
DbName
,
config
.
DbUser
,
config
.
DbPassword
))
using
(
var
connection
=
ConnectionBuilder
.
Create
((
DatabaseType
)
config
.
DataBaseType
,
config
.
DbSource
,
config
.
DbName
,
config
.
DbUser
,
config
.
DbPassword
))
{
{
foreach
(
var
item
in
parameters
)
return
QueryData
(
connection
,
parameters
,
execsql
);
{
}
execsql
=
Regex
.
Replace
(
execsql
,
item
.
Key
,
item
.
Value
,
RegexOptions
.
IgnoreCase
);
}
}
/// <summary>
/// 查询数据
/// </summary>
/// <param name="config"></param>
/// <param name="allot"></param>
/// <param name="execsql"></param>
/// <param name="source"></param>
/// <param name="category"></param>
/// <returns></returns>
public
IEnumerable
<
ExtractDto
>
QueryData
(
IDbConnection
connection
,
Dictionary
<
string
,
string
>
parameters
,
string
execsql
)
{
foreach
(
var
item
in
parameters
)
{
execsql
=
Regex
.
Replace
(
execsql
,
item
.
Key
,
item
.
Value
,
RegexOptions
.
IgnoreCase
);
}
logger
.
LogInformation
(
$"提取绩效数据SQL脚本
{
execsql
}
"
);
logger
.
LogInformation
(
$"提取绩效数据SQL脚本
{
execsql
}
"
);
var
result
=
connection
.
Query
<
ExtractDto
>(
execsql
,
commandTimeout
:
20000
);
var
result
=
connection
.
Query
<
ExtractDto
>(
execsql
,
commandTimeout
:
20000
);
logger
.
LogInformation
(
$"提取绩效数据执行脚本获取数据
{
result
?.
Count
()
??
0
}
条记录"
);
logger
.
LogInformation
(
$"提取绩效数据执行脚本获取数据
{
result
?.
Count
()
??
0
}
条记录"
);
return
result
;
return
result
;
}
}
}
/// <summary>
/// <summary>
...
...
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