diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/utils/ProjectVersionUtil.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/utils/ProjectVersionUtil.java index 8f96faf..4a5227b 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/utils/ProjectVersionUtil.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/utils/ProjectVersionUtil.java @@ -63,28 +63,23 @@ public class ProjectVersionUtil { } // 获取之前版本的项目 - int index = projectList.size() - 1; - ProcessProgressVo instanceDetail = null; - while (index > 0){ - index = index - 1; - Project preProject = projectList.get(index); + for (Project preProject : projectList) { // 从项目流程实例关联表中查出实例详情 - List projectInstList = projectInstService.list(Wrappers.lambdaQuery(ProjectInst.class) - .eq(ProjectInst::getProjectId, preProject.getId()) - .eq(ProjectInst::getInstType,instTypeEnum.getCode())); + List projectInstList = projectInstService + .list(Wrappers.lambdaQuery(ProjectInst.class).eq(ProjectInst::getProjectId, preProject.getId()) + .eq(ProjectInst::getInstType, instTypeEnum.getCode())); if (CollUtil.isNotEmpty(projectInstList)) { List processProgressVoList = projectInstList.stream() - .map(p -> processInstanceService.getProgressInstanceDetail(null, p.getInstCode())) - .collect(Collectors.toList()); + .map(p -> processInstanceService.getProgressInstanceDetail(null, p.getInstCode())) + .collect(Collectors.toList()); // 筛选出上个版本该类型审核流程通过的流程详情 List instanceDetailList = processProgressVoList.stream() - .filter(p -> ProcessStatusEnum.APPROVED.getDesc().equals(p.getStatus())) - .collect(Collectors.toList()); - if (CollUtil.isEmpty(instanceDetailList)){ - continue; + .filter(p -> ProcessStatusEnum.APPROVED.getDesc().equals(p.getStatus())) + .collect(Collectors.toList()); + if (CollUtil.isNotEmpty(instanceDetailList)) { + // 获取最后一个流程详情 + return instanceDetailList.get(instanceDetailList.size() - 1); } - // 获取最后一个流程详情 - return instanceDetailList.get(instanceDetailList.size() - 1); } } return null;