根据接口“”@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(); } }”,修改下面代码: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()) { projectId = projectTaskEntry.getKey(); ProjectCountVO projectCountVO = new ProjectCountVO(); projectCountVO.setId(projectId); //查询项目名称 QueryAllProject projectResult = applicationServicePlatformClient.listUserProject( "token", "userId", "userEnvId", "userTenant", new ProjectCondition()); QueryAllProject queryAllProject = projectResult.ge; String projectName = queryAllProject.getBtpProjectId(); 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-14 09:35:50 浏览: 51
基于框架的Web开发-Mybatis入门.doc
根据你提供的代码,我看到你调用了 IApplicationServicePlatformClient 的 listUserProject 方法来查询项目信息,但是代码中传递的参数有些不合适,需要进行修改。
首先,你需要在 listUserProject 方法中传递正确的参数,即你需要在方法中构建一个 ProjectCondition 对象,并将查询条件设置到该对象中,然后将该对象传递给方法。
其次,你需要在调用 listUserProject 方法时,将正确的参数传递给该方法。具体来说,你需要将 "token"、"userId"、"userEnvId"、"userTenant" 分别替换为正确的值。
最后,在获取查询结果时,你需要从 ResultWrapper 对象中获取 QueryAllProject 对象,并从该对象中获取项目名称,而不是直接调用 getBtpProjectId() 方法。
下面是修改后的代码:
```
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()) {
projectId = projectTaskEntry.getKey();
ProjectCountVO projectCountVO = new ProjectCountVO();
projectCountVO.setId(projectId);
//查询项目名称
ProjectCondition queryProjectDto = new ProjectCondition();
queryProjectDto.setPageSize(1);
queryProjectDto.setCompanyId(companyId);
queryProjectDto.setDesignStatusList(designStatusList);
QueryAllProject projectResult = applicationServicePlatformClient.listUserProject(
"token", "userId", "userEnvId", "userTenant", queryProjectDto);
QueryAllProject queryAllProject = projectResult.getData().get(0);
String projectName = queryAllProject.getProjectName();
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;
}
```
阅读全文