Browse Source

各区域专家总数学历分布职称级别分布明星专家评审次数各类型评审次数

master
niohe·erbao 1 year ago
parent
commit
7b1b6ff2fa
7 changed files with 217 additions and 3 deletions
  1. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/dashboard/constant/AnalysisBasicConstant.java
  2. +6
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/dashboard/constant/ChartTypeEnum.java
  3. +35
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/dashboard/helper/DashboardRegionHelper.java
  4. +169
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/DashboardExpertManage.java
  5. +2
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/DashboardProjectManage.java
  6. +2
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/dashboard/model/basic/AnalysisData.java
  7. +2
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/dashboard/model/po/QueryYearPO.java

+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/dashboard/constant/AnalysisBasicConstant.java View File

@@ -11,7 +11,7 @@ public class AnalysisBasicConstant {
/** /**
* 丽水市区域编码 * 丽水市区域编码
*/ */
private static final String LS_REGION_CODE = "331100";
public static final String LS_REGION_CODE = "331100";








+ 6
- 1
pmapi/src/main/java/com/ningdatech/pmapi/dashboard/constant/ChartTypeEnum.java View File

@@ -20,5 +20,10 @@ public enum ChartTypeEnum {
/** /**
* 各区域专家职称级别分布 * 各区域专家职称级别分布
*/ */
REGION_EXPERT_TITLE_LEVEL_CHART;
REGION_EXPERT_TITLE_LEVEL_CHART,

/**
* 各类型评审次数
*/
MEETING_TYPE_CNT_CHART;
} }

+ 35
- 0
pmapi/src/main/java/com/ningdatech/pmapi/dashboard/helper/DashboardRegionHelper.java View File

@@ -0,0 +1,35 @@
package com.ningdatech.pmapi.dashboard.helper;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ningdatech.pmapi.dashboard.constant.AnalysisBasicConstant;
import com.ningdatech.pmapi.sys.model.entity.Region;
import com.ningdatech.pmapi.sys.service.IRegionService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* @author liuxinxin
* @date 2023/8/3 下午3:13
*/

@Component
@RequiredArgsConstructor
public class DashboardRegionHelper {

private final IRegionService iRegionService;

/**
* 获取丽水区域相关信息
*/
public Map<String, String> getLiShuiRegionCodeNameMap() {
List<Region> regionList = iRegionService.list(Wrappers.lambdaQuery(Region.class)
.eq(Region::getParentCode, AnalysisBasicConstant.LS_REGION_CODE));
Map<String, String> regionCodeNameMap = regionList.stream().collect(Collectors.toMap(Region::getRegionCode, Region::getRegionName));
return regionCodeNameMap;
}

}

+ 169
- 1
pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/DashboardExpertManage.java View File

@@ -1,10 +1,34 @@
package com.ningdatech.pmapi.dashboard.manage; package com.ningdatech.pmapi.dashboard.manage;


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.DashboardRegionHelper;
import com.ningdatech.pmapi.dashboard.model.basic.AnalysisChart;
import com.ningdatech.pmapi.dashboard.model.basic.AnalysisData;
import com.ningdatech.pmapi.dashboard.model.basic.StarExpertBO;
import com.ningdatech.pmapi.dashboard.model.po.QueryYearPO; import com.ningdatech.pmapi.dashboard.model.po.QueryYearPO;
import com.ningdatech.pmapi.dashboard.model.vo.ExpertDashboardSummaryVO; import com.ningdatech.pmapi.dashboard.model.vo.ExpertDashboardSummaryVO;
import com.ningdatech.pmapi.expert.constant.ExpertUserInfoStepEnum;
import com.ningdatech.pmapi.expert.entity.ExpertUserFullInfo;
import com.ningdatech.pmapi.expert.service.IExpertUserFullInfoService;
import com.ningdatech.pmapi.meeting.entity.domain.Meeting;
import com.ningdatech.pmapi.meeting.entity.domain.MeetingExpertJudge;
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; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;


import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

