Ver código fonte

Merge branch 'ls2_performance_appraisal_0801' of http://git.ningdatech.com/liushuai/project-management into dev

master
CMM 1 ano atrás
pai
commit
6f2754499f
18 arquivos alterados com 684 adições e 235 exclusões
  1. +11
    -24
      pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/ReAppraisalController.java
  2. +50
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/VerifyController.java
  3. +2
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/performance/helper/TemplateDetailBuildHelper.java
  4. +42
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/performance/helper/impl/TemplateDetailBuildHelperImpl.java
  5. +2
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/IndicatorConfigManage.java
  6. +9
    -3
      pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/OrgSelfAppraisalManage.java
  7. +3
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/PerformanceAppraisalPlanManage.java
  8. +163
    -203
      pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/ReAppraisalManage.java
  9. +332
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/VerifyManage.java
  10. +3
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/PerformanceAppraisalProjectGroupSaveDTO.java
  11. +6
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/ProjectAppraisalDTO.java
  12. +9
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalProject.java
  13. +3
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalProjectGroup.java
  14. +9
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalScoreInfo.java
  15. +12
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceAppraisalProjectVO.java
  16. +13
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceAppraisalVO.java
  17. +9
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/ProjectAppraisalIndexDetailVO.java
  18. +6
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/ProjectTemplateDetailVO.java

+ 11
- 24
pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/ReAppraisalController.java Ver arquivo

@@ -6,7 +6,6 @@ import com.ningdatech.pmapi.performance.manage.ReAppraisalManage;
import org.springframework.web.bind.annotation.*;

import com.ningdatech.basic.model.PageVo;
import com.ningdatech.pmapi.performance.manage.OrgSelfAppraisalManage;
import com.ningdatech.pmapi.performance.model.dto.ProjectAppraisalDTO;
import com.ningdatech.pmapi.performance.model.req.PerformanceAppraisalListReq;
import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalProjectVO;
@@ -37,28 +36,16 @@ public class ReAppraisalController {
return reAppraisalManage.list(req);
}

//@GetMapping("/pending-list/{planId}")
//@ApiOperation("当前绩效评价待自评列表")
//public PageVo<PerformanceAppraisalProjectVO> pendingList(@PathVariable Long planId, PerformanceAppraisalListReq req) {
// return selfAppraisalManage.pendingList(planId,req);
//}
//
//@GetMapping("/appraisaled-list/{planId}")
//@ApiOperation("当前绩效评价已自评列表")
//public PageVo<PerformanceAppraisalProjectVO> appraisaledList(@PathVariable Long planId,PerformanceAppraisalListReq req) {
// return selfAppraisalManage.appraisaledList(planId,req);
//}
//
//@GetMapping("/get-appraisal-template-detail/{projectCode}")
//@ApiOperation("获取自评模版详情")
//public ProjectAppraisalIndexDetailVO getAppraisalTemplateDetail(@PathVariable String projectCode){
// return selfAppraisalManage.getAppraisalTemplateDetail(projectCode);
//}
//
//@PostMapping("/submit-self-appraisal")
//@ApiOperation("提交自评")
//public String submitSelfAppraisal(@Valid @RequestBody ProjectAppraisalDTO param){
// return selfAppraisalManage.submitSelfAppraisal(param);
//}
@GetMapping("/group-project-list/{groupId}")
@ApiOperation("当前复评用户所在分组复评项目列表")
public PageVo<PerformanceAppraisalProjectVO> groupProjectList(@PathVariable Long groupId, PerformanceAppraisalListReq req) {
return reAppraisalManage.groupProjectList(groupId,req);
}

@PostMapping("/submit-reAppraisal")
@ApiOperation("提交复评")
public String submitReAppraisal(@Valid @RequestBody ProjectAppraisalDTO param){
return reAppraisalManage.submitReAppraisal(param);
}

}

+ 50
- 0
pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/VerifyController.java Ver arquivo

@@ -0,0 +1,50 @@
package com.ningdatech.pmapi.performance.controller;

import javax.validation.Valid;

import com.ningdatech.pmapi.performance.manage.VerifyManage;
import org.springframework.web.bind.annotation.*;

import com.ningdatech.basic.model.PageVo;
import com.ningdatech.pmapi.performance.model.dto.ProjectAppraisalDTO;
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 io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;

/**
* VerifyController
* @return
* @author CMM
* @since 2023/08/10 8:54
*/
@RestController
@RequiredArgsConstructor
@Api(tags = "绩效评价-专家核查")
@RequestMapping("/api/v1/verify")
public class VerifyController {

private final VerifyManage verifyManage;

@GetMapping("/list")
@ApiOperation("当前核查用户的绩效评价计划列表")
public PageVo<PerformanceAppraisalVO> list(PerformanceAppraisalListReq req) {
return verifyManage.list(req);
}

@GetMapping("/group-project-list/{groupId}")
@ApiOperation("当前核查用户所在分组核查项目列表")
public PageVo<PerformanceAppraisalProjectVO> groupProjectList(@PathVariable Long groupId, PerformanceAppraisalListReq req) {
return verifyManage.groupProjectList(groupId,req);
}

@PostMapping("/submit-reAppraisal")
@ApiOperation("提交核查")
public String submitVerify(@Valid @RequestBody ProjectAppraisalDTO param){
return verifyManage.submitVerify(param);
}

}

+ 2
- 1
pmapi/src/main/java/com/ningdatech/pmapi/performance/helper/TemplateDetailBuildHelper.java Ver arquivo

@@ -1,6 +1,7 @@
package com.ningdatech.pmapi.performance.helper;

import com.ningdatech.pmapi.performance.model.entity.PerformanceIndicatorProjectTemplateDetail;
import com.ningdatech.pmapi.performance.model.vo.ProjectAppraisalIndexDetailVO;
import com.ningdatech.pmapi.performance.model.vo.ProjectTemplateDetailVO;

import java.util.List;
@@ -17,5 +18,5 @@ public interface TemplateDetailBuildHelper {
* @param templateDetails
* @return
*/
List<ProjectTemplateDetailVO> buildTemplateDetail(List<PerformanceIndicatorProjectTemplateDetail> templateDetails);
List<ProjectTemplateDetailVO> buildTemplateDetail(List<PerformanceIndicatorProjectTemplateDetail> templateDetails, ProjectAppraisalIndexDetailVO vo);
}

+ 42
- 2
pmapi/src/main/java/com/ningdatech/pmapi/performance/helper/impl/TemplateDetailBuildHelperImpl.java Ver arquivo

