Browse Source

绩效模板

tags/24080901
PoffyZhang 1 year ago
parent
commit
c8ba0f1055
10 changed files with 162 additions and 19 deletions
  1. +7
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/PerformanceIndicatorTemplateController.java
  2. +44
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/performance/enumration/PerformanceTemplateStageNameEnum.java
  3. +81
    -14
      pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/IndicatorTemplateManage.java
  4. +3
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/PerformanceAppraisalProjectGroupSaveDTO.java
  5. +3
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/PerformanceIndicatorProjectTemplateSaveDTO.java
  6. +6
    -5
      pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/ProjectTemplateDetailDTO.java
  7. +3
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceIndicatorProjectTemplate.java
  8. +6
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceIndicatorProjectTemplateDetail.java
  9. +3
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceIndicatorProjectTemplateVO.java
  10. +6
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/ProjectTemplateDetailVO.java

+ 7
- 0
pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/PerformanceIndicatorTemplateController.java View File

@@ -45,4 +45,11 @@ public class PerformanceIndicatorTemplateController {
public String projectTemplateSave(@Valid @RequestBody PerformanceIndicatorProjectTemplateSaveDTO dto) { public String projectTemplateSave(@Valid @RequestBody PerformanceIndicatorProjectTemplateSaveDTO dto) {
return indicatorTemplateManage.projectTemplateSave(dto); return indicatorTemplateManage.projectTemplateSave(dto);
} }

@PostMapping("/project/delete/{id}")
@ApiOperation("项目指标配置模板删除")
@WebLog("项目指标配置模板删除")
public String projectTemplateDelete(@PathVariable Long id) {
return indicatorTemplateManage.projectTemplateDelete(id);
}
} }

