根据接口“”@FeignClient(name = "UserUgsApi", url = "${newbim.login-domain}") public interface IApplicationServicePlatformClient {@PostMapping("/ums/v1/feign/omp/project/search") ResultWrapper<QueryAllProject> listUserProject(@RequestHeader("BSP_TOKEN") String bspToken, @RequestHeader("BSP_USER_ID") String bspUserId, @RequestHeader("BSP_USER_ENV_ID") String bspUserEnvId, @RequestHeader("BSP_USER_TENANT") String bspUserTenant, @RequestBody ProjectCondition queryProjectDto);和代码“@Component @Slf4j public class ApplicationServicePlatformClientProxy { @Autowired private IApplicationServicePlatformClient applicationServicePlatformClient; public QueryAllProject listUserProject(String appId, String companyId, String designStatusList, String pageSize, ProjectCondition userId) { ResultWrapper<QueryAllProject> result = null; return result.getData(); } }”,修改下面代码:@Override public List<ProjectCountVO> projectCount(String beginTime, String endTime, Integer forceType, String projectId) { List<TaskTask> taskTaskList = this.listStatisticsTask(beginTime, endTime, forceType, projectId); if(CollectionUtil.isEmpty(taskTaskList)){ return Collections.emptyList(); } List<ProjectCountVO> result = new ArrayList<>(); Map<String, List<TaskTask>> projectTaskMap = taskTaskList.stream().collect(Collectors.groupingBy(TaskTask::getProjectId)); for (Map.Entry<String, List<TaskTask>> projectTaskEntry : projectTaskMap.entrySet()) { String currentProjectId = projectTaskEntry.getKey(); ProjectCountVO projectCountVO = new ProjectCountVO(); projectCountVO.setId(currentProjectId); // 查询项目名称 QueryAllProject queryAllProject = applicationServicePlatformClient.listUserProject(); projectCountVO.setName(projectName); List<TaskTask> taskList = projectTaskEntry.getValue(); projectCountVO.setTaskCount(taskList.size()); Integer problemCount = CollectionUtil.isEmpty(taskList) ? 0 : taskList.stream().collect(Collectors.summingInt(task-> Optional.ofNullable(task.getProblemNum()).orElse(0))); projectCountVO.setProblemCount(problemCount); result.add(projectCountVO); } return result; }
时间: 2023-12-10 16:40:36 浏览: 77
根据你提供的代码,需要将方法projectCount中的代码进行修改。其中,需要调用IApplicationServicePlatformClient接口中的listUserProject方法,获取所有项目信息。代码修改如下:
```
@Override
public List<ProjectCountVO> projectCount(String beginTime, String endTime, Integer forceType, String projectId) {
List<TaskTask> taskTaskList = this.listStatisticsTask(beginTime, endTime, forceType, projectId);
if(CollectionUtil.isEmpty(taskTaskList)){
return Collections.emptyList();
}
List<ProjectCountVO> result = new ArrayList<>();
Map<String, List<TaskTask>> projectTaskMap = taskTaskList.stream().collect(Collectors.groupingBy(TaskTask::getProjectId));
for (Map.Entry<String, List<TaskTask>> projectTaskEntry : projectTaskMap.entrySet()) {
String currentProjectId = projectTaskEntry.getKey();
ProjectCountVO projectCountVO = new ProjectCountVO();
projectCountVO.setId(currentProjectId);
// 查询项目名称
ResultWrapper<QueryAllProject> resultWrapper = applicationServicePlatformClient.listUserProject("BSP_TOKEN", "BSP_USER_ID", "BSP_USER_ENV_ID", "BSP_USER_TENANT", new ProjectCondition());
if(resultWrapper.isSuccess()){
QueryAllProject queryAllProject = resultWrapper.getData();
List<ProjectVO> projectList = queryAllProject.getProjectList();
for(ProjectVO project : projectList){
if(project.getId().equals(currentProjectId)){
projectCountVO.setName(project.getName());
break;
}
}
}
List<TaskTask> taskList = projectTaskEntry.getValue();
projectCountVO.setTaskCount(taskList.size());
Integer problemCount = CollectionUtil.isEmpty(taskList) ? 0 : taskList.stream().collect(Collectors.summingInt(task-> Optional.ofNullable(task.getProblemNum()).orElse(0)));
projectCountVO.setProblemCount(problemCount);
result.add(projectCountVO);
}
return result;
}
```
需要调用listUserProject方法时,需要传入4个请求头参数,分别是BSP_TOKEN、BSP_USER_ID、BSP_USER_ENV_ID和BSP_USER_TENANT。另外,还需要传入一个空的ProjectCondition对象作为请求体参数。调用listUserProject方法后,需要判断请求是否成功,如果成功,则从返回结果中获取项目列表,遍历项目列表,查找当前项目的名称,并将名称设置到对应的ProjectCountVO对象中。最后将所有的ProjectCountVO对象添加到结果集中返回。
阅读全文