Przeglądaj źródła

表格装配工具类

tags/24080901
niohe·erbao 1 rok temu
rodzic
commit
d7b1e69871
2 zmienionych plików z 31 dodań i 26 usunięć
  1. +22
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/dashboard/helper/DashboardChartAssembler.java
  2. +9
    -26
      pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/DashboardExpertManage.java

+ 22
- 0
pmapi/src/main/java/com/ningdatech/pmapi/dashboard/helper/DashboardChartAssembler.java Wyświetl plik

@@ -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<Integer, List<Project>> projectGroupMap, ChartTypeEnum chartTypeEnum) {
AnalysisChart analysisChart = new AnalysisChart();
List<AnalysisData> dataList = new ArrayList<>();
@@ -81,4 +87,20 @@ public class DashboardChartAssembler {
}
return analysisChart;
}

public <T> AnalysisChart assemblerAnalysisChart(Map<String, List<T>> dictionaryCodeIdMap
, ChartTypeEnum chartTypeEnum) {
AnalysisChart analysisChart = new AnalysisChart();
List<AnalysisData> 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;
}
}

+ 9
- 26
pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/DashboardExpertManage.java Wyświetl plik

@@ -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<ExpertDictionary> titleLevelExpertDictionaryList = iExpertDictionaryService
.listByUserId(regionDegreeExpertIdList, DictExpertInfoTypeEnum.TITLE_LEVEL);
Map<String, List<String>> titleLevelCodeMap = titleLevelExpertDictionaryList.stream()
.map(ExpertDictionary::getDictionaryCode)
.collect(Collectors.groupingBy(Function.identity()));
Map<String, List<ExpertDictionary>> 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<String, List<String>> meetingTypeMap = normalMeetingList.stream().map(Meeting::getType)
.collect(Collectors.groupingBy(Function.identity()));
Map<String, List<Meeting>> 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<String, List<String>> dictionaryCodeIdMap
, ChartTypeEnum chartTypeEnum) {
AnalysisChart analysisChart = new AnalysisChart();
List<AnalysisData> 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;
}
}


Ładowanie…
Anuluj
Zapisz