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
873936cb
Commit
873936cb
authored
Jul 19, 2019
by
799284587@qq.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
取消抽取数据上传下载TOKEN验证
parent
b4cd4e2b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
32 deletions
+41
-32
performance/Performance.Api/Controllers/TemplateController.cs
+34
-19
performance/Performance.Services/ExtractService.cs
+7
-13
No files found.
performance/Performance.Api/Controllers/TemplateController.cs
View file @
873936cb
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
using
Microsoft.AspNetCore.Http.Internal
;
using
Microsoft.AspNetCore.Http.Internal
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.AspNetCore.StaticFiles
;
using
Microsoft.AspNetCore.StaticFiles
;
using
Microsoft.Extensions.Logging
;
using
Microsoft.Extensions.Options
;
using
Microsoft.Extensions.Options
;
using
Performance.DtoModels
;
using
Performance.DtoModels
;
using
Performance.DtoModels.AppSettings
;
using
Performance.DtoModels.AppSettings
;
...
@@ -29,6 +30,8 @@ public class TemplateController : Controller
...
@@ -29,6 +30,8 @@ public class TemplateController : Controller
private
Application
application
;
private
Application
application
;
private
WebapiUrl
url
;
private
WebapiUrl
url
;
private
readonly
AllotService
allotService
;
private
readonly
AllotService
allotService
;
private
readonly
ILogger
<
ExceptionsFilter
>
logger
;
public
TemplateController
(
TemplateService
templateService
,
public
TemplateController
(
TemplateService
templateService
,
HospitalService
hospitalService
,
HospitalService
hospitalService
,
ExtractService
extractService
,
ExtractService
extractService
,
...
@@ -36,7 +39,8 @@ public class TemplateController : Controller
...
@@ -36,7 +39,8 @@ public class TemplateController : Controller
ClaimService
claim
,
ClaimService
claim
,
IOptions
<
Application
>
options
,
IOptions
<
Application
>
options
,
IOptions
<
WebapiUrl
>
url
,
IOptions
<
WebapiUrl
>
url
,
AllotService
allotService
)
AllotService
allotService
,
ILogger
<
ExceptionsFilter
>
logger
)
{
{
this
.
templateService
=
templateService
;
this
.
templateService
=
templateService
;
this
.
extractService
=
extractService
;
this
.
extractService
=
extractService
;
...
@@ -46,6 +50,7 @@ public class TemplateController : Controller
...
@@ -46,6 +50,7 @@ public class TemplateController : Controller
this
.
application
=
options
.
Value
;
this
.
application
=
options
.
Value
;
this
.
url
=
url
.
Value
;
this
.
url
=
url
.
Value
;
this
.
allotService
=
allotService
;
this
.
allotService
=
allotService
;
this
.
logger
=
logger
;
}
}
/// <summary>
/// <summary>
...
@@ -166,6 +171,7 @@ public ApiResponse ExtractData([CustomizeValidator(RuleSet = "Template"), FromBo
...
@@ -166,6 +171,7 @@ public ApiResponse ExtractData([CustomizeValidator(RuleSet = "Template"), FromBo
/// </summary>
/// </summary>
/// <returns></returns>
/// <returns></returns>
[
Route
(
"down"
)]
[
Route
(
"down"
)]
[
NoVerify
]
public
IActionResult
DownFile
([
FromQuery
]
AllotRequest
request
)
public
IActionResult
DownFile
([
FromQuery
]
AllotRequest
request
)
{
{
var
allot
=
allotService
.
GetAllot
(
request
.
ID
);
var
allot
=
allotService
.
GetAllot
(
request
.
ID
);
...
@@ -193,31 +199,39 @@ public IActionResult DownFile([FromQuery]AllotRequest request)
...
@@ -193,31 +199,39 @@ public IActionResult DownFile([FromQuery]AllotRequest request)
/// <returns></returns>
/// <returns></returns>
[
Route
(
"savefile"
)]
[
Route
(
"savefile"
)]
[
HttpPost
]
[
HttpPost
]
[
NoVerify
]
public
ApiResponse
SaveFile
([
FromForm
]
IFormCollection
form
,
int
allotId
,
int
hospitalId
)
public
ApiResponse
SaveFile
([
FromForm
]
IFormCollection
form
,
int
allotId
,
int
hospitalId
)
{
{
var
file
=
((
FormFileCollection
)
form
.
Files
).
FirstOrDefault
();
logger
.
LogInformation
(
$"保存提取文件 参数:allotId:
{
allotId
}
hospitalId:
{
hospitalId
}
"
);
if
(
file
==
null
)
try
return
new
ApiResponse
(
ResponseType
.
Error
,
"上传文件无效"
);
{
var
file
=
((
FormFileCollection
)
form
.
Files
).
FirstOrDefault
();
if
(
file
==
null
)
return
new
ApiResponse
(
ResponseType
.
Error
,
"上传文件无效"
);
var
dpath
=
Path
.
Combine
(
evn
.
ContentRootPath
,
"Files"
,
$"
{
hospitalId
}
"
,
"autoextract"
);
var
dpath
=
Path
.
Combine
(
evn
.
ContentRootPath
,
"Files"
,
$"
{
hospitalId
}
"
,
"autoextract"
);
FileHelper
.
CreateDirectory
(
dpath
);
FileHelper
.
CreateDirectory
(
dpath
);
var
path
=
Path
.
Combine
(
dpath
,
FileHelper
.
GetFileName
(
file
.
FileName
));
var
path
=
Path
.
Combine
(
dpath
,
FileHelper
.
GetFileName
(
file
.
FileName
));
using
(
var
stream
=
file
.
OpenReadStream
())
using
(
var
stream
=
file
.
OpenReadStream
())
{
byte
[]
bytes
=
new
byte
[
stream
.
Length
];
stream
.
Read
(
bytes
,
0
,
bytes
.
Length
);
if
(!
FileHelper
.
CreateFile
(
path
,
bytes
))
return
new
ApiResponse
(
ResponseType
.
Error
,
"保存失败"
);
}
var
allot
=
allotService
.
GetAllot
(
allotId
);
allot
.
ExtractPath
=
path
;
allot
.
IsExtracting
=
2
;
if
(!
string
.
IsNullOrEmpty
(
path
)
&&
allotService
.
Update
(
allot
))
return
new
ApiResponse
(
ResponseType
.
OK
,
"上传成功!"
);
}
catch
(
Exception
ex
)
{
{
byte
[]
bytes
=
new
byte
[
stream
.
Length
];
logger
.
LogInformation
(
$"保存提取文件异常
{
ex
.
ToString
()}
"
);
stream
.
Read
(
bytes
,
0
,
bytes
.
Length
);
if
(!
FileHelper
.
CreateFile
(
path
,
bytes
))
return
new
ApiResponse
(
ResponseType
.
Error
,
"保存失败"
);
}
}
var
allot
=
allotService
.
GetAllot
(
allotId
);
return
new
ApiResponse
(
ResponseType
.
Error
);
allot
.
ExtractPath
=
path
;
allot
.
IsExtracting
=
2
;
if
(!
string
.
IsNullOrEmpty
(
path
)
&&
allotService
.
Update
(
allot
))
return
new
ApiResponse
(
ResponseType
.
OK
,
"上传成功!"
);
else
return
new
ApiResponse
(
ResponseType
.
Error
);
}
}
}
}
}
}
\ No newline at end of file
performance/Performance.Services/ExtractService.cs
View file @
873936cb
...
@@ -105,7 +105,7 @@ public string ExtractData(int allotId, string mail, sys_hospital hospital, strin
...
@@ -105,7 +105,7 @@ public string ExtractData(int allotId, string mail, sys_hospital hospital, strin
{
{
LogHelper
.
Information
(
$"开始执行绩效数据提取任务
{
new
{
allotId
,
mail
,
hospital
}}
"
,
"提取绩效数据"
);
LogHelper
.
Information
(
$"开始执行绩效数据提取任务
{
new
{
allotId
,
mail
,
hospital
}}
"
,
"提取绩效数据"
);
List
<
PerSheet
>
sheetList
=
new
List
<
PerSheet
>();
List
<
PerSheet
>
sheetList
=
new
List
<
PerSheet
>();
string
filepath
=
""
;
try
try
{
{
var
allotList
=
perforPerallotRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
hospital
.
ID
);
var
allotList
=
perforPerallotRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
hospital
.
ID
);
...
@@ -157,7 +157,7 @@ public string ExtractData(int allotId, string mail, sys_hospital hospital, strin
...
@@ -157,7 +157,7 @@ public string ExtractData(int allotId, string mail, sys_hospital hospital, strin
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
,
allotList
.
First
(
t
=>
t
.
ID
==
allotId
),
out
string
filepath
))
if
(
WriteExcel
(
path
,
originalPath
,
sheetList
,
hospitalConfig
,
hospital
.
ID
,
allotList
.
First
(
t
=>
t
.
ID
==
allotId
),
out
filepath
))
{
{
LogHelper
.
Information
(
$"基础数据提取完成,文件保存成功
{
filepath
}
"
,
"提取绩效数据"
);
LogHelper
.
Information
(
$"基础数据提取完成,文件保存成功
{
filepath
}
"
,
"提取绩效数据"
);
//var allot = allotList.First(t => t.ID == allotId);
//var allot = allotList.First(t => t.ID == allotId);
...
@@ -166,36 +166,30 @@ public string ExtractData(int allotId, string mail, sys_hospital hospital, strin
...
@@ -166,36 +166,30 @@ public string ExtractData(int allotId, string mail, sys_hospital hospital, strin
// perforPerallotRepository.Update(allot);
// perforPerallotRepository.Update(allot);
SendEmail
(
mail
,
filepath
,
$"
{
hospital
.
HosName
}
HIS数据提取成功"
,
$"
{
hospital
.
HosName
}
在
{
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)}
成功提取。"
);
SendEmail
(
mail
,
filepath
,
$"
{
hospital
.
HosName
}
HIS数据提取成功"
,
$"
{
hospital
.
HosName
}
在
{
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)}
成功提取。"
);
return
filepath
;
}
}
return
""
;
}
}
catch
(
PerformanceException
ex
)
catch
(
PerformanceException
ex
)
{
{
logger
.
LogError
(
ex
.
ToString
());
logger
.
LogError
(
ex
.
ToString
());
LogHelper
.
Error
(
ex
.
ToString
(),
"提取绩效数据"
,
"异常"
);
LogHelper
.
Error
(
ex
.
ToString
(),
"提取绩效数据"
,
"异常"
);
SendEmail
(
mail
,
""
,
$"
{
hospital
.
HosName
}
HIS数据提取失败"
,
$"
{
hospital
.
HosName
}
提取数据失败,
{
ex
.
Message
}
!"
);
SendEmail
(
mail
,
""
,
$"
{
hospital
.
HosName
}
HIS数据提取失败"
,
$"
{
hospital
.
HosName
}
提取数据失败,
{
ex
.
Message
}
!"
);
var
allot
=
perforPerallotRepository
.
GetEntity
(
t
=>
t
.
ID
==
allotId
);
if
(
allot
!=
null
)
{
allot
.
IsExtracting
=
3
;
perforPerallotRepository
.
Update
(
allot
);
}
throw
ex
;
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
logger
.
LogError
(
ex
.
ToString
());
logger
.
LogError
(
ex
.
ToString
());
LogHelper
.
Error
(
ex
.
ToString
(),
"提取绩效数据"
,
"异常"
);
LogHelper
.
Error
(
ex
.
ToString
(),
"提取绩效数据"
,
"异常"
);
SendEmail
(
mail
,
""
,
$"
{
hospital
.
HosName
}
HIS数据提取失败"
,
$"
{
hospital
.
HosName
}
提取数据过程中出现异常情况,我们将尽快解决问题。给您带来的不便我们深感歉意!"
);
SendEmail
(
mail
,
""
,
$"
{
hospital
.
HosName
}
HIS数据提取失败"
,
$"
{
hospital
.
HosName
}
提取数据过程中出现异常情况,我们将尽快解决问题。给您带来的不便我们深感歉意!"
);
}
finally
{
var
allot
=
perforPerallotRepository
.
GetEntity
(
t
=>
t
.
ID
==
allotId
);
var
allot
=
perforPerallotRepository
.
GetEntity
(
t
=>
t
.
ID
==
allotId
);
if
(
allot
!=
null
)
if
(
allot
!=
null
)
{
{
allot
.
IsExtracting
=
3
;
allot
.
IsExtracting
=
null
;
perforPerallotRepository
.
Update
(
allot
);
perforPerallotRepository
.
Update
(
allot
);
}
}
throw
ex
;
}
}
return
filepath
;
}
}
/// <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