|
|
@@ -1,21 +1,31 @@ |
|
|
|
package com.ningdatech.pmapi.performance.manage; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
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.Lists; |
|
|
|
import com.google.common.collect.Maps; |
|
|
|
import com.google.common.collect.Sets; |
|
|
|
import com.ningdatech.basic.exception.BizException; |
|
|
|
import com.ningdatech.basic.function.VUtils; |
|
|
|
import com.ningdatech.basic.model.PageVo; |
|
|
|
import com.ningdatech.basic.util.NdDateUtils; |
|
|
|
import com.ningdatech.basic.util.StrPool; |
|
|
|
import com.ningdatech.pmapi.common.constant.BizConst; |
|
|
|
import com.ningdatech.pmapi.common.constant.CommonConst; |
|
|
|
import com.ningdatech.pmapi.common.helper.UserInfoHelper; |
|
|
|
import com.ningdatech.pmapi.common.util.BizUtils; |
|
|
|
import com.ningdatech.pmapi.common.util.CodeUtil; |
|
|
|
import com.ningdatech.pmapi.performance.convert.PerformanceAppraisalConveter; |
|
|
|
import com.ningdatech.pmapi.performance.enumration.EvalObjectEnum; |
|
|
|
import com.ningdatech.pmapi.performance.model.dto.AppraisalProjectDTO; |
|
|
|
import com.ningdatech.pmapi.performance.model.dto.PerformanceAppraisalCreateDTO; |
|
|
|
import com.ningdatech.pmapi.performance.model.dto.PerformanceAppraisalEditDTO; |
|
|
@@ -25,6 +35,7 @@ import com.ningdatech.pmapi.performance.model.entity.PerformanceAppraisalApplica |
|
|
|
import com.ningdatech.pmapi.performance.model.entity.PerformanceAppraisalProject; |
|
|
|
import com.ningdatech.pmapi.performance.model.entity.PerformanceAppraisalProjectGroup; |
|
|
|
import com.ningdatech.pmapi.performance.model.req.PerformanceAppraisalListReq; |
|
|
|
import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalApplicationVO; |
|
|
|
import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalProjectGroupVO; |
|
|
|
import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalProjectVO; |
|
|
|
import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalVO; |
|
|
@@ -32,20 +43,27 @@ import com.ningdatech.pmapi.performance.service.IPerformanceAppraisalApplication |
|
|
|
import com.ningdatech.pmapi.performance.service.IPerformanceAppraisalProjectGroupService; |
|
|
|
import com.ningdatech.pmapi.performance.service.IPerformanceAppraisalProjectService; |
|
|
|
import com.ningdatech.pmapi.performance.service.IPerformanceAppraisalService; |
|
|
|
import com.ningdatech.pmapi.projectlib.enumeration.InstTypeEnum; |
|
|
|
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.entity.Project; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.entity.ProjectApplication; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.entity.ProjectInst; |
|
|
|
import com.ningdatech.pmapi.projectlib.service.IProjectApplicationService; |
|
|
|
import com.ningdatech.pmapi.projectlib.service.IProjectInstService; |
|
|
|
import com.ningdatech.pmapi.projectlib.service.IProjectService; |
|
|
|
import com.ningdatech.pmapi.todocenter.utils.BuildUserUtils; |
|
|
|
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; |
|
|
|
import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; |
|
|
|
import com.ningdatech.pmapi.user.util.LoginUserUtil; |
|
|
|
import com.wflow.workflow.bean.process.ProgressNode; |
|
|
|
import com.wflow.workflow.bean.vo.ProcessProgressVo; |
|
|
|
import com.wflow.workflow.service.ProcessInstanceService; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Classname PerformanceAppraisalManage |
|
|
@@ -59,18 +77,15 @@ import java.util.stream.Collectors; |
|
|
|
public class PerformanceAppraisalPlanManage { |
|
|
|
|
|
|
|
private final IPerformanceAppraisalService performanceAppraisalService; |
|
|
|
|
|
|
|
private final IPerformanceAppraisalProjectService performanceAppraisalProjectService; |
|
|
|
|
|
|
|
private final IPerformanceAppraisalApplicationService performanceAppraisalApplicationService; |
|
|
|
|
|
|
|
private final IProjectService projectService; |
|
|
|
|
|
|
|
private final IProjectApplicationService applicationService; |
|
|
|
|
|
|
|
private final IPerformanceAppraisalProjectGroupService groupService; |
|
|
|
|
|
|
|
private final UserInfoHelper userInfoHelper; |
|
|
|
private final IProjectInstService projectInstService; |
|
|
|
private final ProcessInstanceService processInstanceService; |
|
|
|
private final BuildUserUtils buildUserUtils; |
|
|
|
|
|
|
|
/** |
|
|
|
* 绩效列表 |
|
|
@@ -78,12 +93,15 @@ public class PerformanceAppraisalPlanManage { |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public PageVo<PerformanceAppraisalVO> list(PerformanceAppraisalListReq req) { |
|
|
|
UserInfoDetails userDetail = LoginUserUtil.loginUserDetail(); |
|
|
|
String regionCode = userDetail.getRegionCode(); |
|
|
|
Page<PerformanceAppraisal> page = req.page(); |
|
|
|
LambdaQueryWrapper<PerformanceAppraisal> wrapper = Wrappers.lambdaQuery(PerformanceAppraisal.class) |
|
|
|
.like(StringUtils.isNotBlank(req.getPlanName()),PerformanceAppraisal::getName,req.getPlanName()) |
|
|
|
.ge(Objects.nonNull(req.getStart()),PerformanceAppraisal::getCreateOn,req.getStart()) |
|
|
|
.le(Objects.nonNull(req.getEnd()),PerformanceAppraisal::getCreateOn,req.getEnd()) |
|
|
|
.orderByDesc(PerformanceAppraisal::getUpdateOn); |
|
|
|
.like(StringUtils.isNotBlank(req.getPlanName()),PerformanceAppraisal::getName,req.getPlanName()) |
|
|
|
.ge(Objects.nonNull(req.getStart()),PerformanceAppraisal::getCreateOn,req.getStart()) |
|
|
|
.le(Objects.nonNull(req.getEnd()),PerformanceAppraisal::getCreateOn,req.getEnd()) |
|
|
|
.eq(PerformanceAppraisal::getRegionCode,regionCode) |
|
|
|
.orderByDesc(PerformanceAppraisal::getUpdateOn); |
|
|
|
performanceAppraisalService.page(page,wrapper); |
|
|
|
if(0L == page.getTotal()){ |
|
|
|
return PageVo.empty(); |
|
|
@@ -188,6 +206,15 @@ public class PerformanceAppraisalPlanManage { |
|
|
|
if(finalPaasGroupMap.containsKey(vo.getId())){ |
|
|
|
vo.setApplications(PerformanceAppraisalConveter.convertApplications(finalPaasGroupMap.get(vo.getId()),finalApplicationMap)); |
|
|
|
} |
|
|
|
|
|
|
|
// 评价计划关联的分组信息 |
|
|
|
List<PerformanceAppraisalProjectGroup> groupList = groupService.list(Wrappers.lambdaQuery(PerformanceAppraisalProjectGroup.class) |
|
|
|
.eq(PerformanceAppraisalProjectGroup::getAppraisalId, id)); |
|
|
|
// 对计划内待评价项目进行了分组 |
|
|
|
if (CollUtil.isNotEmpty(groupList)){ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return vo; |
|
|
|
} |
|
|
|
|
|
|
@@ -199,25 +226,25 @@ public class PerformanceAppraisalPlanManage { |
|
|
|
@Transactional |
|
|
|
public String create(PerformanceAppraisalCreateDTO createDTO) { |
|
|
|
UserInfoDetails user = LoginUserUtil.loginUserDetail(); |
|
|
|
|
|
|
|
// 计划名称重复校验 |
|
|
|
deduplicationName(createDTO); |
|
|
|
|
|
|
|
PerformanceAppraisal pa = BeanUtil.copyProperties(createDTO,PerformanceAppraisal.class); |
|
|
|
pa.setCreateOn(LocalDateTime.now()); |
|
|
|
pa.setCreateBy(user.getUsername()); |
|
|
|
pa.setUpdateOn(LocalDateTime.now()); |
|
|
|
pa.setUpdateBy(user.getUsername()); |
|
|
|
pa.setRegionCode(user.getRegionCode()); |
|
|
|
performanceAppraisalService.save(pa); |
|
|
|
|
|
|
|
if(CollUtil.isNotEmpty(createDTO.getProjects()) |
|
|
|
&& StringUtils.isNotBlank(createDTO.getTarget()) |
|
|
|
&& createDTO.getTarget().contains("1")){ |
|
|
|
&& createDTO.getTarget().contains(EvalObjectEnum.PROJECT.getCode())){ |
|
|
|
saveProjects(createDTO,pa.getId(),user); |
|
|
|
} |
|
|
|
|
|
|
|
if(CollUtil.isNotEmpty(createDTO.getApplicationIds()) |
|
|
|
&& StringUtils.isNotBlank(createDTO.getTarget()) |
|
|
|
&& createDTO.getTarget().contains("2")){ |
|
|
|
&& createDTO.getTarget().contains(EvalObjectEnum.APP.getCode())){ |
|
|
|
saveApplications(createDTO,pa.getId(),user); |
|
|
|
} |
|
|
|
|
|
|
@@ -278,11 +305,16 @@ public class PerformanceAppraisalPlanManage { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
Integer startSelfDays = createDTO.getStartSelfDays(); |
|
|
|
Integer completeSelfDays = createDTO.getCompleteSelfDays(); |
|
|
|
List<AppraisalProjectDTO> projects = createDTO.getProjects(); |
|
|
|
|
|
|
|
for(AppraisalProjectDTO appraisalProject : projects){ |
|
|
|
Project newProject = projectService.getNewProject(appraisalProject.getId()); |
|
|
|
VUtils.isTrue(Objects.isNull(newProject)).throwMessage("项目不存在 " + appraisalProject.getId()); |
|
|
|
// 获取项目终验完成的时间 |
|
|
|
LocalDateTime finishTime = getProjectFinishTime(newProject); |
|
|
|
|
|
|
|
PerformanceAppraisalProject pap = new PerformanceAppraisalProject(); |
|
|
|
pap.setAppraisalId(id); |
|
|
|
pap.setProjectId(appraisalProject.getId()); |
|
|
@@ -292,10 +324,44 @@ public class PerformanceAppraisalPlanManage { |
|
|
|
pap.setCreateOn(LocalDateTime.now()); |
|
|
|
pap.setUpdateBy(user.getUsername()); |
|
|
|
pap.setUpdateOn(LocalDateTime.now()); |
|
|
|
LocalDateTime selfAppraisalStart = finishTime.plusDays(startSelfDays); |
|
|
|
pap.setSelfAppraisalStart(selfAppraisalStart); |
|
|
|
long days = startSelfDays + completeSelfDays; |
|
|
|
LocalDateTime selfAppraisalEnd = finishTime.plusDays(days); |
|
|
|
pap.setSelfAppraisalEnd(selfAppraisalEnd); |
|
|
|
performanceAppraisalProjectService.save(pap); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private LocalDateTime getProjectFinishTime(Project newProject) { |
|
|
|
//查出历史版本的 所有项目ID |
|
|
|
List<Long> allVersionProjectIds = projectService.getAllVersionProjectId(newProject); |
|
|
|
// 根据项目ID查询出项目终验流程的流程状态 |
|
|
|
ProjectInst projectInst = projectInstService.getOne(Wrappers.lambdaQuery(ProjectInst.class) |
|
|
|
.in(ProjectInst::getProjectId, allVersionProjectIds) |
|
|
|
.eq(ProjectInst::getInstType, InstTypeEnum.PROJECT_FINAL_INSPECTION.getCode()) |
|
|
|
.orderByDesc(ProjectInst::getCreatOn) |
|
|
|
.last(BizConst.LIMIT_1)); |
|
|
|
|
|
|
|
if (Objects.isNull(projectInst)){ |
|
|
|
throw new BizException("未获取到项目终验审批流程信息!"); |
|
|
|
} |
|
|
|
|
|
|
|
LocalDateTime finishTime; |
|
|
|
String instCode = projectInst.getInstCode(); |
|
|
|
ProcessProgressVo instanceDetail = processInstanceService.getProgressInstanceDetail(null, instCode); |
|
|
|
// 装配节点审核人员信息 |
|
|
|
List<ProgressNode> progressInfo = instanceDetail.getProgressInfo(); |
|
|
|
if (CollUtil.isNotEmpty(progressInfo)) { |
|
|
|
buildUserUtils.buildUserByProcessInfo(progressInfo); |
|
|
|
ProgressNode progressNode = progressInfo.get(progressInfo.size() - 1); |
|
|
|
finishTime = NdDateUtils.date2LocalDateTime(progressNode.getFinishTime()); |
|
|
|
}else { |
|
|
|
finishTime = NdDateUtils.date2LocalDateTime(instanceDetail.getStartTime()); |
|
|
|
} |
|
|
|
return finishTime; |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional |
|
|
|
public void saveApplications(PerformanceAppraisalCreateDTO createDTO,Long id,UserInfoDetails user) { |
|
|
|
if(CollUtil.isEmpty(createDTO.getApplicationIds())){ |
|
|
@@ -303,10 +369,7 @@ public class PerformanceAppraisalPlanManage { |
|
|
|
} |
|
|
|
|
|
|
|
List<Long> applicationIds = createDTO.getApplicationIds(); |
|
|
|
|
|
|
|
for(Long applicationId : applicationIds){ |
|
|
|
ProjectApplication projectApplication = applicationService.getById(applicationId); |
|
|
|
VUtils.isTrue(Objects.isNull(projectApplication)).throwMessage("应用不存在 " + applicationId); |
|
|
|
PerformanceAppraisalApplication paa = new PerformanceAppraisalApplication(); |
|
|
|
paa.setAppraisalId(id); |
|
|
|
paa.setApplicationId(applicationId); |
|
|
@@ -327,10 +390,14 @@ public class PerformanceAppraisalPlanManage { |
|
|
|
//删除先 |
|
|
|
performanceAppraisalProjectService.remove(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) |
|
|
|
.eq(PerformanceAppraisalProject::getAppraisalId,editDTO.getId())); |
|
|
|
Integer startSelfDays = editDTO.getStartSelfDays(); |
|
|
|
Integer completeSelfDays = editDTO.getCompleteSelfDays(); |
|
|
|
List<AppraisalProjectDTO> projects = editDTO.getProjects(); |
|
|
|
for(AppraisalProjectDTO appraisalProject : projects){ |
|
|
|
Project newProject = projectService.getNewProject(appraisalProject.getId()); |
|
|
|
VUtils.isTrue(Objects.isNull(newProject)).throwMessage("项目不存在 " + appraisalProject.getId()); |
|
|
|
// 获取项目终验完成的时间 |
|
|
|
LocalDateTime finishTime = getProjectFinishTime(newProject); |
|
|
|
PerformanceAppraisalProject pap = new PerformanceAppraisalProject(); |
|
|
|
pap.setAppraisalId(editDTO.getId()); |
|
|
|
pap.setProjectId(appraisalProject.getId()); |
|
|
@@ -340,6 +407,11 @@ public class PerformanceAppraisalPlanManage { |
|
|
|
pap.setCreateOn(LocalDateTime.now()); |
|
|
|
pap.setUpdateBy(user.getUsername()); |
|
|
|
pap.setUpdateOn(LocalDateTime.now()); |
|
|
|
LocalDateTime selfAppraisalStart = finishTime.plusDays(startSelfDays); |
|
|
|
pap.setSelfAppraisalStart(selfAppraisalStart); |
|
|
|
long days = startSelfDays + completeSelfDays; |
|
|
|
LocalDateTime selfAppraisalEnd = finishTime.plusDays(days); |
|
|
|
pap.setSelfAppraisalEnd(selfAppraisalEnd); |
|
|
|
performanceAppraisalProjectService.save(pap); |
|
|
|
} |
|
|
|
} |
|
|
@@ -379,12 +451,17 @@ public class PerformanceAppraisalPlanManage { |
|
|
|
PerformanceAppraisal pa = performanceAppraisalService.getById(id); |
|
|
|
VUtils.isTrue(Objects.isNull(pa)).throwMessage("绩效评价不存在 删除失败!"); |
|
|
|
|
|
|
|
//如果到了自评就不能删除了 |
|
|
|
if(pa.getSelfAppraisalStart().compareTo(LocalDateTime.now()) < 0){ |
|
|
|
throw new BizException("自评已经开始 不能够删除绩效评价"); |
|
|
|
} |
|
|
|
|
|
|
|
if(performanceAppraisalService.removeById(id)){ |
|
|
|
// 删除评价计划关联的项目 |
|
|
|
//绩效关联的项目 |
|
|
|
List<PerformanceAppraisalProject> paps = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) |
|
|
|
.eq(PerformanceAppraisalProject::getAppraisalId, id)); |
|
|
|
performanceAppraisalProjectService.removeBatchByIds(paps); |
|
|
|
// 删除评价计划关联的应用 |
|
|
|
//绩效关联的应用 |
|
|
|
List<PerformanceAppraisalApplication> paas = performanceAppraisalApplicationService.list(Wrappers.lambdaQuery(PerformanceAppraisalApplication.class) |
|
|
|
.eq(PerformanceAppraisalApplication::getAppraisalId, id)); |
|
|
|
performanceAppraisalApplicationService.removeBatchByIds(paas); |
|
|
|
return "删除成功"; |
|
|
|
} |
|
|
|
return "删除失败"; |
|
|
@@ -393,8 +470,8 @@ public class PerformanceAppraisalPlanManage { |
|
|
|
public List<PerformanceAppraisalProjectGroupVO> groupList(Long appraisalId,String name) { |
|
|
|
List<PerformanceAppraisalProjectGroup> groups = groupService.list( |
|
|
|
Wrappers.lambdaQuery(PerformanceAppraisalProjectGroup.class) |
|
|
|
.eq(PerformanceAppraisalProjectGroup::getAppraisalId, appraisalId) |
|
|
|
.like(StringUtils.isNotBlank(name),PerformanceAppraisalProjectGroup::getName,name)); |
|
|
|
.eq(PerformanceAppraisalProjectGroup::getAppraisalId, appraisalId) |
|
|
|
.like(StringUtils.isNotBlank(name),PerformanceAppraisalProjectGroup::getName,name)); |
|
|
|
if(CollUtil.isEmpty(groups)){ |
|
|
|
return Collections.emptyList(); |
|
|
|
} |
|
|
@@ -538,11 +615,6 @@ public class PerformanceAppraisalPlanManage { |
|
|
|
PerformanceAppraisal pa = performanceAppraisalService.getById(appraisalId); |
|
|
|
VUtils.isTrue(Objects.isNull(pa)).throwMessage("评价不存在"); |
|
|
|
|
|
|
|
//如果到了自评就不能删除了 |
|
|
|
if(pa.getSelfAppraisalStart().compareTo(LocalDateTime.now()) < 0){ |
|
|
|
throw new BizException("自评已经开始 不能够删除绩效评价"); |
|
|
|
} |
|
|
|
|
|
|
|
if(groupService.removeById(id)){ |
|
|
|
return "删除成功"; |
|
|
|
} |
|
|
@@ -573,7 +645,102 @@ public class PerformanceAppraisalPlanManage { |
|
|
|
return Collections.emptyList(); |
|
|
|
} |
|
|
|
return Arrays.stream(users.split(StrPool.COMMA)).map( |
|
|
|
employeeCode -> userMap.get(employeeCode) |
|
|
|
employeeCode -> userMap.get(employeeCode) |
|
|
|
).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
|
|
|
|
public PageVo<PerformanceAppraisalApplicationVO> applicationList(PerformanceAppraisalListReq req) { |
|
|
|
Page<ProjectApplication> page = req.page(); |
|
|
|
// 获取登录用户所在区域已验收项目 |
|
|
|
UserInfoDetails user = LoginUserUtil.loginUserDetail(); |
|
|
|
String regionCode = user.getRegionCode(); |
|
|
|
List<Project> projects = projectService.list(Wrappers.lambdaQuery(Project.class) |
|
|
|
.eq(Project::getAreaCode,regionCode) |
|
|
|
.eq(Project::getStatus, ProjectStatusEnum.ACCEPTED.getCode()) |
|
|
|
.eq(Project::getNewest, Boolean.TRUE)); |
|
|
|
// 获取已验收项目关联的应用信息 |
|
|
|
List<Integer> projectVersions = projects.stream().map(Project::getVersion).collect(Collectors.toList()); |
|
|
|
List<String> projectCodes = projects.stream().map(Project::getProjectCode).collect(Collectors.toList()); |
|
|
|
LambdaQueryWrapper<ProjectApplication> wrapper = Wrappers.lambdaQuery(ProjectApplication.class) |
|
|
|
.like(StringUtils.isNotBlank(req.getApplicationName()),ProjectApplication::getApplicationName,req.getApplicationName()) |
|
|
|
.like(StringUtils.isNotBlank(req.getBuildOrgName()),ProjectApplication::getBuildOrgName,req.getBuildOrgName()) |
|
|
|
.in(ProjectApplication::getProjectCode,projectCodes) |
|
|
|
.in(ProjectApplication::getProjectVersion,projectVersions) |
|
|
|
.orderByDesc(ProjectApplication::getCreateOn); |
|
|
|
applicationService.page(page,wrapper); |
|
|
|
if(0L == page.getTotal()){ |
|
|
|
return PageVo.empty(); |
|
|
|
} |
|
|
|
List<PerformanceAppraisalApplicationVO> res = page.getRecords().stream().map(r -> { |
|
|
|
PerformanceAppraisalApplicationVO vo = new PerformanceAppraisalApplicationVO(); |
|
|
|
vo.setAppId(r.getId()); |
|
|
|
vo.setApplicationName(Objects.nonNull(r.getApplicationName()) ? r.getApplicationName() : r.getRelatedExistsApplication()); |
|
|
|
vo.setBuildOrgName(r.getBuildOrgName()); |
|
|
|
vo.setApplicationType(r.getApplicationType()); |
|
|
|
vo.setBizDomain(r.getBizDomain()); |
|
|
|
vo.setPublishSide(r.getPublishSide()); |
|
|
|
return vo; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
return PageVo.of(res,page.getTotal()); |
|
|
|
} |
|
|
|
|
|
|
|
public String addProject(PerformanceAppraisalCreateDTO addDTO) { |
|
|
|
List<AppraisalProjectDTO> projects = addDTO.getProjects(); |
|
|
|
if (CollUtil.isEmpty(projects)){ |
|
|
|
throw new BizException("请选择至少一个评价项目!"); |
|
|
|
} |
|
|
|
List<Long> projectIdList = projects.stream().map(AppraisalProjectDTO::getId).collect(Collectors.toList()); |
|
|
|
// 获取已经创建的评价计划中添加的评价项目ID |
|
|
|
List<Long> projectIds = performanceAppraisalProjectService.list().stream() |
|
|
|
.map(PerformanceAppraisalProject::getProjectId).collect(Collectors.toList()); |
|
|
|
// 如果有交集,说明选择的项目中,有已经在其他评价计划中的项目 |
|
|
|
if (Boolean.TRUE.equals(haveIntersection(projectIdList, projectIds))){ |
|
|
|
// 得到交集 |
|
|
|
List<Long> intersection = Lists.newArrayList(projectIdList); |
|
|
|
intersection.retainAll(projectIds); |
|
|
|
// 获取重复添加的项目名称 |
|
|
|
String names = intersection.stream().map(i -> { |
|
|
|
Project project = projectService.getById(i); |
|
|
|
if (Objects.nonNull(project)) { |
|
|
|
return project.getProjectName(); |
|
|
|
} |
|
|
|
return StrPool.EMPTY; |
|
|
|
}).collect(Collectors.joining(StrPool.COMMA)); |
|
|
|
throw new BizException(names + CommonConst.PROJECT_REPEAT); |
|
|
|
} |
|
|
|
return "添加成功"; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String addApplication(PerformanceAppraisalCreateDTO addDTO) { |
|
|
|
List<Long> applicationIdList = addDTO.getApplicationIds(); |
|
|
|
if (CollUtil.isEmpty(applicationIdList)){ |
|
|
|
throw new BizException("请选择至少一个评应用!"); |
|
|
|
} |
|
|
|
// 获取已经创建的评价计划中添加的评价应用ID |
|
|
|
List<Long> applicationIds = performanceAppraisalApplicationService.list().stream() |
|
|
|
.map(PerformanceAppraisalApplication::getApplicationId).collect(Collectors.toList()); |
|
|
|
// 如果有交集,说明选择的应用中,有已经在其他评价计划中的应用 |
|
|
|
if (Boolean.TRUE.equals(haveIntersection(applicationIdList, applicationIds))){ |
|
|
|
// 得到交集 |
|
|
|
List<Long> intersection = Lists.newArrayList(applicationIdList); |
|
|
|
intersection.retainAll(applicationIds); |
|
|
|
// 获取重复添加的应用名称 |
|
|
|
String names = intersection.stream().map(i -> { |
|
|
|
ProjectApplication application = applicationService.getById(i); |
|
|
|
if (Objects.nonNull(application)) { |
|
|
|
return Objects.nonNull(application.getApplicationName()) ? application.getApplicationName() |
|
|
|
: application.getRelatedExistsApplication(); |
|
|
|
} |
|
|
|
return StrPool.EMPTY; |
|
|
|
}).collect(Collectors.joining(StrPool.COMMA)); |
|
|
|
throw new BizException(names + CommonConst.APP_REPEAT); |
|
|
|
} |
|
|
|
return "添加成功"; |
|
|
|
} |
|
|
|
|
|
|
|
private Boolean haveIntersection(List<Long> idList, List<Long> ids) { |
|
|
|
return !CollectionUtil.intersection(idList, ids).isEmpty(); |
|
|
|
} |
|
|
|
|
|
|
|
} |