提交 7eee038e 编写于 作者: C chenjianxing

测试跟踪首页数据

上级 6ad8cac6
...@@ -9,4 +9,6 @@ import java.util.List; ...@@ -9,4 +9,6 @@ import java.util.List;
public interface ExtProjectMapper { public interface ExtProjectMapper {
List<ProjectDTO> getProjectWithWorkspace(@Param("proRequest") ProjectRequest request); List<ProjectDTO> getProjectWithWorkspace(@Param("proRequest") ProjectRequest request);
List<String> getProjectIdByWorkspaceId(String workspaceId);
} }
...@@ -16,5 +16,10 @@ ...@@ -16,5 +16,10 @@
</if> </if>
</where> </where>
</select> </select>
<select id="getProjectIdByWorkspaceId" resultType="java.lang.String">
select id
from project
where workspace_id = #{workspaceId}
</select>
</mapper> </mapper>
\ No newline at end of file
package io.metersphere.base.mapper.ext; package io.metersphere.base.mapper.ext;
import io.metersphere.track.dto.TestPlanDTOWithMetric;
import io.metersphere.track.request.testcase.QueryTestPlanRequest; import io.metersphere.track.request.testcase.QueryTestPlanRequest;
import io.metersphere.track.dto.TestPlanDTO; import io.metersphere.track.dto.TestPlanDTO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -9,5 +10,5 @@ import java.util.List; ...@@ -9,5 +10,5 @@ import java.util.List;
public interface ExtTestPlanMapper { public interface ExtTestPlanMapper {
List<TestPlanDTO> list(@Param("request") QueryTestPlanRequest params); List<TestPlanDTO> list(@Param("request") QueryTestPlanRequest params);
List<TestPlanDTO> listRelate(@Param("request") QueryTestPlanRequest params); List<TestPlanDTOWithMetric> listRelate(@Param("request") QueryTestPlanRequest params);
} }
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
</if> </if>
</select> </select>
<select id="listRelate" resultType="io.metersphere.track.dto.TestPlanDTO"> <select id="listRelate" resultType="io.metersphere.track.dto.TestPlanDTOWithMetric">
select test_plan.*, project.name as project_name select test_plan.*, project.name as project_name
from test_plan from test_plan
left join project on test_plan.project_id = project.id left join project on test_plan.project_id = project.id
......
...@@ -8,6 +8,7 @@ import io.metersphere.commons.utils.Pager; ...@@ -8,6 +8,7 @@ import io.metersphere.commons.utils.Pager;
import io.metersphere.commons.utils.SessionUtils; import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.track.dto.TestCaseReportMetricDTO; import io.metersphere.track.dto.TestCaseReportMetricDTO;
import io.metersphere.track.dto.TestPlanDTO; import io.metersphere.track.dto.TestPlanDTO;
import io.metersphere.track.dto.TestPlanDTOWithMetric;
import io.metersphere.track.request.testcase.PlanCaseRelevanceRequest; import io.metersphere.track.request.testcase.PlanCaseRelevanceRequest;
import io.metersphere.track.request.testcase.QueryTestPlanRequest; import io.metersphere.track.request.testcase.QueryTestPlanRequest;
import io.metersphere.track.service.TestPlanService; import io.metersphere.track.service.TestPlanService;
...@@ -38,7 +39,7 @@ public class TestPlanController { ...@@ -38,7 +39,7 @@ public class TestPlanController {
} }
@PostMapping("/list/all/relate") @PostMapping("/list/all/relate")
public List<TestPlanDTO> listRelateAll() { public List<TestPlanDTOWithMetric> listRelateAll() {
return testPlanService.listRelateAllPlan(); return testPlanService.listRelateAllPlan();
} }
......
package io.metersphere.track.dto;
import io.metersphere.base.domain.TestPlan;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class TestPlanDTOWithMetric extends TestPlanDTO {
private Double passRate;
private Double testRate;
private Integer passed;
private Integer tested;
private Integer total;
}
...@@ -20,6 +20,8 @@ public class QueryTestPlanCaseRequest extends TestPlanTestCase { ...@@ -20,6 +20,8 @@ public class QueryTestPlanCaseRequest extends TestPlanTestCase {
private List<String> planIds; private List<String> planIds;
private List<String> projectIds;
private String workspaceId; private String workspaceId;
private String name; private String name;
......
...@@ -72,7 +72,4 @@ public class TestCaseReportService { ...@@ -72,7 +72,4 @@ public class TestCaseReportService {
testPlanMapper.updateByPrimaryKeySelective(testPlan); testPlanMapper.updateByPrimaryKeySelective(testPlan);
return report.getId(); return report.getId();
} }
} }
...@@ -6,6 +6,7 @@ import io.metersphere.base.mapper.TestCaseMapper; ...@@ -6,6 +6,7 @@ import io.metersphere.base.mapper.TestCaseMapper;
import io.metersphere.base.mapper.TestCaseNodeMapper; import io.metersphere.base.mapper.TestCaseNodeMapper;
import io.metersphere.base.mapper.TestPlanMapper; import io.metersphere.base.mapper.TestPlanMapper;
import io.metersphere.base.mapper.TestPlanTestCaseMapper; import io.metersphere.base.mapper.TestPlanTestCaseMapper;
import io.metersphere.base.mapper.ext.ExtProjectMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanMapper; import io.metersphere.base.mapper.ext.ExtTestPlanMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanTestCaseMapper; import io.metersphere.base.mapper.ext.ExtTestPlanTestCaseMapper;
import io.metersphere.commons.constants.TestPlanStatus; import io.metersphere.commons.constants.TestPlanStatus;
...@@ -13,6 +14,8 @@ import io.metersphere.commons.constants.TestPlanTestCaseStatus; ...@@ -13,6 +14,8 @@ import io.metersphere.commons.constants.TestPlanTestCaseStatus;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.user.SessionUser; import io.metersphere.commons.user.SessionUser;
import io.metersphere.commons.utils.SessionUtils; import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.controller.request.ProjectRequest;
import io.metersphere.dto.ProjectDTO;
import io.metersphere.track.dto.*; import io.metersphere.track.dto.*;
import io.metersphere.track.request.testcase.PlanCaseRelevanceRequest; import io.metersphere.track.request.testcase.PlanCaseRelevanceRequest;
import io.metersphere.track.request.testcase.QueryTestPlanRequest; import io.metersphere.track.request.testcase.QueryTestPlanRequest;
...@@ -58,6 +61,9 @@ public class TestPlanService { ...@@ -58,6 +61,9 @@ public class TestPlanService {
@Resource @Resource
TestCaseNodeService testCaseNodeService; TestCaseNodeService testCaseNodeService;
@Resource
ExtProjectMapper extProjectMapper;
public void addTestPlan(TestPlan testPlan) { public void addTestPlan(TestPlan testPlan) {
testPlan.setId(UUID.randomUUID().toString()); testPlan.setId(UUID.randomUUID().toString());
testPlan.setStatus(TestPlanStatus.Prepare.name()); testPlan.setStatus(TestPlanStatus.Prepare.name());
...@@ -149,13 +155,70 @@ public class TestPlanService { ...@@ -149,13 +155,70 @@ public class TestPlanService {
return testPlanMapper.selectByExample(testPlanExample); return testPlanMapper.selectByExample(testPlanExample);
} }
public List<TestPlanDTO> listRelateAllPlan() { public List<TestPlanDTOWithMetric> listRelateAllPlan() {
SessionUser user = SessionUtils.getUser(); SessionUser user = SessionUtils.getUser();
QueryTestPlanRequest request = new QueryTestPlanRequest(); QueryTestPlanRequest request = new QueryTestPlanRequest();
request.setPrincipal(user.getId()); request.setPrincipal(user.getId());
request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId()); request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
request.setPlanIds(extTestPlanTestCaseMapper.findRelateTestPlanId(user.getId())); request.setPlanIds(extTestPlanTestCaseMapper.findRelateTestPlanId(user.getId()));
return extTestPlanMapper.listRelate(request);
List<String> projectIds = extProjectMapper.getProjectIdByWorkspaceId(SessionUtils.getCurrentOrganizationId());
List<TestPlanDTOWithMetric> testPlans = extTestPlanMapper.listRelate(request);
Map<String, List<TestPlanCaseDTO>> testCaseMap = new HashMap<>();
listTestCaseByProjectIds(projectIds).forEach(testCase -> {
List<TestPlanCaseDTO> list = testCaseMap.get(testCase.getPlanId());
if (list == null) {
list = new ArrayList<>();
list.add(testCase);
testCaseMap.put(testCase.getPlanId(), list);
} else {
list.add(testCase);
}
});
testPlans.forEach(testPlan -> {
List<TestPlanCaseDTO> testCases = testCaseMap.get(testPlan.getId());
testPlan.setTested(0);
testPlan.setPassed(0);
testPlan.setTotal(0);
if (testCases != null) {
testPlan.setTotal(testCases.size());
testCases.forEach(testCase -> {
if (!StringUtils.equals(testCase.getStatus(), TestPlanTestCaseStatus.Prepare.name())
&& !StringUtils.equals(testCase.getStatus(), TestPlanTestCaseStatus.Underway.name())) {
testPlan.setTested(testPlan.getTested() + 1);
if (StringUtils.equals(testCase.getStatus(), TestPlanTestCaseStatus.Pass.name())) {
testPlan.setPassed(testPlan.getPassed() + 1);
}
}
});
}
testPlan.setPassRate(getPercentWithTwoDecimals(testPlan.getTested() == 0 ? 0 : testPlan.getPassed()*1.0/testPlan.getTested()));
testPlan.setTestRate(getPercentWithTwoDecimals(testPlan.getTotal() == 0 ? 0 : testPlan.getTested()*1.0/testPlan.getTotal()));
});
return testPlans;
}
private double getPercentWithTwoDecimals(double value) {
return new BigDecimal(value)
.setScale(4, BigDecimal.ROUND_HALF_UP)
.doubleValue() * 100;
}
public List<TestPlanCaseDTO> listTestCaseByPlanId(String planId) {
QueryTestPlanCaseRequest request = new QueryTestPlanCaseRequest();
request.setPlanId(planId);
return extTestPlanTestCaseMapper.list(request);
}
public List<TestPlanCaseDTO> listTestCaseByProjectIds(List<String> projectIds) {
QueryTestPlanCaseRequest request = new QueryTestPlanCaseRequest();
request.setProjectIds(projectIds);
return extTestPlanTestCaseMapper.list(request);
} }
public TestCaseReportMetricDTO getMetric(String planId) { public TestCaseReportMetricDTO getMetric(String planId) {
...@@ -180,9 +243,7 @@ public class TestPlanService { ...@@ -180,9 +243,7 @@ public class TestPlanService {
childIdMap.put(item.getId(), childIds); childIdMap.put(item.getId(), childIds);
}); });
QueryTestPlanCaseRequest request = new QueryTestPlanCaseRequest(); List<TestPlanCaseDTO> testPlanTestCases = listTestCaseByPlanId(planId);
request.setPlanId(planId);
List<TestPlanCaseDTO> testPlanTestCases = extTestPlanTestCaseMapper.list(request);
Map<String, TestCaseReportModuleResultDTO> moduleResultMap = new HashMap<>(); Map<String, TestCaseReportModuleResultDTO> moduleResultMap = new HashMap<>();
...@@ -192,7 +253,6 @@ public class TestPlanService { ...@@ -192,7 +253,6 @@ public class TestPlanService {
getModuleResultMap(childIdMap, moduleResultMap, testCase, nodeTrees); getModuleResultMap(childIdMap, moduleResultMap, testCase, nodeTrees);
} }
nodeTrees.forEach(rootNode -> { nodeTrees.forEach(rootNode -> {
TestCaseReportModuleResultDTO moduleResult = moduleResultMap.get(rootNode.getId()); TestCaseReportModuleResultDTO moduleResult = moduleResultMap.get(rootNode.getId());
if (moduleResult != null) { if (moduleResult != null) {
...@@ -201,9 +261,7 @@ public class TestPlanService { ...@@ -201,9 +261,7 @@ public class TestPlanService {
}); });
for (TestCaseReportModuleResultDTO moduleResult : moduleResultMap.values()) { for (TestCaseReportModuleResultDTO moduleResult : moduleResultMap.values()) {
moduleResult.setPassRate(new BigDecimal(moduleResult.getPassCount()*1.0f/moduleResult.getCaseCount()) moduleResult.setPassRate(getPercentWithTwoDecimals(moduleResult.getPassCount()*1.0f/moduleResult.getCaseCount()));
.setScale(2, BigDecimal.ROUND_HALF_UP)
.doubleValue() * 100);
if (moduleResult.getCaseCount() <= 0) { if (moduleResult.getCaseCount() <= 0) {
moduleResultMap.remove(moduleResult.getModuleId()); moduleResultMap.remove(moduleResult.getModuleId());
} }
......
...@@ -3,15 +3,15 @@ ...@@ -3,15 +3,15 @@
<div class="main-content"> <div class="main-content">
<el-row> <el-row>
<el-col :span="15"> <el-col :span="15">
<related-test-plan-list/> <related-test-plan-list ref="relatedTestPlanList"/>
</el-col> </el-col>
<el-col :span="9"> <el-col :span="9">
<el-row> <el-row>
<el-col> <el-col>
<test-case-side-list :title="'最近测试'" :type="'recent'"/> <test-case-side-list :title="'最近测试'" :type="'recent'" ref="testCaseRecentList"/>
</el-col> </el-col>
<el-col> <el-col>
<test-case-side-list :title="'待完成'" :type="'pending'"/> <test-case-side-list :title="'待完成'" :type="'pending'" ref="testCasePendingList"/>
</el-col> </el-col>
</el-row> </el-row>
</el-col> </el-col>
...@@ -25,7 +25,21 @@ ...@@ -25,7 +25,21 @@
import TestCaseSideList from "./components/TestCaseSideList"; import TestCaseSideList from "./components/TestCaseSideList";
export default { export default {
name: "TrackHome", name: "TrackHome",
components: {TestCaseSideList, RelatedTestPlanList} components: {TestCaseSideList, RelatedTestPlanList},
watch: {
'$route'(to,from) {
if (to.path.indexOf('/track/home') > -1) {
this.innitData();
}
}
},
methods: {
innitData() {
this.$refs.relatedTestPlanList.initTableData();
this.$refs.testCaseRecentList.initTableData();
this.$refs.testCasePendingList.initTableData();
}
}
} }
</script> </script>
......
<template> <template>
<home-base-component :title="'我的计划'"> <home-base-component :title="'我的计划'" v-loading>
<el-table <el-table
:data="tableData" :data="tableData"
@row-click="intoPlan"> @row-click="intoPlan"
v-loading="result.loading">
<el-table-column <el-table-column
prop="name" prop="name"
fixed fixed
...@@ -24,22 +24,28 @@ ...@@ -24,22 +24,28 @@
prop="projectName" prop="projectName"
:label="'通过率'" :label="'通过率'"
show-overflow-tooltip> show-overflow-tooltip>
20% <template v-slot:default="scope">
{{scope.row.passRate}}%
</template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="projectName" prop="projectName"
:label="'已测用例'" :label="'已测用例'"
show-overflow-tooltip> show-overflow-tooltip>
14/16 <template v-slot:default="scope">
{{scope.row.tested}}/{{scope.row.total}}
</template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="projectName" prop="projectName"
:label="'测试进度'" :label="'测试进度'"
min-width="120" min-width="100"
show-overflow-tooltip> show-overflow-tooltip>
<el-progress :percentage="50"></el-progress> <template v-slot:default="scope">
<el-progress :percentage="scope.row.testRate"></el-progress>
</template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
...@@ -56,7 +62,6 @@ ...@@ -56,7 +62,6 @@
show-overflow-tooltip> show-overflow-tooltip>
</el-table-column> </el-table-column>
</el-table> </el-table>
</home-base-component> </home-base-component>
...@@ -72,6 +77,7 @@ ...@@ -72,6 +77,7 @@
components: {MsTableOperator, PlanStageTableItem, PlanStatusTableItem, HomeBaseComponent}, components: {MsTableOperator, PlanStageTableItem, PlanStatusTableItem, HomeBaseComponent},
data() { data() {
return { return {
result: {},
tableData: [] tableData: []
} }
}, },
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
<el-table <el-table
row-key="id" row-key="id"
@row-click="editTestCase" @row-click="editTestCase"
:data="tableData"> :data="tableData"
v-loading="result.loading">
<el-table-column <el-table-column
prop="name" prop="name"
...@@ -54,6 +55,7 @@ ...@@ -54,6 +55,7 @@
components: {PriorityTableItem, TypeTableItem, StatusTableItem, HomeBaseComponent}, components: {PriorityTableItem, TypeTableItem, StatusTableItem, HomeBaseComponent},
data() { data() {
return { return {
result: {},
tableData: [], tableData: [],
} }
}, },
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册