refactor(工作台): 调整测试计划返回数据结构以及布局返回
This commit is contained in:
parent
9dad00730c
commit
0e08171849
|
@ -26,6 +26,7 @@ public enum DashboardUserLayoutKeys {
|
|||
*/
|
||||
TEST_PLAN_COUNT,//测试计划数量统计
|
||||
PLAN_LEGACY_BUG,//计划遗留bug统计
|
||||
PROJECT_PLAN_VIEW,//测试计划概览
|
||||
/**
|
||||
* bug
|
||||
*/
|
||||
|
|
|
@ -32,5 +32,7 @@ public class LayoutDTO implements Serializable {
|
|||
private boolean selectAll;
|
||||
@Schema(description = "人员集合")
|
||||
private List<String> handleUsers;
|
||||
@Schema(description = "测试计划ID")
|
||||
private String planId;
|
||||
|
||||
}
|
||||
|
|
|
@ -30,6 +30,9 @@ public class DashboardFrontPageRequest extends DashboardBaseRequest{
|
|||
@Schema(description = "人员集合")
|
||||
private List<String> handleUsers;
|
||||
|
||||
@Schema(description = "测试计划ID")
|
||||
private String planId;
|
||||
|
||||
|
||||
public Long getToStartTime() {
|
||||
if (startTime == null && dayNumber>0) {
|
||||
|
|
|
@ -20,6 +20,9 @@ public class CascadeChildrenDTO {
|
|||
@Schema(description = "名称/标签")
|
||||
private String label;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private Long createTime;
|
||||
|
||||
@Schema(description = "关联子集")
|
||||
private List<CascadeDTO> children;
|
||||
|
||||
|
|
|
@ -473,9 +473,17 @@ public class DashboardService {
|
|||
Set<String> hasReadProjectIds = permissionModuleProjectIdMap.get(PermissionConstants.PROJECT_API_SCENARIO_READ);
|
||||
checkHasPermissionProject(layoutDTO, hasReadProjectIds);
|
||||
} else if (StringUtils.equalsIgnoreCase(layoutDTO.getKey(), DashboardUserLayoutKeys.TEST_PLAN_COUNT.toString())
|
||||
|| StringUtils.equalsIgnoreCase(layoutDTO.getKey(), DashboardUserLayoutKeys.PLAN_LEGACY_BUG.toString())) {
|
||||
|| StringUtils.equalsIgnoreCase(layoutDTO.getKey(), DashboardUserLayoutKeys.PLAN_LEGACY_BUG.toString())
|
||||
|| StringUtils.equalsIgnoreCase(layoutDTO.getKey(), DashboardUserLayoutKeys.PROJECT_PLAN_VIEW.toString())) {
|
||||
Set<String> hasReadProjectIds = permissionModuleProjectIdMap.get(PermissionConstants.TEST_PLAN_READ);
|
||||
checkHasPermissionProject(layoutDTO, hasReadProjectIds);
|
||||
if (StringUtils.equalsIgnoreCase(layoutDTO.getKey(), DashboardUserLayoutKeys.PROJECT_PLAN_VIEW.toString())) {
|
||||
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(layoutDTO.getPlanId());
|
||||
if (testPlan == null || StringUtils.equalsIgnoreCase(testPlan.getStatus(),TestPlanConstants.TEST_PLAN_STATUS_ARCHIVED)) {
|
||||
TestPlan latestPlan = extTestPlanMapper.getLatestPlan(layoutDTO.getProjectIds().getFirst());
|
||||
layoutDTO.setPlanId(latestPlan.getId());
|
||||
}
|
||||
}
|
||||
} else if (StringUtils.equalsIgnoreCase(layoutDTO.getKey(), DashboardUserLayoutKeys.BUG_COUNT.toString())
|
||||
|| StringUtils.equalsIgnoreCase(layoutDTO.getKey(), DashboardUserLayoutKeys.CREATE_BUG_BY_ME.toString())
|
||||
|| StringUtils.equalsIgnoreCase(layoutDTO.getKey(), DashboardUserLayoutKeys.HANDLE_BUG_BY_ME.toString())
|
||||
|
@ -738,25 +746,33 @@ public class DashboardService {
|
|||
private static List<NameCountDTO> getReviewList(Map<String, List<FunctionalCaseStatisticDTO>> reviewStatusMap, List<FunctionalCaseStatisticDTO> statisticListByProjectId) {
|
||||
List<NameCountDTO> reviewList = new ArrayList<>();
|
||||
List<FunctionalCaseStatisticDTO> unReviewList = reviewStatusMap.get(FunctionalCaseReviewStatus.UN_REVIEWED.toString());
|
||||
List<FunctionalCaseStatisticDTO> underReviewList = reviewStatusMap.get(FunctionalCaseReviewStatus.UNDER_REVIEWED.toString());
|
||||
List<FunctionalCaseStatisticDTO> reReviewedList = reviewStatusMap.get(FunctionalCaseReviewStatus.RE_REVIEWED.toString());
|
||||
if (CollectionUtils.isEmpty(unReviewList)) {
|
||||
unReviewList = new ArrayList<>();
|
||||
}
|
||||
if (CollectionUtils.isEmpty(underReviewList)) {
|
||||
underReviewList = new ArrayList<>();
|
||||
}
|
||||
if (CollectionUtils.isEmpty(reReviewedList)) {
|
||||
reReviewedList = new ArrayList<>();
|
||||
}
|
||||
NameCountDTO reviewRate = new NameCountDTO();
|
||||
reviewRate.setName(Translator.get("functional_case.reviewRate"));
|
||||
if (CollectionUtils.isEmpty(statisticListByProjectId)) {
|
||||
reviewRate.setCount(0);
|
||||
} else {
|
||||
BigDecimal divide = BigDecimal.valueOf(statisticListByProjectId.size() - unReviewList.size()).divide(BigDecimal.valueOf(statisticListByProjectId.size()), 2, RoundingMode.HALF_UP);
|
||||
BigDecimal divide = BigDecimal.valueOf(statisticListByProjectId.size() - unReviewList.size() - underReviewList.size() - reReviewedList.size()).divide(BigDecimal.valueOf(statisticListByProjectId.size()), 2, RoundingMode.HALF_UP);
|
||||
reviewRate.setCount(getTurnCount(divide));
|
||||
}
|
||||
reviewList.add(reviewRate);
|
||||
NameCountDTO hasReview = new NameCountDTO();
|
||||
hasReview.setName(Translator.get("functional_case.hasReview"));
|
||||
hasReview.setCount(statisticListByProjectId.size() - unReviewList.size());
|
||||
hasReview.setCount(statisticListByProjectId.size() - unReviewList.size() - underReviewList.size() - reReviewedList.size());
|
||||
reviewList.add(hasReview);
|
||||
NameCountDTO unReview = new NameCountDTO();
|
||||
unReview.setName(Translator.get("functional_case.unReview"));
|
||||
unReview.setCount(unReviewList.size());
|
||||
unReview.setCount(unReviewList.size() + underReviewList.size() + reReviewedList.size());
|
||||
reviewList.add(unReview);
|
||||
return reviewList;
|
||||
}
|
||||
|
@ -1522,14 +1538,17 @@ public class DashboardService {
|
|||
List<TestPlanAndGroupInfoDTO> groupAndPlanInfo = extTestPlanMapper.getGroupAndPlanInfo(projectId);
|
||||
TestPlanExample testPlanExample = new TestPlanExample();
|
||||
testPlanExample.createCriteria().andProjectIdEqualTo(projectId).andTypeEqualTo(TestPlanConstants.TEST_PLAN_TYPE_PLAN).andGroupIdEqualTo("NONE");
|
||||
testPlanExample.setOrderByClause(" create_time DESC ");
|
||||
List<TestPlan> testPlans = testPlanMapper.selectByExample(testPlanExample);
|
||||
Map<String, List<TestPlanAndGroupInfoDTO>> groupMap = groupAndPlanInfo.stream().collect(Collectors.groupingBy(TestPlanAndGroupInfoDTO::getGroupId));
|
||||
groupMap.forEach((t, list)->{
|
||||
Map<String, List<TestPlanAndGroupInfoDTO>> groupMap = groupAndPlanInfo.stream().sorted(Comparator.comparing(TestPlanAndGroupInfoDTO::getGroupCreateTime).reversed()).collect(Collectors.groupingBy(TestPlanAndGroupInfoDTO::getGroupId));
|
||||
groupMap.forEach((t, list) -> {
|
||||
CascadeChildrenDTO father = new CascadeChildrenDTO();
|
||||
father.setValue(t);
|
||||
father.setLabel(list.getFirst().getGroupName());
|
||||
father.setCreateTime(list.getFirst().getCreateTime());
|
||||
List<CascadeDTO> children = new ArrayList<>();
|
||||
for (TestPlanAndGroupInfoDTO testPlanAndGroupInfoDTO : list) {
|
||||
List<TestPlanAndGroupInfoDTO> sortList = list.stream().sorted(Comparator.comparing(TestPlanAndGroupInfoDTO::getCreateTime).reversed()).toList();
|
||||
for (TestPlanAndGroupInfoDTO testPlanAndGroupInfoDTO : sortList) {
|
||||
CascadeDTO cascadeChildrenDTO = new CascadeDTO();
|
||||
cascadeChildrenDTO.setValue(testPlanAndGroupInfoDTO.getId());
|
||||
cascadeChildrenDTO.setLabel(testPlanAndGroupInfoDTO.getName());
|
||||
|
@ -1542,9 +1561,10 @@ public class DashboardService {
|
|||
CascadeChildrenDTO father = new CascadeChildrenDTO();
|
||||
father.setValue(testPlan.getId());
|
||||
father.setLabel(testPlan.getName());
|
||||
father.setCreateTime(testPlan.getCreateTime());
|
||||
cascadeDTOList.add(father);
|
||||
}
|
||||
return cascadeDTOList;
|
||||
return cascadeDTOList.stream().sorted(Comparator.comparing(CascadeChildrenDTO::getCreateTime).reversed()).toList();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -260,6 +260,8 @@ public class DashboardFrontPageControllerTests extends BaseTest {
|
|||
layoutDTO.add(layoutDTO9);
|
||||
LayoutDTO layoutDTOz = getLayoutDTO(12, DashboardUserLayoutKeys.PLAN_LEGACY_BUG, "计划遗留bug统计");
|
||||
layoutDTO.add(layoutDTOz);
|
||||
LayoutDTO layoutDTOg = getLayoutDTO(17, DashboardUserLayoutKeys.PROJECT_PLAN_VIEW, "测试计划概览");
|
||||
layoutDTO.add(layoutDTOg);
|
||||
LayoutDTO layoutDTOx = getLayoutDTO(13, DashboardUserLayoutKeys.BUG_COUNT, "缺陷数量统计");
|
||||
layoutDTO.add(layoutDTOx);
|
||||
LayoutDTO layoutDTOv = getLayoutDTO(14, DashboardUserLayoutKeys.CREATE_BUG_BY_ME, "我创建的缺陷");
|
||||
|
@ -312,6 +314,7 @@ public class DashboardFrontPageControllerTests extends BaseTest {
|
|||
layoutDTOb.setProjectIds(projects);
|
||||
layoutDTOb.setHandleUsers(new ArrayList<>());
|
||||
layoutDTOb.setFullScreen(false);
|
||||
layoutDTOb.setPlanId("");
|
||||
return layoutDTOb;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,10 +11,14 @@ public class TestPlanAndGroupInfoDTO {
|
|||
private String id;
|
||||
@Schema(description = "计划名称")
|
||||
private String name;
|
||||
@Schema(description = "计划名称")
|
||||
private Long createTime;
|
||||
@Schema(description = "计划组ID")
|
||||
private String groupId;
|
||||
@Schema(description = "计划组名称")
|
||||
private String groupName;
|
||||
@Schema(description = "计划组创建时间")
|
||||
private Long groupCreateTime;
|
||||
@Schema(description = "项目ID")
|
||||
private String projectId;
|
||||
|
||||
|
|
|
@ -104,4 +104,7 @@ public interface ExtTestPlanMapper {
|
|||
* 获取项目下计划组和计划的名称
|
||||
*/
|
||||
List<TestPlanAndGroupInfoDTO> getGroupAndPlanInfo(@Param("projectId") String projectId);
|
||||
|
||||
TestPlan getLatestPlan(@Param("projectId") String projectId);
|
||||
|
||||
}
|
||||
|
|
|
@ -940,12 +940,17 @@
|
|||
</if>
|
||||
</select>
|
||||
<select id="getGroupAndPlanInfo" resultType="io.metersphere.plan.dto.TestPlanAndGroupInfoDTO">
|
||||
select son.id, son.name, son.group_id, son.project_id, father.name as groupName
|
||||
select son.id, son.name, son.group_id, son.project_id, father.name as groupName, son.create_time, father.create_time as groupCreateTime
|
||||
from test_plan son
|
||||
left join test_plan father on father.id = son.group_id
|
||||
where son.type = 'TEST_PLAN'
|
||||
where son.type = 'TEST_PLAN' and son.status='NOT_ARCHIVED'
|
||||
and father.type = 'GROUP' and son.project_id = #{projectId};
|
||||
</select>
|
||||
<select id="getLatestPlan" resultType="io.metersphere.plan.domain.TestPlan">
|
||||
select id, name, group_id
|
||||
from test_plan
|
||||
where type = 'TEST_PLAN' and status='NOT_ARCHIVED' and project_id = #{projectId} order by create_time desc limit 1;
|
||||
</select>
|
||||
|
||||
|
||||
<sql id="queryMyFollowGroupByTableRequest">
|
||||
|
|
Loading…
Reference in New Issue