|
|
@@ -8,14 +8,18 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.ningdatech.basic.exception.BizException; |
|
|
|
import com.ningdatech.basic.function.VUtils; |
|
|
|
import com.ningdatech.basic.model.PageVo; |
|
|
|
import com.ningdatech.pmapi.performance.model.entity.PerformanceAppraisal; |
|
|
|
import com.ningdatech.pmapi.performance.model.entity.PerformanceAppraisalProject; |
|
|
|
import com.ningdatech.basic.util.StrPool; |
|
|
|
import com.ningdatech.pmapi.performance.constant.BizConst; |
|
|
|
import com.ningdatech.pmapi.performance.enumration.AppraisalTypeEnum; |
|
|
|
import com.ningdatech.pmapi.performance.helper.TemplateDetailBuildHelper; |
|
|
|
import com.ningdatech.pmapi.performance.model.dto.ProjectAppraisalDTO; |
|
|
|
import com.ningdatech.pmapi.performance.model.dto.ProjectAppraisalInfoDTO; |
|
|
|
import com.ningdatech.pmapi.performance.model.entity.*; |
|
|
|
import com.ningdatech.pmapi.performance.model.req.PerformanceAppraisalListReq; |
|
|
|
import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalProjectVO; |
|
|
|
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.performance.model.vo.*; |
|
|
|
import com.ningdatech.pmapi.performance.service.*; |
|
|
|
import com.ningdatech.pmapi.portrait.model.entity.ProjectTag; |
|
|
|
import com.ningdatech.pmapi.portrait.service.IProjectTagService; |
|
|
|
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; |
|
|
|
import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeEnum; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.entity.Project; |
|
|
@@ -30,7 +34,9 @@ import lombok.AllArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
@@ -47,16 +53,14 @@ import java.util.stream.Collectors; |
|
|
|
public class OrgSelfAppraisalManage { |
|
|
|
|
|
|
|
private final IPerformanceAppraisalService performanceAppraisalService; |
|
|
|
|
|
|
|
private final IPerformanceAppraisalProjectService performanceAppraisalProjectService; |
|
|
|
|
|
|
|
private final IPerformanceAppraisalApplicationService performanceAppraisalApplicationService; |
|
|
|
|
|
|
|
private final IProjectService projectService; |
|
|
|
|
|
|
|
private final IProjectApplicationService applicationService; |
|
|
|
private final IRoleService roleService; |
|
|
|
|
|
|
|
private final IPerformanceIndicatorProjectTemplateService indicatorProjectTemplateService; |
|
|
|
private final TemplateDetailBuildHelper templateDetailBuildHelper; |
|
|
|
private final IPerformanceIndicatorProjectTemplateDetailService indicatorProjectTemplateDetailService; |
|
|
|
private final IProjectTagService projectTagService; |
|
|
|
private final IPerformanceAppraisalScoreInfoService performanceAppraisalScoreInfoService; |
|
|
|
/** |
|
|
|
* 绩效列表 |
|
|
|
* @param req |
|
|
@@ -121,7 +125,8 @@ public class OrgSelfAppraisalManage { |
|
|
|
|
|
|
|
// 获取评价计划内已添加的待评价项目信息 |
|
|
|
List<PerformanceAppraisalProject> paps = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) |
|
|
|
.eq(PerformanceAppraisalProject::getAppraisalId, plan.getId())); |
|
|
|
.eq(PerformanceAppraisalProject::getAppraisalId, plan.getId())).stream() |
|
|
|
.filter(p -> Objects.isNull(p.getSelfAppraisalScoreTime())).collect(Collectors.toList()); |
|
|
|
Map<Long, PerformanceAppraisalProject> papsMap = paps.stream().collect(Collectors.toMap(PerformanceAppraisalProject::getProjectId, p -> p)); |
|
|
|
|
|
|
|
if(CollUtil.isEmpty(paps)){ |
|
|
@@ -146,11 +151,11 @@ public class OrgSelfAppraisalManage { |
|
|
|
.map(p -> { |
|
|
|
PerformanceAppraisalProjectVO vo = BeanUtil.copyProperties(p, PerformanceAppraisalProjectVO.class); |
|
|
|
PerformanceAppraisalProject appraisalProject = papsMap.get(p.getId()); |
|
|
|
BeanUtil.copyProperties(appraisalProject,vo); |
|
|
|
vo.setProjectId(appraisalProject.getProjectId()); |
|
|
|
vo.setProjectTypeName(ProjectTypeEnum.getDesc(p.getProjectType())); |
|
|
|
vo.setIsReAppraisal(appraisalProject.getIsReAppraisal()); |
|
|
|
vo.setSelfAppraisalStart(appraisalProject.getSelfAppraisalStart()); |
|
|
|
vo.setSelfAppraisalEnd(appraisalProject.getSelfAppraisalEnd()); |
|
|
|
vo.setCanSelfAppraisal(checkCanSelfAppraisal(appraisalProject)); |
|
|
|
vo.setAppraisalId(planId); |
|
|
|
return vo; |
|
|
|
}) |
|
|
|
.collect(Collectors.toList()); |
|
|
@@ -160,12 +165,54 @@ public class OrgSelfAppraisalManage { |
|
|
|
|
|
|
|
/** |
|
|
|
* 已经自评表 |
|
|
|
* |
|
|
|
* @param planId |
|
|
|
* @param req |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public PageVo<PerformanceAppraisalProjectVO> appraisaledList(Long planId) { |
|
|
|
public PageVo<PerformanceAppraisalProjectVO> appraisaledList(Long planId, PerformanceAppraisalListReq req) { |
|
|
|
UserInfoDetails user = LoginUserUtil.loginUserDetail(); |
|
|
|
|
|
|
|
PerformanceAppraisal plan = performanceAppraisalService.getById(planId); |
|
|
|
VUtils.isTrue(Objects.isNull(plan)).throwMessage("该评价计划不存在!"); |
|
|
|
|
|
|
|
// 获取评价计划内已添加的已评价项目信息 |
|
|
|
List<PerformanceAppraisalProject> paps = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) |
|
|
|
.eq(PerformanceAppraisalProject::getAppraisalId, plan.getId())).stream() |
|
|
|
.filter(p -> Objects.nonNull(p.getSelfAppraisalScoreTime())).collect(Collectors.toList()); |
|
|
|
Map<Long, PerformanceAppraisalProject> papsMap = paps.stream().collect(Collectors.toMap(PerformanceAppraisalProject::getProjectId, p -> p)); |
|
|
|
|
|
|
|
if(CollUtil.isEmpty(paps)){ |
|
|
|
return PageVo.empty(); |
|
|
|
} |
|
|
|
|
|
|
|
return PageVo.empty(); |
|
|
|
// 获取本单位在当前评价计划内的项目 |
|
|
|
Set<String> projectCodes = paps.stream().map(PerformanceAppraisalProject::getProjectCode).collect(Collectors.toSet()); |
|
|
|
Page<Project> page = req.page(); |
|
|
|
LambdaQueryWrapper<Project> wrapper = Wrappers.lambdaQuery(Project.class) |
|
|
|
.in(Project::getProjectCode, projectCodes) |
|
|
|
.eq(Project::getNewest, Boolean.TRUE) |
|
|
|
.eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()) |
|
|
|
.like(StringUtils.isNotBlank(req.getProjectName()),Project::getProjectName,req.getProjectName()); |
|
|
|
projectService.page(page,wrapper); |
|
|
|
|
|
|
|
if(0L == page.getTotal()){ |
|
|
|
return PageVo.empty(); |
|
|
|
} |
|
|
|
List<PerformanceAppraisalProjectVO> res = page.getRecords().stream() |
|
|
|
.map(p -> { |
|
|
|
PerformanceAppraisalProjectVO vo = BeanUtil.copyProperties(p, PerformanceAppraisalProjectVO.class); |
|
|
|
PerformanceAppraisalProject appraisalProject = papsMap.get(p.getId()); |
|
|
|
BeanUtil.copyProperties(appraisalProject,vo); |
|
|
|
vo.setProjectId(appraisalProject.getProjectId()); |
|
|
|
vo.setProjectTypeName(ProjectTypeEnum.getDesc(p.getProjectType())); |
|
|
|
vo.setCanSelfAppraisal(checkCanSelfAppraisal(appraisalProject)); |
|
|
|
vo.setAppraisalId(planId); |
|
|
|
return vo; |
|
|
|
}) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
return PageVo.of(res,page.getTotal()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@@ -174,10 +221,143 @@ public class OrgSelfAppraisalManage { |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private Boolean checkCanSelfAppraisal(PerformanceAppraisalProject appraisalProject) { |
|
|
|
// 在自评时间段内,且是首次自评(打分时间为空) |
|
|
|
if(LocalDateTime.now().compareTo(appraisalProject.getSelfAppraisalStart()) > 0 && |
|
|
|
LocalDateTime.now().compareTo(appraisalProject.getSelfAppraisalEnd()) < 0){ |
|
|
|
LocalDateTime.now().compareTo(appraisalProject.getSelfAppraisalEnd()) < 0 && |
|
|
|
Objects.isNull(appraisalProject.getSelfAppraisalScoreTime())){ |
|
|
|
return Boolean.TRUE; |
|
|
|
} |
|
|
|
return Boolean.FALSE; |
|
|
|
} |
|
|
|
|
|
|
|
public ProjectAppraisalIndexDetailVO getAppraisalTemplateDetail(String projectCode) { |
|
|
|
UserInfoDetails user = LoginUserUtil.loginUserDetail(); |
|
|
|
String regionCode = user.getRegionCode(); |
|
|
|
|
|
|
|
ProjectAppraisalIndexDetailVO vo = new ProjectAppraisalIndexDetailVO(); |
|
|
|
|
|
|
|
// 根据项目编码获取最新版本的项目信息 |
|
|
|
Project project = projectService.getProjectByCode(projectCode); |
|
|
|
VUtils.isTrue(Objects.isNull(project)).throwMessage("项目不存在!"); |
|
|
|
// 根据项目类型、预算年度、批复金额、项目标签匹配本区域指标模版 |
|
|
|
Integer projectType = project.getProjectType(); |
|
|
|
Integer projectYear = project.getProjectYear(); |
|
|
|
BigDecimal approvalAmount = project.getApprovalAmount(); |
|
|
|
VUtils.isTrue(Objects.isNull(approvalAmount)).throwMessage("未获取到该项目的立项批复金额"); |
|
|
|
// 根据项目code获取项目标签ID列表 |
|
|
|
List<Long> tagIdList = projectTagService.list(Wrappers.lambdaQuery(ProjectTag.class) |
|
|
|
.eq(ProjectTag::getProjectCode, projectCode)).stream() |
|
|
|
.map(ProjectTag::getTagId).collect(Collectors.toList()); |
|
|
|
VUtils.isTrue(CollUtil.isEmpty(tagIdList)).throwMessage("当前项目未设置标签,匹配不到指标模板,请至项目库或评价计划编辑页面设置标签!"); |
|
|
|
|
|
|
|
List<String> strIdList = tagIdList.stream().map(String::valueOf).collect(Collectors.toList()); |
|
|
|
String projectTagIds = String.join(StrPool.COMMA, strIdList); |
|
|
|
|
|
|
|
Integer amountRange = null; |
|
|
|
if (approvalAmount.compareTo(BigDecimal.valueOf(BizConst.FIVE_MILLION)) < 0){ |
|
|
|
amountRange = BizConst.AMOUNT_RANGE_ONE; |
|
|
|
} else if (approvalAmount.compareTo(BigDecimal.valueOf(BizConst.FIVE_MILLION)) >= 0 && |
|
|
|
approvalAmount.compareTo(BigDecimal.valueOf(BizConst.TWENTY_MILLION)) < 0) { |
|
|
|
amountRange = BizConst.AMOUNT_RANGE_TWO; |
|
|
|
}else if (approvalAmount.compareTo(BigDecimal.valueOf(BizConst.TWENTY_MILLION)) >= 0){ |
|
|
|
amountRange = BizConst.AMOUNT_RANGE_THREE; |
|
|
|
} |
|
|
|
LambdaQueryWrapper<PerformanceIndicatorProjectTemplate> wrapper = Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplate.class) |
|
|
|
.eq(PerformanceIndicatorProjectTemplate::getRegionCode, regionCode) |
|
|
|
.eq(PerformanceIndicatorProjectTemplate::getProjectType, projectType) |
|
|
|
.eq(PerformanceIndicatorProjectTemplate::getProjectYear, projectYear) |
|
|
|
.eq(PerformanceIndicatorProjectTemplate::getAmountRange, amountRange) |
|
|
|
.eq(PerformanceIndicatorProjectTemplate::getProjectTagIds,projectTagIds) |
|
|
|
.orderByDesc(PerformanceIndicatorProjectTemplate::getUpdateOn); |
|
|
|
PerformanceIndicatorProjectTemplate projectTemplate = indicatorProjectTemplateService.getOne(wrapper); |
|
|
|
|
|
|
|
if (Objects.isNull(projectTemplate)){ |
|
|
|
throw new BizException("该项目匹配不到指标模板,请返回上一页或者刷新重试。"); |
|
|
|
} |
|
|
|
// 装配项目指标详情及分数信息 |
|
|
|
// 获取模版绩效指标详情 |
|
|
|
List<PerformanceIndicatorProjectTemplateDetail> templateDetails = indicatorProjectTemplateDetailService.list(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class) |
|
|
|
.eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId, projectTemplate.getId())); |
|
|
|
// 获取模版附加绩效指标详情 |
|
|
|
List<PerformanceIndicatorProjectTemplateDetail> additionalTemplateDetails = indicatorProjectTemplateDetailService.list(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class) |
|
|
|
.eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId, projectTemplate.getId()) |
|
|
|
.eq(PerformanceIndicatorProjectTemplateDetail::getIsAdditional,Boolean.TRUE)); |
|
|
|
List<ProjectTemplateDetailVO> templateDetailVos = templateDetailBuildHelper.buildTemplateDetail(templateDetails); |
|
|
|
List<ProjectTemplateDetailVO> additionalTemplateDetailVos = templateDetailBuildHelper.buildTemplateDetail(additionalTemplateDetails); |
|
|
|
vo.setProjectName(project.getProjectName()); |
|
|
|
vo.setBuildOrgName(project.getBuildOrgName()); |
|
|
|
vo.setProjectStatus(project.getStatus()); |
|
|
|
vo.setProjectYear(projectYear); |
|
|
|
vo.setApprovalAmount(approvalAmount); |
|
|
|
vo.setTemplateDetails(templateDetailVos); |
|
|
|
vo.setAdditionalIndexDetails(additionalTemplateDetailVos); |
|
|
|
return vo; |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public String submitSelfAppraisal(ProjectAppraisalDTO param) { |
|
|
|
UserInfoDetails userDetail = LoginUserUtil.loginUserDetail(); |
|
|
|
String employeeCode = userDetail.getEmployeeCode(); |
|
|
|
String username = userDetail.getUsername(); |
|
|
|
Long appraisalId = param.getAppraisalId(); |
|
|
|
Long appraisalProjectId = param.getAppraisalProjectId(); |
|
|
|
List<ProjectAppraisalInfoDTO> appraisalInfoList = param.getAppraisalInfoList(); |
|
|
|
// 判断该项目是否还存在于计划或分组中 |
|
|
|
PerformanceAppraisalProject appraisalProject = performanceAppraisalProjectService.getOne(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) |
|
|
|
.eq(PerformanceAppraisalProject::getAppraisalId, appraisalId) |
|
|
|
.eq(PerformanceAppraisalProject::getProjectId, appraisalProjectId)); |
|
|
|
if (Objects.isNull(appraisalProject)){ |
|
|
|
throw new BizException("该项目已被移除评价计划,请返回上一页或者刷新重试!"); |
|
|
|
} |
|
|
|
// 根据项目模板详情ID保存自评得分、打分时间 |
|
|
|
if (CollUtil.isEmpty(appraisalInfoList)){ |
|
|
|
throw new BizException("填写所有自评得分后才能提交!"); |
|
|
|
} |
|
|
|
List<Long> ids = appraisalInfoList.stream() |
|
|
|
.map(ProjectAppraisalInfoDTO::getProjectTemplateDetailId) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
// 查出项目模版详情信息 |
|
|
|
List<PerformanceIndicatorProjectTemplateDetail> detailList = indicatorProjectTemplateDetailService.list(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class) |
|
|
|
.in(PerformanceIndicatorProjectTemplateDetail::getId, ids)); |
|
|
|
if (CollUtil.isEmpty(detailList)){ |
|
|
|
throw new BizException("评价指标不存在!"); |
|
|
|
} |
|
|
|
Map<Long, PerformanceIndicatorProjectTemplateDetail> detailMap = detailList.stream().collect(Collectors.toMap(PerformanceIndicatorProjectTemplateDetail::getId, d -> d)); |
|
|
|
List<PerformanceAppraisalScoreInfo> scoreInfos = appraisalInfoList.stream().map(a -> { |
|
|
|
PerformanceIndicatorProjectTemplateDetail templateDetail = detailMap.get(a.getProjectTemplateDetailId()); |
|
|
|
BigDecimal score = a.getScore(); |
|
|
|
BigDecimal indexScore = templateDetail.getIndexScore(); |
|
|
|
if (score.compareTo(indexScore) > 0 || score.compareTo(BigDecimal.ZERO) < 0){ |
|
|
|
throw new BizException("自评得分必须大于等于0且小于等于指标分值!"); |
|
|
|
} |
|
|
|
// 保存自评分数信息 |
|
|
|
PerformanceAppraisalScoreInfo scoreInfo = new PerformanceAppraisalScoreInfo(); |
|
|
|
scoreInfo.setAppraisalBasis(a.getAppraisalBasis()); |
|
|
|
scoreInfo.setAppraisalScore(a.getScore()); |
|
|
|
scoreInfo.setAppraisalBasisAppendix(a.getAppraisalBasisAppendix()); |
|
|
|
scoreInfo.setAppraisalType(AppraisalTypeEnum.SELF_APPRAISAL.getCode()); |
|
|
|
scoreInfo.setTemplateDetailId(templateDetail.getId()); |
|
|
|
scoreInfo.setTemplateId(templateDetail.getTemplateId()); |
|
|
|
scoreInfo.setAppraisalEmployeeCode(employeeCode); |
|
|
|
scoreInfo.setAppraisalEmployeeName(username); |
|
|
|
scoreInfo.setCreateOn(LocalDateTime.now()); |
|
|
|
scoreInfo.setCreateBy(username); |
|
|
|
return scoreInfo; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
if (performanceAppraisalScoreInfoService.saveBatch(scoreInfos)){ |
|
|
|
// 计算自评总分并保存 |
|
|
|
BigDecimal selfAppraisalTotalScore = appraisalInfoList.stream() |
|
|
|
.map(ProjectAppraisalInfoDTO::getScore) |
|
|
|
.filter(Objects::nonNull) |
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
|
appraisalProject.setSelfAppraisalTotalScore(selfAppraisalTotalScore); |
|
|
|
appraisalProject.setSelfAppraisalScoreTime(LocalDateTime.now()); |
|
|
|
appraisalProject.setUpdateOn(LocalDateTime.now()); |
|
|
|
appraisalProject.setUpdateBy(username); |
|
|
|
performanceAppraisalProjectService.updateById(appraisalProject); |
|
|
|
return "提交成功"; |
|
|
|
} |
|
|
|
return "提交失败"; |
|
|
|
} |
|
|
|
} |