/** /**
* @author liuxinxin * @author liuxinxin
* @date 2023/8/2 上午10:39 * @date 2023/8/2 上午10:39
@@ -14,10 +38,154 @@ import org.springframework.stereotype.Component;
@RequiredArgsConstructor @RequiredArgsConstructor
public class DashboardExpertManage { public class DashboardExpertManage {


private final DashboardRegionHelper dashboardRegionHelper;
private final IExpertUserFullInfoService iExpertUserFullInfoService;
private final IMeetingService iMeetingService;
private final DictionaryCache dictionaryCache;
private final IMeetingExpertJudgeService iMeetingExpertJudgeService;
private final IExpertDictionaryService iExpertDictionaryService;



public ExpertDashboardSummaryVO getExpertDashboardSummary(QueryYearPO queryYearPO) { public ExpertDashboardSummaryVO getExpertDashboardSummary(QueryYearPO queryYearPO) {
return null;
String queryRegionCode = queryYearPO.getRegionCode();
List<AnalysisChart> analysisChartList = new ArrayList<>();

// 获取丽水区域 code name Map
Map<String, String> liShuiRegionCodeNameMap = dashboardRegionHelper.getLiShuiRegionCodeNameMap();
// 获取库内所有的专家列表
List<ExpertUserFullInfo> evidenceHasBeenSubmittedExpertInfoList = iExpertUserFullInfoService.list(Wrappers.lambdaQuery(ExpertUserFullInfo.class)
.eq(ExpertUserFullInfo::getUserInfoStep, ExpertUserInfoStepEnum.EVIDENCE_HAS_BEEN_SUBMITTED.getKey()));

// 专家regionCode分组map列表
Map<String, List<ExpertUserFullInfo>> regionCodeExpertMap = evidenceHasBeenSubmittedExpertInfoList.stream()
.collect(Collectors.groupingBy(ExpertUserFullInfo::getRegionCode));

// 各区域专家数量
AnalysisChart regionExpertNumberChartAnalysisChart = new AnalysisChart();
List<AnalysisData> regionExpertNumberChartDataList = new ArrayList<>();
regionExpertNumberChartAnalysisChart.setChartType(ChartTypeEnum.REGION_EXPERT_NUMBER_CHART);
regionExpertNumberChartAnalysisChart.setDataList(regionExpertNumberChartDataList);
for (String regionCode : liShuiRegionCodeNameMap.keySet()) {
AnalysisData analysisData = new AnalysisData();
String regionName = liShuiRegionCodeNameMap.get(regionCode);
List<ExpertUserFullInfo> expertUserFullInfoList = regionCodeExpertMap.get(regionCode);
Integer expertCnt = 0;
if (CollectionUtil.isNotEmpty(expertUserFullInfoList)) {
expertCnt = expertUserFullInfoList.size();
}
analysisData.setKey(regionName);
analysisData.setValue(expertCnt);
regionExpertNumberChartDataList.add(analysisData);
}
analysisChartList.add(regionExpertNumberChartAnalysisChart);

// 查询区域的专家id 列表
List<Long> regionDegreeExpertIdList = new ArrayList<>();
if (StringUtils.isNotBlank(queryRegionCode)) {
List<ExpertUserFullInfo> expertUserFullInfoList = regionCodeExpertMap.get(queryRegionCode);
if (CollectionUtil.isNotEmpty(expertUserFullInfoList)) {
regionDegreeExpertIdList = expertUserFullInfoList.stream()
.map(ExpertUserFullInfo::getUserId)
.collect(Collectors.toList());
}
} else {
regionDegreeExpertIdList = evidenceHasBeenSubmittedExpertInfoList.stream()
.map(ExpertUserFullInfo::getUserId)
.collect(Collectors.toList());
}

if (CollectionUtil.isNotEmpty(regionDegreeExpertIdList)) {
// 区域学历分布
List<ExpertDictionary> degreeExpertDictionaryList = iExpertDictionaryService
.listByUserId(regionDegreeExpertIdList, DictExpertInfoTypeEnum.DEGREE);
Map<String, List<String>> degreeCodeMap = degreeExpertDictionaryList.stream()
.map(ExpertDictionary::getDictionaryCode)
.collect(Collectors.groupingBy(Function.identity()));
AnalysisChart regionExpertEducationChartAnalysisChart =
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()));
AnalysisChart regionExpertTitleLevelChartAnalysisChart =
assemblerAnalysisChart(titleLevelCodeMap, ChartTypeEnum.REGION_EXPERT_TITLE_LEVEL_CHART);
analysisChartList.add(regionExpertTitleLevelChartAnalysisChart);

}


// 评审次数
List<Meeting> normalMeetingList = iMeetingService.list(Wrappers.lambdaQuery(Meeting.class)
.eq(StringUtils.isNotBlank(queryRegionCode), Meeting::getRegionCode, queryRegionCode)
.ne(Meeting::getStatus, MeetingStatusEnum.CANCELED.getCode()));
Integer meetingCnt = normalMeetingList.size();

// 各类型评审次数
Map<String, List<String>> meetingTypeMap = normalMeetingList.stream().map(Meeting::getType)
.collect(Collectors.groupingBy(Function.identity()));
AnalysisChart meetingTypeCntChartAnalysisChart =
assemblerAnalysisChart(meetingTypeMap, ChartTypeEnum.MEETING_TYPE_CNT_CHART);
analysisChartList.add(meetingTypeCntChartAnalysisChart);


// 明星专家列表
List<StarExpertBO> starExpertList = new ArrayList<>();
List<MeetingExpertJudge> meetingExpertJudgeList = iMeetingExpertJudgeService.list();
Map<Long, List<MeetingExpertJudge>> expertIdMeetingExpertJudgeMap = meetingExpertJudgeList.stream()
.collect(Collectors.groupingBy(MeetingExpertJudge::getExpertId));
Map<Long, String> expertIdExpertNameMap = evidenceHasBeenSubmittedExpertInfoList.stream()
.collect(Collectors.toMap(ExpertUserFullInfo::getUserId, ExpertUserFullInfo::getExpertName));

for (Long expertId : expertIdMeetingExpertJudgeMap.keySet()) {
String expertName = expertIdExpertNameMap.get(expertId);
List<MeetingExpertJudge> expertMeetingExpertJudgeList = expertIdMeetingExpertJudgeMap.get(expertId);
DoubleSummaryStatistics statistics = expertMeetingExpertJudgeList
.stream().filter(r -> Objects.nonNull(r.getScore()))
.map(MeetingExpertJudge::getScore).mapToDouble(Number::doubleValue).summaryStatistics();
double average = statistics.getAverage();
StarExpertBO starExpertBO = new StarExpertBO();
starExpertBO.setAveragePerformanceScore(average);
starExpertBO.setExpertId(expertId);
starExpertBO.setExpertName(expertName);
starExpertList.add(starExpertBO);
starExpertList.add(starExpertBO);
}

starExpertList = starExpertList.stream()
.sorted(Comparator.comparing(StarExpertBO::getAveragePerformanceScore)
.reversed()).collect(Collectors.toList());
if (starExpertList.size() > 5) {
starExpertList = starExpertList.subList(0, 5);
}

// 装配返回类
ExpertDashboardSummaryVO expertDashboardSummaryVO = new ExpertDashboardSummaryVO();
expertDashboardSummaryVO.setMeetingCnt(meetingCnt);
expertDashboardSummaryVO.setStarExpertList(starExpertList);
expertDashboardSummaryVO.setAnalysisChartList(analysisChartList);
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;
}
} }



+ 2
- 0
pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/DashboardProjectManage.java View File

@@ -25,6 +25,8 @@ public class DashboardProjectManage {


private static String timeFormat = "%s-01-01 00:00:00"; private static String timeFormat = "%s-01-01 00:00:00";




/** /**
* 查询年份BO 装配 * 查询年份BO 装配
* *


+ 2
- 0
pmapi/src/main/java/com/ningdatech/pmapi/dashboard/model/basic/AnalysisData.java View File

@@ -2,12 +2,14 @@ package com.ningdatech.pmapi.dashboard.model.basic;


import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data;


/** /**
* @author liuxinxin * @author liuxinxin
* @date 2023/8/2 下午2:27 * @date 2023/8/2 下午2:27
*/ */


@Data
@ApiModel("分析数据基础类") @ApiModel("分析数据基础类")
public class AnalysisData { public class AnalysisData {




+ 2
- 0
pmapi/src/main/java/com/ningdatech/pmapi/dashboard/model/po/QueryYearPO.java View File

@@ -16,4 +16,6 @@ public class QueryYearPO {
@ApiModelProperty("查询年份") @ApiModelProperty("查询年份")
private Integer year; private Integer year;


@ApiModelProperty("区域编码")
private String regionCode;
} }

Loading…
Cancel
Save