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
377064cf
Commit
377064cf
authored
Sep 16, 2020
by
lcx
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'v2020special' into v2020calculate
parents
339f6f39
ad2c0867
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
268 additions
and
32 deletions
+268
-32
performance/Performance.Services/DFExtractService.cs
+267
-31
performance/Performance.Services/LogManageService.cs
+1
-1
No files found.
performance/Performance.Services/DFExtractService.cs
View file @
377064cf
...
...
@@ -417,7 +417,7 @@ public string TemplateExecute(string email, sys_hospital hospital, List<sys_hosp
// WriteAccountBasic(sheet, sheetRead);
// break;
case
SheetType
.
SpecialUnit
:
WriteSpecialUnit
(
sheet
,
sheetRead
,
specials
,
data
);
WriteSpecialUnit
(
sheet
,
sheetRead
,
specials
,
data
,
sheetRead
.
Point
.
DataFirstRowNum
.
Value
);
break
;
}
logManage
.
ReturnTheLog
(
Allot
.
ID
,
GroupName
,
2
,
"写入数据"
,
$"sheet“
{
sheet
.
SheetName
}
”已完成数据写入"
);
...
...
@@ -493,28 +493,28 @@ public string AlllotExecute(string email, sys_hospital hospital, List<sys_hospit
//case SheetType.ClinicEmployee:
// WriteClinicEmployee(sheet, sheetRead, false);
// break;
case
SheetType
.
OtherIncome
:
ClearData
(
sheet
,
5
,
7
);
WriteOtherIncome
(
sheet
,
sheetRead
,
modules
,
items
,
extracts
,
false
);
break
;
case
SheetType
.
Income
:
ClearData
(
sheet
,
5
,
3
,
true
);
WriteIncome
(
sheet
,
sheetRead
,
modules
,
items
,
extracts
,
false
);
break
;
case
SheetType
.
Expend
:
ClearData
(
sheet
,
5
,
7
);
WriteExpend
(
sheet
,
sheetRead
,
modules
,
items
,
extracts
,
false
);
break
;
case
SheetType
.
Workload
:
ClearData
(
sheet
,
3
,
3
);
WriteWorkload
(
sheet
,
sheetRead
,
modules
,
items
,
extracts
,
false
);
break
;
//
case SheetType.OtherIncome:
//
ClearData(sheet, 5, 7);
//
WriteOtherIncome(sheet, sheetRead, modules, items, extracts, false);
//
break;
//
case SheetType.Income:
//
ClearData(sheet, 5, 3, true);
//
WriteIncome(sheet, sheetRead, modules, items, extracts, false);
//
break;
//
case SheetType.Expend:
//
ClearData(sheet, 5, 7);
//
WriteExpend(sheet, sheetRead, modules, items, extracts, false);
//
break;
//
case SheetType.Workload:
//
ClearData(sheet, 3, 3);
//
WriteWorkload(sheet, sheetRead, modules, items, extracts, false);
//
break;
//case SheetType.AccountBasic:
// WriteAccountBasic(sheet, sheetRead, false);
// break;
case
SheetType
.
SpecialUnit
:
ClearData
(
sheet
,
2
,
0
);
Write
SpecialUnit
(
sheet
,
sheetRead
,
specials
,
extracts
,
lastAllot
,
false
);
//
ClearData(sheet, 2, 0);
Supply
SpecialUnit
(
sheet
,
sheetRead
,
specials
,
extracts
,
lastAllot
,
false
);
break
;
}
logManage
.
ReturnTheLog
(
Allot
.
ID
,
GroupName
,
2
,
"写入数据"
,
$"sheet“
{
sheet
.
SheetName
}
”已完成数据写入"
);
...
...
@@ -1250,7 +1250,7 @@ private void WriteWorkload(ISheet sheet, IPerSheetDataRead sheetRead, List<ex_mo
logger
.
LogInformation
(
$"
{
sheet
.
SheetName
}
写入结束."
);
}
private
void
WriteSpecialUnit
(
ISheet
sheet
,
IPerSheetDataRead
sheetRead
,
List
<
ex_special
>
specials
,
List
<
NewExtractDto
>
data
,
per_allot
lastAllot
=
null
,
bool
IsWriteHead
=
true
)
private
void
WriteSpecialUnit
(
ISheet
sheet
,
IPerSheetDataRead
sheetRead
,
List
<
ex_special
>
specials
,
List
<
NewExtractDto
>
data
,
int
beginRowIndex
,
per_allot
lastAllot
=
null
,
bool
IsWriteHead
=
true
)
{
logger
.
LogInformation
(
$"
{
sheet
.
SheetName
}
开始执行写入."
);
var
dictionary
=
new
Dictionary
<
string
,
Func
<
ex_special
,
List
<
im_specialunit
>,
object
>>
...
...
@@ -1270,14 +1270,11 @@ private void WriteSpecialUnit(ISheet sheet, IPerSheetDataRead sheetRead, List<ex
if
(
lastAllot
!=
null
)
allotDataList
=
perforImspecialunitRepository
.
GetEntities
(
t
=>
t
.
AllotID
==
lastAllot
.
ID
);
//取消合并单元格
int
mergedCount
=
sheet
.
NumMergedRegions
;
for
(
int
i
=
mergedCount
-
1
;
i
>=
0
;
i
--)
{
var
temp
=
sheet
.
GetMergedRegion
(
i
);
if
(
temp
.
FirstRow
>
sheetRead
.
Point
.
HeaderFirstRowNum
)
sheet
.
RemoveMergedRegion
(
i
);
}
////取消合并单元格
//foreach (var merge in sheet.MergedRegions)
//{
// sheet.RemoveMergedRegion(sheet.MergedRegions.IndexOf(merge));
//}
var
modDataGroup
=
speaialList
.
GroupBy
(
t
=>
new
{
t
.
Department
}).
Select
(
group
=>
new
{
...
...
@@ -1285,8 +1282,8 @@ private void WriteSpecialUnit(ISheet sheet, IPerSheetDataRead sheetRead, List<ex
Count
=
group
.
Count
()
})?.
OrderBy
(
t
=>
t
.
Department
);
int
mergedBegin
=
sheetRead
.
Point
.
DataFirstRowNum
.
Value
;
int
mergedEnd
=
sheetRead
.
Point
.
DataFirstRowNum
.
Value
;
int
mergedBegin
=
beginRowIndex
;
int
mergedEnd
=
beginRowIndex
;
var
extractdata
=
data
.
Where
(
t
=>
t
.
SheetName
==
specialname
).
ToList
();
logger
.
LogInformation
(
$"data有
{
extractdata
?.
Count
??
0
}
个."
);
...
...
@@ -1297,7 +1294,7 @@ private void WriteSpecialUnit(ISheet sheet, IPerSheetDataRead sheetRead, List<ex
var
headIndex
=
sheetRead
.
Point
.
HeaderFirstRowNum
;
var
cellList
=
sheet
.
GetRow
(
headIndex
.
Value
).
Cells
;
var
rowIndex
=
sheetRead
.
Point
.
DataFirstRowNum
.
Value
+
i
;
var
rowIndex
=
beginRowIndex
+
i
;
var
importRow
=
sheet
.
CreateRow
(
rowIndex
);
int
cellIndex
=
0
;
...
...
@@ -1340,6 +1337,197 @@ private void WriteSpecialUnit(ISheet sheet, IPerSheetDataRead sheetRead, List<ex
logger
.
LogInformation
(
$"
{
sheet
.
SheetName
}
写入结束."
);
}
private
void
SupplySpecialUnit
(
ISheet
sheet
,
IPerSheetDataRead
sheetRead
,
List
<
ex_special
>
specials
,
List
<
NewExtractDto
>
data
,
per_allot
lastAllot
=
null
,
bool
IsWriteHead
=
true
)
{
try
{
logger
.
LogInformation
(
$"
{
sheet
.
SheetName
}
开始执行写入."
);
var
dictionary
=
new
Dictionary
<
string
,
Func
<
ex_special
,
List
<
im_specialunit
>,
object
>>
{
{
"科室"
,
(
special
,
lastallot
)
=>
special
.
Department
},
{
"人数"
,
(
special
,
lastallot
)
=>
lastallot
.
Where
(
t
=>
special
.
Department
==
t
.
Department
).
Max
(
t
=>
t
.
Number
)
},
{
"量化指标"
,
(
special
,
lastallot
)
=>
special
.
Target
},
{
"量化指标绩效分值"
,(
special
,
lastallot
)
=>
special
.
TargetFactor
},
{
"调节系数"
,
(
special
,
lastallot
)
=>
special
.
AdjustFactor
},
};
List
<
im_specialunit
>
allotDataList
=
new
List
<
im_specialunit
>();
if
(
lastAllot
!=
null
)
allotDataList
=
perforImspecialunitRepository
.
GetEntities
(
t
=>
t
.
AllotID
==
lastAllot
.
ID
);
var
speaialList
=
specials
?.
OrderBy
(
t
=>
t
.
Department
).
ToList
();
logger
.
LogInformation
(
$"item有
{
speaialList
?.
Count
??
0
}
个."
);
if
(
speaialList
==
null
||
!
speaialList
.
Any
())
return
;
var
headIndex
=
sheetRead
.
Point
.
HeaderFirstRowNum
;
var
cellList
=
sheet
.
GetRow
(
headIndex
.
Value
).
Cells
;
var
headerDict
=
new
Dictionary
<
string
,
int
>();
cellList
.
ForEach
(
t
=>
{
t
.
SetCellType
(
CellType
.
String
);
if
(!
headerDict
.
ContainsKey
(
t
.
StringCellValue
))
headerDict
.
Add
(
t
.
StringCellValue
,
cellList
.
IndexOf
(
t
));
});
if
(!
headerDict
.
ContainsKey
(
"科室"
)
||
!
headerDict
.
ContainsKey
(
"量化指标"
))
return
;
var
extractdata
=
data
.
Where
(
t
=>
t
.
SheetName
==
specialname
).
ToList
();
var
merges
=
mergefunc
.
Invoke
(
sheet
,
sheetRead
.
Point
.
DataFirstRowNum
);
if
(
merges
==
null
||
!
merges
.
Any
())
return
;
merges
=
merges
.
OrderBy
(
t
=>
t
.
FirstRow
).
ToList
();
int
startRowIndex
=
sheetRead
.
Point
.
DataFirstRowNum
??
2
;
foreach
(
var
merge
in
merges
)
{
var
deptSpecials
=
speaialList
.
Where
(
t
=>
t
.
Department
==
merge
.
Value
)?.
ToList
();
if
(
deptSpecials
==
null
)
continue
;
for
(
int
i
=
merge
.
FirstRow
;
i
<
merge
.
LastRow
+
1
;
i
++)
{
var
row
=
GetOrCreate
(
sheet
,
i
);
string
target
=
NopiSevice
.
GetValue
(
GetOrCreate
(
row
,
headerDict
[
"量化指标"
]));
var
config
=
deptSpecials
.
FirstOrDefault
(
t
=>
t
.
Target
==
target
);
if
(
config
!=
null
)
{
deptSpecials
.
RemoveAll
(
t
=>
t
.
Department
==
merge
.
Value
&&
t
.
Target
==
target
);
continue
;
}
}
if
(
deptSpecials
!=
null
&&
deptSpecials
.
Any
())
{
foreach
(
var
spec
in
deptSpecials
)
{
sheet
.
ShiftRows
(
merge
.
LastRow
+
1
,
sheet
.
LastRowNum
,
1
,
true
,
false
);
var
shiftrow
=
sheet
.
CreateRow
(
merge
.
LastRow
+
1
);
WriteSpecialCellValue
(
dictionary
,
shiftrow
,
cellList
,
spec
,
allotDataList
,
extractdata
);
var
thanmerges
=
merges
.
Where
(
t
=>
t
.
FirstRow
>
merge
.
LastRow
)?.
ToList
();
if
(
thanmerges
!=
null
&&
thanmerges
.
Any
())
{
thanmerges
.
ForEach
(
t
=>
{
t
.
FirstRow
+=
1
;
t
.
LastRow
+=
1
;
});
}
merge
.
LastRow
+=
1
;
}
}
speaialList
.
RemoveAll
(
t
=>
t
.
Department
==
merge
.
Value
);
}
if
(
speaialList
!=
null
&&
speaialList
.
Any
())
{
var
index
=
sheet
.
LastRowNum
+
1
;
foreach
(
var
item
in
speaialList
)
{
var
newrow
=
sheet
.
CreateRow
(
index
);
newrow
.
CreateCell
(
0
).
SetCellValue
(
""
);
index
++;
}
}
//取消合并单元格
int
mergedCount
=
sheet
.
NumMergedRegions
;
for
(
int
i
=
mergedCount
-
1
;
i
>=
0
;
i
--)
{
var
temp
=
sheet
.
GetMergedRegion
(
i
);
if
(
temp
.
FirstRow
>
sheetRead
.
Point
.
HeaderFirstRowNum
)
sheet
.
RemoveMergedRegion
(
i
);
}
foreach
(
var
merge
in
merges
.
Where
(
t
=>
t
.
FirstColumn
==
0
))
{
if
(
merge
.
LastRow
>
merge
.
FirstRow
)
{
CellRangeAddress
region
=
new
CellRangeAddress
(
merge
.
FirstRow
,
merge
.
LastRow
,
headerDict
[
"科室"
],
headerDict
[
"科室"
]);
sheet
.
AddMergedRegion
(
region
);
sheet
.
AddMergedRegion
(
new
CellRangeAddress
(
merge
.
FirstRow
,
merge
.
LastRow
,
headerDict
[
"人数"
],
headerDict
[
"人数"
]));
}
}
WriteSpecialUnit
(
sheet
,
sheetRead
,
speaialList
,
data
,
sheet
.
LastRowNum
+
1
,
lastAllot
,
false
);
}
catch
(
Exception
ex
)
{
logger
.
LogError
(
"补充特殊科室数据发生异常"
+
ex
.
ToString
());
}
}
private
void
WriteSpecialCellValue
(
Dictionary
<
string
,
Func
<
ex_special
,
List
<
im_specialunit
>,
object
>>
dictionary
,
IRow
row
,
List
<
ICell
>
cellList
,
ex_special
special
,
List
<
im_specialunit
>
allotDataList
,
List
<
NewExtractDto
>
extractdata
)
{
foreach
(
var
cell
in
cellList
)
{
object
value
=
null
;
if
(
dictionary
.
ContainsKey
(
cell
.
StringCellValue
))
{
var
item
=
dictionary
.
First
(
t
=>
t
.
Key
==
cell
.
StringCellValue
);
value
=
item
.
Value
.
Invoke
(
special
,
allotDataList
)
??
""
;
}
if
(
cell
.
StringCellValue
==
"数量"
&&
special
?.
TypeId
>
0
)
{
value
=
extractdata
?.
FirstOrDefault
(
t
=>
t
.
Category
==
special
.
Target
)?.
Value
;
}
var
newCell
=
row
.
CreateCell
(
cellList
.
IndexOf
(
cell
));
OutToExcelCell
(
newCell
,
value
);
if
(
dictionary
.
ContainsKey
(
cell
.
StringCellValue
)
||
(
cell
.
StringCellValue
==
"数量"
&&
!
string
.
IsNullOrEmpty
(
value
?.
ToString
())))
newCell
.
CellStyle
=
style
;
}
}
private
readonly
Func
<
ISheet
,
int
?,
List
<
CellRangeAddressAndValue
>>
mergefunc
=
(
sheet
,
beginrow
)
=>
{
var
merges
=
new
List
<
CellRangeAddressAndValue
>();
//合并
int
regionsCount
=
sheet
.
NumMergedRegions
;
for
(
int
i
=
0
;
i
<
regionsCount
;
i
++)
{
CellRangeAddress
range
=
sheet
.
GetMergedRegion
(
i
);
if
(
range
!=
null
)
{
var
merge
=
new
CellRangeAddressAndValue
(
range
);
string
value
=
""
;
var
firstrow
=
sheet
.
GetRow
(
range
.
FirstRow
);
if
(
firstrow
!=
null
&&
firstrow
.
GetCell
(
range
.
FirstColumn
)
is
ICell
firstcell
&&
firstcell
!=
null
)
{
firstcell
.
SetCellType
(
CellType
.
String
);
value
=
firstcell
.
StringCellValue
;
}
merge
.
Value
=
value
;
merges
.
Add
(
merge
);
}
}
//非合并
int
index
=
beginrow
??
merges
.
Min
(
t
=>
t
.
FirstRow
);
for
(
int
i
=
index
;
i
<
sheet
.
LastRowNum
+
1
;
i
++)
{
if
(!
merges
.
Any
(
t
=>
i
>=
t
.
FirstRow
&&
i
<=
t
.
LastRow
))
{
string
value
=
""
;
var
firstrow
=
sheet
.
GetRow
(
i
);
if
(
firstrow
!=
null
&&
firstrow
.
GetCell
(
merges
.
First
().
FirstColumn
)
is
ICell
firstcell
&&
firstcell
!=
null
)
{
firstcell
.
SetCellType
(
CellType
.
String
);
value
=
firstcell
.
StringCellValue
;
}
merges
.
Add
(
new
CellRangeAddressAndValue
(
i
,
i
,
merges
.
First
().
FirstColumn
,
merges
.
First
().
LastColumn
,
value
,
false
));
}
}
return
merges
;
};
#
region
写入数据
/// <summary>
/// 写入列头
...
...
@@ -1835,4 +2023,52 @@ public class NewExtractDto : ExtractDto
public
string
InpatTechnicAccounting
{
get
;
set
;
}
public
new
decimal
?
Value
{
get
;
set
;
}
}
public
class
CellRangeAddressAndValue
{
public
CellRangeAddressAndValue
()
:
this
(
default
,
default
,
default
,
default
,
default
)
{
}
public
CellRangeAddressAndValue
(
CellRangeAddress
address
)
:
this
(
address
.
FirstRow
,
address
.
LastRow
,
address
.
FirstColumn
,
address
.
LastColumn
)
{
}
public
CellRangeAddressAndValue
(
int
firstRow
,
int
lastRow
,
int
firstCol
,
int
lastCol
)
:
this
(
firstRow
,
lastRow
,
firstCol
,
lastCol
,
default
)
{
}
public
CellRangeAddressAndValue
(
int
firstRow
,
int
lastRow
,
int
firstCol
,
int
lastCol
,
string
value
,
bool
isMerge
=
true
)
{
if
(
lastRow
<
firstRow
||
lastCol
<
firstCol
)
{
throw
new
ArgumentException
(
"lastRow < firstRow || lastCol < firstCol"
);
}
FirstRow
=
firstRow
;
LastRow
=
lastRow
;
FirstColumn
=
firstCol
;
LastColumn
=
lastCol
;
Value
=
value
;
IsMerge
=
isMerge
;
}
public
int
FirstRow
{
get
;
set
;
}
public
int
LastRow
{
get
;
set
;
}
public
int
FirstColumn
{
get
;
set
;
}
public
int
LastColumn
{
get
;
set
;
}
public
string
Value
{
get
;
set
;
}
public
bool
IsMerge
{
get
;
set
;
}
}
}
performance/Performance.Services/LogManageService.cs
View file @
377064cf
...
...
@@ -83,7 +83,7 @@ public void ReturnTheLog(int allotId, string groupName, int type, string tag, ob
var
http
=
url
.
ImportFile
+
$"/template/returnlog?type=
{
type
}
&tag=
{
tag
}
&message=
{
message
}
&level=
{
level
}
&groupName=
{
groupName
}
"
;
//logger.LogInformation("发送日志:" + http);
logdbug
.
Add
(
allotId
,
tag
,
message
.
ToString
(),
level
,
type
);
HttpHelper
.
HttpPost
(
http
);
//
HttpHelper.HttpPost(http);
}
catch
(
Exception
ex
)
{
...
...
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