diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/ReAppraisalController.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/ReAppraisalController.java index fa0b0a0..dd9e956 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/ReAppraisalController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/ReAppraisalController.java @@ -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 pendingList(@PathVariable Long planId, PerformanceAppraisalListReq req) { - // return selfAppraisalManage.pendingList(planId,req); - //} - // - //@GetMapping("/appraisaled-list/{planId}") - //@ApiOperation("当前绩效评价已自评列表") - //public PageVo 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 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); + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/VerifyController.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/VerifyController.java new file mode 100644 index 0000000..09153bb --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/VerifyController.java @@ -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 list(PerformanceAppraisalListReq req) { + return verifyManage.list(req); + } + + @GetMapping("/group-project-list/{groupId}") + @ApiOperation("当前核查用户所在分组核查项目列表") + public PageVo 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); + } + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/helper/TemplateDetailBuildHelper.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/helper/TemplateDetailBuildHelper.java index f4420e8..2c866a1 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/helper/TemplateDetailBuildHelper.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/helper/TemplateDetailBuildHelper.java @@ -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 buildTemplateDetail(List templateDetails); + List buildTemplateDetail(List templateDetails, ProjectAppraisalIndexDetailVO vo); } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/helper/impl/TemplateDetailBuildHelperImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/helper/impl/TemplateDetailBuildHelperImpl.java index 3813b0c..5cfef4d 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/helper/impl/TemplateDetailBuildHelperImpl.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/helper/impl/TemplateDetailBuildHelperImpl.java @@ -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 buildTemplateDetail(List templateDetails) { - + public List buildTemplateDetail(List templateDetails, ProjectAppraisalIndexDetailVO vo) { List 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 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> reAppScoreInfoMap = reAppraisalScoreInfo.stream().collect(Collectors.groupingBy(PerformanceAppraisalScoreInfo::getAppraisalEmployeeName)); + HashMap scoreMap = MapUtil.newHashMap(); + for (String name : reAppScoreInfoMap.keySet()) { + List 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 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> verifyScoreInfoMap = verifyScoreInfo.stream().collect(Collectors.groupingBy(PerformanceAppraisalScoreInfo::getAppraisalEmployeeName)); + HashMap scoreMap = MapUtil.newHashMap(); + for (String name : verifyScoreInfoMap.keySet()) { + List 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); } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/IndicatorConfigManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/IndicatorConfigManage.java index 0ddefba..9dbbe38 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/IndicatorConfigManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/IndicatorConfigManage.java @@ -115,12 +115,12 @@ public class IndicatorConfigManage { .eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId, id) .eq(PerformanceIndicatorProjectTemplateDetail::getIsAdditional,Boolean.TRUE)); if(CollUtil.isNotEmpty(templateDetails)){ - List templateDetailVos = templateDetailBuildHelper.buildTemplateDetail(templateDetails); + List templateDetailVos = templateDetailBuildHelper.buildTemplateDetail(templateDetails,null); vo.setTemplateDetails(templateDetailVos); } if (CollUtil.isNotEmpty(additionalTemplateDetails)){ - List additionalTemplateDetailVos = templateDetailBuildHelper.buildTemplateDetail(additionalTemplateDetails); + List additionalTemplateDetailVos = templateDetailBuildHelper.buildTemplateDetail(additionalTemplateDetails,null); vo.setAdditionalIndexDetails(additionalTemplateDetailVos); } return vo; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/OrgSelfAppraisalManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/OrgSelfAppraisalManage.java index 231911c..b0bcb24 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/OrgSelfAppraisalManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/OrgSelfAppraisalManage.java @@ -282,8 +282,8 @@ public class OrgSelfAppraisalManage { List additionalTemplateDetails = indicatorProjectTemplateDetailService.list(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class) .eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId, projectTemplate.getId()) .eq(PerformanceIndicatorProjectTemplateDetail::getIsAdditional,Boolean.TRUE)); - List templateDetailVos = templateDetailBuildHelper.buildTemplateDetail(templateDetails); - List additionalTemplateDetailVos = templateDetailBuildHelper.buildTemplateDetail(additionalTemplateDetails); + List templateDetailVos = templateDetailBuildHelper.buildTemplateDetail(templateDetails,vo); + List 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 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); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/PerformanceAppraisalPlanManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/PerformanceAppraisalPlanManage.java index 5b7bc40..9a62202 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/PerformanceAppraisalPlanManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/PerformanceAppraisalPlanManage.java @@ -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())){ // 判断选择的项目是否已经在当前评价计划的其他分组内 diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/ReAppraisalManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/ReAppraisalManage.java index 405cb35..9d8bbbd 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/ReAppraisalManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/ReAppraisalManage.java @@ -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 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 projectLists = projectService.list(Wrappers.lambdaQuery(Project.class) - .eq(Project::getStatus, ProjectStatusEnum.ACCEPTED.getCode()) - .eq(Project::getBuildOrgCode, empPosUnitCode)); + // 从绩效评价 项目表中获取已经完成单位自评的项目 + List paps = performanceAppraisalProjectService.list().stream() + .filter(p -> Objects.nonNull(p.getSelfAppraisalScoreTime())).collect(Collectors.toList()); - if(CollUtil.isEmpty(projectLists)){ - return PageVo.empty(); - } - List projectIds = projectLists.stream().map(Project::getId).collect(Collectors.toList()); - // 获取添加过该单位项目的所有评价计划信息 - List paps = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) - .in(PerformanceAppraisalProject::getProjectId, projectIds)); + // 已存在的评价计划添加的评价项目都未完成单位自评 if(CollUtil.isEmpty(paps)){ return PageVo.empty(); } Set paIds = paps.stream().map(PerformanceAppraisalProject::getAppraisalId).collect(Collectors.toSet()); // 获取评价计划关联的分组信息 - - // 获取评价计划列表 + List groups = groupService.list(Wrappers.lambdaQuery(PerformanceAppraisalProjectGroup.class) + .in(PerformanceAppraisalProjectGroup::getAppraisalId, paIds)); + // 获取当前登录复评员所在的分组信息 + List groupList = groups.stream().filter(g -> { + String reAppraisalUsers = g.getReAppraisalUsers(); + List 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 appraisalIds = groupList.stream().map(PerformanceAppraisalProjectGroup::getAppraisalId).collect(Collectors.toList()); + // 因为同一个复评员只能出现在一个计划的一个分组中,所以分组信息可按照评价计划ID进行分组 + Map groupMap = groupList.stream().collect(Collectors.toMap(PerformanceAppraisalProjectGroup::getAppraisalId, g -> g)); + // 获取复评计划列表 Page page = req.page(); LambdaQueryWrapper 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 res = page.getRecords().stream() - .map(p -> BeanUtil.copyProperties(p, PerformanceAppraisalVO.class)) - .collect(Collectors.toList()); - return PageVo.of(res,page.getTotal()); - } - - public PageVo pendingList(Long planId, PerformanceAppraisalListReq req) { - UserInfoDetails user = LoginUserUtil.loginUserDetail(); - - PerformanceAppraisal plan = performanceAppraisalService.getById(planId); - VUtils.isTrue(Objects.isNull(plan)).throwMessage("该评价计划不存在!"); - - // 获取评价计划内已添加的待评价项目信息 - List paps = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) - .eq(PerformanceAppraisalProject::getAppraisalId, plan.getId())).stream() - .filter(p -> Objects.isNull(p.getSelfAppraisalScoreTime())).collect(Collectors.toList()); - Map papsMap = paps.stream().collect(Collectors.toMap(PerformanceAppraisalProject::getProjectId, p -> p)); - - if(CollUtil.isEmpty(paps)){ - return PageVo.empty(); - } - - // 获取本单位在当前评价计划内的项目 - Set projectCodes = paps.stream().map(PerformanceAppraisalProject::getProjectCode).collect(Collectors.toSet()); - Page page = req.page(); - LambdaQueryWrapper 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 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 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 appraisaledList(Long planId, PerformanceAppraisalListReq req) { - UserInfoDetails user = LoginUserUtil.loginUserDetail(); + private Boolean checkCanReAppraisal(String employeeCode, String projectCode, Long appraisalId) { + // 首次复评(复评打分时间为空) + // 从绩效评价打分信息表中查询打分类型为复评、打分人员为当前登录复评用户的打分信息 + // 如果没有相关的打分信息,说明是当前登录复评用户是首次复评 + List 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 groupProjectList(Long groupId, PerformanceAppraisalListReq req) { - // 获取评价计划内已添加的已评价项目信息 - List paps = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) - .eq(PerformanceAppraisalProject::getAppraisalId, plan.getId())).stream() - .filter(p -> Objects.nonNull(p.getSelfAppraisalScoreTime())).collect(Collectors.toList()); - Map 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 projectCodeList = Arrays.stream(projectCodes.split(StrPool.COMMA)).collect(Collectors.toList()); + + // 筛选出分组内已完成单位自评、需要复评的评价项目信息 + List 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 proCodeList = appraisalProjects.stream().map(PerformanceAppraisalProject::getProjectCode).collect(Collectors.toList()); + Map appraisalProjectMap = appraisalProjects.stream().collect(Collectors.toMap(PerformanceAppraisalProject::getProjectCode, p -> p)); - // 获取本单位在当前评价计划内的项目 - Set projectCodes = paps.stream().map(PerformanceAppraisalProject::getProjectCode).collect(Collectors.toSet()); Page page = req.page(); LambdaQueryWrapper 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 res = page.getRecords().stream() - .map(p -> { + + List 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 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 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 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 templateDetails = indicatorProjectTemplateDetailService.list(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class) - .eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId, projectTemplate.getId())); - // 获取模版附加绩效指标详情 - List additionalTemplateDetails = indicatorProjectTemplateDetailService.list(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class) - .eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId, projectTemplate.getId()) - .eq(PerformanceIndicatorProjectTemplateDetail::getIsAdditional,Boolean.TRUE)); - List templateDetailVos = templateDetailBuildHelper.buildTemplateDetail(templateDetails); - List 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 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 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> scoreInfoMap = performanceAppraisalScoreInfoService.list(Wrappers.lambdaQuery(PerformanceAppraisalScoreInfo.class) + .eq(PerformanceAppraisalScoreInfo::getAppraisalType, AppraisalTypeEnum.RE_APPRAISAL.getCode())) + .stream().collect(Collectors.groupingBy(PerformanceAppraisalScoreInfo::getAppraisalEmployeeCode)); + + List 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 users = Lists.newArrayList(); + for (String reUser : reUsers) { + // 获取分组内复评人员对分组内项目的复评分数信息 + List scoreInfoList = scoreInfoMap.get(reUser); + if (CollUtil.isNotEmpty(scoreInfoList)){ + List projectIdList = scoreInfoList.stream() + .map(PerformanceAppraisalScoreInfo::getAppraisalProjectId) + .collect(Collectors.toList()); + List 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); + } + } + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/VerifyManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/VerifyManage.java new file mode 100644 index 0000000..66e7d01 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/VerifyManage.java @@ -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 list(PerformanceAppraisalListReq req) { + UserInfoDetails user = LoginUserUtil.loginUserDetail(); + String employeeCode = user.getEmployeeCode(); + // 获取当前登录用户的角色列表,只有专家核查人员才能查看该列表 + List userRoleList = user.getUserRoleList(); + List 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 groups = Lists.newArrayList(); + List 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 appraisalIds = groups.stream().map(PerformanceAppraisalProjectGroup::getAppraisalId).collect(Collectors.toList()); + // 因为同一个核查人员只能出现在一个计划的一个分组中,所以分组信息可按照评价计划ID进行分组 + Map groupMap = groups.stream().collect(Collectors.toMap(PerformanceAppraisalProjectGroup::getAppraisalId, g -> g)); + // 获取核查计划列表 + Page page = req.page(); + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(PerformanceAppraisal.class) + .in(PerformanceAppraisal::getId,appraisalIds) + .orderByDesc(PerformanceAppraisal::getUpdateOn); + performanceAppraisalService.page(page,wrapper); + + List 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 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 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 projectCodeList = Arrays.stream(projectCodes.split(StrPool.COMMA)).collect(Collectors.toList()); + + // 筛选出分组内已完成复评的评价项目信息 + List appraisalProjects = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) + .in(PerformanceAppraisalProject::getProjectCode, projectCodeList) + .eq(PerformanceAppraisalProject::getIsCompleteReAppraisal, Boolean.TRUE)); + // 分组内已完成复评的项目信息不存在 + if (CollUtil.isEmpty(appraisalProjects)){ + return PageVo.empty(); + } + List proCodeList = appraisalProjects.stream().map(PerformanceAppraisalProject::getProjectCode).collect(Collectors.toList()); + Map appraisalProjectMap = appraisalProjects.stream().collect(Collectors.toMap(PerformanceAppraisalProject::getProjectCode, p -> p)); + + Page page = req.page(); + LambdaQueryWrapper 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 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 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 ids = appraisalInfoList.stream() + .map(ProjectAppraisalInfoDTO::getProjectTemplateDetailId) + .collect(Collectors.toList()); + // 查出项目模版详情信息 + List detailList = indicatorProjectTemplateDetailService.list(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class) + .in(PerformanceIndicatorProjectTemplateDetail::getId, ids)); + if (CollUtil.isEmpty(detailList)){ + throw new BizException("评价指标不存在!"); + } + Map detailMap = detailList.stream().collect(Collectors.toMap(PerformanceIndicatorProjectTemplateDetail::getId, d -> d)); + List 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> scoreInfoMap = performanceAppraisalScoreInfoService.list(Wrappers.lambdaQuery(PerformanceAppraisalScoreInfo.class) + .eq(PerformanceAppraisalScoreInfo::getAppraisalType, AppraisalTypeEnum.EXPERT_VERIFY.getCode())) + .stream().collect(Collectors.groupingBy(PerformanceAppraisalScoreInfo::getAppraisalEmployeeCode)); + + List 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 users = Lists.newArrayList(); + for (String verifyUser : verifyUsers) { + // 获取分组内核查人员对分组内项目的核查分数信息 + List scoreInfoList = scoreInfoMap.get(verifyUser); + if (CollUtil.isNotEmpty(scoreInfoList)){ + List projectIdList = scoreInfoList.stream() + .map(PerformanceAppraisalScoreInfo::getAppraisalProjectId) + .collect(Collectors.toList()); + List 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); + } + } + } +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/PerformanceAppraisalProjectGroupSaveDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/PerformanceAppraisalProjectGroupSaveDTO.java index e78b1be..4799285 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/PerformanceAppraisalProjectGroupSaveDTO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/PerformanceAppraisalProjectGroupSaveDTO.java @@ -43,4 +43,7 @@ public class PerformanceAppraisalProjectGroupSaveDTO implements Serializable { @ApiModelProperty("核查人员") private List verificationUsers; + + @ApiModelProperty("核查组长") + private String verifyLeader; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/ProjectAppraisalDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/ProjectAppraisalDTO.java index 10ece55..0d0be8d 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/ProjectAppraisalDTO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/ProjectAppraisalDTO.java @@ -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; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalProject.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalProject.java index 76436db..eb11971 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalProject.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalProject.java @@ -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; + } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalProjectGroup.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalProjectGroup.java index 72f4672..9027e46 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalProjectGroup.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalProjectGroup.java @@ -46,4 +46,7 @@ public class PerformanceAppraisalProjectGroup implements Serializable { @ApiModelProperty("核查人员") private String verificationUsers; + + @ApiModelProperty("核查组长") + private String verifyLeader; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalScoreInfo.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalScoreInfo.java index a7cd8a3..12e9fb3 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalScoreInfo.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalScoreInfo.java @@ -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; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceAppraisalProjectVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceAppraisalProjectVO.java index b1233f7..9db9130 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceAppraisalProjectVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceAppraisalProjectVO.java @@ -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; + } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceAppraisalVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceAppraisalVO.java index f93f321..25db559 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceAppraisalVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceAppraisalVO.java @@ -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; + } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/ProjectAppraisalIndexDetailVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/ProjectAppraisalIndexDetailVO.java index c7cbe4a..0b26c1e 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/ProjectAppraisalIndexDetailVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/ProjectAppraisalIndexDetailVO.java @@ -40,4 +40,13 @@ public class ProjectAppraisalIndexDetailVO implements Serializable { @ApiModelProperty("附加绩效指标详情") private List additionalIndexDetails; + + @ApiModelProperty("自评总得分") + private BigDecimal selfAppraisalTotalScore; + + @ApiModelProperty("复评总得分") + private BigDecimal reAppraisalTotalScore; + + @ApiModelProperty("核查总得分") + private BigDecimal verifyTotalScore; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/ProjectTemplateDetailVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/ProjectTemplateDetailVO.java index fc7b6b3..2166577 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/ProjectTemplateDetailVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/ProjectTemplateDetailVO.java @@ -64,7 +64,13 @@ public class ProjectTemplateDetailVO implements Serializable { @ApiModelProperty("复评分数信息") private Map> reAppraisalScoreInfo; + @ApiModelProperty("复评得分信息") + private Map reAppraisalTotalScoreInfo; + @ApiModelProperty("核查分数信息") private Map> verifyScoreInfo; + @ApiModelProperty("核查得分信息") + private Map verifyTotalScoreInfo; + }