|
|
@@ -0,0 +1,180 @@ |
|
|
|
package com.ningdatech.pmapi.performance.manage; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.google.common.collect.Maps; |
|
|
|
import com.ningdatech.basic.function.VUtils; |
|
|
|
import com.ningdatech.basic.model.PageVo; |
|
|
|
import com.ningdatech.pmapi.performance.convert.PerformanceAppraisalConveter; |
|
|
|
import com.ningdatech.pmapi.performance.model.entity.PerformanceAppraisal; |
|
|
|
import com.ningdatech.pmapi.performance.model.entity.PerformanceAppraisalApplication; |
|
|
|
import com.ningdatech.pmapi.performance.model.entity.PerformanceAppraisalProject; |
|
|
|
import com.ningdatech.pmapi.performance.model.req.PerformanceAppraisalListReq; |
|
|
|
import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalVO; |
|
|
|
import com.ningdatech.pmapi.performance.service.IPerformanceAppraisalApplicationService; |
|
|
|
import com.ningdatech.pmapi.performance.service.IPerformanceAppraisalProjectService; |
|
|
|
import com.ningdatech.pmapi.performance.service.IPerformanceAppraisalService; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.entity.Project; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.entity.ProjectApplication; |
|
|
|
import com.ningdatech.pmapi.projectlib.service.IProjectApplicationService; |
|
|
|
import com.ningdatech.pmapi.projectlib.service.IProjectService; |
|
|
|
import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; |
|
|
|
import com.ningdatech.pmapi.user.util.LoginUserUtil; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Classname OrgSelfAppraisalManage |
|
|
|
* @Description |
|
|
|
* @Date 2023/6/19 14:18 |
|
|
|
* @Author PoffyZhang |
|
|
|
*/ |
|
|
|
@Component |
|
|
|
@Slf4j |
|
|
|
@AllArgsConstructor |
|
|
|
public class OrgSelfAppraisalManage { |
|
|
|
|
|
|
|
private final IPerformanceAppraisalService performanceAppraisalService; |
|
|
|
|
|
|
|
private final IPerformanceAppraisalProjectService performanceAppraisalProjectService; |
|
|
|
|
|
|
|
private final IPerformanceAppraisalApplicationService performanceAppraisalApplicationService; |
|
|
|
|
|
|
|
private final IProjectService projectService; |
|
|
|
|
|
|
|
private final IProjectApplicationService applicationService; |
|
|
|
|
|
|
|
/** |
|
|
|
* 绩效列表 |
|
|
|
* @param req |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public PageVo<PerformanceAppraisalVO> list(PerformanceAppraisalListReq req) { |
|
|
|
UserInfoDetails user = LoginUserUtil.loginUserDetail(); |
|
|
|
|
|
|
|
//当前登录用户 单位code |
|
|
|
String empPosUnitCode = user.getEmpPosUnitCode(); |
|
|
|
projectService.list(Wrappers.lambdaQuery(Project.class) |
|
|
|
.eq(Project::getBuildOrgCode,empPosUnitCode)); |
|
|
|
|
|
|
|
|
|
|
|
Page<PerformanceAppraisal> page = req.page(); |
|
|
|
LambdaQueryWrapper<PerformanceAppraisal> wrapper = Wrappers.lambdaQuery(PerformanceAppraisal.class) |
|
|
|
.like(StringUtils.isNotBlank(req.getName()),PerformanceAppraisal::getName,req.getName()) |
|
|
|
.ge(Objects.nonNull(req.getStart()),PerformanceAppraisal::getCreateOn,req.getStart()) |
|
|
|
.le(Objects.nonNull(req.getEnd()),PerformanceAppraisal::getCreateOn,req.getEnd()) |
|
|
|
.orderByDesc(PerformanceAppraisal::getUpdateOn); |
|
|
|
performanceAppraisalService.page(page,wrapper); |
|
|
|
if(0L == page.getTotal()){ |
|
|
|
return PageVo.empty(); |
|
|
|
} |
|
|
|
|
|
|
|
List<Long> paIds = page.getRecords().stream().map(PerformanceAppraisal::getId).collect(Collectors.toList()); |
|
|
|
List<PerformanceAppraisalProject> paps = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) |
|
|
|
.in(PerformanceAppraisalProject::getAppraisalId, paIds)); |
|
|
|
|
|
|
|
Map<String,Project> projectMap = Maps.newHashMap(); |
|
|
|
Map<Long,List<PerformanceAppraisalProject>> papsGroupMap = Maps.newHashMap(); |
|
|
|
if(CollUtil.isNotEmpty(paps)){ |
|
|
|
papsGroupMap = paps.stream().collect(Collectors.groupingBy(PerformanceAppraisalProject::getAppraisalId)); |
|
|
|
|
|
|
|
List<String> projectCodes = paps.stream().map(PerformanceAppraisalProject::getProjectCode).collect(Collectors.toList()); |
|
|
|
List<Project> projects = projectService.list(Wrappers.lambdaQuery(Project.class) |
|
|
|
.in(Project::getProjectCode, projectCodes) |
|
|
|
.eq(Project::getNewest, Boolean.TRUE)); |
|
|
|
if(CollUtil.isNotEmpty(projects)){ |
|
|
|
projectMap = projects.stream().collect(Collectors.toMap(Project::getProjectCode,p -> p)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
List<PerformanceAppraisalApplication> paas = performanceAppraisalApplicationService.list(Wrappers.lambdaQuery(PerformanceAppraisalApplication.class) |
|
|
|
.in(PerformanceAppraisalApplication::getAppraisalId, paIds)); |
|
|
|
Map<Long,ProjectApplication> applicationMap = Maps.newHashMap(); |
|
|
|
Map<Long,List<PerformanceAppraisalApplication>> paasGroupMap = Maps.newHashMap(); |
|
|
|
if(CollUtil.isNotEmpty(paas)){ |
|
|
|
paasGroupMap = paas.stream().collect(Collectors.groupingBy(PerformanceAppraisalApplication::getAppraisalId)); |
|
|
|
|
|
|
|
List<Long> applicationIds = paas.stream().map(PerformanceAppraisalApplication::getApplicationId).collect(Collectors.toList()); |
|
|
|
List<ProjectApplication> apps = applicationService.list(Wrappers.lambdaQuery(ProjectApplication.class) |
|
|
|
.in(ProjectApplication::getId, applicationIds)); |
|
|
|
if(CollUtil.isNotEmpty(apps)){ |
|
|
|
applicationMap = apps.stream().collect(Collectors.toMap(ProjectApplication::getId,a -> a)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Map<Long, List<PerformanceAppraisalProject>> finalPapsGroupMap = papsGroupMap; |
|
|
|
Map<Long,List<PerformanceAppraisalApplication>> finalPaasGroupMap = paasGroupMap; |
|
|
|
Map<String,Project> finalProjectMap = projectMap; |
|
|
|
Map<Long,ProjectApplication> finalApplicationMap = applicationMap; |
|
|
|
List<PerformanceAppraisalVO> res = page.getRecords().stream().map(p -> { |
|
|
|
PerformanceAppraisalVO vo = BeanUtil.copyProperties(p,PerformanceAppraisalVO.class); |
|
|
|
if(finalPapsGroupMap.containsKey(p.getId())){ |
|
|
|
vo.setProjects(PerformanceAppraisalConveter.convertProjects(finalPapsGroupMap.get(p.getId()),finalProjectMap)); |
|
|
|
} |
|
|
|
if(finalPaasGroupMap.containsKey(p.getId())){ |
|
|
|
vo.setApplications(PerformanceAppraisalConveter.convertApplications(finalPaasGroupMap.get(p.getId()),finalApplicationMap)); |
|
|
|
} |
|
|
|
return vo; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
return PageVo.of(res,page.getTotal()); |
|
|
|
} |
|
|
|
|
|
|
|
public PerformanceAppraisalVO detail(Long id) { |
|
|
|
|
|
|
|
PerformanceAppraisal pa = performanceAppraisalService.getById(id); |
|
|
|
VUtils.isTrue(Objects.isNull(pa)).throwMessage("该计划不存在"); |
|
|
|
|
|
|
|
PerformanceAppraisalVO vo = BeanUtil.copyProperties(pa,PerformanceAppraisalVO.class); |
|
|
|
//绩效关联的项目 |
|
|
|
List<PerformanceAppraisalProject> paps = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) |
|
|
|
.eq(PerformanceAppraisalProject::getAppraisalId, id)); |
|
|
|
Map<String,Project> projectMap = Maps.newHashMap(); |
|
|
|
Map<Long,List<PerformanceAppraisalProject>> papsGroupMap = Maps.newHashMap(); |
|
|
|
if(CollUtil.isNotEmpty(paps)){ |
|
|
|
papsGroupMap = paps.stream().collect(Collectors.groupingBy(PerformanceAppraisalProject::getAppraisalId)); |
|
|
|
|
|
|
|
List<String> projectCodes = paps.stream().map(PerformanceAppraisalProject::getProjectCode).collect(Collectors.toList()); |
|
|
|
List<Project> projects = projectService.list(Wrappers.lambdaQuery(Project.class) |
|
|
|
.in(Project::getProjectCode, projectCodes) |
|
|
|
.eq(Project::getNewest, Boolean.TRUE)); |
|
|
|
if(CollUtil.isNotEmpty(projects)){ |
|
|
|
projectMap = projects.stream().collect(Collectors.toMap(Project::getProjectCode,p -> p)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//绩效关联的应用 |
|
|
|
List<PerformanceAppraisalApplication> paas = performanceAppraisalApplicationService.list(Wrappers.lambdaQuery(PerformanceAppraisalApplication.class) |
|
|
|
.eq(PerformanceAppraisalApplication::getAppraisalId, id)); |
|
|
|
Map<Long,ProjectApplication> applicationMap = Maps.newHashMap(); |
|
|
|
Map<Long,List<PerformanceAppraisalApplication>> paasGroupMap = Maps.newHashMap(); |
|
|
|
if(CollUtil.isNotEmpty(paas)){ |
|
|
|
paasGroupMap = paas.stream().collect(Collectors.groupingBy(PerformanceAppraisalApplication::getAppraisalId)); |
|
|
|
|
|
|
|
List<Long> applicationIds = paas.stream().map(PerformanceAppraisalApplication::getApplicationId).collect(Collectors.toList()); |
|
|
|
List<ProjectApplication> apps = applicationService.list(Wrappers.lambdaQuery(ProjectApplication.class) |
|
|
|
.in(ProjectApplication::getId, applicationIds)); |
|
|
|
if(CollUtil.isNotEmpty(apps)){ |
|
|
|
applicationMap = apps.stream().collect(Collectors.toMap(ProjectApplication::getId,a -> a)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Map<Long, List<PerformanceAppraisalProject>> finalPapsGroupMap = papsGroupMap; |
|
|
|
Map<Long,List<PerformanceAppraisalApplication>> finalPaasGroupMap = paasGroupMap; |
|
|
|
Map<String,Project> finalProjectMap = projectMap; |
|
|
|
Map<Long,ProjectApplication> finalApplicationMap = applicationMap; |
|
|
|
if(finalPapsGroupMap.containsKey(vo.getId())){ |
|
|
|
vo.setProjects(PerformanceAppraisalConveter.convertProjects(finalPapsGroupMap.get(vo.getId()),finalProjectMap)); |
|
|
|
} |
|
|
|
if(finalPaasGroupMap.containsKey(vo.getId())){ |
|
|
|
vo.setApplications(PerformanceAppraisalConveter.convertApplications(finalPaasGroupMap.get(vo.getId()),finalApplicationMap)); |
|
|
|
} |
|
|
|
return vo; |
|
|
|
} |
|
|
|
} |