|
|
@@ -4,10 +4,11 @@ import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
import cn.hutool.core.lang.Assert; |
|
|
|
import cn.hutool.core.map.MapUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.google.common.collect.Lists; |
|
|
|
import com.hz.pm.api.common.model.constant.BizConst; |
|
|
|
import com.hz.pm.api.performance.constant.ProjectBizConst; |
|
|
|
import com.hz.pm.api.performance.enumration.AppIndexTypeEnum; |
|
|
|
import com.hz.pm.api.performance.model.dto.AppAppraisalInfoDTO; |
|
|
@@ -25,11 +26,13 @@ import com.hz.pm.api.user.util.LoginUserUtil; |
|
|
|
import com.ningdatech.basic.exception.BizException; |
|
|
|
import com.ningdatech.basic.function.VUtils; |
|
|
|
import com.ningdatech.basic.model.PageVo; |
|
|
|
import com.ningdatech.basic.util.CollUtils; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.time.LocalDateTime; |
|
|
@@ -68,26 +71,25 @@ public class AppAppraisalManage { |
|
|
|
public PageVo<PerformanceAppraisalVO> list(PerformanceAppraisalListReq req) { |
|
|
|
UserInfoDetails user = LoginUserUtil.loginUserDetail(); |
|
|
|
// 获取当前登录用户的角色列表,只有绩效复评人员才能查看该列表 |
|
|
|
List<Role> userRoleList = user.getUserRoleList(); |
|
|
|
List<Long> roleIdList = userRoleList.stream().map(Role::getId).collect(Collectors.toList()); |
|
|
|
List<Long> roleIdList = user.getRoleIds(); |
|
|
|
if (roleIdList.isEmpty()) { |
|
|
|
return PageVo.empty(); |
|
|
|
} |
|
|
|
Role role = roleService.getOne(Wrappers.lambdaQuery(Role.class) |
|
|
|
.eq(Role::getName, ProjectBizConst.REAPPRAISAL_ROLE)); |
|
|
|
if (Objects.isNull(role)) { |
|
|
|
throw new BizException("登录用户没有复评员角色!"); |
|
|
|
} |
|
|
|
|
|
|
|
// 登录用户不是复评员,不能查看复评计划列表 |
|
|
|
if (!roleIdList.contains(role.getId())) { |
|
|
|
if (Objects.isNull(role) || !roleIdList.contains(role.getId())) { |
|
|
|
return PageVo.empty(); |
|
|
|
} |
|
|
|
|
|
|
|
// 获取所有已添加到评价计划中的应用信息 |
|
|
|
List<PerformanceAppraisalApplication> paas = performanceAppraisalApplicationService.list(); |
|
|
|
Wrapper<PerformanceAppraisalApplication> query = Wrappers.lambdaQuery(PerformanceAppraisalApplication.class) |
|
|
|
.select(PerformanceAppraisalApplication::getAppraisalId); |
|
|
|
List<PerformanceAppraisalApplication> paas = performanceAppraisalApplicationService.list(query); |
|
|
|
// 没有包含应用的评价计划 |
|
|
|
if (CollUtil.isEmpty(paas)) { |
|
|
|
if (paas.isEmpty()) { |
|
|
|
return PageVo.empty(); |
|
|
|
} |
|
|
|
Set<Long> paIds = paas.stream().map(PerformanceAppraisalApplication::getAppraisalId).collect(Collectors.toSet()); |
|
|
|
Set<Long> paIds = CollUtils.fieldSet(paas, PerformanceAppraisalApplication::getAppraisalId); |
|
|
|
Page<PerformanceAppraisal> page = req.page(); |
|
|
|
LambdaQueryWrapper<PerformanceAppraisal> wrapper = Wrappers.lambdaQuery(PerformanceAppraisal.class) |
|
|
|
.in(PerformanceAppraisal::getId, paIds) |
|
|
@@ -102,40 +104,42 @@ public class AppAppraisalManage { |
|
|
|
|
|
|
|
public PageVo<PerformanceAppraisalAppVO> unEvaluateList(Long planId, PerformanceAppraisalListReq req) { |
|
|
|
UserInfoDetails user = LoginUserUtil.loginUserDetail(); |
|
|
|
String employeeCode = user.getEmployeeCode(); |
|
|
|
String userIdStr = user.getUserIdStr(); |
|
|
|
|
|
|
|
PerformanceAppraisal plan = performanceAppraisalService.getById(planId); |
|
|
|
VUtils.isTrue(Objects.isNull(plan)).throwMessage("该评价计划不存在!"); |
|
|
|
|
|
|
|
// 获取分组所在评价计划添加的未完成评价的应用信息 |
|
|
|
List<PerformanceAppraisalApplication> paas = performanceAppraisalApplicationService.list(Wrappers.lambdaQuery(PerformanceAppraisalApplication.class) |
|
|
|
Wrapper<PerformanceAppraisalApplication> query = Wrappers.lambdaQuery(PerformanceAppraisalApplication.class) |
|
|
|
.select(PerformanceAppraisalApplication::getApplicationId) |
|
|
|
.eq(PerformanceAppraisalApplication::getAppraisalId, planId) |
|
|
|
.eq(PerformanceAppraisalApplication::getIsCompleteAppraisal, Boolean.FALSE)); |
|
|
|
.eq(PerformanceAppraisalApplication::getIsCompleteAppraisal, Boolean.FALSE); |
|
|
|
List<PerformanceAppraisalApplication> paas = performanceAppraisalApplicationService.list(query); |
|
|
|
// 没有当前用户待评价的应用信息 |
|
|
|
if (CollUtil.isEmpty(paas)) { |
|
|
|
return PageVo.empty(); |
|
|
|
} |
|
|
|
List<Long> ids = paas.stream().map(PerformanceAppraisalApplication::getApplicationId).collect(Collectors.toList()); |
|
|
|
List<Long> ids = CollUtils.fieldList(paas, PerformanceAppraisalApplication::getApplicationId); |
|
|
|
// 从绩效评价打分信息表中获取上述绩效评价计划应用的打分信息 |
|
|
|
List<PerformanceAppraisalAppScoreInfo> appraisalScoreInfos = performanceAppraisalAppScoreInfoService.list(Wrappers.lambdaQuery(PerformanceAppraisalAppScoreInfo.class) |
|
|
|
.eq(PerformanceAppraisalAppScoreInfo::getAppraisalId, planId)); |
|
|
|
List<Long> appIds; |
|
|
|
Wrapper<PerformanceAppraisalAppScoreInfo> paaiQuery = Wrappers.lambdaQuery(PerformanceAppraisalAppScoreInfo.class) |
|
|
|
.select(PerformanceAppraisalAppScoreInfo::getApplicationId, PerformanceAppraisalAppScoreInfo::getAppraisalEmployeeCode) |
|
|
|
.eq(PerformanceAppraisalAppScoreInfo::getAppraisalId, planId); |
|
|
|
List<PerformanceAppraisalAppScoreInfo> appraisalScoreInfos = performanceAppraisalAppScoreInfoService.list(paaiQuery); |
|
|
|
if (CollUtil.isNotEmpty(appraisalScoreInfos)) { |
|
|
|
// 筛选出当前登录用户已进行打分的应用信息 |
|
|
|
List<Long> scoredAppIds = appraisalScoreInfos.stream() |
|
|
|
.filter(a -> employeeCode.equals(a.getAppraisalEmployeeCode())) |
|
|
|
.map(PerformanceAppraisalAppScoreInfo::getApplicationId) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
ids.removeAll(scoredAppIds); |
|
|
|
appraisalScoreInfos.forEach(w -> { |
|
|
|
if (userIdStr.equals(w.getAppraisalEmployeeCode())) { |
|
|
|
ids.remove(w.getApplicationId()); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
appIds = ids; |
|
|
|
// 没有当前用户待评价的应用信息 |
|
|
|
if (CollUtil.isEmpty(appIds)) { |
|
|
|
if (CollUtil.isEmpty(ids)) { |
|
|
|
return PageVo.empty(); |
|
|
|
} |
|
|
|
Page<ProjectApplication> page = req.page(); |
|
|
|
LambdaQueryWrapper<ProjectApplication> wrapper = Wrappers.lambdaQuery(ProjectApplication.class) |
|
|
|
.in(ProjectApplication::getId, appIds) |
|
|
|
.in(ProjectApplication::getId, ids) |
|
|
|
.like(StringUtils.isNotBlank(req.getApplicationName()), ProjectApplication::getApplicationName, req.getApplicationName()); |
|
|
|
projectApplicationService.page(page, wrapper); |
|
|
|
|
|
|
@@ -146,12 +150,11 @@ public class AppAppraisalManage { |
|
|
|
List<PerformanceAppraisalAppVO> res = page.getRecords().stream() |
|
|
|
.map(p -> { |
|
|
|
PerformanceAppraisalAppVO vo = BeanUtil.copyProperties(p, PerformanceAppraisalAppVO.class); |
|
|
|
vo.setCanAppraisal(checkCanAppraisal(employeeCode, p.getId(), planId)); |
|
|
|
vo.setCanAppraisal(checkCanAppraisal(userIdStr, p.getId(), planId)); |
|
|
|
vo.setApplicationName(StringUtils.isNotBlank(p.getApplicationName()) ? p.getApplicationName() : p.getRelatedExistsApplication()); |
|
|
|
vo.setAppraisalId(planId); |
|
|
|
return vo; |
|
|
|
}) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
return PageVo.of(res, page.getTotal()); |
|
|
|
} |
|
|
@@ -174,14 +177,15 @@ public class AppAppraisalManage { |
|
|
|
// 从绩效评价打分信息表中获取上述绩效评价计划应用的打分信息 |
|
|
|
List<PerformanceAppraisalAppScoreInfo> appraisalScoreInfos = performanceAppraisalAppScoreInfoService.list(Wrappers.lambdaQuery(PerformanceAppraisalAppScoreInfo.class) |
|
|
|
.eq(PerformanceAppraisalAppScoreInfo::getAppraisalId, planId)); |
|
|
|
List<Long> appIds = Lists.newArrayList(); |
|
|
|
if (CollUtil.isNotEmpty(appraisalScoreInfos)) { |
|
|
|
// 筛选出当前登录用户已进行打分的应用信息 |
|
|
|
appIds = appraisalScoreInfos.stream() |
|
|
|
.filter(a -> employeeCode.equals(a.getAppraisalEmployeeCode())) |
|
|
|
.map(PerformanceAppraisalAppScoreInfo::getApplicationId) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
if (CollUtil.isEmpty(appraisalScoreInfos)) { |
|
|
|
return PageVo.empty(); |
|
|
|
} |
|
|
|
// 筛选出当前登录用户已进行打分的应用信息 |
|
|
|
List<Long> appIds = appraisalScoreInfos.stream() |
|
|
|
.filter(a -> employeeCode.equals(a.getAppraisalEmployeeCode())) |
|
|
|
.map(PerformanceAppraisalAppScoreInfo::getApplicationId) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
// 没有当前用户已评价的应用信息 |
|
|
|
if (CollUtil.isEmpty(appIds)) { |
|
|
@@ -219,17 +223,16 @@ public class AppAppraisalManage { |
|
|
|
* @param appraisalId |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private Boolean checkCanAppraisal(String employeeCode, Long appId, Long appraisalId) { |
|
|
|
private boolean checkCanAppraisal(String employeeCode, Long appId, Long appraisalId) { |
|
|
|
// 从绩效评价应用打分信息表中查询打分人员为当前登录复评用户的打分信息 |
|
|
|
// 如果没有相关的打分信息,说明是当前登录复评用户是首次评价 |
|
|
|
List<PerformanceAppraisalAppScoreInfo> scoreInfos = performanceAppraisalAppScoreInfoService.list(Wrappers.lambdaQuery(PerformanceAppraisalAppScoreInfo.class) |
|
|
|
Wrapper<PerformanceAppraisalAppScoreInfo> query = Wrappers.lambdaQuery(PerformanceAppraisalAppScoreInfo.class) |
|
|
|
.eq(PerformanceAppraisalAppScoreInfo::getApplicationId, appId) |
|
|
|
.eq(PerformanceAppraisalAppScoreInfo::getAppraisalId, appraisalId) |
|
|
|
.eq(PerformanceAppraisalAppScoreInfo::getAppraisalEmployeeCode, employeeCode)); |
|
|
|
if (CollUtil.isEmpty(scoreInfos)) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
return Boolean.FALSE; |
|
|
|
.eq(PerformanceAppraisalAppScoreInfo::getAppraisalEmployeeCode, employeeCode) |
|
|
|
.last(BizConst.LIMIT_1); |
|
|
|
long scoreInfoNum = performanceAppraisalAppScoreInfoService.count(query); |
|
|
|
return scoreInfoNum == 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@@ -319,9 +322,10 @@ public class AppAppraisalManage { |
|
|
|
return resVo; |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public String saveAppraisal(ProjectAppraisalDTO param) { |
|
|
|
UserInfoDetails userDetail = LoginUserUtil.loginUserDetail(); |
|
|
|
String employeeCode = userDetail.getEmployeeCode(); |
|
|
|
String userIdStr = userDetail.getUserIdStr(); |
|
|
|
String username = userDetail.getUsername(); |
|
|
|
|
|
|
|
Long applicationId = param.getApplicationId(); |
|
|
@@ -344,38 +348,34 @@ public class AppAppraisalManage { |
|
|
|
// 查出通用、辅助应用指标分数信息 |
|
|
|
Map<Long, PerformanceAppraisalAppIndicator> indexMap = MapUtil.newHashMap(); |
|
|
|
if (CollUtil.isNotEmpty(indexIds)) { |
|
|
|
List<PerformanceAppraisalAppIndicator> indexList = performanceAppraisalAppIndicatorService.list(Wrappers.lambdaQuery(PerformanceAppraisalAppIndicator.class) |
|
|
|
.in(PerformanceAppraisalAppIndicator::getId, indexIds)); |
|
|
|
List<PerformanceAppraisalAppIndicator> indexList = performanceAppraisalAppIndicatorService.listByIds(indexIds); |
|
|
|
if (CollUtil.isEmpty(indexList)) { |
|
|
|
throw new BizException("通用/辅助评价指标不存在!"); |
|
|
|
} |
|
|
|
indexMap = indexList.stream().collect(Collectors.toMap(PerformanceAppraisalAppIndicator::getId, d -> d)); |
|
|
|
indexList.forEach(w -> indexMap.put(w.getId(), w)); |
|
|
|
} |
|
|
|
|
|
|
|
// 查出应用业务指标分数信息 |
|
|
|
Map<Long, ProjectCoreBusinessIndicators> businessIndexMap = MapUtil.newHashMap(); |
|
|
|
if (CollUtil.isNotEmpty(businessIndexIds)) { |
|
|
|
List<ProjectCoreBusinessIndicators> businessIndexList = projectCoreBusinessIndicatorsService.list(Wrappers.lambdaQuery(ProjectCoreBusinessIndicators.class) |
|
|
|
.in(ProjectCoreBusinessIndicators::getId, businessIndexIds)); |
|
|
|
List<ProjectCoreBusinessIndicators> businessIndexList = projectCoreBusinessIndicatorsService.listByIds(businessIndexIds); |
|
|
|
if (CollUtil.isEmpty(businessIndexList)) { |
|
|
|
throw new BizException("核心业务评价指标不存在!"); |
|
|
|
} |
|
|
|
businessIndexMap = businessIndexList.stream().collect(Collectors.toMap(ProjectCoreBusinessIndicators::getId, d -> d)); |
|
|
|
businessIndexList.forEach(w -> businessIndexMap.put(w.getId(), w)); |
|
|
|
} |
|
|
|
|
|
|
|
Map<Long, PerformanceAppraisalAppIndicator> finalIndexMap = indexMap; |
|
|
|
Map<Long, ProjectCoreBusinessIndicators> finalBusinessIndexMap = businessIndexMap; |
|
|
|
List<PerformanceAppraisalAppScoreInfo> scoreInfos = appAppraisalInfoList.stream().map(a -> { |
|
|
|
if (AppIndexTypeEnum.COMMON.getCode().equals(a.getIndexType()) || |
|
|
|
AppIndexTypeEnum.AUX.getCode().equals(a.getIndexType())) { |
|
|
|
PerformanceAppraisalAppIndicator appIndicator = finalIndexMap.get(a.getIndexId()); |
|
|
|
PerformanceAppraisalAppIndicator appIndicator = indexMap.get(a.getIndexId()); |
|
|
|
BigDecimal score = a.getScore(); |
|
|
|
BigDecimal indexScore = appIndicator.getIndexScore(); |
|
|
|
if (score.compareTo(indexScore) > 0 || score.compareTo(BigDecimal.ZERO) < 0) { |
|
|
|
throw new BizException("评价得分必须大于等于0且小于等于指标分值!"); |
|
|
|
} |
|
|
|
} else if (AppIndexTypeEnum.BUSINESS.getCode().equals(a.getIndexType())) { |
|
|
|
ProjectCoreBusinessIndicators coreBusinessIndicators = finalBusinessIndexMap.get(a.getIndexId()); |
|
|
|
ProjectCoreBusinessIndicators coreBusinessIndicators = businessIndexMap.get(a.getIndexId()); |
|
|
|
BigDecimal score = a.getScore(); |
|
|
|
BigDecimal indexScore = coreBusinessIndicators.getScore(); |
|
|
|
if (score.compareTo(indexScore) > 0 || score.compareTo(BigDecimal.ZERO) < 0) { |
|
|
@@ -386,7 +386,7 @@ public class AppAppraisalManage { |
|
|
|
PerformanceAppraisalAppScoreInfo scoreInfo = new PerformanceAppraisalAppScoreInfo(); |
|
|
|
scoreInfo.setAppraisalScore(a.getScore()); |
|
|
|
scoreInfo.setAppraisalId(appraisalId); |
|
|
|
scoreInfo.setAppraisalEmployeeCode(employeeCode); |
|
|
|
scoreInfo.setAppraisalEmployeeCode(userIdStr); |
|
|
|
scoreInfo.setAppraisalEmployeeName(username); |
|
|
|
scoreInfo.setApplicationId(applicationId); |
|
|
|
scoreInfo.setIndexId(a.getIndexId()); |
|
|
|