fix(接口测试): 修复场景转测试计划不显示责任人的缺陷

--bug=1018863 --user=王孝刚 【接口测试】接口测试-接口自动化转测试计划中测试计划的进度显示不正确
https://www.tapd.cn/55049933/s/1292768
This commit is contained in:
wxg0103 2022-11-08 19:08:45 +08:00 committed by wxg0103
parent 722de82676
commit a7e91ddb00
8 changed files with 84 additions and 16 deletions

View File

@ -1,8 +1,8 @@
package io.metersphere.controller.remote;
import io.metersphere.service.remote.RemoteTestPlanService;
import io.metersphere.api.dto.QueryTestPlanRequest;
import io.metersphere.commons.exception.MSException;
import io.metersphere.service.remote.RemoteTestPlanService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
@ -22,6 +22,11 @@ public class TestPlanController {
add("test/plan/scenario/case");
}};
@PostMapping("/list/all/{goPage}/{pageSize}")
public Object planListAll(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestPlanRequest request) {
return remoteTestPlanService.planListAll("/test/plan", goPage, pageSize, request);
}
@GetMapping("/**")
public List getStageOption(HttpServletRequest request) {
excludeApi(request.getRequestURI());
@ -37,6 +42,7 @@ public class TestPlanController {
/**
* 解决不同模块路径冲突导致循环调用
* todo 待优化
*
* @param url
*/
public void excludeApi(String url) {

View File

@ -39,4 +39,13 @@ public class RemoteTestPlanService {
return new ArrayList();
}
}
public Object planListAll(String url, int goPage, int pageSize, QueryTestPlanRequest request) {
try {
return microService.postForData(MicroServiceName.TEST_TRACK, url + String.format("/list/all/%s/%s", goPage, pageSize), request);
} catch (Exception e) {
LogUtil.info("测试计划服务调用失败", e);
return new ArrayList();
}
}
}

View File

@ -7,7 +7,11 @@ export function getPlanStageOption() {
}
export function planPage(page, pageSize, params) {
return post('/test/plan/list/all/', params);
return post('/test/plan/list/all/'+ page + '/' + pageSize, params);
}
export function testPlanGetPrincipal(id) {
return get('/test/plan/' + `principal/${id}`);
}
export function getApiScenarioIdByPlanScenarioId(id) {

View File

@ -34,7 +34,7 @@
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="userName"
prop="principalName"
:label="$t('test_track.plan.plan_principal')"
show-overflow-tooltip>
</el-table-column>
@ -109,6 +109,8 @@
</template>
</el-table-column>
</el-table>
<ms-table-pagination :change="initTableData" :current-page.sync="currentPage" :page-size.sync="pageSize"
:total="total"/>
<ms-delete-confirm :title="$t('test_track.plan.plan_delete')" @delete="_handleDelete" ref="deleteConfirm"
:with-tip="enableDeleteTip">
{{ $t('test_track.plan.plan_delete_tip') }}
@ -135,7 +137,7 @@ import {getCurrentProjectID} from "metersphere-frontend/src/utils/token";
import {_filter, _sort} from "metersphere-frontend/src/utils/tableUtils";
import EnvPopover from "@/business/automation/scenario/EnvPopover";
import {ENV_TYPE} from "metersphere-frontend/src/utils/constants";
import {getPlanStageOption, planPage} from "@/api/test-plan";
import {getPlanStageOption, planPage, testPlanGetPrincipal} from "@/api/test-plan";
import {getApiScenarioProjectIdByConditions, getScenarioByProjectId} from "@/api/scenario";
import {getOwnerProjects} from "@/api/project";
@ -277,7 +279,27 @@ export default {
this.result = planPage(this.currentPage, this.pageSize, this.condition).then(response => {
let data = response.data;
this.total = data.itemCount;
this.tableData = data;
data.listObject.forEach(item => {
testPlanGetPrincipal(item.id)
.then(res => {
let data = res.data;
let principal = "";
let principalIds = data.map(d => d.id);
if (data) {
data.forEach(d => {
if (principal !== "") {
principal = principal + "、" + d.name;
} else {
principal = principal + d.name;
}
})
}
this.$set(item, "principalName", principal);
// id
this.$set(item, "principals", principalIds);
});
});
this.tableData = data.listObject;
});
},
buildPagePath(path) {

View File

@ -1,7 +1,6 @@
package io.metersphere.base.mapper.ext;
import io.metersphere.base.domain.TestPlan;
import io.metersphere.dto.ParamsDTO;
import io.metersphere.dto.TestPlanDTOWithMetric;
import io.metersphere.plan.dto.TestPlanDTO;
@ -39,17 +38,19 @@ public interface ExtTestPlanMapper {
int updateActualEndTimeIsNullById(String testPlanID);
@MapKey("id")
Map<String, ParamsDTO> testPlanTestCaseCount(@Param("planIds")Set<String> planIds);
Map<String, ParamsDTO> testPlanTestCaseCount(@Param("planIds") Set<String> planIds);
@MapKey("id")
Map<String, ParamsDTO> testPlanApiCaseCount(@Param("planIds")Set<String> planIds);
Map<String, ParamsDTO> testPlanApiCaseCount(@Param("planIds") Set<String> planIds);
@MapKey("id")
Map<String, ParamsDTO> testPlanApiScenarioCount(@Param("planIds")Set<String> planIds);
Map<String, ParamsDTO> testPlanApiScenarioCount(@Param("planIds") Set<String> planIds);
@MapKey("id")
Map<String, ParamsDTO> testPlanLoadCaseCount(@Param("planIds")Set<String> planIds);
Map<String, ParamsDTO> testPlanLoadCaseCount(@Param("planIds") Set<String> planIds);
@MapKey("id")
Map<String, ParamsDTO> testPlanUiScenarioCount(@Param("planIds")Set<String> planIds);
Map<String, ParamsDTO> testPlanUiScenarioCount(@Param("planIds") Set<String> planIds);
List<TestPlanDTO> planListAll(@Param("request") QueryTestPlanRequest params);
}

View File

@ -406,6 +406,17 @@
</where>
GROUP BY t.test_plan_id
</select>
<select id="planListAll" resultType="io.metersphere.plan.dto.TestPlanDTO">
select DISTINCT test_plan.*, project.name as projectName,
(select name from user where user.id = test_plan.creator) as userName
from test_plan
JOIN project on project.id = test_plan.project_id
<where>
<if test="request.projectId != null">
AND test_plan.project_id = #{request.projectId}
</if>
</where>
</select>
<update id="updateActualEndTimeIsNullById">
update test_plan
set actual_end_time = null

View File

@ -88,6 +88,13 @@ public class TestPlanController {
return testPlanService.listTestAllPlan(request);
}
@PostMapping("/list/all/{goPage}/{pageSize}")
@RequiresPermissions("PROJECT_TRACK_PLAN:READ")
public Pager<List<TestPlanDTO>> planListAll(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestPlanRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, testPlanService.planListAll(request));
}
@GetMapping("/get/stage/option/{projectId}")
public List getStageOption(@PathVariable("projectId") String projectId) {
return testPlanService.getStageOption(projectId);

View File

@ -641,6 +641,14 @@ public class TestPlanService {
return testPlanMapper.selectByExample(example);
}
public List<TestPlanDTO> planListAll(QueryTestPlanRequest request) {
if (StringUtils.isNotBlank(request.getProjectId())) {
request.setProjectId(request.getProjectId());
}
List<TestPlanDTO> testPlanDTOS = extTestPlanMapper.planListAll(request);
return testPlanDTOS;
}
public List<TestPlanCaseDTO> listTestCaseByPlanId(String planId) {
QueryTestPlanCaseRequest request = new QueryTestPlanCaseRequest();
request.setPlanId(planId);
@ -764,7 +772,7 @@ public class TestPlanService {
return testPlanReportService.genTestPlanReportBySchedule(planReportId, planId, userId, triggerMode, runModeConfigDTO);
}
public String run(String testPlanId, String projectId, String userId, String triggerMode, String planReportId,String executionWay, String apiRunConfig) {
public String run(String testPlanId, String projectId, String userId, String triggerMode, String planReportId, String executionWay, String apiRunConfig) {
RunModeConfigDTO runModeConfig = null;
try {
runModeConfig = JSON.parseObject(apiRunConfig, RunModeConfigDTO.class);
@ -778,7 +786,7 @@ public class TestPlanService {
//环境参数为空时依据测试计划保存的环境执行
if (((StringUtils.equals("GROUP", runModeConfig.getEnvironmentType()) && StringUtils.isBlank(runModeConfig.getEnvironmentGroupId()))
|| (!StringUtils.equals("GROUP", runModeConfig.getEnvironmentType()) && MapUtils.isEmpty(runModeConfig.getEnvMap())))
&& !StringUtils.equals(executionWay,ExecutionWay.RUN.name())) {
&& !StringUtils.equals(executionWay, ExecutionWay.RUN.name())) {
TestPlanWithBLOBs testPlanWithBLOBs = testPlanMapper.selectByPrimaryKey(testPlanId);
if (StringUtils.isNotEmpty(testPlanWithBLOBs.getRunModeConfig())) {
try {
@ -1525,7 +1533,7 @@ public class TestPlanService {
String apiRunConfig = JSON.toJSONString(runModeConfig);
return this.run(testPlanId, testplanRunRequest.getProjectId(),
testplanRunRequest.getUserId(), testplanRunRequest.getTriggerMode(), testplanRunRequest.getReportId(),testplanRunRequest.getExecutionWay(), apiRunConfig);
testplanRunRequest.getUserId(), testplanRunRequest.getTriggerMode(), testplanRunRequest.getReportId(), testplanRunRequest.getExecutionWay(), apiRunConfig);
}
@ -1537,12 +1545,12 @@ public class TestPlanService {
runModeConfig.setEnvironmentType(testplanRunRequest.getEnvironmentType());
if (StringUtils.equals(envType, "JSON") && !envMap.isEmpty()) {
runModeConfig.setEnvMap(testplanRunRequest.getEnvMap());
if (!StringUtils.equals(testplanRunRequest.getExecutionWay(),ExecutionWay.RUN.name())){
if (!StringUtils.equals(testplanRunRequest.getExecutionWay(), ExecutionWay.RUN.name())) {
this.setPlanCaseEnv(testPlanId, runModeConfig);
}
} else if (StringUtils.equals(envType, "GROUP") && StringUtils.isNotBlank(environmentGroupId)) {
runModeConfig.setEnvironmentGroupId(testplanRunRequest.getEnvironmentGroupId());
if (!StringUtils.equals(testplanRunRequest.getExecutionWay(),ExecutionWay.RUN.name())){
if (!StringUtils.equals(testplanRunRequest.getExecutionWay(), ExecutionWay.RUN.name())) {
this.setPlanCaseEnv(testPlanId, runModeConfig);
}
}