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
ee267f3d
Commit
ee267f3d
authored
Jun 21, 2021
by
lcx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
划拨收入写入额外收入页
parent
e6ad023d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
27 deletions
+80
-27
performance/Performance.Services/ExtractExcelService/ExtractService.cs
+7
-0
performance/Performance.Services/ExtractExcelService/SheetDataWrite/CostTransferDataWrite.cs
+73
-27
No files found.
performance/Performance.Services/ExtractExcelService/ExtractService.cs
View file @
ee267f3d
...
...
@@ -4,6 +4,7 @@
using
Performance.EntityModels
;
using
Performance.Infrastructure
;
using
Performance.Repository
;
using
Performance.Services.ExtractExcelService.SheetDataWrite
;
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
...
...
@@ -18,6 +19,7 @@ public class ExtractService : IAutoInjection
private
readonly
QueryService
queryService
;
private
readonly
PersonService
personService
;
private
readonly
PerSheetService
perSheetService
;
private
readonly
CostTransferDataWrite
costTransfer
;
private
readonly
DictionaryService
dictionaryService
;
private
readonly
PerforPerallotRepository
perallotRepository
;
private
readonly
PerforCollectdataRepository
collectdataRepository
;
...
...
@@ -30,6 +32,7 @@ public class ExtractService : IAutoInjection
QueryService
queryService
,
PersonService
personService
,
PerSheetService
perSheetService
,
CostTransferDataWrite
costTransfer
,
DictionaryService
dictionaryService
,
PerforPerallotRepository
perallotRepository
,
PerforCollectdataRepository
collectdataRepository
,
...
...
@@ -42,6 +45,7 @@ PerforPerdeptdicRepository perdeptdicRepository
this
.
queryService
=
queryService
;
this
.
personService
=
personService
;
this
.
perSheetService
=
perSheetService
;
this
.
costTransfer
=
costTransfer
;
this
.
dictionaryService
=
dictionaryService
;
this
.
perallotRepository
=
perallotRepository
;
this
.
collectdataRepository
=
collectdataRepository
;
...
...
@@ -204,6 +208,9 @@ private void WriteDataToFile(IWorkbook workbook, per_allot allot, Dictionary<ExD
customer
.
WriteSheetData
(
sheet
,
point
,
sheetType
,
style
,
data
,
exdict
);
}
if
(
sheetName
.
StartsWith
(
"1.0.1"
))
costTransfer
.
WriteSheetData
(
sheet
,
point
,
style
,
allot
.
ID
,
allot
.
HospitalId
);
logService
.
ReturnTheLog
(
allot
.
ID
,
groupName
,
2
,
"写入数据"
,
$"sheet“
{
sheet
.
SheetName
}
”已完成数据写入"
,
1
,
isSingle
);
}
catch
(
Exception
ex
)
...
...
performance/Performance.Services/ExtractExcelService/SheetDataWrite/CostTransferDataWrite.cs
View file @
ee267f3d
...
...
@@ -29,6 +29,8 @@ PerforPerdeptdicRepository perdeptdicRepository
this
.
perdeptdicRepository
=
perdeptdicRepository
;
}
private
readonly
string
[]
Unittypes
=
new
string
[]
{
UnitType
.
护理组
.
ToString
(),
UnitType
.
医生组
.
ToString
(),
UnitType
.
医技组
.
ToString
()
};
public
void
WriteSheetData
(
ISheet
sheet
,
PerSheetPoint
point
,
ExcelStyle
style
,
int
allotId
,
int
hospitalId
)
{
try
...
...
@@ -36,42 +38,23 @@ public void WriteSheetData(ISheet sheet, PerSheetPoint point, ExcelStyle style,
var
costTransfers
=
costtransferRepository
.
GetEntities
(
t
=>
t
.
AllotId
==
allotId
);
if
(
costTransfers
==
null
||
!
costTransfers
.
Any
())
return
;
var
costTransferItems
=
costtransferitemRepository
.
GetEntities
(
t
=>
costTransfers
.
Select
(
c
=>
c
.
Id
).
Contains
(
t
.
TransferId
)
&&
t
.
Status
==
1
&&
t
.
AdminStatus
==
1
);
var
costTransferItems
=
costtransferitemRepository
.
GetEntities
(
t
=>
costTransfers
.
Select
(
c
=>
c
.
Id
).
Contains
(
t
.
TransferId
)
&&
t
.
Status
==
1
&&
t
.
AdminStatus
==
1
&&
t
.
IsWrited
==
0
);
if
(
costTransferItems
==
null
||
!
costTransferItems
.
Any
())
return
;
var
columns
=
SupplySheetHeader
(
sheet
,
point
);
if
(
columns
==
null
||
!
columns
.
Any
())
return
;
var
departments
=
costTransfers
.
Select
(
t
=>
t
.
AdoptedDepartment
??
""
).
Union
(
costTransfers
.
Select
(
t
=>
t
.
ApplicantDepartment
??
""
)).
Distinct
().
ToList
();
var
standardDict
=
perdeptdicRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
hospitalId
)
??
new
List
<
per_dept_dic
>();
var
unittypes
=
new
string
[]
{
UnitType
.
护理组
.
ToString
(),
UnitType
.
医生组
.
ToString
(),
UnitType
.
医技组
.
ToString
()
};
for
(
int
i
=
point
.
DataFirstRowNum
.
Value
;
i
<
sheet
.
LastRowNum
+
1
;
i
++)
{
var
row
=
sheet
.
GetOrCreate
(
i
);
var
department
=
row
.
GetOrCreate
(
point
.
DataFirstCellNum
.
Value
-
1
).
GetDecodeEscapes
();
foreach
(
var
unittype
in
unittypes
)
{
var
key
=
columns
.
Keys
.
FirstOrDefault
(
t
=>
t
.
Contains
(
unittype
.
Replace
(
"组"
,
""
)));
if
(
string
.
IsNullOrEmpty
(
key
))
continue
;
var
index
=
columns
[
key
];
var
cell
=
row
.
GetOrCreate
(
index
);
var
score
=
GetTransfersByDeptAndUnittype
(
costTransfers
,
costTransferItems
,
department
,
unittype
);
cell
.
SetCellOValue
(
score
);
}
var
cellStyle
=
style
.
SetBgkColorAndFormat
(
style
.
GetCellStyle
(),
StyleType
.
数据
);
departments
.
Remove
(
department
);
}
WriteSheetDataExistent
(
sheet
,
cellStyle
,
point
,
columns
,
departments
,
costTransfers
,
costTransferItems
);
if
(
departments
==
null
||
!
departments
.
Any
())
return
;
foreach
(
var
department
in
departments
)
{
var
standardDict
=
perdeptdicRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
hospitalId
&&
departments
.
Contains
(
t
.
Department
))
??
new
List
<
per_dept_dic
>();
}
WriteSheetDataNonexistent
(
sheet
,
cellStyle
,
point
,
columns
,
departments
,
standardDict
,
costTransfers
,
costTransferItems
);
}
catch
(
Exception
ex
)
{
...
...
@@ -85,7 +68,7 @@ public void WriteSheetData(ISheet sheet, PerSheetPoint point, ExcelStyle style,
var
header
=
sheet
.
GetRow
(
point
.
HeaderFirstRowNum
.
Value
);
if
(
header
==
null
)
return
pairs
;
List
<
string
>
fixedColumns
=
new
List
<
string
>
{
"划拨收入(医技)"
,
"划拨收入(医生)"
,
"划拨收入(护理
)"
};
List
<
string
>
fixedColumns
=
new
List
<
string
>
{
$"划拨收入(
{
UnitType
.
医技组
}
)"
,
$"划拨收入(
{
UnitType
.
医生组
}
)"
,
$"划拨收入(
{
UnitType
.
护理组
}
)"
};
for
(
int
i
=
point
.
HeaderFirstCellNum
.
Value
;
i
<
header
.
LastCellNum
;
i
++)
{
...
...
@@ -116,6 +99,69 @@ public void WriteSheetData(ISheet sheet, PerSheetPoint point, ExcelStyle style,
return
pairs
;
}
private
void
WriteSheetDataExistent
(
ISheet
sheet
,
ICellStyle
style
,
PerSheetPoint
point
,
Dictionary
<
string
,
int
>
columns
,
List
<
string
>
departments
,
List
<
cost_transfer
>
costTransfers
,
List
<
cost_transfer_item
>
costTransferItems
)
{
for
(
int
i
=
point
.
DataFirstRowNum
.
Value
;
i
<
sheet
.
LastRowNum
+
1
;
i
++)
{
var
row
=
sheet
.
GetOrCreate
(
i
);
var
department
=
row
.
GetOrCreate
(
point
.
DataFirstCellNum
.
Value
-
1
).
GetDecodeEscapes
();
foreach
(
var
unittype
in
Unittypes
)
{
var
key
=
columns
.
Keys
.
FirstOrDefault
(
t
=>
t
.
Contains
(
unittype
));
if
(
string
.
IsNullOrEmpty
(
key
))
continue
;
var
index
=
columns
[
key
];
var
cell
=
row
.
GetOrCreate
(
index
);
var
score
=
GetTransfersByDeptAndUnittype
(
costTransfers
,
costTransferItems
,
department
,
unittype
);
cell
.
SetCellOValue
(
score
);
cell
.
CellStyle
=
style
;
}
departments
.
Remove
(
department
);
}
}
private
void
WriteSheetDataNonexistent
(
ISheet
sheet
,
ICellStyle
style
,
PerSheetPoint
point
,
Dictionary
<
string
,
int
>
columns
,
List
<
string
>
departments
,
List
<
per_dept_dic
>
standardDict
,
List
<
cost_transfer
>
costTransfers
,
List
<
cost_transfer_item
>
costTransferItems
)
{
int
indexrow
=
sheet
.
LastRowNum
+
1
;
Dictionary
<
string
,
int
>
accountingUnits
=
new
Dictionary
<
string
,
int
>
{
{
UnitType
.
护理组
.
ToString
(),
2
}
,{
UnitType
.
医生组
.
ToString
(),
3
}
,{
UnitType
.
医技组
.
ToString
(),
4
},
};
foreach
(
var
department
in
departments
)
{
var
row
=
sheet
.
GetOrCreate
(
indexrow
);
foreach
(
var
unittype
in
Unittypes
)
{
var
key
=
columns
.
Keys
.
FirstOrDefault
(
t
=>
t
.
Contains
(
unittype
));
if
(!
string
.
IsNullOrEmpty
(
key
)
&&
columns
.
ContainsKey
(
key
))
{
var
index
=
columns
[
key
];
var
cell
=
row
.
GetOrCreate
(
index
);
var
score
=
GetTransfersByDeptAndUnittype
(
costTransfers
,
costTransferItems
,
department
,
unittype
);
cell
.
SetCellOValue
(
score
);
cell
.
CellStyle
=
style
;
}
if
(
accountingUnits
.
ContainsKey
(
unittype
))
{
var
cell
=
row
.
GetOrCreate
(
point
.
DataFirstRowNum
.
Value
-
accountingUnits
[
unittype
]);
var
value
=
standardDict
.
Where
(
t
=>
t
.
Department
==
department
&&
t
.
UnitType
==
unittype
)
?.
Select
(
t
=>
t
.
AccountingUnit
).
FirstOrDefault
(
t
=>
!
string
.
IsNullOrEmpty
(
t
))
??
""
;
cell
.
SetCellValue
(
value
);
cell
.
CellStyle
=
style
;
}
}
indexrow
++;
}
}
private
decimal
GetTransfersByDeptAndUnittype
(
List
<
cost_transfer
>
costTransfers
,
List
<
cost_transfer_item
>
costTransferItems
,
string
department
,
string
unittype
)
{
if
(
costTransfers
==
null
||
!
costTransfers
.
Any
())
return
0
;
...
...
@@ -128,10 +174,10 @@ private decimal GetTransfersByDeptAndUnittype(List<cost_transfer> costTransfers,
?
costTransfers
.
Where
(
t
=>
t
.
ApplicantDepartment
==
department
&&
t
.
ApplicantUnitType
==
unittype
)?.
ToList
()
:
costTransfers
.
Where
(
t
=>
t
.
AdoptedDepartment
==
department
&&
t
.
AdoptedUnitType
==
unittype
)?.
ToList
();
if
(
data
==
null
||
!
data
.
Any
())
return
0
;
if
(
data
==
null
||
!
data
.
Any
())
continue
;
var
items
=
costTransferItems
.
Where
(
t
=>
data
.
Select
(
s
=>
s
.
Id
).
Contains
(
t
.
TransferId
))?.
ToList
();
if
(
items
==
null
||
!
items
.
Any
())
return
0
;
if
(
items
==
null
||
!
items
.
Any
())
continue
;
items
.
ForEach
(
t
=>
t
.
IsWrited
=
1
);
costtransferitemRepository
.
UpdateRange
(
items
.
ToArray
());
...
...
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