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
042ce8fe
Commit
042ce8fe
authored
Jul 29, 2019
by
799284587@qq.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
抽取初稿
parent
b30e08ee
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
652 additions
and
5 deletions
+652
-5
performance/Performance.Api/Controllers/TemplateController.cs
+28
-5
performance/Performance.Api/Performance.Api.csproj
+9
-0
performance/Performance.Api/Template/医院二次分配绩效模板.xlsx
+0
-0
performance/Performance.Api/Template/医院绩效模板.xlsx
+0
-0
performance/Performance.DtoModels/Enum.cs
+22
-0
performance/Performance.DtoModels/ExtractDto.cs
+13
-0
performance/Performance.DtoModels/Request/DownRequest.cs
+11
-0
performance/Performance.EntityModels/Entity/mod_item.cs
+5
-0
performance/Performance.Extract.Api/Performance.Extract.Api.csproj
+13
-0
performance/Performance.Services/NewExtractService.cs
+551
-0
No files found.
performance/Performance.Api/Controllers/TemplateController.cs
View file @
042ce8fe
...
@@ -25,7 +25,7 @@ public class TemplateController : Controller
...
@@ -25,7 +25,7 @@ public class TemplateController : Controller
private
readonly
TemplateService
templateService
;
private
readonly
TemplateService
templateService
;
private
readonly
ExtractService
extractService
;
private
readonly
ExtractService
extractService
;
private
HospitalService
hospitalService
;
private
HospitalService
hospitalService
;
private
IHostingEnvironment
e
vn
;
private
IHostingEnvironment
e
nv
;
private
ClaimService
claim
;
private
ClaimService
claim
;
private
Application
application
;
private
Application
application
;
private
WebapiUrl
url
;
private
WebapiUrl
url
;
...
@@ -35,7 +35,7 @@ public class TemplateController : Controller
...
@@ -35,7 +35,7 @@ public class TemplateController : Controller
public
TemplateController
(
TemplateService
templateService
,
public
TemplateController
(
TemplateService
templateService
,
HospitalService
hospitalService
,
HospitalService
hospitalService
,
ExtractService
extractService
,
ExtractService
extractService
,
IHostingEnvironment
e
vn
,
IHostingEnvironment
e
nv
,
ClaimService
claim
,
ClaimService
claim
,
IOptions
<
Application
>
options
,
IOptions
<
Application
>
options
,
IOptions
<
WebapiUrl
>
url
,
IOptions
<
WebapiUrl
>
url
,
...
@@ -45,7 +45,7 @@ public class TemplateController : Controller
...
@@ -45,7 +45,7 @@ public class TemplateController : Controller
this
.
templateService
=
templateService
;
this
.
templateService
=
templateService
;
this
.
extractService
=
extractService
;
this
.
extractService
=
extractService
;
this
.
hospitalService
=
hospitalService
;
this
.
hospitalService
=
hospitalService
;
this
.
e
vn
=
evn
;
this
.
e
nv
=
env
;
this
.
claim
=
claim
;
this
.
claim
=
claim
;
this
.
application
=
options
.
Value
;
this
.
application
=
options
.
Value
;
this
.
url
=
url
.
Value
;
this
.
url
=
url
.
Value
;
...
@@ -54,6 +54,29 @@ public class TemplateController : Controller
...
@@ -54,6 +54,29 @@ public class TemplateController : Controller
}
}
/// <summary>
/// <summary>
/// 从WebAPI下载模板
/// </summary>
/// <returns></returns>
[
Route
(
"downtemplate"
)]
[
NoVerify
]
public
IActionResult
DownFile
([
FromQuery
]
DownRequest
request
)
{
string
path
=
(
request
.
TempType
==
1
)
?
Path
.
Combine
(
env
.
ContentRootPath
,
"Template"
,
"医院绩效模板.xlsx"
)
:
Path
.
Combine
(
env
.
ContentRootPath
,
"Template"
,
"医院二次分配绩效模板.xlsx"
);
var
memoryStream
=
new
MemoryStream
();
using
(
var
stream
=
new
FileStream
(
path
,
FileMode
.
Open
))
{
stream
.
CopyToAsync
(
memoryStream
).
Wait
();
}
memoryStream
.
Seek
(
0
,
SeekOrigin
.
Begin
);
var
provider
=
new
FileExtensionContentTypeProvider
();
var
memi
=
provider
.
Mappings
[
"xlsx"
];
return
File
(
memoryStream
,
memi
,
Path
.
GetFileName
(
path
));
}
/// <summary>
/// 上传文件
/// 上传文件
/// </summary>
/// </summary>
/// <param name="form"></param>
/// <param name="form"></param>
...
@@ -77,7 +100,7 @@ public ApiResponse Import([FromForm] IFormCollection form)
...
@@ -77,7 +100,7 @@ public ApiResponse Import([FromForm] IFormCollection form)
var
name
=
FileHelper
.
GetFileNameNoExtension
(
file
.
FileName
)
+
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmssfff"
);
var
name
=
FileHelper
.
GetFileNameNoExtension
(
file
.
FileName
)
+
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmssfff"
);
var
ext
=
FileHelper
.
GetExtension
(
file
.
FileName
);
var
ext
=
FileHelper
.
GetExtension
(
file
.
FileName
);
var
dpath
=
Path
.
Combine
(
e
vn
.
ContentRootPath
,
"Files"
,
$"
{
hospitalid
}
"
,
"first"
);
var
dpath
=
Path
.
Combine
(
e
nv
.
ContentRootPath
,
"Files"
,
$"
{
hospitalid
}
"
,
"first"
);
FileHelper
.
CreateDirectory
(
dpath
);
FileHelper
.
CreateDirectory
(
dpath
);
var
path
=
Path
.
Combine
(
dpath
,
$"
{
name
}{
ext
}
"
);
var
path
=
Path
.
Combine
(
dpath
,
$"
{
name
}{
ext
}
"
);
...
@@ -209,7 +232,7 @@ public ApiResponse SaveFile([FromForm] IFormCollection form, int allotId, int ho
...
@@ -209,7 +232,7 @@ public ApiResponse SaveFile([FromForm] IFormCollection form, int allotId, int ho
if
(
file
==
null
)
if
(
file
==
null
)
return
new
ApiResponse
(
ResponseType
.
Error
,
"上传文件无效"
);
return
new
ApiResponse
(
ResponseType
.
Error
,
"上传文件无效"
);
var
dpath
=
Path
.
Combine
(
e
vn
.
ContentRootPath
,
"Files"
,
$"
{
hospitalId
}
"
,
"autoextract"
);
var
dpath
=
Path
.
Combine
(
e
nv
.
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
));
...
...
performance/Performance.Api/Performance.Api.csproj
View file @
042ce8fe
...
@@ -47,6 +47,15 @@
...
@@ -47,6 +47,15 @@
</Content>
</Content>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<None Update="Template\医院二次分配绩效模板.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Template\医院绩效模板.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JSONSchema="" /></VisualStudio></ProjectExtensions>
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JSONSchema="" /></VisualStudio></ProjectExtensions>
</Project>
</Project>
performance/Performance.Api/Template/医院二次分配绩效模板.xlsx
0 → 100644
View file @
042ce8fe
File added
performance/Performance.Api/Template/医院绩效模板.xlsx
0 → 100644
View file @
042ce8fe
File added
performance/Performance.DtoModels/Enum.cs
View file @
042ce8fe
...
@@ -23,6 +23,28 @@ public enum States
...
@@ -23,6 +23,28 @@ public enum States
Disabled
=
2
,
Disabled
=
2
,
}
}
/// <summary> 提取数据使用模板 </summary>
public
enum
UseTemplate
{
/// <summary> 上次绩效 </summary>
[
Description
(
"上次绩效"
)]
LastAllot
=
1
,
/// <summary> 配置模板 </summary>
[
Description
(
"配置模板"
)]
Config
=
2
,
}
/// <summary> 提取数据使用模板 </summary>
public
enum
DbSrouceType
{
/// <summary> 标准库 </summary>
[
Description
(
"标准库"
)]
Standard
=
1
,
/// <summary> 绩效库 </summary>
[
Description
(
"绩效库"
)]
Performance
=
2
,
}
public
enum
AllotStates
public
enum
AllotStates
{
{
/// <summary> 用户状态 </summary>
/// <summary> 用户状态 </summary>
...
...
performance/Performance.DtoModels/ExtractDto.cs
0 → 100644
View file @
042ce8fe
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Performance.DtoModels
{
public
class
ExtractDto
{
public
string
Department
{
get
;
set
;
}
public
string
Category
{
get
;
set
;
}
public
decimal
Value
{
get
;
set
;
}
}
}
performance/Performance.DtoModels/Request/DownRequest.cs
0 → 100644
View file @
042ce8fe
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Performance.DtoModels
{
public
class
DownRequest
:
ApiRequest
{
public
int
TempType
{
get
;
set
;
}
}
}
performance/Performance.EntityModels/Entity/mod_item.cs
View file @
042ce8fe
...
@@ -42,6 +42,11 @@ public class mod_item
...
@@ -42,6 +42,11 @@ public class mod_item
public
Nullable
<
decimal
>
FactorValue2
{
get
;
set
;
}
public
Nullable
<
decimal
>
FactorValue2
{
get
;
set
;
}
/// <summary>
/// <summary>
/// 医技系数
/// </summary>
public
Nullable
<
decimal
>
FactorValue3
{
get
;
set
;
}
/// <summary>
/// 抽取绩效值SQL
/// 抽取绩效值SQL
/// </summary>
/// </summary>
public
Nullable
<
int
>
ExtractId
{
get
;
set
;
}
public
Nullable
<
int
>
ExtractId
{
get
;
set
;
}
...
...
performance/Performance.Extract.Api/Performance.Extract.Api.csproj
View file @
042ce8fe
...
@@ -25,6 +25,19 @@
...
@@ -25,6 +25,19 @@
<ProjectReference Include="..\Performance.Services\Performance.Services.csproj" />
<ProjectReference Include="..\Performance.Services\Performance.Services.csproj" />
</ItemGroup>
</ItemGroup>
<ItemGroup>
<Folder Include="Template\" />
</ItemGroup>
<ItemGroup>
<None Include="..\Performance.Api\Template\医院二次分配绩效模板.xlsx" Link="Template\医院二次分配绩效模板.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\Performance.Api\Template\医院绩效模板.xlsx" Link="Template\医院绩效模板.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JSONSchema="" /></VisualStudio></ProjectExtensions>
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JSONSchema="" /></VisualStudio></ProjectExtensions>
</Project>
</Project>
performance/Performance.Services/NewExtractService.cs
0 → 100644
View file @
042ce8fe
using
Dapper
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.Extensions.Logging
;
using
Microsoft.Extensions.Options
;
using
NPOI.HSSF.UserModel
;
using
NPOI.SS.UserModel
;
using
NPOI.SS.Util
;
using
NPOI.XSSF.UserModel
;
using
Performance.DtoModels
;
using
Performance.DtoModels.AppSettings
;
using
Performance.EntityModels
;
using
Performance.Infrastructure
;
using
Performance.Repository
;
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
using
System.Text
;
using
System.Text.RegularExpressions
;
namespace
Performance.Services
{
/// <summary>
/// 数据抽取服务
/// </summary>
public
class
NewExtractService
:
IAutoInjection
{
#
region
private
readonly
ILogger
<
ExtractService
>
logger
;
private
readonly
IHostingEnvironment
environment
;
private
readonly
PerSheetService
perSheetService
;
private
readonly
PerforHospitalRepository
perforHospitalRepository
;
private
readonly
PerforHospitalconfigRepository
perforHospitalconfigRepository
;
private
readonly
PerforModmoduleRepository
perforModmoduleRepository
;
private
readonly
PerforModextractRepository
perforModextractRepository
;
private
readonly
PerforModitemRepository
perforModitemRepository
;
private
readonly
PerforModspecialRepository
perforModspecialRepository
;
private
readonly
PerforPerallotRepository
perforPerallotRepository
;
private
readonly
PerforPersheetRepository
perforPersheetRepository
;
private
readonly
PerforImemployeeRepository
perforImemployeeRepository
;
private
readonly
PerforImaccountbasicRepository
perforImaccountbasicRepository
;
private
readonly
PerforImspecialunitRepository
perforImspecialunitRepository
;
private
readonly
PerforImdataRepository
perforImdataRepository
;
public
NewExtractService
(
ILogger
<
ExtractService
>
logger
,
IHostingEnvironment
environment
,
PerSheetService
perSheetService
,
PerforHospitalRepository
perforHospitalRepository
,
PerforHospitalconfigRepository
perforHospitalconfigRepository
,
PerforModmoduleRepository
perforModmoduleRepository
,
PerforModextractRepository
perforModextractRepository
,
PerforModitemRepository
perforModitemRepository
,
PerforModspecialRepository
perforModspecialRepository
,
PerforPerallotRepository
perforPerallotRepository
,
PerforPersheetRepository
perforPersheetRepository
,
PerforImemployeeRepository
perforImemployeeRepository
,
PerforImaccountbasicRepository
perforImaccountbasicRepository
,
PerforImspecialunitRepository
perforImspecialunitRepository
,
PerforImdataRepository
perforImdataRepository
)
{
this
.
logger
=
logger
;
this
.
environment
=
environment
;
this
.
perSheetService
=
perSheetService
;
this
.
perforHospitalRepository
=
perforHospitalRepository
;
this
.
perforHospitalconfigRepository
=
perforHospitalconfigRepository
;
this
.
perforModmoduleRepository
=
perforModmoduleRepository
;
this
.
perforModextractRepository
=
perforModextractRepository
;
this
.
perforModitemRepository
=
perforModitemRepository
;
this
.
perforModspecialRepository
=
perforModspecialRepository
;
this
.
perforPerallotRepository
=
perforPerallotRepository
;
this
.
perforPersheetRepository
=
perforPersheetRepository
;
this
.
perforImemployeeRepository
=
perforImemployeeRepository
;
this
.
perforImaccountbasicRepository
=
perforImaccountbasicRepository
;
this
.
perforImspecialunitRepository
=
perforImspecialunitRepository
;
this
.
perforImdataRepository
=
perforImdataRepository
;
}
#
endregion
#
region
改版抽取
public
string
ExtractData
(
int
allotId
,
string
email
,
int
hospitalId
,
UseTemplate
useTemplate
)
{
// 获取医院信息
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
;
FileStream
file
=
null
;
try
{
var
path
=
CopyOriginalFile
(
hospitalId
,
useTemplate
);
file
=
new
FileStream
(
path
,
FileMode
.
Open
);
workbook
=
new
XSSFWorkbook
(
file
);
CreateNotExistSheet
(
modulesList
,
workbook
);
for
(
int
i
=
0
;
i
<
workbook
.
NumberOfSheets
;
i
++)
{
var
sheet
=
workbook
.
GetSheetAt
(
i
);
var
sheetType
=
perSheetService
.
GetSheetType
(
sheet
.
SheetName
);
if
(
sheetType
==
SheetType
.
Unidentifiable
)
continue
;
var
sheetRead
=
PerSheetDataFactory
.
GetDataRead
(
sheetType
);
switch
(
sheetType
)
{
case
SheetType
.
Employee
:
WriteEmployee
(
sheet
,
allotLast
.
ID
,
sheetRead
);
break
;
case
SheetType
.
AccountBasic
:
WriteAccountBasic
(
sheet
,
allotLast
.
ID
,
sheetRead
);
break
;
case
SheetType
.
SpecialUnit
:
WriteSpecialUnit
(
sheet
,
hospital
.
ID
,
allotLast
.
ID
,
sheetRead
);
break
;
case
SheetType
.
Income
:
WriteIncome
(
sheet
,
allotLast
.
ID
,
sheetRead
,
hospitalConfigList
);
break
;
case
SheetType
.
OtherIncome
:
WriteOtherIncome
(
sheet
,
sheetRead
);
break
;
case
SheetType
.
Expend
:
WriteExpend
(
sheet
,
sheetRead
);
break
;
case
SheetType
.
Workload
:
WriteWorkload
(
sheet
,
allotLast
.
ID
,
sheetRead
,
hospitalConfigList
);
break
;
}
}
workbook
.
Write
(
file
);
return
path
;
}
catch
(
Exception
ex
)
{
LogHelper
.
Error
(
$"数据写入出现异常
{
ex
.
ToString
()}
"
,
"提取绩效数据"
,
"异常"
);
throw
ex
;
}
finally
{
workbook
.
Close
();
file
.
Close
();
file
.
Dispose
();
GC
.
Collect
();
}
}
private
static
void
CreateNotExistSheet
(
List
<
mod_module
>
modulesList
,
IWorkbook
workbook
)
{
SortedDictionary
<
string
,
int
>
pairs
=
new
SortedDictionary
<
string
,
int
>();
for
(
int
i
=
0
;
i
<
workbook
.
NumberOfSheets
;
i
++)
{
pairs
.
Add
(
workbook
.
GetSheetAt
(
i
).
SheetName
,
i
);
}
foreach
(
var
module
in
modulesList
.
Where
(
t
=>
t
.
SheetType
==
(
int
)
SheetType
.
Income
))
{
var
sheet
=
workbook
.
GetSheet
(
module
.
ModuleName
);
if
(
sheet
==
null
)
{
string
[]
keyArray
=
new
string
[]
{
"就诊"
,
"开单"
};
if
(
keyArray
.
Any
(
key
=>
module
.
ModuleName
.
Contains
(
key
)))
{
var
newSheet
=
workbook
.
CreateSheet
(
module
.
ModuleName
);
foreach
(
var
key
in
keyArray
)
{
var
item
=
pairs
.
FirstOrDefault
(
t
=>
t
.
Key
.
Contains
(
key
));
newSheet
.
CopySheet
(
item
.
Key
);
workbook
.
SetSheetOrder
(
module
.
ModuleName
,
item
.
Value
);
}
}
}
}
}
private
void
WriteOtherIncome
(
ISheet
sheet
,
IPerSheetDataRead
sheetRead
)
{
var
module
=
perforModmoduleRepository
.
GetEntity
(
t
=>
t
.
SheetType
==
(
int
)
SheetType
.
Expend
);
var
itemList
=
perforModitemRepository
.
GetEntities
(
t
=>
t
.
ModuleId
==
module
.
Id
);
var
nurseFactor
=
sheet
.
GetRow
(
sheetRead
.
Point
.
HeaderFirstRowNum
.
Value
+
1
);
var
doctorFactor
=
sheet
.
GetRow
(
sheetRead
.
Point
.
HeaderFirstRowNum
.
Value
+
2
);
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
;
//写入列头信息
foreach
(
var
item
in
itemList
)
{
head
.
GetCell
(
cellStartIndex
).
SetCellValue
(
item
.
ItemName
);
doctorFactor
.
GetCell
(
cellStartIndex
).
SetCellValue
(
item
.
FactorValue1
?.
ToString
());
nurseFactor
.
GetCell
(
cellStartIndex
).
SetCellValue
(
item
.
FactorValue2
?.
ToString
());
technicianFactor
.
GetCell
(
cellStartIndex
).
SetCellValue
(
item
.
FactorValue3
?.
ToString
());
cellStartIndex
++;
}
}
private
void
WriteIncome
(
ISheet
sheet
,
int
allotLastId
,
IPerSheetDataRead
sheetRead
,
List
<
sys_hospitalconfig
>
hospitalConfigList
)
{
var
moduleList
=
perforModmoduleRepository
.
GetEntities
(
t
=>
t
.
SheetType
==
(
int
)
SheetType
.
Income
);
foreach
(
var
module
in
moduleList
)
{
var
itemList
=
perforModitemRepository
.
GetEntities
(
t
=>
t
.
ModuleId
==
module
.
Id
);
var
nurseFactor
=
sheet
.
GetRow
(
sheetRead
.
Point
.
HeaderFirstRowNum
.
Value
+
1
);
var
doctorFactor
=
sheet
.
GetRow
(
sheetRead
.
Point
.
HeaderFirstRowNum
.
Value
+
2
);
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
;
foreach
(
var
item
in
itemList
)
{
head
.
GetCell
(
cellStartIndex
).
SetCellValue
(
item
.
ItemName
);
doctorFactor
.
GetCell
(
cellStartIndex
).
SetCellValue
(
item
.
FactorValue1
?.
ToString
());
nurseFactor
.
GetCell
(
cellStartIndex
).
SetCellValue
(
item
.
FactorValue2
?.
ToString
());
technicianFactor
.
GetCell
(
cellStartIndex
).
SetCellValue
(
item
.
FactorValue3
?.
ToString
());
cellStartIndex
++;
}
//查询数据
var
extractList
=
perforModextractRepository
.
GetEntities
(
t
=>
module
.
ExtractId
==
t
.
Id
);
List
<
ExtractDto
>
allExtract
=
new
List
<
ExtractDto
>();
foreach
(
var
item
in
extractList
)
{
var
result
=
QueryDatabase
(
hospitalConfigList
,
item
);
if
(
result
!=
null
)
allExtract
.
AddRange
(
result
);
}
//写入数据
var
importSheet
=
perforPersheetRepository
.
GetEntities
(
t
=>
t
.
AllotID
==
allotLastId
&&
t
.
SheetType
==
(
int
)
SheetType
.
Income
);
var
importSheetId
=
importSheet
.
Select
(
t
=>
t
.
ID
).
ToList
();
var
importData
=
perforImdataRepository
.
GetEntities
(
t
=>
importSheetId
.
Contains
(
t
.
SheetID
.
Value
));
var
rowIndex
=
sheetRead
.
Point
.
HeaderFirstRowNum
.
Value
+
3
;
foreach
(
var
department
in
allExtract
.
Select
(
t
=>
t
.
Department
).
Distinct
())
{
var
row
=
sheet
.
CreateRow
(
rowIndex
);
for
(
int
i
=
head
.
FirstCellNum
;
i
<
head
.
LastCellNum
;
i
++)
{
var
headName
=
head
.
GetCell
(
i
).
StringCellValue
;
var
newCell
=
row
.
CreateCell
(
i
);
if
(
headName
==
"核算单元(医生组)"
)
{
var
dept
=
importData
.
FirstOrDefault
(
t
=>
t
.
Department
==
department
&&
t
.
UnitType
==
1
)?.
AccountingUnit
;
newCell
.
SetCellValue
(
dept
??
""
);
}
else
if
(
headName
==
"核算单元(护理组)"
)
{
var
dept
=
importData
.
FirstOrDefault
(
t
=>
t
.
Department
==
department
&&
t
.
UnitType
==
2
)?.
AccountingUnit
;
newCell
.
SetCellValue
(
dept
??
""
);
}
else
if
(
headName
==
"核算单元(医技组)"
)
{
var
dept
=
importData
.
FirstOrDefault
(
t
=>
t
.
Department
==
department
&&
t
.
UnitType
==
3
)?.
AccountingUnit
;
newCell
.
SetCellValue
(
dept
??
""
);
}
else
if
(
headName
==
"科室名称"
)
{
var
dept
=
importData
.
FirstOrDefault
(
t
=>
t
.
Department
==
department
)?.
Department
;
newCell
.
SetCellValue
(
dept
??
""
);
}
else
{
var
value
=
allExtract
.
FirstOrDefault
(
t
=>
t
.
Department
==
department
&&
t
.
Category
==
headName
)?.
Value
;
newCell
.
SetCellValue
(
value
==
null
||
value
==
0
?
""
:
value
.
ToString
());
}
newCell
.
CellStyle
.
FillBackgroundColor
=
NPOI
.
HSSF
.
Util
.
HSSFColor
.
LightBlue
.
Index
;
}
}
}
}
private
void
WriteWorkload
(
ISheet
sheet
,
int
allotLastId
,
IPerSheetDataRead
sheetRead
,
List
<
sys_hospitalconfig
>
hospitalConfigList
)
{
var
module
=
perforModmoduleRepository
.
GetEntity
(
t
=>
t
.
SheetType
==
(
int
)
SheetType
.
Workload
);
var
itemList
=
perforModitemRepository
.
GetEntities
(
t
=>
t
.
ModuleId
==
module
.
Id
);
var
head
=
sheet
.
GetRow
(
sheetRead
.
Point
.
HeaderFirstRowNum
.
Value
+
1
);
var
factor
=
sheet
.
GetRow
(
sheetRead
.
Point
.
HeaderFirstRowNum
.
Value
+
2
);
//写入列头信息
int
cellStartIndex
=
sheetRead
.
Point
.
HeaderFirstCellNum
.
Value
+
3
;
foreach
(
var
item
in
itemList
)
{
head
.
GetCell
(
cellStartIndex
).
SetCellValue
(
item
.
ItemName
);
factor
.
GetCell
(
cellStartIndex
).
SetCellValue
(
item
.
FactorValue1
?.
ToString
());
cellStartIndex
++;
}
//查询数据
var
extractIdList
=
itemList
.
Select
(
t
=>
t
.
ExtractId
).
Distinct
().
ToList
();
var
extractList
=
perforModextractRepository
.
GetEntities
(
t
=>
extractIdList
.
Contains
(
t
.
Id
));
List
<
ExtractDto
>
allExtract
=
new
List
<
ExtractDto
>();
foreach
(
var
item
in
extractList
)
{
var
result
=
QueryDatabase
(
hospitalConfigList
,
item
);
if
(
result
!=
null
)
allExtract
.
AddRange
(
result
);
}
//写入数据
var
importSheet
=
perforPersheetRepository
.
GetEntity
(
t
=>
t
.
AllotID
==
allotLastId
&&
t
.
SheetName
==
module
.
ModuleName
);
var
importData
=
perforImdataRepository
.
GetEntities
(
t
=>
t
.
SheetID
==
importSheet
.
ID
);
var
rowIndex
=
sheetRead
.
Point
.
HeaderFirstRowNum
.
Value
+
3
;
foreach
(
var
department
in
allExtract
.
Select
(
t
=>
t
.
Department
).
Distinct
())
{
var
row
=
sheet
.
CreateRow
(
rowIndex
);
for
(
int
i
=
head
.
FirstCellNum
;
i
<
head
.
LastCellNum
;
i
++)
{
var
headName
=
head
.
GetCell
(
i
).
StringCellValue
;
var
newCell
=
row
.
CreateCell
(
i
);
if
(
headName
==
"核算单元"
)
{
var
dept
=
importData
.
FirstOrDefault
(
t
=>
t
.
Department
==
department
)?.
AccountingUnit
;
newCell
.
SetCellValue
(
dept
??
""
);
}
else
if
(
headName
==
"科室名称"
)
{
var
dept
=
importData
.
FirstOrDefault
(
t
=>
t
.
Department
==
department
)?.
Department
;
newCell
.
SetCellValue
(
dept
??
""
);
}
else
{
var
value
=
allExtract
.
FirstOrDefault
(
t
=>
t
.
Department
==
department
&&
t
.
Category
==
headName
)?.
Value
;
newCell
.
SetCellValue
(
value
==
null
||
value
==
0
?
""
:
value
.
ToString
());
}
newCell
.
CellStyle
.
FillBackgroundColor
=
NPOI
.
HSSF
.
Util
.
HSSFColor
.
LightBlue
.
Index
;
}
}
}
private
List
<
ExtractDto
>
QueryDatabase
(
List
<
sys_hospitalconfig
>
hospitalConfigList
,
mod_extract
extract
)
{
var
config
=
hospitalConfigList
.
FirstOrDefault
(
t
=>
t
.
Type
==
extract
.
SourceType
);
using
(
var
connection
=
ConnectionBuilder
.
Create
(
DatabaseType
.
SqlServer
,
config
.
DbSource
,
config
.
DbName
,
config
.
DbUser
,
config
.
DbPassword
))
{
var
result
=
connection
.
Query
<
ExtractDto
>(
extract
.
ExecuteScript
);
if
(
result
!=
null
&&
result
.
Count
()
>
0
)
{
if
(
extract
.
ExecuteType
==
2
)
{
foreach
(
var
item
in
result
)
{
item
.
Category
=
extract
.
EName
;
}
}
return
result
.
ToList
();
}
}
return
null
;
}
private
void
WriteExpend
(
ISheet
sheet
,
IPerSheetDataRead
sheetRead
)
{
var
module
=
perforModmoduleRepository
.
GetEntity
(
t
=>
t
.
SheetType
==
(
int
)
SheetType
.
Expend
);
var
itemList
=
perforModitemRepository
.
GetEntities
(
t
=>
t
.
ModuleId
==
module
.
Id
);
var
head
=
sheet
.
GetRow
(
sheetRead
.
Point
.
HeaderFirstRowNum
.
Value
+
1
);
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
;
//写入列头信息
foreach
(
var
item
in
itemList
)
{
head
.
GetCell
(
cellStartIndex
).
SetCellValue
(
item
.
ItemName
);
doctorFactor
.
GetCell
(
cellStartIndex
).
SetCellValue
(
item
.
FactorValue1
?.
ToString
());
nurseFactor
.
GetCell
(
cellStartIndex
).
SetCellValue
(
item
.
FactorValue2
?.
ToString
());
cellStartIndex
++;
}
}
private
string
CopyOriginalFile
(
int
hospitalId
,
UseTemplate
useTemplate
)
{
string
originalPath
=
Path
.
Combine
(
environment
.
ContentRootPath
,
"Template"
,
"医院绩效模板.xlsx"
);
var
dpath
=
Path
.
Combine
(
environment
.
ContentRootPath
,
"Files"
,
$"
{
hospitalId
}
"
,
"autoextract"
);
FileHelper
.
CreateDirectory
(
dpath
);
string
path
=
Path
.
Combine
(
dpath
,
$"绩效提取数据
{
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmssfff"
)}
.xlsx"
);
FileHelper
.
Copy
(
originalPath
,
path
);
return
path
;
}
private
void
WriteEmployee
(
ISheet
sheet
,
int
allotLastId
,
IPerSheetDataRead
sheetRead
)
{
var
dictionary
=
new
Dictionary
<
string
,
Func
<
im_employee
,
object
>>
{
{
"核算单元"
,
(
t
)
=>
t
.
AccountingUnit
},
{
"医生姓名"
,
(
t
)
=>
t
.
DoctorName
},
{
"职称"
,
(
t
)
=>
t
.
JobTitle
},
{
"绩效基数核算参考对象"
,
(
t
)
=>
t
.
FitPeople
},
{
"绩效基数核算系数"
,
(
t
)
=>
t
.
FitPeopleRatio
},
{
"核算单元分类"
,
(
t
)
=>
t
.
AccountType
},
{
"岗位系数"
,
(
t
)
=>
t
.
PostCoefficient
},
{
"参加工作时间"
,
(
t
)
=>
t
.
WorkTime
},
{
"考核得分率"
,
(
t
)
=>
t
.
ScoreAverageRate
},
{
"出勤率"
,
(
t
)
=>
t
.
Attendance
},
{
"其他绩效"
,
(
t
)
=>
t
.
OtherPerfor
},
{
"医院奖罚"
,
(
t
)
=>
t
.
Punishment
},
{
"调节系数"
,
(
t
)
=>
t
.
Adjust
},
};
var
dataList
=
perforImemployeeRepository
.
GetEntities
(
t
=>
t
.
AllotID
==
allotLastId
);
for
(
int
i
=
0
;
i
<
dataList
.
Count
;
i
++)
{
var
headIndex
=
sheetRead
.
Point
.
HeaderFirstRowNum
;
var
cellList
=
sheet
.
GetRow
(
headIndex
.
Value
).
Cells
;
var
rowIndex
=
sheetRead
.
Point
.
DataFirstRowNum
.
Value
+
i
;
var
importRow
=
sheet
.
CreateRow
(
rowIndex
);
foreach
(
var
cell
in
cellList
)
{
var
item
=
dictionary
.
FirstOrDefault
(
t
=>
t
.
Key
==
cell
.
StringCellValue
);
var
value
=
(
item
.
Value
.
Invoke
(
dataList
[
i
])
??
""
).
ToString
();
importRow
.
CreateCell
(
cell
.
ColumnIndex
).
SetCellValue
(
Verify
(
value
));
}
}
}
private
void
WriteSpecialUnit
(
ISheet
sheet
,
int
hospitalId
,
int
allotLastId
,
IPerSheetDataRead
sheetRead
)
{
var
dictionary
=
new
Dictionary
<
string
,
Func
<
mod_special
,
List
<
im_specialunit
>,
object
>>
{
{
"科室"
,
(
special
,
lastAllot
)
=>
special
.
Department
},
{
"人数"
,
(
special
,
lastAllot
)
=>
lastAllot
.
Where
(
t
=>
special
.
Department
==
t
.
Department
).
Sum
(
t
=>
t
.
Number
)
},
{
"量化指标"
,
(
special
,
lastAllot
)
=>
special
.
Target
},
{
"量化指标绩效分值"
,(
special
,
lastAllot
)
=>
special
.
TargetFactor
},
{
"调节系数"
,
(
special
,
lastAllot
)
=>
lastAllot
.
Where
(
t
=>
special
.
Department
==
t
.
Department
).
Max
(
t
=>
t
.
Adjust
)
},
};
var
modDataList
=
perforModspecialRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
hospitalId
);
var
allotDataList
=
perforImspecialunitRepository
.
GetEntities
(
t
=>
t
.
AllotID
==
allotLastId
);
for
(
int
i
=
0
;
i
<
modDataList
.
Count
;
i
++)
{
var
headIndex
=
sheetRead
.
Point
.
HeaderFirstRowNum
;
var
cellList
=
sheet
.
GetRow
(
headIndex
.
Value
).
Cells
;
var
rowIndex
=
sheetRead
.
Point
.
DataFirstRowNum
.
Value
+
i
;
var
importRow
=
sheet
.
CreateRow
(
rowIndex
);
foreach
(
var
cell
in
cellList
)
{
var
item
=
dictionary
.
FirstOrDefault
(
t
=>
t
.
Key
==
cell
.
StringCellValue
);
var
value
=
(
item
.
Value
.
Invoke
(
modDataList
[
i
],
allotDataList
)
??
""
).
ToString
();
var
newCell
=
importRow
.
CreateCell
(
cell
.
ColumnIndex
);
newCell
.
SetCellValue
(
Verify
(
value
));
newCell
.
CellStyle
.
FillBackgroundColor
=
NPOI
.
HSSF
.
Util
.
HSSFColor
.
LightBlue
.
Index
;
}
}
}
private
void
WriteAccountBasic
(
ISheet
sheet
,
int
allotLastId
,
IPerSheetDataRead
sheetRead
)
{
var
dictionary
=
new
Dictionary
<
string
,
Func
<
im_accountbasic
,
object
>>
{
{
"核算单元(医生组)"
,
(
t
)
=>
t
.
DoctorAccountingUnit
},
{
"核算单元(护理组)"
,
(
t
)
=>
t
.
NurseAccountingUnit
},
{
"科室名称"
,
(
t
)
=>
t
.
Department
},
{
"医生组核算单元医生数量"
,
(
t
)
=>
t
.
DoctorNumber
},
{
"医生组基础系数"
,
(
t
)
=>
t
.
DoctorBasicFactor
},
{
"医生组倾斜系数"
,
(
t
)
=>
t
.
DoctorSlopeFactor
},
{
"医生组其他绩效1"
,
(
t
)
=>
t
.
DoctorOtherPerfor1
},
{
"医生组考核得分率"
,
(
t
)
=>
t
.
DoctorScoringAverage
},
{
"医生组医院奖罚"
,
(
t
)
=>
t
.
DoctorExtra
},
{
"医生组其他绩效2"
,
(
t
)
=>
t
.
DoctorOtherPerfor2
},
{
"医生组调节系数"
,
(
t
)
=>
t
.
DoctorAdjustFactor
},
{
"护理组核算单元护士数量"
,
(
t
)
=>
t
.
NurseNumber
},
{
"护理组基础系数"
,
(
t
)
=>
t
.
NurseBasicFactor
},
{
"护理组倾斜系数"
,
(
t
)
=>
t
.
NurseSlopeFactor
},
{
"护理组其他绩效1"
,
(
t
)
=>
t
.
NurseOtherPerfor1
},
{
"护理组考核得分率"
,
(
t
)
=>
t
.
NurseScoringAverage
},
{
"护理组医院奖罚"
,
(
t
)
=>
t
.
NurseExtra
},
{
"护理组其他绩效2"
,
(
t
)
=>
t
.
NurseOtherPerfor2
},
{
"护理组调节系数"
,
(
t
)
=>
t
.
NurseAdjustFactor
},
};
var
dataList
=
perforImaccountbasicRepository
.
GetEntities
(
t
=>
t
.
AllotID
==
allotLastId
);
for
(
int
i
=
0
;
i
<
dataList
.
Count
;
i
++)
{
var
headIndex
=
sheetRead
.
Point
.
HeaderFirstRowNum
;
var
cellList
=
sheet
.
GetRow
(
headIndex
.
Value
).
Cells
;
var
rowIndex
=
sheetRead
.
Point
.
DataFirstRowNum
.
Value
+
i
;
var
importRow
=
sheet
.
CreateRow
(
rowIndex
);
foreach
(
var
cell
in
cellList
)
{
var
item
=
dictionary
.
FirstOrDefault
(
t
=>
t
.
Key
==
cell
.
StringCellValue
);
var
value
=
(
item
.
Value
.
Invoke
(
dataList
[
i
])
??
""
).
ToString
();
var
newCell
=
importRow
.
CreateCell
(
cell
.
ColumnIndex
);
newCell
.
SetCellValue
(
Verify
(
value
));
newCell
.
CellStyle
.
FillBackgroundColor
=
NPOI
.
HSSF
.
Util
.
HSSFColor
.
LightBlue
.
Index
;
}
}
}
#
region
校验数据格式
/// <summary>
/// 校验数据格式,并转换
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public
dynamic
Verify
(
string
obj
)
{
try
{
//判断值是否为double类型
if
(!
string
.
IsNullOrEmpty
(
obj
)
&&
Regex
.
Match
(
obj
.
Trim
(),
@"([1-9]\d*\.?\d*)|(0\.\d*[1-9]?\d*)|0"
).
ToString
()
==
obj
.
Trim
())
return
ConvertHelper
.
To
<
double
>(
obj
);
//判断值是否为日期格式
else
if
(!
string
.
IsNullOrEmpty
(
obj
)
&&
Regex
.
Match
(
obj
.
Trim
(),
@"(19|20)\d{2}(-|/)[01]?\d(-|/)[0123]?\d( [012]?\d\:\d{2}\:\d{2})?"
).
ToString
()
==
obj
.
Trim
())
return
ConvertHelper
.
To
<
DateTime
>(
obj
).
ToString
(
"yyyy/M/d"
);
else
return
obj
;
}
catch
{
return
obj
;
}
}
#
endregion
#
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