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
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
175 additions
and
154 deletions
+175
-154
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
+121
-135
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
...
@@ -223,7 +223,7 @@ public ApiResponse NewExtractData([CustomizeValidator, FromBody]ExtractRequest r
// 判断是那种抽取
// 判断是那种抽取
try
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
))
if
(!
string
.
IsNullOrEmpty
(
message
))
return
new
ApiResponse
(
ResponseType
.
Fail
,
message
);
return
new
ApiResponse
(
ResponseType
.
Fail
,
message
);
...
@@ -233,18 +233,14 @@ public ApiResponse NewExtractData([CustomizeValidator, FromBody]ExtractRequest r
...
@@ -233,18 +233,14 @@ public ApiResponse NewExtractData([CustomizeValidator, FromBody]ExtractRequest r
allot
.
IsExtracting
=
1
;
allot
.
IsExtracting
=
1
;
allotService
.
Update
(
allot
);
allotService
.
Update
(
allot
);
//request.Email = claim.GetUserClaim(JwtClaimTypes.Mail);
var
email
=
claim
.
GetUserClaim
(
JwtClaimTypes
.
Mail
);
request
.
Email
=
email
;
//if (request.UseScheme == (int)UseTemplate.Config)
//{
logger
.
LogInformation
(
"提取绩效数据请求路径:"
+
url
.
HttpPost
+
"/extract/extract"
);
logger
.
LogInformation
(
"提取绩效数据请求路径:"
+
url
.
HttpPost
+
"/extract/extract"
);
HttpHelper
.
HttpPostNoRequest
(
url
.
HttpPost
+
"/extract/extract"
,
JsonHelper
.
Serialize
(
request
),
true
);
//
HttpHelper.HttpPostNoRequest(url.HttpPost + "/extract/extract", JsonHelper.Serialize(request), true);
//}
if
(
string
.
IsNullOrEmpty
(
filePath
))
//else
HttpHelper
.
HttpPostNoRequest
(
url
.
HttpPost
+
$"/extract/extract?allotId=
{
request
.
AllotId
}
&hospitalId=
{
request
.
HospitalId
}
&email=
{
claim
.
GetUserClaim
(
JwtClaimTypes
.
Mail
)}
"
,
""
);
//{
else
// return new ApiResponse(ResponseType.Fail, "该功能暂未实现!"
);
HttpHelper
.
HttpClient
(
url
.
HttpPost
+
$"/extract/extract?allotId=
{
request
.
AllotId
}
&hospitalId=
{
request
.
HospitalId
}
&email=
{
claim
.
GetUserClaim
(
JwtClaimTypes
.
Mail
)}
"
,
filePath
);
//}
return
new
ApiResponse
(
ResponseType
.
OK
,
"HIS绩效数据提取任务正在执行,稍后我们将以邮件的通知您!"
);
return
new
ApiResponse
(
ResponseType
.
OK
,
"HIS绩效数据提取任务正在执行,稍后我们将以邮件的通知您!"
);
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
...
...
performance/Performance.Extract.Api/Controllers/ExtractController.cs
View file @
b932b898
...
@@ -118,14 +118,48 @@ public void Index([FromBody]AllotRequest request)
...
@@ -118,14 +118,48 @@ public void Index([FromBody]AllotRequest request)
/// <returns></returns>
/// <returns></returns>
[
Route
(
"extract"
)]
[
Route
(
"extract"
)]
[
HttpPost
]
[
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
));
logger
.
LogInformation
(
"提取绩效数据请求参数:"
+
JsonHelper
.
Serialize
(
new
{
allotId
,
hospitalId
,
email
}));
//string filePath = newExtractService.ExtractData(request.AllotId, request.Email, request.HospitalId);
if
(
allotId
==
0
||
hospitalId
==
0
)
string
filePath
=
dfExtractService
.
ExtractData
(
request
.
AllotId
,
request
.
Email
,
request
.
HospitalId
);
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
))
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
;
int
i
=
1
;
while
(
i
<=
5
)
while
(
i
<=
5
)
{
{
...
@@ -135,7 +169,7 @@ public void ExtractData([CustomizeValidator, FromBody]ExtractRequest request)
...
@@ -135,7 +169,7 @@ public void ExtractData([CustomizeValidator, FromBody]ExtractRequest request)
logger
.
LogInformation
(
$"正在尝试第
{
i
}
次保存!"
);
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
(
"保存提取文件返回结果:"
+
JsonHelper
.
Serialize
(
retJson
));
logger
.
LogInformation
(
retJson
);
logger
.
LogInformation
(
retJson
);
var
ret
=
JsonHelper
.
Deserialize
<
ApiResponse
>(
retJson
);
var
ret
=
JsonHelper
.
Deserialize
<
ApiResponse
>(
retJson
);
...
@@ -149,6 +183,8 @@ public void ExtractData([CustomizeValidator, FromBody]ExtractRequest request)
...
@@ -149,6 +183,8 @@ public void ExtractData([CustomizeValidator, FromBody]ExtractRequest request)
}
}
else
else
logger
.
LogInformation
(
$"保存提取文件提取文件不存在!"
);
logger
.
LogInformation
(
$"保存提取文件提取文件不存在!"
);
#
endregion
}
}
#
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,37 +82,55 @@ public class DFExtractService : IAutoInjection
...
@@ -82,37 +82,55 @@ public class DFExtractService : IAutoInjection
#
region
抽取
#
region
抽取
public
string
ExtractData
(
int
allotId
,
string
email
,
int
hospitalId
)
public
string
ExtractData
(
int
allotId
,
string
email
,
int
hospitalId
,
string
filePath
=
null
)
{
{
var
allot
=
perforPerallotRepository
.
GetEntity
(
t
=>
t
.
ID
==
allotId
);
Allot
=
allot
??
throw
new
PerformanceException
(
""
);
var
hospital
=
perforHospitalRepository
.
GetEntity
(
t
=>
t
.
ID
==
hospitalId
);
var
hospital
=
perforHospitalRepository
.
GetEntity
(
t
=>
t
.
ID
==
hospitalId
);
var
configs
=
perforHospitalconfigRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
hospitalId
);
try
{
var
allot
=
perforPerallotRepository
.
GetEntity
(
t
=>
t
.
ID
==
allotId
);
Allot
=
allot
??
throw
new
PerformanceException
(
""
);
var
statesArray
=
new
int
[]
{
(
int
)
AllotStates
.
GenerateSucceed
,
(
int
)
AllotStates
.
Archive
};
var
configs
=
perforHospitalconfigRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
hospitalId
);
var
allots
=
perforPerallotRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
hospitalId
&&
statesArray
.
Contains
(
t
.
States
));
var
lastAllot
=
allots
?.
OrderByDescending
(
t
=>
t
.
Year
).
ThenByDescending
(
t
=>
t
.
Month
).
First
();
var
extractIds
=
new
List
<
int
>();
var
statesArray
=
new
int
[]
{
(
int
)
AllotStates
.
GenerateSucceed
,
(
int
)
AllotStates
.
Archive
};
var
modules
=
perforModmoduleRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
hospitalId
);
var
allots
=
perforPerallotRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
hospitalId
&&
statesArray
.
Contains
(
t
.
States
));
var
items
=
new
List
<
mod_item
>();
var
lastAllot
=
allots
?.
OrderByDescending
(
t
=>
t
.
Year
).
ThenByDescending
(
t
=>
t
.
Month
).
First
();
if
(
modules
!=
null
&&
modules
.
Any
())
{
extractIds
.
AddRange
(
modules
.
Select
(
t
=>
t
.
ExtractId
??
0
));
items
=
perforModitemRepository
.
GetEntities
(
t
=>
t
.
ModuleId
.
HasValue
&&
modules
.
Select
(
m
=>
m
.
Id
).
Contains
(
t
.
ModuleId
.
Value
));
extractIds
.
AddRange
(
items
?.
Select
(
t
=>
t
.
ExtractId
??
0
)
??
new
List
<
int
>());
var
extractIds
=
new
List
<
int
>();
}
var
modules
=
perforModmoduleRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
hospitalId
);
var
specials
=
perforModspecialRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
hospitalId
);
var
items
=
new
List
<
mod_item
>();
if
(
specials
!=
null
&&
specials
.
Any
())
if
(
modules
!=
null
&&
modules
.
Any
())
extractIds
.
AddRange
(
specials
.
Select
(
t
=>
t
.
ExtractId
??
0
));
{
extractIds
.
AddRange
(
modules
.
Select
(
t
=>
t
.
ExtractId
??
0
));
items
=
perforModitemRepository
.
GetEntities
(
t
=>
t
.
ModuleId
.
HasValue
&&
modules
.
Select
(
m
=>
m
.
Id
).
Contains
(
t
.
ModuleId
.
Value
));
extractIds
.
AddRange
(
items
?.
Select
(
t
=>
t
.
ExtractId
??
0
)
??
new
List
<
int
>());
}
var
specials
=
perforModspecialRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
hospitalId
);
if
(
specials
!=
null
&&
specials
.
Any
())
extractIds
.
AddRange
(
specials
.
Select
(
t
=>
t
.
ExtractId
??
0
));
extractIds
=
extractIds
.
Distinct
().
ToList
();
extractIds
=
extractIds
.
Distinct
().
ToList
();
var
extracts
=
perforModextractRepository
.
GetEntities
(
t
=>
extractIds
.
Contains
(
t
.
Id
));
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>
/// <summary>
...
@@ -129,69 +147,52 @@ public string ExtractData(int allotId, string email, int hospitalId)
...
@@ -129,69 +147,52 @@ public string ExtractData(int allotId, string email, int hospitalId)
/// <returns></returns>
/// <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
)
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
);
string
originalPath
=
Path
.
Combine
(
AppDomain
.
CurrentDomain
.
BaseDirectory
,
"Template"
,
"东方医院绩效模板.xlsx"
);
workbook
=
new
XSSFWorkbook
(
tempPath
);
var
(
tempPath
,
newPath
)
=
CopyOriginalFile
(
hospital
.
ID
,
originalPath
);
workbook
=
new
XSSFWorkbook
(
tempPath
);
CreateNotExistSheet
(
modules
,
workbook
);
CreateNotExistSheet
(
modules
,
workbook
);
style
=
CellStyle
.
CreateCellStyle
(
workbook
,
StyleType
.
数据
);
style
=
CellStyle
.
CreateCellStyle
(
workbook
,
StyleType
.
数据
);
List
<
AccountUnitEntity
>
unitList
=
new
List
<
AccountUnitEntity
>();
List
<
AccountUnitEntity
>
unitList
=
new
List
<
AccountUnitEntity
>();
if
(
lastAllot
!=
null
)
if
(
lastAllot
!=
null
)
unitList
=
perforImdataRepository
.
GetAccountUnit
(
lastAllot
.
ID
).
ToList
();
unitList
=
perforImdataRepository
.
GetAccountUnit
(
lastAllot
.
ID
).
ToList
();
for
(
int
i
=
0
;
i
<
workbook
.
NumberOfSheets
;
i
++)
for
(
int
i
=
0
;
i
<
workbook
.
NumberOfSheets
;
i
++)
{
{
var
sheet
=
workbook
.
GetSheetAt
(
i
);
var
sheet
=
workbook
.
GetSheetAt
(
i
);
var
sheetType
=
perSheetService
.
GetSheetType
(
sheet
.
SheetName
);
var
sheetType
=
perSheetService
.
GetSheetType
(
sheet
.
SheetName
);
if
(
sheetType
==
SheetType
.
Unidentifiable
)
continue
;
if
(
sheetType
==
SheetType
.
Unidentifiable
)
continue
;
var
sheetRead
=
PerSheetDataFactory
.
GetDataRead
(
sheetType
);
var
sheetRead
=
PerSheetDataFactory
.
GetDataRead
(
sheetType
);
switch
(
sheetType
)
switch
(
sheetType
)
{
case
SheetType
.
OtherIncome
:
WriteOtherIncome
(
sheet
,
sheetRead
,
unitList
,
configs
,
modules
,
items
,
extracts
);
break
;
case
SheetType
.
Income
:
WriteIncome
(
sheet
,
sheetRead
,
unitList
,
configs
,
modules
,
items
,
extracts
);
break
;
case
SheetType
.
Expend
:
WriteExpend
(
sheet
,
sheetRead
,
modules
,
items
);
break
;
case
SheetType
.
Workload
:
WriteWorkload
(
sheet
,
sheetRead
,
unitList
,
configs
,
modules
,
items
,
extracts
);
break
;
case
SheetType
.
SpecialUnit
:
WriteSpecialUnit
(
sheet
,
sheetRead
,
configs
,
specials
,
extracts
);
break
;
}
}
using
(
FileStream
file
=
new
FileStream
(
newPath
,
FileMode
.
OpenOrCreate
))
{
{
workbook
.
Write
(
file
);
case
SheetType
.
OtherIncome
:
WriteOtherIncome
(
sheet
,
sheetRead
,
unitList
,
configs
,
modules
,
items
,
extracts
);
break
;
case
SheetType
.
Income
:
WriteIncome
(
sheet
,
sheetRead
,
unitList
,
configs
,
modules
,
items
,
extracts
);
break
;
case
SheetType
.
Expend
:
WriteExpend
(
sheet
,
sheetRead
,
modules
,
items
);
break
;
case
SheetType
.
Workload
:
WriteWorkload
(
sheet
,
sheetRead
,
unitList
,
configs
,
modules
,
items
,
extracts
);
break
;
case
SheetType
.
SpecialUnit
:
WriteSpecialUnit
(
sheet
,
sheetRead
,
configs
,
specials
,
extracts
);
break
;
}
}
logManageService
.
WriteMsg
(
"提取绩效数据"
,
$"
{
hospital
.
HosName
}
HIS数据提取成功,文件路径:
{
newPath
}
。"
,
5
,
Allot
.
ID
,
"ReceiveMessage"
);
logger
.
LogInformation
(
$"提取绩效数据
{
hospital
.
HosName
}
HIS数据提取成功,文件路径:
{
newPath
}
。"
);
SendEmail
(
email
,
newPath
,
$"
{
hospital
.
HosName
}
HIS数据提取成功"
,
$"
{
hospital
.
HosName
}
在
{
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)}
成功提取。"
);
return
newPath
;
}
}
catch
(
Exception
ex
)
using
(
FileStream
file
=
new
FileStream
(
newPath
,
FileMode
.
OpenOrCreate
)
)
{
{
logManageService
.
WriteMsg
(
"提取数据异常"
,
$"数据写入出现异常"
,
4
,
Allot
.
ID
,
"ReceiveMessage"
);
workbook
.
Write
(
file
);
logger
.
LogError
(
$"提取绩效数据异常 数据写入出现异常
{
ex
.
ToString
()}
"
);
SendEmail
(
email
,
""
,
$"
{
hospital
.
HosName
}
HIS数据提取失败"
,
$"
{
hospital
.
HosName
}
提取数据过程中出现异常情况,我们将尽快解决问题。给您带来的不便我们深感歉意!"
);
throw
ex
;
}
finally
{
Allot
.
IsExtracting
=
null
;
perforPerallotRepository
.
Update
(
Allot
);
workbook
.
Close
();
GC
.
Collect
();
}
}
logManageService
.
WriteMsg
(
"提取绩效数据"
,
$"
{
hospital
.
HosName
}
HIS数据提取成功,文件路径:
{
newPath
}
。"
,
5
,
Allot
.
ID
,
"ReceiveMessage"
);
logger
.
LogInformation
(
$"提取绩效数据
{
hospital
.
HosName
}
HIS数据提取成功,文件路径:
{
newPath
}
。"
);
SendEmail
(
email
,
newPath
,
$"
{
hospital
.
HosName
}
HIS数据提取成功"
,
$"
{
hospital
.
HosName
}
在
{
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)}
成功提取。"
);
return
newPath
;
}
}
/// <summary>
/// <summary>
...
@@ -206,75 +207,60 @@ public string TemplateExecute(string email, per_allot lastAllot, sys_hospital ho
...
@@ -206,75 +207,60 @@ public string TemplateExecute(string email, per_allot lastAllot, sys_hospital ho
/// <param name="specials"></param>
/// <param name="specials"></param>
/// <param name="extracts"></param>
/// <param name="extracts"></param>
/// <returns></returns>
/// <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
)
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
)
{
{
try
if
(
string
.
IsNullOrEmpty
(
path
))
throw
new
PerformanceException
(
"历史绩效文件不存在!"
);
{
var
(
tempPath
,
newPath
)
=
CopyOriginalFile
(
hospital
.
ID
,
lastAllot
.
Path
);
workbook
=
new
XSSFWorkbook
(
tempPath
);
CreateNotExistSheet
(
modules
,
workbook
);
var
(
tempPath
,
newPath
)
=
CopyOriginalFile
(
hospital
.
ID
,
path
);
workbook
=
new
XSSFWorkbook
(
tempPath
);
style
=
CellStyle
.
CreateCellStyle
(
workbook
,
StyleType
.
数据
);
CreateNotExistSheet
(
modules
,
workbook
);
List
<
AccountUnitEntity
>
unitList
=
new
List
<
AccountUnitEntity
>();
style
=
CellStyle
.
CreateCellStyle
(
workbook
,
StyleType
.
数据
);
if
(
lastAllot
!=
null
)
unitList
=
perforImdataRepository
.
GetAccountUnit
(
lastAllot
.
ID
).
ToList
();
for
(
int
i
=
0
;
i
<
workbook
.
NumberOfSheets
;
i
++)
List
<
AccountUnitEntity
>
unitList
=
new
List
<
AccountUnitEntity
>();
{
if
(
lastAllot
!=
null
)
var
sheet
=
workbook
.
GetSheetAt
(
i
);
unitList
=
perforImdataRepository
.
GetAccountUnit
(
lastAllot
.
ID
).
ToList
();
var
sheetType
=
perSheetService
.
GetSheetType
(
sheet
.
SheetName
);
if
(
sheetType
==
SheetType
.
Unidentifiable
)
continue
;
var
sheetRead
=
PerSheetDataFactory
.
GetDataRead
(
sheetType
);
for
(
int
i
=
0
;
i
<
workbook
.
NumberOfSheets
;
i
++)
switch
(
sheetType
)
{
{
var
sheet
=
workbook
.
GetSheetAt
(
i
);
case
SheetType
.
OtherIncome
:
var
sheetType
=
perSheetService
.
GetSheetType
(
sheet
.
SheetName
);
ClearData
(
sheet
,
5
);
if
(
sheetType
==
SheetType
.
Unidentifiable
)
continue
;
WriteOtherIncome
(
sheet
,
sheetRead
,
unitList
,
configs
,
modules
,
items
,
extracts
,
false
);
break
;
var
sheetRead
=
PerSheetDataFactory
.
GetDataRead
(
sheetType
);
case
SheetType
.
Income
:
switch
(
sheetType
)
ClearData
(
sheet
,
5
);
WriteIncome
(
sheet
,
sheetRead
,
unitList
,
configs
,
modules
,
items
,
extracts
,
false
);
break
;
case
SheetType
.
Expend
:
ClearData
(
sheet
,
5
);
WriteExpend
(
sheet
,
sheetRead
,
modules
,
items
,
false
);
break
;
case
SheetType
.
Workload
:
ClearData
(
sheet
,
3
);
WriteWorkload
(
sheet
,
sheetRead
,
unitList
,
configs
,
modules
,
items
,
extracts
,
false
);
break
;
case
SheetType
.
SpecialUnit
:
ClearData
(
sheet
,
2
);
WriteSpecialUnit
(
sheet
,
sheetRead
,
configs
,
specials
,
extracts
,
false
,
lastAllot
);
break
;
}
}
using
(
FileStream
file
=
new
FileStream
(
newPath
,
FileMode
.
OpenOrCreate
))
{
{
workbook
.
Write
(
file
);
case
SheetType
.
OtherIncome
:
ClearData
(
sheet
,
5
);
WriteOtherIncome
(
sheet
,
sheetRead
,
unitList
,
configs
,
modules
,
items
,
extracts
,
false
);
break
;
case
SheetType
.
Income
:
ClearData
(
sheet
,
5
);
WriteIncome
(
sheet
,
sheetRead
,
unitList
,
configs
,
modules
,
items
,
extracts
,
false
);
break
;
case
SheetType
.
Expend
:
ClearData
(
sheet
,
5
);
WriteExpend
(
sheet
,
sheetRead
,
modules
,
items
,
false
);
break
;
case
SheetType
.
Workload
:
ClearData
(
sheet
,
3
);
WriteWorkload
(
sheet
,
sheetRead
,
unitList
,
configs
,
modules
,
items
,
extracts
,
false
);
break
;
case
SheetType
.
SpecialUnit
:
ClearData
(
sheet
,
2
);
WriteSpecialUnit
(
sheet
,
sheetRead
,
configs
,
specials
,
extracts
,
false
,
lastAllot
);
break
;
}
}
logManageService
.
WriteMsg
(
"提取绩效数据"
,
$"
{
hospital
.
HosName
}
HIS数据提取成功,文件路径:
{
newPath
}
。"
,
5
,
Allot
.
ID
,
"ReceiveMessage"
);
logger
.
LogInformation
(
$"提取绩效数据
{
hospital
.
HosName
}
HIS数据提取成功,文件路径:
{
newPath
}
。"
);
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
using
(
FileStream
file
=
new
FileStream
(
newPath
,
FileMode
.
OpenOrCreate
))
{
{
Allot
.
IsExtracting
=
null
;
workbook
.
Write
(
file
);
perforPerallotRepository
.
Update
(
Allot
);
workbook
.
Close
();
GC
.
Collect
();
}
}
logManageService
.
WriteMsg
(
"提取绩效数据"
,
$"
{
hospital
.
HosName
}
HIS数据提取成功,文件路径:
{
newPath
}
。"
,
5
,
Allot
.
ID
,
"ReceiveMessage"
);
logger
.
LogInformation
(
$"提取绩效数据
{
hospital
.
HosName
}
HIS数据提取成功,文件路径:
{
newPath
}
。"
);
SendEmail
(
email
,
newPath
,
$"
{
hospital
.
HosName
}
HIS数据提取成功"
,
$"
{
hospital
.
HosName
}
在
{
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)}
成功提取。"
);
return
newPath
;
}
}
#
endregion
#
endregion
...
...
performance/Performance.Services/NewExtractService.cs
View file @
b932b898
...
@@ -888,9 +888,10 @@ public void OutToExcelCell(ICell cell, object obj)
...
@@ -888,9 +888,10 @@ public void OutToExcelCell(ICell cell, object obj)
/// <param name="allotId"></param>
/// <param name="allotId"></param>
/// <param name="hospitalId"></param>
/// <param name="hospitalId"></param>
/// <param name="useTemplate"></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
;
string
result
=
null
;
filePath
=
""
;
try
try
{
{
// 获取绩效信息
// 获取绩效信息
...
@@ -909,6 +910,8 @@ public string Judge(int allotId, int hospitalId, int useTemplate)
...
@@ -909,6 +910,8 @@ public string Judge(int allotId, int hospitalId, int useTemplate)
var
statesArray
=
new
int
[]
{
(
int
)
AllotStates
.
GenerateSucceed
,
(
int
)
AllotStates
.
Archive
};
var
statesArray
=
new
int
[]
{
(
int
)
AllotStates
.
GenerateSucceed
,
(
int
)
AllotStates
.
Archive
};
var
allotList
=
perforPerallotRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
hospitalId
&&
statesArray
.
Contains
(
t
.
States
));
var
allotList
=
perforPerallotRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
hospitalId
&&
statesArray
.
Contains
(
t
.
States
));
var
allotLast
=
allotList
?.
OrderByDescending
(
t
=>
t
.
Year
).
ThenByDescending
(
t
=>
t
.
Month
).
First
();
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
);
var
modulesList
=
perforModmoduleRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
hospitalId
);
if
(
modulesList
==
null
||
modulesList
.
Count
==
0
)
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