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
992bef89
Commit
992bef89
authored
Oct 31, 2020
by
lcx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
抽取数据格式调整
parent
93ae4c3d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
10 deletions
+58
-10
performance/Performance.Services/ExtractExcelService/ExtractHelper/ExcelHelper.cs
+46
-0
performance/Performance.Services/ExtractExcelService/ExtractHelper/WriteDataHelper.cs
+7
-7
performance/Performance.Services/ExtractExcelService/ExtractService.cs
+5
-3
No files found.
performance/Performance.Services/ExtractExcelService/ExtractHelper/ExcelHelper.cs
View file @
992bef89
...
...
@@ -39,6 +39,52 @@ public static void SetRowStyle(this IRow row, ICellStyle cellStyle)
}
}
public
static
void
SetCellValue
<
T
>(
this
ICell
cell
,
object
value
,
T
defaultValue
=
default
)
{
if
(
cell
==
null
)
return
;
try
{
var
type
=
defaultValue
.
GetType
();
switch
(
type
.
ToString
())
{
#
region
SetValue
case
"System.String"
:
//字符串类型
cell
.
SetCellValue
(
ConvertHelper
.
To
<
string
>(
value
));
break
;
case
"System.DateTime"
:
//日期类型
cell
.
SetCellValue
(
ConvertHelper
.
To
<
DateTime
>(
value
).
ToString
(
"yyyy/M/d"
));
break
;
case
"System.Boolean"
:
//布尔型
cell
.
SetCellValue
(
ConvertHelper
.
To
<
bool
>(
value
));
break
;
case
"System.Int16"
:
//整型
case
"System.Int32"
:
case
"System.Int64"
:
case
"System.Byte"
:
cell
.
SetCellValue
(
ConvertHelper
.
To
<
int
>(
value
));
break
;
case
"System.Decimal"
:
//浮点型
case
"System.Double"
:
cell
.
SetCellValue
(
ConvertHelper
.
To
<
double
>(
value
));
break
;
case
"System.DBNull"
:
//空值处理
cell
.
SetCellValue
(
""
);
break
;
default
:
cell
.
SetCellValue
(
""
);
break
;
#
endregion
}
}
catch
{
cell
.
SetCellValue
(
""
);
}
}
public
static
void
SetCellOValue
(
this
ICell
cell
,
object
value
)
{
if
(
cell
==
null
)
return
;
...
...
performance/Performance.Services/ExtractExcelService/ExtractHelper/WriteDataHelper.cs
View file @
992bef89
...
...
@@ -62,21 +62,21 @@ public static void WriteSheetHeader(ISheet sheet, PerSheetPoint point, SheetType
if
(
sheetType
==
SheetType
.
Workload
)
{
var
workloadCell
=
workloadFactor
.
GetOrCreate
(
headerFirstCellNum
);
workloadCell
.
SetCell
OValue
(
item
.
WorkloadFactor
);
workloadCell
.
SetCell
Value
<
decimal
>
(
item
.
WorkloadFactor
);
workloadCell
.
CellStyle
=
factorStyle
;
}
else
{
var
doctorCell
=
doctorFactor
.
GetOrCreate
(
headerFirstCellNum
);
doctorCell
.
SetCell
OValue
(
item
.
DoctorFactor
);
doctorCell
.
SetCell
Value
<
decimal
>
(
item
.
DoctorFactor
);
doctorCell
.
CellStyle
=
factorStyle
;
var
nurseCell
=
nurseFactor
.
GetOrCreate
(
headerFirstCellNum
);
nurseCell
.
SetCell
OValue
(
item
.
NurseFactor
);
nurseCell
.
SetCell
Value
<
decimal
>
(
item
.
NurseFactor
);
nurseCell
.
CellStyle
=
factorStyle
;
var
technicianCell
=
technicianFactor
.
GetOrCreate
(
headerFirstCellNum
);
technicianCell
.
SetCell
OValue
(
item
.
TechnicianFactor
);
technicianCell
.
SetCell
Value
<
decimal
>
(
item
.
TechnicianFactor
);
technicianCell
.
CellStyle
=
factorStyle
;
}
...
...
@@ -125,12 +125,12 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
if
(
sheetType
==
SheetType
.
Income
)
{
cell
.
SetCell
OValue
(
value
);
cell
.
SetCell
Value
<
decimal
>
(
value
);
cell
.
CellStyle
=
cellStyle
;
}
else
if
(
cell
.
CellType
!=
CellType
.
Formula
)
{
cell
.
SetCell
OValue
(
value
);
cell
.
SetCell
Value
<
decimal
>
(
value
);
if
(
headers
!=
null
&&
headers
.
Contains
(
column
))
{
cell
.
CellStyle
=
cellStyle
;
...
...
@@ -176,7 +176,7 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
else
if
(
sheetType
==
SheetType
.
Income
||
(
headers
!=
null
&&
headers
.
Contains
(
column
)))
{
var
value
=
deptData
.
FirstOrDefault
(
t
=>
t
.
Category
==
column
)?.
Value
;
cell
.
SetCell
OValue
(
value
);
cell
.
SetCell
Value
<
decimal
>
(
value
);
cell
.
CellStyle
=
cellStyle
;
}
}
...
...
performance/Performance.Services/ExtractExcelService/ExtractService.cs
View file @
992bef89
...
...
@@ -107,6 +107,8 @@ private void WriteDataToFile(string templateFile, string extractFile, int allotI
var
models
=
exdict
[
ExDataDict
.
ExModule
]
as
List
<
ex_module
>;
ExtractHelper
.
CreateNotExistSheet
(
models
,
workbook
);
var
employeeDict
=
peremployeeRepository
.
GetEntities
(
t
=>
t
.
AllotId
==
allotId
);
WriteDataFactory
factory
=
new
WriteDataFactory
();
for
(
int
sheetIndex
=
0
;
sheetIndex
<
workbook
.
NumberOfSheets
;
sheetIndex
++)
{
...
...
@@ -123,7 +125,7 @@ private void WriteDataToFile(string templateFile, string extractFile, int allotI
if
(
customer
!=
null
)
{
var
exdata
=
extractDto
.
Where
(
t
=>
t
.
SheetName
.
NoBlank
()
==
sheet
.
SheetName
.
NoBlank
())?.
ToList
();
var
data
=
GetDataBySheetType
(
allotId
,
sheetType
,
exdata
);
var
data
=
GetDataBySheetType
(
sheetType
,
exdata
,
employeeDict
);
customer
.
WriteSheetData
(
sheet
,
point
,
sheetType
,
style
,
data
,
exdict
);
}
}
...
...
@@ -134,14 +136,14 @@ private void WriteDataToFile(string templateFile, string extractFile, int allotI
}
}
private
object
GetDataBySheetType
(
int
allotId
,
SheetType
sheetType
,
List
<
ExtractTransDto
>
extractDto
)
private
object
GetDataBySheetType
(
SheetType
sheetType
,
List
<
ExtractTransDto
>
extractDto
,
List
<
per_employee
>
employeeDict
)
{
switch
(
sheetType
)
{
case
SheetType
.
Employee
:
case
SheetType
.
ClinicEmployee
:
case
SheetType
.
AccountBasic
:
return
peremployeeRepository
.
GetEntities
(
t
=>
t
.
AllotId
==
allotId
)
;
return
employeeDict
;
default
:
return
extractDto
;
}
...
...
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