@@ -2,18 +2,23 @@ package com.ningdatech.pmapi.performance.helper.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.ningdatech.pmapi.performance.enumration.AppraisalTypeEnum;
import com.ningdatech.pmapi.performance.enumration.PerformanceTemplateTypeEnum;
import com.ningdatech.pmapi.performance.helper.TemplateDetailBuildHelper;
import com.ningdatech.pmapi.performance.model.dto.ProjectAppraisalInfoDTO;
import com.ningdatech.pmapi.performance.model.entity.PerformanceAppraisalScoreInfo;
import com.ningdatech.pmapi.performance.model.entity.PerformanceIndicatorProjectTemplateDetail;
import com.ningdatech.pmapi.performance.model.vo.ProjectAppraisalIndexDetailVO;
import com.ningdatech.pmapi.performance.model.vo.ProjectTemplateDetailVO;
import com.ningdatech.pmapi.performance.service.IPerformanceAppraisalScoreInfoService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -30,8 +35,7 @@ public class TemplateDetailBuildHelperImpl implements TemplateDetailBuildHelper
private final IPerformanceAppraisalScoreInfoService performanceAppraisalScoreInfoService;

@Override
public List<ProjectTemplateDetailVO> buildTemplateDetail(List<PerformanceIndicatorProjectTemplateDetail> templateDetails) {

public List<ProjectTemplateDetailVO> buildTemplateDetail(List<PerformanceIndicatorProjectTemplateDetail> templateDetails, ProjectAppraisalIndexDetailVO vo) {
List<ProjectTemplateDetailVO> res = Lists.newArrayList();
//第一层是 一级的
for (PerformanceIndicatorProjectTemplateDetail templateDetailFirst : templateDetails) {
@@ -56,6 +60,12 @@ public class TemplateDetailBuildHelperImpl implements TemplateDetailBuildHelper
.eq(PerformanceAppraisalScoreInfo::getAppraisalType, AppraisalTypeEnum.SELF_APPRAISAL.getCode()));
if (CollUtil.isNotEmpty(selfAppraisalScoreInfo)) {
detailThirdVo.setSelfAppraisalScoreInfo(selfAppraisalScoreInfo);
BigDecimal score = selfAppraisalScoreInfo.stream().map(PerformanceAppraisalScoreInfo::getAppraisalScore)
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
if (Objects.nonNull(vo)) {
vo.setSelfAppraisalTotalScore(score);
}
}
// 按照复评人员分组 获取复评分数信息
List<PerformanceAppraisalScoreInfo> reAppraisalScoreInfo = performanceAppraisalScoreInfoService.list(Wrappers.lambdaQuery(PerformanceAppraisalScoreInfo.class)
@@ -63,7 +73,22 @@ public class TemplateDetailBuildHelperImpl implements TemplateDetailBuildHelper
.eq(PerformanceAppraisalScoreInfo::getAppraisalType, AppraisalTypeEnum.RE_APPRAISAL.getCode()));
if (CollUtil.isNotEmpty(reAppraisalScoreInfo)) {
Map<String, List<PerformanceAppraisalScoreInfo>> reAppScoreInfoMap = reAppraisalScoreInfo.stream().collect(Collectors.groupingBy(PerformanceAppraisalScoreInfo::getAppraisalEmployeeName));
HashMap<String, BigDecimal> scoreMap = MapUtil.newHashMap();
for (String name : reAppScoreInfoMap.keySet()) {
List<PerformanceAppraisalScoreInfo> scoreInfos = reAppScoreInfoMap.get(name);
BigDecimal totalScore = scoreInfos.stream().map(PerformanceAppraisalScoreInfo::getAppraisalScore)
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
scoreMap.put(name, totalScore);
}
detailThirdVo.setReAppraisalTotalScoreInfo(scoreMap);
detailThirdVo.setReAppraisalScoreInfo(reAppScoreInfoMap);
if (Objects.nonNull(vo)){
BigDecimal sum = scoreMap.values().stream()
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
vo.setVerifyTotalScore(sum);
}
}
// 按照核查人员分组 获取核查分数信息
List<PerformanceAppraisalScoreInfo> verifyScoreInfo = performanceAppraisalScoreInfoService.list(Wrappers.lambdaQuery(PerformanceAppraisalScoreInfo.class)
@@ -71,7 +96,22 @@ public class TemplateDetailBuildHelperImpl implements TemplateDetailBuildHelper
.eq(PerformanceAppraisalScoreInfo::getAppraisalType, AppraisalTypeEnum.EXPERT_VERIFY.getCode()));
if (CollUtil.isNotEmpty(verifyScoreInfo)) {
Map<String, List<PerformanceAppraisalScoreInfo>> verifyScoreInfoMap = verifyScoreInfo.stream().collect(Collectors.groupingBy(PerformanceAppraisalScoreInfo::getAppraisalEmployeeName));
HashMap<String, BigDecimal> scoreMap = MapUtil.newHashMap();
for (String name : verifyScoreInfoMap.keySet()) {
List<PerformanceAppraisalScoreInfo> scoreInfos = verifyScoreInfoMap.get(name);
BigDecimal totalScore = scoreInfos.stream().map(PerformanceAppraisalScoreInfo::getAppraisalScore)
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
scoreMap.put(name, totalScore);
}
detailThirdVo.setVerifyTotalScoreInfo(scoreMap);
detailThirdVo.setVerifyScoreInfo(verifyScoreInfoMap);
if (Objects.nonNull(vo)){
BigDecimal sum = scoreMap.values().stream()
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
vo.setVerifyTotalScore(sum);
}
}
secondList.add(detailThirdVo);
}


+ 2
- 2
pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/IndicatorConfigManage.java Ver arquivo

@@ -115,12 +115,12 @@ public class IndicatorConfigManage {
.eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId, id)
.eq(PerformanceIndicatorProjectTemplateDetail::getIsAdditional,Boolean.TRUE));
if(CollUtil.isNotEmpty(templateDetails)){
List<ProjectTemplateDetailVO> templateDetailVos = templateDetailBuildHelper.buildTemplateDetail(templateDetails);
List<ProjectTemplateDetailVO> templateDetailVos = templateDetailBuildHelper.buildTemplateDetail(templateDetails,null);
vo.setTemplateDetails(templateDetailVos);
}

if (CollUtil.isNotEmpty(additionalTemplateDetails)){
List<ProjectTemplateDetailVO> additionalTemplateDetailVos = templateDetailBuildHelper.buildTemplateDetail(additionalTemplateDetails);
List<ProjectTemplateDetailVO> additionalTemplateDetailVos = templateDetailBuildHelper.buildTemplateDetail(additionalTemplateDetails,null);
vo.setAdditionalIndexDetails(additionalTemplateDetailVos);
}
return vo;


