From 7eb79a418ba66d4cf8bace1a80cad94bb5f4a5f8 Mon Sep 17 00:00:00 2001 From: CMM <2198256324@qq.com> Date: Thu, 17 Aug 2023 10:48:51 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=A9=E6=95=88=E8=AF=84=E4=BB=B7-=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E8=AF=84=E5=88=86=E8=A1=A8=E5=88=A0=E9=99=A4=E5=A4=9A?= =?UTF-8?q?=E4=BD=99=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/OrgSelfAppraisalController.java | 7 +- .../performance/manage/OrgSelfAppraisalManage.java | 116 +++++++++++++-------- .../model/dto/AppraisalScoreExportDTO.java | 11 ++ .../entity/PerformanceAppraisalScoreInfo.java | 3 - .../model/req/PerformanceAppraisalExportReq.java | 20 ++++ 5 files changed, 107 insertions(+), 50 deletions(-) create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/performance/model/req/PerformanceAppraisalExportReq.java diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/OrgSelfAppraisalController.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/OrgSelfAppraisalController.java index 36c1e3c..6e933b0 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/OrgSelfAppraisalController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/OrgSelfAppraisalController.java @@ -5,6 +5,7 @@ import com.ningdatech.log.annotation.WebLog; import com.ningdatech.pmapi.common.util.ExcelDownUtil; import com.ningdatech.pmapi.performance.manage.OrgSelfAppraisalManage; import com.ningdatech.pmapi.performance.model.dto.ProjectAppraisalDTO; +import com.ningdatech.pmapi.performance.model.req.PerformanceAppraisalExportReq; import com.ningdatech.pmapi.performance.model.req.PerformanceAppraisalListReq; import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalProjectVO; import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalVO; @@ -62,10 +63,10 @@ public class OrgSelfAppraisalController { return selfAppraisalManage.submitSelfAppraisal(param); } - @GetMapping("/score/export/{projectCode}") + @GetMapping("/score/export") @ApiOperation("自评打分导出") @WebLog(value = "自评打分导出",modular = "绩效评价-单位自评") - private void exportScore(@PathVariable String projectCode, HttpServletResponse response){ - ExcelDownUtil.downXls(response, projectCode, selfAppraisalManage::exportScore); + public void exportScore(@Valid @ModelAttribute PerformanceAppraisalExportReq param, HttpServletResponse response){ + ExcelDownUtil.downXls(response, param, selfAppraisalManage::exportScore); } } 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 9df9352..274303a 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 @@ -2,6 +2,7 @@ package com.ningdatech.pmapi.performance.manage; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; +import com.alibaba.excel.EasyExcel; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -11,6 +12,8 @@ import com.ningdatech.basic.function.VUtils; import com.ningdatech.basic.model.PageVo; import com.ningdatech.basic.util.StrPool; import com.ningdatech.pmapi.common.enumeration.CommonEnum; +import com.ningdatech.pmapi.common.util.ExcelDownUtil; +import com.ningdatech.pmapi.common.util.ExcelExportStyle; import com.ningdatech.pmapi.performance.constant.BizConst; import com.ningdatech.pmapi.performance.enumration.AppraisalTypeEnum; import com.ningdatech.pmapi.performance.enumration.PerformanceTemplateTypeEnum; @@ -19,6 +22,7 @@ import com.ningdatech.pmapi.performance.model.dto.AppraisalScoreExportDTO; import com.ningdatech.pmapi.performance.model.dto.ProjectAppraisalDTO; import com.ningdatech.pmapi.performance.model.dto.ProjectAppraisalInfoDTO; import com.ningdatech.pmapi.performance.model.entity.*; +import com.ningdatech.pmapi.performance.model.req.PerformanceAppraisalExportReq; import com.ningdatech.pmapi.performance.model.req.PerformanceAppraisalListReq; import com.ningdatech.pmapi.performance.model.vo.*; import com.ningdatech.pmapi.performance.service.*; @@ -41,6 +45,7 @@ import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import javax.servlet.http.HttpServletResponse; +import java.io.IOException; import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.*; @@ -273,12 +278,14 @@ public class OrgSelfAppraisalManage { .eq(PerformanceIndicatorProjectTemplate::getProjectYear, projectYear) .eq(PerformanceIndicatorProjectTemplate::getAmountRange, amountRange) .eq(PerformanceIndicatorProjectTemplate::getProjectTagIds,projectTagIds) + .eq(PerformanceIndicatorProjectTemplate::getStatus,CommonEnum.YES.getCode()) .orderByDesc(PerformanceIndicatorProjectTemplate::getUpdateOn); - PerformanceIndicatorProjectTemplate projectTemplate = indicatorProjectTemplateService.getOne(wrapper); - - if (Objects.isNull(projectTemplate)){ - throw new BizException("该项目匹配不到指标模板,请返回上一页或者刷新重试。"); + List templates = indicatorProjectTemplateService.list(wrapper); + VUtils.isTrue(CollUtil.isEmpty(templates)).throwMessage("该项目匹配不到指标模板,请返回上一页或者刷新重试。"); + if (templates.size() > 1){ + throw new BizException("当前项目匹配到多个模板,请返回模板库检查模板配置!"); } + PerformanceIndicatorProjectTemplate projectTemplate = templates.get(0); // 装配项目指标详情及分数信息 // 获取模版绩效指标详情 List templateDetails = indicatorProjectTemplateDetailService.list(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class) @@ -373,11 +380,11 @@ public class OrgSelfAppraisalManage { return "提交失败"; } - public void exportScore(HttpServletResponse response, String projectCode) { + public void exportScore(HttpServletResponse response, PerformanceAppraisalExportReq param) { UserInfoDetails user = LoginUserUtil.loginUserDetail(); String regionCode = user.getRegionCode(); - - ProjectAppraisalIndexDetailVO vo = new ProjectAppraisalIndexDetailVO(); + String projectCode = param.getProjectCode(); + Long appraisalId = param.getAppraisalId(); // 根据项目编码获取最新版本的项目信息 Project project = projectService.getProjectByCode(projectCode); @@ -411,66 +418,87 @@ public class OrgSelfAppraisalManage { .eq(PerformanceIndicatorProjectTemplate::getProjectYear, projectYear) .eq(PerformanceIndicatorProjectTemplate::getAmountRange, amountRange) .eq(PerformanceIndicatorProjectTemplate::getProjectTagIds,projectTagIds) + .eq(PerformanceIndicatorProjectTemplate::getStatus,CommonEnum.YES.getCode()) .orderByDesc(PerformanceIndicatorProjectTemplate::getUpdateOn); - PerformanceIndicatorProjectTemplate projectTemplate = indicatorProjectTemplateService.getOne(wrapper); - - if (Objects.isNull(projectTemplate)){ - throw new BizException("该项目匹配不到指标模板,请返回上一页或者刷新重试。"); + List templates = indicatorProjectTemplateService.list(wrapper); + VUtils.isTrue(CollUtil.isEmpty(templates)).throwMessage("该项目匹配不到指标模板,请返回上一页或者刷新重试。"); + if (templates.size() > 1){ + throw new BizException("当前项目匹配到多个模板,请返回模板库检查模板配置!"); } + PerformanceIndicatorProjectTemplate projectTemplate = templates.get(0); // 装配项目指标详情及分数信息 // 获取模版绩效指标详情 List templateDetails = indicatorProjectTemplateDetailService.list(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class) - .eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId, projectTemplate.getId()) - .eq(PerformanceIndicatorProjectTemplateDetail::getIsAdditional,Boolean.FALSE)); - // 获取模版附加绩效指标详情 - List additionalTemplateDetails = indicatorProjectTemplateDetailService.list(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class) - .eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId, projectTemplate.getId()) - .eq(PerformanceIndicatorProjectTemplateDetail::getIsAdditional,Boolean.TRUE)); - List templateDetailVos = templateDetailBuildHelper.buildTemplateDetail(templateDetails,projectCode,vo); - List additionalTemplateDetailVos = templateDetailBuildHelper.buildTemplateDetail(additionalTemplateDetails,projectCode,vo); - Map templateDetailVoMap = templateDetailVos.stream().collect(Collectors.toMap(ProjectTemplateDetailVO::getId, t -> t)); + .eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId, projectTemplate.getId())); + Map templateDetailMap = templateDetails.stream().collect(Collectors.toMap(PerformanceIndicatorProjectTemplateDetail::getId, t -> t)); List exportDataList = Lists.newArrayList(); + List exportAdditionalDataList = Lists.newArrayList(); // 构建指标和打分详情 - Map scoreInfoMap = performanceAppraisalScoreInfoService.list().stream() + List scoreInfoList = performanceAppraisalScoreInfoService.list(Wrappers.lambdaQuery(PerformanceAppraisalScoreInfo.class) + .eq(PerformanceAppraisalScoreInfo::getAppraisalId, appraisalId) + .eq(PerformanceAppraisalScoreInfo::getAppraisalType, AppraisalTypeEnum.SELF_APPRAISAL.getCode()) + .eq(PerformanceAppraisalScoreInfo::getAppraisalProjectCode, projectCode) + .orderBy(Boolean.TRUE, Boolean.TRUE, PerformanceAppraisalScoreInfo::getTemplateDetailId)); + Map scoreInfoMap = scoreInfoList.stream() .collect(Collectors.toMap(PerformanceAppraisalScoreInfo::getTemplateDetailId, p -> p)); - // 筛选出所有三级指标 - List thirdVos = templateDetailVos.stream() - .filter(t -> PerformanceTemplateTypeEnum.THIRD_INDEX.getCode().equals(t.getType())) - .collect(Collectors.toList()); - for (ProjectTemplateDetailVO templateDetailVo : thirdVos) { + // 筛选出所有打分的三级指标模板详情ID + for (PerformanceAppraisalScoreInfo scoreInfo : scoreInfoList) { AppraisalScoreExportDTO thirdDto = new AppraisalScoreExportDTO(); - thirdDto.setThirdIndexName(templateDetailVo.getName()); - thirdDto.setIndexDetail(templateDetailVo.getIndexDetail()); - thirdDto.setGradeDetail(templateDetailVo.getGradeDetail()); - thirdDto.setSupportMaterial(templateDetailVo.getSupportMaterial()); - thirdDto.setIndexScore(templateDetailVo.getIndexScore()); - thirdDto.setIsAdditional(CommonEnum.YES.getDesc()); - PerformanceAppraisalScoreInfo appraisalScoreInfo = scoreInfoMap.get(templateDetailVo.getId()); + Long detailId = scoreInfo.getTemplateDetailId(); + PerformanceIndicatorProjectTemplateDetail thirdTemplateDetail = templateDetailMap.get(detailId); + thirdDto.setThirdIndexName(thirdTemplateDetail.getName()); + thirdDto.setIndexDetail(thirdTemplateDetail.getIndexDetail()); + thirdDto.setGradeDetail(thirdTemplateDetail.getGradeDetail()); + thirdDto.setSupportMaterial(thirdTemplateDetail.getSupportMaterial()); + thirdDto.setIndexScore(thirdTemplateDetail.getIndexScore()); + if (Boolean.TRUE.equals(thirdTemplateDetail.getIsAdditional())) { + thirdDto.setIsAdditional(CommonEnum.YES.getDesc()); + } else if (Boolean.FALSE.equals(thirdTemplateDetail.getIsAdditional())) { + thirdDto.setIsAdditional(CommonEnum.NO.getDesc()); + } + PerformanceAppraisalScoreInfo appraisalScoreInfo = scoreInfoMap.get(thirdTemplateDetail.getId()); if (Objects.nonNull(appraisalScoreInfo)) { thirdDto.setAppraisalBasis(appraisalScoreInfo.getAppraisalBasis()); + thirdDto.setAppraisalScore(appraisalScoreInfo.getAppraisalScore()); } - exportDataList.add(thirdDto); // 二级指标名称 - Long secondId = templateDetailVo.getParentId(); + Long secondId = thirdTemplateDetail.getParentId(); if (Objects.nonNull(secondId)) { - ProjectTemplateDetailVO secondTemplateDetailVo = templateDetailVoMap.get(secondId); - if (Objects.nonNull(secondTemplateDetailVo)) { - thirdDto.setSecondIndexName(secondTemplateDetailVo.getName()); + PerformanceIndicatorProjectTemplateDetail secondTemplateDetail = templateDetailMap.get(secondId); + if (Objects.nonNull(secondTemplateDetail)) { + thirdDto.setSecondIndexName(secondTemplateDetail.getName()); // 一级指标名称 - Long firstId = secondTemplateDetailVo.getParentId(); + Long firstId = secondTemplateDetail.getParentId(); if (Objects.nonNull(firstId)){ - ProjectTemplateDetailVO firstTemplateDetailVo = templateDetailVoMap.get(secondId); - if (Objects.nonNull(firstTemplateDetailVo)) { - thirdDto.setFirstIndexName(firstTemplateDetailVo.getName()); + PerformanceIndicatorProjectTemplateDetail firstTemplateDetail = templateDetailMap.get(firstId); + if (Objects.nonNull(firstTemplateDetail)) { + thirdDto.setFirstIndexName(firstTemplateDetail.getName()); } } } } + if (Boolean.FALSE.equals(thirdTemplateDetail.getIsAdditional())) { + exportDataList.add(thirdDto); + }else { + exportAdditionalDataList.add(thirdDto); + } + } + exportDataList.addAll(exportAdditionalDataList); + + String fileName = "绩效评价_单位自评_评分明细表"; + ExcelDownUtil.setFileName(fileName, response); + //数据导出处理函数 + try { + EasyExcel.write(response.getOutputStream(), AppraisalScoreExportDTO.class) + .autoCloseStream(false) + .registerWriteHandler(ExcelExportStyle.formalStyle()) + .sheet(fileName) + .doWrite(exportDataList); + } catch (IOException e) { + throw new RuntimeException(e); } - - } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/AppraisalScoreExportDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/AppraisalScoreExportDTO.java index 163c1c8..84132dd 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/AppraisalScoreExportDTO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/AppraisalScoreExportDTO.java @@ -3,6 +3,7 @@ package com.ningdatech.pmapi.performance.model.dto; import java.io.Serializable; import java.math.BigDecimal; +import com.alibaba.excel.annotation.ExcelProperty; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -18,32 +19,42 @@ public class AppraisalScoreExportDTO implements Serializable { private static final long serialVersionUID = 1L; @ApiModelProperty("一级指标名称") + @ExcelProperty(value = "一级指标",index = 0) private String firstIndexName; @ApiModelProperty("二级指标名称") + @ExcelProperty(value = "二级指标",index = 1) private String secondIndexName; @ApiModelProperty("三级指标名称") + @ExcelProperty(value = "三级指标",index = 2) private String thirdIndexName; @ApiModelProperty("指标分值 3级指标才有") + @ExcelProperty(value = "指标分值",index = 3) private BigDecimal indexScore; @ApiModelProperty("指标细则 3级指标才有") + @ExcelProperty(value = "指标细则",index = 4) private String indexDetail; @ApiModelProperty("评分细则") + @ExcelProperty(value = "评分细则",index = 5) private String gradeDetail; @ApiModelProperty("佐证材料描述") + @ExcelProperty(value = "佐证材料",index = 6) private String supportMaterial; @ApiModelProperty("自评依据") + @ExcelProperty(value = "自评依据",index = 7) private String appraisalBasis; @ApiModelProperty("自评得分") + @ExcelProperty(value = "自评得分",index = 8) private BigDecimal appraisalScore; @ApiModelProperty("是否为附加指标") + @ExcelProperty(value = "是否附加指标",index = 9) private String isAdditional; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalScoreInfo.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalScoreInfo.java index 586be45..4bead52 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalScoreInfo.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalScoreInfo.java @@ -70,7 +70,4 @@ public class PerformanceAppraisalScoreInfo implements Serializable { @ApiModelProperty("评价项目Code") private String appraisalProjectCode; - - @ApiModelProperty("评价应用ID") - private Long appraisalAppId; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/req/PerformanceAppraisalExportReq.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/req/PerformanceAppraisalExportReq.java new file mode 100644 index 0000000..7163acb --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/req/PerformanceAppraisalExportReq.java @@ -0,0 +1,20 @@ +package com.ningdatech.pmapi.performance.model.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * PerformanceAppraisalExportReq + * @return + * @author CMM + * @since 2023/08/16 17:07 + */ +@Data +public class PerformanceAppraisalExportReq { + + @ApiModelProperty("计划名称") + private String projectCode; + + @ApiModelProperty("评价计划Id") + private Long appraisalId; +}