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
f5b6c8d5
Commit
f5b6c8d5
authored
Aug 06, 2019
by
李承祥
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
方案抽取
parent
3a8ab121
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
151 additions
and
36 deletions
+151
-36
performance/Performance.Api/Controllers/TemplateController.cs
+47
-3
performance/Performance.Api/Performance.Api.csproj
+0
-3
performance/Performance.Api/appsettings.Development.json
+2
-1
performance/Performance.Api/appsettings.Localhost.json
+2
-1
performance/Performance.DtoModels/Request/ExtractRequest.cs
+6
-1
performance/Performance.Extract.Api/Controllers/ExtractController.cs
+19
-1
performance/Performance.Services/NewExtractService.cs
+75
-26
No files found.
performance/Performance.Api/Controllers/TemplateController.cs
View file @
f5b6c8d5
...
...
@@ -25,6 +25,7 @@ public class TemplateController : Controller
{
private
readonly
TemplateService
templateService
;
private
readonly
ExtractService
extractService
;
private
readonly
NewExtractService
newExtractService
;
private
HospitalService
hospitalService
;
private
IHostingEnvironment
env
;
private
ClaimService
claim
;
...
...
@@ -36,6 +37,7 @@ public class TemplateController : Controller
public
TemplateController
(
TemplateService
templateService
,
HospitalService
hospitalService
,
ExtractService
extractService
,
NewExtractService
newExtractService
,
IHostingEnvironment
env
,
ClaimService
claim
,
IOptions
<
Application
>
options
,
...
...
@@ -45,6 +47,7 @@ public class TemplateController : Controller
{
this
.
templateService
=
templateService
;
this
.
extractService
=
extractService
;
this
.
newExtractService
=
newExtractService
;
this
.
hospitalService
=
hospitalService
;
this
.
env
=
env
;
this
.
claim
=
claim
;
...
...
@@ -194,7 +197,7 @@ public ApiResponse ExtractData([CustomizeValidator(RuleSet = "Template"), FromBo
}
#
endregion
#
region
老
版提取
#
region
新
版提取
/// <summary>
/// 提取绩效数据
/// </summary>
...
...
@@ -202,13 +205,48 @@ public ApiResponse ExtractData([CustomizeValidator(RuleSet = "Template"), FromBo
/// <returns></returns>
[
Route
(
"NewExtractData"
)]
[
HttpPost
]
public
void
NewExtractData
([
CustomizeValidator
,
FromBody
]
ExtractRequest
request
)
public
ApiResponse
NewExtractData
([
CustomizeValidator
,
FromBody
]
ExtractRequest
request
)
{
var
allot
=
allotService
.
GetAllot
(
request
.
AllotId
);
if
(
allot
==
null
)
return
new
ApiResponse
(
ResponseType
.
ParameterError
,
"AllotID错误"
);
// 判断是那种抽取
try
{
string
message
=
newExtractService
.
Judge
(
request
.
AllotId
,
request
.
HospitalId
,
request
.
UseScheme
);
if
(!
string
.
IsNullOrEmpty
(
message
))
return
new
ApiResponse
(
ResponseType
.
Fail
,
message
);
allot
.
IsExtracting
=
allot
.
IsExtracting
??
0
;
if
(
allot
.
IsExtracting
==
1
)
throw
new
PerformanceException
(
"正在提取数据,请稍等!"
);
allot
.
IsExtracting
=
1
;
allotService
.
Update
(
allot
);
var
email
=
claim
.
GetUserClaim
(
JwtClaimTypes
.
Mail
);
request
.
Email
=
email
;
if
(
request
.
UseScheme
==
(
int
)
UseTemplate
.
Config
)
{
LogHelper
.
Information
(
"请求路径:"
+
url
.
HttpPost
+
"/extract/extract"
,
"提取绩效数据"
);
HttpHelper
.
HttpPostNoRequest
(
url
.
HttpPost
+
"/extract/extract"
,
JsonHelper
.
Serialize
(
request
),
true
);
}
else
{
}
return
new
ApiResponse
(
ResponseType
.
Error
,
"HIS绩效数据提取任务正在执行,稍后我们将以邮件的通知您!"
);
}
catch
(
Exception
ex
)
{
if
(
allot
!=
null
)
{
allot
.
IsExtracting
=
3
;
allotService
.
Update
(
allot
);
}
logger
.
LogError
(
"提取绩效数据:"
+
ex
.
ToString
());
throw
new
Exception
(
ex
.
Message
);
}
// A 使用上传绩效作为模板
// A-1 判断上传绩效是否存在,并执行成功
// A-2 医院人员名单、1.0.1 额外收入(写出列头)、2.1 成本支出统计表(写出列头)、4.1 临床科室医护绩效测算表、4.2 特殊核算单元绩效测算表(数量、考核得分率、奖罚、其他)
...
...
@@ -259,17 +297,22 @@ public IActionResult DownFile([FromQuery]AllotRequest request)
[
AllowAnonymous
]
public
ApiResponse
SaveFile
([
FromForm
]
IFormCollection
form
,
int
allotId
,
int
hospitalId
)
{
LogHelper
.
Information
(
$"请求参数:allotId:
{
allotId
}
hospitalId:
{
hospitalId
}
"
,
"保存提取文件"
);
logger
.
LogInformation
(
$"保存提取文件 参数:allotId:
{
allotId
}
hospitalId:
{
hospitalId
}
"
);
try
{
var
file
=
((
FormFileCollection
)
form
.
Files
).
FirstOrDefault
();
if
(
file
==
null
)
{
LogHelper
.
Error
(
$"返回文件为空!"
,
"保存提取文件"
);
return
new
ApiResponse
(
ResponseType
.
Error
,
"上传文件无效"
);
}
var
dpath
=
Path
.
Combine
(
env
.
ContentRootPath
,
"Files"
,
$"
{
hospitalId
}
"
,
"autoextract"
);
FileHelper
.
CreateDirectory
(
dpath
);
var
path
=
Path
.
Combine
(
dpath
,
FileHelper
.
GetFileName
(
file
.
FileName
));
LogHelper
.
Information
(
$"保存路径:"
+
path
,
"保存提取文件"
);
using
(
var
stream
=
file
.
OpenReadStream
())
{
...
...
@@ -287,6 +330,7 @@ public ApiResponse SaveFile([FromForm] IFormCollection form, int allotId, int ho
catch
(
Exception
ex
)
{
logger
.
LogInformation
(
$"保存提取文件异常
{
ex
.
ToString
()}
"
);
LogHelper
.
Error
(
$"保存失败:"
+
ex
.
ToString
(),
"保存提取文件"
);
}
return
new
ApiResponse
(
ResponseType
.
Error
);
}
...
...
performance/Performance.Api/Performance.Api.csproj
View file @
f5b6c8d5
...
...
@@ -58,9 +58,6 @@
<Content Update="wwwroot\Performance.Api.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\Performance.DtoModels.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\Performance.EntityModels.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
...
...
performance/Performance.Api/appsettings.Development.json
View file @
f5b6c8d5
...
...
@@ -26,6 +26,7 @@
"WebapiUrl"
:
{
"ImportFirst"
:
"http://localhost:50997/api/extract/import"
,
"ExtractData"
:
"http://localhost:50997/api/extract/index"
,
"ImportFile"
:
""
"ImportFile"
:
"http://localhost:5001/api/template/savefile"
,
"HttpPost"
:
"http://localhost:50997/api"
}
}
performance/Performance.Api/appsettings.Localhost.json
View file @
f5b6c8d5
...
...
@@ -27,6 +27,7 @@
"WebapiUrl"
:
{
"ImportFirst"
:
"http://localhost:50997/api/extract/import"
,
"ExtractData"
:
"http://localhost:50997/api/extract/index"
,
"ImportFile"
:
""
"ImportFile"
:
"http://localhost:5001/api/template/savefile"
,
"HttpPost"
:
"http://localhost:50997/api"
}
}
performance/Performance.DtoModels/Request/ExtractRequest.cs
View file @
f5b6c8d5
...
...
@@ -3,7 +3,7 @@
using
System.Collections.Generic
;
using
System.Text
;
namespace
Performance.DtoModels
namespace
Performance.DtoModels
{
public
class
ExtractRequest
{
...
...
@@ -21,6 +21,11 @@ public class ExtractRequest
/// 使用方案
/// </summary>
public
int
UseScheme
{
get
;
set
;
}
/// <summary>
/// 邮箱
/// </summary>
public
string
Email
{
get
;
set
;
}
}
...
...
performance/Performance.Extract.Api/Controllers/ExtractController.cs
View file @
f5b6c8d5
...
...
@@ -117,7 +117,25 @@ public void Index([FromBody]AllotRequest request)
[
HttpPost
]
public
void
ExtractData
([
CustomizeValidator
,
FromBody
]
ExtractRequest
request
)
{
newExtractService
.
ExtractData
(
request
.
AllotId
,
""
,
request
.
HospitalId
);
LogHelper
.
Information
(
"请求参数:"
+
JsonHelper
.
Serialize
(
request
),
"提取绩效数据"
);
string
filePath
=
newExtractService
.
ExtractData
(
request
.
AllotId
,
""
,
request
.
HospitalId
);
LogHelper
.
Information
(
"提取文件路径:"
+
filePath
,
"提取绩效数据"
);
if
(!
string
.
IsNullOrEmpty
(
filePath
)
&&
FileHelper
.
IsExistFile
(
filePath
))
{
int
i
=
1
;
while
(
i
<=
5
)
{
LogHelper
.
Information
(
"请求路径:"
+
url
.
ImportFile
,
"保存提取文件"
);
string
retJson
=
HttpHelper
.
HttpClient
(
url
.
ImportFile
+
$"?allotId=
{
request
.
AllotId
}
&hospitalId=
{
request
.
HospitalId
}
"
,
filePath
);
LogHelper
.
Information
(
"返回结果:"
+
JsonHelper
.
Serialize
(
retJson
),
"保存提取文件"
);
logger
.
LogInformation
(
retJson
);
var
ret
=
JsonHelper
.
Deserialize
<
ApiResponse
>(
retJson
);
if
((
int
)
ret
.
State
==
1
)
break
;
i
++;
}
}
}
#
endregion
...
...
performance/Performance.Services/NewExtractService.cs
View file @
f5b6c8d5
...
...
@@ -85,34 +85,22 @@ public string ExtractData(int allotId, string email, int hospitalId)
{
// 获取绩效信息
var
allot
=
perforPerallotRepository
.
GetEntity
(
t
=>
t
.
ID
==
allotId
);
if
(
allot
==
null
)
throw
new
PerformanceException
(
"AllotID错误"
);
// 获取医院信息
var
hospital
=
perforHospitalRepository
.
GetEntity
(
t
=>
t
.
ID
==
hospitalId
);
if
(
hospital
==
null
)
throw
new
PerformanceException
(
"医院ID错误"
);
// 获取医院配置信息
var
hospitalConfigList
=
perforHospitalconfigRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
hospitalId
);
if
(
hospitalConfigList
==
null
||
hospitalConfigList
.
Count
==
0
)
throw
new
PerformanceException
(
"当前医院暂不支持HIS数据抽取"
);
// 获取最近一次绩效
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
();
// 获取当前医院模版信息
var
modulesList
=
perforModmoduleRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
hospitalId
);
if
(
modulesList
==
null
||
modulesList
.
Count
==
0
)
throw
new
PerformanceException
(
"当前医院还未配置模版"
);
// 获取模板项
var
moduleIdList
=
modulesList
.
Select
(
t
=>
t
.
Id
).
ToList
();
var
itemsList
=
perforModitemRepository
.
GetEntities
(
t
=>
t
.
ModuleId
.
HasValue
&&
moduleIdList
.
Contains
(
t
.
ModuleId
.
Value
));
if
(
itemsList
==
null
||
itemsList
.
Count
==
0
)
throw
new
PerformanceException
(
"当前医院还未配置模版项"
);
// 获取当前模板所有相关抽取SQL语句
var
extractIdList
=
itemsList
.
Select
(
t
=>
t
.
ExtractId
).
Union
(
modulesList
.
Select
(
t
=>
t
.
ExtractId
)).
Distinct
().
ToList
();
var
extractList
=
perforModextractRepository
.
GetEntities
(
t
=>
extractIdList
.
Contains
(
t
.
Id
));
if
(
extractList
==
null
||
extractList
.
Count
==
0
)
throw
new
PerformanceException
(
"当前医院配置模板无需抽取"
);
IWorkbook
workbook
=
null
;
...
...
@@ -125,6 +113,7 @@ public string ExtractData(int allotId, string email, int hospitalId)
#
region
单元格样式
style
=
workbook
.
CreateCellStyle
();
//字体
IFont
titleFont
=
workbook
.
CreateFont
();
titleFont
.
FontHeightInPoints
=
12
;
//设置字体大小
titleFont
.
Color
=
HSSFColor
.
Black
.
Index
;
//设置字体颜色
...
...
@@ -139,6 +128,10 @@ public string ExtractData(int allotId, string email, int hospitalId)
//前景色
style
.
FillForegroundColor
=
NPOI
.
HSSF
.
Util
.
HSSFColor
.
SkyBlue
.
Index
;
style
.
FillPattern
=
FillPattern
.
SolidForeground
;
//居中
style
.
Alignment
=
HorizontalAlignment
.
Center
;
//水平居中
style
.
VerticalAlignment
=
VerticalAlignment
.
Center
;
//垂直居中
#
endregion
for
(
int
i
=
0
;
i
<
workbook
.
NumberOfSheets
;
i
++)
...
...
@@ -187,6 +180,8 @@ public string ExtractData(int allotId, string email, int hospitalId)
}
finally
{
allot
.
IsExtracting
=
3
;
perforPerallotRepository
.
Update
(
allot
);
workbook
.
Close
();
GC
.
Collect
();
}
...
...
@@ -233,7 +228,7 @@ private void WriteOtherIncome(ISheet sheet, IPerSheetDataRead sheetRead)
var
technicianFactor
=
sheet
.
GetRow
(
sheetRead
.
Point
.
HeaderFirstRowNum
.
Value
+
3
);
var
head
=
sheet
.
GetRow
(
sheetRead
.
Point
.
HeaderFirstRowNum
.
Value
+
4
);
int
cellStartIndex
=
sheetRead
.
Point
.
HeaderFirstCellNum
.
Value
+
3
;
int
cellStartIndex
=
sheetRead
.
Point
.
HeaderFirstCellNum
.
Value
+
4
;
//写入列头信息
foreach
(
var
item
in
itemList
)
{
...
...
@@ -315,8 +310,8 @@ private void WriteIncome(ISheet sheet, int allotLastId, IPerSheetDataRead sheetR
{
var
value
=
allExtract
.
FirstOrDefault
(
t
=>
t
.
Department
==
department
&&
t
.
Category
==
headName
)?.
Value
;
newCell
.
SetCellValue
(
value
==
null
||
value
==
0
?
""
:
value
.
ToString
());
newCell
.
CellStyle
=
style
;
}
newCell
.
CellStyle
=
style
;
}
rowIndex
++;
}
...
...
@@ -328,7 +323,7 @@ private ICell GetOrCreate(IRow row, int index)
if
(
cell
==
null
)
cell
=
row
.
CreateCell
(
index
);
cell
.
CellStyle
.
FillBackgroundColor
=
NPOI
.
HSSF
.
Util
.
HSSFColor
.
Orange
.
Index
;
//
cell.CellStyle.FillBackgroundColor = NPOI.HSSF.Util.HSSFColor.Orange.Index;
return
cell
;
}
...
...
@@ -414,8 +409,8 @@ private void WriteWorkload(ISheet sheet, int allotLastId, IPerSheetDataRead shee
{
var
value
=
allExtract
.
FirstOrDefault
(
t
=>
t
.
Department
==
department
&&
t
.
Category
==
headName
)?.
Value
;
newCell
.
SetCellValue
(
value
==
null
||
value
==
0
?
""
:
value
.
ToString
());
newCell
.
CellStyle
=
style
;
}
newCell
.
CellStyle
=
style
;
}
}
}
...
...
@@ -457,7 +452,7 @@ private void WriteExpend(ISheet sheet, IPerSheetDataRead sheetRead)
var
nurseFactor
=
sheet
.
GetRow
(
sheetRead
.
Point
.
HeaderFirstRowNum
.
Value
+
2
);
var
doctorFactor
=
sheet
.
GetRow
(
sheetRead
.
Point
.
HeaderFirstRowNum
.
Value
+
3
);
int
cellStartIndex
=
sheetRead
.
Point
.
HeaderFirstCellNum
.
Value
+
3
;
int
cellStartIndex
=
sheetRead
.
Point
.
HeaderFirstCellNum
.
Value
+
4
;
//写入列头信息
foreach
(
var
item
in
itemList
)
{
...
...
@@ -574,11 +569,10 @@ private void WriteSpecialUnit(ISheet sheet, int hospitalId, int allotLastId, IPe
var
count
=
modDataGroup
.
First
(
t
=>
t
.
Department
.
ToString
()
==
value
).
Count
;
mergedEnd
=
mergedBegin
+
count
-
1
;
}
sheet
.
AddMergedRegion
(
new
CellRangeAddress
(
mergedBegin
,
mergedEnd
,
cellIndex
,
cellIndex
));
//合并单元格
CellRangeAddress
region
=
new
CellRangeAddress
(
mergedBegin
,
mergedEnd
,
cellIndex
,
cellIndex
);
sheet
.
AddMergedRegion
(
region
);
//合并单元格
var
newCell
=
importRow
.
CreateCell
(
cellIndex
);
newCell
.
SetCellValue
(
Verify
(
value
));
style
.
Alignment
=
HorizontalAlignment
.
Center
;
//水平居中
style
.
VerticalAlignment
=
VerticalAlignment
.
Center
;
//垂直居中
newCell
.
CellStyle
=
style
;
}
else
...
...
@@ -592,11 +586,10 @@ private void WriteSpecialUnit(ISheet sheet, int hospitalId, int allotLastId, IPe
{
if
(!
new
List
<
string
>
{
"量化指标"
,
"数量"
,
"量化指标绩效分值"
}.
Contains
(
cell
.
StringCellValue
)
&&
rowIndex
==
mergedBegin
)
{
sheet
.
AddMergedRegion
(
new
CellRangeAddress
(
mergedBegin
,
mergedEnd
,
cellIndex
,
cellIndex
));
//合并单元格
CellRangeAddress
region
=
new
CellRangeAddress
(
mergedBegin
,
mergedEnd
,
cellIndex
,
cellIndex
);
sheet
.
AddMergedRegion
(
region
);
//合并单元格
var
newCell
=
importRow
.
CreateCell
(
cellIndex
);
newCell
.
SetCellValue
(
""
);
style
.
Alignment
=
HorizontalAlignment
.
Center
;
//水平居中
style
.
VerticalAlignment
=
VerticalAlignment
.
Center
;
//垂直居中
newCell
.
CellStyle
=
style
;
}
}
...
...
@@ -648,7 +641,7 @@ private void WriteAccountBasic(ISheet sheet, int allotLastId, IPerSheetDataRead
}
var
newCell
=
importRow
.
CreateCell
(
cell
.
ColumnIndex
);
newCell
.
SetCellValue
(
Verify
(
value
));
newCell
.
CellStyle
=
style
;
//
newCell.CellStyle = style;
}
}
}
...
...
@@ -678,7 +671,63 @@ public dynamic Verify(string obj)
}
}
#
endregion
#
endregion
#
region
配置校验
/// <summary>
/// 配置校验
/// </summary>
/// <param name="allotId"></param>
/// <param name="hospitalId"></param>
/// <param name="useTemplate"></param>
public
string
Judge
(
int
allotId
,
int
hospitalId
,
int
useTemplate
)
{
string
result
=
null
;
try
{
// 获取绩效信息
var
allot
=
perforPerallotRepository
.
GetEntity
(
t
=>
t
.
ID
==
allotId
);
if
(
allot
==
null
)
throw
new
PerformanceException
(
"AllotID错误"
);
// 获取医院信息
var
hospital
=
perforHospitalRepository
.
GetEntity
(
t
=>
t
.
ID
==
hospitalId
);
if
(
hospital
==
null
)
throw
new
PerformanceException
(
"医院ID错误"
);
// 获取医院配置信息
var
hospitalConfigList
=
perforHospitalconfigRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
hospitalId
);
if
(
hospitalConfigList
==
null
||
hospitalConfigList
.
Count
==
0
)
throw
new
PerformanceException
(
"当前医院暂不支持HIS数据抽取"
);
// 获取最近一次绩效
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
();
// 获取当前医院模版信息
var
modulesList
=
perforModmoduleRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
hospitalId
);
if
(
modulesList
==
null
||
modulesList
.
Count
==
0
)
throw
new
PerformanceException
(
"当前医院还未配置模版"
);
// 获取模板项
var
moduleIdList
=
modulesList
.
Select
(
t
=>
t
.
Id
).
ToList
();
var
itemsList
=
perforModitemRepository
.
GetEntities
(
t
=>
t
.
ModuleId
.
HasValue
&&
moduleIdList
.
Contains
(
t
.
ModuleId
.
Value
));
if
(
itemsList
==
null
||
itemsList
.
Count
==
0
)
throw
new
PerformanceException
(
"当前医院还未配置模版项"
);
// 获取当前模板所有相关抽取SQL语句
var
extractIdList
=
itemsList
.
Select
(
t
=>
t
.
ExtractId
).
Union
(
modulesList
.
Select
(
t
=>
t
.
ExtractId
)).
Distinct
().
ToList
();
var
extractList
=
perforModextractRepository
.
GetEntities
(
t
=>
extractIdList
.
Contains
(
t
.
Id
));
if
(
extractList
==
null
||
extractList
.
Count
==
0
)
throw
new
PerformanceException
(
"当前医院配置模板无需抽取"
);
}
catch
(
PerformanceException
ex
)
{
LogHelper
.
Error
(
ex
.
ToString
(),
"提取绩效数据"
);
result
=
ex
.
ToString
();
}
catch
(
Exception
ex
)
{
LogHelper
.
Error
(
ex
.
ToString
(),
"提取绩效数据"
);
throw
new
Exception
(
ex
.
Message
);
}
return
result
;
}
#
endregion
}
}
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