+ 9
- 3
pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/OrgSelfAppraisalManage.java Ver arquivo

@@ -282,8 +282,8 @@ public class OrgSelfAppraisalManage {
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);
List<ProjectTemplateDetailVO> templateDetailVos = templateDetailBuildHelper.buildTemplateDetail(templateDetails,vo);
List<ProjectTemplateDetailVO> additionalTemplateDetailVos = templateDetailBuildHelper.buildTemplateDetail(additionalTemplateDetails,vo);
vo.setProjectName(project.getProjectName());
vo.setBuildOrgName(project.getBuildOrgName());
vo.setProjectStatus(project.getStatus());
@@ -301,11 +301,13 @@ public class OrgSelfAppraisalManage {
String username = userDetail.getUsername();
Long appraisalId = param.getAppraisalId();
Long appraisalProjectId = param.getAppraisalProjectId();
String appraisalProjectCode = param.getAppraisalProjectCode();
List<ProjectAppraisalInfoDTO> appraisalInfoList = param.getAppraisalInfoList();
// 判断该项目是否还存在于计划或分组中
PerformanceAppraisalProject appraisalProject = performanceAppraisalProjectService.getOne(Wrappers.lambdaQuery(PerformanceAppraisalProject.class)
.eq(PerformanceAppraisalProject::getAppraisalId, appraisalId)
.eq(PerformanceAppraisalProject::getProjectId, appraisalProjectId));
.eq(PerformanceAppraisalProject::getProjectId, appraisalProjectId)
.eq(PerformanceAppraisalProject::getProjectCode,appraisalProjectCode));
if (Objects.isNull(appraisalProject)){
throw new BizException("该项目已被移除评价计划,请返回上一页或者刷新重试!");
}
@@ -340,6 +342,9 @@ public class OrgSelfAppraisalManage {
scoreInfo.setTemplateId(templateDetail.getTemplateId());
scoreInfo.setAppraisalEmployeeCode(employeeCode);
scoreInfo.setAppraisalEmployeeName(username);
scoreInfo.setAppraisalId(appraisalId);
scoreInfo.setAppraisalProjectId(appraisalProjectId);
scoreInfo.setAppraisalProjectCode(appraisalProjectCode);
scoreInfo.setCreateOn(LocalDateTime.now());
scoreInfo.setCreateBy(username);
return scoreInfo;
@@ -353,6 +358,7 @@ public class OrgSelfAppraisalManage {
.reduce(BigDecimal.ZERO, BigDecimal::add);
appraisalProject.setSelfAppraisalTotalScore(selfAppraisalTotalScore);
appraisalProject.setSelfAppraisalScoreTime(LocalDateTime.now());
appraisalProject.setIsCompleteSelfAppraisal(Boolean.TRUE);
appraisalProject.setUpdateOn(LocalDateTime.now());
appraisalProject.setUpdateBy(username);
performanceAppraisalProjectService.updateById(appraisalProject);


+ 3
- 0
pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/PerformanceAppraisalPlanManage.java Ver arquivo

@@ -600,9 +600,12 @@ public class PerformanceAppraisalPlanManage {
group.setCreateOn(LocalDateTime.now());
group.setCreateBy(user.getUsername());
}else{
// 编辑分组
PerformanceAppraisalProjectGroup old = groupService.getById(dto.getId());
VUtils.isTrue(Objects.isNull(old)).throwMessage("该分组不存在 编辑失败!");
group.setId(old.getId());
// 先删除旧的分组
groupList.remove(old);
}
if(CollUtil.isNotEmpty(dto.getProjectCodes())){
// 判断选择的项目是否已经在当前评价计划的其他分组内


+ 163
- 203
pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/ReAppraisalManage.java Ver arquivo

@@ -2,12 +2,10 @@ package com.ningdatech.pmapi.performance.manage;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;

import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@@ -21,25 +19,18 @@ import com.ningdatech.basic.model.PageVo;
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.model.vo.ProjectAppraisalIndexDetailVO;
import com.ningdatech.pmapi.performance.model.vo.ProjectTemplateDetailVO;
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;
import com.ningdatech.pmapi.projectlib.service.IProjectService;
import com.ningdatech.pmapi.sys.model.entity.Role;
import com.ningdatech.pmapi.sys.service.IRoleService;
import com.ningdatech.pmapi.user.entity.enumeration.RoleEnum;
import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails;
import com.ningdatech.pmapi.user.util.LoginUserUtil;

@@ -63,19 +54,17 @@ public class ReAppraisalManage {
private final IPerformanceAppraisalProjectService performanceAppraisalProjectService;
private final IProjectService projectService;
private final IRoleService roleService;
private final IPerformanceIndicatorProjectTemplateService indicatorProjectTemplateService;
private final TemplateDetailBuildHelper templateDetailBuildHelper;
private final IPerformanceIndicatorProjectTemplateDetailService indicatorProjectTemplateDetailService;
private final IProjectTagService projectTagService;
private final IPerformanceAppraisalScoreInfoService performanceAppraisalScoreInfoService;
private final IPerformanceAppraisalProjectGroupService groupService;
/**
* 绩效列表
* 复评-评价计划列表
* @param req
* @return
*/
public PageVo<PerformanceAppraisalVO> list(PerformanceAppraisalListReq req) {
UserInfoDetails user = LoginUserUtil.loginUserDetail();
String employeeCode = user.getEmployeeCode();
//当前登录用户 单位code
String empPosUnitCode = user.getEmpPosUnitCode();
// 获取当前登录用户的角色列表,只有绩效复评人员才能查看该列表
@@ -92,237 +81,150 @@ public class ReAppraisalManage {
return PageVo.empty();
}

// 获取登录用户所在单位的所有已终验项目信息
List<Project> projectLists = projectService.list(Wrappers.lambdaQuery(Project.class)
.eq(Project::getStatus, ProjectStatusEnum.ACCEPTED.getCode())
.eq(Project::getBuildOrgCode, empPosUnitCode));
// 从绩效评价 项目表中获取已经完成单位自评的项目
List<PerformanceAppraisalProject> paps = performanceAppraisalProjectService.list().stream()
.filter(p -> Objects.nonNull(p.getSelfAppraisalScoreTime())).collect(Collectors.toList());

if(CollUtil.isEmpty(projectLists)){
return PageVo.empty();
}
List<Long> projectIds = projectLists.stream().map(Project::getId).collect(Collectors.toList());
// 获取添加过该单位项目的所有评价计划信息
List<PerformanceAppraisalProject> paps = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class)
.in(PerformanceAppraisalProject::getProjectId, projectIds));
// 已存在的评价计划添加的评价项目都未完成单位自评
if(CollUtil.isEmpty(paps)){
return PageVo.empty();
}
Set<Long> paIds = paps.stream().map(PerformanceAppraisalProject::getAppraisalId).collect(Collectors.toSet());

// 获取评价计划关联的分组信息

// 获取评价计划列表
List<PerformanceAppraisalProjectGroup> groups = groupService.list(Wrappers.lambdaQuery(PerformanceAppraisalProjectGroup.class)
.in(PerformanceAppraisalProjectGroup::getAppraisalId, paIds));
// 获取当前登录复评员所在的分组信息
List<PerformanceAppraisalProjectGroup> groupList = groups.stream().filter(g -> {
String reAppraisalUsers = g.getReAppraisalUsers();
List<String> empCodeList = Arrays.stream(reAppraisalUsers.split(StrPool.COMMA)).collect(Collectors.toList());
if (empCodeList.contains(employeeCode)) {
return true;
}
return false;
}).collect(Collectors.toList());
// 当前登录复评员用户,没有参加评价计划
if (CollUtil.isEmpty(groupList)){
return PageVo.empty();
}
// 获取分组所在的评价计划ID
List<Long> appraisalIds = groupList.stream().map(PerformanceAppraisalProjectGroup::getAppraisalId).collect(Collectors.toList());
// 因为同一个复评员只能出现在一个计划的一个分组中,所以分组信息可按照评价计划ID进行分组
Map<Long, PerformanceAppraisalProjectGroup> groupMap = groupList.stream().collect(Collectors.toMap(PerformanceAppraisalProjectGroup::getAppraisalId, g -> g));
// 获取复评计划列表
Page<PerformanceAppraisal> page = req.page();
LambdaQueryWrapper<PerformanceAppraisal> wrapper = Wrappers.lambdaQuery(PerformanceAppraisal.class)
.in(PerformanceAppraisal::getId,paIds)
.in(PerformanceAppraisal::getId,appraisalIds)
.orderByDesc(PerformanceAppraisal::getUpdateOn);
performanceAppraisalService.page(page,wrapper);
if(0L == page.getTotal()){
return PageVo.empty();
}

List<PerformanceAppraisalVO> res = page.getRecords().stream()
.map(p -> BeanUtil.copyProperties(p, PerformanceAppraisalVO.class))
.collect(Collectors.toList());
return PageVo.of(res,page.getTotal());
}

public PageVo<PerformanceAppraisalProjectVO> pendingList(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.isNull(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();
}

// 获取本单位在当前评价计划内的项目
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());

List<PerformanceAppraisalVO> res = page.getRecords().stream().map(p -> {
PerformanceAppraisalVO vo = BeanUtil.copyProperties(p, PerformanceAppraisalVO.class);
PerformanceAppraisalProjectGroup group = groupMap.get(p.getId());
if (Objects.nonNull(group)) {
vo.setReAppraisalGroupId(group.getId());
vo.setReAppraisalGroupName(group.getName());
}
return vo;
}).collect(Collectors.toList());
return PageVo.of(res,page.getTotal());
}

/**
* 已经自评表
* 是否可以复评
*
* @param planId
* @param req
* @param employeeCode
* @param projectCode
* @param appraisalId
* @return
*/
public PageVo<PerformanceAppraisalProjectVO> appraisaledList(Long planId, PerformanceAppraisalListReq req) {
UserInfoDetails user = LoginUserUtil.loginUserDetail();
private Boolean checkCanReAppraisal(String employeeCode, String projectCode, Long appraisalId) {
// 首次复评(复评打分时间为空)
// 从绩效评价打分信息表中查询打分类型为复评、打分人员为当前登录复评用户的打分信息
// 如果没有相关的打分信息,说明是当前登录复评用户是首次复评
List<PerformanceAppraisalScoreInfo> scoreInfos = performanceAppraisalScoreInfoService.list(Wrappers.lambdaQuery(PerformanceAppraisalScoreInfo.class)
.eq(PerformanceAppraisalScoreInfo::getAppraisalType, AppraisalTypeEnum.RE_APPRAISAL.getCode())
.eq(PerformanceAppraisalScoreInfo::getAppraisalProjectCode,projectCode)
.eq(PerformanceAppraisalScoreInfo::getAppraisalId,appraisalId)
.eq(PerformanceAppraisalScoreInfo::getAppraisalEmployeeCode, employeeCode));
if (CollUtil.isEmpty(scoreInfos)){
return true;
}
return Boolean.FALSE;
}

PerformanceAppraisal plan = performanceAppraisalService.getById(planId);
VUtils.isTrue(Objects.isNull(plan)).throwMessage("该评价计划不存在!");
public PageVo<PerformanceAppraisalProjectVO> groupProjectList(Long groupId, PerformanceAppraisalListReq req) {

// 获取评价计划内已添加的已评价项目信息
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));
UserInfoDetails userDetail = LoginUserUtil.loginUserDetail();
String employeeCode = userDetail.getEmployeeCode();

if(CollUtil.isEmpty(paps)){
// 获取分组内的项目信息
PerformanceAppraisalProjectGroup projectGroup = groupService.getById(groupId);
String projectCodes = projectGroup.getProjectCodes();
Long appraisalId = projectGroup.getAppraisalId();
VUtils.isTrue(StringUtils.isBlank(projectCodes)).throwMessage("分组内项目信息不存在!");
List<String> projectCodeList = Arrays.stream(projectCodes.split(StrPool.COMMA)).collect(Collectors.toList());

// 筛选出分组内已完成单位自评、需要复评的评价项目信息
List<PerformanceAppraisalProject> appraisalProjects = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class)
.in(PerformanceAppraisalProject::getProjectCode, projectCodeList)
.eq(PerformanceAppraisalProject::getIsReAppraisal,Boolean.TRUE)
.eq(PerformanceAppraisalProject::getIsCompleteSelfAppraisal, Boolean.TRUE));
// 分组内已完成单位自评的项目信息不存在
if (CollUtil.isEmpty(appraisalProjects)){
return PageVo.empty();
}
List<String> proCodeList = appraisalProjects.stream().map(PerformanceAppraisalProject::getProjectCode).collect(Collectors.toList());
Map<String, PerformanceAppraisalProject> appraisalProjectMap = appraisalProjects.stream().collect(Collectors.toMap(PerformanceAppraisalProject::getProjectCode, p -> p));

