|
@@ -1,294 +0,0 @@
|
|
|
-package cn.iocoder.yudao.module.rd.controller.admin.expertpool;
|
|
|
|
|
-
|
|
|
|
|
-import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
-import cn.hutool.core.date.DateUtil;
|
|
|
|
|
-import cn.hutool.core.util.ObjUtil;
|
|
|
|
|
-import cn.hutool.core.util.StrUtil;
|
|
|
|
|
-import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
|
|
-import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
|
|
-import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
|
|
-import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
|
|
-import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
|
|
-import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
|
|
-import cn.iocoder.yudao.module.rd.controller.admin.expertpool.vo.EchelonExpertPoolRespVO;
|
|
|
|
|
-import cn.iocoder.yudao.module.rd.controller.admin.expertpool.vo.ExpertPoolPageReqVO;
|
|
|
|
|
-import cn.iocoder.yudao.module.rd.controller.admin.expertpool.vo.ExpertPoolRespVO;
|
|
|
|
|
-import cn.iocoder.yudao.module.rd.controller.admin.expertpool.vo.ExpertPoolSaveReqVO;
|
|
|
|
|
-import cn.iocoder.yudao.module.rd.controller.admin.expertpool.vo.ExpertPoolSortReqVO;
|
|
|
|
|
-import cn.iocoder.yudao.module.rd.controller.admin.team.vo.TeamPageReqVO;
|
|
|
|
|
-import cn.iocoder.yudao.module.rd.controller.admin.team.vo.TeamRespVO;
|
|
|
|
|
-import cn.iocoder.yudao.module.rd.dal.dataobject.expertpool.ExpertPoolDO;
|
|
|
|
|
-import cn.iocoder.yudao.module.rd.dal.dataobject.team.TeamDO;
|
|
|
|
|
-import cn.iocoder.yudao.module.rd.service.expertpool.ExpertPoolService;
|
|
|
|
|
-import cn.iocoder.yudao.module.rd.service.team.TeamService;
|
|
|
|
|
-import cn.iocoder.yudao.module.rd.utils.DictDataUtils;
|
|
|
|
|
-import cn.iocoder.yudao.module.system.service.dict.DictDataService;
|
|
|
|
|
-import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
|
-import io.swagger.v3.oas.annotations.Parameter;
|
|
|
|
|
-import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
|
-import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
|
-import org.springframework.validation.annotation.Validated;
|
|
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
|
|
-
|
|
|
|
|
-import javax.annotation.Resource;
|
|
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
-import javax.validation.Valid;
|
|
|
|
|
-import java.io.IOException;
|
|
|
|
|
-import java.time.LocalDateTime;
|
|
|
|
|
-import java.util.*;
|
|
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
-
|
|
|
|
|
-import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
|
|
|
-import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
|
|
-
|
|
|
|
|
-@Tag(name = "管理后台 - 专家库")
|
|
|
|
|
-@RestController
|
|
|
|
|
-@RequestMapping("/rd/expert-pool")
|
|
|
|
|
-@Validated
|
|
|
|
|
-public class ExpertPoolController {
|
|
|
|
|
-
|
|
|
|
|
- @Resource
|
|
|
|
|
- private ExpertPoolService expertPoolService;
|
|
|
|
|
- @Resource
|
|
|
|
|
- private DictDataService dictDataService;
|
|
|
|
|
- @Resource
|
|
|
|
|
- private TeamService expertTeamService;
|
|
|
|
|
- @Resource
|
|
|
|
|
- private DictDataUtils dictDataUtils;
|
|
|
|
|
-
|
|
|
|
|
- @PostMapping("/create")
|
|
|
|
|
- @Operation(summary = "创建专家库")
|
|
|
|
|
- @PreAuthorize("@ss.hasPermission('rd:expert-pool:create')")
|
|
|
|
|
- public CommonResult<Long> createExpertPool(@Valid @RequestBody ExpertPoolSaveReqVO createReqVO) {
|
|
|
|
|
- return success(expertPoolService.createExpertPool(createReqVO));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @PutMapping("/update")
|
|
|
|
|
- @Operation(summary = "更新专家库")
|
|
|
|
|
- @PreAuthorize("@ss.hasPermission('rd:expert-pool:update')")
|
|
|
|
|
- public CommonResult<Boolean> updateExpertPool(@Valid @RequestBody ExpertPoolSaveReqVO updateReqVO) {
|
|
|
|
|
- expertPoolService.updateExpertPool(updateReqVO);
|
|
|
|
|
- return success(true);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 拖拽排序
|
|
|
|
|
- @PutMapping("/changeSort")
|
|
|
|
|
- @Operation(summary = "专家拖拽排序")
|
|
|
|
|
- @PreAuthorize("@ss.hasPermission('rd:expert-pool:update')")
|
|
|
|
|
- public CommonResult<Boolean> changeSort(@Valid @RequestBody ExpertPoolSortReqVO sortReqVO) {
|
|
|
|
|
- expertPoolService.changeSort(sortReqVO);
|
|
|
|
|
- return success(true);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- @DeleteMapping("/delete")
|
|
|
|
|
- @Operation(summary = "删除专家库")
|
|
|
|
|
- @Parameter(name = "id", description = "编号", required = true)
|
|
|
|
|
- @PreAuthorize("@ss.hasPermission('rd:expert-pool:delete')")
|
|
|
|
|
- public CommonResult<Boolean> deleteExpertPool(@RequestParam("id") Long id) {
|
|
|
|
|
- expertPoolService.deleteExpertPool(id);
|
|
|
|
|
- return success(true);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @GetMapping("/get")
|
|
|
|
|
- @Operation(summary = "获得专家库")
|
|
|
|
|
- @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
|
|
- @PreAuthorize("@ss.hasPermission('rd:expert-pool:query')")
|
|
|
|
|
- public CommonResult<ExpertPoolRespVO> getExpertPool(@RequestParam("id") Long id) {
|
|
|
|
|
- ExpertPoolDO expertPool = expertPoolService.getExpertPool(id);
|
|
|
|
|
- return success(buildDailyReport(expertPool));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 查询专家库 专家详情
|
|
|
|
|
- * @param expertPool
|
|
|
|
|
- * @return
|
|
|
|
|
- */
|
|
|
|
|
- private ExpertPoolRespVO buildDailyReport(ExpertPoolDO expertPool) {
|
|
|
|
|
- // 如果 expertPool 为空 返回空对象
|
|
|
|
|
- if (ObjUtil.isEmpty(expertPool)) {
|
|
|
|
|
- return new ExpertPoolRespVO();
|
|
|
|
|
- }
|
|
|
|
|
- ExpertPoolRespVO expertPoolVO = BeanUtils.toBean(expertPool, ExpertPoolRespVO.class);
|
|
|
|
|
-
|
|
|
|
|
- // 专家梯队 字典数据
|
|
|
|
|
- Map<String, String> expertEchelonPair = dictDataUtils.getDictData("rd_expert_echelon");
|
|
|
|
|
- // 专家序列 数据字典
|
|
|
|
|
- Map<String, String> expertRankPair = dictDataUtils.getDictData("rd_expert_rank");
|
|
|
|
|
- // 专家学历 数据字典
|
|
|
|
|
- Map<String, String> expertEducationPair = dictDataUtils.getDictData("rd_expert_education");
|
|
|
|
|
- // 软件技能 数据字典
|
|
|
|
|
- Map<String, String> expertSoftwarePair = dictDataUtils.getDictData("rd_expert_software");
|
|
|
|
|
- // 专业方向 数据字典
|
|
|
|
|
- Map<String, String> expertTechnicalPair = dictDataUtils.getDictData("rd_expert_technical");
|
|
|
|
|
- // 学历
|
|
|
|
|
- String education = expertPoolVO.getEducation();
|
|
|
|
|
- if (StrUtil.isNotBlank(education) && expertEducationPair.containsKey(education)) {
|
|
|
|
|
- expertPoolVO.setEducationLabel(expertEducationPair.get(education));
|
|
|
|
|
- }
|
|
|
|
|
- // 梯队
|
|
|
|
|
- String echelon = expertPoolVO.getEchelon();
|
|
|
|
|
- if (StrUtil.isNotBlank(echelon) && expertEchelonPair.containsKey(echelon)) {
|
|
|
|
|
- expertPoolVO.setEchelonLabel(expertEchelonPair.get(echelon));
|
|
|
|
|
- }
|
|
|
|
|
- // 专家技术序列
|
|
|
|
|
- Set<Long> expertRankValues = expertPoolVO.getExpertRank();
|
|
|
|
|
- if (CollUtil.isNotEmpty(expertRankValues)) {
|
|
|
|
|
- String rankLabels = expertRankValues.stream()
|
|
|
|
|
- .map(lg -> ObjUtil.isNotEmpty(lg) ? lg.toString() : StrUtil.EMPTY) // 将Long转为String,匹配techniqueDictPair的key类型
|
|
|
|
|
- .map(key -> expertRankPair.getOrDefault(key, key)) // 取label,无则用原key
|
|
|
|
|
- .collect(Collectors.joining(",")); // 逗号拼接
|
|
|
|
|
- expertPoolVO.setExpertRankLabel(rankLabels);
|
|
|
|
|
- }
|
|
|
|
|
- // 专家软件技能
|
|
|
|
|
- Set<Long> expertSoftwareValues = expertPoolVO.getSoftwareSkills();
|
|
|
|
|
- if (CollUtil.isNotEmpty(expertSoftwareValues)) {
|
|
|
|
|
- String softwareLabels = expertSoftwareValues.stream()
|
|
|
|
|
- .map(lg -> ObjUtil.isNotEmpty(lg) ? lg.toString() : StrUtil.EMPTY) // 将Long转为String,匹配techniqueDictPair的key类型
|
|
|
|
|
- .map(key -> expertSoftwarePair.getOrDefault(key, key)) // 取label,无则用原key
|
|
|
|
|
- .collect(Collectors.joining(",")); // 逗号拼接
|
|
|
|
|
- expertPoolVO.setSoftwareSkillsLabel(softwareLabels);
|
|
|
|
|
- }
|
|
|
|
|
- // 专家 专业方向
|
|
|
|
|
- Set<Long> expertTechnicalValues = expertPoolVO.getSpecialDirection();
|
|
|
|
|
- if (CollUtil.isNotEmpty(expertTechnicalValues)) {
|
|
|
|
|
- String technicalLabels = expertTechnicalValues.stream()
|
|
|
|
|
- .map(lg -> ObjUtil.isNotEmpty(lg) ? lg.toString() : StrUtil.EMPTY) // 将Long转为String,匹配techniqueDictPair的key类型
|
|
|
|
|
- .map(key -> expertTechnicalPair.getOrDefault(key, key)) // 取label,无则用原key
|
|
|
|
|
- .collect(Collectors.joining(",")); // 逗号拼接
|
|
|
|
|
- expertPoolVO.setSoftwareSkillsLabel(technicalLabels);
|
|
|
|
|
- }
|
|
|
|
|
- // 专家所属队伍
|
|
|
|
|
- Set<Long> teamIds = expertPoolVO.getTeamIds();
|
|
|
|
|
- if (CollUtil.isNotEmpty(teamIds)) {
|
|
|
|
|
- TeamPageReqVO teamReqVO = new TeamPageReqVO();
|
|
|
|
|
- teamReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
|
|
- teamReqVO.setTeamIds(teamIds);
|
|
|
|
|
- PageResult<TeamDO> pageTeams = expertTeamService.getTeamPage(teamReqVO);
|
|
|
|
|
- List<TeamDO> teams = pageTeams.getList();
|
|
|
|
|
- if (CollUtil.isNotEmpty(teams)) {
|
|
|
|
|
- List<TeamRespVO> teamResp = BeanUtils.toBean(teams, TeamRespVO.class);
|
|
|
|
|
- expertPoolVO.setTeams(teamResp);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- // 专家年龄
|
|
|
|
|
- LocalDateTime birthday = expertPoolVO.getBirthday();
|
|
|
|
|
- if (ObjUtil.isNotEmpty(birthday)) {
|
|
|
|
|
- Integer age = DateUtil.ageOfNow(DateUtil.date(birthday));
|
|
|
|
|
- expertPoolVO.setAge(age);
|
|
|
|
|
- }
|
|
|
|
|
- return expertPoolVO;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 根据数据字典类型获取数据字典值列表
|
|
|
|
|
- * @param dictType
|
|
|
|
|
- * @return
|
|
|
|
|
- */
|
|
|
|
|
- /* private Map<String, String> getDictData(String dictType) {
|
|
|
|
|
- Map<String, String> dictDataPair = new HashMap<>();
|
|
|
|
|
- List<DictDataDO> somethingDictData = dictDataService.getDictDataListByDictType(dictType);
|
|
|
|
|
- if (CollUtil.isNotEmpty(somethingDictData)) {
|
|
|
|
|
- somethingDictData.forEach(tech -> {
|
|
|
|
|
- dictDataPair.put(tech.getValue(), tech.getLabel());
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- return dictDataPair;
|
|
|
|
|
- } */
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 根据数据字典类型获取数据字典值排序
|
|
|
|
|
- * @param dictType
|
|
|
|
|
- * @return
|
|
|
|
|
- */
|
|
|
|
|
- /* private Map<String, Integer> getDictDataSort(String dictType) {
|
|
|
|
|
- Map<String, Integer> dictDataPair = new HashMap<>();
|
|
|
|
|
- List<DictDataDO> somethingDictData = dictDataService.getDictDataListByDictType(dictType);
|
|
|
|
|
- if (CollUtil.isNotEmpty(somethingDictData)) {
|
|
|
|
|
- somethingDictData.forEach(tech -> {
|
|
|
|
|
- dictDataPair.put(tech.getValue(), tech.getSort());
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- return dictDataPair;
|
|
|
|
|
- } */
|
|
|
|
|
-
|
|
|
|
|
- @GetMapping("/page")
|
|
|
|
|
- @Operation(summary = "获得专家库分页")
|
|
|
|
|
- @PreAuthorize("@ss.hasPermission('rd:expert-pool:query')")
|
|
|
|
|
- public CommonResult<PageResult<ExpertPoolRespVO>> getExpertPoolPage(@Valid ExpertPoolPageReqVO pageReqVO) {
|
|
|
|
|
- PageResult<ExpertPoolDO> pageResult = expertPoolService.getExpertPoolPage(pageReqVO);
|
|
|
|
|
- return success(BeanUtils.toBean(pageResult, ExpertPoolRespVO.class));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- @GetMapping("/echelonExperts")
|
|
|
|
|
- @Operation(summary = "将专家按照梯队汇总数据返回")
|
|
|
|
|
- @PreAuthorize("@ss.hasPermission('rd:expert-pool:query')")
|
|
|
|
|
- public CommonResult<List<EchelonExpertPoolRespVO>> echelonExperts(@Valid ExpertPoolPageReqVO pageReqVO) {
|
|
|
|
|
- List<EchelonExpertPoolRespVO> result = new ArrayList<>();
|
|
|
|
|
- // 查询所有专家后组装
|
|
|
|
|
- pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
|
|
- PageResult<ExpertPoolDO> pageResult = expertPoolService.getExpertPoolPage(pageReqVO);
|
|
|
|
|
- List<ExpertPoolDO> experts = pageResult.getList();
|
|
|
|
|
- // key梯队数据字典value value梯队包含的专家列表
|
|
|
|
|
- Map<String, List<ExpertPoolDO>> echelonExpertPair = new HashMap<>();
|
|
|
|
|
- // 专家梯队 字典数据 key值 value标签
|
|
|
|
|
- Map<String, String> expertEchelonPair = dictDataUtils.getDictData("rd_expert_echelon");
|
|
|
|
|
- // 专家梯队 字典数据 排序值 key值 value排序sort
|
|
|
|
|
- Map<String, Integer> expertEchelonSortPair = dictDataUtils.getDictDataSort("rd_expert_echelon");
|
|
|
|
|
- // 按照梯队对专家分组
|
|
|
|
|
- if (CollUtil.isNotEmpty(experts)) {
|
|
|
|
|
- experts.forEach(expert -> {
|
|
|
|
|
- // 梯队
|
|
|
|
|
- String echelon = expert.getEchelon();
|
|
|
|
|
- if (expertEchelonPair.containsKey(echelon)) {
|
|
|
|
|
- String echelonLabel = expertEchelonPair.get(echelon);
|
|
|
|
|
- if (echelonExpertPair.containsKey(echelon)) {
|
|
|
|
|
- List<ExpertPoolDO> tempExperts = echelonExpertPair.get(echelon);
|
|
|
|
|
- tempExperts.add(expert);
|
|
|
|
|
- echelonExpertPair.put(echelon, tempExperts);
|
|
|
|
|
- } else {
|
|
|
|
|
- List<ExpertPoolDO> tempExperts = new ArrayList<>();
|
|
|
|
|
- tempExperts.add(expert);
|
|
|
|
|
- echelonExpertPair.put(echelon, tempExperts);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- if (CollUtil.isNotEmpty(echelonExpertPair)) {
|
|
|
|
|
- echelonExpertPair.forEach((echelon, relatedExperts) -> {
|
|
|
|
|
- EchelonExpertPoolRespVO expertPool = new EchelonExpertPoolRespVO();
|
|
|
|
|
- if (expertEchelonPair.containsKey(echelon)) {
|
|
|
|
|
- String echelonLabel = expertEchelonPair.get(echelon);
|
|
|
|
|
- expertPool.setEchelonLabel(echelonLabel);
|
|
|
|
|
- }
|
|
|
|
|
- expertPool.setNum(relatedExperts.size());
|
|
|
|
|
- expertPool.setExperts(relatedExperts);
|
|
|
|
|
- // 设置各专家梯队的排序值
|
|
|
|
|
- if (expertEchelonSortPair.containsKey(echelon)) {
|
|
|
|
|
- Integer echelonSort = expertEchelonSortPair.get(echelon);
|
|
|
|
|
- expertPool.setSort(echelonSort);
|
|
|
|
|
- }
|
|
|
|
|
- result.add(expertPool);
|
|
|
|
|
- });
|
|
|
|
|
- result.sort(Comparator.comparing(EchelonExpertPoolRespVO::getSort));
|
|
|
|
|
- }
|
|
|
|
|
- return success(result);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @GetMapping("/export-excel")
|
|
|
|
|
- @Operation(summary = "导出专家库 Excel")
|
|
|
|
|
- @PreAuthorize("@ss.hasPermission('rd:expert-pool:export')")
|
|
|
|
|
- @ApiAccessLog(operateType = EXPORT)
|
|
|
|
|
- public void exportExpertPoolExcel(@Valid ExpertPoolPageReqVO pageReqVO,
|
|
|
|
|
- HttpServletResponse response) throws IOException {
|
|
|
|
|
- pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
|
|
- List<ExpertPoolDO> list = expertPoolService.getExpertPoolPage(pageReqVO).getList();
|
|
|
|
|
- // 导出 Excel
|
|
|
|
|
- ExcelUtils.write(response, "专家库.xls", "数据", ExpertPoolRespVO.class,
|
|
|
|
|
- BeanUtils.toBean(list, ExpertPoolRespVO.class));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-}
|
|
|