|
@@ -3,10 +3,6 @@ package com.ningdatech.pmapi.dashboard.manage; |
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
import com.google.common.collect.Lists; |
|
|
import com.google.common.collect.Lists; |
|
|
import com.ningdatech.pmapi.common.constant.BizConst; |
|
|
|
|
|
import com.ningdatech.pmapi.common.statemachine.contants.RegionContant; |
|
|
|
|
|
import com.ningdatech.pmapi.dashboard.constant.DashboardConstant; |
|
|
|
|
|
import com.ningdatech.pmapi.dashboard.model.vo.ExpertStatisticsVO; |
|
|
|
|
|
import com.ningdatech.pmapi.dashboard.model.vo.FundStatisticsVO; |
|
|
import com.ningdatech.pmapi.dashboard.model.vo.FundStatisticsVO; |
|
|
import com.ningdatech.pmapi.gov.model.entity.GovBizProjectApply; |
|
|
import com.ningdatech.pmapi.gov.model.entity.GovBizProjectApply; |
|
|
import com.ningdatech.pmapi.gov.model.entity.GovBizProjectApprove; |
|
|
import com.ningdatech.pmapi.gov.model.entity.GovBizProjectApprove; |
|
@@ -19,26 +15,16 @@ import com.ningdatech.pmapi.gov.service.IGovBizProjectProcureService; |
|
|
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; |
|
|
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; |
|
|
import com.ningdatech.pmapi.projectlib.model.entity.Project; |
|
|
import com.ningdatech.pmapi.projectlib.model.entity.Project; |
|
|
import com.ningdatech.pmapi.projectlib.service.IProjectService; |
|
|
import com.ningdatech.pmapi.projectlib.service.IProjectService; |
|
|
import com.ningdatech.pmapi.sys.model.req.NoticeListReq; |
|
|
|
|
|
import com.ningdatech.pmapi.todocenter.model.req.ToBeProcessedReq; |
|
|
|
|
|
import com.ningdatech.pmapi.todocenter.model.vo.TodoCenterStatisticsVO; |
|
|
|
|
|
import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; |
|
|
|
|
|
import com.ningdatech.pmapi.user.util.LoginUserUtil; |
|
|
|
|
|
import com.ningdatech.pmapi.workbench.converter.WorkbenchConverter; |
|
|
|
|
|
import io.swagger.models.auth.In; |
|
|
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
|
import org.springframework.stereotype.Component; |
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
import java.time.LocalDateTime; |
|
|
import java.time.LocalDateTime; |
|
|
import java.util.Arrays; |
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
import java.util.Objects; |
|
|
|
|
|
|
|
|
import java.util.*; |
|
|
import java.util.concurrent.CompletableFuture; |
|
|
import java.util.concurrent.CompletableFuture; |
|
|
import java.util.concurrent.ForkJoinPool; |
|
|
import java.util.concurrent.ForkJoinPool; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
import java.util.stream.Stream; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @Classname FundStatisticsManage |
|
|
* @Classname FundStatisticsManage |
|
@@ -154,9 +140,23 @@ public class FundStatisticsManage { |
|
|
} |
|
|
} |
|
|
return Boolean.FALSE; |
|
|
return Boolean.FALSE; |
|
|
}).collect(Collectors.toList()); |
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
//计划核减 |
|
|
|
|
|
FundStatisticsVO.HeJianAmount planHejian = computePlanHeJian(normalProjects,applies,approves); |
|
|
|
|
|
//批复核减 |
|
|
|
|
|
FundStatisticsVO.HeJianAmount approvalHejian = computeApprovalHeJian(normalProjects,approves,planHejian.getApproval()); |
|
|
|
|
|
//合同核减 |
|
|
|
|
|
FundStatisticsVO.HeJianAmount contractHejian = computeContractHeJian(normalProjects,procures,approvalHejian.getApproval()); |
|
|
|
|
|
|
|
|
|
|
|
return planHejian.getDiff().add(approvalHejian.getDiff()).add(contractHejian.getDiff()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//计算 计划阶段的 核减金额 |
|
|
|
|
|
private FundStatisticsVO.HeJianAmount computePlanHeJian(List<Project> projects, List<GovBizProjectApply> applies, |
|
|
|
|
|
List<GovBizProjectApprove> approves) { |
|
|
|
|
|
FundStatisticsVO.HeJianAmount heJianAmount = new FundStatisticsVO.HeJianAmount(); |
|
|
|
|
|
|
|
|
//申报的申报金额(申报项目:初步方案申报金额 项目归集:项目总投资) |
|
|
//申报的申报金额(申报项目:初步方案申报金额 项目归集:项目总投资) |
|
|
BigDecimal declaredAmountApprove = normalProjects.stream().map(p -> { |
|
|
|
|
|
|
|
|
BigDecimal declaredAmountApprove = projects.stream().map(p -> { |
|
|
BigDecimal declareAmount = Objects.nonNull(p.getDeclareAmount()) ? |
|
|
BigDecimal declareAmount = Objects.nonNull(p.getDeclareAmount()) ? |
|
|
p.getDeclareAmount() : BigDecimal.ZERO; |
|
|
p.getDeclareAmount() : BigDecimal.ZERO; |
|
|
return declareAmount; |
|
|
return declareAmount; |
|
@@ -166,9 +166,10 @@ public class FundStatisticsManage { |
|
|
return totalAmount; |
|
|
return totalAmount; |
|
|
}).reduce(BigDecimal::add).get(); |
|
|
}).reduce(BigDecimal::add).get(); |
|
|
BigDecimal declaredAmountApproveTotal = declaredAmountApprove.add(declaredAmountApproveGov); |
|
|
BigDecimal declaredAmountApproveTotal = declaredAmountApprove.add(declaredAmountApproveGov); |
|
|
|
|
|
heJianAmount.setApprove(declaredAmountApproveTotal); |
|
|
|
|
|
|
|
|
//申报的批复金额(申报项目:建设方案申报金额 项目归集:建议总投资) |
|
|
//申报的批复金额(申报项目:建设方案申报金额 项目归集:建议总投资) |
|
|
BigDecimal approvalAmountApprove = normalProjects.stream().map(p -> { |
|
|
|
|
|
|
|
|
BigDecimal approvalAmountApprove = projects.stream().map(p -> { |
|
|
BigDecimal declareAmount = Objects.nonNull(p.getApprovalAmount()) ? p.getApprovalAmount() : BigDecimal.ZERO; |
|
|
BigDecimal declareAmount = Objects.nonNull(p.getApprovalAmount()) ? p.getApprovalAmount() : BigDecimal.ZERO; |
|
|
return declareAmount; |
|
|
return declareAmount; |
|
|
}).reduce(BigDecimal::add).get(); |
|
|
}).reduce(BigDecimal::add).get(); |
|
@@ -177,11 +178,20 @@ public class FundStatisticsManage { |
|
|
return expertTotalMoney; |
|
|
return expertTotalMoney; |
|
|
}).reduce(BigDecimal::add).get(); |
|
|
}).reduce(BigDecimal::add).get(); |
|
|
BigDecimal approvalAmountApproveTotal = approvalAmountApprove.add(approvalAmountApproveGov); |
|
|
BigDecimal approvalAmountApproveTotal = approvalAmountApprove.add(approvalAmountApproveGov); |
|
|
|
|
|
heJianAmount.setApproval(approvalAmountApproveTotal); |
|
|
//申报的差额 |
|
|
//申报的差额 |
|
|
BigDecimal subtractApprove = declaredAmountApproveTotal.subtract(approvalAmountApproveTotal); |
|
|
BigDecimal subtractApprove = declaredAmountApproveTotal.subtract(approvalAmountApproveTotal); |
|
|
|
|
|
heJianAmount.setDiff(subtractApprove); |
|
|
|
|
|
return heJianAmount; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//计算 批复阶段的 核减金额 |
|
|
|
|
|
private FundStatisticsVO.HeJianAmount computeApprovalHeJian(List<Project> projects,List<GovBizProjectApprove> approves, |
|
|
|
|
|
BigDecimal approvalAmountApproveTotal){ |
|
|
|
|
|
FundStatisticsVO.HeJianAmount approvalHejian = new FundStatisticsVO.HeJianAmount(); |
|
|
|
|
|
approvalHejian.setApprove(approvalAmountApproveTotal); |
|
|
//批复的批复金额(申报项目:归集信息建议批复总投资 项目归集:建议批复总投资) |
|
|
//批复的批复金额(申报项目:归集信息建议批复总投资 项目归集:建议批复总投资) |
|
|
BigDecimal approvalAmountApproval = normalProjects.stream().map(p -> { |
|
|
|
|
|
|
|
|
BigDecimal approvalAmountApproval = projects.stream().map(p -> { |
|
|
BigDecimal proposeTotalInvest = Objects.nonNull(p.getProposeTotalInvest()) ? p.getProposeTotalInvest() : BigDecimal.ZERO; |
|
|
BigDecimal proposeTotalInvest = Objects.nonNull(p.getProposeTotalInvest()) ? p.getProposeTotalInvest() : BigDecimal.ZERO; |
|
|
return proposeTotalInvest; |
|
|
return proposeTotalInvest; |
|
|
}).reduce(BigDecimal::add).get(); |
|
|
}).reduce(BigDecimal::add).get(); |
|
@@ -190,12 +200,20 @@ public class FundStatisticsManage { |
|
|
return reviewTotalMoney; |
|
|
return reviewTotalMoney; |
|
|
}).reduce(BigDecimal::add).get(); |
|
|
}).reduce(BigDecimal::add).get(); |
|
|
BigDecimal approvalAmountApprovalTotal = approvalAmountApproval.add(approvalAmountApprovalGov); |
|
|
BigDecimal approvalAmountApprovalTotal = approvalAmountApproval.add(approvalAmountApprovalGov); |
|
|
|
|
|
|
|
|
|
|
|
approvalHejian.setApproval(approvalAmountApprovalTotal); |
|
|
//批复的差额 |
|
|
//批复的差额 |
|
|
BigDecimal subtractApproval = approvalAmountApproveTotal.subtract(approvalAmountApprovalTotal); |
|
|
BigDecimal subtractApproval = approvalAmountApproveTotal.subtract(approvalAmountApprovalTotal); |
|
|
|
|
|
approvalHejian.setDiff(subtractApproval); |
|
|
|
|
|
return approvalHejian; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//计算 合同阶段的 核减金额 |
|
|
|
|
|
private FundStatisticsVO.HeJianAmount computeContractHeJian(List<Project> projects,List<GovBizProjectProcure> procures, |
|
|
|
|
|
BigDecimal approvalAmountApprovalTotal){ |
|
|
|
|
|
FundStatisticsVO.HeJianAmount contractHejian = new FundStatisticsVO.HeJianAmount(); |
|
|
|
|
|
contractHejian.setApprove(approvalAmountApprovalTotal); |
|
|
//合同的批复金额(申报项目:成交金额 项目归集:成交金额) |
|
|
//合同的批复金额(申报项目:成交金额 项目归集:成交金额) |
|
|
BigDecimal approvalAmountContract = normalProjects.stream().map(p -> { |
|
|
|
|
|
|
|
|
BigDecimal approvalAmountContract = projects.stream().map(p -> { |
|
|
BigDecimal transactionAmount = Objects.nonNull(p.getTransactionAmount()) ? p.getTransactionAmount() : BigDecimal.ZERO; |
|
|
BigDecimal transactionAmount = Objects.nonNull(p.getTransactionAmount()) ? p.getTransactionAmount() : BigDecimal.ZERO; |
|
|
return transactionAmount; |
|
|
return transactionAmount; |
|
|
}).reduce(BigDecimal::add).get(); |
|
|
}).reduce(BigDecimal::add).get(); |
|
@@ -205,10 +223,11 @@ public class FundStatisticsManage { |
|
|
return purchaseAmount; |
|
|
return purchaseAmount; |
|
|
}).reduce(BigDecimal::add).get(); |
|
|
}).reduce(BigDecimal::add).get(); |
|
|
BigDecimal approvalAmountContractTotal = approvalAmountContract.add(approvalAmountContractGov); |
|
|
BigDecimal approvalAmountContractTotal = approvalAmountContract.add(approvalAmountContractGov); |
|
|
|
|
|
contractHejian.setApproval(approvalAmountContractTotal); |
|
|
//合同的差额 |
|
|
//合同的差额 |
|
|
BigDecimal subtractContract = approvalAmountApprovalTotal.subtract(approvalAmountContractTotal); |
|
|
BigDecimal subtractContract = approvalAmountApprovalTotal.subtract(approvalAmountContractTotal); |
|
|
|
|
|
|
|
|
return subtractApprove.add(subtractApproval).add(subtractContract); |
|
|
|
|
|
|
|
|
contractHejian.setDiff(subtractContract); |
|
|
|
|
|
return contractHejian; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@@ -353,15 +372,65 @@ public class FundStatisticsManage { |
|
|
.map(p -> Objects.nonNull(p.getBaseProjPurchaseAmount()) ? p.getBaseProjPurchaseAmount() : BigDecimal.ZERO) |
|
|
.map(p -> Objects.nonNull(p.getBaseProjPurchaseAmount()) ? p.getBaseProjPurchaseAmount() : BigDecimal.ZERO) |
|
|
.reduce(BigDecimal::add).get(); |
|
|
.reduce(BigDecimal::add).get(); |
|
|
res.setApprovalTotalAmount(contractTotalAmount.add(contractTotalAmountGov)); |
|
|
res.setApprovalTotalAmount(contractTotalAmount.add(contractTotalAmountGov)); |
|
|
|
|
|
|
|
|
|
|
|
//计划核减 |
|
|
|
|
|
FundStatisticsVO.HeJianAmount planHejian = computePlanHeJian(projects,applies,approves); |
|
|
|
|
|
//批复核减 |
|
|
|
|
|
FundStatisticsVO.HeJianAmount approvalHejian = computeApprovalHeJian(projects,approves,planHejian.getApproval()); |
|
|
|
|
|
//合同核减 |
|
|
|
|
|
FundStatisticsVO.HeJianAmount contractHejian = computeContractHeJian(projects,procures,approvalHejian.getApproval()); |
|
|
|
|
|
res.setPlanDeduction(planHejian); |
|
|
|
|
|
res.setApprovalDeduction(approvalHejian); |
|
|
|
|
|
res.setContractDeduction(contractHejian); |
|
|
|
|
|
|
|
|
|
|
|
//部门TOP10 |
|
|
|
|
|
res.setDepartmentTop10(computeTop10(projects,baseInfos,applies,approves,procures)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 专家统计 |
|
|
|
|
|
* @param year |
|
|
|
|
|
|
|
|
* 计算 部门TOP10 |
|
|
|
|
|
* @param projects |
|
|
|
|
|
* @param applies |
|
|
|
|
|
* @param approves |
|
|
|
|
|
* @param procures |
|
|
* @return |
|
|
* @return |
|
|
*/ |
|
|
*/ |
|
|
public ExpertStatisticsVO expert(Integer year) { |
|
|
|
|
|
ExpertStatisticsVO res = new ExpertStatisticsVO(); |
|
|
|
|
|
|
|
|
private List<FundStatisticsVO.AmountData> computeTop10(List<Project> projects,List<GovBizProjectBaseinfo> baseInfos, |
|
|
|
|
|
List<GovBizProjectApply> applies, List<GovBizProjectApprove> approves, |
|
|
|
|
|
List<GovBizProjectProcure> procures) { |
|
|
|
|
|
//申报项目颗粒度 |
|
|
|
|
|
List<FundStatisticsVO.AmountData> orgAmounts = projects.stream().map(p -> { |
|
|
|
|
|
FundStatisticsVO.AmountData orgAmount = new FundStatisticsVO.AmountData(); |
|
|
|
|
|
orgAmount.setName(p.getBuildOrgName()); |
|
|
|
|
|
orgAmount.setAmount(completeDeductionAmount(Lists.newArrayList(p), |
|
|
|
|
|
Collections.emptyList(), Collections.emptyList(), |
|
|
|
|
|
Collections.emptyList())); |
|
|
|
|
|
return orgAmount; |
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, List<GovBizProjectApply>> applyMap = applies.stream().collect(Collectors |
|
|
|
|
|
.groupingBy(GovBizProjectApply::getBaseProjId)); |
|
|
|
|
|
Map<String, List<GovBizProjectApprove>> approveMap = approves.stream().collect(Collectors |
|
|
|
|
|
.groupingBy(GovBizProjectApprove::getBaseProjId)); |
|
|
|
|
|
Map<String, List<GovBizProjectProcure>> procureMap = procures.stream().collect(Collectors |
|
|
|
|
|
.groupingBy(GovBizProjectProcure::getBaseProjId)); |
|
|
|
|
|
|
|
|
|
|
|
//项目归集颗粒度 |
|
|
|
|
|
List<FundStatisticsVO.AmountData> orgAmountsGov = baseInfos.stream().map(p -> { |
|
|
|
|
|
FundStatisticsVO.AmountData orgAmount = new FundStatisticsVO.AmountData(); |
|
|
|
|
|
orgAmount.setName(p.getBaseBuildDeprt()); |
|
|
|
|
|
List<GovBizProjectApply> appliesThis = applyMap.getOrDefault(p.getBaseProjId(), Collections.emptyList()); |
|
|
|
|
|
List<GovBizProjectApprove> approvesThis = approveMap.getOrDefault(p.getBaseProjId(), Collections.emptyList()); |
|
|
|
|
|
List<GovBizProjectProcure> procuresThis = procureMap.getOrDefault(p.getBaseProjId(), Collections.emptyList()); |
|
|
|
|
|
orgAmount.setAmount(completeDeductionAmount(Collections.emptyList(), |
|
|
|
|
|
appliesThis, approvesThis,procuresThis)); |
|
|
|
|
|
return orgAmount; |
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
//求出TOP10 |
|
|
|
|
|
List<FundStatisticsVO.AmountData> res = Stream.concat(orgAmounts.stream(), orgAmountsGov.stream()) |
|
|
|
|
|
.sorted(Comparator.comparing(FundStatisticsVO.AmountData::getAmount).reversed()) |
|
|
|
|
|
.limit(10).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
return res; |
|
|
return res; |
|
|
} |
|
|
} |
|
|