From eec31dde8cdb654a9ef7ac9be5068ec5c9543187 Mon Sep 17 00:00:00 2001 From: CMM <2198256324@qq.com> Date: Mon, 14 Aug 2023 15:54:19 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=BB=A9=E6=95=88=E8=AF=84=E4=BB=B7-?= =?UTF-8?q?=E8=AF=84=E4=BB=B7=E6=A8=A1=E6=9D=BF=E8=AF=A6=E6=83=85=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ningdatech/pmapi/performance/manage/OrgSelfAppraisalManage.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 index b0bcb24..aa8de44 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/OrgSelfAppraisalManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/OrgSelfAppraisalManage.java @@ -277,7 +277,8 @@ public class OrgSelfAppraisalManage { // 装配项目指标详情及分数信息 // 获取模版绩效指标详情 List templateDetails = indicatorProjectTemplateDetailService.list(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class) - .eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId, projectTemplate.getId())); + .eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId, projectTemplate.getId()) + .eq(PerformanceIndicatorProjectTemplateDetail::getIsAdditional,Boolean.FALSE)); // 获取模版附加绩效指标详情 List additionalTemplateDetails = indicatorProjectTemplateDetailService.list(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class) .eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId, projectTemplate.getId()) From f40796fc27bddbffac1014e430b5207c3de7edbb Mon Sep 17 00:00:00 2001 From: CMM <2198256324@qq.com> Date: Mon, 14 Aug 2023 16:34:33 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=BB=A9=E6=95=88=E8=AF=84=E4=BB=B7-?= =?UTF-8?q?=E8=AF=84=E4=BB=B7=E6=8C=87=E6=A0=87=E6=A8=A1=E6=9D=BF=E5=A4=8D?= =?UTF-8?q?=E5=88=B6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../performance/manage/IndicatorConfigManage.java | 80 ++++++++++++++++++---- 1 file changed, 67 insertions(+), 13 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/IndicatorConfigManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/IndicatorConfigManage.java index 9dbbe38..81cb2d3 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/IndicatorConfigManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/IndicatorConfigManage.java @@ -46,6 +46,7 @@ import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.Arrays; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.stream.Collectors; @@ -375,20 +376,73 @@ public class IndicatorConfigManage { // 新增指标详情 List projectTemplateDetails = indicatorProjectTemplateDetailService.list(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class) .eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId, templateId)); - // 逐个新增并保存各指标 - for (PerformanceIndicatorProjectTemplateDetail projectTemplateDetail : projectTemplateDetails) { - PerformanceIndicatorProjectTemplateDetail newProjectTemplateDetail = new PerformanceIndicatorProjectTemplateDetail(); - BeanUtils.copyProperties(projectTemplateDetail, newProjectTemplateDetail); - newProjectTemplateDetail.setTemplateId(newTemplate.getId()); - newProjectTemplateDetail.setCreateOn(LocalDateTime.now()); - newProjectTemplateDetail.setCreateBy(user.getUsername()); - newProjectTemplateDetail.setUpdateOn(LocalDateTime.now()); - newProjectTemplateDetail.setUpdateBy(user.getUsername()); - // 新的指标ID要置空 - newProjectTemplateDetail.setId(null); - indicatorProjectTemplateDetailService.save(newProjectTemplateDetail); + Map detailMap = projectTemplateDetails.stream().collect(Collectors.toMap(PerformanceIndicatorProjectTemplateDetail::getId, p -> p)); + // 按层级逐个新增并保存各指标 + // 从三级指标开始 + List thirdList = projectTemplateDetails.stream() + .filter(p -> PerformanceTemplateTypeEnum.THIRD_INDEX.getCode().equals(p.getType())) + .collect(Collectors.toList()); + if (CollUtil.isEmpty(thirdList)){ + throw new BizException("当前模板未配置三级指!"); + } + List templateDetails = Lists.newArrayList(); + for (PerformanceIndicatorProjectTemplateDetail templateDetail : thirdList) { + PerformanceIndicatorProjectTemplateDetail newThirdTemplateDetail = new PerformanceIndicatorProjectTemplateDetail(); + BeanUtils.copyProperties(templateDetail, newThirdTemplateDetail); + newThirdTemplateDetail.setTemplateId(newTemplate.getId()); + newThirdTemplateDetail.setCreateOn(LocalDateTime.now()); + newThirdTemplateDetail.setCreateBy(user.getUsername()); + newThirdTemplateDetail.setUpdateOn(LocalDateTime.now()); + newThirdTemplateDetail.setUpdateBy(user.getUsername()); + // 新的指标ID、parentId要置空 + newThirdTemplateDetail.setId(null); + newThirdTemplateDetail.setParentId(null); + indicatorProjectTemplateDetailService.save(newThirdTemplateDetail); + // 再保存关联的二级指标 + Long thirdParentId = templateDetail.getParentId(); + PerformanceIndicatorProjectTemplateDetail secondTemplateDetail = detailMap.get(thirdParentId); + if (Objects.isNull(secondTemplateDetail)){ + throw new BizException("三级指标:" + templateDetail.getName() + "对应的二级指标不存在"); + } + PerformanceIndicatorProjectTemplateDetail newSecondTemplateDetail = new PerformanceIndicatorProjectTemplateDetail(); + BeanUtils.copyProperties(secondTemplateDetail, newSecondTemplateDetail); + newSecondTemplateDetail.setTemplateId(newTemplate.getId()); + newSecondTemplateDetail.setCreateOn(LocalDateTime.now()); + newSecondTemplateDetail.setCreateBy(user.getUsername()); + newSecondTemplateDetail.setUpdateOn(LocalDateTime.now()); + newSecondTemplateDetail.setUpdateBy(user.getUsername()); + // 新的指标Id、parentId要置空 + newSecondTemplateDetail.setId(null); + newSecondTemplateDetail.setParentId(null); + indicatorProjectTemplateDetailService.save(newSecondTemplateDetail); + // 关联三级指标 + newThirdTemplateDetail.setParentId(newSecondTemplateDetail.getId()); + templateDetails.add(newThirdTemplateDetail); + // 再保存关联的一级指标 + Long secondParentId = secondTemplateDetail.getParentId(); + PerformanceIndicatorProjectTemplateDetail firstTemplateDetail = detailMap.get(secondParentId); + if (Objects.isNull(firstTemplateDetail)){ + throw new BizException("二级指标:" + secondTemplateDetail.getName() + "对应的一级指标不存在"); + } + PerformanceIndicatorProjectTemplateDetail newFirstTemplateDetail = new PerformanceIndicatorProjectTemplateDetail(); + BeanUtils.copyProperties(firstTemplateDetail, newFirstTemplateDetail); + newFirstTemplateDetail.setTemplateId(newTemplate.getId()); + newFirstTemplateDetail.setCreateOn(LocalDateTime.now()); + newFirstTemplateDetail.setCreateBy(user.getUsername()); + newFirstTemplateDetail.setUpdateOn(LocalDateTime.now()); + newFirstTemplateDetail.setUpdateBy(user.getUsername()); + // 新的指标ID、parentId要置空 + newFirstTemplateDetail.setId(null); + newFirstTemplateDetail.setParentId(null); + indicatorProjectTemplateDetailService.save(newFirstTemplateDetail); + // 关联二级指标 + newSecondTemplateDetail.setParentId(newFirstTemplateDetail.getId()); + templateDetails.add(newSecondTemplateDetail); + } + // 批量更新 + if (indicatorProjectTemplateDetailService.updateBatchById(templateDetails)) { + return "模版复制成功"; } - return "模版复制成功"; } return "模版复制失败"; }