feat(测试跟踪): 测试计划列表增加进度列
This commit is contained in:
parent
8cb881fe42
commit
12e86889f7
|
@ -8,7 +8,7 @@ import org.apache.ibatis.annotations.Param;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface ExtTestPlanMapper {
|
public interface ExtTestPlanMapper {
|
||||||
List<TestPlanDTO> list(@Param("request") QueryTestPlanRequest params);
|
List<TestPlanDTOWithMetric> list(@Param("request") QueryTestPlanRequest params);
|
||||||
|
|
||||||
List<TestPlanDTOWithMetric> listRelate(@Param("request") QueryTestPlanRequest params);
|
List<TestPlanDTOWithMetric> listRelate(@Param("request") QueryTestPlanRequest params);
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@
|
||||||
</if>
|
</if>
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="list" resultMap="BaseResultMap"
|
<select id="list" resultType="io.metersphere.track.dto.TestPlanDTOWithMetric"
|
||||||
parameterType="io.metersphere.track.request.testcase.QueryTestPlanRequest">
|
parameterType="io.metersphere.track.request.testcase.QueryTestPlanRequest">
|
||||||
select DISTINCT test_plan.*, user.name as user_name from test_plan
|
select DISTINCT test_plan.*, user.name as user_name from test_plan
|
||||||
LEFT JOIN user ON user.id = test_plan.principal
|
LEFT JOIN user ON user.id = test_plan.principal
|
||||||
|
|
|
@ -8,7 +8,7 @@ import io.metersphere.base.mapper.ext.*;
|
||||||
import io.metersphere.commons.utils.SessionUtils;
|
import io.metersphere.commons.utils.SessionUtils;
|
||||||
import io.metersphere.dto.LoadTestDTO;
|
import io.metersphere.dto.LoadTestDTO;
|
||||||
import io.metersphere.i18n.Translator;
|
import io.metersphere.i18n.Translator;
|
||||||
import io.metersphere.track.dto.TestPlanDTO;
|
import io.metersphere.track.dto.TestPlanDTOWithMetric;
|
||||||
import io.metersphere.track.request.testplan.QueryTestPlanRequest;
|
import io.metersphere.track.request.testplan.QueryTestPlanRequest;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -81,7 +81,7 @@ public class CheckOwnerService {
|
||||||
io.metersphere.track.request.testcase.QueryTestPlanRequest request = new io.metersphere.track.request.testcase.QueryTestPlanRequest();
|
io.metersphere.track.request.testcase.QueryTestPlanRequest request = new io.metersphere.track.request.testcase.QueryTestPlanRequest();
|
||||||
request.setWorkspaceId(workspaceId);
|
request.setWorkspaceId(workspaceId);
|
||||||
request.setId(planId);
|
request.setId(planId);
|
||||||
List<TestPlanDTO> list = extTestPlanMapper.list(request);
|
List<TestPlanDTOWithMetric> list = extTestPlanMapper.list(request);
|
||||||
if (CollectionUtils.size(list) != 1) {
|
if (CollectionUtils.size(list) != 1) {
|
||||||
throw new UnauthorizedException(Translator.get("check_owner_plan"));
|
throw new UnauthorizedException(Translator.get("check_owner_plan"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class TestPlanController {
|
||||||
CheckOwnerService checkOwnerService;
|
CheckOwnerService checkOwnerService;
|
||||||
|
|
||||||
@PostMapping("/list/{goPage}/{pageSize}")
|
@PostMapping("/list/{goPage}/{pageSize}")
|
||||||
public Pager<List<TestPlanDTO>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestPlanRequest request) {
|
public Pager<List<TestPlanDTOWithMetric>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestPlanRequest request) {
|
||||||
String currentWorkspaceId = SessionUtils.getCurrentWorkspaceId();
|
String currentWorkspaceId = SessionUtils.getCurrentWorkspaceId();
|
||||||
request.setWorkspaceId(currentWorkspaceId);
|
request.setWorkspaceId(currentWorkspaceId);
|
||||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||||
|
|
|
@ -279,9 +279,46 @@ public class TestPlanService {
|
||||||
testPlanTestCaseMapper.deleteByExample(testPlanTestCaseExample);
|
testPlanTestCaseMapper.deleteByExample(testPlanTestCaseExample);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TestPlanDTO> listTestPlan(QueryTestPlanRequest request) {
|
private void calcTestPlanRate(List<TestPlanDTOWithMetric> testPlans) {
|
||||||
|
List<String> projectIds = extProjectMapper.getProjectIdByWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
||||||
|
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(MathUtils.getPercentWithDecimal(testPlan.getTested() == 0 ? 0 : testPlan.getPassed() * 1.0 / testPlan.getTested()));
|
||||||
|
testPlan.setTestRate(MathUtils.getPercentWithDecimal(testPlan.getTotal() == 0 ? 0 : testPlan.getTested() * 1.0 / testPlan.getTotal()));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TestPlanDTOWithMetric> listTestPlan(QueryTestPlanRequest request) {
|
||||||
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
|
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
|
||||||
return extTestPlanMapper.list(request);
|
List<TestPlanDTOWithMetric> testPlans = extTestPlanMapper.list(request);
|
||||||
|
calcTestPlanRate(testPlans);
|
||||||
|
return testPlans;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TestPlanDTO> listTestPlanByProject(QueryTestPlanRequest request) {
|
public List<TestPlanDTO> listTestPlanByProject(QueryTestPlanRequest request) {
|
||||||
|
@ -359,49 +396,12 @@ public class TestPlanService {
|
||||||
|
|
||||||
public List<TestPlanDTOWithMetric> 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(), SessionUtils.getCurrentWorkspaceId()));
|
request.setPlanIds(extTestPlanTestCaseMapper.findRelateTestPlanId(user.getId(), SessionUtils.getCurrentWorkspaceId()));
|
||||||
|
|
||||||
List<String> projectIds = extProjectMapper.getProjectIdByWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
|
||||||
|
|
||||||
List<TestPlanDTOWithMetric> testPlans = extTestPlanMapper.listRelate(request);
|
List<TestPlanDTOWithMetric> testPlans = extTestPlanMapper.listRelate(request);
|
||||||
|
calcTestPlanRate(testPlans);
|
||||||
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(MathUtils.getPercentWithDecimal(testPlan.getTested() == 0 ? 0 : testPlan.getPassed() * 1.0 / testPlan.getTested()));
|
|
||||||
testPlan.setTestRate(MathUtils.getPercentWithDecimal(testPlan.getTotal() == 0 ? 0 : testPlan.getTested() * 1.0 / testPlan.getTotal()));
|
|
||||||
});
|
|
||||||
|
|
||||||
return testPlans;
|
return testPlans;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -528,7 +528,7 @@ public class TestPlanService {
|
||||||
for (Project project : projects) {
|
for (Project project : projects) {
|
||||||
stringBuilder.append(project.getName()).append("、");
|
stringBuilder.append(project.getName()).append("、");
|
||||||
}
|
}
|
||||||
projectName = stringBuilder.toString().substring(0, stringBuilder.length() - 1);
|
projectName = stringBuilder.substring(0, stringBuilder.length() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return projectName;
|
return projectName;
|
||||||
|
|
|
@ -63,6 +63,15 @@
|
||||||
<plan-stage-table-item :stage="scope.row.stage"/>
|
<plan-stage-table-item :stage="scope.row.stage"/>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
prop="projectName"
|
||||||
|
:label="$t('test_track.home.test_rate')"
|
||||||
|
min-width="100"
|
||||||
|
show-overflow-tooltip>
|
||||||
|
<template v-slot:default="scope">
|
||||||
|
<el-progress :percentage="scope.row.testRate"></el-progress>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
prop="projectName"
|
prop="projectName"
|
||||||
:label="$t('test_track.plan.plan_project')"
|
:label="$t('test_track.plan.plan_project')"
|
||||||
|
|
Loading…
Reference in New Issue