diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/constant/ChartTypeEnum.java b/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/constant/ChartTypeEnum.java index 29b1779..cdcb0ec 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/constant/ChartTypeEnum.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/constant/ChartTypeEnum.java @@ -50,5 +50,16 @@ public enum ChartTypeEnum { /** * 各阶段项目数量 */ - PROJECTS_NUMBER_IN_EACH_STAGE_CHART + PROJECTS_NUMBER_IN_EACH_STAGE_CHART, + + /** + * 各领域项目投资金额 + */ + PROJECTS_INVESTMENT_AMOUNT_IN_VARIOUS_FIELDS_CHART, + + /** + * 各区域项目投资情况 + */ + PROJECTS_INVESTMENT_SITUATION_IN_VARIOUS_REGIONS + } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/helper/DashboardChartAssembler.java b/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/helper/DashboardChartAssembler.java index 19115cd..49a550c 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/helper/DashboardChartAssembler.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/helper/DashboardChartAssembler.java @@ -8,9 +8,11 @@ import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; import com.ningdatech.pmapi.projectlib.model.entity.Project; import org.springframework.stereotype.Component; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Objects; /** * @author liuxinxin @@ -36,6 +38,33 @@ public class DashboardChartAssembler { return analysisChart; } + public static AnalysisChart buildInvestmentAnalysisChart(Map keyValueMap + , Map> projectGroupMap, ChartTypeEnum chartTypeEnum) { + AnalysisChart analysisChart = new AnalysisChart(); + List dataList = new ArrayList<>(); + analysisChart.setChartType(chartTypeEnum); + analysisChart.setDataList(dataList); + for (T key : keyValueMap.keySet()) { + AnalysisData analysisData = new AnalysisData(); + String chartKey = keyValueMap.get(key); + List projectList = projectGroupMap.get(key); + + BigDecimal approvedTotalInvestmentIncreaseSum = new BigDecimal("0"); + if (CollUtil.isNotEmpty(projectList)) { + for (Project project : projectList) { + BigDecimal approvedTotalInvestmentIncrease = project.getApprovedTotalInvestmentIncrease(); + if (Objects.nonNull(approvedTotalInvestmentIncrease)) { + approvedTotalInvestmentIncreaseSum.add(approvedTotalInvestmentIncrease); + } + } + } + analysisData.setKey(chartKey); + analysisData.setValue(approvedTotalInvestmentIncreaseSum); + dataList.add(analysisData); + } + return analysisChart; + } + public static AnalysisChart buildAnalysisChart(Map keyValueMap , Map> projectGroupMap, ChartTypeEnum chartTypeEnum) { AnalysisChart analysisChart = new AnalysisChart(); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/DashboardProjectManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/DashboardProjectManage.java index 36b45b2..3930c50 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/DashboardProjectManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/DashboardProjectManage.java @@ -186,12 +186,11 @@ public class DashboardProjectManage { // 预算年度 Integer year = queryYearPO.getYear(); String regionCode = queryYearPO.getRegionCode(); - List allProjectWithRepeatList = iProjectService.list(Wrappers.lambdaQuery(Project.class) + List allProjectList = iProjectService.list(Wrappers.lambdaQuery(Project.class) + .eq(Project::getNewest, true) .eq(Objects.nonNull(year), Project::getProjectYear, year) .eq(StringUtils.isNotBlank(regionCode), Project::getAreaCode, regionCode) ); - List allProjectList = allProjectWithRepeatList.stream() - .filter(r -> r.getNewest()).collect(Collectors.toList()); // 项目增补情况 Map> isTemporaryAugmentGroupMap = allProjectList.stream() @@ -240,9 +239,34 @@ public class DashboardProjectManage { public DashboardInvestmentSummaryVO getInvestmentSummary(QueryYearPO queryYearPO) { - QueryTimeYearBO queryTimeYearBO = getQueryTimeYearBO(queryYearPO.getYear()); + // 预算年度 + Integer year = queryYearPO.getYear(); + String regionCode = queryYearPO.getRegionCode(); + List allProjectList = iProjectService.list(Wrappers.lambdaQuery(Project.class) + .eq(Project::getNewest, true) + .eq(Objects.nonNull(year), Project::getProjectYear, year) + .eq(StringUtils.isNotBlank(regionCode), Project::getAreaCode, regionCode) + ); + + // 各领域项目投资情况 + Map> bizDomainGroupMap = allProjectList.stream() + .collect(Collectors.groupingBy(Project::getBizDomain)); + Map bizDomainMap = dashboardHelper.getBizDomainMap(); + AnalysisChart bizDomainInvestmentAnalysisChart = DashboardChartAssembler.buildInvestmentAnalysisChart(bizDomainMap, bizDomainGroupMap + , ChartTypeEnum.PROJECTS_INVESTMENT_AMOUNT_IN_VARIOUS_FIELDS_CHART); + + // 各区域项目投资情况 + Map> areaCodeGroupMap = allProjectList.stream() + .collect(Collectors.groupingBy(Project::getAreaCode)); + Map liShuiRegionCodeNameMap = dashboardHelper.getLiShuiRegionCodeNameMap(); + AnalysisChart areaCodeInvestmentAnalysisChart = DashboardChartAssembler.buildInvestmentAnalysisChart(liShuiRegionCodeNameMap, areaCodeGroupMap + , ChartTypeEnum.PROJECTS_INVESTMENT_SITUATION_IN_VARIOUS_REGIONS); DashboardInvestmentSummaryVO dashboardInvestmentSummaryVO = new DashboardInvestmentSummaryVO(); + List analysisChartList = new ArrayList<>(); + dashboardInvestmentSummaryVO.setAnalysisChartList(analysisChartList); + analysisChartList.add(areaCodeInvestmentAnalysisChart); + analysisChartList.add(bizDomainInvestmentAnalysisChart); return dashboardInvestmentSummaryVO; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/model/vo/DashboardInvestmentSummaryVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/model/vo/DashboardInvestmentSummaryVO.java index a4b26d6..11f6d00 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/model/vo/DashboardInvestmentSummaryVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/model/vo/DashboardInvestmentSummaryVO.java @@ -1,8 +1,12 @@ package com.ningdatech.pmapi.dashboard.model.vo; +import com.ningdatech.pmapi.dashboard.model.basic.AnalysisChart; import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.util.List; + /** * @author liuxinxin * @date 2023/8/2 下午3:36 @@ -13,11 +17,13 @@ import lombok.Data; public class DashboardInvestmentSummaryVO { /** - * 各领域项目投资金额 * 单位预算TOP5 * 项目预算TOP5 * 近5年项目投资走势 - * 各区域项目投资情况 * 近5年资金核定率走势 */ + + @ApiModelProperty("各领域项目投资金额,各区域项目投资情况") + List analysisChartList; + }