|
|
@@ -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<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 |
|
|
|