Quellcode durchsuchen

绩效模板

tags/24080901
PoffyZhang vor 1 Jahr
Ursprung
Commit
c8ba0f1055
10 geänderte Dateien mit 162 neuen und 19 gelöschten Zeilen
  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 Datei anzeigen

@@ -45,4 +45,11 @@ public class PerformanceIndicatorTemplateController {
public String projectTemplateSave(@Valid @RequestBody PerformanceIndicatorProjectTemplateSaveDTO 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 Datei anzeigen

@@ -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 Datei anzeigen

@@ -9,6 +9,8 @@ import com.google.common.collect.Lists;
import com.ningdatech.basic.exception.BizException;
import com.ningdatech.basic.function.VUtils;
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.model.dto.PerformanceIndicatorProjectTemplateSaveDTO;
import com.ningdatech.pmapi.performance.model.dto.ProjectTemplateDetailDTO;
@@ -25,9 +27,9 @@ import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

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

private final IPerformanceIndicatorProjectTemplateDetailService indicatorProjectTemplateDetailService;

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

if(0L == page.getTotal()){
return PageVo.empty();
@@ -75,7 +77,7 @@ public class IndicatorTemplateManage {
* @return
*/
public PerformanceIndicatorProjectTemplateVO projectDetail(Long id) {
PerformanceIndicatorProjectTemplate template = indicatorTemplateService.getById(id);
PerformanceIndicatorProjectTemplate template = indicatorProjectTemplateService.getById(id);
if(Objects.isNull(template)){
return null;
}
@@ -94,11 +96,12 @@ public class IndicatorTemplateManage {
* @param dto
* @return
*/
@Transactional
public String projectTemplateSave(PerformanceIndicatorProjectTemplateSaveDTO dto) {
UserInfoDetails user = LoginUserUtil.loginUserDetail();
PerformanceIndicatorProjectTemplate template = BeanUtil.copyProperties(dto, PerformanceIndicatorProjectTemplate.class);
if(Objects.nonNull(dto.getId())){
PerformanceIndicatorProjectTemplate old = indicatorTemplateService.getById(dto.getId());
PerformanceIndicatorProjectTemplate old = indicatorProjectTemplateService.getById(dto.getId());
VUtils.isTrue(Objects.isNull(old)).throwMessage("该模板不存在!");
template.setId(old.getId());
}else{
@@ -108,13 +111,24 @@ public class IndicatorTemplateManage {
}
template.setUpdateOn(LocalDateTime.now());
template.setUpdateBy(user.getUsername());
if(indicatorTemplateService.saveOrUpdate(template)){
if(indicatorProjectTemplateService.saveOrUpdate(template)){
//保存 模板的详情
if(CollUtil.isNotEmpty(dto.getTemplateDetails())){
//先删除
indicatorProjectTemplateDetailService.remove(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class)
.eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId,dto.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 "保存成功";
}
@@ -126,23 +140,22 @@ public class IndicatorTemplateManage {
* @param templateDetails
* @return
*/
private void analysisTemplateDetails(
public void analysisTemplateDetails(
List<ProjectTemplateDetailDTO> templateDetails,Long templateId) {
List<PerformanceIndicatorProjectTemplateDetail> details = Lists.newArrayList();
if(CollUtil.isEmpty(templateDetails)){
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)){
return;
}
UserInfoDetails user = LoginUserUtil.loginUserDetail();
for(ProjectTemplateDetailDTO detail : templateDetails){
//计算阶段的
PerformanceIndicatorProjectTemplateDetail templateDetail = BeanUtil.copyProperties(detail, PerformanceIndicatorProjectTemplateDetail.class);
templateDetail.setCreateBy(user.getUsername());
templateDetail.setCreateOn(LocalDateTime.now());
@@ -150,12 +163,46 @@ public class IndicatorTemplateManage {
templateDetail.setUpdateOn(LocalDateTime.now());
templateDetail.setTemplateId(templateId);
templateDetail.setParentId(parentId);
//如果是阶段的计算下 总分
if(!PerformanceTemplateTypeEnum.STAGE.getCode().equals(templateDetail.getType())){
templateDetail.setStageId(stageId);
}
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())){
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);
}
}

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 Datei anzeigen

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

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

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



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

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

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

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

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

@@ -1,14 +1,9 @@
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.ApiModelProperty;
import lombok.Data;

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

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

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

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

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

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

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

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

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

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

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

@ApiModelProperty("分数细则 3级指标才有")
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 Datei anzeigen

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

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

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

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

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

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

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

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

Laden…
Abbrechen
Speichern