|
|
@@ -1,16 +1,25 @@
|
|
|
package cn.iocoder.yudao.module.rd.controller.admin.team;
|
|
|
|
|
|
+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.ExpertPoolPageReqVO;
|
|
|
+import cn.iocoder.yudao.module.rd.controller.admin.expertpool.vo.ExpertPoolRespVO;
|
|
|
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.controller.admin.team.vo.TeamSaveReqVO;
|
|
|
+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 io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
@@ -22,7 +31,9 @@ import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.Valid;
|
|
|
import java.io.IOException;
|
|
|
-import java.util.List;
|
|
|
+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;
|
|
|
@@ -35,6 +46,10 @@ public class TeamController {
|
|
|
|
|
|
@Resource
|
|
|
private TeamService teamService;
|
|
|
+ @Resource
|
|
|
+ private ExpertPoolService rdExpertPoolService;
|
|
|
+ @Resource
|
|
|
+ private DictDataUtils dictDataUtils;
|
|
|
|
|
|
@PostMapping("/create")
|
|
|
@Operation(summary = "创建团队")
|
|
|
@@ -66,7 +81,84 @@ public class TeamController {
|
|
|
@PreAuthorize("@ss.hasPermission('rd:team:query')")
|
|
|
public CommonResult<TeamRespVO> getTeam(@RequestParam("id") Long id) {
|
|
|
TeamDO team = teamService.getTeam(id);
|
|
|
- return success(BeanUtils.toBean(team, TeamRespVO.class));
|
|
|
+ return success(buildTeam(team));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询专家库 团队详情
|
|
|
+ * @param team
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private TeamRespVO buildTeam(TeamDO team) {
|
|
|
+ // 如果 team 为空 返回空对象
|
|
|
+ if (ObjUtil.isEmpty(team)) {
|
|
|
+ return new TeamRespVO();
|
|
|
+ }
|
|
|
+ TeamRespVO teamRespVO = BeanUtils.toBean(team, TeamRespVO.class);
|
|
|
+ // 查询每个团队下的专家列表
|
|
|
+ List<ExpertPoolRespVO> teamExperts = new ArrayList<>();
|
|
|
+ ExpertPoolPageReqVO reqVO = new ExpertPoolPageReqVO();
|
|
|
+ reqVO.setTeamId(teamRespVO.getId());
|
|
|
+ List<ExpertPoolDO> experts = rdExpertPoolService.getExpertPools(reqVO);
|
|
|
+ if (CollUtil.isNotEmpty(experts)) {
|
|
|
+ experts.forEach(expert -> {
|
|
|
+ ExpertPoolRespVO expertPoolVO = BeanUtils.toBean(expert, 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 = expert.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);
|
|
|
+ }
|
|
|
+ // 专家年龄
|
|
|
+ LocalDateTime birthday = expertPoolVO.getBirthday();
|
|
|
+ Integer age = DateUtil.ageOfNow(DateUtil.date(birthday));
|
|
|
+ expertPoolVO.setAge(age);
|
|
|
+ teamExperts.add(expertPoolVO);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ teamRespVO.setExperts(teamExperts);
|
|
|
+ return teamRespVO;
|
|
|
}
|
|
|
|
|
|
@GetMapping("/page")
|
|
|
@@ -74,7 +166,41 @@ public class TeamController {
|
|
|
@PreAuthorize("@ss.hasPermission('rd:team:query')")
|
|
|
public CommonResult<PageResult<TeamRespVO>> getTeamPage(@Valid TeamPageReqVO pageReqVO) {
|
|
|
PageResult<TeamDO> pageResult = teamService.getTeamPage(pageReqVO);
|
|
|
- return success(BeanUtils.toBean(pageResult, TeamRespVO.class));
|
|
|
+ return success(new PageResult<>(buildTeamList(pageResult.getList()), pageResult.getTotal()));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置每个团队包含的专家姓名集合 逗号分隔
|
|
|
+ * @param teams
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<TeamRespVO> buildTeamList(List<TeamDO> teams) {
|
|
|
+ if (CollUtil.isEmpty(teams)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ // 查询每个团队包含的专家姓名集合 逗号分隔
|
|
|
+ Map<Long, Set<String>> teamExpertNamePair = new HashMap<>();
|
|
|
+ teams.forEach(team -> {
|
|
|
+ Long teamId = team.getId();
|
|
|
+ ExpertPoolPageReqVO reqVO = new ExpertPoolPageReqVO();
|
|
|
+ reqVO.setTeamId(teamId);
|
|
|
+ List<ExpertPoolDO> teamExperts = rdExpertPoolService.getExpertPools(reqVO);
|
|
|
+ Set<String> expertNames = new HashSet<>();
|
|
|
+ if (CollUtil.isNotEmpty(teamExperts)) {
|
|
|
+ teamExperts.forEach(expert -> {
|
|
|
+ expertNames.add(expert.getExpertName());
|
|
|
+ });
|
|
|
+ teamExpertNamePair.put(teamId, expertNames);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return BeanUtils.toBean(teams, TeamRespVO.class, (teamVO) -> {
|
|
|
+ Long teamId = teamVO.getId();
|
|
|
+ if (teamExpertNamePair.containsKey(teamId)) {
|
|
|
+ Set<String> tempExpertNames = teamExpertNamePair.get(teamId);
|
|
|
+ String expertNamesStr = StrUtil.join(",", tempExpertNames);
|
|
|
+ teamVO.setExpertNames(expertNamesStr);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
@GetMapping("/export-excel")
|