Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MeterSphere
metersphere
提交
6ad8cac6
M
metersphere
项目概览
MeterSphere
/
metersphere
上一次同步 大约 3 年
通知
25
Star
1
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
metersphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6ad8cac6
编写于
5月 15, 2020
作者:
C
chenjianxing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
接口调整
上级
8a5a8557
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
123 addition
and
126 deletion
+123
-126
backend/src/main/java/io/metersphere/track/controller/TestCaseReportController.java
...etersphere/track/controller/TestCaseReportController.java
+0
-4
backend/src/main/java/io/metersphere/track/controller/TestPlanController.java
...a/io/metersphere/track/controller/TestPlanController.java
+5
-1
backend/src/main/java/io/metersphere/track/service/TestCaseReportService.java
...a/io/metersphere/track/service/TestCaseReportService.java
+0
-119
backend/src/main/java/io/metersphere/track/service/TestPlanService.java
...in/java/io/metersphere/track/service/TestPlanService.java
+117
-1
frontend/src/business/components/track/plan/view/comonents/TestCaseReportView.vue
...mponents/track/plan/view/comonents/TestCaseReportView.vue
+1
-1
未找到文件。
backend/src/main/java/io/metersphere/track/controller/TestCaseReportController.java
浏览文件 @
6ad8cac6
...
...
@@ -41,8 +41,4 @@ public class TestCaseReportController {
return
testCaseReportService
.
deleteTestCaseReport
(
id
);
}
@GetMapping
(
"/get/metric/{planId}"
)
public
TestCaseReportMetricDTO
getMetric
(
@PathVariable
String
planId
){
return
testCaseReportService
.
getMetric
(
planId
);
}
}
backend/src/main/java/io/metersphere/track/controller/TestPlanController.java
浏览文件 @
6ad8cac6
...
...
@@ -6,6 +6,7 @@ import io.metersphere.base.domain.TestPlan;
import
io.metersphere.commons.utils.PageUtils
;
import
io.metersphere.commons.utils.Pager
;
import
io.metersphere.commons.utils.SessionUtils
;
import
io.metersphere.track.dto.TestCaseReportMetricDTO
;
import
io.metersphere.track.dto.TestPlanDTO
;
import
io.metersphere.track.request.testcase.PlanCaseRelevanceRequest
;
import
io.metersphere.track.request.testcase.QueryTestPlanRequest
;
...
...
@@ -73,5 +74,8 @@ public class TestPlanController {
testPlanService
.
testPlanRelevance
(
request
);
}
@GetMapping
(
"/get/metric/{planId}"
)
public
TestCaseReportMetricDTO
getMetric
(
@PathVariable
String
planId
){
return
testPlanService
.
getMetric
(
planId
);
}
}
backend/src/main/java/io/metersphere/track/service/TestCaseReportService.java
浏览文件 @
6ad8cac6
...
...
@@ -35,21 +35,6 @@ public class TestCaseReportService {
@Resource
TestCaseReportTemplateMapper
testCaseReportTemplateMapper
;
@Resource
TestCaseNodeService
testCaseNodeService
;
@Resource
TestCaseNodeMapper
testCaseNodeMapper
;
@Resource
ExtTestPlanTestCaseMapper
extTestPlanTestCaseMapper
;
@Resource
TestPlanTestCaseMapper
testPlanTestCaseMapper
;
@Resource
ExtTestCaseMapper
extTestCaseMapper
;
public
List
<
TestCaseReport
>
listTestCaseReport
(
TestCaseReport
request
)
{
TestCaseReportExample
example
=
new
TestCaseReportExample
();
if
(
StringUtils
.
isNotBlank
(
request
.
getName
())
)
{
...
...
@@ -88,110 +73,6 @@ public class TestCaseReportService {
return
report
.
getId
();
}
public
TestCaseReportMetricDTO
getMetric
(
String
planId
)
{
QueryTestPlanRequest
queryTestPlanRequest
=
new
QueryTestPlanRequest
();
queryTestPlanRequest
.
setId
(
planId
);
TestPlanDTO
testPlan
=
extTestPlanMapper
.
list
(
queryTestPlanRequest
).
get
(
0
);
Set
<
String
>
executors
=
new
HashSet
<>();
Map
<
String
,
TestCaseReportStatusResultDTO
>
reportStatusResultMap
=
new
HashMap
<>();
TestCaseNodeExample
testCaseNodeExample
=
new
TestCaseNodeExample
();
testCaseNodeExample
.
createCriteria
().
andProjectIdEqualTo
(
testPlan
.
getProjectId
());
List
<
TestCaseNode
>
nodes
=
testCaseNodeMapper
.
selectByExample
(
testCaseNodeExample
);
List
<
TestCaseNodeDTO
>
nodeTrees
=
testCaseNodeService
.
getNodeTrees
(
nodes
);
Map
<
String
,
Set
<
String
>>
childIdMap
=
new
HashMap
<>();
nodeTrees
.
forEach
(
item
->
{
Set
<
String
>
childIds
=
new
HashSet
<>();
getChildIds
(
item
,
childIds
);
childIdMap
.
put
(
item
.
getId
(),
childIds
);
});
QueryTestPlanCaseRequest
request
=
new
QueryTestPlanCaseRequest
();
request
.
setPlanId
(
planId
);
List
<
TestPlanCaseDTO
>
testPlanTestCases
=
extTestPlanTestCaseMapper
.
list
(
request
);
Map
<
String
,
TestCaseReportModuleResultDTO
>
moduleResultMap
=
new
HashMap
<>();
for
(
TestPlanCaseDTO
testCase:
testPlanTestCases
)
{
executors
.
add
(
testCase
.
getExecutor
());
getStatusResultMap
(
reportStatusResultMap
,
testCase
);
getModuleResultMap
(
childIdMap
,
moduleResultMap
,
testCase
,
nodeTrees
);
}
nodeTrees
.
forEach
(
rootNode
->
{
TestCaseReportModuleResultDTO
moduleResult
=
moduleResultMap
.
get
(
rootNode
.
getId
());
if
(
moduleResult
!=
null
)
{
moduleResult
.
setModuleName
(
rootNode
.
getName
());
}
});
for
(
TestCaseReportModuleResultDTO
moduleResult
:
moduleResultMap
.
values
())
{
moduleResult
.
setPassRate
(
new
BigDecimal
(
moduleResult
.
getPassCount
()*
1.0f
/
moduleResult
.
getCaseCount
())
.
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
)
.
doubleValue
()
*
100
);
if
(
moduleResult
.
getCaseCount
()
<=
0
)
{
moduleResultMap
.
remove
(
moduleResult
.
getModuleId
());
}
}
TestCaseReportMetricDTO
testCaseReportMetricDTO
=
new
TestCaseReportMetricDTO
();
testCaseReportMetricDTO
.
setProjectName
(
testPlan
.
getProjectName
());
testCaseReportMetricDTO
.
setPrincipal
(
testPlan
.
getPrincipal
());
testCaseReportMetricDTO
.
setExecutors
(
new
ArrayList
<>(
executors
));
testCaseReportMetricDTO
.
setExecuteResult
(
new
ArrayList
<>(
reportStatusResultMap
.
values
()));
testCaseReportMetricDTO
.
setModuleExecuteResult
(
new
ArrayList
<>(
moduleResultMap
.
values
()));
return
testCaseReportMetricDTO
;
}
private
void
getStatusResultMap
(
Map
<
String
,
TestCaseReportStatusResultDTO
>
reportStatusResultMap
,
TestPlanCaseDTO
testCase
)
{
TestCaseReportStatusResultDTO
statusResult
=
reportStatusResultMap
.
get
(
testCase
.
getStatus
());
if
(
statusResult
==
null
)
{
statusResult
=
new
TestCaseReportStatusResultDTO
();
statusResult
.
setStatus
(
testCase
.
getStatus
());
statusResult
.
setCount
(
0
);
}
statusResult
.
setCount
(
statusResult
.
getCount
()
+
1
);
reportStatusResultMap
.
put
(
testCase
.
getStatus
(),
statusResult
);
}
private
void
getModuleResultMap
(
Map
<
String
,
Set
<
String
>>
childIdMap
,
Map
<
String
,
TestCaseReportModuleResultDTO
>
moduleResultMap
,
TestPlanCaseDTO
testCase
,
List
<
TestCaseNodeDTO
>
nodeTrees
)
{
childIdMap
.
forEach
((
rootNodeId
,
childIds
)
->
{
if
(
childIds
.
contains
(
testCase
.
getNodeId
()))
{
TestCaseReportModuleResultDTO
moduleResult
=
moduleResultMap
.
get
(
rootNodeId
);
if
(
moduleResult
==
null
)
{
moduleResult
=
new
TestCaseReportModuleResultDTO
();
moduleResult
.
setCaseCount
(
0
);
moduleResult
.
setPassCount
(
0
);
moduleResult
.
setModuleId
(
rootNodeId
);
}
moduleResult
.
setCaseCount
(
moduleResult
.
getCaseCount
()
+
1
);
if
(
StringUtils
.
equals
(
testCase
.
getStatus
(),
TestPlanTestCaseStatus
.
Pass
.
name
()))
{
moduleResult
.
setPassCount
(
moduleResult
.
getPassCount
()
+
1
);
}
moduleResultMap
.
put
(
rootNodeId
,
moduleResult
);
return
;
}
});
}
private
void
getChildIds
(
TestCaseNodeDTO
rootNode
,
Set
<
String
>
childIds
)
{
childIds
.
add
(
rootNode
.
getId
());
List
<
TestCaseNodeDTO
>
children
=
rootNode
.
getChildren
();
if
(
children
!=
null
)
{
Iterator
<
TestCaseNodeDTO
>
iterator
=
children
.
iterator
();
while
(
iterator
.
hasNext
()){
getChildIds
(
iterator
.
next
(),
childIds
);
}
}
}
}
backend/src/main/java/io/metersphere/track/service/TestPlanService.java
浏览文件 @
6ad8cac6
...
...
@@ -3,18 +3,21 @@ package io.metersphere.track.service;
import
io.metersphere.base.domain.*
;
import
io.metersphere.base.mapper.TestCaseMapper
;
import
io.metersphere.base.mapper.TestCaseNodeMapper
;
import
io.metersphere.base.mapper.TestPlanMapper
;
import
io.metersphere.base.mapper.TestPlanTestCaseMapper
;
import
io.metersphere.base.mapper.ext.ExtTestPlanMapper
;
import
io.metersphere.base.mapper.ext.ExtTestPlanTestCaseMapper
;
import
io.metersphere.commons.constants.TestPlanStatus
;
import
io.metersphere.commons.constants.TestPlanTestCaseStatus
;
import
io.metersphere.commons.exception.MSException
;
import
io.metersphere.commons.user.SessionUser
;
import
io.metersphere.commons.utils.SessionUtils
;
import
io.metersphere.track.dto.*
;
import
io.metersphere.track.request.testcase.PlanCaseRelevanceRequest
;
import
io.metersphere.track.request.testcase.QueryTestPlanRequest
;
import
io.metersphere.track.dto.TestPlanDTO
;
import
io.metersphere.i18n.Translator
;
import
io.metersphere.track.request.testplancase.QueryTestPlanCaseRequest
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.ibatis.session.ExecutorType
;
import
org.apache.ibatis.session.SqlSession
;
...
...
@@ -23,6 +26,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
java.math.BigDecimal
;
import
java.util.*
;
import
java.util.stream.Collectors
;
...
...
@@ -48,6 +52,12 @@ public class TestPlanService {
@Resource
SqlSessionFactory
sqlSessionFactory
;
@Resource
TestCaseNodeMapper
testCaseNodeMapper
;
@Resource
TestCaseNodeService
testCaseNodeService
;
public
void
addTestPlan
(
TestPlan
testPlan
)
{
testPlan
.
setId
(
UUID
.
randomUUID
().
toString
());
testPlan
.
setStatus
(
TestPlanStatus
.
Prepare
.
name
());
...
...
@@ -147,4 +157,110 @@ public class TestPlanService {
request
.
setPlanIds
(
extTestPlanTestCaseMapper
.
findRelateTestPlanId
(
user
.
getId
()));
return
extTestPlanMapper
.
listRelate
(
request
);
}
public
TestCaseReportMetricDTO
getMetric
(
String
planId
)
{
QueryTestPlanRequest
queryTestPlanRequest
=
new
QueryTestPlanRequest
();
queryTestPlanRequest
.
setId
(
planId
);
TestPlanDTO
testPlan
=
extTestPlanMapper
.
list
(
queryTestPlanRequest
).
get
(
0
);
Set
<
String
>
executors
=
new
HashSet
<>();
Map
<
String
,
TestCaseReportStatusResultDTO
>
reportStatusResultMap
=
new
HashMap
<>();
TestCaseNodeExample
testCaseNodeExample
=
new
TestCaseNodeExample
();
testCaseNodeExample
.
createCriteria
().
andProjectIdEqualTo
(
testPlan
.
getProjectId
());
List
<
TestCaseNode
>
nodes
=
testCaseNodeMapper
.
selectByExample
(
testCaseNodeExample
);
List
<
TestCaseNodeDTO
>
nodeTrees
=
testCaseNodeService
.
getNodeTrees
(
nodes
);
Map
<
String
,
Set
<
String
>>
childIdMap
=
new
HashMap
<>();
nodeTrees
.
forEach
(
item
->
{
Set
<
String
>
childIds
=
new
HashSet
<>();
getChildIds
(
item
,
childIds
);
childIdMap
.
put
(
item
.
getId
(),
childIds
);
});
QueryTestPlanCaseRequest
request
=
new
QueryTestPlanCaseRequest
();
request
.
setPlanId
(
planId
);
List
<
TestPlanCaseDTO
>
testPlanTestCases
=
extTestPlanTestCaseMapper
.
list
(
request
);
Map
<
String
,
TestCaseReportModuleResultDTO
>
moduleResultMap
=
new
HashMap
<>();
for
(
TestPlanCaseDTO
testCase:
testPlanTestCases
)
{
executors
.
add
(
testCase
.
getExecutor
());
getStatusResultMap
(
reportStatusResultMap
,
testCase
);
getModuleResultMap
(
childIdMap
,
moduleResultMap
,
testCase
,
nodeTrees
);
}
nodeTrees
.
forEach
(
rootNode
->
{
TestCaseReportModuleResultDTO
moduleResult
=
moduleResultMap
.
get
(
rootNode
.
getId
());
if
(
moduleResult
!=
null
)
{
moduleResult
.
setModuleName
(
rootNode
.
getName
());
}
});
for
(
TestCaseReportModuleResultDTO
moduleResult
:
moduleResultMap
.
values
())
{
moduleResult
.
setPassRate
(
new
BigDecimal
(
moduleResult
.
getPassCount
()*
1.0f
/
moduleResult
.
getCaseCount
())
.
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
)
.
doubleValue
()
*
100
);
if
(
moduleResult
.
getCaseCount
()
<=
0
)
{
moduleResultMap
.
remove
(
moduleResult
.
getModuleId
());
}
}
TestCaseReportMetricDTO
testCaseReportMetricDTO
=
new
TestCaseReportMetricDTO
();
testCaseReportMetricDTO
.
setProjectName
(
testPlan
.
getProjectName
());
testCaseReportMetricDTO
.
setPrincipal
(
testPlan
.
getPrincipal
());
testCaseReportMetricDTO
.
setExecutors
(
new
ArrayList
<>(
executors
));
testCaseReportMetricDTO
.
setExecuteResult
(
new
ArrayList
<>(
reportStatusResultMap
.
values
()));
testCaseReportMetricDTO
.
setModuleExecuteResult
(
new
ArrayList
<>(
moduleResultMap
.
values
()));
return
testCaseReportMetricDTO
;
}
private
void
getStatusResultMap
(
Map
<
String
,
TestCaseReportStatusResultDTO
>
reportStatusResultMap
,
TestPlanCaseDTO
testCase
)
{
TestCaseReportStatusResultDTO
statusResult
=
reportStatusResultMap
.
get
(
testCase
.
getStatus
());
if
(
statusResult
==
null
)
{
statusResult
=
new
TestCaseReportStatusResultDTO
();
statusResult
.
setStatus
(
testCase
.
getStatus
());
statusResult
.
setCount
(
0
);
}
statusResult
.
setCount
(
statusResult
.
getCount
()
+
1
);
reportStatusResultMap
.
put
(
testCase
.
getStatus
(),
statusResult
);
}
private
void
getModuleResultMap
(
Map
<
String
,
Set
<
String
>>
childIdMap
,
Map
<
String
,
TestCaseReportModuleResultDTO
>
moduleResultMap
,
TestPlanCaseDTO
testCase
,
List
<
TestCaseNodeDTO
>
nodeTrees
)
{
childIdMap
.
forEach
((
rootNodeId
,
childIds
)
->
{
if
(
childIds
.
contains
(
testCase
.
getNodeId
()))
{
TestCaseReportModuleResultDTO
moduleResult
=
moduleResultMap
.
get
(
rootNodeId
);
if
(
moduleResult
==
null
)
{
moduleResult
=
new
TestCaseReportModuleResultDTO
();
moduleResult
.
setCaseCount
(
0
);
moduleResult
.
setPassCount
(
0
);
moduleResult
.
setModuleId
(
rootNodeId
);
}
moduleResult
.
setCaseCount
(
moduleResult
.
getCaseCount
()
+
1
);
if
(
StringUtils
.
equals
(
testCase
.
getStatus
(),
TestPlanTestCaseStatus
.
Pass
.
name
()))
{
moduleResult
.
setPassCount
(
moduleResult
.
getPassCount
()
+
1
);
}
moduleResultMap
.
put
(
rootNodeId
,
moduleResult
);
return
;
}
});
}
private
void
getChildIds
(
TestCaseNodeDTO
rootNode
,
Set
<
String
>
childIds
)
{
childIds
.
add
(
rootNode
.
getId
());
List
<
TestCaseNodeDTO
>
children
=
rootNode
.
getChildren
();
if
(
children
!=
null
)
{
Iterator
<
TestCaseNodeDTO
>
iterator
=
children
.
iterator
();
while
(
iterator
.
hasNext
()){
getChildIds
(
iterator
.
next
(),
childIds
);
}
}
}
}
frontend/src/business/components/track/plan/view/comonents/TestCaseReportView.vue
浏览文件 @
6ad8cac6
...
...
@@ -150,7 +150,7 @@
}
},
getMetric
()
{
this
.
result
=
this
.
$get
(
'
/
case/report
/get/metric/
'
+
this
.
planId
,
response
=>
{
this
.
result
=
this
.
$get
(
'
/
test/plan
/get/metric/
'
+
this
.
planId
,
response
=>
{
this
.
metric
=
response
.
data
;
if
(
this
.
report
.
startTime
)
{
this
.
metric
.
startTime
=
new
Date
(
this
.
report
.
startTime
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录