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
d2764d99
Commit
d2764d99
authored
May 20, 2022
by
1391696987
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
每月汇报表返回结果平级转层级
parent
064e84b5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
8 deletions
+30
-8
performance/Performance.DtoModels/ReportStatistics/ReportStatisticsInfoDto.cs
+1
-1
performance/Performance.Services/StatisticsService.cs
+29
-7
No files found.
performance/Performance.DtoModels/ReportStatistics/ReportStatisticsInfoDto.cs
View file @
d2764d99
...
...
@@ -79,7 +79,7 @@ public class StatisticsQueryResultDto
/// </summary>
public
int
?
IsComparison
{
get
;
set
;
}
public
List
<
StatisticsColumn
>
Columns
{
get
;
set
;
}
public
List
<
Dictionary
<
string
,
string
>>
Datas
{
get
;
set
;
}
public
List
<
Dictionary
<
string
,
object
>>
Datas
{
get
;
set
;
}
}
public
class
StatisticsColumn
...
...
performance/Performance.Services/StatisticsService.cs
View file @
d2764d99
...
...
@@ -187,14 +187,14 @@ private StatisticsQueryResultDto StatisticsQuery7(StatisticsQuery query, report_
{
pairs
.
Add
(
item
.
Title
,
item
.
Values
);
}
var
table
=
new
List
<
Dictionary
<
string
,
string
>>();
var
table
=
new
List
<
Dictionary
<
string
,
object
>>();
using
(
IDbConnection
connection
=
new
MySqlConnection
(
_options
.
Value
.
PerformanceConnectionString
))
{
if
(!
string
.
IsNullOrEmpty
(
statistics
.
TotalScript
))
{
var
(
sql
,
param
)
=
GetSqlQuery
(
statistics
.
TotalScript
,
pairs
);
var
data
=
connection
.
Query
(
sql
,
param
);
table
=
JsonHelper
.
Deserialize
<
List
<
Dictionary
<
string
,
string
>>>(
JsonHelper
.
Serialize
(
data
));
table
=
JsonHelper
.
Deserialize
<
List
<
Dictionary
<
string
,
object
>>>(
JsonHelper
.
Serialize
(
data
));
}
}
var
columns
=
new
List
<
StatisticsColumn
>();
...
...
@@ -251,14 +251,14 @@ private StatisticsQueryResultDto StatisticsQuery(StatisticsQuery query, report_s
{
pairs
.
Add
(
item
.
Title
,
item
.
Values
);
}
var
table
=
new
List
<
Dictionary
<
string
,
string
>>();
var
table
=
new
List
<
Dictionary
<
string
,
object
>>();
using
(
IDbConnection
connection
=
new
MySqlConnection
(
_options
.
Value
.
PerformanceConnectionString
))
{
if
(!
string
.
IsNullOrEmpty
(
statistics
.
TotalScript
))
{
var
(
sql
,
param
)
=
GetSqlQuery
(
statistics
.
TotalScript
,
pairs
);
var
data
=
connection
.
Query
(
sql
,
param
);
table
=
JsonHelper
.
Deserialize
<
List
<
Dictionary
<
string
,
string
>>>(
JsonHelper
.
Serialize
(
data
));
table
=
JsonHelper
.
Deserialize
<
List
<
Dictionary
<
string
,
object
>>>(
JsonHelper
.
Serialize
(
data
));
}
}
var
columns
=
new
List
<
StatisticsColumn
>();
...
...
@@ -313,11 +313,14 @@ private StatisticsQueryResultDto StatisticsTreeQuery(StatisticsQuery query, List
pairs
.
Add
(
item
.
Title
,
item
.
Values
);
}
var
table
=
new
List
<
Dictionary
<
string
,
string
>>();
var
table
=
new
List
<
Dictionary
<
string
,
object
>>();
// 层级有几层,则数据就有几层
foreach
(
var
item
in
reportStatisticsTree
)
{
var
row
=
new
Dictionary
<
string
,
string
>();
var
row
=
new
Dictionary
<
string
,
object
>();
row
.
Add
(
"ID"
,
item
.
ID
);
row
.
Add
(
"ParentID"
,
item
.
ParentID
);
row
.
Add
(
"项目"
,
item
.
Name
);
if
(
reportStatisticsTree
.
Any
(
w
=>
!
string
.
IsNullOrEmpty
(
w
.
TotalScript
)
||
!
string
.
IsNullOrEmpty
(
w
.
TotalFormula
)))
{
...
...
@@ -351,12 +354,31 @@ private StatisticsQueryResultDto StatisticsTreeQuery(StatisticsQuery query, List
}
table
.
Add
(
row
);
}
// 平级转层级
var
statisticsTree
=
StatisticsTree
(
table
,
0
);
return
new
StatisticsQueryResultDto
{
IsComparison
=
query
.
IsComparison
,
Columns
=
columns
,
Datas
=
tabl
e
,
Datas
=
statisticsTre
e
,
};
}
private
List
<
Dictionary
<
string
,
object
>>
StatisticsTree
(
List
<
Dictionary
<
string
,
object
>>
oldTree
,
int
parentID
)
{
if
(
oldTree
.
Any
(
w
=>
(
int
)
w
[
"ParentID"
]
==
parentID
))
{
List
<
Dictionary
<
string
,
object
>>
newTree
=
new
List
<
Dictionary
<
string
,
object
>>();
foreach
(
var
item
in
oldTree
.
Where
(
t
=>
(
int
)
t
[
"ParentID"
]
==
parentID
))
{
item
.
Add
(
"Children"
,
StatisticsTree
(
oldTree
,
(
int
)
item
[
"ID"
]));
newTree
.
Add
(
item
);
}
return
newTree
;
}
else
return
null
;
}
}
}
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