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 49a550c..749f350 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 @@ -4,8 +4,10 @@ import cn.hutool.core.collection.CollUtil; import com.ningdatech.pmapi.dashboard.constant.ChartTypeEnum; import com.ningdatech.pmapi.dashboard.model.basic.AnalysisChart; import com.ningdatech.pmapi.dashboard.model.basic.AnalysisData; +import com.ningdatech.pmapi.meta.helper.DictionaryCache; import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; import com.ningdatech.pmapi.projectlib.model.entity.Project; +import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; import java.math.BigDecimal; @@ -20,8 +22,12 @@ import java.util.Objects; */ @Component +@RequiredArgsConstructor public class DashboardChartAssembler { + private final DictionaryCache dictionaryCache; + + public static AnalysisChart buildProjectStateAnalysisChart(Map> projectGroupMap, ChartTypeEnum chartTypeEnum) { AnalysisChart analysisChart = new AnalysisChart(); List dataList = new ArrayList<>(); @@ -81,4 +87,20 @@ public class DashboardChartAssembler { } return analysisChart; } + + public AnalysisChart assemblerAnalysisChart(Map> dictionaryCodeIdMap + , ChartTypeEnum chartTypeEnum) { + AnalysisChart analysisChart = new AnalysisChart(); + List dataList = new ArrayList<>(); + analysisChart.setChartType(chartTypeEnum); + analysisChart.setDataList(dataList); + + for (String dictionaryCode : dictionaryCodeIdMap.keySet()) { + AnalysisData analysisData = new AnalysisData(); + analysisData.setKey(dictionaryCache.getByCode(dictionaryCode).getName()); + analysisData.setValue(dictionaryCodeIdMap.get(dictionaryCode).size()); + dataList.add(analysisData); + } + return analysisChart; + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/DashboardExpertManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/DashboardExpertManage.java index da311cc..d53a236 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/DashboardExpertManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/DashboardExpertManage.java @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ningdatech.pmapi.dashboard.constant.ChartTypeEnum; +import com.ningdatech.pmapi.dashboard.helper.DashboardChartAssembler; import com.ningdatech.pmapi.dashboard.helper.DashboardHelper; import com.ningdatech.pmapi.dashboard.model.basic.AnalysisChart; import com.ningdatech.pmapi.dashboard.model.basic.AnalysisData; @@ -19,7 +20,6 @@ import com.ningdatech.pmapi.meeting.entity.enumeration.MeetingStatusEnum; import com.ningdatech.pmapi.meeting.service.IMeetingExpertJudgeService; import com.ningdatech.pmapi.meeting.service.IMeetingService; import com.ningdatech.pmapi.meta.constant.DictExpertInfoTypeEnum; -import com.ningdatech.pmapi.meta.helper.DictionaryCache; import com.ningdatech.pmapi.meta.model.entity.ExpertDictionary; import com.ningdatech.pmapi.meta.service.IExpertDictionaryService; import lombok.RequiredArgsConstructor; @@ -41,9 +41,10 @@ public class DashboardExpertManage { private final DashboardHelper dashboardHelper; private final IExpertUserFullInfoService iExpertUserFullInfoService; private final IMeetingService iMeetingService; - private final DictionaryCache dictionaryCache; + // private final DictionaryCache dictionaryCache; private final IMeetingExpertJudgeService iMeetingExpertJudgeService; private final IExpertDictionaryService iExpertDictionaryService; + private final DashboardChartAssembler dashboardChartAssembler; public ExpertDashboardSummaryVO getExpertDashboardSummary(QueryYearPO queryYearPO) { @@ -102,17 +103,16 @@ public class DashboardExpertManage { .map(ExpertDictionary::getDictionaryCode) .collect(Collectors.groupingBy(Function.identity())); AnalysisChart regionExpertEducationChartAnalysisChart = - assemblerAnalysisChart(degreeCodeMap, ChartTypeEnum.REGION_EXPERT_EDUCATION_CHART); + dashboardChartAssembler.assemblerAnalysisChart(degreeCodeMap, ChartTypeEnum.REGION_EXPERT_EDUCATION_CHART); analysisChartList.add(regionExpertEducationChartAnalysisChart); // 区域职称级别分布 List titleLevelExpertDictionaryList = iExpertDictionaryService .listByUserId(regionDegreeExpertIdList, DictExpertInfoTypeEnum.TITLE_LEVEL); - Map> titleLevelCodeMap = titleLevelExpertDictionaryList.stream() - .map(ExpertDictionary::getDictionaryCode) - .collect(Collectors.groupingBy(Function.identity())); + Map> titleLevelCodeMap = titleLevelExpertDictionaryList.stream() + .collect(Collectors.groupingBy(ExpertDictionary::getDictionaryCode)); AnalysisChart regionExpertTitleLevelChartAnalysisChart = - assemblerAnalysisChart(titleLevelCodeMap, ChartTypeEnum.REGION_EXPERT_TITLE_LEVEL_CHART); + dashboardChartAssembler.assemblerAnalysisChart(titleLevelCodeMap, ChartTypeEnum.REGION_EXPERT_TITLE_LEVEL_CHART); analysisChartList.add(regionExpertTitleLevelChartAnalysisChart); } @@ -123,10 +123,9 @@ public class DashboardExpertManage { Integer meetingCnt = normalMeetingList.size(); // 各类型评审次数 - Map> meetingTypeMap = normalMeetingList.stream().map(Meeting::getType) - .collect(Collectors.groupingBy(Function.identity())); + Map> meetingTypeMap = normalMeetingList.stream().collect(Collectors.groupingBy(Meeting::getType)); AnalysisChart meetingTypeCntChartAnalysisChart = - assemblerAnalysisChart(meetingTypeMap, ChartTypeEnum.MEETING_TYPE_CNT_CHART); + dashboardChartAssembler.assemblerAnalysisChart(meetingTypeMap, ChartTypeEnum.MEETING_TYPE_CNT_CHART); analysisChartList.add(meetingTypeCntChartAnalysisChart); // 明星专家列表 @@ -165,21 +164,5 @@ public class DashboardExpertManage { return expertDashboardSummaryVO; } - - private AnalysisChart assemblerAnalysisChart(Map> dictionaryCodeIdMap - , ChartTypeEnum chartTypeEnum) { - AnalysisChart analysisChart = new AnalysisChart(); - List dataList = new ArrayList<>(); - analysisChart.setChartType(chartTypeEnum); - analysisChart.setDataList(dataList); - - for (String dictionaryCode : dictionaryCodeIdMap.keySet()) { - AnalysisData analysisData = new AnalysisData(); - analysisData.setKey(dictionaryCache.getByCode(dictionaryCode).getName()); - analysisData.setValue(dictionaryCodeIdMap.get(dictionaryCode).size()); - dataList.add(analysisData); - } - return analysisChart; - } }