// 获取本单位在当前评价计划内的项目
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)
.in(Project::getProjectCode, proCodeList)
.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()){
// 分组内项目信息不存在
if (CollUtil.isEmpty(page.getRecords())){
return PageVo.empty();
}
List<PerformanceAppraisalProjectVO> res = page.getRecords().stream()
.map(p -> {
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);
PerformanceAppraisalProject appraisalProject = appraisalProjectMap.get(p.getProjectCode());
BeanUtil.copyProperties(appraisalProject, vo);
vo.setProjectId(appraisalProject.getProjectId());
vo.setProjectTypeName(ProjectTypeEnum.getDesc(p.getProjectType()));
vo.setCanSelfAppraisal(checkCanSelfAppraisal(appraisalProject));
vo.setAppraisalId(planId);
vo.setCanReAppraisal(checkCanReAppraisal(employeeCode,appraisalProject.getProjectCode(),appraisalId));
if (Boolean.TRUE.equals(appraisalProject.getIsCompleteReAppraisal())){
// 完成复评的项目可以进行核查
vo.setCanVerify(Boolean.TRUE);
}
vo.setGroupId(groupId);
return vo;
})
.collect(Collectors.toList());

return PageVo.of(res,page.getTotal());
}

/**
* 是否可以自评
* @param appraisalProject
* @return
*/
private Boolean checkCanSelfAppraisal(PerformanceAppraisalProject appraisalProject) {
// 在自评时间段内,且是首次自评(打分时间为空)
if(LocalDateTime.now().compareTo(appraisalProject.getSelfAppraisalStart()) > 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) {
public String submitReAppraisal(ProjectAppraisalDTO param) {
UserInfoDetails userDetail = LoginUserUtil.loginUserDetail();
String employeeCode = userDetail.getEmployeeCode();
String username = userDetail.getUsername();
Long appraisalId = param.getAppraisalId();
Long appraisalProjectId = param.getAppraisalProjectId();
String appraisalProjectCode = param.getAppraisalProjectCode();
List<ProjectAppraisalInfoDTO> appraisalInfoList = param.getAppraisalInfoList();
// 判断该项目是否还存在于计划或分组中
Long groupId = param.getGroupId();
PerformanceAppraisalProjectGroup group = groupService.getById(groupId);

// 获取评价项目
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("填写所有自评得分后才能提交!");
}
.eq(PerformanceAppraisalProject::getProjectId, appraisalProjectId)
.eq(PerformanceAppraisalProject::getProjectCode,appraisalProjectCode));

List<Long> ids = appraisalInfoList.stream()
.map(ProjectAppraisalInfoDTO::getProjectTemplateDetailId)
.collect(Collectors.toList());
@@ -338,31 +240,47 @@ public class ReAppraisalManage {
BigDecimal score = a.getScore();
BigDecimal indexScore = templateDetail.getIndexScore();
if (score.compareTo(indexScore) > 0 || score.compareTo(BigDecimal.ZERO) < 0){
throw new BizException("评得分必须大于等于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.setAppraisalType(AppraisalTypeEnum.RE_APPRAISAL.getCode());
scoreInfo.setTemplateDetailId(templateDetail.getId());
scoreInfo.setTemplateId(templateDetail.getTemplateId());
scoreInfo.setAppraisalEmployeeCode(employeeCode);
scoreInfo.setAppraisalEmployeeName(username);
scoreInfo.setAppraisalId(appraisalId);
scoreInfo.setAppraisalProjectId(appraisalProjectId);
scoreInfo.setAppraisalProjectCode(appraisalProjectCode);
scoreInfo.setCreateOn(LocalDateTime.now());
scoreInfo.setCreateBy(username);
return scoreInfo;
}).collect(Collectors.toList());

if (performanceAppraisalScoreInfoService.saveBatch(scoreInfos)){
// 计算评总分并保存
BigDecimal selfAppraisalTotalScore = appraisalInfoList.stream()
// 计算评总分并保存
BigDecimal reAppraisalTotalScore = appraisalInfoList.stream()
.map(ProjectAppraisalInfoDTO::getScore)
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
appraisalProject.setSelfAppraisalTotalScore(selfAppraisalTotalScore);
appraisalProject.setSelfAppraisalScoreTime(LocalDateTime.now());
BigDecimal lastReappraisalTotalScore;
// 判断项目所在分组内其他复评人员是否已经打分
if (Objects.nonNull(appraisalProject.getReAppraisalTotalScore())){
// 已经进行了复评,计算两个分值的平均分
BigDecimal add = reAppraisalTotalScore.add(appraisalProject.getReAppraisalTotalScore());
lastReappraisalTotalScore = add.divide(BigDecimal.valueOf(2));
}else {
// 还没有进行过复评
lastReappraisalTotalScore = reAppraisalTotalScore;
}
appraisalProject.setReAppraisalTotalScore(lastReappraisalTotalScore);
// 取最新地复评打分时间
appraisalProject.setReAppraisalScoreTime(LocalDateTime.now());
// 判断当前复评人是否为该评价项目所在分组的复评人员中的最后一个复评人
judgeCompleteReAppraisal(group, appraisalProject);
appraisalProject.setUpdateOn(LocalDateTime.now());
appraisalProject.setUpdateBy(username);
performanceAppraisalProjectService.updateById(appraisalProject);
@@ -370,4 +288,46 @@ public class ReAppraisalManage {
}
return "提交失败";
}

private void judgeCompleteReAppraisal(PerformanceAppraisalProjectGroup group, PerformanceAppraisalProject appraisalProject) {
Map<String, List<PerformanceAppraisalScoreInfo>> scoreInfoMap = performanceAppraisalScoreInfoService.list(Wrappers.lambdaQuery(PerformanceAppraisalScoreInfo.class)
.eq(PerformanceAppraisalScoreInfo::getAppraisalType, AppraisalTypeEnum.RE_APPRAISAL.getCode()))
.stream().collect(Collectors.groupingBy(PerformanceAppraisalScoreInfo::getAppraisalEmployeeCode));

List<String> reUsers = Lists.newArrayList();
String reAppraisalUsers = group.getReAppraisalUsers();
String projectCodes = group.getProjectCodes();
if (reAppraisalUsers.contains(StrPool.COMMA)){
reUsers = Arrays.asList(reAppraisalUsers.split(StrPool.COMMA));
}else {
reUsers.add(reAppraisalUsers);
}
List<String> users = Lists.newArrayList();
for (String reUser : reUsers) {
// 获取分组内复评人员对分组内项目的复评分数信息
List<PerformanceAppraisalScoreInfo> scoreInfoList = scoreInfoMap.get(reUser);
if (CollUtil.isNotEmpty(scoreInfoList)){
List<Long> projectIdList = scoreInfoList.stream()
.map(PerformanceAppraisalScoreInfo::getAppraisalProjectId)
.collect(Collectors.toList());
List<String> proCodes = projectService.listByIds(projectIdList).stream()
.map(Project::getProjectCode)
.collect(Collectors.toList());
// 当前登录用户所在分组的复评人员 对分组内所有项目进行了复评
if (CollUtil.isNotEmpty(proCodes)){
String join = String.join(StrPool.COMMA, proCodes);
if (join.equals(projectCodes)) {
users.add(reUser);
}
}
}
}
if (CollUtil.isNotEmpty(users)) {
String join = String.join(StrPool.COMMA, users);
if (join.equals(reAppraisalUsers)) {
// 标记项目完成复评
appraisalProject.setIsCompleteReAppraisal(Boolean.TRUE);
}
}
}
}

+ 332
- 0
pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/VerifyManage.java Ver arquivo

@@ -0,0 +1,332 @@
package com.ningdatech.pmapi.performance.manage;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;

import com.google.common.collect.Lists;
import com.ningdatech.pmapi.user.entity.enumeration.RoleEnum;
import org.apache.commons.lang3.StringUtils;
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.Wrappers;
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.basic.util.StrPool;
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.*;
import com.ningdatech.pmapi.portrait.service.IProjectTagService;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeEnum;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.projectlib.service.IProjectService;
import com.ningdatech.pmapi.sys.model.entity.Role;
import com.ningdatech.pmapi.sys.service.IRoleService;
import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails;
import com.ningdatech.pmapi.user.util.LoginUserUtil;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
* VerifyManage
* @return
* @author CMM
* @since 2023/08/10 8:55
*/
@Component
@Slf4j
@AllArgsConstructor
public class VerifyManage {

private final IPerformanceAppraisalService performanceAppraisalService;
private final IPerformanceAppraisalProjectService performanceAppraisalProjectService;
private final IProjectService projectService;
private final IRoleService roleService;
private final IPerformanceIndicatorProjectTemplateService indicatorProjectTemplateService;
private final TemplateDetailBuildHelper templateDetailBuildHelper;
private final IPerformanceIndicatorProjectTemplateDetailService indicatorProjectTemplateDetailService;
private final IProjectTagService projectTagService;
private final IPerformanceAppraisalScoreInfoService performanceAppraisalScoreInfoService;
private final IPerformanceAppraisalProjectGroupService groupService;
/**
* 核查-评价计划列表
* @param req
* @return
*/
public PageVo<PerformanceAppraisalVO> list(PerformanceAppraisalListReq req) {
UserInfoDetails user = LoginUserUtil.loginUserDetail();
String employeeCode = user.getEmployeeCode();
// 获取当前登录用户的角色列表,只有专家核查人员才能查看该列表
List<Role> userRoleList = user.getUserRoleList();
List<Long> roleIdList = userRoleList.stream().map(Role::getId).collect(Collectors.toList());
Role role = roleService.getOne(Wrappers.lambdaQuery(Role.class)
.eq(Role::getName, RoleEnum.EXPERT.getDesc()));
if (Objects.isNull(role)){
throw new BizException("登录用户没有复评员角色!");
}

// 登录用户不是专家,不能查看核查计划列表
if (!roleIdList.contains(role.getId())){
return PageVo.empty();
}

// 从绩效评价 分组表中获取当前登录专家所在的分组信息
List<PerformanceAppraisalProjectGroup> groups = Lists.newArrayList();
List<PerformanceAppraisalProjectGroup> projectGroups = groupService.list();
for (PerformanceAppraisalProjectGroup projectGroup : projectGroups) {
String verificationUsers = projectGroup.getVerificationUsers();
if (verificationUsers.contains(StrPool.COMMA)){
if (verificationUsers.contains(employeeCode)){
groups.add(projectGroup);
}
} else if (verificationUsers.equals(employeeCode)) {
groups.add(projectGroup);
}
}
// 当前登录专家没有绩效分组信息
if (CollUtil.isEmpty(groups)){
return PageVo.empty();
}

// 获取分组所在的评价计划ID
List<Long> appraisalIds = groups.stream().map(PerformanceAppraisalProjectGroup::getAppraisalId).collect(Collectors.toList());
// 因为同一个核查人员只能出现在一个计划的一个分组中,所以分组信息可按照评价计划ID进行分组
Map<Long, PerformanceAppraisalProjectGroup> groupMap = groups.stream().collect(Collectors.toMap(PerformanceAppraisalProjectGroup::getAppraisalId, g -> g));
// 获取核查计划列表
Page<PerformanceAppraisal> page = req.page();
LambdaQueryWrapper<PerformanceAppraisal> wrapper = Wrappers.lambdaQuery(PerformanceAppraisal.class)
.in(PerformanceAppraisal::getId,appraisalIds)
.orderByDesc(PerformanceAppraisal::getUpdateOn);
performanceAppraisalService.page(page,wrapper);

List<PerformanceAppraisalVO> res = page.getRecords().stream().map(p -> {
PerformanceAppraisalVO vo = BeanUtil.copyProperties(p, PerformanceAppraisalVO.class);
PerformanceAppraisalProjectGroup group = groupMap.get(p.getId());
if (Objects.nonNull(group)) {
vo.setReAppraisalGroupId(group.getId());
vo.setReAppraisalGroupName(group.getName());
}
return vo;
}).collect(Collectors.toList());
return PageVo.of(res,page.getTotal());
}

/**
* 是否可以核查
*
* @param employeeCode
* @param projectCode
* @param appraisalId
* @return
*/
private Boolean checkCanVerify(String employeeCode, String projectCode, Long appraisalId) {

// 首次核查(核查打分信息为空)
// 从绩效评价打分信息表中查询打分类型为专家核查、打分人员为当前登录专家用户的打分信息
// 如果没有相关的打分信息,说明是当前登录复评用户是首次核查
List<PerformanceAppraisalScoreInfo> scoreInfos = performanceAppraisalScoreInfoService.list(Wrappers.lambdaQuery(PerformanceAppraisalScoreInfo.class)
.eq(PerformanceAppraisalScoreInfo::getAppraisalType, AppraisalTypeEnum.EXPERT_VERIFY.getCode())
.eq(PerformanceAppraisalScoreInfo::getAppraisalId,appraisalId)
.eq(PerformanceAppraisalScoreInfo::getAppraisalProjectCode,projectCode)
.eq(PerformanceAppraisalScoreInfo::getAppraisalEmployeeCode, employeeCode));
if (CollUtil.isEmpty(scoreInfos)){
return true;
}
return Boolean.FALSE;
}

public PageVo<PerformanceAppraisalProjectVO> groupProjectList(Long groupId, PerformanceAppraisalListReq req) {

UserInfoDetails userDetail = LoginUserUtil.loginUserDetail();
String employeeCode = userDetail.getEmployeeCode();

// 获取分组内的项目信息
PerformanceAppraisalProjectGroup projectGroup = groupService.getById(groupId);
String projectCodes = projectGroup.getProjectCodes();
Long appraisalId = projectGroup.getAppraisalId();
VUtils.isTrue(StringUtils.isBlank(projectCodes)).throwMessage("分组内项目信息不存在!");
List<String> projectCodeList = Arrays.stream(projectCodes.split(StrPool.COMMA)).collect(Collectors.toList());

// 筛选出分组内已完成复评的评价项目信息
List<PerformanceAppraisalProject> appraisalProjects = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class)
.in(PerformanceAppraisalProject::getProjectCode, projectCodeList)
.eq(PerformanceAppraisalProject::getIsCompleteReAppraisal, Boolean.TRUE));
// 分组内已完成复评的项目信息不存在
if (CollUtil.isEmpty(appraisalProjects)){
return PageVo.empty();
}
List<String> proCodeList = appraisalProjects.stream().map(PerformanceAppraisalProject::getProjectCode).collect(Collectors.toList());
Map<String, PerformanceAppraisalProject> appraisalProjectMap = appraisalProjects.stream().collect(Collectors.toMap(PerformanceAppraisalProject::getProjectCode, p -> p));

Page<Project> page = req.page();
LambdaQueryWrapper<Project> wrapper = Wrappers.lambdaQuery(Project.class)
.in(Project::getProjectCode, proCodeList)
.eq(Project::getNewest, Boolean.TRUE)
.like(StringUtils.isNotBlank(req.getProjectName()),Project::getProjectName,req.getProjectName());
projectService.page(page,wrapper);

// 分组内项目信息不存在
if (CollUtil.isEmpty(page.getRecords())){
return PageVo.empty();
}

List<PerformanceAppraisalProjectVO> res = page.getRecords().stream().map(p -> {
PerformanceAppraisalProjectVO vo = BeanUtil.copyProperties(p, PerformanceAppraisalProjectVO.class);
PerformanceAppraisalProject appraisalProject = appraisalProjectMap.get(p.getProjectCode());
BeanUtil.copyProperties(appraisalProject, vo);
vo.setProjectId(appraisalProject.getProjectId());
vo.setProjectTypeName(ProjectTypeEnum.getDesc(p.getProjectType()));
vo.setCanVerify(checkCanVerify(employeeCode,appraisalProject.getProjectCode(),appraisalId));
// 如果登录用户是核查组长,该项目可填写整改意见
String verifyLeader = projectGroup.getVerifyLeader();
if (employeeCode.equals(verifyLeader)){
vo.setCanRectify(Boolean.TRUE);
}
return vo;
})
.collect(Collectors.toList());
return PageVo.of(res,page.getTotal());
}

