|
|
@@ -8,16 +8,22 @@ import com.ningdatech.pmapi.dashboard.model.vo.DashboardProjectCntSummaryVO; |
|
|
|
import com.ningdatech.pmapi.dashboard.model.vo.DashboardProjectSummaryVO; |
|
|
|
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.entity.Project; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.entity.ProjectDelayApply; |
|
|
|
import com.ningdatech.pmapi.projectlib.service.INdProjectDelayApplyService; |
|
|
|
import com.ningdatech.pmapi.projectlib.service.IProjectService; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.LocalTime; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.time.temporal.TemporalAdjusters; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Objects; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
@@ -31,6 +37,7 @@ public class DashboardProjectManage { |
|
|
|
|
|
|
|
private static String timeFormat = "%s-01-01 00:00:00"; |
|
|
|
private final IProjectService iProjectService; |
|
|
|
private final INdProjectDelayApplyService iProjectDelayApplyService; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
@@ -66,10 +73,12 @@ public class DashboardProjectManage { |
|
|
|
public DashboardProjectSummaryVO getProjectSummary(QueryYearPO queryYearPO) { |
|
|
|
// 预算年度 |
|
|
|
Integer year = queryYearPO.getYear(); |
|
|
|
QueryTimeYearBO queryTimeYearBO = getQueryTimeYearBO(queryYearPO.getYear()); |
|
|
|
List<Project> allProjectList = iProjectService.list(Wrappers.lambdaQuery(Project.class) |
|
|
|
.eq(Project::getNewest, true) |
|
|
|
List<Project> allProjectWithRepeatList = iProjectService.list(Wrappers.lambdaQuery(Project.class) |
|
|
|
.eq(Project::getProjectYear, year)); |
|
|
|
List<Project> allProjectList = allProjectWithRepeatList.stream() |
|
|
|
.filter(r -> r.getNewest()).collect(Collectors.toList()); |
|
|
|
|
|
|
|
List<Long> allProjectIdWithRepeatList = allProjectWithRepeatList.stream().map(Project::getId).collect(Collectors.toList()); |
|
|
|
|
|
|
|
// 项目总数 |
|
|
|
Integer projectCnt = allProjectList.size(); |
|
|
@@ -83,8 +92,6 @@ public class DashboardProjectManage { |
|
|
|
// 已立项项目数 |
|
|
|
Integer approvedProjectCnt = projectCnt - toBeApprovedProjectCnt; |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// 项目画像 |
|
|
|
// * 项目立项率 |
|
|
|
// * 项目申报总金额 |
|
|
@@ -93,16 +100,58 @@ public class DashboardProjectManage { |
|
|
|
// * 资金核定率 |
|
|
|
// * 延期项目数 |
|
|
|
// * 延期占比 |
|
|
|
// * 项目变更数量 |
|
|
|
// * 项目变更金额 |
|
|
|
|
|
|
|
|
|
|
|
// 延期项目数 延期占比 |
|
|
|
List<ProjectDelayApply> projectDelayApplyList = iProjectDelayApplyService |
|
|
|
.list(Wrappers.lambdaQuery(ProjectDelayApply.class) |
|
|
|
.in(ProjectDelayApply::getProjectId, allProjectIdWithRepeatList)); |
|
|
|
Map<Long, List<ProjectDelayApply>> projectDelayApplyListMap = projectDelayApplyList.stream().collect(Collectors.groupingBy(ProjectDelayApply::getProjectId)); |
|
|
|
Integer delayProjectCnt = projectDelayApplyListMap.keySet().size(); |
|
|
|
Double delayProportion = new BigDecimal((float) delayProjectCnt / projectCnt).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
|
|
|
|
|
|
|
|
// 项目变更数量 项目变更金额 |
|
|
|
List<Project> changedProjectList = new ArrayList<>(); |
|
|
|
Map<String, List<Project>> allProjectMap = allProjectWithRepeatList.stream().collect(Collectors.groupingBy(Project::getProjectCode)); |
|
|
|
for (String projectCode : allProjectMap.keySet()) { |
|
|
|
List<Project> projectList = allProjectMap.get(projectCode); |
|
|
|
Project newestProject = projectList.stream() |
|
|
|
.filter(r -> r.getNewest()) |
|
|
|
.collect(Collectors.toList()).get(0); |
|
|
|
Boolean isChanged = false; |
|
|
|
for (Project project : projectList) { |
|
|
|
Boolean newest = project.getNewest(); |
|
|
|
Boolean isBackReject = project.getIsBackReject(); |
|
|
|
if (!newest && isBackReject) { |
|
|
|
isChanged = true; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
if (isChanged) { |
|
|
|
changedProjectList.add(newestProject); |
|
|
|
} |
|
|
|
} |
|
|
|
Integer changedProjectCnt = changedProjectList.size(); |
|
|
|
|
|
|
|
// 项目变更金额 |
|
|
|
BigDecimal changedProjectContractAmountSum = new BigDecimal("0"); |
|
|
|
for (Project project : changedProjectList) { |
|
|
|
BigDecimal contractAmount = project.getContractAmount(); |
|
|
|
if (Objects.nonNull(contractAmount)) { |
|
|
|
changedProjectContractAmountSum.add(contractAmount); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 装配返回VO |
|
|
|
DashboardProjectSummaryVO dashboardProjectSummaryVO = new DashboardProjectSummaryVO(); |
|
|
|
dashboardProjectSummaryVO.setProjectCnt(projectCnt); |
|
|
|
dashboardProjectSummaryVO.setApprovedProjectCnt(approvedProjectCnt); |
|
|
|
dashboardProjectSummaryVO.setToBeApprovedProjectCnt(toBeApprovedProjectCnt); |
|
|
|
|
|
|
|
dashboardProjectSummaryVO.setDelayProjectCnt(delayProjectCnt); |
|
|
|
dashboardProjectSummaryVO.setDelayProportion(delayProportion); |
|
|
|
dashboardProjectSummaryVO.setChangedProjectCnt(changedProjectCnt); |
|
|
|
dashboardProjectSummaryVO.setChangedProjectContractAmountSum(changedProjectContractAmountSum); |
|
|
|
return dashboardProjectSummaryVO; |
|
|
|
} |
|
|
|
|
|
|
|