From 678672559e8f0e03482cb485c401d2e4ac1d5700 Mon Sep 17 00:00:00 2001 From: CMM <2198256324@qq.com> Date: Mon, 21 Aug 2023 18:41:19 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=A9=E6=95=88=E8=AF=84=E4=BB=B7-=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=BE=85=E6=B7=BB=E5=8A=A0=E5=BA=94=E7=94=A8=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PerformanceAppraisalPlanController.java | 7 ++ .../manage/PerformanceAppraisalPlanManage.java | 80 +++++++++++++++++++++- .../pmapi/projectlib/helper/ProjectHelper.java | 2 + .../pmapi/projectlib/model/req/ProjectListReq.java | 3 + 4 files changed, 89 insertions(+), 3 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/PerformanceAppraisalPlanController.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/PerformanceAppraisalPlanController.java index 094c921..d204c5f 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/PerformanceAppraisalPlanController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/PerformanceAppraisalPlanController.java @@ -12,6 +12,7 @@ import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalApplication import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalProjectGroupVO; import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalProjectVO; import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalVO; +import com.ningdatech.pmapi.projectlib.model.vo.ProjectApplicationVO; import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -60,6 +61,12 @@ public class PerformanceAppraisalPlanController { return performanceAppraisalPlanManage.finalProjectList(req); } + @GetMapping("/final-application-list") + @ApiOperation("评价计划-终验应用列表") + public PageVo finalApplicationList(PerformanceAppraisalListReq req) { + return performanceAppraisalPlanManage.finalApplicationList(req); + } + @PostMapping("/addProject") @ApiOperation("评价计划-添加待评价项目") @WebLog("评价计划-添加待评价项目") diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/PerformanceAppraisalPlanManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/PerformanceAppraisalPlanManage.java index 21c7b21..3b2c0e1 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/PerformanceAppraisalPlanManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/PerformanceAppraisalPlanManage.java @@ -9,7 +9,10 @@ import com.ningdatech.pmapi.performance.service.*; import com.ningdatech.pmapi.projectlib.helper.ProjectHelper; import com.ningdatech.pmapi.projectlib.manage.ProjectLibManage; import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; +import com.ningdatech.pmapi.projectlib.model.vo.ProjectApplicationVO; import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO; +import com.wflow.workflow.bean.vo.ProcessTaskVo; +import org.checkerframework.checker.nullness.qual.Nullable; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; @@ -85,6 +88,7 @@ public class PerformanceAppraisalPlanManage { private final IPerformanceAppraisalScoreInfoService performanceAppraisalScoreInfoService; private final IPerformanceAppraisalAppScoreInfoService performanceAppraisalAppScoreInfoService; private final ProjectLibManage projectLibManage; + private final IProjectApplicationService projectApplicationService; /** * 绩效列表 @@ -1055,8 +1059,8 @@ public class PerformanceAppraisalPlanManage { param.setBuildOrgName(buildOrgName); param.setProjectType(projectType); param.setProjectYear(projectYear); + param.setRegionCode(user.getRegionCode()); param.setStatus(ProjectStatusEnum.ACCEPTED.getCode()); - PageVo resList = projectLibManage.projectLibListWithPermission(param, user); // 获取已添加到评价计划中的项目 List projectCodes = performanceAppraisalProjectService.list().stream() .map(PerformanceAppraisalProject::getProjectCode).collect(Collectors.toList()); @@ -1070,7 +1074,77 @@ public class PerformanceAppraisalPlanManage { } } // 过滤掉已经添加到评价计划中的项目(如果是编辑评价计划,保留当前计划已添加的项目) - List result = resList.getRecords().stream().filter(r -> !projectCodes.contains(r.getProjectCode())).collect(Collectors.toList()); - return PageVo.of(result,result.size()); + param.setProjectCodes(projectCodes); + return projectLibManage.projectLibListWithPermission(param, user); + } + + public PageVo finalApplicationList(PerformanceAppraisalListReq req) { + UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); + String regionCode = user.getRegionCode(); + Long appraisalId = req.getAppraisalId(); + + Page page = req.page(); + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(ProjectApplication.class) + .like(StringUtils.isNotBlank(req.getBuildOrgName()), ProjectApplication::getBuildOrgName, req.getBuildOrgName()); + + if (StringUtils.isNotBlank(req.getApplicationName())) { + wrapper.and(q1 -> q1.like(ProjectApplication::getApplicationName, req.getApplicationName()) + .or(q2 -> q2.like(ProjectApplication::getRelatedExistsApplication, req.getApplicationName()))); + } + // 获取本区域已验收的项目关联的应用 + List projectList = projectService.list(Wrappers.lambdaQuery(Project.class) + .eq(Project::getAreaCode, regionCode) + .eq(Project::getNewest,Boolean.TRUE) + .eq(Project::getStatus, ProjectStatusEnum.ACCEPTED.getCode())); + List projectCodeList = projectList.stream().map(Project::getProjectCode).collect(Collectors.toList()); + List projectVersionList = projectList.stream().map(Project::getVersion).collect(Collectors.toList()); + wrapper.in(ProjectApplication::getProjectCode,projectCodeList); + wrapper.in(ProjectApplication::getProjectVersion,projectVersionList); + wrapper.orderByDesc(ProjectApplication::getUpdateOn); + List appList = projectApplicationService.list(wrapper); + + List applicationList = Lists.newArrayList(); + // 按项目编号+应用名称+IRS关联应用名称分组,获取最新版本的应用 + Map> appMap = appList.stream().collect(Collectors.groupingBy(p -> p.getProjectCode() + p.getRelatedExistsApplication() + p.getApplicationName())); + for (Map.Entry> entry : appMap.entrySet()) { + List applications = entry.getValue(); + Optional max = applications.stream().max(Comparator.comparingInt(ProjectApplication::getProjectVersion)); + if (max.isPresent()){ + ProjectApplication application = max.get(); + applicationList.add(application); + } + } + if (CollUtil.isEmpty(applicationList)){ + return PageVo.empty(); + } + // 获取已添加到评价计划中的应用 + List applicationIdList = performanceAppraisalApplicationService.list().stream() + .map(PerformanceAppraisalApplication::getApplicationId).collect(Collectors.toList()); + // 如果是编辑评价计划,保留当前计划已添加的应用 + if (Objects.nonNull(appraisalId)) { + List projectApplications = performanceAppraisalApplicationService.list(Wrappers.lambdaQuery(PerformanceAppraisalApplication.class) + .eq(PerformanceAppraisalApplication::getAppraisalId, appraisalId)); + if (CollUtil.isNotEmpty(projectApplications)){ + List appIdList = projectApplications.stream().map(PerformanceAppraisalApplication::getApplicationId).collect(Collectors.toList()); + applicationIdList.removeAll(appIdList); + } + } + List resList = applicationList.stream().filter(a -> !applicationIdList.contains(a.getId())).collect(Collectors.toList()); + if (CollUtil.isEmpty(resList)){ + return PageVo.empty(); + } + + Integer pageNumber = req.getPageNumber(); + Integer pageSize = req.getPageSize(); + List resultList = resList.stream() + .skip((long) (pageNumber - 1) * pageSize) + .limit(pageSize) + .collect(Collectors.toList()); + + List res = resultList.stream() + .map(app -> BeanUtil.copyProperties(app, ProjectApplicationVO.class)) + .collect(Collectors.toList()); + + return PageVo.of(res, resList.size()); } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/helper/ProjectHelper.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/helper/ProjectHelper.java index 0ce4d34..890ddfa 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/helper/ProjectHelper.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/helper/ProjectHelper.java @@ -60,6 +60,8 @@ public class ProjectHelper { .in(CollUtil.isNotEmpty(req.getStatusList()),Project::getStatus,req.getStatusList()) //实例code .in(CollUtil.isNotEmpty(req.getInstCodes()),Project::getInstCode,req.getInstCodes()) + //已添加评价计划的项目code + .notIn(CollUtil.isNotEmpty(req.getProjectCodes()),Project::getProjectCode,req.getProjectCodes()) .orderByDesc(Project::getCreateOn); return query; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/req/ProjectListReq.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/req/ProjectListReq.java index 0259e92..15495fe 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/req/ProjectListReq.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/req/ProjectListReq.java @@ -96,6 +96,9 @@ public class ProjectListReq extends PagePo { @ApiModelProperty("实例code 多个") private List instCodes; + @ApiModelProperty("项目code 多个") + private List projectCodes; + @ApiModelProperty("导出选项") private List exportOptionList; }