From 9211ac94ea98472bf932558c07e4a00606025fae Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Thu, 16 Nov 2023 11:55:02 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=AD=E5=BB=BA=E9=A1=B9=E7=9B=AE=20?= =?UTF-8?q?=E8=83=BD=E5=85=B3=E8=81=94=E7=9A=84=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manage/DeclaredProjectManage.java | 16 +---- .../ProjectRenewalFundDeclarationController.java | 10 ++- .../helper/ProjectRenewwalFundHelper.java | 48 +++++++++++++ .../pmapi/projectlib/manage/ProjectLibManage.java | 27 ++++--- .../manage/ProjectRenewalFundManage.java | 82 ++++++++++++++++++++-- 5 files changed, 149 insertions(+), 34 deletions(-) create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/projectlib/helper/ProjectRenewwalFundHelper.java diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java index c0960fd..5444034 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java @@ -1,5 +1,6 @@ package com.ningdatech.pmapi.projectdeclared.manage; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import com.alibaba.excel.EasyExcel; import com.alibaba.fastjson.JSON; @@ -380,20 +381,7 @@ public class DeclaredProjectManage { return PageVo.empty(); } List records = CollUtils.convert(page.getRecords(), w -> { - ProjectLibListItemVO item = new ProjectLibListItemVO(); - item.setId(w.getId()); - item.setProjectName(w.getProjectName()); - item.setCreateOn(w.getCreateOn()); - item.setDeclaredAmount(w.getDeclareAmount()); - item.setStage(w.getStage()); - item.setStatus(w.getStatus()); - item.setProjectType(w.getProjectType()); - item.setProjectYear(w.getProjectYear()); - item.setBuildOrg(w.getBuildOrgName()); - item.setBizDomain(w.getBizDomain()); - item.setProcessStatus(w.getProcessStatus()); - item.setInstCode(w.getInstCode()); - item.setIsHigherSuperOrg(w.getIsHigherSuperOrg()); + ProjectLibListItemVO item = BeanUtil.copyProperties(w,ProjectLibListItemVO.class); return item; }); return PageVo.of(records, total); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/controller/ProjectRenewalFundDeclarationController.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/controller/ProjectRenewalFundDeclarationController.java index 88c72e8..0dbea5f 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/controller/ProjectRenewalFundDeclarationController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/controller/ProjectRenewalFundDeclarationController.java @@ -7,8 +7,10 @@ import com.ningdatech.pmapi.common.helper.UserInfoHelper; import com.ningdatech.pmapi.common.util.ExcelDownUtil; import com.ningdatech.pmapi.projectlib.manage.ProjectRenewalFundManage; import com.ningdatech.pmapi.projectlib.model.dto.ProjectRenewalFundDeclarationDTO; +import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; import com.ningdatech.pmapi.projectlib.model.req.ProjectRenewalAuditReq; import com.ningdatech.pmapi.projectlib.model.req.ProjectRenewalListReq; +import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO; import com.ningdatech.pmapi.projectlib.model.vo.ProjectRenewalFundDeclarationVO; import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; import com.ningdatech.pmapi.user.util.LoginUserUtil; @@ -39,12 +41,18 @@ public class ProjectRenewalFundDeclarationController { @GetMapping("/list") @ApiOperation("项目续建资金库") - @WebLog("项目续建资金库") public PageVo list(ProjectRenewalListReq req) { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); return projectRenewalFundManage.list(req,user); } + @GetMapping("/project-list") + @ApiOperation("项目续建资金库能关联的项目列表") + public PageVo projectlist(ProjectRenewalListReq req) { + UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); + return projectRenewalFundManage.projectlist(req,user); + } + @GetMapping("/{id}") @ApiOperation("项目续建资金详情") @WebLog("项目续建资金详情") diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/helper/ProjectRenewwalFundHelper.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/helper/ProjectRenewwalFundHelper.java new file mode 100644 index 0000000..82743c1 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/helper/ProjectRenewwalFundHelper.java @@ -0,0 +1,48 @@ +package com.ningdatech.pmapi.projectlib.helper; + +import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.ningdatech.pmapi.performance.model.entity.ProjectCoreBusinessIndicators; +import com.ningdatech.pmapi.projectlib.model.entity.Project; +import com.ningdatech.pmapi.projectlib.model.entity.ProjectApplication; +import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; +import com.ningdatech.pmapi.projectlib.model.req.ProjectRenewalListReq; +import com.ningdatech.pmapi.projectlib.model.vo.ProjectApplicationVO; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; + +import java.util.List; +import java.util.Map; + +/** + *

+ * ProjectRenewwalFundHelper + *

+ * + * @author ZPF + * @since 14:15 2023/11/16 + */ +public class ProjectRenewwalFundHelper { + + /** + * 通用项目查询 + * + * @param req 查询条件 + * @return / + **/ + public static LambdaQueryWrapper projectQuery(ProjectRenewalListReq req) { + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.eq(req.getRegionCode() != null, Project::getAreaCode, req.getRegionCode()) + .eq(req.getUserId() != null, Project::getCreateBy, req.getUserId()) + .like(req.getProjectName() != null, Project::getProjectName, req.getProjectName()) + .eq(req.getProjectType() != null, Project::getProjectType, req.getProjectType()) + .eq(req.getStage() != null, Project::getStage, req.getStage()) + .eq(req.getStatus() != null, Project::getStatus, req.getStatus()) + + //状态 阶段 list + .in(CollUtil.isNotEmpty(req.getStageList()),Project::getStage,req.getStageList()) + .in(CollUtil.isNotEmpty(req.getStatusList()),Project::getStatus,req.getStatusList()) + .orderByDesc(Project::getUpdateOn); + return query; + } +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java index 2fa2365..9378c9a 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java @@ -138,18 +138,18 @@ public class ProjectLibManage { query.eq(Project::getNewest, Boolean.TRUE); Page page = projectService.page(req.page(), query); long total; - if ((total = page.getTotal()) == 0) { + if (CollUtil.isEmpty(page.getRecords())) { return PageVo.empty(); } - //已验收项目ID - List acceptedProjectId = page.getRecords().stream().filter(p -> ProjectStatusEnum.ACCEPTED.getCode().equals(p.getStatus())) - .map(Project::getId).collect(Collectors.toList()); + // + List projectCodes = page.getRecords().stream() + .map(Project::getProjectCode).collect(Collectors.toList()); Map> renewalMap = Maps.newHashMap(); - if(CollUtil.isNotEmpty(acceptedProjectId)){ + if(CollUtil.isNotEmpty(projectCodes)){ List renewalDeclarations = renewalFundDeclarationService.list(Wrappers.lambdaQuery(ProjectRenewalFundDeclaration.class) - .in(ProjectRenewalFundDeclaration::getProjectId, acceptedProjectId) + .in(ProjectRenewalFundDeclaration::getProjectCode, projectCodes) .eq(ProjectRenewalFundDeclaration::getApprovalStatus, ProjectRenewalApprovalStatusEnum.PASS.name()) .eq(ProjectRenewalFundDeclaration::getDeleted,Boolean.FALSE) .orderByAsc(ProjectRenewalFundDeclaration::getProjectYear)); @@ -185,7 +185,7 @@ public class ProjectLibManage { } return item; }); - return PageVo.of(records, total); + return PageVo.of(records, page.getTotal()); } public PageVo projectLibListWithPermission(ProjectListReq req, UserFullInfoDTO user) { @@ -218,14 +218,11 @@ public class ProjectLibManage { Map> finalTagMap = tagMap; Map finalTagNameMap = tagNameMap; - //已验收项目ID - List acceptedProjectId = page.getRecords().stream().filter(p -> ProjectStatusEnum.ACCEPTED.getCode().equals(p.getStatus())) - .map(Project::getId).collect(Collectors.toList()); Map> renewalMap = Maps.newHashMap(); - if(CollUtil.isNotEmpty(acceptedProjectId)){ + if(CollUtil.isNotEmpty(projectCodes)){ List renewalDeclarations = renewalFundDeclarationService.list(Wrappers.lambdaQuery(ProjectRenewalFundDeclaration.class) - .in(ProjectRenewalFundDeclaration::getProjectId, acceptedProjectId) + .in(ProjectRenewalFundDeclaration::getProjectCode, projectCodes) .eq(ProjectRenewalFundDeclaration::getApprovalStatus, ProjectRenewalApprovalStatusEnum.PASS.name()) .eq(ProjectRenewalFundDeclaration::getDeleted,Boolean.FALSE) .orderByAsc(ProjectRenewalFundDeclaration::getProjectYear)); @@ -444,7 +441,7 @@ public class ProjectLibManage { return PageVo.of(records, page.getTotal()); } - private BigDecimal computeAmount(BigDecimal cuurentAmount,List prfs) { + public static BigDecimal computeAmount(BigDecimal cuurentAmount,List prfs) { BigDecimal res = Objects.isNull(cuurentAmount) ? BigDecimal.ZERO : cuurentAmount; for(ProjectRenewalFundDeclaration prf : prfs){ res = res.add(prf.getAnnualPaymentAmount()); @@ -452,7 +449,7 @@ public class ProjectLibManage { return res; } - private List convertAccmulate(ProjectPO project,List prfs) { + public static List convertAccmulate(ProjectPO project,List prfs) { List annualAmounts = Lists.newArrayList(); annualAmounts.add(AnnualAmountVO.builder() .projectId(project.getId()) @@ -469,7 +466,7 @@ public class ProjectLibManage { return annualAmounts; } - private List convertAccmulate(Project project,List prfs) { + public static List convertAccmulate(Project project,List prfs) { List annualAmounts = Lists.newArrayList(); annualAmounts.add(AnnualAmountVO.builder() .projectId(project.getId()) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectRenewalFundManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectRenewalFundManage.java index e5a63a7..b6b8c5f 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectRenewalFundManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectRenewalFundManage.java @@ -1,10 +1,13 @@ package com.ningdatech.pmapi.projectlib.manage; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.excel.EasyExcel; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import com.ningdatech.basic.exception.BizException; import com.ningdatech.basic.function.VUtils; import com.ningdatech.basic.model.PageVo; @@ -26,11 +29,15 @@ import com.ningdatech.pmapi.gov.service.IGovBizProjectApplyService; import com.ningdatech.pmapi.gov.service.IGovBizProjectApproveService; import com.ningdatech.pmapi.gov.service.IGovBizProjectBaseinfoService; import com.ningdatech.pmapi.gov.service.IGovOperationProjectBaseinfoService; +import com.ningdatech.pmapi.portrait.model.entity.ProjectTag; +import com.ningdatech.pmapi.portrait.model.entity.Tag; import com.ningdatech.pmapi.projectdeclared.model.dto.ProjectRenewalDeclareExportDTO; import com.ningdatech.pmapi.projectlib.enumeration.ProjectRenewalApprovalStatusEnum; import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeEnum; import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeNewEnum; +import com.ningdatech.pmapi.projectlib.helper.ProjectHelper; +import com.ningdatech.pmapi.projectlib.helper.ProjectRenewwalFundHelper; import com.ningdatech.pmapi.projectlib.model.dto.ProjectRenewalExportDTO; import com.ningdatech.pmapi.projectlib.model.dto.ProjectRenewalFundDeclarationDTO; import com.ningdatech.pmapi.projectlib.model.entity.Project; @@ -40,6 +47,7 @@ import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; import com.ningdatech.pmapi.projectlib.model.req.ProjectRenewalAuditReq; import com.ningdatech.pmapi.projectlib.model.req.ProjectRenewalListReq; import com.ningdatech.pmapi.projectlib.model.vo.AnnualAmountVO; +import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO; import com.ningdatech.pmapi.projectlib.model.vo.ProjectRenewalFundDeclarationVO; import com.ningdatech.pmapi.projectlib.service.IProjectRenewalFundDeclarationService; import com.ningdatech.pmapi.projectlib.service.IProjectService; @@ -56,10 +64,7 @@ import org.springframework.stereotype.Component; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.Objects; -import java.util.Optional; +import java.util.*; import java.util.stream.Collectors; /** @@ -110,6 +115,75 @@ public class ProjectRenewalFundManage { return PageVo.of(records, total); } + public PageVo projectlist(ProjectRenewalListReq req, UserFullInfoDTO user) { + LambdaQueryWrapper query = ProjectRenewwalFundHelper.projectQuery(req); + //项目查最新 + query.eq(Project::getNewest, Boolean.TRUE); + //自己单位 + query.eq(Project::getBuildOrgCode,user.getEmpPosUnitCode()); + //立项批复到初验 + query.gt(Project::getStatus,ProjectStatusEnum.APPROVED_AFTER_CHOICE.getCode()); + query.le(Project::getStatus,ProjectStatusEnum.UNDER_CONSTRUCTION.getCode()); + Page page = projectService.page(req.page(), query); + if (CollUtil.isEmpty(page.getRecords())) { + return PageVo.empty(); + } + UserFullInfoDTO finalUser = user; + + Set projectCodes = page.getRecords().stream() + .map(Project::getProjectCode).collect(Collectors.toSet()); + + Map> renewalMap = Maps.newHashMap(); + if(CollUtil.isNotEmpty(projectCodes)){ + List renewalDeclarations = projectRenewalFundDeclarationService.list(Wrappers.lambdaQuery(ProjectRenewalFundDeclaration.class) + .in(ProjectRenewalFundDeclaration::getProjectCode, projectCodes) + .eq(ProjectRenewalFundDeclaration::getApprovalStatus, ProjectRenewalApprovalStatusEnum.PASS.name()) + .eq(ProjectRenewalFundDeclaration::getDeleted,Boolean.FALSE) + .orderByAsc(ProjectRenewalFundDeclaration::getProjectYear)); + renewalMap = renewalDeclarations.stream().collect(Collectors.groupingBy(ProjectRenewalFundDeclaration::getProjectId)); + } + + Map> finalRenewalMap = renewalMap; + List records = CollUtils.convert(page.getRecords(), w -> { + ProjectLibListItemVO item = new ProjectLibListItemVO(); + item.setId(w.getId()); + item.setProjectName(w.getProjectName()); + item.setProjectCode(w.getProjectCode()); + item.setArea(w.getArea()); + item.setAreaCode(w.getAreaCode()); + item.setCreateOn(w.getCreateOn()); + item.setDeclaredAmount(w.getDeclareAmount()); + item.setStage(w.getStage()); + item.setStatus(w.getStatus()); + item.setProjectType(w.getProjectType()); + item.setProjectYear(w.getProjectYear()); + item.setBuildOrg(w.getBuildOrgName()); + item.setBizDomain(w.getBizDomain()); + item.setProcessStatus(w.getProcessStatus()); + item.setInstCode(w.getInstCode()); + item.setIsHigherSuperOrg(w.getIsHigherSuperOrg()); + if (finalUser.getIsOrgAdmin() && + ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode().equals(item.getStatus()) + && StringUtils.isNotBlank(w.getSuperOrgCode()) && StringUtils.isNotBlank(finalUser.getEmpPosUnitCode()) + && w.getSuperOrgCode().equals(finalUser.getEmpPosUnitCode())) { + item.setCanPreDeclared(Boolean.TRUE); + } + item.setApprovedAmount(w.getApprovalAmount()); + item.setAnnualPlanAmount(w.getAnnualPlanAmount()); + item.setPrePlanProjectId(w.getPrePlanProjectId()); + if(finalRenewalMap.containsKey(item.getId())){ + List prfs = finalRenewalMap.get(item.getId()); + item.setAnnualAccumulateAmount(ProjectLibManage.computeAmount(w.getAnnualPlanAmount(),prfs)); + item.setAnnualAccumulateAmountList(ProjectLibManage.convertAccmulate(w,prfs)); + }else{ + item.setAnnualAccumulateAmount(w.getAnnualPlanAmount()); + item.setAnnualAccumulateAmountList(ProjectLibManage.convertAccmulate(w,Collections.emptyList())); + } + return item; + }); + return PageVo.of(records, page.getTotal()); + } + /** * @param id * @author ZPF