fix(测试跟踪): 我的工作台接口Api, 接口Case统计有误

--bug=1025728 --user=宋昌昌 【工作台】我的仪表盘-我的待办-接口和接口用例统计和进入我的待办-各项目接口和接口用例总和不一致 https://www.tapd.cn/55049933/s/1367776
This commit is contained in:
song-cc-rock 2023-04-27 19:01:20 +08:00 committed by fit2-zhao
parent 0ab17da957
commit 9acdca8c57
2 changed files with 14 additions and 2 deletions

View File

@ -552,6 +552,7 @@
</foreach>
and ad.status in ('Prepare', 'Underway')
and ad.user_id = #{userId,jdbcType=VARCHAR}
and ad.latest = 1
</select>

View File

@ -4,11 +4,13 @@ package io.metersphere.workstation.service;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.metersphere.base.domain.Project;
import io.metersphere.base.domain.ProjectApplication;
import io.metersphere.base.mapper.ext.*;
import io.metersphere.commons.constants.ExecuteResult;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.request.ApiSyncCaseRequest;
import io.metersphere.request.ProjectRequest;
import io.metersphere.request.api.ApiScenarioRequest;
import io.metersphere.request.track.QueryTestCaseRequest;
import io.metersphere.request.track.QueryTestPlanRequest;
@ -27,6 +29,8 @@ import java.time.temporal.TemporalAccessor;
import java.time.temporal.TemporalField;
import java.time.temporal.WeekFields;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static io.metersphere.workstation.util.ShareUtil.getTimeMills;
@ -58,6 +62,9 @@ public class WorkstationService {
@Resource
private ExtProjectMapper extProjectMapper;
@Resource
private BaseProjectMapper baseProjectMapper;
@Resource
private ExtProjectApplicationMapper extProjectApplicationMapper;
@ -152,10 +159,14 @@ public class WorkstationService {
public Map<String, Integer> getUpcomingTotalCount(String workstationId){
String userId = SessionUtils.getUserId();
List<String> projectIds = extProjectMapper.getProjectIdByWorkspaceId(workstationId);
if (CollectionUtils.isEmpty(projectIds)) {
ProjectRequest projectRequest = new ProjectRequest();
projectRequest.setWorkspaceId(workstationId);
projectRequest.setUserId(userId);
List<Project> projects = baseProjectMapper.getUserProject(projectRequest);
if (CollectionUtils.isEmpty(projects)) {
return null;
}
List<String> projectIds = projects.stream().map(Project::getId).toList();
int caseUpcomingCount = extTestCaseMapper.getCountUpcoming(projectIds, userId);
int planUpcomingCount = extTestPlanMapper.getCountUpcoming(projectIds, userId);
int reviewUpcomingCount = extTestCaseReviewMapper.getCountUpcoming(projectIds, userId);