fix(测试跟踪): 测试计划缺陷管理列表查询优化
--bug=1011778 --user=郭雨琦 测试计划和缺陷管理列表查询优化 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001011778 chore(sync): sync
This commit is contained in:
parent
8a29a86138
commit
127b01bc19
|
@ -1,8 +1,13 @@
|
|||
package io.metersphere.base.mapper;
|
||||
|
||||
import io.metersphere.api.dto.definition.ParamsDTO;
|
||||
import io.metersphere.base.domain.TestCaseIssues;
|
||||
import io.metersphere.base.domain.TestCaseIssuesExample;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.ibatis.annotations.MapKey;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface TestCaseIssuesMapper {
|
||||
|
@ -27,4 +32,5 @@ public interface TestCaseIssuesMapper {
|
|||
int updateByPrimaryKeySelective(TestCaseIssues record);
|
||||
|
||||
int updateByPrimaryKey(TestCaseIssues record);
|
||||
|
||||
}
|
|
@ -1,8 +1,13 @@
|
|||
package io.metersphere.base.mapper;
|
||||
|
||||
import io.metersphere.api.dto.definition.ParamsDTO;
|
||||
import io.metersphere.base.domain.TestPlanReport;
|
||||
import io.metersphere.base.domain.TestPlanReportExample;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.ibatis.annotations.MapKey;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface TestPlanReportMapper {
|
||||
|
@ -27,4 +32,7 @@ public interface TestPlanReportMapper {
|
|||
int updateByPrimaryKeySelective(TestPlanReport record);
|
||||
|
||||
int updateByPrimaryKey(TestPlanReport record);
|
||||
|
||||
@MapKey("id")
|
||||
Map<String, ParamsDTO> reportCount(@Param("planIds") Set<String> planIds);
|
||||
}
|
|
@ -235,6 +235,18 @@
|
|||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</select>
|
||||
<select id="reportCount" resultType="io.metersphere.api.dto.definition.ParamsDTO">
|
||||
select t.test_plan_id as id , count(*) from test_plan_report t
|
||||
<where>
|
||||
<if test="planIds != null and planIds.size() > 0">
|
||||
and t.test_plan_id IN
|
||||
<foreach collection="planIds" item="id" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY t.test_plan_id
|
||||
</select>
|
||||
<update id="updateByExampleSelective" parameterType="map">
|
||||
update test_plan_report
|
||||
<set>
|
||||
|
|
|
@ -31,4 +31,6 @@ public interface ExtIssuesMapper {
|
|||
List<IssuesDao> getPlanIssues(@Param("request") IssuesRequest issueRequest);
|
||||
|
||||
int deleteIssues(@Param("issuesId") String issuesId, @Param("resourceId") String resourceId);
|
||||
|
||||
IssuesDao selectByPrimaryKey(String id);
|
||||
}
|
||||
|
|
|
@ -112,6 +112,12 @@
|
|||
#{value}
|
||||
</foreach>
|
||||
</select>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultType="io.metersphere.base.domain.IssuesDao">
|
||||
select
|
||||
<include refid="Issue_List_Column" />
|
||||
from issues
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</select>
|
||||
|
||||
<sql id="queryWhereCondition">
|
||||
<where>
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
package io.metersphere.base.mapper.ext;
|
||||
|
||||
import io.metersphere.api.dto.definition.ParamsDTO;
|
||||
import io.metersphere.base.domain.TestPlan;
|
||||
import io.metersphere.track.dto.TestPlanDTO;
|
||||
import io.metersphere.track.dto.TestPlanDTOWithMetric;
|
||||
import io.metersphere.track.request.testcase.QueryTestPlanRequest;
|
||||
import org.apache.ibatis.annotations.MapKey;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public interface ExtTestPlanMapper {
|
||||
|
@ -37,4 +40,16 @@ public interface ExtTestPlanMapper {
|
|||
List<TestPlan> listRecent(@Param("userId") String userId, @Param("projectId") String currentProjectId);
|
||||
|
||||
int updateActualEndTimeIsNullById(String testPlanID);
|
||||
|
||||
@MapKey("id")
|
||||
Map<String, ParamsDTO> testPlanTestCaseCount(@Param("planIds")Set<String> planIds);
|
||||
|
||||
@MapKey("id")
|
||||
Map<String, ParamsDTO> testPlanApiCaseCount(@Param("planIds")Set<String> planIds);
|
||||
|
||||
@MapKey("id")
|
||||
Map<String, ParamsDTO> testPlanApiScenarioCount(@Param("planIds")Set<String> planIds);
|
||||
|
||||
@MapKey("id")
|
||||
Map<String, ParamsDTO> testPlanLoadCaseCount(@Param("planIds")Set<String> planIds);
|
||||
}
|
||||
|
|
|
@ -111,34 +111,24 @@
|
|||
</if>
|
||||
</sql>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<select id="list" resultType="io.metersphere.track.dto.TestPlanDTOWithMetric"
|
||||
parameterType="io.metersphere.track.request.testcase.QueryTestPlanRequest">
|
||||
select DISTINCT test_plan.*, project.name as projectName,schedule.id as scheduleId,
|
||||
(select name from user where user.id = test_plan.creator) as createUser,
|
||||
IF(schedule.enable = true,true,false) as scheduleOpen,
|
||||
(select COUNT(*) from test_plan_test_case t
|
||||
inner join test_case on t.case_id = test_case.id
|
||||
left join test_case_node on test_case_node.id = test_case.node_id
|
||||
inner join project on project.id = test_case.project_id
|
||||
where (test_case.status != 'Trash' or test_case.status is null )
|
||||
and t.plan_id = test_plan.id) as testPlanTestCaseCount,
|
||||
|
||||
(select COUNT(*) from test_plan_api_case t
|
||||
inner join api_test_case c on t.api_case_id = c.id
|
||||
inner join api_definition a on c.api_definition_id = a.id
|
||||
where t.test_plan_id = test_plan.id and (c.status != 'Trash' or c.status is null)) as testPlanApiCaseCount,
|
||||
|
||||
(select COUNT(*) from test_plan_api_scenario t
|
||||
inner join api_scenario c on t.api_scenario_id = c.id
|
||||
and (c.status != 'Trash' or c.status is null)
|
||||
where t.test_plan_id = test_plan.id) as testPlanApiScenarioCount,
|
||||
|
||||
(select COUNT(*) from test_plan_load_case t
|
||||
inner join load_test lt on t.load_case_id = lt.id
|
||||
left join user u on lt.user_id = u.id
|
||||
left join project p on lt.project_id = p.id
|
||||
where t.test_plan_id = test_plan.id) as testPlanLoadCaseCount
|
||||
|
||||
IF(schedule.enable = true,true,false) as scheduleOpen
|
||||
from test_plan
|
||||
LEFT JOIN schedule ON schedule.resource_id = test_plan.id
|
||||
JOIN project on project.id = test_plan.project_id
|
||||
|
@ -347,6 +337,56 @@
|
|||
</where>
|
||||
order by test_plan.update_time desc
|
||||
</select>
|
||||
<select id="testPlanTestCaseCount" resultType="io.metersphere.api.dto.definition.ParamsDTO">
|
||||
select t.plan_id as id, COUNT(*) as countNum from test_plan_test_case t
|
||||
<where>
|
||||
<if test="planIds != null and planIds.size() > 0">
|
||||
and t.plan_id IN
|
||||
<foreach collection="planIds" item="id" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY t.plan_id
|
||||
</select>
|
||||
<select id="testPlanApiCaseCount" resultType="io.metersphere.api.dto.definition.ParamsDTO">
|
||||
select t.test_plan_id as id, COUNT(*) as countNum from test_plan_api_case t
|
||||
inner join api_test_case c on t.api_case_id = c.id
|
||||
inner join api_definition a on c.api_definition_id = a.id
|
||||
<where>
|
||||
<if test="planIds != null and planIds.size() > 0">
|
||||
and t.test_plan_id IN
|
||||
<foreach collection="planIds" item="id" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY t.test_plan_id
|
||||
</select>
|
||||
<select id="testPlanApiScenarioCount" resultType="io.metersphere.api.dto.definition.ParamsDTO">
|
||||
select t.test_plan_id as id , COUNT(*) as countNum from test_plan_api_scenario t
|
||||
<where>
|
||||
<if test="planIds != null and planIds.size() > 0">
|
||||
and t.test_plan_id IN
|
||||
<foreach collection="planIds" item="id" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY t.test_plan_id
|
||||
</select>
|
||||
<select id="testPlanLoadCaseCount" resultType="io.metersphere.api.dto.definition.ParamsDTO">
|
||||
select t.test_plan_id as id,COUNT(*) as countNum from test_plan_load_case t
|
||||
<where>
|
||||
<if test="planIds != null and planIds.size() > 0">
|
||||
and t.test_plan_id IN
|
||||
<foreach collection="planIds" item="id" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY t.test_plan_id
|
||||
</select>
|
||||
<update id="updateActualEndTimeIsNullById">
|
||||
update test_plan
|
||||
set actual_end_time = null
|
||||
|
|
|
@ -565,8 +565,7 @@ public class ProjectService {
|
|||
}
|
||||
|
||||
|
||||
public boolean isThirdPartTemplate(String projectId) {
|
||||
Project project = getProjectById(projectId);
|
||||
public boolean isThirdPartTemplate(Project project) {
|
||||
if (project.getThirdPartTemplate() != null && project.getThirdPartTemplate()
|
||||
&& project.getPlatform().equals(IssuesManagePlatform.Jira.name())) {
|
||||
return true;
|
||||
|
|
|
@ -81,7 +81,6 @@ public class ScheduleService {
|
|||
}
|
||||
|
||||
public Schedule getScheduleByResource(String resourceId, String group) {
|
||||
|
||||
ScheduleExample example = new ScheduleExample();
|
||||
example.createCriteria().andResourceIdEqualTo(resourceId).andGroupEqualTo(group);
|
||||
List<Schedule> schedules = scheduleMapper.selectByExample(example);
|
||||
|
@ -91,6 +90,16 @@ public class ScheduleService {
|
|||
return null;
|
||||
}
|
||||
|
||||
public List<Schedule> getScheduleByResourceIds(List<String>resourceIds, String group) {
|
||||
ScheduleExample example = new ScheduleExample();
|
||||
example.createCriteria().andResourceIdIn(resourceIds).andGroupEqualTo(group);
|
||||
List<Schedule> schedules = scheduleMapper.selectByExample(example);
|
||||
if (schedules.size() > 0) {
|
||||
return schedules;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int deleteByResourceId(String resourceId, String group) {
|
||||
ScheduleExample scheduleExample = new ScheduleExample();
|
||||
scheduleExample.createCriteria().andResourceIdEqualTo(resourceId);
|
||||
|
|
|
@ -43,6 +43,13 @@ public class IssuesController {
|
|||
return PageUtils.setPageInfo(page, issuesService.list(request));
|
||||
}
|
||||
|
||||
@PostMapping("/dashboard/list/{goPage}/{pageSize}")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ)
|
||||
public Pager<List<IssuesDao>> listByWorkspaceId(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody IssuesRequest request) {
|
||||
Page<List<Issues>> page = PageHelper.startPage(goPage, pageSize, true);
|
||||
return PageUtils.setPageInfo(page, issuesService.listByWorkspaceId(request));
|
||||
}
|
||||
|
||||
@PostMapping("/list/relate/{goPage}/{pageSize}")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ)
|
||||
public Pager<List<IssuesDao>> relateList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody IssuesRequest request) {
|
||||
|
|
|
@ -62,6 +62,13 @@ public class TestPlanController {
|
|||
return PageUtils.setPageInfo(page, testPlanService.listTestPlan(request));
|
||||
}
|
||||
|
||||
@PostMapping("/dashboard/list/{goPage}/{pageSize}")
|
||||
@RequiresPermissions("PROJECT_TRACK_PLAN:READ")
|
||||
public Pager<List<TestPlanDTOWithMetric>> listByWorkspaceId(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestPlanRequest request) {
|
||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||
return PageUtils.setPageInfo(page, testPlanService.listByWorkspaceId(request));
|
||||
}
|
||||
|
||||
/*jenkins测试计划*/
|
||||
@GetMapping("/list/all/{projectId}/{workspaceId}")
|
||||
public List<TestPlanDTOWithMetric> listByProjectId(@PathVariable String projectId, @PathVariable String workspaceId) {
|
||||
|
|
|
@ -70,8 +70,6 @@ public class IssuesService {
|
|||
@Resource
|
||||
private IssueTemplateService issueTemplateService;
|
||||
@Resource
|
||||
private TestCaseMapper testCaseMapper;
|
||||
@Resource
|
||||
private TestCaseIssueService testCaseIssueService;
|
||||
@Resource
|
||||
private TestPlanTestCaseService testPlanTestCaseService;
|
||||
|
@ -110,7 +108,6 @@ public class IssuesService {
|
|||
platformList.forEach(platform -> {
|
||||
platform.updateIssue(issuesRequest);
|
||||
});
|
||||
//saveFollows(issuesRequest.getId(), issuesRequest.getFollows());
|
||||
// todo 缺陷更新事件?
|
||||
}
|
||||
|
||||
|
@ -165,7 +162,22 @@ public class IssuesService {
|
|||
}
|
||||
|
||||
public IssuesWithBLOBs getIssue(String id) {
|
||||
return issuesMapper.selectByPrimaryKey(id);
|
||||
IssuesDao issuesWithBLOBs = extIssuesMapper.selectByPrimaryKey(id);
|
||||
IssuesRequest issuesRequest = new IssuesRequest();
|
||||
Project project = projectService.getProjectById(issuesWithBLOBs.getProjectId());
|
||||
issuesRequest.setWorkspaceId(project.getWorkspaceId());
|
||||
issuesRequest.setProjectId(issuesWithBLOBs.getProjectId());
|
||||
issuesRequest.setUserId(issuesWithBLOBs.getCreator());
|
||||
if (StringUtils.equals(issuesWithBLOBs.getPlatform(),IssuesManagePlatform.Tapd.name() )) {
|
||||
TapdPlatform tapdPlatform = (TapdPlatform) IssueFactory.createPlatform(IssuesManagePlatform.Tapd.name(), issuesRequest);
|
||||
List<String> tapdUsers = tapdPlatform.getTapdUsers(issuesWithBLOBs.getProjectId(), issuesWithBLOBs.getPlatformId());
|
||||
issuesWithBLOBs.setTapdUsers(tapdUsers);
|
||||
}
|
||||
if (StringUtils.equals(issuesWithBLOBs.getPlatform(), IssuesManagePlatform.Zentao.name())) {
|
||||
ZentaoPlatform zentaoPlatform = (ZentaoPlatform) IssueFactory.createPlatform(IssuesManagePlatform.Zentao.name(), issuesRequest);
|
||||
zentaoPlatform.getZentaoAssignedAndBuilds(issuesWithBLOBs);
|
||||
}
|
||||
return issuesWithBLOBs;
|
||||
}
|
||||
|
||||
public String getPlatformsByCaseId(String caseId) {
|
||||
|
@ -333,58 +345,73 @@ public class IssuesService {
|
|||
request.setOrders(ServiceUtils.getDefaultOrderByField(request.getOrders(), "create_time"));
|
||||
List<IssuesDao> issues = extIssuesMapper.getIssues(request);
|
||||
|
||||
List<String> ids = issues.stream()
|
||||
.map(IssuesDao::getCreator)
|
||||
.collect(Collectors.toList());
|
||||
Map<String, User> userMap = ServiceUtils.getUserMap(ids);
|
||||
List<String> resourceIds = issues.stream()
|
||||
.map(IssuesDao::getResourceId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<TestPlan> testPlans = testPlanService.getTestPlanByIds(resourceIds);
|
||||
Map<String, String> planMap = testPlans.stream()
|
||||
.collect(Collectors.toMap(TestPlan::getId, TestPlan::getName));
|
||||
Map<String, Set<String>> caseSetMap = getCaseSetMap(issues);
|
||||
Map<String, User> userMap = getUserMap(issues);
|
||||
Map<String, String> planMap = getPlanMap(issues);
|
||||
|
||||
issues.forEach(item -> {
|
||||
User createUser = userMap.get(item.getCreator());
|
||||
if (createUser != null) {
|
||||
item.setCreatorName(createUser.getName());
|
||||
}
|
||||
if (planMap.get(item.getResourceId()) != null) {
|
||||
item.setResourceName(planMap.get(item.getResourceId()));
|
||||
String resourceName = planMap.get(item.getResourceId());
|
||||
if (StringUtils.isNotBlank(resourceName)) {
|
||||
item.setResourceName(resourceName);
|
||||
}
|
||||
|
||||
TestCaseIssuesExample example = new TestCaseIssuesExample();
|
||||
example.createCriteria().andIssuesIdEqualTo(item.getId());
|
||||
List<TestCaseIssues> testCaseIssues = testCaseIssuesMapper.selectByExample(example);
|
||||
Set<String> caseIdSet = new HashSet<>();
|
||||
testCaseIssues.forEach(i -> {
|
||||
if (i.getRefType().equals(IssueRefType.PLAN_FUNCTIONAL.name())) {
|
||||
caseIdSet.add(i.getRefId());
|
||||
} else {
|
||||
caseIdSet.add(i.getResourceId());
|
||||
}
|
||||
});
|
||||
Set<String> caseIdSet = caseSetMap.get(item.getId());
|
||||
if(caseIdSet==null){
|
||||
caseIdSet = new HashSet<>();
|
||||
}
|
||||
item.setCaseIds(new ArrayList<>(caseIdSet));
|
||||
item.setCaseCount(caseIdSet.size());
|
||||
|
||||
try {
|
||||
if (StringUtils.equals(item.getPlatform(), IssuesManagePlatform.Tapd.name())) {
|
||||
TapdPlatform platform = (TapdPlatform) IssueFactory.createPlatform(item.getPlatform(), request);
|
||||
List<String> tapdUsers = platform.getTapdUsers(item.getProjectId(), item.getPlatformId());
|
||||
item.setTapdUsers(tapdUsers);
|
||||
}
|
||||
if (StringUtils.equals(item.getPlatform(), IssuesManagePlatform.Zentao.name())) {
|
||||
ZentaoPlatform platform = (ZentaoPlatform) IssueFactory.createPlatform(item.getPlatform(), request);
|
||||
platform.getZentaoAssignedAndBuilds(item);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
}
|
||||
});
|
||||
return issues;
|
||||
}
|
||||
|
||||
private Map<String, String> getPlanMap(List<IssuesDao> issues) {
|
||||
List<String> resourceIds = issues.stream().map(IssuesDao::getResourceId)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<TestPlan> testPlans = testPlanService.getTestPlanByIds(resourceIds);
|
||||
Map<String, String> planMap = new HashMap<>();
|
||||
if(testPlans!=null){
|
||||
planMap = testPlans.stream()
|
||||
.collect(Collectors.toMap(TestPlan::getId, TestPlan::getName));
|
||||
}
|
||||
return planMap;
|
||||
}
|
||||
|
||||
private Map<String, User> getUserMap(List<IssuesDao> issues) {
|
||||
List<String> userIds = issues.stream()
|
||||
.map(IssuesDao::getCreator)
|
||||
.collect(Collectors.toList());
|
||||
return ServiceUtils.getUserMap(userIds);
|
||||
}
|
||||
|
||||
private Map<String, Set<String>> getCaseSetMap(List<IssuesDao> issues) {
|
||||
List<String> ids = issues.stream().map(Issues::getId).collect(Collectors.toList());
|
||||
Map<String,Set<String>>map = new HashMap<>();
|
||||
TestCaseIssuesExample example = new TestCaseIssuesExample();
|
||||
example.createCriteria().andIssuesIdIn(ids);
|
||||
List<TestCaseIssues> testCaseIssues = testCaseIssuesMapper.selectByExample(example);
|
||||
testCaseIssues.forEach(i -> {
|
||||
Set<String> caseIdSet = new HashSet<>();
|
||||
if (i.getRefType().equals(IssueRefType.PLAN_FUNCTIONAL.name())) {
|
||||
caseIdSet.add(i.getRefId());
|
||||
} else {
|
||||
caseIdSet.add(i.getResourceId());
|
||||
}
|
||||
if(map.get(i.getId())!=null){
|
||||
map.get(i.getId()).addAll(caseIdSet);
|
||||
}else{
|
||||
map.put(i.getId(),caseIdSet);
|
||||
}
|
||||
});
|
||||
return map;
|
||||
}
|
||||
|
||||
public Map<String, List<IssuesDao>> getIssueMap(List<IssuesDao> issues) {
|
||||
Map<String, List<IssuesDao>> issueMap = new HashMap<>();
|
||||
issues.forEach(item -> {
|
||||
|
@ -461,7 +488,7 @@ public class IssuesService {
|
|||
IssuesRequest issuesRequest = new IssuesRequest();
|
||||
issuesRequest.setProjectId(projectId);
|
||||
issuesRequest.setWorkspaceId(project.getWorkspaceId());
|
||||
if (!projectService.isThirdPartTemplate(projectId)) {
|
||||
if (!projectService.isThirdPartTemplate(project)) {
|
||||
String defaultCustomFields = getDefaultCustomFields(projectId);
|
||||
issuesRequest.setDefaultCustomFields(defaultCustomFields);
|
||||
}
|
||||
|
@ -712,4 +739,9 @@ public class IssuesService {
|
|||
AbstractIssuePlatform platform = IssueFactory.createPlatform(project.getPlatform(), issueRequest);
|
||||
return platform.getDemandList(projectId);
|
||||
}
|
||||
|
||||
public List<IssuesDao> listByWorkspaceId(IssuesRequest request) {
|
||||
request.setOrders(ServiceUtils.getDefaultOrderByField(request.getOrders(), "create_time"));
|
||||
return extIssuesMapper.getIssues(request);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import io.metersphere.api.dto.automation.*;
|
|||
import io.metersphere.api.dto.datacount.request.ScheduleInfoRequest;
|
||||
import io.metersphere.api.dto.definition.ApiTestCaseRequest;
|
||||
import io.metersphere.api.dto.definition.BatchRunDefinitionRequest;
|
||||
import io.metersphere.api.dto.definition.ParamsDTO;
|
||||
import io.metersphere.api.dto.definition.TestPlanApiCaseDTO;
|
||||
import io.metersphere.api.service.ApiAutomationService;
|
||||
import io.metersphere.api.service.ApiDefinitionService;
|
||||
|
@ -100,8 +101,6 @@ public class TestPlanService {
|
|||
@Resource
|
||||
TestPlanTestCaseMapper testPlanTestCaseMapper;
|
||||
@Resource
|
||||
ExtApiScenarioMapper extApiScenarioMapper;
|
||||
@Resource
|
||||
SqlSessionFactory sqlSessionFactory;
|
||||
@Lazy
|
||||
@Resource
|
||||
|
@ -150,8 +149,6 @@ public class TestPlanService {
|
|||
@Resource
|
||||
private TestCaseTestMapper testCaseTestMapper;
|
||||
@Resource
|
||||
private ApiScenarioReportMapper apiScenarioReportMapper;
|
||||
@Resource
|
||||
private TestPlanReportMapper testPlanReportMapper;
|
||||
@Resource
|
||||
private TestPlanReportService testPlanReportService;
|
||||
|
@ -432,14 +429,22 @@ public class TestPlanService {
|
|||
request.setProjectId(request.getProjectId());
|
||||
}
|
||||
List<TestPlanDTOWithMetric> testPlans = extTestPlanMapper.list(request);
|
||||
Set<String> ids = testPlans.stream().map(TestPlan::getId).collect(Collectors.toSet());
|
||||
Map<String, ParamsDTO> planTestCaseCountMap = extTestPlanMapper.testPlanTestCaseCount(ids);
|
||||
Map<String, ParamsDTO> planApiCaseMap = extTestPlanMapper.testPlanApiCaseCount(ids);
|
||||
Map<String, ParamsDTO> planApiScenarioMap = extTestPlanMapper.testPlanApiScenarioCount(ids);
|
||||
Map<String, ParamsDTO> planLoadCaseMap = extTestPlanMapper.testPlanLoadCaseCount(ids);
|
||||
ArrayList<String> idList = new ArrayList<>(ids);
|
||||
List<Schedule> scheduleByResourceIds = scheduleService.getScheduleByResourceIds(idList, ScheduleGroup.TEST_PLAN_TEST.name());
|
||||
Map<String, Schedule> scheduleMap = scheduleByResourceIds.stream().collect(Collectors.toMap(Schedule::getResourceId, Schedule -> Schedule));
|
||||
Map<String, ParamsDTO> stringParamsDTOMap = testPlanReportMapper.reportCount(ids);
|
||||
|
||||
testPlans.forEach(item -> {
|
||||
TestPlanReportExample example = new TestPlanReportExample();
|
||||
example.createCriteria().andTestPlanIdEqualTo(item.getId());
|
||||
item.setExecutionTimes((int) testPlanReportMapper.countByExample(example));
|
||||
item.setExecutionTimes(stringParamsDTOMap.get(item.getId()) == null ? 0 : Integer.parseInt(stringParamsDTOMap.get(item.getId()).getValue() == null ? "0" : stringParamsDTOMap.get(item.getId()).getValue()));
|
||||
if (StringUtils.isNotBlank(item.getScheduleId())) {
|
||||
if (item.isScheduleOpen()) {
|
||||
item.setScheduleStatus(ScheduleStatus.OPEN.name());
|
||||
Schedule schedule = scheduleService.getScheduleByResource(item.getId(), ScheduleGroup.TEST_PLAN_TEST.name());
|
||||
Schedule schedule = scheduleMap.get(item.getId());
|
||||
item.setScheduleCorn(schedule.getValue());
|
||||
item.setScheduleExecuteTime(getNextTriggerTime(schedule.getValue()));
|
||||
} else {
|
||||
|
@ -448,6 +453,10 @@ public class TestPlanService {
|
|||
} else {
|
||||
item.setScheduleStatus(ScheduleStatus.NOTSET.name());
|
||||
}
|
||||
item.setTestPlanTestCaseCount(planTestCaseCountMap.get(item.getId()) == null ? 0 : Integer.parseInt(planTestCaseCountMap.get(item.getId()).getValue() == null ? "0" : planTestCaseCountMap.get(item.getId()).getValue()));
|
||||
item.setTestPlanApiCaseCount(planApiCaseMap.get(item.getId()) == null ? 0 : Integer.parseInt(planApiCaseMap.get(item.getId()).getValue() == null ? "0" : planApiCaseMap.get(item.getId()).getValue()));
|
||||
item.setTestPlanApiScenarioCount(planApiScenarioMap.get(item.getId()) == null? 0 : Integer.parseInt(planApiScenarioMap.get(item.getId()).getValue() == null ? "0" : planApiScenarioMap.get(item.getId()).getValue()));
|
||||
item.setTestPlanLoadCaseCount(planLoadCaseMap.get(item.getId()) == null ? 0 : Integer.parseInt(planLoadCaseMap.get(item.getId()).getValue() == null ? "0" : planLoadCaseMap.get(item.getId()).getValue()));
|
||||
});
|
||||
calcTestPlanRate(testPlans);
|
||||
return testPlans;
|
||||
|
@ -2067,4 +2076,9 @@ public class TestPlanService {
|
|||
}
|
||||
return scheduleDTO;
|
||||
}
|
||||
|
||||
public List<TestPlanDTOWithMetric> listByWorkspaceId(QueryTestPlanRequest request) {
|
||||
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
|
||||
return extTestPlanMapper.list(request);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 7ef69d7405fc95065672901d34c763bdd0ff36ed
|
||||
Subproject commit 10a8affb172fa37d51bf6451a39388be02f86a9f
|
|
@ -0,0 +1,10 @@
|
|||
ALTER TABLE `test_plan_api_case`
|
||||
ADD INDEX planIdIndex (`test_plan_id`);
|
||||
ALTER TABLE `test_plan_api_scenario`
|
||||
ADD INDEX planIdIndex (`test_plan_id`);
|
||||
ALTER TABLE `test_plan_load_case`
|
||||
ADD INDEX planIdIndex (`test_plan_id`);
|
||||
ALTER TABLE `test_case_issues`
|
||||
ADD INDEX issues_id_index (`issues_id`);
|
||||
ALTER TABLE `test_plan_report`
|
||||
ADD INDEX planIdIndex (`test_plan_id`);
|
|
@ -118,12 +118,14 @@ import CustomFiledComponent from "@/business/components/project/template/CustomF
|
|||
import TestCaseIssueList from "@/business/components/track/issue/TestCaseIssueList";
|
||||
import IssueEditDetail from "@/business/components/track/issue/IssueEditDetail";
|
||||
import {getCurrentProjectID, getCurrentUser, getCurrentUserId, getCurrentWorkspaceId,} from "@/common/js/utils";
|
||||
import {enableThirdPartTemplate, getIssuePartTemplateWithProject} from "@/network/Issue";
|
||||
import {enableThirdPartTemplate, getIssuePartTemplateWithProject, getIssuesListById} from "@/network/Issue";
|
||||
import CustomFiledFormItem from "@/business/components/common/components/form/CustomFiledFormItem";
|
||||
import MsMarkDownText from "@/business/components/track/case/components/MsMarkDownText";
|
||||
import IssueComment from "@/business/components/track/issue/IssueComment";
|
||||
import ReviewCommentItem from "@/business/components/track/review/commom/ReviewCommentItem";
|
||||
|
||||
const {getIssuesById} = require("@/network/Issue");
|
||||
|
||||
export default {
|
||||
name: "IssueEditDetail",
|
||||
components: {
|
||||
|
@ -260,6 +262,11 @@ export default {
|
|||
}
|
||||
}
|
||||
})
|
||||
getIssuesById(data.id, (data) => {
|
||||
this.form.tapdUsers = data.tapdUsers;
|
||||
this.form.zentaoBuilds = data.zentaoBuilds;
|
||||
this.form.zentaoAssigned = data.zentaoAssigned;
|
||||
});
|
||||
} else {
|
||||
this.issueId = null;
|
||||
this.form.follows = [];
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 0594c7c0861bbf0bae2d132d934d161b7dcadace
|
||||
Subproject commit 3a784a9dcc3616f263faeea49ce0141b30832f11
|
|
@ -24,6 +24,14 @@ export function getIssues(page) {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
export function getDashboardIssues(page) {
|
||||
return post('issues/dashboard/list/' + page.currentPage + '/' + page.pageSize, page.condition, (response) => {
|
||||
getPageDate(response, page);
|
||||
buildIssues(page);
|
||||
});
|
||||
}
|
||||
|
||||
export function getIssuesByCaseId(refType, caseId, page) {
|
||||
if (caseId) {
|
||||
return get('issues/get/case/' + refType + '/' + caseId, (response) => {
|
||||
|
|
Loading…
Reference in New Issue