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
22b147a5
Commit
22b147a5
authored
Oct 14, 2020
by
ruyun.zhang@suvalue.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'v2020calculate' into fixed/bug
parents
87de3c0a
33ad0b56
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
13 deletions
+34
-13
performance/Performance.Services/ExtractIncomeService.cs
+34
-13
No files found.
performance/Performance.Services/ExtractIncomeService.cs
View file @
22b147a5
...
...
@@ -55,6 +55,10 @@ public string Execture(int allotId)
logger
.
LogInformation
(
"医生收入文件: "
+
filepath
);
return
filepath
;
}
catch
(
PerformanceException
ex
)
{
throw
ex
;
}
catch
(
Exception
ex
)
{
logger
.
LogError
(
ex
.
ToString
());
...
...
@@ -65,10 +69,10 @@ public string Execture(int allotId)
private
Dictionary
<
string
,
List
<
IncomeDataDto
>>
GetIncomeData
(
per_allot
allot
)
{
var
configs
=
hospitalconfigRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
allot
.
HospitalId
);
if
(
configs
==
null
||
!
configs
.
Any
())
return
null
;
if
(
configs
==
null
||
!
configs
.
Any
())
throw
new
PerformanceException
(
"未添加医院提取配置"
)
;
var
types
=
extypeRepository
.
GetEntities
(
t
=>
t
.
Source
==
100
);
if
(
types
==
null
||
!
types
.
Any
())
return
null
;
if
(
types
==
null
||
!
types
.
Any
())
throw
new
PerformanceException
(
"未配置数据提取内容"
)
;
Dictionary
<
string
,
List
<
IncomeDataDto
>>
pairs
=
new
Dictionary
<
string
,
List
<
IncomeDataDto
>>();
foreach
(
var
item
in
types
)
...
...
@@ -107,26 +111,38 @@ private IEnumerable<IncomeDataDto> QueryData(sys_hospitalconfig config, per_allo
private
string
CreateExcel
(
int
hospitalId
,
Dictionary
<
string
,
List
<
IncomeDataDto
>>
dataDict
)
{
if
(
dataDict
==
null
||
!
dataDict
.
Any
())
throw
new
PerformanceException
(
"未查询到数据!"
);
if
(
dataDict
==
null
||
!
dataDict
.
Any
(
t
=>
t
.
Value
!=
null
&&
t
.
Value
.
Any
()
))
throw
new
PerformanceException
(
"未查询到数据!"
);
IWorkbook
workbook
=
new
XSSFWorkbook
();
ICellStyle
cellStyle
=
getCellStyle
.
Invoke
(
workbook
);
foreach
(
var
dict
in
dataDict
)
foreach
(
var
dict
in
dataDict
.
Where
(
t
=>
t
.
Value
!=
null
&&
t
.
Value
.
Any
())
)
{
ISheet
sheet
=
workbook
.
CreateSheet
(
dict
.
Key
);
CreateHeader
(
sheet
,
cellStyle
);
var
columns
=
memberDict
.
Keys
.
ToList
();
var
categories
=
dict
.
Value
.
Select
(
s
=>
s
.
Category
).
Distinct
().
OrderBy
(
t
=>
t
);
columns
.
AddRange
(
categories
);
CreateHeader
(
sheet
,
cellStyle
,
columns
);
int
rowIndex
=
sheet
.
LastRowNum
+
1
;
foreach
(
var
data
in
dict
.
Value
)
var
groupData
=
dict
.
Value
.
GroupBy
(
t
=>
new
{
t
.
EmpCode
,
t
.
EmpName
,
t
.
DeptName
,
t
.
ExecDeptName
});
foreach
(
var
data
in
groupData
)
{
IRow
row
=
sheet
.
CreateRow
(
rowIndex
);
int
index
=
0
;
foreach
(
var
field
in
memberDict
.
Value
s
)
foreach
(
var
field
in
column
s
)
{
ICell
cell
=
row
.
CreateCell
(
index
);
OutToExcelCell
(
cell
,
field
?.
Invoke
(
data
));
if
(
memberDict
.
ContainsKey
(
field
))
OutToExcelCell
(
cell
,
memberDict
[
field
]?.
Invoke
(
data
.
Key
));
else
{
var
value
=
data
.
FirstOrDefault
(
t
=>
t
.
Category
==
field
)?.
Fee
;
if
(
value
.
HasValue
)
OutToExcelCell
(
cell
,
value
.
Value
);
}
cell
.
CellStyle
=
cellStyle
;
index
++;
}
...
...
@@ -149,13 +165,13 @@ private string CreateExcel(int hospitalId, Dictionary<string, List<IncomeDataDto
return
filepath
;
}
private
void
CreateHeader
(
ISheet
sheet
,
ICellStyle
cellStyle
)
private
void
CreateHeader
(
ISheet
sheet
,
ICellStyle
cellStyle
,
List
<
string
>
columns
)
{
IRow
row
=
sheet
.
CreateRow
(
0
);
if
(
row
==
null
)
return
;
int
index
=
0
;
foreach
(
var
col
in
memberDict
.
Key
s
)
foreach
(
var
col
in
column
s
)
{
ICell
cell
=
row
.
CreateCell
(
index
);
cell
.
SetCellValue
(
col
);
...
...
@@ -163,7 +179,7 @@ private void CreateHeader(ISheet sheet, ICellStyle cellStyle)
index
++;
}
sheet
.
CreateFreezePane
(
0
,
1
);
//首行冻结
sheet
.
CreateFreezePane
(
memberDict
.
Count
,
1
);
//首行冻结
}
private
Dictionary
<
string
,
string
>
GetParameters
(
per_allot
allot
)
...
...
@@ -234,9 +250,14 @@ public void OutToExcelCell(ICell cell, object obj)
}
}
private
readonly
Dictionary
<
string
,
Func
<
IncomeDataDto
,
object
>>
memberDict
=
new
Dictionary
<
string
,
Func
<
IncomeDataDto
,
object
>>
private
readonly
Dictionary
<
string
,
Func
<
dynamic
,
object
>>
memberDict
=
new
Dictionary
<
string
,
Func
<
dynamic
,
object
>>
{
{
"医生工号"
,
(
t
)
=>
t
.
EmpCode
},
{
"医生姓名"
,
(
t
)
=>
t
.
EmpName
},
{
"开单科室"
,
(
t
)
=>
t
.
DeptName
},
{
"执行科室"
,
(
t
)
=>
t
.
ExecDeptName
},
{
"费用类型"
,
(
t
)
=>
t
.
Category
},
{
"费用"
,
(
t
)
=>
t
.
Fee
}
{
"医生工号"
,
(
t
)
=>
t
.
EmpCode
},
{
"医生姓名"
,
(
t
)
=>
t
.
EmpName
},
{
"开单科室"
,
(
t
)
=>
t
.
DeptName
},
{
"执行科室"
,
(
t
)
=>
t
.
ExecDeptName
},
//{ "费用类型", (t) => t.Category },
//{ "费用", (t) => t.Fee }
};
private
readonly
Func
<
IWorkbook
,
ICellStyle
>
getCellStyle
=
(
workbook
)
=>
...
...
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