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
488aa8ce
Commit
488aa8ce
authored
Aug 07, 2019
by
李承祥
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
抽取数据值类型修改
parent
5ac214da
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
30 deletions
+78
-30
performance/Performance.Services/NewExtractService.cs
+78
-30
No files found.
performance/Performance.Services/NewExtractService.cs
View file @
488aa8ce
...
...
@@ -239,9 +239,9 @@ private void WriteOtherIncome(ISheet sheet, int hospitalId, IPerSheetDataRead sh
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
()
);
doctorFactor
.
GetCell
(
cellStartIndex
).
SetCellValue
(
item
.
FactorValue1
!=
null
?
(
double
)
item
.
FactorValue1
:
0
);
nurseFactor
.
GetCell
(
cellStartIndex
).
SetCellValue
(
item
.
FactorValue2
!=
null
?
(
double
)
item
.
FactorValue2
:
0
);
technicianFactor
.
GetCell
(
cellStartIndex
).
SetCellValue
(
item
.
FactorValue3
!=
null
?
(
double
)
item
.
FactorValue3
:
0
);
cellStartIndex
++;
}
}
...
...
@@ -264,9 +264,9 @@ private void WriteIncome(ISheet sheet, int hospitalId, List<AccountUnitEntity> u
foreach
(
var
item
in
itemList
)
{
GetOrCreate
(
head
,
cellStartIndex
).
SetCellValue
(
item
.
ItemName
);
GetOrCreate
(
doctorFactor
,
cellStartIndex
).
SetCellValue
(
item
.
FactorValue1
?.
ToString
()
);
GetOrCreate
(
nurseFactor
,
cellStartIndex
).
SetCellValue
(
item
.
FactorValue2
?.
ToString
()
);
GetOrCreate
(
technicianFactor
,
cellStartIndex
).
SetCellValue
(
item
.
FactorValue3
?.
ToString
()
);
GetOrCreate
(
doctorFactor
,
cellStartIndex
).
SetCellValue
(
item
.
FactorValue1
!=
null
?
(
double
)
item
.
FactorValue1
:
0
);
GetOrCreate
(
nurseFactor
,
cellStartIndex
).
SetCellValue
(
item
.
FactorValue2
!=
null
?
(
double
)
item
.
FactorValue2
:
0
);
GetOrCreate
(
technicianFactor
,
cellStartIndex
).
SetCellValue
(
item
.
FactorValue3
!=
null
?
(
double
)
item
.
FactorValue3
:
0
);
cellStartIndex
++;
}
//查询数据
...
...
@@ -311,7 +311,9 @@ private void WriteIncome(ISheet sheet, int hospitalId, List<AccountUnitEntity> u
else
{
var
value
=
allExtract
.
FirstOrDefault
(
t
=>
t
.
Department
==
department
&&
t
.
Category
==
headName
)?.
Value
;
newCell
.
SetCellValue
(
value
==
null
||
value
==
0
?
""
:
value
.
ToString
());
value
=
value
==
0
?
null
:
value
;
OutToExcelCell
(
newCell
,
value
);
//newCell.SetCellValue(value == null || value == 0 ? "" : value.ToString());
newCell
.
CellStyle
=
style
;
}
}
...
...
@@ -366,7 +368,7 @@ private void WriteWorkload(ISheet sheet, int hospitalId, List<AccountUnitEntity>
foreach
(
var
item
in
itemList
)
{
GetOrCreate
(
head
,
cellStartIndex
).
SetCellValue
(
item
.
ItemName
);
GetOrCreate
(
factor
,
cellStartIndex
).
SetCellValue
(
item
.
FactorValue1
?.
ToString
()
);
GetOrCreate
(
factor
,
cellStartIndex
).
SetCellValue
(
item
.
FactorValue1
!=
null
?
(
double
)
item
.
FactorValue1
:
0
);
cellStartIndex
++;
}
//查询数据
...
...
@@ -407,7 +409,10 @@ private void WriteWorkload(ISheet sheet, int hospitalId, List<AccountUnitEntity>
else
{
var
value
=
allExtract
.
FirstOrDefault
(
t
=>
t
.
Department
==
department
&&
t
.
Category
==
headName
)?.
Value
;
newCell
.
SetCellValue
(
value
==
null
||
value
==
0
?
""
:
value
.
ToString
());
value
=
value
==
0
?
null
:
value
;
OutToExcelCell
(
newCell
,
value
);
//newCell.SetCellValue(value == null || value == 0 ? "" : value.ToString());
if
(
itemList
.
Select
(
t
=>
t
.
ItemName
).
Contains
(
headName
))
newCell
.
CellStyle
=
style
;
}
}
...
...
@@ -461,9 +466,9 @@ private void WriteExpend(ISheet sheet, int hospitalId, IPerSheetDataRead sheetRe
foreach
(
var
item
in
itemList
)
{
GetOrCreate
(
head
,
cellStartIndex
).
SetCellValue
(
item
.
ItemName
);
GetOrCreate
(
doctorFactor
,
cellStartIndex
).
SetCellValue
(
item
.
FactorValue1
?.
ToString
()
);
GetOrCreate
(
nurseFactor
,
cellStartIndex
).
SetCellValue
(
item
.
FactorValue2
?.
ToString
()
);
GetOrCreate
(
technicianFactor
,
cellStartIndex
).
SetCellValue
(
item
.
FactorValue3
?.
ToString
()
);
GetOrCreate
(
doctorFactor
,
cellStartIndex
).
SetCellValue
(
item
.
FactorValue1
!=
null
?
(
double
)
item
.
FactorValue1
:
0
);
GetOrCreate
(
nurseFactor
,
cellStartIndex
).
SetCellValue
(
item
.
FactorValue2
!=
null
?
(
double
)
item
.
FactorValue2
:
0
);
GetOrCreate
(
technicianFactor
,
cellStartIndex
).
SetCellValue
(
item
.
FactorValue3
!=
null
?
(
double
)
item
.
FactorValue3
:
0
);
cellStartIndex
++;
}
}
...
...
@@ -511,8 +516,9 @@ private void WriteEmployee(ISheet sheet, int allotLastId, IPerSheetDataRead shee
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
));
var
value
=
item
.
Value
.
Invoke
(
dataList
[
i
])
??
""
;
var
newCell
=
importRow
.
CreateCell
(
cell
.
ColumnIndex
);
//.SetCellValue(Verify(value));
OutToExcelCell
(
newCell
,
value
);
}
}
}
...
...
@@ -568,25 +574,27 @@ private void WriteSpecialUnit(ISheet sheet, int hospitalId, per_allot allotLast,
if
(
dictionary
.
ContainsKey
(
cell
.
StringCellValue
))
{
var
item
=
dictionary
.
First
(
t
=>
t
.
Key
==
cell
.
StringCellValue
);
var
value
=
(
item
.
Value
.
Invoke
(
modDataList
[
i
],
allotDataList
)
??
""
).
ToString
()
;
var
value
=
item
.
Value
.
Invoke
(
modDataList
[
i
],
allotDataList
)
??
""
;
if
(!
new
List
<
string
>
{
"量化指标"
,
"数量"
,
"量化指标绩效分值"
}.
Contains
(
cell
.
StringCellValue
)
&&
rowIndex
==
mergedBegin
)
{
if
(
item
.
Key
==
"科室"
)
{
var
count
=
modDataGroup
.
First
(
t
=>
t
.
Department
.
ToString
()
==
value
).
Count
;
var
count
=
modDataGroup
.
First
(
t
=>
t
.
Department
.
ToString
()
==
value
.
ToString
()
).
Count
;
mergedEnd
=
mergedBegin
+
count
-
1
;
}
CellRangeAddress
region
=
new
CellRangeAddress
(
mergedBegin
,
mergedEnd
,
cellIndex
,
cellIndex
);
sheet
.
AddMergedRegion
(
region
);
//合并单元格
var
newCell
=
importRow
.
CreateCell
(
cellIndex
);
newCell
.
SetCellValue
(
Verify
(
value
));
//newCell.SetCellValue(Verify(value));
OutToExcelCell
(
newCell
,
value
);
newCell
.
CellStyle
=
style
;
}
else
{
var
newCell
=
importRow
.
CreateCell
(
cell
.
ColumnIndex
);
newCell
.
SetCellValue
(
Verify
(
value
));
//newCell.SetCellValue(Verify(value));
OutToExcelCell
(
newCell
,
value
);
newCell
.
CellStyle
=
style
;
}
}
...
...
@@ -642,14 +650,15 @@ private void WriteAccountBasic(ISheet sheet, int allotLastId, IPerSheetDataRead
foreach
(
var
cell
in
cellList
)
{
var
item
=
dictionary
.
FirstOrDefault
(
t
=>
t
.
Key
==
cell
.
StringCellValue
);
var
value
=
(
item
.
Value
.
Invoke
(
dataList
[
i
])
??
""
).
ToString
()
;
var
value
=
item
.
Value
.
Invoke
(
dataList
[
i
])
??
""
;
if
(
cell
.
StringCellValue
==
"核算单元类型"
)
{
value
=
value
==
"1"
?
"医生组"
:
value
==
"2"
?
"护理组"
:
"医技组"
;
value
=
value
.
ToString
()
==
"1"
?
"医生组"
:
value
.
ToString
()
==
"2"
?
"护理组"
:
"医技组"
;
}
var
newCell
=
importRow
.
CreateCell
(
cell
.
ColumnIndex
);
newCell
.
SetCellValue
(
Verify
(
value
));
//
newCell.SetCellValue(Verify(value));
//newCell.CellStyle = style;
OutToExcelCell
(
newCell
,
value
);
}
}
}
...
...
@@ -660,22 +669,61 @@ private void WriteAccountBasic(ISheet sheet, int allotLastId, IPerSheetDataRead
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public
dynamic
Verify
(
string
obj
)
public
void
OutToExcelCell
(
ICell
cell
,
object
obj
)
{
string
value
=
obj
?.
ToString
()
??
""
;
try
{
var
type
=
obj
.
GetType
();
switch
(
type
.
ToString
())
{
case
"System.String"
:
//字符串类型
cell
.
SetCellValue
(
value
);
break
;
case
"System.DateTime"
:
//日期类型
DateTime
dateV
;
DateTime
.
TryParse
(
value
,
out
dateV
);
cell
.
SetCellValue
(
dateV
.
ToString
(
"yyyy/M/d"
));
break
;
case
"System.Boolean"
:
//布尔型
bool
boolV
=
false
;
bool
.
TryParse
(
value
,
out
boolV
);
cell
.
SetCellValue
(
boolV
);
break
;
case
"System.Int16"
:
//整型
case
"System.Int32"
:
case
"System.Int64"
:
case
"System.Byte"
:
int
intV
=
0
;
int
.
TryParse
(
value
,
out
intV
);
cell
.
SetCellValue
(
intV
);
break
;
case
"System.Decimal"
:
//浮点型
case
"System.Double"
:
double
doubV
=
0
;
double
.
TryParse
(
value
,
out
doubV
);
cell
.
SetCellValue
(
doubV
);
break
;
case
"System.DBNull"
:
//空值处理
cell
.
SetCellValue
(
""
);
break
;
default
:
cell
.
SetCellValue
(
""
);
break
;
}
//判断值是否为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
;
//
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
;
cell
.
SetCellValue
(
value
)
;
}
}
#
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