+ 44
- 0
pmapi/src/main/java/com/ningdatech/pmapi/performance/enumration/PerformanceTemplateStageNameEnum.java View File

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

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
* <p>
* PerformanceTemplateStageNameEnum
* </p>
*
* @author Poffy
* @since 16:56 2023/6/27
*/
@Getter
@AllArgsConstructor
@NoArgsConstructor
public enum PerformanceTemplateStageNameEnum {
/**
* 模板阶段名称枚举
*/
STAGE_1(1, "立项阶段"),
STAGE_2(2, "建设阶段"),
STAGE_3(3, "运行阶段"),
STAGE_4(4, "附加阶段");

private Integer code;
private String desc;

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

+ 81
- 14
pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/IndicatorTemplateManage.java View File

@@ -9,6 +9,8 @@ import com.google.common.collect.Lists;
import com.ningdatech.basic.exception.BizException; import com.ningdatech.basic.exception.BizException;
import com.ningdatech.basic.function.VUtils; import com.ningdatech.basic.function.VUtils;
import com.ningdatech.basic.model.PageVo; import com.ningdatech.basic.model.PageVo;
import com.ningdatech.pmapi.common.enumeration.CommonEnum;
import com.ningdatech.pmapi.performance.enumration.PerformanceTemplateStageNameEnum;
import com.ningdatech.pmapi.performance.enumration.PerformanceTemplateTypeEnum; import com.ningdatech.pmapi.performance.enumration.PerformanceTemplateTypeEnum;
import com.ningdatech.pmapi.performance.model.dto.PerformanceIndicatorProjectTemplateSaveDTO; import com.ningdatech.pmapi.performance.model.dto.PerformanceIndicatorProjectTemplateSaveDTO;
import com.ningdatech.pmapi.performance.model.dto.ProjectTemplateDetailDTO; import com.ningdatech.pmapi.performance.model.dto.ProjectTemplateDetailDTO;
@@ -25,9 +27,9 @@ import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;


import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -42,7 +44,7 @@ import java.util.stream.Collectors;
@Component @Component
@AllArgsConstructor @AllArgsConstructor
public class IndicatorTemplateManage { public class IndicatorTemplateManage {
private final IPerformanceIndicatorProjectTemplateService indicatorTemplateService;
private final IPerformanceIndicatorProjectTemplateService indicatorProjectTemplateService;


private final IPerformanceIndicatorProjectTemplateDetailService indicatorProjectTemplateDetailService; private final IPerformanceIndicatorProjectTemplateDetailService indicatorProjectTemplateDetailService;


@@ -56,7 +58,7 @@ public class IndicatorTemplateManage {
LambdaQueryWrapper<PerformanceIndicatorProjectTemplate> wrapper = Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplate.class) LambdaQueryWrapper<PerformanceIndicatorProjectTemplate> wrapper = Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplate.class)
.like(StringUtils.isNotBlank(req.getTemplateName()), PerformanceIndicatorProjectTemplate::getName, req.getTemplateName()) .like(StringUtils.isNotBlank(req.getTemplateName()), PerformanceIndicatorProjectTemplate::getName, req.getTemplateName())
.eq(StringUtils.isNotBlank(req.getRegionCode()), PerformanceIndicatorProjectTemplate::getRegionCode,req.getRegionCode()); .eq(StringUtils.isNotBlank(req.getRegionCode()), PerformanceIndicatorProjectTemplate::getRegionCode,req.getRegionCode());
indicatorTemplateService.page(page,wrapper);
indicatorProjectTemplateService.page(page,wrapper);


if(0L == page.getTotal()){ if(0L == page.getTotal()){
return PageVo.empty(); return PageVo.empty();
@@ -75,7 +77,7 @@ public class IndicatorTemplateManage {
* @return * @return
*/ */
public PerformanceIndicatorProjectTemplateVO projectDetail(Long id) { public PerformanceIndicatorProjectTemplateVO projectDetail(Long id) {
PerformanceIndicatorProjectTemplate template = indicatorTemplateService.getById(id);
PerformanceIndicatorProjectTemplate template = indicatorProjectTemplateService.getById(id);
if(Objects.isNull(template)){ if(Objects.isNull(template)){
return null; return null;
} }
@@ -94,11 +96,12 @@ public class IndicatorTemplateManage {
* @param dto * @param dto
* @return * @return
*/ */
@Transactional
public String projectTemplateSave(PerformanceIndicatorProjectTemplateSaveDTO dto) { public String projectTemplateSave(PerformanceIndicatorProjectTemplateSaveDTO dto) {
UserInfoDetails user = LoginUserUtil.loginUserDetail(); UserInfoDetails user = LoginUserUtil.loginUserDetail();
PerformanceIndicatorProjectTemplate template = BeanUtil.copyProperties(dto, PerformanceIndicatorProjectTemplate.class); PerformanceIndicatorProjectTemplate template = BeanUtil.copyProperties(dto, PerformanceIndicatorProjectTemplate.class);
if(Objects.nonNull(dto.getId())){ if(Objects.nonNull(dto.getId())){
PerformanceIndicatorProjectTemplate old = indicatorTemplateService.getById(dto.getId());
PerformanceIndicatorProjectTemplate old = indicatorProjectTemplateService.getById(dto.getId());
VUtils.isTrue(Objects.isNull(old)).throwMessage("该模板不存在!"); VUtils.isTrue(Objects.isNull(old)).throwMessage("该模板不存在!");
template.setId(old.getId()); template.setId(old.getId());
}else{ }else{
@@ -108,13 +111,24 @@ public class IndicatorTemplateManage {
} }
template.setUpdateOn(LocalDateTime.now()); template.setUpdateOn(LocalDateTime.now());
template.setUpdateBy(user.getUsername()); template.setUpdateBy(user.getUsername());
if(indicatorTemplateService.saveOrUpdate(template)){
if(indicatorProjectTemplateService.saveOrUpdate(template)){
//保存 模板的详情 //保存 模板的详情
if(CollUtil.isNotEmpty(dto.getTemplateDetails())){ if(CollUtil.isNotEmpty(dto.getTemplateDetails())){
//先删除 //先删除
indicatorProjectTemplateDetailService.remove(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class) indicatorProjectTemplateDetailService.remove(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class)
.eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId,dto.getId())); .eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId,dto.getId()));
analysisTemplateDetails(dto.getTemplateDetails(),template.getId()); analysisTemplateDetails(dto.getTemplateDetails(),template.getId());

//校检 3个阶段 总分是不是100
List<PerformanceIndicatorProjectTemplateDetail> stages = indicatorProjectTemplateDetailService.list(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class)
.eq(PerformanceIndicatorProjectTemplateDetail::getType, PerformanceTemplateTypeEnum.STAGE.getCode())
.eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId, template.getId())
.in(PerformanceIndicatorProjectTemplateDetail::getName, Lists.newArrayList(PerformanceTemplateStageNameEnum.STAGE_1.getDesc(),
PerformanceTemplateStageNameEnum.STAGE_2.getDesc(), PerformanceTemplateStageNameEnum.STAGE_3.getDesc())));
if(CollUtil.isNotEmpty(stages)){
int sum = stages.stream().filter(p -> Objects.nonNull(p.getScore())).mapToInt(PerformanceIndicatorProjectTemplateDetail::getScore).sum();
VUtils.isTrue(sum != 100).throwMessage("总分不是100 操作失败!");
}
} }
return "保存成功"; return "保存成功";
} }
@@ -126,23 +140,22 @@ public class IndicatorTemplateManage {
* @param templateDetails * @param templateDetails
* @return * @return
*/ */
private void analysisTemplateDetails(
public void analysisTemplateDetails(
List<ProjectTemplateDetailDTO> templateDetails,Long templateId) { List<ProjectTemplateDetailDTO> templateDetails,Long templateId) {
List<PerformanceIndicatorProjectTemplateDetail> details = Lists.newArrayList();
if(CollUtil.isEmpty(templateDetails)){ if(CollUtil.isEmpty(templateDetails)){
return; return;
} }

analysisTemplateDetailsInner(templateDetails,templateId,null);
analysisTemplateDetailsInner(templateDetails,templateId,null,null);
} }


private void analysisTemplateDetailsInner(List<ProjectTemplateDetailDTO> templateDetails,
Long templateId,Long parentId) {
public void analysisTemplateDetailsInner(List<ProjectTemplateDetailDTO> templateDetails,
Long templateId,Long parentId,Long stageId) {
if(CollUtil.isEmpty(templateDetails)){ if(CollUtil.isEmpty(templateDetails)){
return; return;
} }
UserInfoDetails user = LoginUserUtil.loginUserDetail(); UserInfoDetails user = LoginUserUtil.loginUserDetail();
for(ProjectTemplateDetailDTO detail : templateDetails){ for(ProjectTemplateDetailDTO detail : templateDetails){
//计算阶段的
PerformanceIndicatorProjectTemplateDetail templateDetail = BeanUtil.copyProperties(detail, PerformanceIndicatorProjectTemplateDetail.class); PerformanceIndicatorProjectTemplateDetail templateDetail = BeanUtil.copyProperties(detail, PerformanceIndicatorProjectTemplateDetail.class);
templateDetail.setCreateBy(user.getUsername()); templateDetail.setCreateBy(user.getUsername());
templateDetail.setCreateOn(LocalDateTime.now()); templateDetail.setCreateOn(LocalDateTime.now());
@@ -150,12 +163,46 @@ public class IndicatorTemplateManage {
templateDetail.setUpdateOn(LocalDateTime.now()); templateDetail.setUpdateOn(LocalDateTime.now());
templateDetail.setTemplateId(templateId); templateDetail.setTemplateId(templateId);
templateDetail.setParentId(parentId); templateDetail.setParentId(parentId);
//如果是阶段的计算下 总分
if(!PerformanceTemplateTypeEnum.STAGE.getCode().equals(templateDetail.getType())){
templateDetail.setStageId(stageId);
}
indicatorProjectTemplateDetailService.save(templateDetail); indicatorProjectTemplateDetailService.save(templateDetail);
//如果是阶段的话 阶段Id 就是自己的id
if(PerformanceTemplateTypeEnum.STAGE.getCode().equals(templateDetail.getType())){
templateDetail.setScore(computeTotalScore(templateDetail));
templateDetail.setStageId(templateDetail.getId());
indicatorProjectTemplateDetailService.updateById(templateDetail);
stageId = templateDetail.getId();
}


if(CollUtil.isNotEmpty(detail.getChildren())){ if(CollUtil.isNotEmpty(detail.getChildren())){
analysisTemplateDetailsInner(detail.getChildren(),templateId,templateDetail.getId());
analysisTemplateDetailsInner(detail.getChildren(),templateId,templateDetail.getId(),stageId);
}
}
}

/**
* 计算 此阶段下的 总分
* @param templateDetail
* @return
*/
private Integer computeTotalScore(PerformanceIndicatorProjectTemplateDetail templateDetail) {
Integer total = 0;
if(Objects.isNull(templateDetail) || Objects.isNull(templateDetail.getId())){
return total;
}

if(PerformanceTemplateTypeEnum.STAGE.getCode().equals(templateDetail.getType())){
List<PerformanceIndicatorProjectTemplateDetail> thirds = indicatorProjectTemplateDetailService.list(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class)
.eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId, templateDetail.getTemplateId())
.eq(PerformanceIndicatorProjectTemplateDetail::getStageId, templateDetail.getId())
.eq(PerformanceIndicatorProjectTemplateDetail::getType,PerformanceTemplateTypeEnum.THIRD_INDEX.getCode()));
if(CollUtil.isNotEmpty(thirds)){
total = thirds.stream().mapToInt(PerformanceIndicatorProjectTemplateDetail::getScore).sum();
} }
} }
return total;
} }


/** /**
@@ -199,7 +246,27 @@ public class IndicatorTemplateManage {
res.add(detailVo); res.add(detailVo);
} }
} }

return res; return res;
} }

/**
* 删除项目模板
* @param id
* @return
*/
public String projectTemplateDelete(Long id) {
PerformanceIndicatorProjectTemplate projectTemplate = indicatorProjectTemplateService.getById(id);
VUtils.isTrue(Objects.isNull(projectTemplate)).throwMessage("该模板不存在!");

if(CommonEnum.YES.getCode().equals(projectTemplate.getStatus())){
throw new BizException("操作失败 该模板 是启用状态!");
}

if(indicatorProjectTemplateService.removeById(id)){
indicatorProjectTemplateDetailService.remove(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class)
.eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId,id));
return "删除成功";
}
return "操作失败";
}
} }

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

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


@ApiModelProperty("状态 0关闭 1开启")
private Integer status = 0;

@ApiModelProperty("分组内的所有项目code") @ApiModelProperty("分组内的所有项目code")
private List<String> projectCodes; private List<String> projectCodes;




+ 3
- 0
pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/PerformanceIndicatorProjectTemplateSaveDTO.java View File

@@ -37,6 +37,9 @@ public class PerformanceIndicatorProjectTemplateSaveDTO implements Serializable
@ApiModelProperty("项目资金范围 1.500万元以下、2.500-2000万元,3.2000万元及以上") @ApiModelProperty("项目资金范围 1.500万元以下、2.500-2000万元,3.2000万元及以上")
private Integer amountRange; private Integer amountRange;


@ApiModelProperty("状态 0 1")
private Integer status;

@ApiModelProperty("绩效指标详情") @ApiModelProperty("绩效指标详情")
private List<ProjectTemplateDetailDTO> templateDetails; private List<ProjectTemplateDetailDTO> templateDetails;
} }

