diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/OrgSelfAppraisalController.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/OrgSelfAppraisalController.java new file mode 100644 index 0000000..7b9b218 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/OrgSelfAppraisalController.java @@ -0,0 +1,37 @@ +package com.ningdatech.pmapi.performance.controller; + +import com.ningdatech.basic.model.PageVo; +import com.ningdatech.pmapi.performance.manage.OrgSelfAppraisalManage; +import com.ningdatech.pmapi.performance.model.req.PerformanceAppraisalListReq; +import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalVO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; + +/** + * @Classname OrgSelfAppraisalController + * @Description + * @Date 2023/6/25 14:16 + * @Author PoffyZhang + */ +@RestController +@RequiredArgsConstructor +@Api(tags = "绩效评价-单位自评") +@RequestMapping("/api/v1/self-appraisal") +public class OrgSelfAppraisalController { + + private final OrgSelfAppraisalManage selfAppraisalManage; + + @GetMapping("/list") + @ApiOperation("当前用户的绩效评价计划列表") + public PageVo list(PerformanceAppraisalListReq req) { + return selfAppraisalManage.list(req); + } + + @GetMapping("/detail/{id}") + @ApiOperation("当前用户的绩效评价计划详情") + public PerformanceAppraisalVO detail(@PathVariable Long id) { + return selfAppraisalManage.detail(id); + } +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/PerformanceAppraisalPlanController.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/PerformanceAppraisalPlanController.java index 032e52d..c501e1c 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/PerformanceAppraisalPlanController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/PerformanceAppraisalPlanController.java @@ -57,6 +57,13 @@ public class PerformanceAppraisalPlanController { return performanceAppraisalPlanManage.edit(editDTO); } + @PostMapping("/delete/{id}") + @ApiOperation("绩效评价删除") + @WebLog("绩效评价删除") + public String delete(@PathVariable Long id) { + return performanceAppraisalPlanManage.delete(id); + } + @GetMapping("/group/list/{appraisalId}") @ApiOperation("绩效评价分组列表") public List groupList(@PathVariable Long appraisalId, @@ -64,10 +71,23 @@ public class PerformanceAppraisalPlanController { return performanceAppraisalPlanManage.groupList(appraisalId,name); } + @GetMapping("/group/detail/{id}") + @ApiOperation("绩效评价分组详情") + public PerformanceAppraisalProjectGroupVO groupDetail(@PathVariable Long id) { + return performanceAppraisalPlanManage.groupDetail(id); + } + @PostMapping("/group/save") @ApiOperation("绩效评价分组保存") @WebLog("绩效评价分组保存") public String groupSave(@Valid @RequestBody PerformanceAppraisalProjectGroupSaveDTO dto) { return performanceAppraisalPlanManage.groupSave(dto); } + + @PostMapping("/group/delete/{id}") + @ApiOperation("绩效评价分组删除") + @WebLog("绩效评价分组删除") + public String groupDelete(@PathVariable Long id) { + return performanceAppraisalPlanManage.groupDelete(id); + } } 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 new file mode 100644 index 0000000..56697ce --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/OrgSelfAppraisalManage.java @@ -0,0 +1,180 @@ +package com.ningdatech.pmapi.performance.manage; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.google.common.collect.Maps; +import com.ningdatech.basic.function.VUtils; +import com.ningdatech.basic.model.PageVo; +import com.ningdatech.pmapi.performance.convert.PerformanceAppraisalConveter; +import com.ningdatech.pmapi.performance.model.entity.PerformanceAppraisal; +import com.ningdatech.pmapi.performance.model.entity.PerformanceAppraisalApplication; +import com.ningdatech.pmapi.performance.model.entity.PerformanceAppraisalProject; +import com.ningdatech.pmapi.performance.model.req.PerformanceAppraisalListReq; +import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalVO; +import com.ningdatech.pmapi.performance.service.IPerformanceAppraisalApplicationService; +import com.ningdatech.pmapi.performance.service.IPerformanceAppraisalProjectService; +import com.ningdatech.pmapi.performance.service.IPerformanceAppraisalService; +import com.ningdatech.pmapi.projectlib.model.entity.Project; +import com.ningdatech.pmapi.projectlib.model.entity.ProjectApplication; +import com.ningdatech.pmapi.projectlib.service.IProjectApplicationService; +import com.ningdatech.pmapi.projectlib.service.IProjectService; +import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; +import com.ningdatech.pmapi.user.util.LoginUserUtil; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @Classname OrgSelfAppraisalManage + * @Description + * @Date 2023/6/19 14:18 + * @Author PoffyZhang + */ +@Component +@Slf4j +@AllArgsConstructor +public class OrgSelfAppraisalManage { + + private final IPerformanceAppraisalService performanceAppraisalService; + + private final IPerformanceAppraisalProjectService performanceAppraisalProjectService; + + private final IPerformanceAppraisalApplicationService performanceAppraisalApplicationService; + + private final IProjectService projectService; + + private final IProjectApplicationService applicationService; + + /** + * 绩效列表 + * @param req + * @return + */ + public PageVo list(PerformanceAppraisalListReq req) { + UserInfoDetails user = LoginUserUtil.loginUserDetail(); + + //当前登录用户 单位code + String empPosUnitCode = user.getEmpPosUnitCode(); + projectService.list(Wrappers.lambdaQuery(Project.class) + .eq(Project::getBuildOrgCode,empPosUnitCode)); + + + Page page = req.page(); + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(PerformanceAppraisal.class) + .like(StringUtils.isNotBlank(req.getName()),PerformanceAppraisal::getName,req.getName()) + .ge(Objects.nonNull(req.getStart()),PerformanceAppraisal::getCreateOn,req.getStart()) + .le(Objects.nonNull(req.getEnd()),PerformanceAppraisal::getCreateOn,req.getEnd()) + .orderByDesc(PerformanceAppraisal::getUpdateOn); + performanceAppraisalService.page(page,wrapper); + if(0L == page.getTotal()){ + return PageVo.empty(); + } + + List paIds = page.getRecords().stream().map(PerformanceAppraisal::getId).collect(Collectors.toList()); + List paps = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) + .in(PerformanceAppraisalProject::getAppraisalId, paIds)); + + Map projectMap = Maps.newHashMap(); + Map> papsGroupMap = Maps.newHashMap(); + if(CollUtil.isNotEmpty(paps)){ + papsGroupMap = paps.stream().collect(Collectors.groupingBy(PerformanceAppraisalProject::getAppraisalId)); + + List projectCodes = paps.stream().map(PerformanceAppraisalProject::getProjectCode).collect(Collectors.toList()); + List projects = projectService.list(Wrappers.lambdaQuery(Project.class) + .in(Project::getProjectCode, projectCodes) + .eq(Project::getNewest, Boolean.TRUE)); + if(CollUtil.isNotEmpty(projects)){ + projectMap = projects.stream().collect(Collectors.toMap(Project::getProjectCode,p -> p)); + } + } + + List paas = performanceAppraisalApplicationService.list(Wrappers.lambdaQuery(PerformanceAppraisalApplication.class) + .in(PerformanceAppraisalApplication::getAppraisalId, paIds)); + Map applicationMap = Maps.newHashMap(); + Map> paasGroupMap = Maps.newHashMap(); + if(CollUtil.isNotEmpty(paas)){ + paasGroupMap = paas.stream().collect(Collectors.groupingBy(PerformanceAppraisalApplication::getAppraisalId)); + + List applicationIds = paas.stream().map(PerformanceAppraisalApplication::getApplicationId).collect(Collectors.toList()); + List apps = applicationService.list(Wrappers.lambdaQuery(ProjectApplication.class) + .in(ProjectApplication::getId, applicationIds)); + if(CollUtil.isNotEmpty(apps)){ + applicationMap = apps.stream().collect(Collectors.toMap(ProjectApplication::getId,a -> a)); + } + } + + Map> finalPapsGroupMap = papsGroupMap; + Map> finalPaasGroupMap = paasGroupMap; + Map finalProjectMap = projectMap; + Map finalApplicationMap = applicationMap; + List res = page.getRecords().stream().map(p -> { + PerformanceAppraisalVO vo = BeanUtil.copyProperties(p,PerformanceAppraisalVO.class); + if(finalPapsGroupMap.containsKey(p.getId())){ + vo.setProjects(PerformanceAppraisalConveter.convertProjects(finalPapsGroupMap.get(p.getId()),finalProjectMap)); + } + if(finalPaasGroupMap.containsKey(p.getId())){ + vo.setApplications(PerformanceAppraisalConveter.convertApplications(finalPaasGroupMap.get(p.getId()),finalApplicationMap)); + } + return vo; + }).collect(Collectors.toList()); + return PageVo.of(res,page.getTotal()); + } + + public PerformanceAppraisalVO detail(Long id) { + + PerformanceAppraisal pa = performanceAppraisalService.getById(id); + VUtils.isTrue(Objects.isNull(pa)).throwMessage("该计划不存在"); + + PerformanceAppraisalVO vo = BeanUtil.copyProperties(pa,PerformanceAppraisalVO.class); + //绩效关联的项目 + List paps = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) + .eq(PerformanceAppraisalProject::getAppraisalId, id)); + Map projectMap = Maps.newHashMap(); + Map> papsGroupMap = Maps.newHashMap(); + if(CollUtil.isNotEmpty(paps)){ + papsGroupMap = paps.stream().collect(Collectors.groupingBy(PerformanceAppraisalProject::getAppraisalId)); + + List projectCodes = paps.stream().map(PerformanceAppraisalProject::getProjectCode).collect(Collectors.toList()); + List projects = projectService.list(Wrappers.lambdaQuery(Project.class) + .in(Project::getProjectCode, projectCodes) + .eq(Project::getNewest, Boolean.TRUE)); + if(CollUtil.isNotEmpty(projects)){ + projectMap = projects.stream().collect(Collectors.toMap(Project::getProjectCode,p -> p)); + } + } + + //绩效关联的应用 + List paas = performanceAppraisalApplicationService.list(Wrappers.lambdaQuery(PerformanceAppraisalApplication.class) + .eq(PerformanceAppraisalApplication::getAppraisalId, id)); + Map applicationMap = Maps.newHashMap(); + Map> paasGroupMap = Maps.newHashMap(); + if(CollUtil.isNotEmpty(paas)){ + paasGroupMap = paas.stream().collect(Collectors.groupingBy(PerformanceAppraisalApplication::getAppraisalId)); + + List applicationIds = paas.stream().map(PerformanceAppraisalApplication::getApplicationId).collect(Collectors.toList()); + List apps = applicationService.list(Wrappers.lambdaQuery(ProjectApplication.class) + .in(ProjectApplication::getId, applicationIds)); + if(CollUtil.isNotEmpty(apps)){ + applicationMap = apps.stream().collect(Collectors.toMap(ProjectApplication::getId,a -> a)); + } + } + + Map> finalPapsGroupMap = papsGroupMap; + Map> finalPaasGroupMap = paasGroupMap; + Map finalProjectMap = projectMap; + Map finalApplicationMap = applicationMap; + if(finalPapsGroupMap.containsKey(vo.getId())){ + vo.setProjects(PerformanceAppraisalConveter.convertProjects(finalPapsGroupMap.get(vo.getId()),finalProjectMap)); + } + if(finalPaasGroupMap.containsKey(vo.getId())){ + vo.setApplications(PerformanceAppraisalConveter.convertApplications(finalPaasGroupMap.get(vo.getId()),finalApplicationMap)); + } + return vo; + } +} 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 1f0601d..d6dd8f3 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 @@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.Maps; import com.google.common.collect.Sets; +import com.ningdatech.basic.exception.BizException; import com.ningdatech.basic.function.VUtils; import com.ningdatech.basic.model.PageVo; import com.ningdatech.basic.util.StrPool; @@ -368,6 +369,27 @@ public class PerformanceAppraisalPlanManage { } } + /** + * 删除绩效评价计划 + * 连带删除 其下所有 + * @param id + * @return + */ + public String delete(Long id) { + PerformanceAppraisal pa = performanceAppraisalService.getById(id); + VUtils.isTrue(Objects.isNull(pa)).throwMessage("绩效评价不存在 删除失败!"); + + //如果到了自评就不能删除了 + if(pa.getSelfAppraisalStart().compareTo(LocalDateTime.now()) < 0){ + throw new BizException("自评已经开始 不能够删除绩效评价"); + } + + if(performanceAppraisalService.removeById(id)){ + return "删除成功"; + } + return "删除失败"; + } + public List groupList(Long appraisalId,String name) { List groups = groupService.list( Wrappers.lambdaQuery(PerformanceAppraisalProjectGroup.class) @@ -422,6 +444,52 @@ public class PerformanceAppraisalPlanManage { } /** + * 分组详情 + * @param id + * @return + */ + public PerformanceAppraisalProjectGroupVO groupDetail(Long id) { + PerformanceAppraisalProjectGroup group = groupService.getById(id); + + if(Objects.isNull(group)){ + return null; + } + + Map projectMap = Maps.newHashMap(); + List projects = projectService.list(Wrappers.lambdaQuery(Project.class) + .in(StringUtils.isNotBlank(group.getProjectIds()),Project::getProjectCode, + Arrays.stream(group.getProjectIds().split(StrPool.COMMA)).collect(Collectors.toList())) + .eq(Project::getNewest,Boolean.TRUE)); + if(CollUtil.isNotEmpty(projects)){ + projectMap = projects.stream().collect(Collectors.toMap(Project::getProjectCode,p -> p)); + } + + Map userMap = Maps.newHashMap(); + Set allEmployeeCodes = Sets.newHashSet(); + allEmployeeCodes.addAll(CodeUtil.convertStrToList(group.getReAppraisalUsers())); + allEmployeeCodes.addAll(CodeUtil.convertStrToList(group.getVerificationUsers())); + if(CollUtil.isNotEmpty(allEmployeeCodes)){ + List users = userInfoHelper.getUserFullInfoByEmployeeCodes(allEmployeeCodes); + if(CollUtil.isNotEmpty(users)){ + userMap = users.stream().collect(Collectors.toMap(UserFullInfoDTO::getEmployeeCode,u -> u)); + } + } + + PerformanceAppraisalProjectGroupVO vo = new PerformanceAppraisalProjectGroupVO(); + vo.setAppraisalId(group.getAppraisalId()); + vo.setName(group.getName()); + vo.setCreateOn(group.getCreateOn()); + vo.setCreateBy(group.getCreateBy()); + vo.setUpdateBy(group.getUpdateBy()); + vo.setUpdateOn(group.getUpdateOn()); + vo.setId(group.getId()); + vo.setProjects(checkProject(group.getProjectIds(), projectMap)); + vo.setReAppraisalUsers(checkUser(group.getReAppraisalUsers(), userMap)); + vo.setVerificationUsers(checkUser(group.getVerificationUsers(), userMap)); + return vo; + } + + /** * 分组 保存 * @param dto * @return @@ -455,6 +523,32 @@ public class PerformanceAppraisalPlanManage { return "操作成功"; } + /** + * 删除分组 + * @param id + * @return + */ + public String groupDelete(Long id) { + PerformanceAppraisalProjectGroup group = groupService.getById(id); + VUtils.isTrue(Objects.isNull(group)).throwMessage("分组不存在"); + + //评价Id + Long appraisalId = group.getAppraisalId(); + + PerformanceAppraisal pa = performanceAppraisalService.getById(appraisalId); + VUtils.isTrue(Objects.isNull(pa)).throwMessage("评价不存在"); + + //如果到了自评就不能删除了 + if(pa.getSelfAppraisalStart().compareTo(LocalDateTime.now()) < 0){ + throw new BizException("自评已经开始 不能够删除绩效评价"); + } + + if(groupService.removeById(id)){ + return "删除成功"; + } + return "删除失败"; + } + private List checkProject(String projectIds, Map projectMap) { if(StringUtils.isBlank(projectIds)){ return Collections.emptyList(); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/dto/ProjectCollectionSaveDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/dto/ProjectCollectionSaveDTO.java index 5392876..7060b4f 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/dto/ProjectCollectionSaveDTO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/dto/ProjectCollectionSaveDTO.java @@ -28,6 +28,9 @@ public class ProjectCollectionSaveDTO implements Serializable { @ApiModelProperty("主键") private Long id; + @ApiModelProperty("项目编号") + private String projectCode; + @ApiModelProperty("所属地区编号") private String areaCode; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/entity/ProjectCollection.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/entity/ProjectCollection.java index ce6c860..8eb46e2 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/entity/ProjectCollection.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/entity/ProjectCollection.java @@ -28,6 +28,9 @@ public class ProjectCollection implements Serializable { @TableId(type = IdType.AUTO) private Long id; + @ApiModelProperty("项目编号") + private String projectCode; + @ApiModelProperty("所属地区编号") private String areaCode; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectCollectionVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectCollectionVO.java index a6ab4dc..cc136a2 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectCollectionVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectCollectionVO.java @@ -28,6 +28,9 @@ public class ProjectCollectionVO implements Serializable { @ApiModelProperty("主键") private Long id; + @ApiModelProperty("项目编号") + private String projectCode; + @ApiModelProperty("所属地区编号") private String areaCode;