@Transactional(rollbackFor = Exception.class)
public String submitVerify(ProjectAppraisalDTO param) {
UserInfoDetails userDetail = LoginUserUtil.loginUserDetail();
String employeeCode = userDetail.getEmployeeCode();
String username = userDetail.getUsername();
Long appraisalId = param.getAppraisalId();
Long appraisalProjectId = param.getAppraisalProjectId();
String appraisalProjectCode = param.getAppraisalProjectCode();
List<ProjectAppraisalInfoDTO> appraisalInfoList = param.getAppraisalInfoList();
Long groupId = param.getGroupId();
PerformanceAppraisalProjectGroup group = groupService.getById(groupId);

// 获取评价项目
PerformanceAppraisalProject appraisalProject = performanceAppraisalProjectService.getOne(Wrappers.lambdaQuery(PerformanceAppraisalProject.class)
.eq(PerformanceAppraisalProject::getAppraisalId, appraisalId)
.eq(PerformanceAppraisalProject::getProjectCode,appraisalProjectCode)
.eq(PerformanceAppraisalProject::getProjectId, appraisalProjectId));

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.EXPERT_VERIFY.getCode());
scoreInfo.setTemplateDetailId(templateDetail.getId());
scoreInfo.setTemplateId(templateDetail.getTemplateId());
scoreInfo.setAppraisalEmployeeCode(employeeCode);
scoreInfo.setAppraisalEmployeeName(username);
scoreInfo.setAppraisalId(appraisalId);
scoreInfo.setAppraisalProjectId(appraisalProjectId);
scoreInfo.setAppraisalProjectCode(appraisalProjectCode);
scoreInfo.setCreateOn(LocalDateTime.now());
scoreInfo.setCreateBy(username);
return scoreInfo;
}).collect(Collectors.toList());

