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 c27c6a8bce
commit 82ec04d945
8 changed files with 79 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;
@ -52,4 +51,6 @@ public interface ExtTestPlanMapper {
@MapKey("id")
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

@ -1,15 +1,12 @@
package io.metersphere.plan.service;
import com.google.gson.Gson;
import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.*;
import io.metersphere.base.mapper.ext.ExtTestCaseMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanReportMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanTestCaseMapper;
import io.metersphere.commons.constants.*;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.*;
import io.metersphere.constants.RunModeConstants;
import io.metersphere.dto.*;
import io.metersphere.excel.constants.TestPlanTestCaseStatus;
@ -41,7 +38,7 @@ import io.metersphere.plan.service.remote.ui.PlanTestPlanUiScenarioCaseService;
import io.metersphere.plan.service.remote.ui.PlanUiAutomationService;
import io.metersphere.plan.utils.TestPlanRequestUtil;
import io.metersphere.request.ScheduleRequest;
import io.metersphere.service.*;
import io.metersphere.service.IssuesService;
import io.metersphere.utils.DiscoveryUtil;
import io.metersphere.utils.LoggerUtil;
import io.metersphere.xpack.track.dto.IssuesDao;
@ -52,7 +49,6 @@ import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionUtils;
import org.quartz.*;
import org.springframework.context.annotation.Lazy;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;
@ -1772,6 +1768,13 @@ public class TestPlanService {
}
public List<TestPlanDTO> planListAll(QueryTestPlanRequest request) {
if (StringUtils.isNotBlank(request.getProjectId())) {
request.setProjectId(request.getProjectId());
}
List<TestPlanDTO> testPlanDTOS = extTestPlanMapper.planListAll(request);
return testPlanDTOS;
}
private List<TestPlanExecutionQueue> getTestPlanExecutionQueues(TestPlanRunRequest request, Map<String, String> executeQueue) {
List<TestPlanExecutionQueue> planExecutionQueues = new ArrayList<>();