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
3a17417f
Commit
3a17417f
authored
Jun 28, 2021
by
lcx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
自定义抽取
parent
0fb6137d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
8 deletions
+68
-8
performance/Performance.Services/CustomExtractService.cs
+1
-1
performance/Performance.Services/ExtractExcelService/SheetDataWrite/CustomDataWrite.cs
+67
-7
No files found.
performance/Performance.Services/CustomExtractService.cs
View file @
3a17417f
...
@@ -267,7 +267,7 @@ public IEnumerable<dynamic> QueryData(sys_hospitalconfig config, string execsql,
...
@@ -267,7 +267,7 @@ public IEnumerable<dynamic> QueryData(sys_hospitalconfig config, string execsql,
/// </summary>
/// </summary>
/// <param name="allot"></param>
/// <param name="allot"></param>
/// <returns></returns>
/// <returns></returns>
p
rivate
Dictionary
<
string
,
string
>
GetParameters
(
per_allot
allot
)
p
ublic
Dictionary
<
string
,
string
>
GetParameters
(
per_allot
allot
)
{
{
DateTime
beginTime
=
new
DateTime
(
allot
.
Year
,
allot
.
Month
,
1
);
DateTime
beginTime
=
new
DateTime
(
allot
.
Year
,
allot
.
Month
,
1
);
...
...
performance/Performance.Services/ExtractExcelService/SheetDataWrite/CustomDataWrite.cs
View file @
3a17417f
using
NPOI.SS.UserModel
;
using
Microsoft.Extensions.Logging
;
using
NPOI.SS.UserModel
;
using
Performance.DtoModels
;
using
Performance.DtoModels
;
using
Performance.EntityModels
;
using
Performance.EntityModels
;
using
Performance.Repository
;
using
Performance.Repository
;
...
@@ -10,21 +11,48 @@ namespace Performance.Services.ExtractExcelService.SheetDataWrite
...
@@ -10,21 +11,48 @@ namespace Performance.Services.ExtractExcelService.SheetDataWrite
{
{
public
class
CustomDataWrite
public
class
CustomDataWrite
{
{
private
readonly
ILogger
<
CustomDataWrite
>
logger
;
private
readonly
PerforHospitalconfigRepository
hospitalconfigRepository
;
private
readonly
PerforHospitalconfigRepository
hospitalconfigRepository
;
private
readonly
PerforExmoduleRepository
exmoduleRepository
;
private
readonly
PerforExscriptRepository
exscriptRepository
;
private
readonly
CustomExtractService
customExtractService
;
public
CustomDataWrite
(
PerforHospitalconfigRepository
hospitalconfigRepository
)
public
CustomDataWrite
(
ILogger
<
CustomDataWrite
>
logger
,
PerforHospitalconfigRepository
hospitalconfigRepository
,
PerforExmoduleRepository
exmoduleRepository
,
PerforExscriptRepository
exscriptRepository
,
CustomExtractService
customExtractService
)
{
{
this
.
logger
=
logger
;
this
.
hospitalconfigRepository
=
hospitalconfigRepository
;
this
.
hospitalconfigRepository
=
hospitalconfigRepository
;
this
.
exmoduleRepository
=
exmoduleRepository
;
this
.
exscriptRepository
=
exscriptRepository
;
this
.
customExtractService
=
customExtractService
;
}
}
public
void
WriteDataToCustom
(
IWorkbook
workbook
,
per_allot
allot
)
public
PerSheetPoint
Point
=>
new
PerSheetPoint
{
{
var
modules
=
new
List
<
ex_module
>();
DataFirstRowNum
=
2
,
DataFirstCellNum
=
7
,
};
public
void
WriteDataToCustom
(
IWorkbook
workbook
,
per_allot
allot
,
ExcelStyle
style
)
{
var
modules
=
exmoduleRepository
.
GetEntities
(
t
=>
t
.
SheetType
==
(
int
)
SheetType
.
Custom
)?.
OrderBy
(
t
=>
t
.
ModuleName
);
if
(
modules
==
null
||
!
modules
.
Any
())
return
;
var
exscripts
=
exscriptRepository
.
GetEntities
(
t
=>
modules
.
Select
(
s
=>
s
.
TypeId
).
Contains
(
t
.
TypeId
));
if
(
exscripts
==
null
||
!
exscripts
.
Any
())
return
;
var
configs
=
hospitalconfigRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
allot
.
HospitalId
);
var
configs
=
hospitalconfigRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
allot
.
HospitalId
);
if
(
configs
==
null
||
!
configs
.
Any
())
throw
new
Exception
(
"医院未配置绩效抽取信息"
);
if
(
configs
==
null
||
!
configs
.
Any
())
throw
new
Exception
(
"医院未配置绩效抽取信息"
);
foreach
(
var
module
in
modules
.
Where
(
t
=>
t
.
SheetType
==
(
int
)
SheetType
.
Custom
)?.
OrderBy
(
t
=>
t
.
ModuleName
))
var
parameters
=
customExtractService
.
GetParameters
(
allot
);
var
cellStyle
=
style
.
SetBgkColorAndFormat
(
style
.
GetCellStyle
(),
StyleType
.
数据
);
foreach
(
var
module
in
modules
)
{
{
var
sheet
=
workbook
.
GetSheet
(
module
.
ModuleName
)
??
workbook
.
GetSheet
(
module
.
ModuleName
.
NoBlank
());
var
sheet
=
workbook
.
GetSheet
(
module
.
ModuleName
)
??
workbook
.
GetSheet
(
module
.
ModuleName
.
NoBlank
());
if
(
sheet
==
null
)
if
(
sheet
==
null
)
...
@@ -32,12 +60,44 @@ public void WriteDataToCustom(IWorkbook workbook, per_allot allot)
...
@@ -32,12 +60,44 @@ public void WriteDataToCustom(IWorkbook workbook, per_allot allot)
sheet
=
workbook
.
CreateSheet
(
module
.
ModuleName
);
sheet
=
workbook
.
CreateSheet
(
module
.
ModuleName
);
workbook
.
SetSheetOrder
(
sheet
.
SheetName
,
workbook
.
NumberOfSheets
-
1
);
workbook
.
SetSheetOrder
(
sheet
.
SheetName
,
workbook
.
NumberOfSheets
-
1
);
}
}
}
IEnumerable
<
dynamic
>
data
;
var
exscript
=
exscripts
.
FirstOrDefault
(
t
=>
t
.
TypeId
==
module
.
TypeId
);
if
(
exscript
==
null
)
continue
;
var
conf
=
configs
.
FirstOrDefault
(
w
=>
w
.
Id
==
module
.
ConfigId
);
if
(
conf
==
null
)
continue
;
var
execsql
=
exscript
.
ExecScript
;
var
dynamics
=
customExtractService
.
QueryData
(
conf
,
execsql
,
parameters
);
try
{
// 没数据跳过
if
(
dynamics
==
null
||
dynamics
.
Count
()
==
0
)
continue
;
var
rowindex
=
Point
.
DataFirstRowNum
.
Value
;
for
(
int
r
=
0
;
r
<
dynamics
.
Count
();
r
++)
{
var
temp
=
(
IDictionary
<
string
,
object
>)
dynamics
.
ElementAt
(
r
);
// 行数据
var
row
=
sheet
.
GetOrCreate
(
rowindex
);
var
cellindex
=
Point
.
DataFirstCellNum
.
Value
;
foreach
(
var
item
in
temp
)
{
var
cell
=
row
.
GetOrCreate
(
cellindex
);
cell
.
SetCellOValue
(
item
.
Value
);
cell
.
CellStyle
=
cellStyle
;
cellindex
++;
}
rowindex
++;
}
}
catch
(
Exception
ex
)
{
logger
.
LogError
(
$"自定义模板 -
{
sheet
.
SheetName
}
抽取异常:"
+
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