Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
xiaofang li
MeterSphere
Commits
9bb48e54
Commit
9bb48e54
authored
3 years ago
by
chenjianxing
Committed by
jianxing
3 years ago
Browse files
Options
Download
Email Patches
Plain Diff
feat: 保存的测试报告支持导出报告
parent
c81813f8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
backend/src/main/java/io/metersphere/track/controller/TestPlanController.java
+5
-0
...a/io/metersphere/track/controller/TestPlanController.java
backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java
+10
-0
...a/io/metersphere/track/service/TestPlanReportService.java
backend/src/main/java/io/metersphere/track/service/TestPlanService.java
+62
-41
...in/java/io/metersphere/track/service/TestPlanService.java
frontend/src/business/components/track/plan/view/comonents/report/detail/TestPlanReportButtons.vue
+8
-4
...an/view/comonents/report/detail/TestPlanReportButtons.vue
frontend/src/business/components/track/plan/view/comonents/report/detail/TestPlanReportContent.vue
+2
-2
...an/view/comonents/report/detail/TestPlanReportContent.vue
with
87 additions
and
47 deletions
+87
-47
backend/src/main/java/io/metersphere/track/controller/TestPlanController.java
+
5
-
0
View file @
9bb48e54
...
@@ -213,6 +213,11 @@ public class TestPlanController {
...
@@ -213,6 +213,11 @@ public class TestPlanController {
testPlanService
.
exportPlanReport
(
planId
,
response
);
testPlanService
.
exportPlanReport
(
planId
,
response
);
}
}
@GetMapping
(
"/report/db/export/{reportId}"
)
public
void
exportHtmlDbReport
(
@PathVariable
String
reportId
,
HttpServletResponse
response
)
throws
UnsupportedEncodingException
{
testPlanService
.
exportPlanDbReport
(
reportId
,
response
);
}
@GetMapping
(
"/report/{planId}"
)
@GetMapping
(
"/report/{planId}"
)
public
TestPlanSimpleReportDTO
getReport
(
@PathVariable
String
planId
)
{
public
TestPlanSimpleReportDTO
getReport
(
@PathVariable
String
planId
)
{
return
testPlanService
.
getReport
(
planId
);
return
testPlanService
.
getReport
(
planId
);
...
...
This diff is collapsed.
Click to expand it.
backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java
+
10
-
0
View file @
9bb48e54
...
@@ -927,6 +927,9 @@ public class TestPlanReportService {
...
@@ -927,6 +927,9 @@ public class TestPlanReportService {
TestPlanReportDataExample
example
=
new
TestPlanReportDataExample
();
TestPlanReportDataExample
example
=
new
TestPlanReportDataExample
();
example
.
createCriteria
().
andTestPlanReportIdEqualTo
(
testPlanReportId
);
example
.
createCriteria
().
andTestPlanReportIdEqualTo
(
testPlanReportId
);
testPlanReportDataMapper
.
deleteByExample
(
example
);
testPlanReportDataMapper
.
deleteByExample
(
example
);
TestPlanReportContentExample
contentExample
=
new
TestPlanReportContentExample
();
contentExample
.
createCriteria
().
andTestPlanReportIdEqualTo
(
testPlanReportId
);
testPlanReportContentMapper
.
deleteByExample
(
contentExample
);
// TestPlanReportResourceExample resourceExample = new TestPlanReportResourceExample();
// TestPlanReportResourceExample resourceExample = new TestPlanReportResourceExample();
// resourceExample.createCriteria().andTestPlanReportIdEqualTo(testPlanReportId);
// resourceExample.createCriteria().andTestPlanReportIdEqualTo(testPlanReportId);
// testPlanReportResourceService.deleteByExample(resourceExample);
// testPlanReportResourceService.deleteByExample(resourceExample);
...
@@ -954,6 +957,10 @@ public class TestPlanReportService {
...
@@ -954,6 +957,10 @@ public class TestPlanReportService {
example
.
createCriteria
().
andTestPlanReportIdIn
(
deleteReportIds
);
example
.
createCriteria
().
andTestPlanReportIdIn
(
deleteReportIds
);
testPlanReportDataMapper
.
deleteByExample
(
example
);
testPlanReportDataMapper
.
deleteByExample
(
example
);
TestPlanReportContentExample
contentExample
=
new
TestPlanReportContentExample
();
contentExample
.
createCriteria
().
andTestPlanReportIdIn
(
deleteReportIds
);
testPlanReportContentMapper
.
deleteByExample
(
contentExample
);
// TestPlanReportResourceExample resourceExample = new TestPlanReportResourceExample();
// TestPlanReportResourceExample resourceExample = new TestPlanReportResourceExample();
// resourceExample.createCriteria().andTestPlanReportIdIn(deleteReportIds);
// resourceExample.createCriteria().andTestPlanReportIdIn(deleteReportIds);
// testPlanReportResourceService.deleteByExample(resourceExample);
// testPlanReportResourceService.deleteByExample(resourceExample);
...
@@ -1096,6 +1103,9 @@ public class TestPlanReportService {
...
@@ -1096,6 +1103,9 @@ public class TestPlanReportService {
if
(
StringUtils
.
isNotBlank
(
testPlanReportContent
.
getLoadFailureCases
()))
{
if
(
StringUtils
.
isNotBlank
(
testPlanReportContent
.
getLoadFailureCases
()))
{
testPlanReportDTO
.
setLoadFailureCases
(
JSONObject
.
parseArray
(
testPlanReportContent
.
getLoadFailureCases
(),
TestPlanLoadCaseDTO
.
class
));
testPlanReportDTO
.
setLoadFailureCases
(
JSONObject
.
parseArray
(
testPlanReportContent
.
getLoadFailureCases
(),
TestPlanLoadCaseDTO
.
class
));
}
}
testPlanReportDTO
.
setId
(
reportId
);
TestPlanReport
testPlanReport
=
testPlanReportMapper
.
selectByPrimaryKey
(
testPlanReportContent
.
getTestPlanReportId
());
testPlanReportDTO
.
setName
(
testPlanReport
.
getName
());
return
testPlanReportDTO
;
return
testPlanReportDTO
;
}
}
}
}
This diff is collapsed.
Click to expand it.
backend/src/main/java/io/metersphere/track/service/TestPlanService.java
+
62
-
41
View file @
9bb48e54
...
@@ -1397,19 +1397,12 @@ public class TestPlanService {
...
@@ -1397,19 +1397,12 @@ public class TestPlanService {
apiAllCases
=
testPlanApiCaseService
.
getAllCases
(
planId
);
apiAllCases
=
testPlanApiCaseService
.
getAllCases
(
planId
);
report
.
setApiAllCases
(
apiAllCases
);
report
.
setApiAllCases
(
apiAllCases
);
if
(
saveResponse
)
{
if
(
saveResponse
)
{
apiAllCases
.
forEach
(
item
->
{
buildApiResponse
(
apiAllCases
);
APIReportResult
dbResult
=
apiDefinitionService
.
getDbResult
(
item
.
getId
());
if
(
dbResult
!=
null
&&
StringUtils
.
isNotBlank
(
dbResult
.
getContent
()))
{
item
.
setResponse
(
dbResult
.
getContent
());
}
});
}
}
//场景
//场景
scenarioAllCases
=
testPlanScenarioCaseService
.
getAllCases
(
planId
);
scenarioAllCases
=
testPlanScenarioCaseService
.
getAllCases
(
planId
);
if
(
saveResponse
)
{
if
(
saveResponse
)
{
scenarioAllCases
.
forEach
((
item
)
->
{
buildScenarioResponse
(
scenarioAllCases
);
item
.
setResponse
(
apiScenarioReportService
.
get
(
item
.
getReportId
()));
});
}
}
report
.
setScenarioAllCases
(
scenarioAllCases
);
report
.
setScenarioAllCases
(
scenarioAllCases
);
}
}
...
@@ -1425,12 +1418,7 @@ public class TestPlanService {
...
@@ -1425,12 +1418,7 @@ public class TestPlanService {
apiFailureCases
=
testPlanApiCaseService
.
getFailureCases
(
planId
);
apiFailureCases
=
testPlanApiCaseService
.
getFailureCases
(
planId
);
}
}
if
(
saveResponse
)
{
if
(
saveResponse
)
{
apiFailureCases
.
forEach
(
item
->
{
buildApiResponse
(
apiFailureCases
);
APIReportResult
dbResult
=
apiDefinitionService
.
getDbResult
(
item
.
getId
());
if
(
dbResult
!=
null
&&
StringUtils
.
isNotBlank
(
dbResult
.
getContent
()))
{
item
.
setResponse
(
dbResult
.
getContent
());
}
});
}
}
report
.
setApiFailureCases
(
apiFailureCases
);
report
.
setApiFailureCases
(
apiFailureCases
);
...
@@ -1445,43 +1433,66 @@ public class TestPlanService {
...
@@ -1445,43 +1433,66 @@ public class TestPlanService {
scenarioFailureCases
=
testPlanScenarioCaseService
.
getFailureCases
(
planId
);
scenarioFailureCases
=
testPlanScenarioCaseService
.
getFailureCases
(
planId
);
}
}
if
(
saveResponse
)
{
if
(
saveResponse
)
{
scenarioFailureCases
.
forEach
((
item
)
->
{
buildScenarioResponse
(
scenarioFailureCases
);
item
.
setResponse
(
apiScenarioReportService
.
get
(
item
.
getReportId
()));
});
}
}
report
.
setScenarioFailureCases
(
scenarioFailureCases
);
report
.
setScenarioFailureCases
(
scenarioFailureCases
);
}
}
}
}
}
}
public
void
buildApiResponse
(
List
<
TestPlanFailureApiDTO
>
cases
)
{
if
(!
CollectionUtils
.
isEmpty
(
cases
))
{
cases
.
forEach
(
item
->
{
APIReportResult
dbResult
=
apiDefinitionService
.
getDbResult
(
item
.
getId
());
if
(
dbResult
!=
null
&&
StringUtils
.
isNotBlank
(
dbResult
.
getContent
()))
{
item
.
setResponse
(
dbResult
.
getContent
());
}
});
}
}
public
void
buildScenarioResponse
(
List
<
TestPlanFailureScenarioDTO
>
cases
)
{
if
(!
CollectionUtils
.
isEmpty
(
cases
))
{
cases
.
forEach
((
item
)
->
{
item
.
setResponse
(
apiScenarioReportService
.
get
(
item
.
getReportId
()));
});
}
}
public
void
buildLoadResponse
(
List
<
TestPlanLoadCaseDTO
>
cases
)
{
if
(!
CollectionUtils
.
isEmpty
(
cases
))
{
cases
.
forEach
(
item
->
{
LoadCaseReportRequest
request
=
new
LoadCaseReportRequest
();
String
reportId
=
item
.
getLoadReportId
();
if
(
StringUtils
.
isNotBlank
(
reportId
))
{
request
.
setTestPlanLoadCaseId
(
item
.
getId
());
request
.
setReportId
(
reportId
);
Boolean
existReport
=
testPlanLoadCaseService
.
isExistReport
(
request
);
if
(
existReport
)
{
LoadTestReportWithBLOBs
loadTestReport
=
performanceReportService
.
getLoadTestReport
(
reportId
);
ReportTimeInfo
reportTimeInfo
=
performanceReportService
.
getReportTimeInfo
(
reportId
);
TestPlanLoadCaseDTO
.
ReportDTO
reportDTO
=
new
TestPlanLoadCaseDTO
.
ReportDTO
();
if
(
loadTestReport
!=
null
)
{
BeanUtils
.
copyBean
(
reportDTO
,
loadTestReport
);
}
if
(
reportTimeInfo
!=
null
)
{
BeanUtils
.
copyBean
(
reportDTO
,
reportTimeInfo
);
}
item
.
setResponse
(
reportDTO
);
// todo 报告详情
}
}
});
}
}
public
void
buildLoadReport
(
TestPlanSimpleReportDTO
report
,
JSONObject
config
,
String
planId
,
boolean
saveResponse
)
{
public
void
buildLoadReport
(
TestPlanSimpleReportDTO
report
,
JSONObject
config
,
String
planId
,
boolean
saveResponse
)
{
if
(
checkReportConfig
(
config
,
"load"
))
{
if
(
checkReportConfig
(
config
,
"load"
))
{
List
<
TestPlanLoadCaseDTO
>
allCases
=
null
;
List
<
TestPlanLoadCaseDTO
>
allCases
=
null
;
if
(
checkReportConfig
(
config
,
"load"
,
"all"
))
{
if
(
checkReportConfig
(
config
,
"load"
,
"all"
))
{
allCases
=
testPlanLoadCaseService
.
getAllCases
(
planId
);
allCases
=
testPlanLoadCaseService
.
getAllCases
(
planId
);
if
(
saveResponse
)
{
if
(
saveResponse
)
{
allCases
.
forEach
(
item
->
{
buildLoadResponse
(
allCases
);
LoadCaseReportRequest
request
=
new
LoadCaseReportRequest
();
String
reportId
=
item
.
getLoadReportId
();
if
(
StringUtils
.
isNotBlank
(
reportId
))
{
request
.
setTestPlanLoadCaseId
(
item
.
getId
());
request
.
setReportId
(
reportId
);
Boolean
existReport
=
testPlanLoadCaseService
.
isExistReport
(
request
);
if
(
existReport
)
{
LoadTestReportWithBLOBs
loadTestReport
=
performanceReportService
.
getLoadTestReport
(
reportId
);
ReportTimeInfo
reportTimeInfo
=
performanceReportService
.
getReportTimeInfo
(
reportId
);
TestPlanLoadCaseDTO
.
ReportDTO
reportDTO
=
new
TestPlanLoadCaseDTO
.
ReportDTO
();
if
(
loadTestReport
!=
null
)
{
BeanUtils
.
copyBean
(
reportDTO
,
loadTestReport
);
}
if
(
reportTimeInfo
!=
null
)
{
BeanUtils
.
copyBean
(
reportDTO
,
reportTimeInfo
);
}
item
.
setResponse
(
reportDTO
);
// todo 报告详情
}
}
});
}
}
report
.
setLoadAllCases
(
allCases
);
report
.
setLoadAllCases
(
allCases
);
}
}
...
@@ -1659,6 +1670,16 @@ public class TestPlanService {
...
@@ -1659,6 +1670,16 @@ public class TestPlanService {
render
(
buildPlanReport
(
planId
,
true
),
response
);
render
(
buildPlanReport
(
planId
,
true
),
response
);
}
}
public
void
exportPlanDbReport
(
String
reportId
,
HttpServletResponse
response
)
throws
UnsupportedEncodingException
{
TestPlanSimpleReportDTO
report
=
testPlanReportService
.
getReport
(
reportId
);
buildApiResponse
(
report
.
getApiAllCases
());
buildApiResponse
(
report
.
getApiFailureCases
());
buildScenarioResponse
(
report
.
getScenarioAllCases
());
buildScenarioResponse
(
report
.
getScenarioFailureCases
());
buildLoadResponse
(
report
.
getLoadAllCases
());
render
(
report
,
response
);
}
public
Boolean
checkReportConfig
(
JSONObject
config
,
String
key
)
{
public
Boolean
checkReportConfig
(
JSONObject
config
,
String
key
)
{
if
(
config
==
null
)
{
if
(
config
==
null
)
{
return
true
;
return
true
;
...
@@ -1709,7 +1730,7 @@ public class TestPlanService {
...
@@ -1709,7 +1730,7 @@ public class TestPlanService {
start
+=
1024
;
start
+=
1024
;
}
}
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Throwable
e
)
{
LogUtil
.
error
(
e
.
getMessage
(),
e
);
LogUtil
.
error
(
e
.
getMessage
(),
e
);
MSException
.
throwException
(
e
.
getMessage
());
MSException
.
throwException
(
e
.
getMessage
());
}
}
...
...
This diff is collapsed.
Click to expand it.
frontend/src/business/components/track/plan/view/comonents/report/detail/TestPlanReportButtons.vue
+
8
-
4
View file @
9bb48e54
...
@@ -9,14 +9,14 @@
...
@@ -9,14 +9,14 @@
<el-button
type=
"primary"
size=
"mini"
:disabled=
"!shareUrl"
<el-button
type=
"primary"
size=
"mini"
:disabled=
"!shareUrl"
v-clipboard:copy=
"shareUrl"
>
{{
$t
(
"
commons.copy
"
)
}}
</el-button>
v-clipboard:copy=
"shareUrl"
>
{{
$t
(
"
commons.copy
"
)
}}
</el-button>
</div>
</div>
<el-button
icon=
"el-icon-share"
slot=
"reference"
:disabled=
"!isTestManagerOrTestUser"
<el-button
icon=
"el-icon-share"
v-if=
"!isDb"
slot=
"reference"
:disabled=
"!isTestManagerOrTestUser"
plain
size=
"mini"
@
click=
"handleShare()"
>
plain
size=
"mini"
@
click=
"handleShare()"
>
{{
'
分享
'
}}
{{
'
分享
'
}}
</el-button>
</el-button>
</el-popover>
</el-popover>
</el-row>
</el-row>
<el-row>
<el-row>
<el-button
icon=
"el-icon-receiving"
:disabled=
"!isTestManagerOrTestUser"
plain
size=
"mini"
@
click=
"handleSave()"
>
<el-button
icon=
"el-icon-receiving"
v-if=
"!isDb"
:disabled=
"!isTestManagerOrTestUser"
plain
size=
"mini"
@
click=
"handleSave()"
>
{{
'
保存
'
}}
{{
'
保存
'
}}
</el-button>
</el-button>
</el-row>
</el-row>
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
</el-button>
</el-button>
</el-row>
</el-row>
<el-row>
<el-row>
<el-button
icon=
"el-icon-setting"
:disabled=
"!isTestManagerOrTestUser"
plain
size=
"mini"
@
click=
"handleEditTemplate()"
>
<el-button
icon=
"el-icon-setting"
v-if=
"!isDb"
:disabled=
"!isTestManagerOrTestUser"
plain
size=
"mini"
@
click=
"handleEditTemplate()"
>
{{
'
配置
'
}}
{{
'
配置
'
}}
</el-button>
</el-button>
</el-row>
</el-row>
...
@@ -49,7 +49,8 @@ export default {
...
@@ -49,7 +49,8 @@ export default {
props
:
{
props
:
{
planId
:
String
,
planId
:
String
,
isShare
:
Boolean
,
isShare
:
Boolean
,
report
:
Object
report
:
Object
,
isDb
:
Boolean
},
},
data
()
{
data
()
{
return
{
return
{
...
@@ -91,6 +92,9 @@ export default {
...
@@ -91,6 +92,9 @@ export default {
method
:
'
get
'
,
method
:
'
get
'
,
responseType
:
'
blob
'
responseType
:
'
blob
'
};
};
if
(
this
.
isDb
)
{
config
.
url
=
'
/test/plan/report/db/export/
'
+
this
.
report
.
id
;
}
if
(
this
.
isShare
)
{
if
(
this
.
isShare
)
{
config
.
url
=
'
/share
'
+
config
.
url
;
config
.
url
=
'
/share
'
+
config
.
url
;
}
}
...
...
This diff is collapsed.
Click to expand it.
frontend/src/business/components/track/plan/view/comonents/report/detail/TestPlanReportContent.vue
+
2
-
2
View file @
9bb48e54
...
@@ -2,8 +2,8 @@
...
@@ -2,8 +2,8 @@
<div
class=
"container"
>
<div
class=
"container"
>
<el-main>
<el-main>
<el-card
v-loading=
"result ? result.loading : false"
>
<el-card
v-loading=
"result ? result.loading : false"
>
<test-plan-report-buttons
:plan-id=
"planId"
:is-share=
"isShare"
:report=
"report"
<test-plan-report-buttons
:is-db=
"isDb"
:plan-id=
"planId"
:is-share=
"isShare"
:report=
"report"
v-if=
"!isTemplate
&& !isShare && !isDb
"
/>
v-if=
"!isTemplate"
/>
<test-plan-overview-report
v-if=
"overviewEnable"
:report=
"report"
/>
<test-plan-overview-report
v-if=
"overviewEnable"
:report=
"report"
/>
<test-plan-summary-report
v-if=
"summaryEnable"
:is-db=
"isDb"
:is-template=
"isTemplate"
:is-share=
"isShare"
:report=
"report"
:plan-id=
"planId"
/>
<test-plan-summary-report
v-if=
"summaryEnable"
:is-db=
"isDb"
:is-template=
"isTemplate"
:is-share=
"isShare"
:report=
"report"
:plan-id=
"planId"
/>
<test-plan-functional-report
v-if=
"functionalEnable"
:is-db=
"isDb"
:share-id=
"shareId"
:is-share=
"isShare"
:is-template=
"isTemplate"
:plan-id=
"planId"
:report=
"report"
/>
<test-plan-functional-report
v-if=
"functionalEnable"
:is-db=
"isDb"
:share-id=
"shareId"
:is-share=
"isShare"
:is-template=
"isTemplate"
:plan-id=
"planId"
:report=
"report"
/>
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
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
Menu
Projects
Groups
Snippets
Help