From 2208bdd9692715af7be2fe6f1febbfa6bd4689e2 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Wed, 21 Feb 2024 19:07:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0decimal=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hz/pm/api/common/util/BizUtils.java | 1 + .../com/hz/pm/api/common/util/DecimalUtil.java | 81 ++++++++++++++++++++++ .../converter/ApplicationConverter.java | 3 +- .../projectdeclared/manage/ConstructionManage.java | 41 +++++++++-- .../manage/ReviewChecklistManage.java | 2 +- .../projectlib/controller/MhProjectController.java | 2 +- .../api/projectlib/manage/AnnualPlanLibManage.java | 3 +- .../pm/api/projectlib/manage/ProjectLibManage.java | 61 +++++++++++----- .../manage/ProjectRenewalFundManage.java | 38 +++++++--- .../hz/pm/api/projectlib/mapper/ProjectMapper.xml | 4 -- .../hz/pm/api/projectlib/model/dto/ProjectDTO.java | 3 + .../hz/pm/api/projectlib/model/entity/Project.java | 27 +------- .../model/entity/ProjectPaymentPlan.java | 2 + .../service/IProjectPaymentPlanService.java | 26 ++++++- .../pm/api/todocenter/manage/TodoCenterManage.java | 4 +- 15 files changed, 226 insertions(+), 72 deletions(-) create mode 100644 hz-pm-api/src/main/java/com/hz/pm/api/common/util/DecimalUtil.java diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/util/BizUtils.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/util/BizUtils.java index 0e0686a..20a6a21 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/util/BizUtils.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/util/BizUtils.java @@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONArray; import com.hz.pm.api.projectlib.model.enumeration.ProjectTypeNewEnum; import com.ningdatech.basic.util.StrPool; import com.ningdatech.file.entity.vo.result.FileResultVO; +import liquibase.pro.packaged.O; import org.apache.commons.lang3.StringUtils; import org.springframework.util.NumberUtils; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/util/DecimalUtil.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/util/DecimalUtil.java new file mode 100644 index 0000000..de08485 --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/util/DecimalUtil.java @@ -0,0 +1,81 @@ +package com.hz.pm.api.common.util; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ArrayUtil; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.Arrays; +import java.util.Collection; +import java.util.Comparator; +import java.util.function.Function; + +/** + *

+ * DecimalUtil + *

+ * + * @author WendyYang + * @since 18:53 2024/2/21 + */ +public class DecimalUtil { + + private DecimalUtil() { + } + + @SafeVarargs + public static BigDecimal sum(Collection objs, Function... functions) { + if (CollUtil.isEmpty(objs) || ArrayUtil.isEmpty(functions)) { + return BigDecimal.ZERO; + } + return objs.stream() + .map(w -> Arrays.stream(functions) + .map(f -> f.apply(w)) + .reduce(BigDecimal::add) + .orElse(BigDecimal.ZERO)) + .reduce(BigDecimal::add) + .orElse(BigDecimal.ZERO); + + } + + public static BigDecimal avg(Collection objs, Function function) { + if (CollUtil.isEmpty(objs)) { + return BigDecimal.ZERO; + } + BigDecimal size = BigDecimal.valueOf(objs.size()); + return objs.stream() + .map(function) + .reduce(BigDecimal::add) + .orElse(BigDecimal.ZERO) + .divide(size, RoundingMode.HALF_UP); + } + + public static BigDecimal max(Collection objs, Function function) { + if (CollUtil.isEmpty(objs)) { + return BigDecimal.ZERO; + } + return objs.stream().map(function).max(BigDecimal::compareTo).orElse(BigDecimal.ZERO); + } + + public static BigDecimal min(Collection objs, Function function) { + if (CollUtil.isEmpty(objs)) { + return BigDecimal.ZERO; + } + return objs.stream().map(function).min(BigDecimal::compareTo).orElse(BigDecimal.ZERO); + } + + public static T objByMax(Collection objs, Function function) { + if (CollUtil.isEmpty(objs)) { + return null; + } + return objs.stream().max(Comparator.comparing(function)).orElse(null); + } + + public static T objByMin(Collection objs, Function function) { + if (CollUtil.isEmpty(objs)) { + return null; + } + return objs.stream().min(Comparator.comparing(function)).orElse(null); + } + +} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/converter/ApplicationConverter.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/converter/ApplicationConverter.java index 33a095e..1067da5 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/converter/ApplicationConverter.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/converter/ApplicationConverter.java @@ -43,7 +43,8 @@ public class ApplicationConverter { .projectId(projectInfo.getProjectCode()) .projectType(convertProjectType(projectInfo.getProjectType())) .totalMoney(projectInfo.getDeclareAmount()) - .yearBudget(projectInfo.getAnnualPlanAmount()) + // TODO + .yearBudget(BigDecimal.ZERO) .budgetFrom(checkAddBudget(projectInfo.getDeclareHaveAmount() , projectInfo.getDeclareGovOwnFinanceAmount(), projectInfo.getDeclareGovSuperiorFinanceAmount(), diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ConstructionManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ConstructionManage.java index f2caf79..702a382 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ConstructionManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ConstructionManage.java @@ -27,10 +27,12 @@ import com.hz.pm.api.projectdeclared.service.IPreInsAcceptancePersonService; import com.hz.pm.api.projectdeclared.service.IPurchaseService; import com.hz.pm.api.projectlib.helper.ProjectHelper; import com.hz.pm.api.projectlib.model.entity.Project; +import com.hz.pm.api.projectlib.model.entity.ProjectPaymentPlan; import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum; import com.hz.pm.api.projectlib.model.enumeration.ProjectTypeNewEnum; import com.hz.pm.api.projectlib.model.req.ProjectListReq; import com.hz.pm.api.projectlib.model.vo.ProjectLibListItemVO; +import com.hz.pm.api.projectlib.service.IProjectPaymentPlanService; import com.hz.pm.api.projectlib.service.IProjectService; import com.hz.pm.api.user.security.model.UserFullInfoDTO; import com.hz.pm.api.user.security.model.UserInfoDetails; @@ -51,10 +53,7 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; @@ -81,6 +80,7 @@ public class ConstructionManage { private final IPreInsAcceptancePersonService acceptancePersonService; private final StateMachineUtil stateMachineUtil; + private final IProjectPaymentPlanService projectPaymentPlanService; /** * 待采购的-项目列表 @@ -381,6 +381,16 @@ public class ConstructionManage { if ((total = page.getTotal()) == 0) { return PageVo.empty(); } + + Set projectCodes = new HashSet<>(); + List projectIds = new ArrayList<>(); + for (Project project : page.getRecords()) { + projectIds.add(project.getId()); + projectCodes.add(project.getProjectCode()); + } + + Map> paymentPlansMap = projectPaymentPlanService.listByProjectIds(projectIds); + List records = CollUtils.convert(page.getRecords(), w -> { ProjectLibListItemVO item = new ProjectLibListItemVO(); item.setId(w.getId()); @@ -400,7 +410,11 @@ public class ConstructionManage { item.setApprovalDate(w.getApprovalDate()); item.setDeliveryTime(w.getDeliveryTime()); item.setContractAmount(w.getContractAmount()); - item.setAnnualPlanAmount(w.getAnnualPlanAmount()); + List paymentPlans = paymentPlansMap.getOrDefault(w.getId(), Collections.emptyList()); + BigDecimal totalAnnualAmount = paymentPlans.stream() + .map(ProjectPaymentPlan::getAnnualPlanAmount) + .reduce(BigDecimal::add).orElse(BigDecimal.ZERO); + item.setAnnualPlanAmount(totalAnnualAmount); item.setTransactionTime(w.getTransactionTime()); item.setTransactionAmount(w.getTransactionAmount()); return item; @@ -425,6 +439,13 @@ public class ConstructionManage { List collect = Lists.newArrayList(); if (CollUtil.isNotEmpty(records)) { + List projectIds = new ArrayList<>(); + for (Project project : records) { + projectIds.add(project.getId()); + } + + Map> paymentPlansMap = projectPaymentPlanService.listByProjectIds(projectIds); + AtomicInteger serialNumber = new AtomicInteger(0); collect = records.stream().map(r -> { DeclaredProjectExportDTO exportDTO = new DeclaredProjectExportDTO(); @@ -436,7 +457,13 @@ public class ConstructionManage { exportDTO.setSerialNumber(serialNumber.incrementAndGet()); exportDTO.setDeliveryTime(r.getDeliveryTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); exportDTO.setContractAmount(r.getContractAmount()); - exportDTO.setAnnualPlanAmount(r.getAnnualPlanAmount()); + + List paymentPlans = paymentPlansMap.getOrDefault(r.getId(), Collections.emptyList()); + BigDecimal totalAnnualAmount = paymentPlans.stream() + .map(ProjectPaymentPlan::getAnnualPlanAmount) + .reduce(BigDecimal::add).orElse(BigDecimal.ZERO); + + exportDTO.setAnnualPlanAmount(totalAnnualAmount); if (Objects.nonNull(r.getTransactionTime())) { exportDTO.setTransactionTime(r.getTransactionTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); } @@ -445,7 +472,7 @@ public class ConstructionManage { }).collect(Collectors.toList()); } - String fileName = "合同备案项目列表"; + final String fileName = "合同备案项目列表"; ExcelDownUtil.setFileName(fileName, response); //数据导出处理函数 try { diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ReviewChecklistManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ReviewChecklistManage.java index ed3e245..b3ea67d 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ReviewChecklistManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ReviewChecklistManage.java @@ -121,7 +121,7 @@ public class ReviewChecklistManage { item.setProcessStatus(w.getProcessStatus()); item.setInstCode(w.getInstCode()); item.setApprovedAmount(w.getApprovalAmount()); - item.setAnnualPlanAmount(w.getAnnualPlanAmount()); + // item.setAnnualPlanAmount(w.getAnnualPlanAmount()); // 审查人员情况 item.setVerifiedHumans(computeVerify(item, approveMap.get(w.getProjectCode()), userMap, user)); item.setReviewCheckFinish(w.getReviewCheckFinish()); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/controller/MhProjectController.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/controller/MhProjectController.java index 0bb22a8..d860237 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/controller/MhProjectController.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/controller/MhProjectController.java @@ -21,7 +21,7 @@ import javax.validation.Valid; * @author WendyYang * @since 2024-01-30 */ -@Api(tags = "信产项目(立项备案)列表") +@Api(tags = "信产项目(立项备案)相关接口") @RestController @RequiredArgsConstructor @RequestMapping("/api/v1/declared/record") diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/AnnualPlanLibManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/AnnualPlanLibManage.java index 23a51af..31f6c8d 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/AnnualPlanLibManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/AnnualPlanLibManage.java @@ -344,7 +344,8 @@ public class AnnualPlanLibManage { project.setBeginTime(dataArr[0].trim()); project.setEndTime(dataArr[1].trim()); project.setDeclareAmount(data.getDeclaredAmount()); - project.setAnnualPlanAmount(data.getAnnualPlanAmount()); + // TODO 年度计划 + // project.setAnnualPlanAmount(data.getAnnualPlanAmount()); project.setDeclareHaveAmount(data.getDeclareHaveAmount()); project.setDeclareGovOwnFinanceAmount(data.getDeclareGovOwnFinanceAmount()); project.setDeclareGovSuperiorFinanceAmount(data.getDeclareGovSuperiorFinanceAmount()); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectLibManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectLibManage.java index 69b2350..c88a5e4 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectLibManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectLibManage.java @@ -5,6 +5,7 @@ import cn.hutool.core.bean.copier.CopyOptions; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.lang.Assert; import cn.hutool.core.util.NumberUtil; +import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; @@ -93,6 +94,7 @@ import org.springframework.stereotype.Component; import javax.servlet.http.HttpServletResponse; import java.math.BigDecimal; import java.math.RoundingMode; +import java.sql.Array; import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; @@ -146,10 +148,14 @@ public class ProjectLibManage { if (CollUtil.isEmpty(page.getRecords())) { return PageVo.empty(); } - - List projectCodes = page.getRecords().stream() - .map(Project::getProjectCode).collect(Collectors.toList()); + Set projectCodes = new HashSet<>(); + List projectIds = new ArrayList<>(); + for (Project project : page.getRecords()) { + projectIds.add(project.getId()); + projectCodes.add(project.getProjectCode()); + } Map> renewalMap = listRenewDeclarations(projectCodes); + Map> paymentPlansMap = projectPaymentPlanService.listByProjectIds(projectIds); List records = CollUtils.convert(page.getRecords(), w -> { ProjectLibListItemVO item = new ProjectLibListItemVO(); @@ -169,13 +175,18 @@ public class ProjectLibManage { item.setProcessStatus(w.getProcessStatus()); item.setInstCode(w.getInstCode()); item.setIsHigherSuperOrg(w.getIsHigherSuperOrg()); + List paymentPlans = paymentPlansMap.getOrDefault(w.getId(), Collections.emptyList()); + BigDecimal totalAnnualPaymentAmount = paymentPlans.stream() + .map(ProjectPaymentPlan::getAnnualPlanAmount) + .reduce(BigDecimal::add).orElse(BigDecimal.ZERO); + List fundDeclarations = renewalMap.get(w.getId()); if (fundDeclarations != null) { - item.setAnnualAccumulateAmount(computeAmount(w.getAnnualPlanAmount(), fundDeclarations)); - item.setAnnualAccumulateAmountList(convertAccmulate(w, fundDeclarations)); + item.setAnnualAccumulateAmount(computeAmount(totalAnnualPaymentAmount, fundDeclarations)); + item.setAnnualAccumulateAmountList(convertAccmulate(w, totalAnnualPaymentAmount, fundDeclarations)); } else { - item.setAnnualAccumulateAmount(w.getAnnualPlanAmount()); - item.setAnnualAccumulateAmountList(convertAccmulate(w, Collections.emptyList())); + item.setAnnualAccumulateAmount(totalAnnualPaymentAmount); + item.setAnnualAccumulateAmountList(convertAccmulate(w, totalAnnualPaymentAmount, Collections.emptyList())); } return item; }); @@ -193,10 +204,14 @@ public class ProjectLibManage { return PageVo.empty(); } UserFullInfoDTO finalUser = user; - - Set projectCodes = page.getRecords().stream() - .map(Project::getProjectCode).collect(Collectors.toSet()); + Set projectCodes = new HashSet<>(); + List projectIds = new ArrayList<>(); + for (Project project : page.getRecords()) { + projectIds.add(project.getId()); + projectCodes.add(project.getProjectCode()); + } Map> projectTagMap = getProjectTags(projectCodes); + Map> paymentPlansMap = projectPaymentPlanService.listByProjectIds(projectIds); Map> renewalMap = listRenewDeclarations(projectCodes); List records = CollUtils.convert(page.getRecords(), w -> { @@ -223,16 +238,20 @@ public class ProjectLibManage { item.setCanPreDeclared(Boolean.TRUE); } item.setApprovedAmount(w.getApprovalAmount()); - item.setAnnualPlanAmount(w.getAnnualPlanAmount()); + List paymentPlans = paymentPlansMap.getOrDefault(w.getId(), Collections.emptyList()); + BigDecimal totalAnnualPaymentAmount = paymentPlans.stream() + .map(ProjectPaymentPlan::getAnnualPlanAmount) + .reduce(BigDecimal::add).orElse(BigDecimal.ZERO); + item.setAnnualPlanAmount(totalAnnualPaymentAmount); item.setPrePlanProjectId(w.getPrePlanProjectId()); item.setTags(projectTagMap.get(w.getProjectCode())); List fundDeclarations = renewalMap.get(w.getId()); if (fundDeclarations != null) { - item.setAnnualAccumulateAmount(computeAmount(w.getAnnualPlanAmount(), fundDeclarations)); - item.setAnnualAccumulateAmountList(convertAccmulate(w, fundDeclarations)); + item.setAnnualAccumulateAmount(computeAmount(totalAnnualPaymentAmount, fundDeclarations)); + item.setAnnualAccumulateAmountList(convertAccmulate(w, totalAnnualPaymentAmount, fundDeclarations)); } else { - item.setAnnualAccumulateAmount(w.getAnnualPlanAmount()); - item.setAnnualAccumulateAmountList(convertAccmulate(w, Collections.emptyList())); + item.setAnnualAccumulateAmount(totalAnnualPaymentAmount); + item.setAnnualAccumulateAmountList(convertAccmulate(w, totalAnnualPaymentAmount, Collections.emptyList())); } return item; }); @@ -298,7 +317,7 @@ public class ProjectLibManage { item.setCanPreDeclared(Boolean.TRUE); } item.setApprovedAmount(w.getApprovalAmount()); - item.setAnnualPlanAmount(w.getAnnualPlanAmount()); + // item.setAnnualPlanAmount(w.getAnnualPlanAmount()); item.setPrePlanProjectId(w.getPrePlanProjectId()); records.add(item); } @@ -572,12 +591,12 @@ public class ProjectLibManage { return annualAmounts; } - public static List convertAccmulate(Project project, List prfs) { + public static List convertAccmulate(Project project, BigDecimal totalAnnualPlanAmount, List prfs) { List annualAmounts = Lists.newArrayList(); annualAmounts.add(AnnualAmountVO.builder() .projectId(project.getId()) .projectYear(project.getProjectYear()) - .annualAmount(project.getAnnualPlanAmount()) + .annualAmount(totalAnnualPlanAmount) .build()); for (ProjectRenewalFundDeclaration prf : prfs) { annualAmounts.add(AnnualAmountVO.builder() @@ -719,11 +738,15 @@ public class ProjectLibManage { //查询年度投资金额 要是已验收的项目 if (ProjectStatusEnum.ACCEPTED.getCode().equals(projectInfo.getStatus())) { + List paymentPlans = projectPaymentPlanService.listByProjectId(projectInfo.getId()); + BigDecimal totalAnnualAmount = paymentPlans.stream() + .map(ProjectPaymentPlan::getAnnualPlanAmount) + .reduce(BigDecimal::add).orElse(BigDecimal.ZERO); List annualAmounts = Lists.newArrayList(); annualAmounts.add(AnnualAmountVO.builder() .projectId(projectInfo.getId()) .projectYear(projectInfo.getProjectYear()) - .annualAmount(projectInfo.getAnnualPlanAmount()) + .annualAmount(totalAnnualAmount) .build()); List renewalDeclarations = renewalFundDeclarationService.list(Wrappers.lambdaQuery(ProjectRenewalFundDeclaration.class) .eq(ProjectRenewalFundDeclaration::getProjectId, vo.getId()) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectRenewalFundManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectRenewalFundManage.java index 3e033cf..6e61030 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectRenewalFundManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectRenewalFundManage.java @@ -9,6 +9,8 @@ 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.hz.pm.api.projectlib.model.entity.ProjectPaymentPlan; +import com.hz.pm.api.projectlib.service.IProjectPaymentPlanService; import com.hz.pm.api.user.security.model.UserInfoDetails; import com.hz.pm.api.user.util.LoginUserUtil; import com.ningdatech.basic.exception.BizException; @@ -91,9 +93,8 @@ public class ProjectRenewalFundManage { private final IGovBizProjectApproveService approveService; - private final RegionCacheHelper regionCacheHelper; - private final IPaymentPlanService paymentPlanService; + private final IProjectPaymentPlanService projectPaymentPlanService; /** * 项目续建资金库列表 分页 @@ -131,7 +132,14 @@ public class ProjectRenewalFundManage { return PageVo.empty(); } - List projectCodes = CollUtils.fieldList(page.getRecords(), Project::getProjectCode); + Set projectCodes = new HashSet<>(); + List projectIds = new ArrayList<>(); + for (Project project : page.getRecords()) { + projectIds.add(project.getId()); + projectCodes.add(project.getProjectCode()); + } + + Map> paymentPlansMap = projectPaymentPlanService.listByProjectIds(projectIds); Map> renewalMap; if (CollUtil.isNotEmpty(projectCodes)) { @@ -172,15 +180,20 @@ public class ProjectRenewalFundManage { item.setCanPreDeclared(Boolean.TRUE); } item.setApprovedAmount(w.getApprovalAmount()); - item.setAnnualPlanAmount(w.getAnnualPlanAmount()); + List paymentPlans = paymentPlansMap.getOrDefault(w.getId(), Collections.emptyList()); + BigDecimal totalAnnualPaymentAmount = paymentPlans.stream() + .map(ProjectPaymentPlan::getAnnualPlanAmount) + .reduce(BigDecimal::add).orElse(BigDecimal.ZERO); + + item.setAnnualPlanAmount(totalAnnualPaymentAmount); 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)); + item.setAnnualAccumulateAmount(ProjectLibManage.computeAmount(totalAnnualPaymentAmount, prfs)); + item.setAnnualAccumulateAmountList(ProjectLibManage.convertAccmulate(w, totalAnnualPaymentAmount, prfs)); } else { - item.setAnnualAccumulateAmount(w.getAnnualPlanAmount()); - item.setAnnualAccumulateAmountList(ProjectLibManage.convertAccmulate(w, Collections.emptyList())); + item.setAnnualAccumulateAmount(totalAnnualPaymentAmount); + item.setAnnualAccumulateAmountList(ProjectLibManage.convertAccmulate(w, totalAnnualPaymentAmount, Collections.emptyList())); } return item; }); @@ -223,11 +236,18 @@ public class ProjectRenewalFundManage { vo.setBuildOrgName(project.getBuildOrgName()); vo.setAnnualPaymentAmount(renewal.getAnnualPaymentAmount()); List annualAmounts = Lists.newArrayList(); + + List paymentPlans = projectPaymentPlanService.listByProjectId(project.getId()); + + BigDecimal totalAnnualPaymentAmount = paymentPlans.stream() + .map(ProjectPaymentPlan::getAnnualPlanAmount) + .reduce(BigDecimal::add).orElse(BigDecimal.ZERO); + annualAmounts.add(AnnualAmountVO.builder() .projectId(project.getId()) .projectCode(project.getProjectCode()) .projectYear(project.getProjectYear()) - .annualAmount(project.getAnnualPlanAmount()) + .annualAmount(totalAnnualPaymentAmount) .build()); List renewalDeclarations = projectRenewalFundDeclarationService.list(Wrappers.lambdaQuery(ProjectRenewalFundDeclaration.class) .eq(ProjectRenewalFundDeclaration::getProjectId, vo.getProjectId()) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/mapper/ProjectMapper.xml b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/mapper/ProjectMapper.xml index b26ca24..c60155c 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/mapper/ProjectMapper.xml +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/mapper/ProjectMapper.xml @@ -18,7 +18,6 @@ approval_amount, stage, status, - annual_plan_amount, biz_domain, inst_code, is_higher_super_org, @@ -41,7 +40,6 @@ approval_amount, stage, status, - annual_plan_amount, biz_domain, inst_code, is_higher_super_org, @@ -297,7 +295,6 @@ approval_amount, stage, status, - annual_plan_amount, biz_domain, inst_code, is_higher_super_org, @@ -320,7 +317,6 @@ approval_amount, stage, status, - annual_plan_amount, biz_domain, inst_code, is_higher_super_org, diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/dto/ProjectDTO.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/dto/ProjectDTO.java index 1952ac2..deadb2e 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/dto/ProjectDTO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/dto/ProjectDTO.java @@ -334,6 +334,9 @@ public class ProjectDTO implements Serializable { @ApiModelProperty("可研报告") private String baseResearchReportFile; + @ApiModelProperty("可研批复文件") + private String baseResearchReportApprovalFile; + @ApiModelProperty("其他附件") private String baseProjOtherFile; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/Project.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/Project.java index 59d6e5f..fa7949b 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/Project.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/Project.java @@ -209,30 +209,6 @@ public class Project implements Serializable { @Compare("资金分配情况-第三方服务") private BigDecimal thirdPartyAmount; - @ApiModelProperty("年度支付计划-年度支付计划(万元)") - @Compare("年度支付计划-年度支付计划") - private BigDecimal annualPlanAmount; - - @ApiModelProperty("年度支付计划-自有金额(万元)") - @Compare("年度支付计划-自有金额") - private BigDecimal annualPlanHaveAmount; - - @ApiModelProperty("年度支付计划-政府投资-本级财政资金(万元)") - @Compare("年度支付计划-政府投资-本级财政资金") - private BigDecimal annualPlanGovOwnFinanceAmount; - - @ApiModelProperty("年度支付计划-政府投资-上级补助资金(万元)") - @Compare("年度支付计划-政府投资-上级补助资金") - private BigDecimal annualPlanGovSuperiorFinanceAmount; - - @ApiModelProperty("年度支付计划-银行贷款(万元)") - @Compare("年度支付计划-银行贷款") - private BigDecimal annualPlanBankLendingAmount; - - @ApiModelProperty("年度支付计划-其它资金(万元)") - @Compare("年度支付计划-其它资金") - private BigDecimal annualPlanOtherAmount; - @ApiModelProperty("立项批复总投资(万元)") @Compare("立项批复总投资") private BigDecimal approvalAmount; @@ -535,6 +511,9 @@ public class Project implements Serializable { @ApiModelProperty("可研报告") private String baseResearchReportFile; + @ApiModelProperty("可研批复文件") + private String baseResearchReportApprovalFile; + @ApiModelProperty("其他附件") private String baseProjOtherFile; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/ProjectPaymentPlan.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/ProjectPaymentPlan.java index 3d4b601..cbeba84 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/ProjectPaymentPlan.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/ProjectPaymentPlan.java @@ -39,6 +39,8 @@ public class ProjectPaymentPlan implements Serializable { private BigDecimal annualPlanGovSuperiorFinanceAmount; + private Long projectId; + @ApiModelProperty("项目编码") private String projectCode; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/service/IProjectPaymentPlanService.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/service/IProjectPaymentPlanService.java index 3eff525..2e83374 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/service/IProjectPaymentPlanService.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/service/IProjectPaymentPlanService.java @@ -1,13 +1,19 @@ package com.hz.pm.api.projectlib.service; +import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.hz.pm.api.projectlib.model.entity.ProjectApplication; -import com.hz.pm.api.projectlib.model.entity.ProjectPaymentPlan; import com.baomidou.mybatisplus.extension.service.IService; +import com.hz.pm.api.projectlib.model.entity.ProjectPaymentPlan; +import com.ningdatech.basic.util.CollUtils; + +import java.util.Collection; +import java.util.List; +import java.util.Map; /** *

- * 服务类 + * 服务类 *

* * @author WendyYang @@ -21,4 +27,18 @@ public interface IProjectPaymentPlanService extends IService .eq(ProjectPaymentPlan::getProjectVersion, projectVersion)); } + default Map> listByProjectIds(Collection projectIds) { + LambdaQueryWrapper query = Wrappers.lambdaQuery(ProjectPaymentPlan.class) + .in(ProjectPaymentPlan::getProjectId, projectIds) + .orderByAsc(ProjectPaymentPlan::getPaymentYear); + return CollUtils.group(list(query), ProjectPaymentPlan::getProjectId); + } + + default List listByProjectId(Long projectId) { + LambdaQueryWrapper query = Wrappers.lambdaQuery(ProjectPaymentPlan.class) + .eq(ProjectPaymentPlan::getProjectId, projectId) + .orderByAsc(ProjectPaymentPlan::getPaymentYear); + return list(query); + } + } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/manage/TodoCenterManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/manage/TodoCenterManage.java index 563f9cc..9423264 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/manage/TodoCenterManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/manage/TodoCenterManage.java @@ -1414,8 +1414,8 @@ public class TodoCenterManage { paramsMap.put("cloudType", cloudTypeName); } // 获取本年计划投资金额 - BigDecimal yearPlanInvest = project.getAnnualPlanAmount(); - paramsMap.put("yearPlanInvest", yearPlanInvest); + // BigDecimal yearPlanInvest = project.getAnnualPlanAmount(); + paramsMap.put("yearPlanInvest", BigDecimal.ZERO); // 根据地区编码获取当地大数据局(中心)的名称 paramsMap.put("bigDataBureauName", null); // 备注模块如果为空