if (performanceAppraisalScoreInfoService.saveBatch(scoreInfos)){
// 计算核查总分并保存
BigDecimal verifyTotalScore = appraisalInfoList.stream()
.map(ProjectAppraisalInfoDTO::getScore)
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal lastVerifyTotalScore;
// 判断项目所在分组内其他复评人员是否已经打分
if (Objects.nonNull(appraisalProject.getVerifyTotalScore())){
// 已经进行了核查,计算两个分值的平均分
BigDecimal add = verifyTotalScore.add(appraisalProject.getReAppraisalTotalScore());
lastVerifyTotalScore = add.divide(BigDecimal.valueOf(2));
}else {
// 还没有进行过复评
lastVerifyTotalScore = verifyTotalScore;
}
appraisalProject.setReAppraisalTotalScore(lastVerifyTotalScore);
// 取最新地核查打分时间
appraisalProject.setVerifyScoreTime(LocalDateTime.now());
// 判断当前核查人是否为该评价项目所在分组的核查人员中的最后一个核查人
judgeCompleteVerify(group, appraisalProject);
appraisalProject.setUpdateOn(LocalDateTime.now());
appraisalProject.setUpdateBy(username);
if (Objects.nonNull(param.getIsRectify()) ||
StringUtils.isNotBlank(param.getRectifyOpinion())) {
appraisalProject.setIsRectify(param.getIsRectify());
appraisalProject.setRectifyOpinion(param.getRectifyOpinion());
}
performanceAppraisalProjectService.updateById(appraisalProject);
return "提交成功";
}
return "提交失败";
}

private void judgeCompleteVerify(PerformanceAppraisalProjectGroup group, PerformanceAppraisalProject appraisalProject) {
Map<String, List<PerformanceAppraisalScoreInfo>> scoreInfoMap = performanceAppraisalScoreInfoService.list(Wrappers.lambdaQuery(PerformanceAppraisalScoreInfo.class)
.eq(PerformanceAppraisalScoreInfo::getAppraisalType, AppraisalTypeEnum.EXPERT_VERIFY.getCode()))
.stream().collect(Collectors.groupingBy(PerformanceAppraisalScoreInfo::getAppraisalEmployeeCode));

List<String> verifyUsers = Lists.newArrayList();
String verificationUsers = group.getVerificationUsers();
String projectCodes = group.getProjectCodes();
if (verificationUsers.contains(StrPool.COMMA)){
verifyUsers = Arrays.asList(verificationUsers.split(StrPool.COMMA));
}else {
verifyUsers.add(verificationUsers);
}
List<String> users = Lists.newArrayList();
for (String verifyUser : verifyUsers) {
// 获取分组内核查人员对分组内项目的核查分数信息
List<PerformanceAppraisalScoreInfo> scoreInfoList = scoreInfoMap.get(verifyUser);
if (CollUtil.isNotEmpty(scoreInfoList)){
List<Long> projectIdList = scoreInfoList.stream()
.map(PerformanceAppraisalScoreInfo::getAppraisalProjectId)
.collect(Collectors.toList());
List<String> proCodes = projectService.listByIds(projectIdList).stream()
.map(Project::getProjectCode)
.collect(Collectors.toList());
// 当前登录用户所在分组的核查人员 对分组内所有项目进行了核查
if (CollUtil.isNotEmpty(proCodes)){
String join = String.join(StrPool.COMMA, proCodes);
if (join.equals(projectCodes)) {
users.add(verifyUser);
}
}
}
}
if (CollUtil.isNotEmpty(users)) {
String join = String.join(StrPool.COMMA, users);
if (join.equals(verificationUsers)) {
appraisalProject.setIsCompleteVerify(Boolean.TRUE);
}
}
}
}

