From 9c0d9ceb0c4233ed32da88d3e9d36b4a5915f885 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Fri, 21 Jul 2023 15:20:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=B8=80=E4=B8=AA=20?= =?UTF-8?q?=E5=8F=AA=E6=9F=A5=E8=AF=A2=E5=BD=93=E5=89=8D=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/projectlib/manage/ProjectLibManage.java | 97 +++++++++++++++++++++- 1 file changed, 93 insertions(+), 4 deletions(-) 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 4f284e0..9299e64 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 @@ -750,6 +750,95 @@ public class ProjectLibManage { } /** + * @param projectId 项目详情 不查询最新版本 + * @return com.ningdatech.pmapi.projectlib.model.entity.vo.ProjectDetailVO + * @author ZPF + * @since 2023/02/11 11:15 + */ + public ProjectDetailVO getProjectDetailThisVersion(Long projectId) { + // 查询最新的项目申报信息 + Project projectInfo = projectService.getById(projectId); + if (Objects.isNull(projectInfo)) { + return null; + } + ProjectDetailVO vo = new ProjectDetailVO(); + BeanUtils.copyProperties(projectInfo, vo); + vo.buildDynamicForm(projectInfo.getDynamicForm()); + // 查询应用 + List applications = applicationService.list(Wrappers.lambdaQuery(ProjectApplication.class) + .eq(ProjectApplication::getProjectCode, vo.getProjectCode()) + .eq(ProjectApplication::getIsConstruct,projectInfo.getIsConstruct())); + + Optional.ofNullable(applications).ifPresent(apps -> + vo.setProjectApplications(CollUtils.convert(apps, + ProjectHelper::convertVO) + )); + + List allVersionProjectId = projectService.getAllVersionProjectId(projectInfo); + //查询采购备案 + Purchase purchase = purchaseService.getOne(Wrappers.lambdaQuery(Purchase.class) + .in(Purchase::getProjectId, allVersionProjectId) + .last(BizConst.LIMIT_1)); + vo.setPurchase(BeanUtil.copyProperties(purchase, PurchaseVO.class)); + + //查询合同备案 + Contract contract = contractService.getOne(Wrappers.lambdaQuery(Contract.class) + .in(Contract::getProjectId, allVersionProjectId) + .last(BizConst.LIMIT_1)); + ContractVO contractVO = BeanUtil.copyProperties(contract, ContractVO.class); + vo.setContract(contractVO); + List payments = paymentPlanService.list(Wrappers.lambdaQuery(PaymentPlan.class) + .in(PaymentPlan::getProjectId, allVersionProjectId) + .orderByAsc(PaymentPlan::getPaymentTime)); + if(Objects.nonNull(contractVO)){ + contractVO.setPayments(convertPayments(payments, + contractVO.getTotalAmount())); + } + + + //查询初验信息 + List acceptancePersons = acceptancePersonService.list(Wrappers.lambdaQuery(PreInsAcceptancePerson.class) + .in(PreInsAcceptancePerson::getProjectId, allVersionProjectId) + .orderByAsc(PreInsAcceptancePerson::getCreateOn)); + vo.setAcceptancePersons(convertPersons(acceptancePersons)); + + //查询终验信息 + //查询年度投资金额 要是已验收的项目 + if (ProjectStatusEnum.ACCEPTED.getCode().equals(projectInfo.getStatus())) { + List annualAmounts = Lists.newArrayList(); + annualAmounts.add(AnnualAmountVO.builder() + .projectId(projectInfo.getId()) + .projectYear(projectInfo.getProjectYear()) + .annualAmount(projectInfo.getAnnualPlanAmount()) + .build()); + List renewalDeclarations = renewalFundDeclarationService.list(Wrappers.lambdaQuery(ProjectRenewalFundDeclaration.class) + .eq(ProjectRenewalFundDeclaration::getProjectId, vo.getId()) + .orderByAsc(ProjectRenewalFundDeclaration::getProjectYear)); + Optional.ofNullable(renewalDeclarations).ifPresent(declarations -> + declarations.forEach(declaration -> { + annualAmounts.add(AnnualAmountVO.builder() + .projectId(projectInfo.getId()) + .projectYear(declaration.getProjectYear()) + .annualAmount(declaration.getAnnualPaymentAmount()) + .build()); + }) + ); + vo.setAnnualAccumulateAmountList(annualAmounts); + } + // 处理文件名 + List fileIdList = new ArrayList<>(); + BizUtils.notBlank(vo.getApprovedFile(), w -> fileIdList.add(Long.parseLong(w))); + BizUtils.notBlank(vo.getApprovedConstructionPlanFile(), w -> fileIdList.add(Long.parseLong(w))); + if (!fileIdList.isEmpty()) { + List files = fileService.listByIds(fileIdList); + Map fileMap = CollUtils.listToMap(files, w -> w.getId().toString(), File::getOriginalFileName); + vo.setApprovedFileName(fileMap.get(vo.getApprovedFile())); + vo.setApprovedConstructionPlanFileName(fileMap.get(vo.getApprovedConstructionPlanFile())); + } + return vo; + } + + /** * 获取项目初步方案详情 * @param projectId * @return com.ningdatech.pmapi.projectlib.model.vo.ProjectDetailVO @@ -1019,12 +1108,12 @@ public class ProjectLibManage { } List basicProjects = historyProjects.stream() - .map(p -> this.getProjectDetail(p.getId())) - .filter(p -> !p.getIsConstruct()) + .map(p -> this.getProjectDetailThisVersion(p.getId())) + .filter(p -> Objects.isNull(p.getIsConstruct()) || !p.getIsConstruct()) .collect(Collectors.toList()); List constructProjects = historyProjects.stream() - .map(p -> this.getProjectDetail(p.getId())) - .filter(p -> p.getIsConstruct()) + .map(p -> this.getProjectDetailThisVersion(p.getId())) + .filter(p -> Objects.nonNull(p.getIsConstruct()) && p.getIsConstruct()) .collect(Collectors.toList()); res.put(ProjectConstant.ProjectLib.PROJECT_BASIC,basicProjects); res.put(ProjectConstant.ProjectLib.PROJECT_CONSTRUCT,constructProjects);