|
@@ -2,6 +2,7 @@ package com.ningdatech.pmapi.performance.manage; |
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
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.model.PageVo; |
|
|
import com.ningdatech.basic.util.StrPool; |
|
|
import com.ningdatech.basic.util.StrPool; |
|
|
import com.ningdatech.pmapi.common.enumeration.CommonEnum; |
|
|
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.constant.BizConst; |
|
|
import com.ningdatech.pmapi.performance.enumration.AppraisalTypeEnum; |
|
|
import com.ningdatech.pmapi.performance.enumration.AppraisalTypeEnum; |
|
|
import com.ningdatech.pmapi.performance.enumration.PerformanceTemplateTypeEnum; |
|
|
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.ProjectAppraisalDTO; |
|
|
import com.ningdatech.pmapi.performance.model.dto.ProjectAppraisalInfoDTO; |
|
|
import com.ningdatech.pmapi.performance.model.dto.ProjectAppraisalInfoDTO; |
|
|
import com.ningdatech.pmapi.performance.model.entity.*; |
|
|
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.req.PerformanceAppraisalListReq; |
|
|
import com.ningdatech.pmapi.performance.model.vo.*; |
|
|
import com.ningdatech.pmapi.performance.model.vo.*; |
|
|
import com.ningdatech.pmapi.performance.service.*; |
|
|
import com.ningdatech.pmapi.performance.service.*; |
|
@@ -41,6 +45,7 @@ import org.springframework.stereotype.Component; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
import java.io.IOException; |
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
import java.time.LocalDateTime; |
|
|
import java.time.LocalDateTime; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
@@ -273,12 +278,14 @@ public class OrgSelfAppraisalManage { |
|
|
.eq(PerformanceIndicatorProjectTemplate::getProjectYear, projectYear) |
|
|
.eq(PerformanceIndicatorProjectTemplate::getProjectYear, projectYear) |
|
|
.eq(PerformanceIndicatorProjectTemplate::getAmountRange, amountRange) |
|
|
.eq(PerformanceIndicatorProjectTemplate::getAmountRange, amountRange) |
|
|
.eq(PerformanceIndicatorProjectTemplate::getProjectTagIds,projectTagIds) |
|
|
.eq(PerformanceIndicatorProjectTemplate::getProjectTagIds,projectTagIds) |
|
|
|
|
|
.eq(PerformanceIndicatorProjectTemplate::getStatus,CommonEnum.YES.getCode()) |
|
|
.orderByDesc(PerformanceIndicatorProjectTemplate::getUpdateOn); |
|
|
.orderByDesc(PerformanceIndicatorProjectTemplate::getUpdateOn); |
|
|
PerformanceIndicatorProjectTemplate projectTemplate = indicatorProjectTemplateService.getOne(wrapper); |
|
|
|
|
|
|
|
|
|
|
|
if (Objects.isNull(projectTemplate)){ |
|
|
|
|
|
throw new BizException("该项目匹配不到指标模板,请返回上一页或者刷新重试。"); |
|
|
|
|
|
|
|
|
List<PerformanceIndicatorProjectTemplate> templates = indicatorProjectTemplateService.list(wrapper); |
|
|
|
|
|
VUtils.isTrue(CollUtil.isEmpty(templates)).throwMessage("该项目匹配不到指标模板,请返回上一页或者刷新重试。"); |
|
|
|
|
|
if (templates.size() > 1){ |
|
|
|
|
|
throw new BizException("当前项目匹配到多个模板,请返回模板库检查模板配置!"); |
|
|
} |
|
|
} |
|
|
|
|
|
PerformanceIndicatorProjectTemplate projectTemplate = templates.get(0); |
|
|
// 装配项目指标详情及分数信息 |
|
|
// 装配项目指标详情及分数信息 |
|
|
// 获取模版绩效指标详情 |
|
|
// 获取模版绩效指标详情 |
|
|
List<PerformanceIndicatorProjectTemplateDetail> templateDetails = indicatorProjectTemplateDetailService.list(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class) |
|
|
List<PerformanceIndicatorProjectTemplateDetail> templateDetails = indicatorProjectTemplateDetailService.list(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class) |
|
@@ -373,11 +380,11 @@ public class OrgSelfAppraisalManage { |
|
|
return "提交失败"; |
|
|
return "提交失败"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void exportScore(HttpServletResponse response, String projectCode) { |
|
|
|
|
|
|
|
|
public void exportScore(HttpServletResponse response, PerformanceAppraisalExportReq param) { |
|
|
UserInfoDetails user = LoginUserUtil.loginUserDetail(); |
|
|
UserInfoDetails user = LoginUserUtil.loginUserDetail(); |
|
|
String regionCode = user.getRegionCode(); |
|
|
String regionCode = user.getRegionCode(); |
|
|
|
|
|
|
|
|
ProjectAppraisalIndexDetailVO vo = new ProjectAppraisalIndexDetailVO(); |
|
|
|
|
|
|
|
|
String projectCode = param.getProjectCode(); |
|
|
|
|
|
Long appraisalId = param.getAppraisalId(); |
|
|
|
|
|
|
|
|
// 根据项目编码获取最新版本的项目信息 |
|
|
// 根据项目编码获取最新版本的项目信息 |
|
|
Project project = projectService.getProjectByCode(projectCode); |
|
|
Project project = projectService.getProjectByCode(projectCode); |
|
@@ -411,66 +418,87 @@ public class OrgSelfAppraisalManage { |
|
|
.eq(PerformanceIndicatorProjectTemplate::getProjectYear, projectYear) |
|
|
.eq(PerformanceIndicatorProjectTemplate::getProjectYear, projectYear) |
|
|
.eq(PerformanceIndicatorProjectTemplate::getAmountRange, amountRange) |
|
|
.eq(PerformanceIndicatorProjectTemplate::getAmountRange, amountRange) |
|
|
.eq(PerformanceIndicatorProjectTemplate::getProjectTagIds,projectTagIds) |
|
|
.eq(PerformanceIndicatorProjectTemplate::getProjectTagIds,projectTagIds) |
|
|
|
|
|
.eq(PerformanceIndicatorProjectTemplate::getStatus,CommonEnum.YES.getCode()) |
|
|
.orderByDesc(PerformanceIndicatorProjectTemplate::getUpdateOn); |
|
|
.orderByDesc(PerformanceIndicatorProjectTemplate::getUpdateOn); |
|
|
PerformanceIndicatorProjectTemplate projectTemplate = indicatorProjectTemplateService.getOne(wrapper); |
|
|
|
|
|
|
|
|
|
|
|
if (Objects.isNull(projectTemplate)){ |
|
|
|
|
|
throw new BizException("该项目匹配不到指标模板,请返回上一页或者刷新重试。"); |
|
|
|
|
|
|
|
|
List<PerformanceIndicatorProjectTemplate> templates = indicatorProjectTemplateService.list(wrapper); |
|
|
|
|
|
VUtils.isTrue(CollUtil.isEmpty(templates)).throwMessage("该项目匹配不到指标模板,请返回上一页或者刷新重试。"); |
|
|
|
|
|
if (templates.size() > 1){ |
|
|
|
|
|
throw new BizException("当前项目匹配到多个模板,请返回模板库检查模板配置!"); |
|
|
} |
|
|
} |
|
|
|
|
|
PerformanceIndicatorProjectTemplate projectTemplate = templates.get(0); |
|
|
// 装配项目指标详情及分数信息 |
|
|
// 装配项目指标详情及分数信息 |
|
|
// 获取模版绩效指标详情 |
|
|
// 获取模版绩效指标详情 |
|
|
List<PerformanceIndicatorProjectTemplateDetail> templateDetails = indicatorProjectTemplateDetailService.list(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class) |
|
|
List<PerformanceIndicatorProjectTemplateDetail> templateDetails = indicatorProjectTemplateDetailService.list(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class) |
|
|
.eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId, projectTemplate.getId()) |
|
|
|
|
|
.eq(PerformanceIndicatorProjectTemplateDetail::getIsAdditional,Boolean.FALSE)); |
|
|
|
|
|
// 获取模版附加绩效指标详情 |
|
|
|
|
|
List<PerformanceIndicatorProjectTemplateDetail> additionalTemplateDetails = indicatorProjectTemplateDetailService.list(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class) |
|
|
|
|
|
.eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId, projectTemplate.getId()) |
|
|
|
|
|
.eq(PerformanceIndicatorProjectTemplateDetail::getIsAdditional,Boolean.TRUE)); |
|
|
|
|
|
List<ProjectTemplateDetailVO> templateDetailVos = templateDetailBuildHelper.buildTemplateDetail(templateDetails,projectCode,vo); |
|
|
|
|
|
List<ProjectTemplateDetailVO> additionalTemplateDetailVos = templateDetailBuildHelper.buildTemplateDetail(additionalTemplateDetails,projectCode,vo); |
|
|
|
|
|
Map<Long, ProjectTemplateDetailVO> templateDetailVoMap = templateDetailVos.stream().collect(Collectors.toMap(ProjectTemplateDetailVO::getId, t -> t)); |
|
|
|
|
|
|
|
|
.eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId, projectTemplate.getId())); |
|
|
|
|
|
Map<Long, PerformanceIndicatorProjectTemplateDetail> templateDetailMap = templateDetails.stream().collect(Collectors.toMap(PerformanceIndicatorProjectTemplateDetail::getId, t -> t)); |
|
|
|
|
|
|
|
|
List<AppraisalScoreExportDTO> exportDataList = Lists.newArrayList(); |
|
|
List<AppraisalScoreExportDTO> exportDataList = Lists.newArrayList(); |
|
|
|
|
|
List<AppraisalScoreExportDTO> exportAdditionalDataList = Lists.newArrayList(); |
|
|
// 构建指标和打分详情 |
|
|
// 构建指标和打分详情 |
|
|
Map<Long, PerformanceAppraisalScoreInfo> scoreInfoMap = performanceAppraisalScoreInfoService.list().stream() |
|
|
|
|
|
|
|
|
List<PerformanceAppraisalScoreInfo> 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<Long, PerformanceAppraisalScoreInfo> scoreInfoMap = scoreInfoList.stream() |
|
|
.collect(Collectors.toMap(PerformanceAppraisalScoreInfo::getTemplateDetailId, p -> p)); |
|
|
.collect(Collectors.toMap(PerformanceAppraisalScoreInfo::getTemplateDetailId, p -> p)); |
|
|
|
|
|
|
|
|
// 筛选出所有三级指标 |
|
|
|
|
|
List<ProjectTemplateDetailVO> 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(); |
|
|
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)) { |
|
|
if (Objects.nonNull(appraisalScoreInfo)) { |
|
|
thirdDto.setAppraisalBasis(appraisalScoreInfo.getAppraisalBasis()); |
|
|
thirdDto.setAppraisalBasis(appraisalScoreInfo.getAppraisalBasis()); |
|
|
|
|
|
thirdDto.setAppraisalScore(appraisalScoreInfo.getAppraisalScore()); |
|
|
} |
|
|
} |
|
|
exportDataList.add(thirdDto); |
|
|
|
|
|
// 二级指标名称 |
|
|
// 二级指标名称 |
|
|
Long secondId = templateDetailVo.getParentId(); |
|
|
|
|
|
|
|
|
Long secondId = thirdTemplateDetail.getParentId(); |
|
|
if (Objects.nonNull(secondId)) { |
|
|
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)){ |
|
|
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); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |