From c8ba0f1055c1e9c9a6346a17ff1f8cb4ac8c7b49 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Wed, 28 Jun 2023 15:11:45 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=A9=E6=95=88=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PerformanceIndicatorTemplateController.java | 7 ++ .../PerformanceTemplateStageNameEnum.java | 44 ++++++++++ .../manage/IndicatorTemplateManage.java | 95 ++++++++++++++++++---- .../PerformanceAppraisalProjectGroupSaveDTO.java | 3 + ...PerformanceIndicatorProjectTemplateSaveDTO.java | 3 + .../model/dto/ProjectTemplateDetailDTO.java | 11 +-- .../PerformanceIndicatorProjectTemplate.java | 3 + .../PerformanceIndicatorProjectTemplateDetail.java | 6 ++ .../vo/PerformanceIndicatorProjectTemplateVO.java | 3 + .../model/vo/ProjectTemplateDetailVO.java | 6 ++ 10 files changed, 162 insertions(+), 19 deletions(-) create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/performance/enumration/PerformanceTemplateStageNameEnum.java diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/PerformanceIndicatorTemplateController.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/PerformanceIndicatorTemplateController.java index d5951ed..7876d71 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/PerformanceIndicatorTemplateController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/PerformanceIndicatorTemplateController.java @@ -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); + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/enumration/PerformanceTemplateStageNameEnum.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/enumration/PerformanceTemplateStageNameEnum.java new file mode 100644 index 0000000..e5958f8 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/enumration/PerformanceTemplateStageNameEnum.java @@ -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; + +/** + *

+ * PerformanceTemplateStageNameEnum + *

+ * + * @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; + } +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/IndicatorTemplateManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/IndicatorTemplateManage.java index 8865874..6fa97a8 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/IndicatorTemplateManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/IndicatorTemplateManage.java @@ -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 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 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 templateDetails,Long templateId) { - List details = Lists.newArrayList(); if(CollUtil.isEmpty(templateDetails)){ return; } - - analysisTemplateDetailsInner(templateDetails,templateId,null); + analysisTemplateDetailsInner(templateDetails,templateId,null,null); } - private void analysisTemplateDetailsInner(List templateDetails, - Long templateId,Long parentId) { + public void analysisTemplateDetailsInner(List 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 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 "操作失败"; + } } 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 b5bc523..e78b1be 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 @@ -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 projectCodes; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/PerformanceIndicatorProjectTemplateSaveDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/PerformanceIndicatorProjectTemplateSaveDTO.java index 56503b4..72cf09d 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/PerformanceIndicatorProjectTemplateSaveDTO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/PerformanceIndicatorProjectTemplateSaveDTO.java @@ -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 templateDetails; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/ProjectTemplateDetailDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/ProjectTemplateDetailDTO.java index 2f0afab..412db14 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/ProjectTemplateDetailDTO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/ProjectTemplateDetailDTO.java @@ -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 children; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceIndicatorProjectTemplate.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceIndicatorProjectTemplate.java index 338195e..98c95d5 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceIndicatorProjectTemplate.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceIndicatorProjectTemplate.java @@ -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; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceIndicatorProjectTemplateDetail.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceIndicatorProjectTemplateDetail.java index 006ff62..6890d1e 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceIndicatorProjectTemplateDetail.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceIndicatorProjectTemplateDetail.java @@ -50,4 +50,10 @@ public class PerformanceIndicatorProjectTemplateDetail implements Serializable { @ApiModelProperty("分数细则 3级指标才有") private String scoreRubric; + + @ApiModelProperty("评分pdf") + private String pdf; + + @ApiModelProperty("阶段id") + private Long stageId; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceIndicatorProjectTemplateVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceIndicatorProjectTemplateVO.java index 81b7416..6ac7ff2 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceIndicatorProjectTemplateVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceIndicatorProjectTemplateVO.java @@ -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 templateDetails; } 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 7ee7ad6..bd32eb8 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 @@ -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 children; }