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
e73d4b6a
Commit
e73d4b6a
authored
Mar 19, 2020
by
lcx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提取数据含有历史绩效时,保留科室,补充数据
parent
6b98dbdb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
264 additions
and
99 deletions
+264
-99
performance/Performance.Extract.Api/Controllers/ExtractController.cs
+7
-4
performance/Performance.Services/DFExtractService.cs
+257
-95
No files found.
performance/Performance.Extract.Api/Controllers/ExtractController.cs
View file @
e73d4b6a
...
...
@@ -136,6 +136,8 @@ public void ExtractData([FromForm] IFormCollection form, int allotId, int hospit
path
=
Path
.
Combine
(
dpath
,
FileHelper
.
GetFileName
(
file
.
FileName
));
logger
.
LogInformation
(
$"保存历史绩效文件保存路径:"
+
path
);
if
(!
string
.
IsNullOrEmpty
(
path
)
&&
FileHelper
.
IsExistFile
(
path
))
FileHelper
.
DeleteFile
(
path
);
using
(
var
stream
=
file
.
OpenReadStream
())
{
...
...
@@ -152,14 +154,15 @@ public void ExtractData([FromForm] IFormCollection form, int allotId, int hospit
//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
,
hospitalId
}));
logger
.
LogInformation
(
"请求路径:"
+
url
.
ImportFile
+
",请求参数"
+
JsonHelper
.
Serialize
(
new
{
allotId
,
hospitalId
}));
int
i
=
1
;
while
(
i
<=
5
)
{
...
...
performance/Performance.Services/DFExtractService.cs
View file @
e73d4b6a
...
...
@@ -114,7 +114,8 @@ public string ExtractData(int allotId, string email, int hospitalId, string file
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
,
filePath
);
return
lastAllot
==
null
?
TemplateExecute
(
email
,
hospital
,
configs
,
modules
,
items
,
specials
,
extracts
)
:
AlllotExecute
(
email
,
hospital
,
configs
,
modules
,
items
,
specials
,
extracts
,
lastAllot
,
filePath
);
}
catch
(
Exception
ex
)
{
...
...
@@ -145,7 +146,7 @@ public string ExtractData(int allotId, string email, int hospitalId, string file
/// <param name="specials"></param>
/// <param name="extracts"></param>
/// <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
,
sys_hospital
hospital
,
List
<
sys_hospitalconfig
>
configs
,
List
<
mod_module
>
modules
,
List
<
mod_item
>
items
,
List
<
mod_special
>
specials
,
List
<
mod_extract
>
extracts
)
{
string
originalPath
=
Path
.
Combine
(
AppDomain
.
CurrentDomain
.
BaseDirectory
,
"Template"
,
"东方医院绩效模板.xlsx"
);
var
(
tempPath
,
newPath
)
=
CopyOriginalFile
(
hospital
.
ID
,
originalPath
);
...
...
@@ -156,8 +157,6 @@ public string TemplateExecute(string email, per_allot lastAllot, sys_hospital ho
style
=
CellStyle
.
CreateCellStyle
(
workbook
,
StyleType
.
数据
);
List
<
AccountUnitEntity
>
unitList
=
new
List
<
AccountUnitEntity
>();
if
(
lastAllot
!=
null
)
unitList
=
perforImdataRepository
.
GetAccountUnit
(
lastAllot
.
ID
).
ToList
();
for
(
int
i
=
0
;
i
<
workbook
.
NumberOfSheets
;
i
++)
{
...
...
@@ -207,7 +206,7 @@ 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
,
string
path
)
public
string
AlllotExecute
(
string
email
,
sys_hospital
hospital
,
List
<
sys_hospitalconfig
>
configs
,
List
<
mod_module
>
modules
,
List
<
mod_item
>
items
,
List
<
mod_special
>
specials
,
List
<
mod_extract
>
extracts
,
per_allot
lastAllot
,
string
path
)
{
if
(
string
.
IsNullOrEmpty
(
path
))
throw
new
PerformanceException
(
"历史绩效文件不存在!"
);
...
...
@@ -226,29 +225,28 @@ public string AlllotExecute(string email, per_allot lastAllot, sys_hospital hosp
{
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
.
OtherIncome
:
ClearData
(
sheet
,
5
);
ClearData
(
sheet
,
5
,
4
);
WriteOtherIncome
(
sheet
,
sheetRead
,
unitList
,
configs
,
modules
,
items
,
extracts
,
false
);
break
;
case
SheetType
.
Income
:
ClearData
(
sheet
,
5
);
ClearData
(
sheet
,
5
,
4
,
true
);
WriteIncome
(
sheet
,
sheetRead
,
unitList
,
configs
,
modules
,
items
,
extracts
,
false
);
break
;
case
SheetType
.
Expend
:
ClearData
(
sheet
,
5
);
ClearData
(
sheet
,
5
,
4
);
WriteExpend
(
sheet
,
sheetRead
,
unitList
,
configs
,
modules
,
items
,
extracts
,
false
);
break
;
case
SheetType
.
Workload
:
ClearData
(
sheet
,
3
);
ClearData
(
sheet
,
3
,
2
);
WriteWorkload
(
sheet
,
sheetRead
,
unitList
,
configs
,
modules
,
items
,
extracts
,
false
);
break
;
case
SheetType
.
SpecialUnit
:
ClearData
(
sheet
,
2
);
ClearData
(
sheet
,
2
,
0
);
WriteSpecialUnit
(
sheet
,
sheetRead
,
configs
,
specials
,
extracts
,
false
,
lastAllot
);
break
;
}
...
...
@@ -308,7 +306,7 @@ private static void CreateNotExistSheet(List<mod_module> modulesList, IWorkbook
}
}
private
void
ClearData
(
ISheet
sheet
,
int
beginRowNum
)
private
void
ClearData
(
ISheet
sheet
,
int
beginRowNum
,
int
beginCellNum
,
bool
isIncome
=
false
)
{
if
(
sheet
==
null
)
return
;
...
...
@@ -318,10 +316,11 @@ private void ClearData(ISheet sheet, int beginRowNum)
var
row
=
sheet
.
GetRow
(
i
);
if
(
row
!=
null
)
{
for
(
int
j
=
0
;
j
<
row
.
LastCellNum
+
1
;
j
++)
//跳过核算单元和科室
for
(
int
j
=
beginCellNum
;
j
<
row
.
LastCellNum
;
j
++)
{
var
cell
=
row
.
GetCell
(
j
);
if
(
cell
!=
null
&&
cell
.
CellType
!=
CellType
.
Formula
)
if
(
cell
!=
null
&&
(
cell
.
CellType
!=
CellType
.
Formula
||
isIncome
)
)
{
cell
.
RemoveCellComment
();
row
.
RemoveCell
(
cell
);
...
...
@@ -356,7 +355,7 @@ private ICell GetOrCreate(IRow row, int index)
#
region
SheetData
private
void
WriteOtherIncome
(
ISheet
sheet
,
IPerSheetDataRead
sheetRead
,
List
<
AccountUnitEntity
>
unitList
,
List
<
sys_hospitalconfig
>
configs
,
List
<
mod_module
>
modules
,
List
<
mod_item
>
items
,
List
<
mod_extract
>
extracts
,
bool
IsWriteHead
=
true
)
private
void
WriteOtherIncome
(
ISheet
sheet
,
IPerSheetDataRead
sheetRead
,
List
<
AccountUnitEntity
>
unitList
,
List
<
sys_hospitalconfig
>
configs
,
List
<
mod_module
>
modules
,
List
<
mod_item
>
items
,
List
<
mod_extract
>
extracts
,
bool
isNewTemp
=
true
)
{
logger
.
LogInformation
(
$"
{
sheet
.
SheetName
}
开始提取."
);
var
module
=
modules
.
FirstOrDefault
(
t
=>
t
.
SheetType
==
(
int
)
SheetType
.
OtherIncome
);
...
...
@@ -366,8 +365,7 @@ private void WriteOtherIncome(ISheet sheet, IPerSheetDataRead sheetRead, List<Ac
logger
.
LogInformation
(
$"item有
{
itemList
?.
Count
??
0
}
个."
);
if
(
itemList
==
null
||
!
itemList
.
Any
())
return
;
if
(
IsWriteHead
)
WriteHeaderAndFactor
(
sheet
,
sheetRead
,
itemList
);
WriteHeaderAndFactor
(
sheet
,
sheetRead
,
itemList
,
isNewTemp
);
//查询数据
var
extractIdList
=
itemList
.
Select
(
t
=>
t
.
ExtractId
).
Distinct
().
ToList
();
...
...
@@ -392,11 +390,11 @@ private void WriteOtherIncome(ISheet sheet, IPerSheetDataRead sheetRead, List<Ac
}
}
WriteSheetData
(
sheet
,
sheetRead
,
unitList
,
allExtract
,
itemList
.
Select
(
t
=>
t
.
ItemName
));
WriteSheetData
(
sheet
,
sheetRead
,
unitList
,
allExtract
,
itemList
.
Select
(
t
=>
t
.
ItemName
)
,
isNewTemp
);
logger
.
LogInformation
(
$"
{
sheet
.
SheetName
}
提取结束."
);
}
private
void
WriteIncome
(
ISheet
sheet
,
IPerSheetDataRead
sheetRead
,
List
<
AccountUnitEntity
>
unitList
,
List
<
sys_hospitalconfig
>
configs
,
List
<
mod_module
>
modules
,
List
<
mod_item
>
items
,
List
<
mod_extract
>
extracts
,
bool
IsWriteHead
=
true
)
private
void
WriteIncome
(
ISheet
sheet
,
IPerSheetDataRead
sheetRead
,
List
<
AccountUnitEntity
>
unitList
,
List
<
sys_hospitalconfig
>
configs
,
List
<
mod_module
>
modules
,
List
<
mod_item
>
items
,
List
<
mod_extract
>
extracts
,
bool
isNewTemp
=
true
)
{
logger
.
LogInformation
(
$"
{
sheet
.
SheetName
}
开始提取."
);
var
module
=
modules
.
FirstOrDefault
(
t
=>
t
.
ModuleName
.
Replace
(
" "
,
""
)
==
sheet
.
SheetName
.
Replace
(
" "
,
""
));
...
...
@@ -406,8 +404,7 @@ private void WriteIncome(ISheet sheet, IPerSheetDataRead sheetRead, List<Account
logger
.
LogInformation
(
$"item有
{
itemList
?.
Count
??
0
}
个."
);
if
(
itemList
==
null
||
!
itemList
.
Any
())
return
;
if
(
IsWriteHead
)
WriteHeaderAndFactor
(
sheet
,
sheetRead
,
itemList
);
WriteHeaderAndFactor
(
sheet
,
sheetRead
,
itemList
,
isNewTemp
);
//查询数据
var
extractList
=
extracts
.
Where
(
t
=>
module
.
ExtractId
==
t
.
Id
).
ToList
();
...
...
@@ -426,11 +423,11 @@ private void WriteIncome(ISheet sheet, IPerSheetDataRead sheetRead, List<Account
allExtract
.
AddRange
(
result
);
}
WriteSheetData
(
sheet
,
sheetRead
,
unitList
,
allExtract
,
itemList
.
Select
(
t
=>
t
.
ItemName
),
true
);
WriteSheetData
(
sheet
,
sheetRead
,
unitList
,
allExtract
,
itemList
.
Select
(
t
=>
t
.
ItemName
),
isNewTemp
,
true
);
logger
.
LogInformation
(
$"
{
sheet
.
SheetName
}
提取结束."
);
}
private
void
WriteExpend
(
ISheet
sheet
,
IPerSheetDataRead
sheetRead
,
List
<
AccountUnitEntity
>
unitList
,
List
<
sys_hospitalconfig
>
configs
,
List
<
mod_module
>
modules
,
List
<
mod_item
>
items
,
List
<
mod_extract
>
extracts
,
bool
IsWriteHead
=
true
)
private
void
WriteExpend
(
ISheet
sheet
,
IPerSheetDataRead
sheetRead
,
List
<
AccountUnitEntity
>
unitList
,
List
<
sys_hospitalconfig
>
configs
,
List
<
mod_module
>
modules
,
List
<
mod_item
>
items
,
List
<
mod_extract
>
extracts
,
bool
isNewTemp
=
true
)
{
logger
.
LogInformation
(
$"
{
sheet
.
SheetName
}
开始提取."
);
var
module
=
modules
.
FirstOrDefault
(
t
=>
t
.
SheetType
==
(
int
)
SheetType
.
Expend
);
...
...
@@ -440,8 +437,7 @@ private void WriteExpend(ISheet sheet, IPerSheetDataRead sheetRead, List<Account
logger
.
LogInformation
(
$"item有
{
itemList
?.
Count
??
0
}
个."
);
if
(
itemList
==
null
||
!
itemList
.
Any
())
return
;
if
(
IsWriteHead
)
WriteHeaderAndFactor
(
sheet
,
sheetRead
,
itemList
);
WriteHeaderAndFactor
(
sheet
,
sheetRead
,
itemList
,
isNewTemp
);
//查询数据
var
extractIdList
=
itemList
.
Select
(
t
=>
t
.
ExtractId
).
Distinct
().
ToList
();
...
...
@@ -466,11 +462,11 @@ private void WriteExpend(ISheet sheet, IPerSheetDataRead sheetRead, List<Account
}
}
WriteSheetData
(
sheet
,
sheetRead
,
unitList
,
allExtract
,
itemList
.
Select
(
t
=>
t
.
ItemName
));
WriteSheetData
(
sheet
,
sheetRead
,
unitList
,
allExtract
,
itemList
.
Select
(
t
=>
t
.
ItemName
)
,
isNewTemp
);
logger
.
LogInformation
(
$"
{
sheet
.
SheetName
}
提取结束."
);
}
private
void
WriteWorkload
(
ISheet
sheet
,
IPerSheetDataRead
sheetRead
,
List
<
AccountUnitEntity
>
unitList
,
List
<
sys_hospitalconfig
>
configs
,
List
<
mod_module
>
modules
,
List
<
mod_item
>
items
,
List
<
mod_extract
>
extracts
,
bool
IsWriteHead
=
true
)
private
void
WriteWorkload
(
ISheet
sheet
,
IPerSheetDataRead
sheetRead
,
List
<
AccountUnitEntity
>
unitList
,
List
<
sys_hospitalconfig
>
configs
,
List
<
mod_module
>
modules
,
List
<
mod_item
>
items
,
List
<
mod_extract
>
extracts
,
bool
isNewTemp
=
true
)
{
logger
.
LogInformation
(
$"
{
sheet
.
SheetName
}
开始提取."
);
var
module
=
modules
.
FirstOrDefault
(
t
=>
t
.
ModuleName
.
Replace
(
" "
,
""
)
==
sheet
.
SheetName
.
Replace
(
" "
,
""
));
...
...
@@ -480,27 +476,7 @@ private void WriteWorkload(ISheet sheet, IPerSheetDataRead sheetRead, List<Accou
logger
.
LogInformation
(
$"item有
{
itemList
?.
Count
??
0
}
个."
);
if
(
itemList
==
null
||
!
itemList
.
Any
())
return
;
var
head
=
GetOrCreate
(
sheet
,
sheetRead
.
Point
.
HeaderFirstRowNum
.
Value
+
0
);
var
factor
=
GetOrCreate
(
sheet
,
sheetRead
.
Point
.
HeaderFirstRowNum
.
Value
+
1
);
if
(
IsWriteHead
)
{
logManageService
.
WriteMsg
(
"提取绩效数据"
,
$"写入列头信息 --
{
module
.
ModuleName
}
"
,
1
,
Allot
.
ID
,
"ReceiveMessage"
);
logger
.
LogInformation
(
$"提取绩效数据 写入列头信息 --
{
module
.
ModuleName
}
"
);
//写入列头信息
int
cellStartIndex
=
sheetRead
.
Point
.
HeaderFirstCellNum
.
Value
+
2
;
foreach
(
var
item
in
itemList
)
{
var
headcell
=
GetOrCreate
(
head
,
cellStartIndex
);
headcell
.
SetCellValue
(
item
.
ItemName
);
headcell
.
CellStyle
=
CellStyle
.
CreateCellStyle
(
workbook
,
StyleType
.
列头
);
var
doctorcell
=
GetOrCreate
(
factor
,
cellStartIndex
);
doctorcell
.
SetCellValue
(
item
.
FactorValue1
!=
null
?
(
double
)
item
.
FactorValue1
:
0
);
doctorcell
.
CellStyle
=
CellStyle
.
CreateCellStyle
(
workbook
,
StyleType
.
列头
,
CellFormat
.
数字
2
);
cellStartIndex
++;
}
}
WriteWorkHeader
(
sheet
,
sheetRead
,
itemList
,
isNewTemp
);
//查询数据
var
extractIdList
=
itemList
.
Select
(
t
=>
t
.
ExtractId
).
Distinct
().
ToList
();
...
...
@@ -535,36 +511,7 @@ private void WriteWorkload(ISheet sheet, IPerSheetDataRead sheetRead, List<Accou
logManageService
.
WriteMsg
(
"提取绩效数据"
,
$"填充数据 --
{
module
.
ModuleName
}
"
,
1
,
Allot
.
ID
,
"ReceiveMessage"
);
logger
.
LogInformation
(
$"提取绩效数据 填充数据 --
{
module
.
ModuleName
}
"
);
//写入数据
var
rowIndex
=
sheetRead
.
Point
.
HeaderFirstRowNum
.
Value
+
2
;
foreach
(
var
department
in
allExtract
.
Select
(
t
=>
t
.
Department
).
Distinct
())
{
var
row
=
GetOrCreate
(
sheet
,
rowIndex
);
for
(
int
i
=
head
.
FirstCellNum
;
i
<
head
.
LastCellNum
;
i
++)
{
var
headName
=
head
.
GetCell
(
i
).
StringCellValue
;
var
newCell
=
GetOrCreate
(
row
,
i
);
if
(
headName
==
"核算单元"
)
{
var
dept
=
unitList
.
FirstOrDefault
(
t
=>
t
.
SheetName
==
sheet
.
SheetName
&&
t
.
Department
==
department
)?.
AccountingUnit
;
newCell
.
SetCellValue
(
dept
??
""
);
newCell
.
CellStyle
=
CellStyle
.
CreateCellStyle
(
workbook
,
StyleType
.
默认
);
}
else
if
(
headName
==
"科室名称"
)
{
newCell
.
SetCellValue
(
department
??
""
);
newCell
.
CellStyle
=
CellStyle
.
CreateCellStyle
(
workbook
,
StyleType
.
默认
);
}
else
if
(
newCell
.
CellType
!=
CellType
.
Formula
)
{
var
extract
=
allExtract
.
FirstOrDefault
(
t
=>
t
.
Department
==
department
&&
t
.
Category
==
headName
);
var
value
=
extract
?.
Value
==
0
?
null
:
extract
?.
Value
;
OutToExcelCell
(
newCell
,
value
);
if
(
specialHead
!=
null
&&
specialHead
.
Contains
(
headName
))
newCell
.
CellStyle
=
style
;
}
}
rowIndex
++;
}
WriteWorkData
(
sheet
,
sheetRead
,
unitList
,
allExtract
,
specialHead
,
isNewTemp
);
logger
.
LogInformation
(
$"
{
sheet
.
SheetName
}
提取结束."
);
}
...
...
@@ -737,7 +684,15 @@ private void WriteSpecialUnit(ISheet sheet, IPerSheetDataRead sheetRead, List<sy
logger
.
LogInformation
(
$"
{
sheet
.
SheetName
}
提取结束."
);
}
private
void
WriteHeaderAndFactor
(
ISheet
sheet
,
IPerSheetDataRead
sheetRead
,
List
<
mod_item
>
items
)
#
region
写入数据
/// <summary>
/// 写入列头
/// </summary>
/// <param name="sheet"></param>
/// <param name="sheetRead"></param>
/// <param name="items">列头数据(列名、系数)</param>
/// <param name="isNewTemp">是否为空白模板</param>
private
void
WriteHeaderAndFactor
(
ISheet
sheet
,
IPerSheetDataRead
sheetRead
,
List
<
mod_item
>
items
,
bool
isNewTemp
)
{
var
nurseFactor
=
sheet
.
GetRow
(
sheetRead
.
Point
.
AccountingUnit
.
First
(
t
=>
t
.
UnitType
==
"护理组"
).
FactorRow
.
Value
);
var
doctorFactor
=
sheet
.
GetRow
(
sheetRead
.
Point
.
AccountingUnit
.
First
(
t
=>
t
.
UnitType
==
"医生组"
).
FactorRow
.
Value
);
...
...
@@ -746,43 +701,118 @@ private void WriteHeaderAndFactor(ISheet sheet, IPerSheetDataRead sheetRead, Lis
logManageService
.
WriteMsg
(
"提取绩效数据"
,
$"写入列头信息 --
{
sheet
.
SheetName
}
"
,
1
,
Allot
.
ID
,
"ReceiveMessage"
);
logger
.
LogInformation
(
$"提取绩效数据 提取绩效数据 写入列头信息 --
{
sheet
.
SheetName
}
"
);
//写入列头信息
int
cellStartIndex
=
sheetRead
.
Point
.
HeaderFirstCellNum
.
Value
+
4
;
foreach
(
var
item
in
items
)
var
cellItems
=
items
;
if
(!
isNewTemp
)
{
#
region
过滤历史模板中已有的列头
//写入列头信息
int
cellStartIndex
=
sheetRead
.
Point
.
HeaderFirstCellNum
.
Value
+
4
;
for
(
int
i
=
cellStartIndex
;
i
<
head
.
LastCellNum
;
i
++)
{
var
cellvalue
=
head
.
GetCell
(
i
)?.
ToString
();
if
(
string
.
IsNullOrEmpty
(
cellvalue
))
continue
;
cellItems
.
RemoveAll
(
t
=>
t
.
ItemName
==
cellvalue
);
}
#
endregion
}
if
(
cellItems
==
null
||
!
cellItems
.
Any
())
return
;
#
region
新增模板中不存在的列头
var
lastcellIndex
=
head
.
LastCellNum
;
foreach
(
var
item
in
cellItems
)
{
var
headcell
=
GetOrCreate
(
head
,
cellStart
Index
);
var
headcell
=
GetOrCreate
(
head
,
lastcell
Index
);
headcell
.
SetCellValue
(
item
.
ItemName
);
headcell
.
CellStyle
=
CellStyle
.
CreateCellStyle
(
workbook
,
StyleType
.
列头
);
var
doctorcell
=
GetOrCreate
(
doctorFactor
,
cellStart
Index
);
var
doctorcell
=
GetOrCreate
(
doctorFactor
,
lastcell
Index
);
doctorcell
.
SetCellValue
(
item
.
FactorValue1
!=
null
?
(
double
)
item
.
FactorValue1
:
0
);
doctorcell
.
CellStyle
=
CellStyle
.
CreateCellStyle
(
workbook
,
StyleType
.
系数
,
CellFormat
.
百分比
);
var
nursecell
=
GetOrCreate
(
nurseFactor
,
cellStart
Index
);
var
nursecell
=
GetOrCreate
(
nurseFactor
,
lastcell
Index
);
nursecell
.
SetCellValue
(
item
.
FactorValue2
!=
null
?
(
double
)
item
.
FactorValue2
:
0
);
nursecell
.
CellStyle
=
CellStyle
.
CreateCellStyle
(
workbook
,
StyleType
.
系数
,
CellFormat
.
百分比
);
var
techniciancell
=
GetOrCreate
(
technicianFactor
,
cellStart
Index
);
var
techniciancell
=
GetOrCreate
(
technicianFactor
,
lastcell
Index
);
techniciancell
.
SetCellValue
(
item
.
FactorValue3
!=
null
?
(
double
)
item
.
FactorValue3
:
0
);
techniciancell
.
CellStyle
=
CellStyle
.
CreateCellStyle
(
workbook
,
StyleType
.
系数
,
CellFormat
.
百分比
);
cellStart
Index
++;
lastcell
Index
++;
}
#
endregion
}
private
void
WriteSheetData
(
ISheet
sheet
,
IPerSheetDataRead
sheetRead
,
List
<
AccountUnitEntity
>
unitList
,
List
<
ExtractDto
>
allExtract
,
IEnumerable
<
string
>
header
,
bool
isIncom
=
false
)
/// <summary>
/// 写入数据
/// </summary>
/// <param name="sheet"></param>
/// <param name="sheetRead"></param>
/// <param name="unitList">核算单元</param>
/// <param name="allExtract">抽取的数据(科室、列头、数据)</param>
/// <param name="header">设定抽取的列头</param>
/// <param name="isNewTemp">是否为空白模板</param>
/// <param name="isIncom">是否是开单、执行收入</param>
private
void
WriteSheetData
(
ISheet
sheet
,
IPerSheetDataRead
sheetRead
,
List
<
AccountUnitEntity
>
unitList
,
List
<
ExtractDto
>
allExtract
,
IEnumerable
<
string
>
header
,
bool
isNewTemp
,
bool
isIncom
=
false
)
{
logManageService
.
WriteMsg
(
"提取绩效数据"
,
$"填充数据 --
{
sheet
.
SheetName
}
"
,
1
,
Allot
.
ID
,
"ReceiveMessage"
);
logger
.
LogInformation
(
$"提取绩效数据 填充数据 --
{
sheet
.
SheetName
}
"
);
//写入数据
var
head
=
GetOrCreate
(
sheet
,
sheetRead
.
Point
.
HeaderFirstRowNum
.
Value
);
var
rowIndex
=
sheetRead
.
Point
.
HeaderFirstRowNum
.
Value
+
1
;
foreach
(
var
department
in
allExtract
.
Select
(
t
=>
t
.
Department
).
Distinct
())
if
(!
isNewTemp
)
{
#
region
给历史模板已有科室补充数据
for
(
int
i
=
rowIndex
;
i
<
sheet
.
LastRowNum
+
1
;
i
++)
{
var
row
=
sheet
.
GetRow
(
i
);
if
(
row
!=
null
)
{
var
department
=
row
.
GetCell
(
3
)?.
ToString
();
if
(
string
.
IsNullOrEmpty
(
department
))
continue
;
var
deptData
=
allExtract
.
Where
(
t
=>
t
.
Department
==
department
);
if
(
deptData
==
null
||
!
deptData
.
Any
())
continue
;
for
(
int
j
=
rowIndex
;
j
<
head
.
LastCellNum
;
j
++)
{
var
headName
=
head
.
GetCell
(
j
).
StringCellValue
;
var
newCell
=
GetOrCreate
(
row
,
j
);
if
(
newCell
==
null
)
continue
;
var
value
=
deptData
.
FirstOrDefault
(
t
=>
t
.
Category
==
headName
)?.
Value
;
if
(
isIncom
)
{
value
=
value
==
0
?
null
:
value
;
OutToExcelCell
(
newCell
,
value
);
newCell
.
CellStyle
=
style
;
}
else
if
(
newCell
.
CellType
!=
CellType
.
Formula
)
{
value
=
value
==
0
?
null
:
value
;
OutToExcelCell
(
newCell
,
value
);
if
(
header
!=
null
&&
header
.
Contains
(
headName
))
newCell
.
CellStyle
=
style
;
}
}
allExtract
.
RemoveAll
(
t
=>
t
.
Department
==
department
);
}
}
#
endregion
}
if
(
allExtract
==
null
||
!
allExtract
.
Any
())
return
;
#
region
补充新的科室及数据
var
lastrowIndex
=
sheet
.
LastRowNum
+
1
;
foreach
(
var
department
in
allExtract
.
Select
(
t
=>
t
.
Department
).
Where
(
t
=>
!
string
.
IsNullOrEmpty
(
t
)).
Distinct
())
{
var
row
=
GetOrCreate
(
sheet
,
rowIndex
);
var
row
=
sheet
.
CreateRow
(
last
rowIndex
);
for
(
int
i
=
head
.
FirstCellNum
;
i
<
head
.
LastCellNum
;
i
++)
{
var
headName
=
head
.
GetCell
(
i
).
StringCellValue
;
var
newCell
=
GetOrCreate
(
row
,
i
);
var
newCell
=
row
.
CreateCell
(
i
);
if
(
headName
.
Replace
(
"\n"
,
""
)
==
"核算单元(医生组)"
)
{
var
dept
=
unitList
.
FirstOrDefault
(
t
=>
t
.
SheetName
==
sheet
.
SheetName
&&
t
.
Department
==
department
&&
t
.
UnitType
==
1
)?.
AccountingUnit
;
...
...
@@ -815,18 +845,150 @@ private void WriteSheetData(ISheet sheet, IPerSheetDataRead sheetRead, List<Acco
OutToExcelCell
(
newCell
,
value
);
newCell
.
CellStyle
=
style
;
}
else
if
(
newCell
.
CellType
!=
CellType
.
Formula
)
else
if
(
header
!=
null
&&
header
.
Contains
(
headName
)
)
{
value
=
value
==
0
?
null
:
value
;
OutToExcelCell
(
newCell
,
value
);
if
(
header
!=
null
&&
header
.
Contains
(
headName
))
newCell
.
CellStyle
=
style
;
newCell
.
CellStyle
=
style
;
}
}
}
lastrowIndex
++;
}
#
endregion
}
/// <summary>
/// 写入工作量列头
/// </summary>
/// <param name="sheet"></param>
/// <param name="sheetRead"></param>
/// <param name="items"></param>
/// <param name="isNewTemp"></param>
private
void
WriteWorkHeader
(
ISheet
sheet
,
IPerSheetDataRead
sheetRead
,
List
<
mod_item
>
items
,
bool
isNewTemp
)
{
var
head
=
GetOrCreate
(
sheet
,
sheetRead
.
Point
.
HeaderFirstRowNum
.
Value
+
0
);
var
factor
=
GetOrCreate
(
sheet
,
sheetRead
.
Point
.
HeaderFirstRowNum
.
Value
+
1
);
var
cellItems
=
items
;
if
(!
isNewTemp
)
{
#
region
过滤历史模板中已有的列头
//写入列头信息
int
cellStartIndex
=
sheetRead
.
Point
.
HeaderFirstCellNum
.
Value
+
4
;
for
(
int
i
=
cellStartIndex
;
i
<
head
.
LastCellNum
;
i
++)
{
var
cellvalue
=
head
.
GetCell
(
i
)?.
ToString
();
if
(
string
.
IsNullOrEmpty
(
cellvalue
))
continue
;
cellItems
.
RemoveAll
(
t
=>
t
.
ItemName
==
cellvalue
);
}
#
endregion
}
if
(
cellItems
==
null
||
!
cellItems
.
Any
())
return
;
#
region
新增模板中不存在的列头
var
lastcellIndex
=
head
.
LastCellNum
;
foreach
(
var
item
in
cellItems
)
{
var
headcell
=
GetOrCreate
(
head
,
lastcellIndex
);
headcell
.
SetCellValue
(
item
.
ItemName
);
headcell
.
CellStyle
=
CellStyle
.
CreateCellStyle
(
workbook
,
StyleType
.
列头
);
var
doctorcell
=
GetOrCreate
(
factor
,
lastcellIndex
);
doctorcell
.
SetCellValue
(
item
.
FactorValue1
!=
null
?
(
double
)
item
.
FactorValue1
:
0
);
doctorcell
.
CellStyle
=
CellStyle
.
CreateCellStyle
(
workbook
,
StyleType
.
列头
,
CellFormat
.
数字
2
);
lastcellIndex
++;
}
#
endregion
}
/// <summary>
/// 写入工作量数据
/// </summary>
/// <param name="sheet"></param>
/// <param name="sheetRead"></param>
/// <param name="unitList"></param>
/// <param name="allExtract"></param>
/// <param name="header"></param>
/// <param name="isNewTemp"></param>
private
void
WriteWorkData
(
ISheet
sheet
,
IPerSheetDataRead
sheetRead
,
List
<
AccountUnitEntity
>
unitList
,
List
<
ExtractDto
>
allExtract
,
IEnumerable
<
string
>
header
,
bool
isNewTemp
)
{
var
head
=
GetOrCreate
(
sheet
,
sheetRead
.
Point
.
HeaderFirstRowNum
.
Value
+
0
);
var
rowIndex
=
sheetRead
.
Point
.
HeaderFirstRowNum
.
Value
+
2
;
if
(!
isNewTemp
)
{
#
region
给历史模板已有科室补充数据
for
(
int
i
=
rowIndex
;
i
<
sheet
.
LastRowNum
+
1
;
i
++)
{
var
row
=
sheet
.
GetRow
(
i
);
if
(
row
!=
null
)
{
var
department
=
row
.
GetCell
(
1
)?.
ToString
();
if
(
string
.
IsNullOrEmpty
(
department
))
continue
;
var
deptData
=
allExtract
.
Where
(
t
=>
t
.
Department
==
department
);
if
(
deptData
==
null
||
!
deptData
.
Any
())
continue
;
for
(
int
j
=
rowIndex
;
j
<
head
.
LastCellNum
;
j
++)
{
var
headName
=
head
.
GetCell
(
j
).
StringCellValue
;
var
newCell
=
GetOrCreate
(
row
,
j
);
if
(
newCell
==
null
)
continue
;
if
(
newCell
.
CellType
!=
CellType
.
Formula
)
{
var
extract
=
deptData
.
FirstOrDefault
(
t
=>
t
.
Category
==
headName
);
var
value
=
extract
?.
Value
==
0
?
null
:
extract
?.
Value
;
OutToExcelCell
(
newCell
,
value
);
if
(
header
!=
null
&&
header
.
Contains
(
headName
))
newCell
.
CellStyle
=
style
;
}
}
allExtract
.
RemoveAll
(
t
=>
t
.
Department
==
department
);
}
}
#
endregion
}
if
(
allExtract
==
null
||
!
allExtract
.
Any
())
return
;
#
region
补充新的科室及数据
var
lastrowIndex
=
sheet
.
LastRowNum
+
1
;
foreach
(
var
department
in
allExtract
.
Select
(
t
=>
t
.
Department
).
Where
(
t
=>
!
string
.
IsNullOrEmpty
(
t
)).
Distinct
())
{
var
row
=
sheet
.
CreateRow
(
lastrowIndex
);
for
(
int
i
=
head
.
FirstCellNum
;
i
<
head
.
LastCellNum
;
i
++)
{
var
headName
=
head
.
GetCell
(
i
).
StringCellValue
;
var
newCell
=
row
.
CreateCell
(
i
);
if
(
headName
==
"核算单元"
)
{
var
dept
=
unitList
.
FirstOrDefault
(
t
=>
t
.
SheetName
==
sheet
.
SheetName
&&
t
.
Department
==
department
)?.
AccountingUnit
;
newCell
.
SetCellValue
(
dept
??
""
);
newCell
.
CellStyle
=
CellStyle
.
CreateCellStyle
(
workbook
,
StyleType
.
默认
);
}
else
if
(
headName
==
"科室名称"
)
{
newCell
.
SetCellValue
(
department
??
""
);
newCell
.
CellStyle
=
CellStyle
.
CreateCellStyle
(
workbook
,
StyleType
.
默认
);
}
else
{
var
extract
=
allExtract
.
FirstOrDefault
(
t
=>
t
.
Department
==
department
&&
t
.
Category
==
headName
);
var
value
=
extract
?.
Value
==
0
?
null
:
extract
?.
Value
;
OutToExcelCell
(
newCell
,
value
);
if
(
header
!=
null
&&
header
.
Contains
(
headName
))
newCell
.
CellStyle
=
style
;
}
}
rowIndex
++;
last
rowIndex
++;
}
#
endregion
}
#
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