+ 3
- 0
pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/PerformanceAppraisalProjectGroupSaveDTO.java Ver arquivo

@@ -43,4 +43,7 @@ public class PerformanceAppraisalProjectGroupSaveDTO implements Serializable {

@ApiModelProperty("核查人员")
private List<String> verificationUsers;

@ApiModelProperty("核查组长")
private String verifyLeader;
}

+ 6
- 0
pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/ProjectAppraisalDTO.java Ver arquivo

@@ -22,6 +22,9 @@ public class ProjectAppraisalDTO implements Serializable {
@ApiModelProperty("评价项目ID")
private Long appraisalProjectId;

@ApiModelProperty("评价项目Code")
private String appraisalProjectCode;

@ApiModelProperty("评价计划ID")
private Long appraisalId;

@@ -33,4 +36,7 @@ public class ProjectAppraisalDTO implements Serializable {

@ApiModelProperty("整改意见")
private String rectifyOpinion;

@ApiModelProperty("评价项目所在分组ID")
private Long groupId;
}

+ 9
- 0
pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalProject.java Ver arquivo

@@ -76,4 +76,13 @@ public class PerformanceAppraisalProject implements Serializable {
@ApiModelProperty("整改意见")
private String rectifyOpinion;

@ApiModelProperty("是否完成自评")
private Boolean isCompleteSelfAppraisal;

@ApiModelProperty("是否完成复评")
private Boolean isCompleteReAppraisal;

@ApiModelProperty("是否完成核查")
private Boolean isCompleteVerify;

}

+ 3
- 0
pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalProjectGroup.java Ver arquivo

@@ -46,4 +46,7 @@ public class PerformanceAppraisalProjectGroup implements Serializable {

@ApiModelProperty("核查人员")
private String verificationUsers;

@ApiModelProperty("核查组长")
private String verifyLeader;
}

+ 9
- 0
pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalScoreInfo.java Ver arquivo

@@ -61,4 +61,13 @@ public class PerformanceAppraisalScoreInfo implements Serializable {

@ApiModelProperty("评价类型 1 单位自评、2 复评人员复评、3 专家核查")
private Integer appraisalType;

@ApiModelProperty("评价计划ID")
private Long appraisalId;

@ApiModelProperty("评价项目ID")
private Long appraisalProjectId;

@ApiModelProperty("评价项目Code")
private String appraisalProjectCode;
}

+ 12
- 0
pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceAppraisalProjectVO.java Ver arquivo

@@ -51,6 +51,15 @@ public class PerformanceAppraisalProjectVO implements Serializable {
@ApiModelProperty("是否可自评")
private Boolean canSelfAppraisal = Boolean.FALSE;

@ApiModelProperty("是否可复评")
private Boolean canReAppraisal = Boolean.FALSE;

@ApiModelProperty("是否可核查")
private Boolean canVerify = Boolean.FALSE;

@ApiModelProperty("是否可整改")
private Boolean canRectify = Boolean.FALSE;

@ApiModelProperty("自评开始时间")
private LocalDateTime selfAppraisalStart;

@@ -87,4 +96,7 @@ public class PerformanceAppraisalProjectVO implements Serializable {
@ApiModelProperty("评价计划ID")
private Long appraisalId;

@ApiModelProperty("所在分组ID")
private Long groupId;

}

+ 13
- 0
pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceAppraisalVO.java Ver arquivo

@@ -51,4 +51,17 @@ public class PerformanceAppraisalVO implements Serializable {

@ApiModelProperty("备注")
private String remark;

@ApiModelProperty("复评分组ID")
private Long reAppraisalGroupId;

@ApiModelProperty("复评分组名称")
private String reAppraisalGroupName;

@ApiModelProperty("核查分组ID")
private Long verifyGroupId;

@ApiModelProperty("核查分组名称")
private String verifyGroupName;

}

+ 9
- 0
pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/ProjectAppraisalIndexDetailVO.java Ver arquivo

@@ -40,4 +40,13 @@ public class ProjectAppraisalIndexDetailVO implements Serializable {

@ApiModelProperty("附加绩效指标详情")
private List<ProjectTemplateDetailVO> additionalIndexDetails;

@ApiModelProperty("自评总得分")
private BigDecimal selfAppraisalTotalScore;

@ApiModelProperty("复评总得分")
private BigDecimal reAppraisalTotalScore;

@ApiModelProperty("核查总得分")
private BigDecimal verifyTotalScore;
}

+ 6
- 0
pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/ProjectTemplateDetailVO.java Ver arquivo

@@ -64,7 +64,13 @@ public class ProjectTemplateDetailVO implements Serializable {
@ApiModelProperty("复评分数信息")
private Map<String, List<PerformanceAppraisalScoreInfo>> reAppraisalScoreInfo;

@ApiModelProperty("复评得分信息")
private Map<String, BigDecimal> reAppraisalTotalScoreInfo;

@ApiModelProperty("核查分数信息")
private Map<String, List<PerformanceAppraisalScoreInfo>> verifyScoreInfo;

@ApiModelProperty("核查得分信息")
private Map<String, BigDecimal> verifyTotalScoreInfo;

}

Carregando…
Cancelar
Salvar