Browse Source

续建项目 能关联的项目

master
PoffyZhang 11 months ago
parent
commit
ee4b34ef14
5 changed files with 60 additions and 2 deletions
  1. +3
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ConstructionManage.java
  2. +3
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/entity/Contract.java
  3. +3
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/vo/ContractVO.java
  4. +2
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java
  5. +49
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectRenewalFundManage.java

+ 3
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ConstructionManage.java View File

@@ -91,6 +91,7 @@ public class ConstructionManage {
LambdaQueryWrapper<Project> query = ProjectHelper.projectQuery(req); LambdaQueryWrapper<Project> query = ProjectHelper.projectQuery(req);
//建设中状态 //建设中状态
query.eq(Project::getStatus, ProjectStatusEnum.UNDER_CONSTRUCTION.getCode()); query.eq(Project::getStatus, ProjectStatusEnum.UNDER_CONSTRUCTION.getCode());
query.isNull(Project::getContractAmount);
query.eq(Project::getStage, ProjectStatusEnum.PROJECT_APPROVED.getCode()); query.eq(Project::getStage, ProjectStatusEnum.PROJECT_APPROVED.getCode());
query.eq(Project::getNewest, Boolean.TRUE); query.eq(Project::getNewest, Boolean.TRUE);
//只能看自己单位的 //只能看自己单位的
@@ -193,6 +194,7 @@ public class ConstructionManage {
LambdaQueryWrapper<Project> query = ProjectHelper.projectQuery(param); LambdaQueryWrapper<Project> query = ProjectHelper.projectQuery(param);
//待采购状态 //待采购状态
query.eq(Project::getStatus, ProjectStatusEnum.UNDER_CONSTRUCTION.getCode()); query.eq(Project::getStatus, ProjectStatusEnum.UNDER_CONSTRUCTION.getCode());
query.isNull(Project::getContractAmount);
query.eq(Project::getStage, ProjectStatusEnum.PROJECT_APPROVED.getCode()); query.eq(Project::getStage, ProjectStatusEnum.PROJECT_APPROVED.getCode());
query.eq(Project::getNewest, Boolean.TRUE); query.eq(Project::getNewest, Boolean.TRUE);
query.orderByAsc(Project::getTransactionTime); query.orderByAsc(Project::getTransactionTime);
@@ -314,6 +316,7 @@ public class ConstructionManage {
contractEntity.setId(contract.getId()); contractEntity.setId(contract.getId());
} }
contractEntity.setProjectId(projectId); contractEntity.setProjectId(projectId);
contractEntity.setProjectCode(project.getProjectCode());
if (contractService.saveOrUpdate(contractEntity)) { if (contractService.saveOrUpdate(contractEntity)) {
//存 付款计划信心 //存 付款计划信心
if (Objects.nonNull(dto.getPayments())) { if (Objects.nonNull(dto.getPayments())) {


+ 3
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/entity/Contract.java View File

@@ -67,4 +67,7 @@ public class Contract {


@ApiModelProperty("项目ID") @ApiModelProperty("项目ID")
private Long projectId; private Long projectId;

@ApiModelProperty("项目编号")
private String projectCode;
} }

+ 3
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/vo/ContractVO.java View File

@@ -72,6 +72,9 @@ public class ContractVO {
@ApiModelProperty("项目ID") @ApiModelProperty("项目ID")
private Long projectId; private Long projectId;


@ApiModelProperty("项目编号")
private String projectCode;

@ApiModelProperty("支付计划") @ApiModelProperty("支付计划")
private List<PaymentPlanVO> payments; private List<PaymentPlanVO> payments;
} }

+ 2
- 2
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java View File

@@ -581,12 +581,12 @@ public class ProjectLibManage {


//查询合同备案 //查询合同备案
Contract contract = contractService.getOne(Wrappers.lambdaQuery(Contract.class) Contract contract = contractService.getOne(Wrappers.lambdaQuery(Contract.class)
.in(Contract::getProjectId, allVersionProjectId)
.eq(Contract::getProjectCode, projectInfo.getProjectCode())
.last(BizConst.LIMIT_1)); .last(BizConst.LIMIT_1));
ContractVO contractVO = BeanUtil.copyProperties(contract, ContractVO.class); ContractVO contractVO = BeanUtil.copyProperties(contract, ContractVO.class);
vo.setContract(contractVO); vo.setContract(contractVO);
List<PaymentPlan> payments = paymentPlanService.list(Wrappers.lambdaQuery(PaymentPlan.class) List<PaymentPlan> payments = paymentPlanService.list(Wrappers.lambdaQuery(PaymentPlan.class)
.in(PaymentPlan::getProjectId, allVersionProjectId)
.eq(PaymentPlan::getProjectCode, projectInfo.getProjectCode())
.orderByAsc(PaymentPlan::getPaymentTime)); .orderByAsc(PaymentPlan::getPaymentTime));
if (Objects.nonNull(contractVO)) { if (Objects.nonNull(contractVO)) {
contractVO.setPayments(convertPayments(payments, contractVO.setPayments(convertPayments(payments,


+ 49
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectRenewalFundManage.java View File

@@ -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.ProjectTag;
import com.ningdatech.pmapi.portrait.model.entity.Tag; import com.ningdatech.pmapi.portrait.model.entity.Tag;
import com.ningdatech.pmapi.projectdeclared.model.dto.ProjectRenewalDeclareExportDTO; 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.ProjectRenewalApprovalStatusEnum;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeEnum; import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeEnum;
@@ -63,6 +65,7 @@ import org.springframework.stereotype.Component;


import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -94,6 +97,8 @@ public class ProjectRenewalFundManage {


private final RegionCacheHelper regionCacheHelper; private final RegionCacheHelper regionCacheHelper;


private final IPaymentPlanService paymentPlanService;

/** /**
* 项目续建资金库列表 分页 * 项目续建资金库列表 分页
* @param req * @param req
@@ -320,6 +325,7 @@ public class ProjectRenewalFundManage {
* @return * @return
*/ */
public Long declared(ProjectRenewalFundDeclarationDTO dto) { public Long declared(ProjectRenewalFundDeclarationDTO dto) {
Integer projectYear = dto.getProjectYear();
//要判断 项目id 是否 以及状态是 已验收 //要判断 项目id 是否 以及状态是 已验收
String projectCode = dto.getProjectCode(); String projectCode = dto.getProjectCode();
Project project = projectService.getProjectByCode(projectCode); Project project = projectService.getProjectByCode(projectCode);
@@ -375,6 +381,9 @@ public class ProjectRenewalFundManage {
.throwMessage("续建资金年度错误!"); .throwMessage("续建资金年度错误!");
} }


//判断金额
checkPaymentAmount(projectCode,projectYear,dto.getAnnualPaymentAmount());

declaration.setApprovalStatus(ProjectRenewalApprovalStatusEnum.PENDING.name()); declaration.setApprovalStatus(ProjectRenewalApprovalStatusEnum.PENDING.name());
if(Objects.nonNull(project)){ if(Objects.nonNull(project)){
declaration.setRegionCode(project.getAreaCode()); declaration.setRegionCode(project.getAreaCode());
@@ -393,6 +402,46 @@ public class ProjectRenewalFundManage {
return declaration.getId(); return declaration.getId();
} }


//判断金额
private void checkPaymentAmount(String projectCode, Integer projectYear, BigDecimal annualPlanAmount) {
//判断金额问题
//1 是否有该年度的合同支付计划
List<PaymentPlan> 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 * @param param


Loading…
Cancel
Save