Browse Source

绩效评价计划-代码修改

master
CMM 1 year ago
parent
commit
16dbddf02a
14 changed files with 371 additions and 132 deletions
  1. +2
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/common/constant/CommonConst.java
  2. +23
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/PerformanceAppraisalPlanController.java
  3. +30
    -6
      pmapi/src/main/java/com/ningdatech/pmapi/performance/convert/PerformanceAppraisalConveter.java
  4. +42
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/performance/enumration/EvalObjectEnum.java
  5. +9
    -7
      pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/OrgSelfAppraisalManage.java
  6. +204
    -37
      pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/PerformanceAppraisalPlanManage.java
  7. +13
    -27
      pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/PerformanceAppraisalCreateDTO.java
  8. +11
    -22
      pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/PerformanceAppraisalEditDTO.java
  9. +10
    -16
      pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisal.java
  10. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalApplication.java
  11. +6
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalProject.java
  12. +6
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/performance/model/req/PerformanceAppraisalListReq.java
  13. +2
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceAppraisalApplicationVO.java
  14. +12
    -12
      pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceAppraisalVO.java

+ 2
- 0
pmapi/src/main/java/com/ningdatech/pmapi/common/constant/CommonConst.java View File

@@ -58,6 +58,8 @@ public interface CommonConst {
Integer VERSION_JUDGE = -1;

String COPY = "副本";
String PROJECT_REPEAT = " 项目已在其他评价计划中,请勿重复添加!";
String APP_REPEAT = " 应用已在其他评价计划中,请勿重复添加!";





+ 23
- 2
pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/PerformanceAppraisalPlanController.java View File

@@ -7,6 +7,7 @@ import com.ningdatech.pmapi.performance.model.dto.PerformanceAppraisalCreateDTO;
import com.ningdatech.pmapi.performance.model.dto.PerformanceAppraisalEditDTO;
import com.ningdatech.pmapi.performance.model.dto.PerformanceAppraisalProjectGroupSaveDTO;
import com.ningdatech.pmapi.performance.model.req.PerformanceAppraisalListReq;
import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalApplicationVO;
import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalProjectGroupVO;
import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalVO;
import io.swagger.annotations.Api;
@@ -32,13 +33,13 @@ public class PerformanceAppraisalPlanController {
private final PerformanceAppraisalPlanManage performanceAppraisalPlanManage;

@GetMapping("/list")
@ApiOperation("绩效评价列表")
@ApiOperation("评价计划列表")
public PageVo<PerformanceAppraisalVO> list(PerformanceAppraisalListReq req) {
return performanceAppraisalPlanManage.list(req);
}

@GetMapping("/detail/{id}")
@ApiOperation("绩效评价列表")
@ApiOperation("评价计划详情")
public PerformanceAppraisalVO detail(@PathVariable Long id) {
return performanceAppraisalPlanManage.detail(id);
}
@@ -50,6 +51,20 @@ public class PerformanceAppraisalPlanController {
return performanceAppraisalPlanManage.create(createDTO);
}

@PostMapping("/addProject")
@ApiOperation("评价计划-添加待评价项目")
@WebLog("评价计划-添加待评价项目")
public String addProject(@Valid @RequestBody PerformanceAppraisalCreateDTO createDTO) {
return performanceAppraisalPlanManage.addProject(createDTO);
}

@PostMapping("/addApplication")
@ApiOperation("评价计划-添加待评价应用")
@WebLog("评价计划-添加待评价应用")
public String addApplication(@Valid @RequestBody PerformanceAppraisalCreateDTO createDTO) {
return performanceAppraisalPlanManage.addApplication(createDTO);
}

@PostMapping("/edit")
@ApiOperation("编辑绩效评价")
@WebLog("编辑绩效评价")
@@ -64,6 +79,12 @@ public class PerformanceAppraisalPlanController {
return performanceAppraisalPlanManage.delete(id);
}

@GetMapping("/application-list")
@ApiOperation("待添加应用列表")
public PageVo<PerformanceAppraisalApplicationVO> applicationList(PerformanceAppraisalListReq req) {
return performanceAppraisalPlanManage.applicationList(req);
}

@GetMapping("/group/list/{appraisalId}")
@ApiOperation("绩效评价分组列表")
public List<PerformanceAppraisalProjectGroupVO> groupList(@PathVariable Long appraisalId,


+ 30
- 6
pmapi/src/main/java/com/ningdatech/pmapi/performance/convert/PerformanceAppraisalConveter.java View File

@@ -1,6 +1,14 @@
package com.ningdatech.pmapi.performance.convert;

import cn.hutool.core.collection.CollUtil;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

import org.apache.commons.lang3.StringUtils;

import com.ningdatech.pmapi.performance.model.entity.PerformanceAppraisalApplication;
import com.ningdatech.pmapi.performance.model.entity.PerformanceAppraisalProject;
import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalApplicationVO;
@@ -8,10 +16,8 @@ import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalProjectVO;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeEnum;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.projectlib.model.entity.ProjectApplication;
import org.apache.commons.lang3.StringUtils;

import java.util.*;
import java.util.stream.Collectors;
import cn.hutool.core.collection.CollUtil;

/**
* @Classname PerformanceAppraisalConverer
@@ -27,6 +33,7 @@ public class PerformanceAppraisalConveter {
return projects.stream().map(p -> {
PerformanceAppraisalProjectVO vo = new PerformanceAppraisalProjectVO();
vo.setIsReAppraisal(p.getIsReAppraisal());
vo.setCanSelfAppraisal(checkCanSelfAppraisal(p));
vo.setId(p.getProjectId());
if(map.containsKey(p.getProjectCode())){
Project project = map.get(p.getProjectCode());
@@ -45,17 +52,18 @@ public class PerformanceAppraisalConveter {
}

public static List<PerformanceAppraisalApplicationVO> convertApplications(
List<PerformanceAppraisalApplication> applications, Map<Long, ProjectApplication> map) {
List<PerformanceAppraisalApplication> applications, Map<Long,ProjectApplication> map) {
if(CollUtil.isNotEmpty(applications) && CollUtil.isNotEmpty(map)){
return applications.stream().map(a -> {
PerformanceAppraisalApplicationVO vo = new PerformanceAppraisalApplicationVO();
vo.setId(a.getApplicationId());
vo.setAppId(a.getApplicationId());
if(map.containsKey(a.getApplicationId())){
ProjectApplication application = map.get(a.getApplicationId());
vo.setApplicationName(StringUtils.isNotBlank(application.getApplicationName())?
application.getApplicationName() : application.getAccountAppName());
vo.setApplicationType(application.getApplicationType());
vo.setBizDomain(application.getBizDomain());
vo.setBuildOrgName(application.getBuildOrgName());
vo.setPublishSide(application.getPublishSide());
}
return vo;
@@ -70,4 +78,20 @@ public class PerformanceAppraisalConveter {
}
return StringUtils.EMPTY;
}

/**
* 是否可以自评
* @param appraisalProject
* @return
*/
public static Boolean checkCanSelfAppraisal(PerformanceAppraisalProject appraisalProject) {
if (Objects.nonNull(appraisalProject.getSelfAppraisalStart())
&& Objects.nonNull(appraisalProject.getSelfAppraisalEnd())) {
if (LocalDateTime.now().compareTo(appraisalProject.getSelfAppraisalStart()) > 0 &&
LocalDateTime.now().compareTo(appraisalProject.getSelfAppraisalEnd()) < 0) {
return Boolean.TRUE;
}
}
return Boolean.FALSE;
}
}

+ 42
- 0
pmapi/src/main/java/com/ningdatech/pmapi/performance/enumration/EvalObjectEnum.java View File

@@ -0,0 +1,42 @@
package com.ningdatech.pmapi.performance.enumration;

import java.util.Objects;

import org.apache.commons.lang3.StringUtils;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
* EvalObjectEnum
* @return
* @author CMM
* @since 2023/07/26 16:44
*/
@Getter
@AllArgsConstructor
@NoArgsConstructor
public enum EvalObjectEnum {
/**
* 评价对象
*/
PROJECT("1", "项目"),
APP("2", "应用"),
PROJECT_APP("1,2", "项目、应用");

private String code;
private String desc;

public static String getDesc(String code) {
if (Objects.isNull(code)) {
return StringUtils.EMPTY;
}
for (EvalObjectEnum t : EvalObjectEnum.values()) {
if (code.equals(t.getCode())) {
return t.desc;
}
}
return StringUtils.EMPTY;
}
}

+ 9
- 7
pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/OrgSelfAppraisalManage.java View File

@@ -79,8 +79,8 @@ public class OrgSelfAppraisalManage {

Page<PerformanceAppraisal> page = req.page();
LambdaQueryWrapper<PerformanceAppraisal> wrapper = Wrappers.lambdaQuery(PerformanceAppraisal.class)
.in(PerformanceAppraisal::getId,paIds)
.orderByDesc(PerformanceAppraisal::getUpdateOn);
.in(PerformanceAppraisal::getId,paIds)
.orderByDesc(PerformanceAppraisal::getUpdateOn);
performanceAppraisalService.page(page,wrapper);
if(0L == page.getTotal()){
return PageVo.empty();
@@ -101,6 +101,7 @@ public class OrgSelfAppraisalManage {

List<PerformanceAppraisalProject> paps = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class)
.eq(PerformanceAppraisalProject::getAppraisalId, plan.getId()));
Map<Long, PerformanceAppraisalProject> papsMap = paps.stream().collect(Collectors.toMap(PerformanceAppraisalProject::getProjectId, p -> p));

if(CollUtil.isEmpty(paps)){
return PageVo.empty();
@@ -122,7 +123,8 @@ public class OrgSelfAppraisalManage {
List<PerformanceAppraisalProjectVO> res = page.getRecords().stream()
.map(p -> {
PerformanceAppraisalProjectVO vo = BeanUtil.copyProperties(p, PerformanceAppraisalProjectVO.class);
vo.setCanSelfAppraisal(checkCanSelfAppraisal(plan));
PerformanceAppraisalProject appraisalProject = papsMap.get(p.getId());
vo.setCanSelfAppraisal(checkCanSelfAppraisal(appraisalProject));
return vo;
})
.collect(Collectors.toList());
@@ -142,12 +144,12 @@ public class OrgSelfAppraisalManage {

/**
* 是否可以自评
* @param plan
* @param appraisalProject
* @return
*/
private Boolean checkCanSelfAppraisal(PerformanceAppraisal plan) {
if(LocalDateTime.now().compareTo(plan.getSelfAppraisalStart()) > 0 &&
LocalDateTime.now().compareTo(plan.getSelfAppraisalEnd()) < 0){
private Boolean checkCanSelfAppraisal(PerformanceAppraisalProject appraisalProject) {
if(LocalDateTime.now().compareTo(appraisalProject.getSelfAppraisalStart()) > 0 &&
LocalDateTime.now().compareTo(appraisalProject.getSelfAppraisalEnd()) < 0){
return Boolean.TRUE;
}
return Boolean.FALSE;


+ 204
- 37
pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/PerformanceAppraisalPlanManage.java View File

@@ -1,21 +1,31 @@
package com.ningdatech.pmapi.performance.manage;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;

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.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists;
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.NdDateUtils;
import com.ningdatech.basic.util.StrPool;
import com.ningdatech.pmapi.common.constant.BizConst;
import com.ningdatech.pmapi.common.constant.CommonConst;
import com.ningdatech.pmapi.common.helper.UserInfoHelper;
import com.ningdatech.pmapi.common.util.BizUtils;
import com.ningdatech.pmapi.common.util.CodeUtil;
import com.ningdatech.pmapi.performance.convert.PerformanceAppraisalConveter;
import com.ningdatech.pmapi.performance.enumration.EvalObjectEnum;
import com.ningdatech.pmapi.performance.model.dto.AppraisalProjectDTO;
import com.ningdatech.pmapi.performance.model.dto.PerformanceAppraisalCreateDTO;
import com.ningdatech.pmapi.performance.model.dto.PerformanceAppraisalEditDTO;
@@ -25,6 +35,7 @@ import com.ningdatech.pmapi.performance.model.entity.PerformanceAppraisalApplica
import com.ningdatech.pmapi.performance.model.entity.PerformanceAppraisalProject;
import com.ningdatech.pmapi.performance.model.entity.PerformanceAppraisalProjectGroup;
import com.ningdatech.pmapi.performance.model.req.PerformanceAppraisalListReq;
import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalApplicationVO;
import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalProjectGroupVO;
import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalProjectVO;
import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalVO;
@@ -32,20 +43,27 @@ import com.ningdatech.pmapi.performance.service.IPerformanceAppraisalApplication
import com.ningdatech.pmapi.performance.service.IPerformanceAppraisalProjectGroupService;
import com.ningdatech.pmapi.performance.service.IPerformanceAppraisalProjectService;
import com.ningdatech.pmapi.performance.service.IPerformanceAppraisalService;
import com.ningdatech.pmapi.projectlib.enumeration.InstTypeEnum;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.projectlib.model.entity.ProjectApplication;
import com.ningdatech.pmapi.projectlib.model.entity.ProjectInst;
import com.ningdatech.pmapi.projectlib.service.IProjectApplicationService;
import com.ningdatech.pmapi.projectlib.service.IProjectInstService;
import com.ningdatech.pmapi.projectlib.service.IProjectService;
import com.ningdatech.pmapi.todocenter.utils.BuildUserUtils;
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO;
import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails;
import com.ningdatech.pmapi.user.util.LoginUserUtil;
import com.wflow.workflow.bean.process.ProgressNode;
import com.wflow.workflow.bean.vo.ProcessProgressVo;
import com.wflow.workflow.service.ProcessInstanceService;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;

/**
* @Classname PerformanceAppraisalManage
@@ -59,18 +77,15 @@ import java.util.stream.Collectors;
public class PerformanceAppraisalPlanManage {

private final IPerformanceAppraisalService performanceAppraisalService;

private final IPerformanceAppraisalProjectService performanceAppraisalProjectService;

private final IPerformanceAppraisalApplicationService performanceAppraisalApplicationService;

private final IProjectService projectService;

private final IProjectApplicationService applicationService;

private final IPerformanceAppraisalProjectGroupService groupService;

private final UserInfoHelper userInfoHelper;
private final IProjectInstService projectInstService;
private final ProcessInstanceService processInstanceService;
private final BuildUserUtils buildUserUtils;

/**
* 绩效列表
@@ -78,12 +93,15 @@ public class PerformanceAppraisalPlanManage {
* @return
*/
public PageVo<PerformanceAppraisalVO> list(PerformanceAppraisalListReq req) {
UserInfoDetails userDetail = LoginUserUtil.loginUserDetail();
String regionCode = userDetail.getRegionCode();
Page<PerformanceAppraisal> page = req.page();
LambdaQueryWrapper<PerformanceAppraisal> wrapper = Wrappers.lambdaQuery(PerformanceAppraisal.class)
.like(StringUtils.isNotBlank(req.getPlanName()),PerformanceAppraisal::getName,req.getPlanName())
.ge(Objects.nonNull(req.getStart()),PerformanceAppraisal::getCreateOn,req.getStart())
.le(Objects.nonNull(req.getEnd()),PerformanceAppraisal::getCreateOn,req.getEnd())
.orderByDesc(PerformanceAppraisal::getUpdateOn);
.like(StringUtils.isNotBlank(req.getPlanName()),PerformanceAppraisal::getName,req.getPlanName())
.ge(Objects.nonNull(req.getStart()),PerformanceAppraisal::getCreateOn,req.getStart())
.le(Objects.nonNull(req.getEnd()),PerformanceAppraisal::getCreateOn,req.getEnd())
.eq(PerformanceAppraisal::getRegionCode,regionCode)
.orderByDesc(PerformanceAppraisal::getUpdateOn);
performanceAppraisalService.page(page,wrapper);
if(0L == page.getTotal()){
return PageVo.empty();
@@ -188,6 +206,15 @@ public class PerformanceAppraisalPlanManage {
if(finalPaasGroupMap.containsKey(vo.getId())){
vo.setApplications(PerformanceAppraisalConveter.convertApplications(finalPaasGroupMap.get(vo.getId()),finalApplicationMap));
}

// 评价计划关联的分组信息
List<PerformanceAppraisalProjectGroup> groupList = groupService.list(Wrappers.lambdaQuery(PerformanceAppraisalProjectGroup.class)
.eq(PerformanceAppraisalProjectGroup::getAppraisalId, id));
// 对计划内待评价项目进行了分组
if (CollUtil.isNotEmpty(groupList)){

}

return vo;
}

@@ -199,25 +226,25 @@ public class PerformanceAppraisalPlanManage {
@Transactional
public String create(PerformanceAppraisalCreateDTO createDTO) {
UserInfoDetails user = LoginUserUtil.loginUserDetail();
// 计划名称重复校验
deduplicationName(createDTO);

PerformanceAppraisal pa = BeanUtil.copyProperties(createDTO,PerformanceAppraisal.class);
pa.setCreateOn(LocalDateTime.now());
pa.setCreateBy(user.getUsername());
pa.setUpdateOn(LocalDateTime.now());
pa.setUpdateBy(user.getUsername());
pa.setRegionCode(user.getRegionCode());
performanceAppraisalService.save(pa);

if(CollUtil.isNotEmpty(createDTO.getProjects())
&& StringUtils.isNotBlank(createDTO.getTarget())
&& createDTO.getTarget().contains("1")){
&& createDTO.getTarget().contains(EvalObjectEnum.PROJECT.getCode())){
saveProjects(createDTO,pa.getId(),user);
}

if(CollUtil.isNotEmpty(createDTO.getApplicationIds())
&& StringUtils.isNotBlank(createDTO.getTarget())
&& createDTO.getTarget().contains("2")){
&& createDTO.getTarget().contains(EvalObjectEnum.APP.getCode())){
saveApplications(createDTO,pa.getId(),user);
}

@@ -278,11 +305,16 @@ public class PerformanceAppraisalPlanManage {
return;
}

Integer startSelfDays = createDTO.getStartSelfDays();
Integer completeSelfDays = createDTO.getCompleteSelfDays();
List<AppraisalProjectDTO> projects = createDTO.getProjects();

for(AppraisalProjectDTO appraisalProject : projects){
Project newProject = projectService.getNewProject(appraisalProject.getId());
VUtils.isTrue(Objects.isNull(newProject)).throwMessage("项目不存在 " + appraisalProject.getId());
// 获取项目终验完成的时间
LocalDateTime finishTime = getProjectFinishTime(newProject);

PerformanceAppraisalProject pap = new PerformanceAppraisalProject();
pap.setAppraisalId(id);
pap.setProjectId(appraisalProject.getId());
@@ -292,10 +324,44 @@ public class PerformanceAppraisalPlanManage {
pap.setCreateOn(LocalDateTime.now());
pap.setUpdateBy(user.getUsername());
pap.setUpdateOn(LocalDateTime.now());
LocalDateTime selfAppraisalStart = finishTime.plusDays(startSelfDays);
pap.setSelfAppraisalStart(selfAppraisalStart);
long days = startSelfDays + completeSelfDays;
LocalDateTime selfAppraisalEnd = finishTime.plusDays(days);
pap.setSelfAppraisalEnd(selfAppraisalEnd);
performanceAppraisalProjectService.save(pap);
}
}

private LocalDateTime getProjectFinishTime(Project newProject) {
//查出历史版本的 所有项目ID
List<Long> allVersionProjectIds = projectService.getAllVersionProjectId(newProject);
// 根据项目ID查询出项目终验流程的流程状态
ProjectInst projectInst = projectInstService.getOne(Wrappers.lambdaQuery(ProjectInst.class)
.in(ProjectInst::getProjectId, allVersionProjectIds)
.eq(ProjectInst::getInstType, InstTypeEnum.PROJECT_FINAL_INSPECTION.getCode())
.orderByDesc(ProjectInst::getCreatOn)
.last(BizConst.LIMIT_1));

if (Objects.isNull(projectInst)){
throw new BizException("未获取到项目终验审批流程信息!");
}

LocalDateTime finishTime;
String instCode = projectInst.getInstCode();
ProcessProgressVo instanceDetail = processInstanceService.getProgressInstanceDetail(null, instCode);
// 装配节点审核人员信息
List<ProgressNode> progressInfo = instanceDetail.getProgressInfo();
if (CollUtil.isNotEmpty(progressInfo)) {
buildUserUtils.buildUserByProcessInfo(progressInfo);
ProgressNode progressNode = progressInfo.get(progressInfo.size() - 1);
finishTime = NdDateUtils.date2LocalDateTime(progressNode.getFinishTime());
}else {
finishTime = NdDateUtils.date2LocalDateTime(instanceDetail.getStartTime());
}
return finishTime;
}

@Transactional
public void saveApplications(PerformanceAppraisalCreateDTO createDTO,Long id,UserInfoDetails user) {
if(CollUtil.isEmpty(createDTO.getApplicationIds())){
@@ -303,10 +369,7 @@ public class PerformanceAppraisalPlanManage {
}

List<Long> applicationIds = createDTO.getApplicationIds();

for(Long applicationId : applicationIds){
ProjectApplication projectApplication = applicationService.getById(applicationId);
VUtils.isTrue(Objects.isNull(projectApplication)).throwMessage("应用不存在 " + applicationId);
PerformanceAppraisalApplication paa = new PerformanceAppraisalApplication();
paa.setAppraisalId(id);
paa.setApplicationId(applicationId);
@@ -327,10 +390,14 @@ public class PerformanceAppraisalPlanManage {
//删除先
performanceAppraisalProjectService.remove(Wrappers.lambdaQuery(PerformanceAppraisalProject.class)
.eq(PerformanceAppraisalProject::getAppraisalId,editDTO.getId()));
Integer startSelfDays = editDTO.getStartSelfDays();
Integer completeSelfDays = editDTO.getCompleteSelfDays();
List<AppraisalProjectDTO> projects = editDTO.getProjects();
for(AppraisalProjectDTO appraisalProject : projects){
Project newProject = projectService.getNewProject(appraisalProject.getId());
VUtils.isTrue(Objects.isNull(newProject)).throwMessage("项目不存在 " + appraisalProject.getId());
// 获取项目终验完成的时间
LocalDateTime finishTime = getProjectFinishTime(newProject);
PerformanceAppraisalProject pap = new PerformanceAppraisalProject();
pap.setAppraisalId(editDTO.getId());
pap.setProjectId(appraisalProject.getId());
@@ -340,6 +407,11 @@ public class PerformanceAppraisalPlanManage {
pap.setCreateOn(LocalDateTime.now());
pap.setUpdateBy(user.getUsername());
pap.setUpdateOn(LocalDateTime.now());
LocalDateTime selfAppraisalStart = finishTime.plusDays(startSelfDays);
pap.setSelfAppraisalStart(selfAppraisalStart);
long days = startSelfDays + completeSelfDays;
LocalDateTime selfAppraisalEnd = finishTime.plusDays(days);
pap.setSelfAppraisalEnd(selfAppraisalEnd);
performanceAppraisalProjectService.save(pap);
}
}
@@ -379,12 +451,17 @@ public class PerformanceAppraisalPlanManage {
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)){
// 删除评价计划关联的项目
//绩效关联的项目
List<PerformanceAppraisalProject> paps = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class)
.eq(PerformanceAppraisalProject::getAppraisalId, id));
performanceAppraisalProjectService.removeBatchByIds(paps);
// 删除评价计划关联的应用
//绩效关联的应用
List<PerformanceAppraisalApplication> paas = performanceAppraisalApplicationService.list(Wrappers.lambdaQuery(PerformanceAppraisalApplication.class)
.eq(PerformanceAppraisalApplication::getAppraisalId, id));
performanceAppraisalApplicationService.removeBatchByIds(paas);
return "删除成功";
}
return "删除失败";
@@ -393,8 +470,8 @@ public class PerformanceAppraisalPlanManage {
public List<PerformanceAppraisalProjectGroupVO> groupList(Long appraisalId,String name) {
List<PerformanceAppraisalProjectGroup> groups = groupService.list(
Wrappers.lambdaQuery(PerformanceAppraisalProjectGroup.class)
.eq(PerformanceAppraisalProjectGroup::getAppraisalId, appraisalId)
.like(StringUtils.isNotBlank(name),PerformanceAppraisalProjectGroup::getName,name));
.eq(PerformanceAppraisalProjectGroup::getAppraisalId, appraisalId)
.like(StringUtils.isNotBlank(name),PerformanceAppraisalProjectGroup::getName,name));
if(CollUtil.isEmpty(groups)){
return Collections.emptyList();
}
@@ -538,11 +615,6 @@ public class PerformanceAppraisalPlanManage {
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 "删除成功";
}
@@ -573,7 +645,102 @@ public class PerformanceAppraisalPlanManage {
return Collections.emptyList();
}
return Arrays.stream(users.split(StrPool.COMMA)).map(
employeeCode -> userMap.get(employeeCode)
employeeCode -> userMap.get(employeeCode)
).collect(Collectors.toList());
}

public PageVo<PerformanceAppraisalApplicationVO> applicationList(PerformanceAppraisalListReq req) {
Page<ProjectApplication> page = req.page();
// 获取登录用户所在区域已验收项目
UserInfoDetails user = LoginUserUtil.loginUserDetail();
String regionCode = user.getRegionCode();
List<Project> projects = projectService.list(Wrappers.lambdaQuery(Project.class)
.eq(Project::getAreaCode,regionCode)
.eq(Project::getStatus, ProjectStatusEnum.ACCEPTED.getCode())
.eq(Project::getNewest, Boolean.TRUE));
// 获取已验收项目关联的应用信息
List<Integer> projectVersions = projects.stream().map(Project::getVersion).collect(Collectors.toList());
List<String> projectCodes = projects.stream().map(Project::getProjectCode).collect(Collectors.toList());
LambdaQueryWrapper<ProjectApplication> wrapper = Wrappers.lambdaQuery(ProjectApplication.class)
.like(StringUtils.isNotBlank(req.getApplicationName()),ProjectApplication::getApplicationName,req.getApplicationName())
.like(StringUtils.isNotBlank(req.getBuildOrgName()),ProjectApplication::getBuildOrgName,req.getBuildOrgName())
.in(ProjectApplication::getProjectCode,projectCodes)
.in(ProjectApplication::getProjectVersion,projectVersions)
.orderByDesc(ProjectApplication::getCreateOn);
applicationService.page(page,wrapper);
if(0L == page.getTotal()){
return PageVo.empty();
}
List<PerformanceAppraisalApplicationVO> res = page.getRecords().stream().map(r -> {
PerformanceAppraisalApplicationVO vo = new PerformanceAppraisalApplicationVO();
vo.setAppId(r.getId());
vo.setApplicationName(Objects.nonNull(r.getApplicationName()) ? r.getApplicationName() : r.getRelatedExistsApplication());
vo.setBuildOrgName(r.getBuildOrgName());
vo.setApplicationType(r.getApplicationType());
vo.setBizDomain(r.getBizDomain());
vo.setPublishSide(r.getPublishSide());
return vo;
}).collect(Collectors.toList());
return PageVo.of(res,page.getTotal());
}

public String addProject(PerformanceAppraisalCreateDTO addDTO) {
List<AppraisalProjectDTO> projects = addDTO.getProjects();
if (CollUtil.isEmpty(projects)){
throw new BizException("请选择至少一个评价项目!");
}
List<Long> projectIdList = projects.stream().map(AppraisalProjectDTO::getId).collect(Collectors.toList());
// 获取已经创建的评价计划中添加的评价项目ID
List<Long> projectIds = performanceAppraisalProjectService.list().stream()
.map(PerformanceAppraisalProject::getProjectId).collect(Collectors.toList());
// 如果有交集,说明选择的项目中,有已经在其他评价计划中的项目
if (Boolean.TRUE.equals(haveIntersection(projectIdList, projectIds))){
// 得到交集
List<Long> intersection = Lists.newArrayList(projectIdList);
intersection.retainAll(projectIds);
// 获取重复添加的项目名称
String names = intersection.stream().map(i -> {
Project project = projectService.getById(i);
if (Objects.nonNull(project)) {
return project.getProjectName();
}
return StrPool.EMPTY;
}).collect(Collectors.joining(StrPool.COMMA));
throw new BizException(names + CommonConst.PROJECT_REPEAT);
}
return "添加成功";
}


public String addApplication(PerformanceAppraisalCreateDTO addDTO) {
List<Long> applicationIdList = addDTO.getApplicationIds();
if (CollUtil.isEmpty(applicationIdList)){
throw new BizException("请选择至少一个评应用!");
}
// 获取已经创建的评价计划中添加的评价应用ID
List<Long> applicationIds = performanceAppraisalApplicationService.list().stream()
.map(PerformanceAppraisalApplication::getApplicationId).collect(Collectors.toList());
// 如果有交集,说明选择的应用中,有已经在其他评价计划中的应用
if (Boolean.TRUE.equals(haveIntersection(applicationIdList, applicationIds))){
// 得到交集
List<Long> intersection = Lists.newArrayList(applicationIdList);
intersection.retainAll(applicationIds);
// 获取重复添加的应用名称
String names = intersection.stream().map(i -> {
ProjectApplication application = applicationService.getById(i);
if (Objects.nonNull(application)) {
return Objects.nonNull(application.getApplicationName()) ? application.getApplicationName()
: application.getRelatedExistsApplication();
}
return StrPool.EMPTY;
}).collect(Collectors.joining(StrPool.COMMA));
throw new BizException(names + CommonConst.APP_REPEAT);
}
return "添加成功";
}

private Boolean haveIntersection(List<Long> idList, List<Long> ids) {
return !CollectionUtil.intersection(idList, ids).isEmpty();
}

}

+ 13
- 27
pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/PerformanceAppraisalCreateDTO.java View File

@@ -6,9 +6,11 @@ import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalProjectVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
@@ -27,37 +29,21 @@ public class PerformanceAppraisalCreateDTO implements Serializable {

@ApiModelProperty("计划名称")
@NotBlank(message = "请输入计划名称")
@Size(max = 50)
private String name;

@ApiModelProperty("自评开始时间")
@NotNull(message = "自评时间错误")
@JSONField(format = "yyyy-MM-dd")
private LocalDateTime selfAppraisalStart;
@ApiModelProperty("终验后 xx 天开始自评")
@NotNull(message = "开始自评时间不能为空")
@Range(min = 0, max = 100, message = "数值范围不正确,数值应为1~100")
private Integer startSelfDays;

@ApiModelProperty("自评结束时间")
@NotNull(message = "自评时间错误")
@JSONField(format = "yyyy-MM-dd")
private LocalDateTime selfAppraisalEnd;
@ApiModelProperty("xx 天需完成自评")
@NotNull(message = "完成自评时间不能为空")
@Range(min = 0, max = 100, message = "数值范围不正确,数值应为1~100")
private Integer completeSelfDays;

@ApiModelProperty("复评开始时间")
@NotNull(message = "复评时间错误")
@JSONField(format = "yyyy-MM-dd")
private LocalDateTime reAppraisalStart;

@ApiModelProperty("复评结束时间")
@NotNull(message = "复评时间错误")
@JSONField(format = "yyyy-MM-dd")
private LocalDateTime reAppraisalEnd;

@ApiModelProperty("核查开始时间")
@NotNull(message = "核查时间错误")
@JSONField(format = "yyyy-MM-dd")
private LocalDateTime verificationStart;

@ApiModelProperty("核查结束时间")
@NotNull(message = "核查时间错误")
@JSONField(format = "yyyy-MM-dd")
private LocalDateTime verificationEnd;
@ApiModelProperty("备注")
private String remark;

@ApiModelProperty("评价目标 1项目 2应用 可多选 1,2")
@NotBlank(message = "评价目标不能为空")


+ 11
- 22
pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/PerformanceAppraisalEditDTO.java View File

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.annotation.JSONField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
@@ -28,32 +29,20 @@ public class PerformanceAppraisalEditDTO implements Serializable {
private Long id;

@ApiModelProperty("计划名称")
@JSONField(format = "yyyy-MM-dd")
private String name;

@ApiModelProperty("自评开始时间")
@JSONField(format = "yyyy-MM-dd")
private LocalDateTime selfAppraisalStart;
@ApiModelProperty("终验后 xx 天开始自评")
@NotNull(message = "开始自评时间不能为空")
@Range(min = 0, max = 100, message = "数值范围不正确,数值应为1~100")
private Integer startSelfDays;

@ApiModelProperty("自评结束时间")
@JSONField(format = "yyyy-MM-dd")
private LocalDateTime selfAppraisalEnd;
@ApiModelProperty("xx 天需完成自评")
@NotNull(message = "完成自评时间不能为空")
@Range(min = 0, max = 100, message = "数值范围不正确,数值应为1~100")
private Integer completeSelfDays;

@ApiModelProperty("复评开始时间")
@JSONField(format = "yyyy-MM-dd")
private LocalDateTime reAppraisalStart;

@ApiModelProperty("复评结束时间")
@JSONField(format = "yyyy-MM-dd")
private LocalDateTime reAppraisalEnd;

@ApiModelProperty("核查开始时间")
@JSONField(format = "yyyy-MM-dd")
private LocalDateTime verificationStart;

@ApiModelProperty("核查结束时间")
@JSONField(format = "yyyy-MM-dd")
private LocalDateTime verificationEnd;
@ApiModelProperty("备注")
private String remark;

@ApiModelProperty("评价目标 1项目 2应用 可多选 1,2")
private String target;


+ 10
- 16
pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisal.java View File

@@ -35,24 +35,18 @@ public class PerformanceAppraisal implements Serializable {
@ApiModelProperty("计划名称")
private String name;

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

@ApiModelProperty("自评结束时间")
private LocalDateTime selfAppraisalEnd;

@ApiModelProperty("复评开始时间")
private LocalDateTime reAppraisalStart;
@ApiModelProperty("评价目标 1项目 2应用 可多选 1,2")
private String target;

@ApiModelProperty("复评结束时间")
private LocalDateTime reAppraisalEnd;
@ApiModelProperty("终验后 xx 天开始自评")
private Integer startSelfDays;

@ApiModelProperty("核查开始时间")
private LocalDateTime verificationStart;
@ApiModelProperty("xx 天需完成自评")
private Integer completeSelfDays;

@ApiModelProperty("核查结束时间")
private LocalDateTime verificationEnd;
@ApiModelProperty("区域编码")
private String regionCode;

@ApiModelProperty("评价目标 1项目 2应用 可多选 1,2")
private String target;
@ApiModelProperty("备注")
private String remark;
}

+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalApplication.java View File

@@ -35,6 +35,6 @@ public class PerformanceAppraisalApplication implements Serializable {
@ApiModelProperty("计划id")
private Long appraisalId;

@ApiModelProperty("应用id")
@ApiModelProperty("应用ID")
private Long applicationId;
}

+ 6
- 0
pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalProject.java View File

@@ -43,4 +43,10 @@ public class PerformanceAppraisalProject implements Serializable {

@ApiModelProperty("是否核查")
private Boolean isReAppraisal;

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

@ApiModelProperty("自评结束时间")
private LocalDateTime selfAppraisalEnd;
}

+ 6
- 0
pmapi/src/main/java/com/ningdatech/pmapi/performance/model/req/PerformanceAppraisalListReq.java View File

@@ -39,4 +39,10 @@ public class PerformanceAppraisalListReq extends PagePo {

@ApiModelProperty("指标级别 1一级指标 2二级指标 3三级指标")
private Integer indexLevel;

@ApiModelProperty("应用名称")
private String applicationName;

@ApiModelProperty("申报单位")
private String buildOrgName;
}

+ 2
- 2
pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceAppraisalApplicationVO.java View File

@@ -18,8 +18,8 @@ public class PerformanceAppraisalApplicationVO implements Serializable {

private static final long serialVersionUID = 1L;

@ApiModelProperty("项目ID")
private Long id;
@ApiModelProperty("应用ID")
private Long appId;

@ApiModelProperty("应用名称")
private String applicationName;


+ 12
- 12
pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceAppraisalVO.java View File

@@ -37,18 +37,6 @@ public class PerformanceAppraisalVO implements Serializable {
@ApiModelProperty("自评结束时间")
private LocalDateTime selfAppraisalEnd;

@ApiModelProperty("复评开始时间")
private LocalDateTime reAppraisalStart;

@ApiModelProperty("复评结束时间")
private LocalDateTime reAppraisalEnd;

@ApiModelProperty("核查开始时间")
private LocalDateTime verificationStart;

@ApiModelProperty("核查结束时间")
private LocalDateTime verificationEnd;

@ApiModelProperty("评价目标 1项目 2应用 可多选 1,2")
private String target;

@@ -57,4 +45,16 @@ public class PerformanceAppraisalVO implements Serializable {

@ApiModelProperty("评价应用列表")
private List<PerformanceAppraisalApplicationVO> applications;

@ApiModelProperty("项目分组信息")
private List<PerformanceAppraisalProjectGroupVO> groups;

@ApiModelProperty("终验后 xx 天开始自评")
private Integer startSelfDays;

@ApiModelProperty("xx 天需完成自评")
private Integer completeSelfDays;

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

Loading…
Cancel
Save