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
8f813702
Commit
8f813702
authored
Jun 17, 2019
by
799284587@qq.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sql带入参数
parent
15e62c9a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
8 deletions
+24
-8
performance/Performance.Api/Controllers/TemplateController.cs
+2
-2
performance/Performance.Services/ExtractService.cs
+22
-6
No files found.
performance/Performance.Api/Controllers/TemplateController.cs
View file @
8f813702
...
@@ -116,8 +116,8 @@ public ApiResponse ExtractData([CustomizeValidator(RuleSet = "Template"), FromBo
...
@@ -116,8 +116,8 @@ public ApiResponse ExtractData([CustomizeValidator(RuleSet = "Template"), FromBo
return
new
ApiResponse
(
ResponseType
.
Fail
,
"医院无效"
);
return
new
ApiResponse
(
ResponseType
.
Fail
,
"医院无效"
);
var
user
=
claim
.
At
(
request
.
Token
);
var
user
=
claim
.
At
(
request
.
Token
);
//
extractService.ExtractData(request.ID, user.Mail, hospital);
extractService
.
ExtractData
(
request
.
ID
,
user
.
Mail
,
hospital
);
BackgroundJob
.
Enqueue
(()
=>
extractService
.
ExtractData
(
request
.
ID
,
user
.
Mail
,
hospital
));
//
BackgroundJob.Enqueue(() => extractService.ExtractData(request.ID, user.Mail, hospital));
return
new
ApiResponse
(
ResponseType
.
OK
,
"HIS绩效数据提取任务正在执行,稍后我们将以邮件的通知您!"
);
return
new
ApiResponse
(
ResponseType
.
OK
,
"HIS绩效数据提取任务正在执行,稍后我们将以邮件的通知您!"
);
}
}
...
...
performance/Performance.Services/ExtractService.cs
View file @
8f813702
...
@@ -109,10 +109,9 @@ public void ExtractData(int allotId, string mail, sys_hospital hospital)
...
@@ -109,10 +109,9 @@ public void ExtractData(int allotId, string mail, sys_hospital hospital)
{
{
LogHelper
.
Information
(
$"当前绩效为非首次提取,从数据库中获取信息"
,
"提取绩效数据"
);
LogHelper
.
Information
(
$"当前绩效为非首次提取,从数据库中获取信息"
,
"提取绩效数据"
);
//非首次 从数据库中获取人员信息,SHEET页信息,列头信息
//非首次 从数据库中获取人员信息,SHEET页信息,列头信息
allotList
=
allotList
.
Where
(
t
=>
t
.
Path
!=
null
&&
t
.
Path
!=
""
).
ToList
();
if
(
allotList
.
Any
(
t
=>
t
.
Path
!=
null
&&
t
.
Path
!=
""
))
if
(
allotList
!=
null
&&
allotList
.
Count
>
0
)
{
{
var
allot
=
allotList
.
OrderByDescending
(
t
=>
t
.
Year
).
ThenByDescending
(
t
=>
t
.
Month
).
First
();
var
allot
=
allotList
.
Where
(
t
=>
t
.
Path
!=
null
&&
t
.
Path
!=
""
).
OrderByDescending
(
t
=>
t
.
Year
).
ThenByDescending
(
t
=>
t
.
Month
).
First
();
sheetList
=
GetRepositoryData
(
allot
.
ID
);
sheetList
=
GetRepositoryData
(
allot
.
ID
);
originalPath
=
allot
.
Path
;
originalPath
=
allot
.
Path
;
}
}
...
@@ -127,10 +126,10 @@ public void ExtractData(int allotId, string mail, sys_hospital hospital)
...
@@ -127,10 +126,10 @@ public void ExtractData(int allotId, string mail, sys_hospital hospital)
FileHelper
.
CreateDirectory
(
dpath
);
FileHelper
.
CreateDirectory
(
dpath
);
string
path
=
Path
.
Combine
(
dpath
,
$"绩效数据
{
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmssfff"
)}
.xlsx"
);
string
path
=
Path
.
Combine
(
dpath
,
$"绩效数据
{
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmssfff"
)}
.xlsx"
);
//根据SHEET页信息,列头信息,创建EXCEL文件
//根据SHEET页信息,列头信息,创建EXCEL文件
if
(
WriteExcel
(
path
,
originalPath
,
sheetList
,
hospitalConfig
,
hospital
.
ID
,
out
string
filepath
))
if
(
WriteExcel
(
path
,
originalPath
,
sheetList
,
hospitalConfig
,
hospital
.
ID
,
allotList
.
First
(
t
=>
t
.
ID
==
allotId
),
out
string
filepath
))
{
{
LogHelper
.
Information
(
$"基础数据提取完成,文件保存成功
{
filepath
}
"
,
"提取绩效数据"
);
LogHelper
.
Information
(
$"基础数据提取完成,文件保存成功
{
filepath
}
"
,
"提取绩效数据"
);
var
allot
=
perforPerallotRepository
.
GetEntity
(
t
=>
t
.
ID
==
allotId
);
var
allot
=
allotList
.
First
(
t
=>
t
.
ID
==
allotId
);
allot
.
ExtractPath
=
filepath
;
allot
.
ExtractPath
=
filepath
;
if
(!
string
.
IsNullOrEmpty
(
filepath
))
if
(!
string
.
IsNullOrEmpty
(
filepath
))
perforPerallotRepository
.
Update
(
allot
);
perforPerallotRepository
.
Update
(
allot
);
...
@@ -183,7 +182,7 @@ private void SendEmail(string mail, string path, string subject, string body)
...
@@ -183,7 +182,7 @@ private void SendEmail(string mail, string path, string subject, string body)
/// <param name="sheetList"></param>
/// <param name="sheetList"></param>
/// <param name="hospitalConfig"></param>
/// <param name="hospitalConfig"></param>
/// <param name="hospitalId"></param>
/// <param name="hospitalId"></param>
private
bool
WriteExcel
(
string
newpath
,
string
originalPath
,
List
<
PerSheet
>
sheetList
,
sys_hospitalconfig
hospitalConfig
,
int
hospitalId
,
out
string
filepath
)
private
bool
WriteExcel
(
string
newpath
,
string
originalPath
,
List
<
PerSheet
>
sheetList
,
sys_hospitalconfig
hospitalConfig
,
int
hospitalId
,
per_allot
allot
,
out
string
filepath
)
{
{
LogHelper
.
Information
(
$"开始向EXCEL中写入数据,"
,
"提取绩效数据"
);
LogHelper
.
Information
(
$"开始向EXCEL中写入数据,"
,
"提取绩效数据"
);
if
(
string
.
IsNullOrEmpty
(
originalPath
))
if
(
string
.
IsNullOrEmpty
(
originalPath
))
...
@@ -323,6 +322,7 @@ private bool WriteExcel(string newpath, string originalPath, List<PerSheet> shee
...
@@ -323,6 +322,7 @@ private bool WriteExcel(string newpath, string originalPath, List<PerSheet> shee
var
script
=
scriptList
.
First
(
t
=>
sheet
.
SheetName
.
Contains
(
t
.
SheetName
));
var
script
=
scriptList
.
First
(
t
=>
sheet
.
SheetName
.
Contains
(
t
.
SheetName
));
if
(!
string
.
IsNullOrEmpty
(
script
.
ExecuteScript
))
if
(!
string
.
IsNullOrEmpty
(
script
.
ExecuteScript
))
{
{
script
.
ExecuteScript
=
ReplaceParameter
(
script
.
ExecuteScript
,
allot
);
LogHelper
.
Information
(
$"SQL脚本
{
script
.
ExecuteScript
}
,"
,
"提取绩效数据"
);
LogHelper
.
Information
(
$"SQL脚本
{
script
.
ExecuteScript
}
,"
,
"提取绩效数据"
);
var
children
=
new
List
<
PerHeader
>();
var
children
=
new
List
<
PerHeader
>();
foreach
(
var
item
in
sheet
.
PerHeader
?.
Select
(
t
=>
t
.
Children
))
foreach
(
var
item
in
sheet
.
PerHeader
?.
Select
(
t
=>
t
.
Children
))
...
@@ -407,6 +407,22 @@ private bool WriteExcel(string newpath, string originalPath, List<PerSheet> shee
...
@@ -407,6 +407,22 @@ private bool WriteExcel(string newpath, string originalPath, List<PerSheet> shee
}
}
/// <summary>
/// <summary>
/// 替换SQL参数
/// </summary>
/// <param name="executeScript"></param>
/// <param name="allot"></param>
/// <returns></returns>
private
string
ReplaceParameter
(
string
executeScript
,
per_allot
allot
)
{
var
basicTime
=
new
DateTime
(
allot
.
Year
,
allot
.
Month
,
1
);
string
beginTime
=
basicTime
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
);
string
endTime
=
basicTime
.
AddMonths
(
1
).
AddSeconds
(-
1
).
ToString
(
"yyyy-MM-dd HH:mm:ss"
);
executeScript
=
Regex
.
Replace
(
executeScript
,
"@beginTime"
,
$"'
{
beginTime
}
'"
,
RegexOptions
.
IgnoreCase
);
executeScript
=
Regex
.
Replace
(
executeScript
,
"@endTime"
,
$"'
{
endTime
}
'"
,
RegexOptions
.
IgnoreCase
);
return
executeScript
;
}
/// <summary>
/// 从数据库中获取sheet及列头
/// 从数据库中获取sheet及列头
/// </summary>
/// </summary>
/// <param name="allotId"></param>
/// <param name="allotId"></param>
...
...
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