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
0ee51efa
Commit
0ee51efa
authored
Nov 11, 2020
by
lcx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
特殊科室微调
parent
b96457b9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
45 deletions
+58
-45
performance/Performance.Services/ExtractExcelService/QueryService.cs
+21
-21
performance/Performance.Services/ExtractExcelService/SheetDataWrite/SpecialUnitDataWrite.cs
+37
-24
No files found.
performance/Performance.Services/ExtractExcelService/QueryService.cs
View file @
0ee51efa
...
...
@@ -76,27 +76,27 @@ public List<ex_result> Handler(int hospitalId, per_allot allot, ref Dictionary<E
ClearHistoryData
(
allot
.
ID
);
var
data
=
new
List
<
ex_result
>();
var
scripts
=
exscriptRepository
.
GetEntities
(
t
=>
extypeIds
.
Contains
(
t
.
TypeId
));
if
(
scripts
!=
null
&&
scripts
.
Any
())
{
var
allmodules
=
dict
[
ExDataDict
.
ExModule
]
as
List
<
ex_module
>;
foreach
(
var
pair
in
dict
)
{
switch
(
pair
.
Key
)
{
case
ExDataDict
.
ExModule
:
data
.
AddRange
(
ExtractModuleData
(
allot
,
scripts
,
configs
,
pair
.
Value
));
break
;
case
ExDataDict
.
ExItem
:
data
.
AddRange
(
ExtractItemData
(
allot
,
scripts
,
configs
,
allmodules
,
pair
.
Value
));
break
;
case
ExDataDict
.
ExSpecial
:
data
.
AddRange
(
ExtractSpecialData
(
allot
,
scripts
,
configs
,
pair
.
Value
));
break
;
}
}
}
//
var scripts = exscriptRepository.GetEntities(t => extypeIds.Contains(t.TypeId));
//
if (scripts != null && scripts.Any())
//
{
//
var allmodules = dict[ExDataDict.ExModule] as List<ex_module>;
//
foreach (var pair in dict)
//
{
//
switch (pair.Key)
//
{
//
case ExDataDict.ExModule:
//
data.AddRange(ExtractModuleData(allot, scripts, configs, pair.Value));
//
break;
//
case ExDataDict.ExItem:
//
data.AddRange(ExtractItemData(allot, scripts, configs, allmodules, pair.Value));
//
break;
//
case ExDataDict.ExSpecial:
//
data.AddRange(ExtractSpecialData(allot, scripts, configs, pair.Value));
//
break;
//
}
//
}
//
}
return
data
;
}
catch
(
Exception
ex
)
...
...
performance/Performance.Services/ExtractExcelService/SheetDataWrite/SpecialUnitDataWrite.cs
View file @
0ee51efa
...
...
@@ -6,7 +6,7 @@
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Text
.RegularExpressions
;
namespace
Performance.Services.ExtractExcelService.SheetDataWrite
{
...
...
@@ -35,7 +35,7 @@ public void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType sheetTyp
SupplyMergedRegionData
(
sheet
,
style
,
mergedRegions
);
var
index
=
columns
.
IndexOf
(
SpecialUnitColumns
.
Department
);
var
needMergedRegions
=
mergedRegions
.
Where
(
t
=>
t
.
FirstColumn
==
index
&&
t
.
LastColumn
==
index
)?.
ToList
();
var
needMergedRegions
=
mergedRegions
.
Where
(
t
=>
t
.
FirstColumn
==
index
&&
t
.
LastColumn
==
index
)?.
ToList
()
??
new
List
<
SpecialCellRange
>()
;
var
specials
=
exSpecials
.
GroupJoin
(
extractDto
,
outer
=>
new
{
outer
.
Department
,
outer
.
Target
},
inner
=>
new
{
inner
.
Department
,
Target
=
inner
.
Category
},
(
outer
,
inner
)
=>
new
SpecialDto
...
...
@@ -47,9 +47,9 @@ public void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType sheetTyp
Quantity
=
inner
.
FirstOrDefault
()?.
Value
}).
ToList
();
SupplySpecialQuantity
(
sheet
,
style
,
specials
,
columns
,
ref
dataFirstRowNum
);
AddNewSpecialConfig
(
sheet
,
style
,
specials
,
needMergedRegions
,
columns
,
dataFirstRowNum
);
AddMergedRegion
(
sheet
,
needMergedRegions
,
columns
);
SupplySpecialQuantity
(
sheet
,
style
,
specials
,
needMergedRegions
,
columns
,
ref
dataFirstRowNum
);
//
AddNewSpecialConfig(sheet, style, specials, needMergedRegions, columns, dataFirstRowNum);
//
AddMergedRegion(sheet, needMergedRegions, columns);
}
catch
(
Exception
ex
)
{
...
...
@@ -121,14 +121,14 @@ private void SupplyMergedRegionData(ISheet sheet, ExcelStyle style, List<Special
{
var
cell
=
row
.
GetCell
(
cellIndex
);
if
(
cell
==
null
)
cell
=
row
.
CreateCell
(
cellIndex
);
if
(!
string
.
IsNullOrEmpty
(
value
))
SetCellValue
(
cell
,
cellType
,
value
);
if
(!
string
.
IsNullOrEmpty
(
value
))
SetCellValue
(
cell
,
value
);
}
row
.
SetRowStyle
(
basicStyle
);
}
}
}
private
void
SupplySpecialQuantity
(
ISheet
sheet
,
ExcelStyle
style
,
List
<
SpecialDto
>
specials
,
List
<
string
>
columns
,
ref
int
dataFirstRowNum
)
private
void
SupplySpecialQuantity
(
ISheet
sheet
,
ExcelStyle
style
,
List
<
SpecialDto
>
specials
,
List
<
SpecialCellRange
>
ranges
,
List
<
string
>
columns
,
ref
int
dataFirstRowNum
)
{
if
(
sheet
==
null
)
return
;
...
...
@@ -160,6 +160,8 @@ private void SupplySpecialQuantity(ISheet sheet, ExcelStyle style, List<SpecialD
var
department
=
row
.
GetCell
(
dict
[
SpecialUnitColumns
.
Department
]).
GetDecodeEscapes
();
var
target
=
row
.
GetCell
(
dict
[
SpecialUnitColumns
.
Target
]).
GetDecodeEscapes
();
CheckMergedRegions
(
rowIndex
,
department
,
ranges
);
var
special
=
specials
.
FirstOrDefault
(
t
=>
t
.
Department
==
department
&&
t
.
Target
==
target
);
if
(
special
!=
null
)
{
...
...
@@ -175,6 +177,28 @@ private void SupplySpecialQuantity(ISheet sheet, ExcelStyle style, List<SpecialD
}
}
private
void
CheckMergedRegions
(
int
rowIndex
,
string
department
,
List
<
SpecialCellRange
>
ranges
)
{
var
range
=
ranges
.
FirstOrDefault
(
t
=>
t
.
FirstRow
<=
rowIndex
&&
t
.
LastRow
>=
rowIndex
);
if
(
range
==
null
)
{
if
(
rowIndex
==
0
)
return
;
int
prevRowIndex
=
rowIndex
-
1
;
range
=
ranges
.
FirstOrDefault
(
t
=>
t
.
FirstRow
<=
prevRowIndex
&&
t
.
LastRow
>=
prevRowIndex
);
if
(
range
!=
null
&&
range
.
Single
==
department
)
range
.
LastRow
=
rowIndex
;
else
{
var
columnIndex
=
ranges
.
First
().
FirstColumn
;
ranges
.
Add
(
new
SpecialCellRange
(
new
CellRangeAddress
(
rowIndex
,
rowIndex
,
columnIndex
,
columnIndex
))
{
Single
=
department
});
}
}
}
private
void
AddNewSpecialConfig
(
ISheet
sheet
,
ExcelStyle
style
,
List
<
SpecialDto
>
specials
,
List
<
SpecialCellRange
>
ranges
,
List
<
string
>
columns
,
int
dataFirstRowNum
)
{
if
(
specials
==
null
||
!
specials
.
Any
())
return
;
...
...
@@ -241,6 +265,7 @@ private void WriteSpecialData(IRow row, ICellStyle style, SpecialDto special, Li
private
void
AddMergedRegion
(
ISheet
sheet
,
List
<
SpecialCellRange
>
ranges
,
List
<
string
>
columns
)
{
if
(
columns
==
null
||
!
columns
.
Any
())
return
;
if
(
ranges
==
null
||
!
ranges
.
Any
())
return
;
var
columnIndexs
=
new
string
[]
{
SpecialUnitColumns
.
Department
,
SpecialUnitColumns
.
PeopleNumber
,
SpecialUnitColumns
.
AdjustFactor
}.
Select
(
t
=>
columns
.
IndexOf
(
t
));
if
(
columnIndexs
==
null
||
!
columnIndexs
.
Any
(
t
=>
t
>
-
1
))
return
;
...
...
@@ -258,30 +283,18 @@ private void AddMergedRegion(ISheet sheet, List<SpecialCellRange> ranges, List<s
}
}
p
rivate
void
SetCellValue
(
ICell
cell
,
CellType
cellType
,
string
value
)
p
ublic
void
SetCellValue
(
ICell
cell
,
string
value
)
{
if
(
string
.
IsNullOrEmpty
(
value
)
)
switch
(
value
)
{
cell
.
SetCellValue
(
""
);
return
;
}
switch
(
cellType
)
{
case
CellType
.
Numeric
:
case
string
reg
when
Regex
.
IsMatch
(
reg
,
@"^[+-]?\d*[.]?\d*$"
):
cell
.
SetCellValue
(
ConvertHelper
.
To
<
double
>(
value
));
break
;
case
CellType
.
String
:
cell
.
SetCellValue
(
value
.
ToString
());
break
;
case
CellType
.
Boolean
:
case
string
reg
when
Regex
.
IsMatch
(
reg
,
@"^[+-]?\d*$"
):
cell
.
SetCellValue
(
ConvertHelper
.
To
<
int
>(
value
));
break
;
case
CellType
.
Unknown
:
case
CellType
.
Blank
:
case
CellType
.
Error
:
case
CellType
.
Formula
:
default
:
cell
.
SetCellValue
(
value
);
break
;
}
}
...
...
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