fix(工作台): 工作台缺陷状态统计有误

--bug=1016061 --user=陈建星 【工作台】-我创建的缺陷-github#17150展示状态只有【新建】,【测试跟踪】-【缺陷管理】处的【已解决】和【已关闭】状态也被当做【新建】状态被展示 https://www.tapd.cn/55049933/s/1233613
This commit is contained in:
chenjianxing 2022-08-25 10:52:50 +08:00 committed by f2c-ci-robot[bot]
parent 1d68b3b220
commit 3db9e9374c
7 changed files with 57 additions and 14 deletions

View File

@ -17,7 +17,6 @@ public class IssuesDao extends IssuesWithBLOBs {
private long caseCount; private long caseCount;
private List<String> caseIds; private List<String> caseIds;
private String caseId; private String caseId;
private int totalIssueCount;
private List<String> tapdUsers; private List<String> tapdUsers;
private List<String>zentaoBuilds; private List<String>zentaoBuilds;
private String zentaoAssigned; private String zentaoAssigned;

View File

@ -0,0 +1,12 @@
package io.metersphere.base.domain;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class IssuesStatusCountDao {
private int count;
private String statusValue;
private String platform;
}

View File

@ -2,9 +2,11 @@ package io.metersphere.base.mapper.ext;
import io.metersphere.base.domain.Issues; import io.metersphere.base.domain.Issues;
import io.metersphere.base.domain.IssuesDao; import io.metersphere.base.domain.IssuesDao;
import io.metersphere.base.domain.IssuesStatusCountDao;
import io.metersphere.dto.CustomFieldItemDTO; import io.metersphere.dto.CustomFieldItemDTO;
import io.metersphere.track.dto.CustomFieldResourceCompatibleDTO; import io.metersphere.track.dto.CustomFieldResourceCompatibleDTO;
import io.metersphere.track.dto.PlanReportIssueDTO; import io.metersphere.track.dto.PlanReportIssueDTO;
import io.metersphere.track.request.testcase.IssuesCountRequest;
import io.metersphere.track.request.testcase.IssuesRequest; import io.metersphere.track.request.testcase.IssuesRequest;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -26,7 +28,7 @@ public interface ExtIssuesMapper {
List<PlanReportIssueDTO> selectForPlanReport(String planId); List<PlanReportIssueDTO> selectForPlanReport(String planId);
List<IssuesDao> getCountByStatus(@Param("request") IssuesRequest issuesRequest); List<IssuesStatusCountDao> getCountByStatus(@Param("request") IssuesCountRequest issuesRequest);
List<String> selectIdNotInUuIds(@Param("projectId") String projectId, @Param("platform") String platform, @Param("platformIds") List<String> platformIds); List<String> selectIdNotInUuIds(@Param("projectId") String projectId, @Param("platform") String platform, @Param("platformIds") List<String> platformIds);

View File

@ -83,11 +83,22 @@
<select id="getNextNum" resultType="io.metersphere.base.domain.Issues"> <select id="getNextNum" resultType="io.metersphere.base.domain.Issues">
SELECT * FROM issues WHERE issues.project_id = #{projectId} ORDER BY num DESC LIMIT 1; SELECT * FROM issues WHERE issues.project_id = #{projectId} ORDER BY num DESC LIMIT 1;
</select> </select>
<select id="getCountByStatus" resultType="io.metersphere.base.domain.IssuesDao"> <select id="getCountByStatus" resultType="io.metersphere.base.domain.IssuesStatusCountDao">
select count(issues.id) as totalIssueCount, ifnull(issues.status,issues.platform_status) as status from issues select count(1) as `count`, if(i.platform = 'Local', cfi.value, i.platform_status) as statusValue, i.platform
left join project on issues.project_id = project.id from issues i
<include refid="queryWhereCondition"/> inner join project p
group by status; on i.project_id = p.id and p.workspace_id = #{request.workspaceId}
left join custom_field_issues cfi
on i.id = cfi.resource_id and field_id in (
select cf.id
from custom_field cf
left join project pr
on cf.project_id = pr.id
where cf.scene = 'ISSUE' and cf.name = '状态'
and (pr.workspace_id = #{request.workspaceId} or global = true)
)
where i.creator = #{request.creator}
group by statusValue;
</select> </select>
<select id="getRelateIssues" resultType="io.metersphere.base.domain.IssuesDao"> <select id="getRelateIssues" resultType="io.metersphere.base.domain.IssuesDao">
select issues.id, issues.num, issues.title, issues.project_id, issues.create_time, issues.update_time, select issues.id, issues.num, issues.title, issues.project_id, issues.create_time, issues.update_time,

View File

@ -4,6 +4,7 @@ import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.Issues; import io.metersphere.base.domain.Issues;
import io.metersphere.base.domain.IssuesDao; import io.metersphere.base.domain.IssuesDao;
import io.metersphere.base.domain.IssuesStatusCountDao;
import io.metersphere.base.domain.IssuesWithBLOBs; import io.metersphere.base.domain.IssuesWithBLOBs;
import io.metersphere.commons.constants.NoticeConstants; import io.metersphere.commons.constants.NoticeConstants;
import io.metersphere.commons.constants.OperLogConstants; import io.metersphere.commons.constants.OperLogConstants;
@ -14,7 +15,6 @@ import io.metersphere.commons.utils.Pager;
import io.metersphere.dto.IssueTemplateDao; import io.metersphere.dto.IssueTemplateDao;
import io.metersphere.log.annotation.MsAuditLog; import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.notice.annotation.SendNotice; import io.metersphere.notice.annotation.SendNotice;
import io.metersphere.service.FileService;
import io.metersphere.track.dto.DemandDTO; import io.metersphere.track.dto.DemandDTO;
import io.metersphere.track.dto.PlatformStatusDTO; import io.metersphere.track.dto.PlatformStatusDTO;
import io.metersphere.track.issue.domain.PlatformUser; import io.metersphere.track.issue.domain.PlatformUser;
@ -23,6 +23,7 @@ import io.metersphere.track.issue.domain.zentao.ZentaoBuild;
import io.metersphere.track.request.issues.JiraIssueTypeRequest; import io.metersphere.track.request.issues.JiraIssueTypeRequest;
import io.metersphere.track.request.issues.PlatformIssueTypeRequest; import io.metersphere.track.request.issues.PlatformIssueTypeRequest;
import io.metersphere.track.request.testcase.AuthUserIssueRequest; import io.metersphere.track.request.testcase.AuthUserIssueRequest;
import io.metersphere.track.request.testcase.IssuesCountRequest;
import io.metersphere.track.request.testcase.IssuesRequest; import io.metersphere.track.request.testcase.IssuesRequest;
import io.metersphere.track.request.testcase.IssuesUpdateRequest; import io.metersphere.track.request.testcase.IssuesUpdateRequest;
import io.metersphere.track.service.IssuesService; import io.metersphere.track.service.IssuesService;
@ -39,8 +40,6 @@ public class IssuesController {
@Resource @Resource
private IssuesService issuesService; private IssuesService issuesService;
@Resource
private FileService fileService;
@PostMapping("/list/{goPage}/{pageSize}") @PostMapping("/list/{goPage}/{pageSize}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ) @RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ)
@ -155,7 +154,7 @@ public class IssuesController {
} }
@PostMapping("/status/count") @PostMapping("/status/count")
public List<IssuesDao> getCountByStatus(@RequestBody IssuesRequest request) { public List<IssuesStatusCountDao> getCountByStatus(@RequestBody IssuesCountRequest request) {
return issuesService.getCountByStatus(request); return issuesService.getCountByStatus(request);
} }

View File

@ -0,0 +1,11 @@
package io.metersphere.track.request.testcase;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class IssuesCountRequest {
private String workspaceId;
private String creator;
}

View File

@ -30,6 +30,7 @@ import io.metersphere.track.request.attachment.AttachmentRequest;
import io.metersphere.track.request.issues.JiraIssueTypeRequest; import io.metersphere.track.request.issues.JiraIssueTypeRequest;
import io.metersphere.track.request.issues.PlatformIssueTypeRequest; import io.metersphere.track.request.issues.PlatformIssueTypeRequest;
import io.metersphere.track.request.testcase.AuthUserIssueRequest; import io.metersphere.track.request.testcase.AuthUserIssueRequest;
import io.metersphere.track.request.testcase.IssuesCountRequest;
import io.metersphere.track.request.testcase.IssuesRequest; import io.metersphere.track.request.testcase.IssuesRequest;
import io.metersphere.track.request.testcase.IssuesUpdateRequest; import io.metersphere.track.request.testcase.IssuesUpdateRequest;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
@ -770,9 +771,17 @@ public class IssuesService {
} }
} }
public List<IssuesDao> getCountByStatus(IssuesRequest request) { public List<IssuesStatusCountDao> getCountByStatus(IssuesCountRequest request) {
return extIssuesMapper.getCountByStatus(request); request.setCreator(SessionUtils.getUserId());
List<IssuesStatusCountDao> countByStatus = extIssuesMapper.getCountByStatus(request);
countByStatus.forEach(item -> {
if (StringUtils.isBlank(item.getStatusValue())) {
item.setStatusValue(IssuesStatus.NEW.toString());
} else {
item.setStatusValue(item.getStatusValue().replace("\"", ""));
}
});
return countByStatus;
} }
public List<String> getFollows(String issueId) { public List<String> getFollows(String issueId) {