Merge branch 'master' of https://github.com/metersphere/metersphere
This commit is contained in:
commit
26ba9a93ea
|
@ -8,7 +8,7 @@ import org.apache.ibatis.annotations.Param;
|
|||
import java.util.List;
|
||||
|
||||
public interface ExtTestPlanMapper {
|
||||
List<TestPlanDTO> list(@Param("request") QueryTestPlanRequest params);
|
||||
List<TestPlanDTOWithMetric> list(@Param("request") QueryTestPlanRequest params);
|
||||
|
||||
List<TestPlanDTOWithMetric> listRelate(@Param("request") QueryTestPlanRequest params);
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@
|
|||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="list" resultMap="BaseResultMap"
|
||||
<select id="list" resultType="io.metersphere.track.dto.TestPlanDTOWithMetric"
|
||||
parameterType="io.metersphere.track.request.testcase.QueryTestPlanRequest">
|
||||
select DISTINCT test_plan.*, user.name as user_name from test_plan
|
||||
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.dto.LoadTestDTO;
|
||||
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 org.apache.commons.collections.CollectionUtils;
|
||||
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();
|
||||
request.setWorkspaceId(workspaceId);
|
||||
request.setId(planId);
|
||||
List<TestPlanDTO> list = extTestPlanMapper.list(request);
|
||||
List<TestPlanDTOWithMetric> list = extTestPlanMapper.list(request);
|
||||
if (CollectionUtils.size(list) != 1) {
|
||||
throw new UnauthorizedException(Translator.get("check_owner_plan"));
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ public class TestPlanController {
|
|||
CheckOwnerService checkOwnerService;
|
||||
|
||||
@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();
|
||||
request.setWorkspaceId(currentWorkspaceId);
|
||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||
|
|
|
@ -281,9 +281,46 @@ public class TestPlanService {
|
|||
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()));
|
||||
return extTestPlanMapper.list(request);
|
||||
List<TestPlanDTOWithMetric> testPlans = extTestPlanMapper.list(request);
|
||||
calcTestPlanRate(testPlans);
|
||||
return testPlans;
|
||||
}
|
||||
|
||||
public List<TestPlanDTO> listTestPlanByProject(QueryTestPlanRequest request) {
|
||||
|
@ -361,49 +398,12 @@ public class TestPlanService {
|
|||
|
||||
public List<TestPlanDTOWithMetric> listRelateAllPlan() {
|
||||
SessionUser user = SessionUtils.getUser();
|
||||
|
||||
QueryTestPlanRequest request = new QueryTestPlanRequest();
|
||||
request.setPrincipal(user.getId());
|
||||
request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
||||
request.setPlanIds(extTestPlanTestCaseMapper.findRelateTestPlanId(user.getId(), SessionUtils.getCurrentWorkspaceId()));
|
||||
|
||||
List<String> projectIds = extProjectMapper.getProjectIdByWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
||||
|
||||
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(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()));
|
||||
});
|
||||
|
||||
calcTestPlanRate(testPlans);
|
||||
return testPlans;
|
||||
}
|
||||
|
||||
|
@ -530,7 +530,7 @@ public class TestPlanService {
|
|||
for (Project project : projects) {
|
||||
stringBuilder.append(project.getName()).append("、");
|
||||
}
|
||||
projectName = stringBuilder.toString().substring(0, stringBuilder.length() - 1);
|
||||
projectName = stringBuilder.substring(0, stringBuilder.length() - 1);
|
||||
}
|
||||
|
||||
return projectName;
|
||||
|
|
|
@ -63,6 +63,15 @@
|
|||
<plan-stage-table-item :stage="scope.row.stage"/>
|
||||
</template>
|
||||
</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
|
||||
prop="projectName"
|
||||
:label="$t('test_track.plan.plan_project')"
|
||||
|
|
Loading…
Reference in New Issue