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
b932b898
Commit
b932b898
authored
Mar 09, 2020
by
lcx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
抽取修改
parent
123c69f4
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
79 additions
and
58 deletions
+79
-58
performance/Performance.Api/Controllers/TemplateController.cs
+8
-12
performance/Performance.Extract.Api/Controllers/ExtractController.cs
+42
-6
performance/Performance.Extract.Api/Template/东方医院绩效模板.xlsx
+0
-0
performance/Performance.Services/DFExtractService.cs
+25
-39
performance/Performance.Services/NewExtractService.cs
+4
-1
No files found.
performance/Performance.Api/Controllers/TemplateController.cs
View file @
b932b898
...
...
@@ -223,7 +223,7 @@ public ApiResponse NewExtractData([CustomizeValidator, FromBody]ExtractRequest r
// 判断是那种抽取
try
{
string
message
=
newExtractService
.
Judge
(
request
.
AllotId
,
request
.
HospitalId
,
request
.
UseScheme
);
string
message
=
newExtractService
.
Judge
(
request
.
AllotId
,
request
.
HospitalId
,
request
.
UseScheme
,
out
string
filePath
);
if
(!
string
.
IsNullOrEmpty
(
message
))
return
new
ApiResponse
(
ResponseType
.
Fail
,
message
);
...
...
@@ -233,18 +233,14 @@ public ApiResponse NewExtractData([CustomizeValidator, FromBody]ExtractRequest r
allot
.
IsExtracting
=
1
;
allotService
.
Update
(
allot
);
var
email
=
claim
.
GetUserClaim
(
JwtClaimTypes
.
Mail
);
request
.
Email
=
email
;
//if (request.UseScheme == (int)UseTemplate.Config)
//{
//request.Email = claim.GetUserClaim(JwtClaimTypes.Mail);
logger
.
LogInformation
(
"提取绩效数据请求路径:"
+
url
.
HttpPost
+
"/extract/extract"
);
HttpHelper
.
HttpPostNoRequest
(
url
.
HttpPost
+
"/extract/extract"
,
JsonHelper
.
Serialize
(
request
),
true
);
//}
//else
//{
// return new ApiResponse(ResponseType.Fail, "该功能暂未实现!"
);
//}
//
HttpHelper.HttpPostNoRequest(url.HttpPost + "/extract/extract", JsonHelper.Serialize(request), true);
if
(
string
.
IsNullOrEmpty
(
filePath
))
HttpHelper
.
HttpPostNoRequest
(
url
.
HttpPost
+
$"/extract/extract?allotId=
{
request
.
AllotId
}
&hospitalId=
{
request
.
HospitalId
}
&email=
{
claim
.
GetUserClaim
(
JwtClaimTypes
.
Mail
)}
"
,
""
);
else
HttpHelper
.
HttpClient
(
url
.
HttpPost
+
$"/extract/extract?allotId=
{
request
.
AllotId
}
&hospitalId=
{
request
.
HospitalId
}
&email=
{
claim
.
GetUserClaim
(
JwtClaimTypes
.
Mail
)}
"
,
filePath
);
return
new
ApiResponse
(
ResponseType
.
OK
,
"HIS绩效数据提取任务正在执行,稍后我们将以邮件的通知您!"
);
}
catch
(
Exception
ex
)
...
...
performance/Performance.Extract.Api/Controllers/ExtractController.cs
View file @
b932b898
...
...
@@ -118,14 +118,48 @@ public void Index([FromBody]AllotRequest request)
/// <returns></returns>
[
Route
(
"extract"
)]
[
HttpPost
]
public
void
ExtractData
([
CustomizeValidator
,
FromBody
]
ExtractRequest
request
)
public
void
ExtractData
([
FromForm
]
IFormCollection
form
,
int
allotId
,
int
hospitalId
,
string
email
)
{
logger
.
LogInformation
(
"提取绩效数据请求参数:"
+
JsonHelper
.
Serialize
(
request
));
//string filePath = newExtractService.ExtractData(request.AllotId, request.Email, request.HospitalId);
string
filePath
=
dfExtractService
.
ExtractData
(
request
.
AllotId
,
request
.
Email
,
request
.
HospitalId
);
logger
.
LogInformation
(
"提取绩效数据请求参数:"
+
JsonHelper
.
Serialize
(
new
{
allotId
,
hospitalId
,
email
}));
if
(
allotId
==
0
||
hospitalId
==
0
)
return
;
var
path
=
string
.
Empty
;
#
region
保存历史绩效文件
var
file
=
((
FormFileCollection
)
form
.
Files
).
FirstOrDefault
();
if
(
file
==
null
)
logger
.
LogInformation
(
$"文件为空!"
);
else
{
var
dpath
=
Path
.
Combine
(
evn
.
ContentRootPath
,
"Files"
,
"HospitalAllot"
,
$"
{
hospitalId
}
"
);
FileHelper
.
CreateDirectory
(
dpath
);
path
=
Path
.
Combine
(
dpath
,
FileHelper
.
GetFileName
(
file
.
FileName
));
logger
.
LogInformation
(
$"保存历史绩效文件保存路径:"
+
path
);
using
(
var
stream
=
file
.
OpenReadStream
())
{
byte
[]
bytes
=
new
byte
[
stream
.
Length
];
stream
.
Read
(
bytes
,
0
,
bytes
.
Length
);
if
(!
FileHelper
.
CreateFile
(
path
,
bytes
))
{
logger
.
LogInformation
(
$"保存历史绩效文件保存失败"
);
}
}
}
#
endregion
//string filePath = newExtractService.ExtractData(allotId, request.Email, hospitalId);
string
filePath
=
dfExtractService
.
ExtractData
(
allotId
,
email
,
hospitalId
,
path
);
//抽取
if
(!
string
.
IsNullOrEmpty
(
path
)
&&
FileHelper
.
IsExistFile
(
path
))
FileHelper
.
DeleteFile
(
path
);
#
region
保存文件到网站下
if
(!
string
.
IsNullOrEmpty
(
filePath
)
&&
FileHelper
.
IsExistFile
(
filePath
))
{
logger
.
LogInformation
(
"请求路径:"
+
url
.
ImportFile
+
",请求参数"
+
JsonHelper
.
Serialize
(
new
{
allotId
=
request
.
AllotId
,
hospitalId
=
request
.
H
ospitalId
}));
logger
.
LogInformation
(
"请求路径:"
+
url
.
ImportFile
+
",请求参数"
+
JsonHelper
.
Serialize
(
new
{
allotId
,
h
ospitalId
}));
int
i
=
1
;
while
(
i
<=
5
)
{
...
...
@@ -135,7 +169,7 @@ public void ExtractData([CustomizeValidator, FromBody]ExtractRequest request)
logger
.
LogInformation
(
$"正在尝试第
{
i
}
次保存!"
);
//保存文件
string
retJson
=
HttpHelper
.
HttpClient
(
url
.
ImportFile
+
$"?allotId=
{
request
.
AllotId
}
&hospitalId=
{
request
.
H
ospitalId
}
"
,
filePath
);
string
retJson
=
HttpHelper
.
HttpClient
(
url
.
ImportFile
+
$"?allotId=
{
allotId
}
&hospitalId=
{
h
ospitalId
}
"
,
filePath
);
logger
.
LogInformation
(
"保存提取文件返回结果:"
+
JsonHelper
.
Serialize
(
retJson
));
logger
.
LogInformation
(
retJson
);
var
ret
=
JsonHelper
.
Deserialize
<
ApiResponse
>(
retJson
);
...
...
@@ -149,6 +183,8 @@ public void ExtractData([CustomizeValidator, FromBody]ExtractRequest request)
}
else
logger
.
LogInformation
(
$"保存提取文件提取文件不存在!"
);
#
endregion
}
#
endregion
...
...
performance/Performance.Extract.Api/Template/东方医院绩效模板.xlsx
View file @
b932b898
No preview for this file type
performance/Performance.Services/DFExtractService.cs
View file @
b932b898
...
...
@@ -82,12 +82,14 @@ public class DFExtractService : IAutoInjection
#
region
抽取
public
string
ExtractData
(
int
allotId
,
string
email
,
int
hospitalId
)
public
string
ExtractData
(
int
allotId
,
string
email
,
int
hospitalId
,
string
filePath
=
null
)
{
var
hospital
=
perforHospitalRepository
.
GetEntity
(
t
=>
t
.
ID
==
hospitalId
);
try
{
var
allot
=
perforPerallotRepository
.
GetEntity
(
t
=>
t
.
ID
==
allotId
);
Allot
=
allot
??
throw
new
PerformanceException
(
""
);
var
hospital
=
perforHospitalRepository
.
GetEntity
(
t
=>
t
.
ID
==
hospitalId
);
var
configs
=
perforHospitalconfigRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
hospitalId
);
var
statesArray
=
new
int
[]
{
(
int
)
AllotStates
.
GenerateSucceed
,
(
int
)
AllotStates
.
Archive
};
...
...
@@ -112,7 +114,23 @@ public string ExtractData(int allotId, string email, int hospitalId)
extractIds
=
extractIds
.
Distinct
().
ToList
();
var
extracts
=
perforModextractRepository
.
GetEntities
(
t
=>
extractIds
.
Contains
(
t
.
Id
));
return
lastAllot
==
null
?
TemplateExecute
(
email
,
lastAllot
,
hospital
,
configs
,
modules
,
items
,
specials
,
extracts
)
:
AlllotExecute
(
email
,
lastAllot
,
hospital
,
configs
,
modules
,
items
,
specials
,
extracts
);
return
lastAllot
==
null
?
TemplateExecute
(
email
,
lastAllot
,
hospital
,
configs
,
modules
,
items
,
specials
,
extracts
)
:
AlllotExecute
(
email
,
lastAllot
,
hospital
,
configs
,
modules
,
items
,
specials
,
extracts
,
filePath
);
}
catch
(
Exception
ex
)
{
logManageService
.
WriteMsg
(
"提取数据异常"
,
$"数据写入出现异常"
,
4
,
Allot
.
ID
,
"ReceiveMessage"
);
logger
.
LogError
(
$"提取绩效数据异常 数据写入出现异常
{
ex
.
ToString
()}
"
);
SendEmail
(
email
,
""
,
$"
{
hospital
.
HosName
}
HIS数据提取失败"
,
$"
{
hospital
.
HosName
}
提取数据过程中出现异常情况,我们将尽快解决问题。给您带来的不便我们深感歉意!"
);
throw
ex
;
}
finally
{
Allot
.
IsExtracting
=
null
;
perforPerallotRepository
.
Update
(
Allot
);
if
(
workbook
!=
null
)
workbook
.
Close
();
GC
.
Collect
();
}
}
/// <summary>
...
...
@@ -129,8 +147,6 @@ public string ExtractData(int allotId, string email, int hospitalId)
/// <returns></returns>
public
string
TemplateExecute
(
string
email
,
per_allot
lastAllot
,
sys_hospital
hospital
,
List
<
sys_hospitalconfig
>
configs
,
List
<
mod_module
>
modules
,
List
<
mod_item
>
items
,
List
<
mod_special
>
specials
,
List
<
mod_extract
>
extracts
)
{
try
{
string
originalPath
=
Path
.
Combine
(
AppDomain
.
CurrentDomain
.
BaseDirectory
,
"Template"
,
"东方医院绩效模板.xlsx"
);
var
(
tempPath
,
newPath
)
=
CopyOriginalFile
(
hospital
.
ID
,
originalPath
);
workbook
=
new
XSSFWorkbook
(
tempPath
);
...
...
@@ -178,21 +194,6 @@ public string TemplateExecute(string email, per_allot lastAllot, sys_hospital ho
SendEmail
(
email
,
newPath
,
$"
{
hospital
.
HosName
}
HIS数据提取成功"
,
$"
{
hospital
.
HosName
}
在
{
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)}
成功提取。"
);
return
newPath
;
}
catch
(
Exception
ex
)
{
logManageService
.
WriteMsg
(
"提取数据异常"
,
$"数据写入出现异常"
,
4
,
Allot
.
ID
,
"ReceiveMessage"
);
logger
.
LogError
(
$"提取绩效数据异常 数据写入出现异常
{
ex
.
ToString
()}
"
);
SendEmail
(
email
,
""
,
$"
{
hospital
.
HosName
}
HIS数据提取失败"
,
$"
{
hospital
.
HosName
}
提取数据过程中出现异常情况,我们将尽快解决问题。给您带来的不便我们深感歉意!"
);
throw
ex
;
}
finally
{
Allot
.
IsExtracting
=
null
;
perforPerallotRepository
.
Update
(
Allot
);
workbook
.
Close
();
GC
.
Collect
();
}
}
/// <summary>
/// 历史绩效为模板
...
...
@@ -206,11 +207,11 @@ public string TemplateExecute(string email, per_allot lastAllot, sys_hospital ho
/// <param name="specials"></param>
/// <param name="extracts"></param>
/// <returns></returns>
public
string
AlllotExecute
(
string
email
,
per_allot
lastAllot
,
sys_hospital
hospital
,
List
<
sys_hospitalconfig
>
configs
,
List
<
mod_module
>
modules
,
List
<
mod_item
>
items
,
List
<
mod_special
>
specials
,
List
<
mod_extract
>
extracts
)
{
try
public
string
AlllotExecute
(
string
email
,
per_allot
lastAllot
,
sys_hospital
hospital
,
List
<
sys_hospitalconfig
>
configs
,
List
<
mod_module
>
modules
,
List
<
mod_item
>
items
,
List
<
mod_special
>
specials
,
List
<
mod_extract
>
extracts
,
string
path
)
{
var
(
tempPath
,
newPath
)
=
CopyOriginalFile
(
hospital
.
ID
,
lastAllot
.
Path
);
if
(
string
.
IsNullOrEmpty
(
path
))
throw
new
PerformanceException
(
"历史绩效文件不存在!"
);
var
(
tempPath
,
newPath
)
=
CopyOriginalFile
(
hospital
.
ID
,
path
);
workbook
=
new
XSSFWorkbook
(
tempPath
);
CreateNotExistSheet
(
modules
,
workbook
);
...
...
@@ -261,21 +262,6 @@ public string AlllotExecute(string email, per_allot lastAllot, sys_hospital hosp
SendEmail
(
email
,
newPath
,
$"
{
hospital
.
HosName
}
HIS数据提取成功"
,
$"
{
hospital
.
HosName
}
在
{
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)}
成功提取。"
);
return
newPath
;
}
catch
(
Exception
ex
)
{
logManageService
.
WriteMsg
(
"提取数据异常"
,
$"数据写入出现异常"
,
4
,
Allot
.
ID
,
"ReceiveMessage"
);
logger
.
LogError
(
$"提取绩效数据 异常 数据写入出现异常
{
ex
.
ToString
()}
"
);
SendEmail
(
email
,
""
,
$"
{
hospital
.
HosName
}
HIS数据提取失败"
,
$"
{
hospital
.
HosName
}
提取数据过程中出现异常情况,我们将尽快解决问题。给您带来的不便我们深感歉意!"
);
throw
ex
;
}
finally
{
Allot
.
IsExtracting
=
null
;
perforPerallotRepository
.
Update
(
Allot
);
workbook
.
Close
();
GC
.
Collect
();
}
}
#
endregion
...
...
performance/Performance.Services/NewExtractService.cs
View file @
b932b898
...
...
@@ -888,9 +888,10 @@ public void OutToExcelCell(ICell cell, object obj)
/// <param name="allotId"></param>
/// <param name="hospitalId"></param>
/// <param name="useTemplate"></param>
public
string
Judge
(
int
allotId
,
int
hospitalId
,
int
useTemplate
)
public
string
Judge
(
int
allotId
,
int
hospitalId
,
int
useTemplate
,
out
string
filePath
)
{
string
result
=
null
;
filePath
=
""
;
try
{
// 获取绩效信息
...
...
@@ -909,6 +910,8 @@ public string Judge(int allotId, int hospitalId, int useTemplate)
var
statesArray
=
new
int
[]
{
(
int
)
AllotStates
.
GenerateSucceed
,
(
int
)
AllotStates
.
Archive
};
var
allotList
=
perforPerallotRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
hospitalId
&&
statesArray
.
Contains
(
t
.
States
));
var
allotLast
=
allotList
?.
OrderByDescending
(
t
=>
t
.
Year
).
ThenByDescending
(
t
=>
t
.
Month
).
First
();
if
(
allotLast
!=
null
)
filePath
=
allotLast
.
Path
;
// 获取当前医院模版信息
var
modulesList
=
perforModmoduleRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
hospitalId
);
if
(
modulesList
==
null
||
modulesList
.
Count
==
0
)
...
...
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