+ 6
- 5
pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/ProjectTemplateDetailDTO.java View File

@@ -1,14 +1,9 @@
package com.ningdatech.pmapi.performance.model.dto; package com.ningdatech.pmapi.performance.model.dto;


import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;

import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List; import java.util.List;


/** /**
@@ -41,6 +36,12 @@ public class ProjectTemplateDetailDTO implements Serializable {
@ApiModelProperty("分数细则 3级指标才有") @ApiModelProperty("分数细则 3级指标才有")
private String scoreRubric; private String scoreRubric;


@ApiModelProperty("评分pdf")
private String pdf;

@ApiModelProperty("阶段id")
private Long stageId;

@ApiModelProperty("子指标") @ApiModelProperty("子指标")
private List<ProjectTemplateDetailDTO> children; private List<ProjectTemplateDetailDTO> children;
} }

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

@@ -44,6 +44,9 @@ public class PerformanceIndicatorProjectTemplate implements Serializable {
@ApiModelProperty("项目类型") @ApiModelProperty("项目类型")
private Integer projectType; private Integer projectType;


@ApiModelProperty("状态 0关闭 1开启")
private Integer status;

@ApiModelProperty("项目资金范围 1.500万元以下、2.500-2000万元,3.2000万元及以上") @ApiModelProperty("项目资金范围 1.500万元以下、2.500-2000万元,3.2000万元及以上")
private Integer amountRange; private Integer amountRange;
} }

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

@@ -50,4 +50,10 @@ public class PerformanceIndicatorProjectTemplateDetail implements Serializable {


@ApiModelProperty("分数细则 3级指标才有") @ApiModelProperty("分数细则 3级指标才有")
private String scoreRubric; private String scoreRubric;

@ApiModelProperty("评分pdf")
private String pdf;

@ApiModelProperty("阶段id")
private Long stageId;
} }

+ 3
- 0
pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceIndicatorProjectTemplateVO.java View File

@@ -43,6 +43,9 @@ public class PerformanceIndicatorProjectTemplateVO implements Serializable {
@ApiModelProperty("项目资金范围 1.500万元以下、2.500-2000万元,3.2000万元及以上") @ApiModelProperty("项目资金范围 1.500万元以下、2.500-2000万元,3.2000万元及以上")
private Integer amountRange; private Integer amountRange;


@ApiModelProperty("状态 0关闭 1开启")
private Integer status;

@ApiModelProperty("绩效指标详情") @ApiModelProperty("绩效指标详情")
private List<ProjectTemplateDetailVO> templateDetails; private List<ProjectTemplateDetailVO> templateDetails;
} }

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

@@ -37,6 +37,12 @@ public class ProjectTemplateDetailVO implements Serializable {
@ApiModelProperty("分数细则 3级指标才有") @ApiModelProperty("分数细则 3级指标才有")
private String scoreRubric; private String scoreRubric;


@ApiModelProperty("评分pdf")
private String pdf;

@ApiModelProperty("阶段id")
private Long stageId;

@ApiModelProperty("子指标") @ApiModelProperty("子指标")
private List<ProjectTemplateDetailVO> children; private List<ProjectTemplateDetailVO> children;
} }

Loading…
Cancel
Save