From ee4b34ef1470e0a6290f86c355ca1d0d1d88daba Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Thu, 16 Nov 2023 16:22:50 +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 --- .../projectdeclared/manage/ConstructionManage.java | 3 ++ .../projectdeclared/model/entity/Contract.java | 3 ++ .../pmapi/projectdeclared/model/vo/ContractVO.java | 3 ++ .../pmapi/projectlib/manage/ProjectLibManage.java | 4 +- .../manage/ProjectRenewalFundManage.java | 49 ++++++++++++++++++++++ 5 files changed, 60 insertions(+), 2 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ConstructionManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ConstructionManage.java index 08a2b31..e4ece04 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ConstructionManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ConstructionManage.java @@ -91,6 +91,7 @@ public class ConstructionManage { LambdaQueryWrapper query = ProjectHelper.projectQuery(req); //建设中状态 query.eq(Project::getStatus, ProjectStatusEnum.UNDER_CONSTRUCTION.getCode()); + query.isNull(Project::getContractAmount); query.eq(Project::getStage, ProjectStatusEnum.PROJECT_APPROVED.getCode()); query.eq(Project::getNewest, Boolean.TRUE); //只能看自己单位的 @@ -193,6 +194,7 @@ public class ConstructionManage { LambdaQueryWrapper query = ProjectHelper.projectQuery(param); //待采购状态 query.eq(Project::getStatus, ProjectStatusEnum.UNDER_CONSTRUCTION.getCode()); + query.isNull(Project::getContractAmount); query.eq(Project::getStage, ProjectStatusEnum.PROJECT_APPROVED.getCode()); query.eq(Project::getNewest, Boolean.TRUE); query.orderByAsc(Project::getTransactionTime); @@ -314,6 +316,7 @@ public class ConstructionManage { contractEntity.setId(contract.getId()); } contractEntity.setProjectId(projectId); + contractEntity.setProjectCode(project.getProjectCode()); if (contractService.saveOrUpdate(contractEntity)) { //存 付款计划信心 if (Objects.nonNull(dto.getPayments())) { diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/entity/Contract.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/entity/Contract.java index 3d8a5a6..9774dc3 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/entity/Contract.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/entity/Contract.java @@ -67,4 +67,7 @@ public class Contract { @ApiModelProperty("项目ID") private Long projectId; + + @ApiModelProperty("项目编号") + private String projectCode; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/vo/ContractVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/vo/ContractVO.java index 4530e38..658b4e9 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/vo/ContractVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/vo/ContractVO.java @@ -72,6 +72,9 @@ public class ContractVO { @ApiModelProperty("项目ID") private Long projectId; + @ApiModelProperty("项目编号") + private String projectCode; + @ApiModelProperty("支付计划") private List payments; } 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 9378c9a..ac14006 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 @@ -581,12 +581,12 @@ public class ProjectLibManage { //查询合同备案 Contract contract = contractService.getOne(Wrappers.lambdaQuery(Contract.class) - .in(Contract::getProjectId, allVersionProjectId) + .eq(Contract::getProjectCode, projectInfo.getProjectCode()) .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) + .eq(PaymentPlan::getProjectCode, projectInfo.getProjectCode()) .orderByAsc(PaymentPlan::getPaymentTime)); if (Objects.nonNull(contractVO)) { contractVO.setPayments(convertPayments(payments, 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 b6b8c5f..313096f 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 @@ -32,6 +32,8 @@ 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.projectdeclared.model.entity.PaymentPlan; +import com.ningdatech.pmapi.projectdeclared.service.IPaymentPlanService; import com.ningdatech.pmapi.projectlib.enumeration.ProjectRenewalApprovalStatusEnum; import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeEnum; @@ -63,6 +65,7 @@ import org.springframework.stereotype.Component; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; @@ -94,6 +97,8 @@ public class ProjectRenewalFundManage { private final RegionCacheHelper regionCacheHelper; + private final IPaymentPlanService paymentPlanService; + /** * 项目续建资金库列表 分页 * @param req @@ -320,6 +325,7 @@ public class ProjectRenewalFundManage { * @return */ public Long declared(ProjectRenewalFundDeclarationDTO dto) { + Integer projectYear = dto.getProjectYear(); //要判断 项目id 是否 以及状态是 已验收 String projectCode = dto.getProjectCode(); Project project = projectService.getProjectByCode(projectCode); @@ -375,6 +381,9 @@ public class ProjectRenewalFundManage { .throwMessage("续建资金年度错误!"); } + //判断金额 + checkPaymentAmount(projectCode,projectYear,dto.getAnnualPaymentAmount()); + declaration.setApprovalStatus(ProjectRenewalApprovalStatusEnum.PENDING.name()); if(Objects.nonNull(project)){ declaration.setRegionCode(project.getAreaCode()); @@ -393,6 +402,46 @@ public class ProjectRenewalFundManage { return declaration.getId(); } + //判断金额 + private void checkPaymentAmount(String projectCode, Integer projectYear, BigDecimal annualPlanAmount) { + //判断金额问题 + //1 是否有该年度的合同支付计划 + List paymentPlans = paymentPlanService.list(Wrappers.lambdaQuery(PaymentPlan.class) + .eq(PaymentPlan::getProjectCode, projectCode) + .orderByAsc(PaymentPlan::getPaymentTime)); + VUtils.isTrue(CollUtil.isEmpty(paymentPlans)).throwMessage("未有所选年度的支付计划,无法提交"); + Boolean hasYearPlan = Boolean.FALSE; + + for(PaymentPlan plan : paymentPlans){ + if(Objects.isNull(plan.getPaymentTime())){ + continue; + } + int year = plan.getPaymentTime().getYear(); + if(Objects.nonNull(year) && projectYear.equals(year)){ + hasYearPlan = Boolean.TRUE; + //2 如果有 这一年的实际支付金额有没有填 + VUtils.isTrue(Objects.isNull(plan.getActualPaymentAmount())) + .throwMessage("未填写当年度的实际支付金额,请去合同备案补充"); + } + } + VUtils.isTrue(!hasYearPlan).throwMessage("未有所选年度的支付计划,无法提交"); + + //3. 算出 所能申报的最大金额 + //3.1 算出 申报年 以及 之前的所有合同计划金额 + Double planSum = paymentPlans.stream().filter(c -> Objects.nonNull(c.getPaymentTime()) && + (c.getPaymentTime().getYear() - projectYear) <= 0) + .mapToDouble(c -> Objects.nonNull(c.getPaymentAmount()) ? c.getPaymentAmount().doubleValue() : 0.0) + .sum(); + + Double actualPlanSum = paymentPlans.stream().filter(c -> Objects.nonNull(c.getPaymentTime()) && + (c.getPaymentTime().getYear() - projectYear) < 0) + .mapToDouble(c -> Objects.nonNull(c.getActualPaymentAmount()) ? c.getActualPaymentAmount().doubleValue() : 0.0) + .sum(); + Double maxAmount = planSum - actualPlanSum; + VUtils.isTrue(annualPlanAmount.compareTo(BigDecimal.valueOf(maxAmount)) > 0).throwMessage("所填年度支付金额 超出 最大限额"); + } + + /** * 续建项目审核 * @param param