Browse Source

项目变更数量

项目变更金额
项目延期
延期占比
master
niohe·erbao 1 year ago
parent
commit
4661690e45
2 changed files with 71 additions and 15 deletions
  1. +57
    -8
      pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/DashboardProjectManage.java
  2. +14
    -7
      pmapi/src/main/java/com/ningdatech/pmapi/dashboard/model/vo/DashboardProjectSummaryVO.java

+ 57
- 8
pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/DashboardProjectManage.java View File

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



+ 14
- 7
pmapi/src/main/java/com/ningdatech/pmapi/dashboard/model/vo/DashboardProjectSummaryVO.java View File

@@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;

/**
* @author liuxinxin
* @date 2023/8/2 下午3:37
@@ -12,19 +14,12 @@ import lombok.Data;
@ApiModel("驾驶舱项目总览驶舱统计数据")
public class DashboardProjectSummaryVO {
/**
* 项目总数
* 待立项项目数
* 已立项项目数
* 项目画像
* 项目立项率
* 项目申报总金额
* 项目批复总金额
* 项目采购总金额
* 资金核定率
* 延期项目数
* 延期占比
* 项目变更数量
* 项目变更金额
*/

@ApiModelProperty("项目总数")
@@ -36,5 +31,17 @@ public class DashboardProjectSummaryVO {
@ApiModelProperty("已立项项目数")
private Integer approvedProjectCnt;

@ApiModelProperty("延期项目数")
private Integer delayProjectCnt;

@ApiModelProperty("延期占比")
private Double delayProportion;

@ApiModelProperty("项目变更数量")
private Integer changedProjectCnt;

@ApiModelProperty("项目变更金额")
private BigDecimal changedProjectContractAmountSum;


}

Loading…
Cancel
Save