Преглед на файлове

Merge branch 'ls2_performance_appraisal_0801' of http://git.ningdatech.com/liushuai/project-management into dev

tags/24080901
CMM преди 1 година
родител
ревизия
f25de4fcce
променени са 14 файла, в които са добавени 663 реда и са изтрити 113 реда
  1. +32
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/performance/constant/BizConst.java
  2. +7
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/PerformanceAppraisalPlanController.java
  3. +10
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/VerifyController.java
  4. +81
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/PerformanceAppraisalPlanManage.java
  5. +72
    -105
      pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/ReAppraisalManage.java
  6. +197
    -4
      pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/VerifyManage.java
  7. +27
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/ReAppraisalInfoDTO.java
  8. +2
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/ReAppraisalScoreExportDTO.java
  9. +36
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/ExcelHead.java
  10. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/performance/model/req/PerformanceAppraisalExportReq.java
  11. +6
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/performance/model/req/PerformanceAppraisalListReq.java
  12. +37
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/performance/util/ContentTypeUtils.java
  13. +37
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/performance/util/ExcelSheetVerticalCellStyleStrategy.java
  14. +118
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/performance/util/ExcelUtils.java

+ 32
- 0
pmapi/src/main/java/com/ningdatech/pmapi/performance/constant/BizConst.java Целия файл

@@ -35,4 +35,36 @@ public interface BizConst {
* 复评员
*/
String REAPPRAISAL_ROLE = "复评员";

String FIRST_INDEX_NAME = "firstIndexName";
String FIRST_INDEX_TITLE = "一级指标";
String SECOND_INDEX_NAME = "secondIndexName";
String SECOND_INDEX_TITLE = "二级指标";
String THIRD_INDEX_NAME = "thirdIndexName";
String THIRD_INDEX_TITLE = "三级指标";
String INDEX_SCORE = "indexScore";
String INDEX_SCORE_TITLE = "指标分值";
String INDEX_DETAIL = "indexDetail";
String INDEX_DETAIL_TITLE = "指标细则";
String GRADE_DETAIL = "gradeDetail";
String GRADE_DETAIL_TITLE = "评分细则";
String SUPPORT_MATERIAL = "supportMaterial";
String SUPPORT_MATERIAL_TITLE = "佐证材料";
String SELF_APPRAISAL_BASIS = "selfAppraisalBasis";
String SELF_APPRAISAL_BASIS_TITLE = "自评依据";
String SELF_APPRAISAL_SCORE = "selfAppraisalScore";
String SELF_APPRAISAL_SCORE_TITLE = "自评得分";
String RE_APPRAISAL_BASIS = "refAppraisalBasis";
String RE_APPRAISAL_BASIS_TITLE = "复评依据";
String RE_APPRAISAL_SCORE = "reAppraisalScore";
String RE_APPRAISAL_SCORE_TITLE = "复评得分";

String VERIFY_BASIS = "verifyBasis";
String VERIFY_BASIS_TITLE = "核查依据";
String VERIFY_SCORE = "verifyScore";
String VERIFY_SCORE_TITLE = "核查得分";
String IS_ADDITIONAL = "isAdditional";
String IS_ADDITIONAL_TITLE = "是否附加指标";
String RE_APPRAISAL = "(复评)";
String VERIFY = "(核查)";
}

+ 7
- 0
pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/PerformanceAppraisalPlanController.java Целия файл

@@ -12,6 +12,7 @@ import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalApplication
import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalProjectGroupVO;
import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalProjectVO;
import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalVO;
import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
@@ -53,6 +54,12 @@ public class PerformanceAppraisalPlanController {
return performanceAppraisalPlanManage.create(createDTO);
}

@GetMapping("/final-project-list")
@ApiOperation("评价计划-终验项目列表")
public PageVo<ProjectLibListItemVO> finalProjectList(PerformanceAppraisalListReq req) {
return performanceAppraisalPlanManage.finalProjectList(req);
}

@PostMapping("/addProject")
@ApiOperation("评价计划-添加待评价项目")
@WebLog("评价计划-添加待评价项目")


+ 10
- 0
pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/VerifyController.java Целия файл

@@ -1,9 +1,12 @@
package com.ningdatech.pmapi.performance.controller;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import com.ningdatech.log.annotation.WebLog;
import com.ningdatech.pmapi.common.util.ExcelDownUtil;
import com.ningdatech.pmapi.performance.manage.VerifyManage;
import com.ningdatech.pmapi.performance.model.req.PerformanceAppraisalExportReq;
import org.springframework.web.bind.annotation.*;

import com.ningdatech.basic.model.PageVo;
@@ -49,4 +52,11 @@ public class VerifyController {
return verifyManage.submitVerify(param);
}

@GetMapping("/score/export")
@ApiOperation("核查打分导出")
@WebLog(value = "核查打分导出",modular = "绩效评价-专家核查")
public void exportScore(@Valid @ModelAttribute PerformanceAppraisalExportReq param, HttpServletResponse response){
ExcelDownUtil.downXls(response, param, verifyManage::exportScore);
}

}

+ 81
- 2
pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/PerformanceAppraisalPlanManage.java Целия файл

@@ -6,6 +6,10 @@ import java.util.stream.Collectors;

import com.ningdatech.pmapi.performance.model.entity.*;
import com.ningdatech.pmapi.performance.service.*;
import com.ningdatech.pmapi.projectlib.helper.ProjectHelper;
import com.ningdatech.pmapi.projectlib.manage.ProjectLibManage;
import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq;
import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@@ -80,6 +84,7 @@ public class PerformanceAppraisalPlanManage {
private final BuildUserUtils buildUserUtils;
private final IPerformanceAppraisalScoreInfoService performanceAppraisalScoreInfoService;
private final IPerformanceAppraisalAppScoreInfoService performanceAppraisalAppScoreInfoService;
private final ProjectLibManage projectLibManage;

/**
* 绩效列表
@@ -320,11 +325,30 @@ public class PerformanceAppraisalPlanManage {
if(CollUtil.isEmpty(createDTO.getProjects())){
return;
}

Integer startSelfDays = createDTO.getStartSelfDays();
Integer completeSelfDays = createDTO.getCompleteSelfDays();
List<AppraisalProjectDTO> projects = createDTO.getProjects();

List<Long> proIdList = performanceAppraisalProjectService.list().stream()
.map(PerformanceAppraisalProject::getProjectId).collect(Collectors.toList());

List<Long> projectIdList = projects.stream().map(AppraisalProjectDTO::getId).collect(Collectors.toList());
// 判断提交时,项目是否已经被添加到其他评价计划中
if (Boolean.TRUE.equals(haveIntersection(projectIdList, proIdList))){
// 得到交集
List<Long> intersection = Lists.newArrayList(projectIdList);
intersection.retainAll(proIdList);
// 获取重复添加的项目名称
String names = intersection.stream().map(i -> {
Project project = projectService.getById(i);
if (Objects.nonNull(project)) {
return project.getProjectName();
}
return StrPool.EMPTY;
}).collect(Collectors.joining(StrPool.COMMA));
throw new BizException(names + CommonConst.PROJECT_REPEAT);
}

for(AppraisalProjectDTO appraisalProject : projects){
Project newProject = projectService.getNewProject(appraisalProject.getId());
VUtils.isTrue(Objects.isNull(newProject)).throwMessage("项目不存在 " + appraisalProject.getId());
@@ -384,7 +408,28 @@ public class PerformanceAppraisalPlanManage {
return;
}

List<Long> applicationIds = createDTO.getApplicationIds();
List<Long> applicationIdList = createDTO.getApplicationIds();
// 获取已经创建的评价计划中添加的评价应用ID
List<Long> applicationIds = performanceAppraisalApplicationService.list().stream()
.map(PerformanceAppraisalApplication::getApplicationId).collect(Collectors.toList());

// 如果有交集,说明选择的应用中,有已经在其他评价计划中的应用
if (Boolean.TRUE.equals(haveIntersection(applicationIdList, applicationIds))){
// 得到交集
List<Long> intersection = Lists.newArrayList(applicationIdList);
intersection.retainAll(applicationIds);
// 获取重复添加的应用名称
String names = intersection.stream().map(i -> {
ProjectApplication application = applicationService.getById(i);
if (Objects.nonNull(application)) {
return Objects.nonNull(application.getApplicationName()) ? application.getApplicationName()
: application.getRelatedExistsApplication();
}
return StrPool.EMPTY;
}).collect(Collectors.joining(StrPool.COMMA));
throw new BizException(names + CommonConst.APP_REPEAT);
}

Map<Long, ProjectApplication> applicationMap = applicationService.list(Wrappers.lambdaQuery(ProjectApplication.class).in(ProjectApplication::getId, applicationIds)).stream()
.collect(Collectors.toMap(ProjectApplication::getId, a -> a));
for(Long applicationId : applicationIds){
@@ -992,4 +1037,38 @@ public class PerformanceAppraisalPlanManage {
}).collect(Collectors.toList());
return PageVo.of(voList,voList.size());
}

public PageVo<ProjectLibListItemVO> finalProjectList(PerformanceAppraisalListReq req) {

UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId());

Long appraisalId = req.getAppraisalId();
String projectName = req.getProjectName();
String buildOrgName = req.getBuildOrgName();
Integer projectType = req.getProjectType();
Integer projectYear = req.getProjectYear();
// 从项目库获取本区域已验收的项目列表
ProjectListReq param = new ProjectListReq();
param.setProjectName(projectName);
param.setBuildOrgName(buildOrgName);
param.setProjectType(projectType);
param.setProjectYear(projectYear);
param.setStatus(ProjectStatusEnum.ACCEPTED.getCode());
PageVo<ProjectLibListItemVO> resList = projectLibManage.projectLibListWithPermission(param, user);
// 获取已添加到评价计划中的项目
List<String> projectCodes = performanceAppraisalProjectService.list().stream()
.map(PerformanceAppraisalProject::getProjectCode).collect(Collectors.toList());
// 如果是编辑评价计划,获取当前评价计划已添加的项目,并保留当前计划已添加的项目
if (Objects.nonNull(appraisalId)) {
List<PerformanceAppraisalProject> projects = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class)
.eq(PerformanceAppraisalProject::getAppraisalId, appraisalId));
if (CollUtil.isNotEmpty(projects)){
List<String> projectCodeList = projects.stream().map(PerformanceAppraisalProject::getProjectCode).collect(Collectors.toList());
projectCodes.removeAll(projectCodeList);
}
}
// 过滤掉已经添加到评价计划中的项目(如果是编辑评价计划,保留当前计划已添加的项目)
List<ProjectLibListItemVO> result = resList.getRecords().stream().filter(r -> !projectCodes.contains(r.getProjectCode())).collect(Collectors.toList());
return PageVo.of(result,result.size());
}
}

+ 72
- 105
pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/ReAppraisalManage.java Целия файл

@@ -6,20 +6,20 @@ import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;

import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.CharsetUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.write.builder.ExcelWriterBuilder;
import com.google.common.collect.Lists;
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.model.dto.ReAppraisalScoreExportDTO;
import com.ningdatech.pmapi.performance.model.dto.SelfAppraisalScoreExportDTO;
import com.ningdatech.pmapi.performance.model.dto.*;
import com.ningdatech.pmapi.performance.model.req.PerformanceAppraisalExportReq;
import com.ningdatech.pmapi.performance.util.ExcelFillCellMergeStrategy;
import com.ningdatech.pmapi.performance.util.MultiColumnMergeStrategy;
import com.ningdatech.pmapi.performance.util.*;
import com.ningdatech.pmapi.portrait.model.entity.ProjectTag;
import com.ningdatech.pmapi.portrait.service.IProjectTagService;
import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@@ -32,8 +32,6 @@ import com.ningdatech.basic.model.PageVo;
import com.ningdatech.basic.util.StrPool;
import com.ningdatech.pmapi.performance.constant.BizConst;
import com.ningdatech.pmapi.performance.enumration.AppraisalTypeEnum;
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.PerformanceAppraisalListReq;
import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalProjectVO;
@@ -384,143 +382,112 @@ public class ReAppraisalManage {
.eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId, projectTemplate.getId()));
Map<Long, PerformanceIndicatorProjectTemplateDetail> templateDetailMap = templateDetails.stream().collect(Collectors.toMap(PerformanceIndicatorProjectTemplateDetail::getId, t -> t));

List<SelfAppraisalScoreExportDTO> exportDataList = Lists.newArrayList();
List<SelfAppraisalScoreExportDTO> exportAdditionalDataList = Lists.newArrayList();
List<Map<String, Object>> exportDataList = Lists.newArrayList();
List<Map<String, Object>> exportAdditionalDataList = Lists.newArrayList();
// 构建指标和打分详情
List<PerformanceAppraisalScoreInfo> scoreInfoList = performanceAppraisalScoreInfoService.list(Wrappers.lambdaQuery(PerformanceAppraisalScoreInfo.class)
.eq(PerformanceAppraisalScoreInfo::getAppraisalId, appraisalId)
.eq(PerformanceAppraisalScoreInfo::getAppraisalType, AppraisalTypeEnum.RE_APPRAISAL.getCode())
.and(wp -> wp.eq(PerformanceAppraisalScoreInfo::getAppraisalType, AppraisalTypeEnum.SELF_APPRAISAL.getCode()).or()
.eq(PerformanceAppraisalScoreInfo::getAppraisalType, AppraisalTypeEnum.RE_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));
// 按照复评打分人员分组
Map<String, List<PerformanceAppraisalScoreInfo>> scoreInfoUserMap = scoreInfoList.stream()
.collect(Collectors.groupingBy(PerformanceAppraisalScoreInfo::getAppraisalEmployeeName));
Set<String> reUserList = scoreInfoUserMap.keySet();

// 获取复评打分人员信息
List<PerformanceAppraisalScoreInfo> reScoreInfoList = scoreInfoList.stream()
.filter(s -> AppraisalTypeEnum.RE_APPRAISAL.getCode().equals(s.getAppraisalType()))
.collect(Collectors.toList());
List<String> reUserList = reScoreInfoList.stream()
.map(PerformanceAppraisalScoreInfo::getAppraisalEmployeeName)
.collect(Collectors.toList());

// 筛选出所有打分的三级指标模板详情ID
for (PerformanceAppraisalScoreInfo scoreInfo : scoreInfoList) {
SelfAppraisalScoreExportDTO thirdDto = new SelfAppraisalScoreExportDTO();
HashMap<String, Object> scoreMap = MapUtil.newHashMap();
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());
}

// 二级指标名称
Long secondId = thirdTemplateDetail.getParentId();
if (Objects.nonNull(secondId)) {
PerformanceIndicatorProjectTemplateDetail secondTemplateDetail = templateDetailMap.get(secondId);
if (Objects.nonNull(secondTemplateDetail)) {
thirdDto.setSecondIndexName(secondTemplateDetail.getName());
// 一级指标名称
Long firstId = secondTemplateDetail.getParentId();
if (Objects.nonNull(firstId)){
PerformanceIndicatorProjectTemplateDetail firstTemplateDetail = templateDetailMap.get(firstId);
if (Objects.nonNull(firstTemplateDetail)) {
thirdDto.setFirstIndexName(firstTemplateDetail.getName());
scoreMap.put(BizConst.FIRST_INDEX_NAME,firstTemplateDetail.getName());
scoreMap.put(BizConst.SECOND_INDEX_NAME,secondTemplateDetail.getName());
}
}
}
}
scoreMap.put(BizConst.THIRD_INDEX_NAME,thirdTemplateDetail.getName());
scoreMap.put(BizConst.INDEX_SCORE,thirdTemplateDetail.getIndexScore());
scoreMap.put(BizConst.INDEX_DETAIL,thirdTemplateDetail.getIndexDetail());
scoreMap.put(BizConst.GRADE_DETAIL,thirdTemplateDetail.getGradeDetail());
scoreMap.put(BizConst.SUPPORT_MATERIAL,thirdTemplateDetail.getSupportMaterial());
PerformanceAppraisalScoreInfo appraisalScoreInfo = scoreInfoMap.get(thirdTemplateDetail.getId());
// 构建自评和复评打分信息
if (AppraisalTypeEnum.SELF_APPRAISAL.getCode().equals(appraisalScoreInfo.getAppraisalType())){
scoreMap.put(BizConst.SELF_APPRAISAL_BASIS,appraisalScoreInfo.getAppraisalBasis());
scoreMap.put(BizConst.SELF_APPRAISAL_SCORE,appraisalScoreInfo.getAppraisalScore());
} else if (AppraisalTypeEnum.RE_APPRAISAL.getCode().equals(appraisalScoreInfo.getAppraisalType())) {
scoreMap.put(appraisalScoreInfo.getAppraisalEmployeeName() + BizConst.RE_APPRAISAL_BASIS, appraisalScoreInfo.getAppraisalBasis());
scoreMap.put(appraisalScoreInfo.getAppraisalEmployeeName() + BizConst.RE_APPRAISAL_SCORE, appraisalScoreInfo.getAppraisalScore());
}

if (Boolean.TRUE.equals(thirdTemplateDetail.getIsAdditional())) {
scoreMap.put(BizConst.IS_ADDITIONAL,CommonEnum.YES.getDesc());
} else if (Boolean.FALSE.equals(thirdTemplateDetail.getIsAdditional())) {
scoreMap.put(BizConst.IS_ADDITIONAL,CommonEnum.NO.getDesc());
}
if (Boolean.FALSE.equals(thirdTemplateDetail.getIsAdditional())) {
exportDataList.add(thirdDto);
exportDataList.add(scoreMap);
}else {
exportAdditionalDataList.add(thirdDto);
exportAdditionalDataList.add(scoreMap);
}
}
exportDataList.addAll(exportAdditionalDataList);
List<List<SelfAppraisalScoreExportDTO>> dataList = Lists.newArrayList();
dataList.add(exportDataList);
String fileName = "绩效评价_人工复评_评分明细表";
ExcelDownUtil.setFileName(fileName, response);
int[] mergeColumnIndex = {0};
// 需要从第几行开始合并
int mergeRowIndex = 2;

//数据导出处理函数
try {
EasyExcel.write(response.getOutputStream(), SelfAppraisalScoreExportDTO.class)
.autoCloseStream(false)
.head(head(reUserList))
.registerWriteHandler(new MultiColumnMergeStrategy(exportDataList.size(),0,1))
.registerWriteHandler(new ExcelFillCellMergeStrategy(mergeRowIndex,mergeColumnIndex))
.registerWriteHandler(ExcelExportStyle.formalStyle())
.sheet(fileName)
//.doWrite(dataList);
.doWrite(getData());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private List<List<String>> head(Set<String> reUserList) {
List<List<String>> list = Lists.newArrayList();
List<String> head0 = Lists.newArrayList();
head0.add("一级指标");
List<String> head1 = Lists.newArrayList();
head1.add("二级指标");
List<String> head2 = Lists.newArrayList();
head2.add("三级指标");
List<String> head3 = Lists.newArrayList();
head2.add("指标分值");
List<String> head4 = Lists.newArrayList();
head2.add("指标细则");
List<String> head5 = Lists.newArrayList();
head2.add("评分细则");
List<String> head6 = Lists.newArrayList();
head2.add("佐证材料");
List<String> head7 = Lists.newArrayList();
head2.add("自评依据");
List<String> head8 = Lists.newArrayList();
head2.add("自评得分");


list.add(head0);
list.add(head1);
list.add(head2);
list.add(head3);
list.add(head4);
list.add(head5);
list.add(head6);
list.add(head7);
list.add(head8);

List<String> reUserHead = Lists.newArrayList();
reUserHead.add("复评依据");
reUserHead.add("复评得分");

List<ExcelHead> headList = Lists.newArrayList();
headList.add(new ExcelHead(BizConst.FIRST_INDEX_NAME,BizConst.FIRST_INDEX_TITLE,StrPool.EMPTY));
headList.add(new ExcelHead(BizConst.SECOND_INDEX_NAME,BizConst.SECOND_INDEX_TITLE,StrPool.EMPTY));
headList.add(new ExcelHead(BizConst.THIRD_INDEX_NAME,BizConst.THIRD_INDEX_TITLE,StrPool.EMPTY));
headList.add(new ExcelHead(BizConst.INDEX_SCORE,BizConst.INDEX_SCORE_TITLE,StrPool.EMPTY));
headList.add(new ExcelHead(BizConst.INDEX_DETAIL,BizConst.INDEX_DETAIL_TITLE,StrPool.EMPTY));
headList.add(new ExcelHead(BizConst.GRADE_DETAIL,BizConst.GRADE_DETAIL_TITLE,StrPool.EMPTY));
headList.add(new ExcelHead(BizConst.SUPPORT_MATERIAL,BizConst.SUPPORT_MATERIAL_TITLE,StrPool.EMPTY));
headList.add(new ExcelHead(BizConst.SELF_APPRAISAL_BASIS,BizConst.SELF_APPRAISAL_BASIS_TITLE,StrPool.EMPTY));
headList.add(new ExcelHead(BizConst.SELF_APPRAISAL_SCORE,BizConst.SELF_APPRAISAL_SCORE_TITLE,StrPool.EMPTY));
for (String reUser : reUserList) {
for (String h : reUserHead) {
List<String> reUsers = Lists.newArrayList();
reUsers.add(reUser + "(复评)");
reUsers.add(h);
list.add(reUsers);
}
headList.add(new ExcelHead(reUser + BizConst.RE_APPRAISAL_BASIS,BizConst.RE_APPRAISAL_BASIS_TITLE,StrPool.EMPTY));
headList.add(new ExcelHead(reUser + BizConst.RE_APPRAISAL_SCORE,BizConst.RE_APPRAISAL_SCORE_TITLE,StrPool.EMPTY));
}
return list;
}
headList.add(new ExcelHead(BizConst.IS_ADDITIONAL,BizConst.IS_ADDITIONAL_TITLE,StrPool.EMPTY));

public List<List<ReAppraisalScoreExportDTO>> getData() {
List<List<ReAppraisalScoreExportDTO>> total = new ArrayList<>();
List<ReAppraisalScoreExportDTO> list = new ArrayList<>();
for (int i = 0; i < 15; i++) {
ReAppraisalScoreExportDTO dto = new ReAppraisalScoreExportDTO();
dto.setFirstIndexName("一级指标" + i);
list.add(dto);
// 数据导出处理函数
try {
response.setCharacterEncoding(CharsetUtil.UTF_8);
response.setContentType(ContentTypeUtils.APPLICATION_EXCEL);
ExcelWriterBuilder writerBuilder = EasyExcel.write();
writerBuilder.file(response.getOutputStream());
writerBuilder.autoCloseStream(true);
writerBuilder.registerWriteHandler(new ExcelSheetVerticalCellStyleStrategy());
writerBuilder.registerWriteHandler(new MultiColumnMergeStrategy(exportDataList.size(),0,1));
writerBuilder.registerWriteHandler(new ExcelFillCellMergeStrategy(mergeRowIndex,mergeColumnIndex));
writerBuilder.head(ExcelUtils.getHead(reUserList,Lists.newArrayList()))
.sheet(fileName)
.doWrite(ExcelUtils.convertData(headList, exportDataList));
} catch (IOException e) {
throw new BizException(e.getMessage());
}
total.add(list);
return total;
}
}

+ 197
- 4
pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/VerifyManage.java Целия файл

@@ -1,13 +1,22 @@
package com.ningdatech.pmapi.performance.manage;

import java.io.IOException;
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.*;
import java.util.stream.Collectors;

import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.CharsetUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.write.builder.ExcelWriterBuilder;
import com.ningdatech.pmapi.common.enumeration.CommonEnum;
import com.ningdatech.pmapi.common.util.ExcelDownUtil;
import com.ningdatech.pmapi.performance.constant.BizConst;
import com.ningdatech.pmapi.performance.model.req.PerformanceAppraisalExportReq;
import com.ningdatech.pmapi.performance.util.*;
import com.ningdatech.pmapi.portrait.model.entity.ProjectTag;
import com.ningdatech.pmapi.portrait.service.IProjectTagService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@@ -43,6 +52,8 @@ import cn.hutool.core.collection.CollUtil;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import javax.servlet.http.HttpServletResponse;

/**
* VerifyManage
* @return
@@ -61,6 +72,8 @@ public class VerifyManage {
private final IPerformanceIndicatorProjectTemplateDetailService indicatorProjectTemplateDetailService;
private final IPerformanceAppraisalScoreInfoService performanceAppraisalScoreInfoService;
private final IPerformanceAppraisalProjectGroupService groupService;
private final IProjectTagService projectTagService;
private final IPerformanceIndicatorProjectTemplateService indicatorProjectTemplateService;
/**
* 核查-评价计划列表
* @param req
@@ -316,4 +329,184 @@ public class VerifyManage {
}
}
}

public void exportScore(HttpServletResponse response, PerformanceAppraisalExportReq param) {
UserInfoDetails user = LoginUserUtil.loginUserDetail();
String regionCode = user.getRegionCode();
String projectCode = param.getProjectCode();
Long appraisalId = param.getAppraisalId();

// 根据项目编码获取最新版本的项目信息
Project project = projectService.getProjectByCode(projectCode);
VUtils.isTrue(Objects.isNull(project)).throwMessage("项目不存在!");
// 根据项目类型、预算年度、批复金额、项目标签匹配本区域指标模版
Integer projectType = project.getProjectType();
Integer projectYear = project.getProjectYear();
BigDecimal approvalAmount = project.getApprovalAmount();
VUtils.isTrue(Objects.isNull(approvalAmount)).throwMessage("未获取到该项目的立项批复金额");
// 根据项目code获取项目标签ID列表
List<Long> tagIdList = projectTagService.list(Wrappers.lambdaQuery(ProjectTag.class)
.eq(ProjectTag::getProjectCode, projectCode)).stream()
.map(ProjectTag::getTagId).collect(Collectors.toList());
VUtils.isTrue(CollUtil.isEmpty(tagIdList)).throwMessage("当前项目未设置标签,匹配不到指标模板,请至项目库或评价计划编辑页面设置标签!");

List<String> strIdList = tagIdList.stream().map(String::valueOf).collect(Collectors.toList());
String projectTagIds = String.join(StrPool.COMMA, strIdList);

Integer amountRange = null;
if (approvalAmount.compareTo(BigDecimal.valueOf(BizConst.FIVE_MILLION)) < 0){
amountRange = BizConst.AMOUNT_RANGE_ONE;
} else if (approvalAmount.compareTo(BigDecimal.valueOf(BizConst.FIVE_MILLION)) >= 0 &&
approvalAmount.compareTo(BigDecimal.valueOf(BizConst.TWENTY_MILLION)) < 0) {
amountRange = BizConst.AMOUNT_RANGE_TWO;
}else if (approvalAmount.compareTo(BigDecimal.valueOf(BizConst.TWENTY_MILLION)) >= 0){
amountRange = BizConst.AMOUNT_RANGE_THREE;
}
LambdaQueryWrapper<PerformanceIndicatorProjectTemplate> wrapper = Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplate.class)
.eq(PerformanceIndicatorProjectTemplate::getRegionCode, regionCode)
.eq(PerformanceIndicatorProjectTemplate::getProjectType, projectType)
.eq(PerformanceIndicatorProjectTemplate::getProjectYear, projectYear)
.eq(PerformanceIndicatorProjectTemplate::getAmountRange, amountRange)
.eq(PerformanceIndicatorProjectTemplate::getProjectTagIds,projectTagIds)
.eq(PerformanceIndicatorProjectTemplate::getStatus, CommonEnum.YES.getCode())
.orderByDesc(PerformanceIndicatorProjectTemplate::getUpdateOn);
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)
.eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId, projectTemplate.getId()));
Map<Long, PerformanceIndicatorProjectTemplateDetail> templateDetailMap = templateDetails.stream().collect(Collectors.toMap(PerformanceIndicatorProjectTemplateDetail::getId, t -> t));

List<Map<String, Object>> exportDataList = Lists.newArrayList();
List<Map<String, Object>> exportAdditionalDataList = Lists.newArrayList();
// 构建指标和打分详情
List<PerformanceAppraisalScoreInfo> scoreInfoList = performanceAppraisalScoreInfoService.list(Wrappers.lambdaQuery(PerformanceAppraisalScoreInfo.class)
.eq(PerformanceAppraisalScoreInfo::getAppraisalId, appraisalId)
.and(wp -> wp.eq(PerformanceAppraisalScoreInfo::getAppraisalType, AppraisalTypeEnum.SELF_APPRAISAL.getCode()).or()
.eq(PerformanceAppraisalScoreInfo::getAppraisalType, AppraisalTypeEnum.RE_APPRAISAL.getCode()).or()
.eq(PerformanceAppraisalScoreInfo::getAppraisalType, AppraisalTypeEnum.EXPERT_VERIFY.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));

// 获取复评打分人员信息
List<PerformanceAppraisalScoreInfo> reScoreInfoList = scoreInfoList.stream()
.filter(s -> AppraisalTypeEnum.RE_APPRAISAL.getCode().equals(s.getAppraisalType()))
.collect(Collectors.toList());
List<String> reUserList = reScoreInfoList.stream()
.map(PerformanceAppraisalScoreInfo::getAppraisalEmployeeName)
.collect(Collectors.toList());

// 获取核查打分人员信息
List<PerformanceAppraisalScoreInfo> verifyScoreInfoList = scoreInfoList.stream()
.filter(s -> AppraisalTypeEnum.EXPERT_VERIFY.getCode().equals(s.getAppraisalType()))
.collect(Collectors.toList());
List<String> verifyUserList = verifyScoreInfoList.stream()
.map(PerformanceAppraisalScoreInfo::getAppraisalEmployeeName)
.collect(Collectors.toList());

// 筛选出所有打分的三级指标模板详情ID
for (PerformanceAppraisalScoreInfo scoreInfo : scoreInfoList) {
HashMap<String, Object> scoreMap = MapUtil.newHashMap();
Long detailId = scoreInfo.getTemplateDetailId();
PerformanceIndicatorProjectTemplateDetail thirdTemplateDetail = templateDetailMap.get(detailId);

// 二级指标名称
Long secondId = thirdTemplateDetail.getParentId();
if (Objects.nonNull(secondId)) {
PerformanceIndicatorProjectTemplateDetail secondTemplateDetail = templateDetailMap.get(secondId);
if (Objects.nonNull(secondTemplateDetail)) {
// 一级指标名称
Long firstId = secondTemplateDetail.getParentId();
if (Objects.nonNull(firstId)){
PerformanceIndicatorProjectTemplateDetail firstTemplateDetail = templateDetailMap.get(firstId);
if (Objects.nonNull(firstTemplateDetail)) {
scoreMap.put(BizConst.FIRST_INDEX_NAME,firstTemplateDetail.getName());
scoreMap.put(BizConst.SECOND_INDEX_NAME,secondTemplateDetail.getName());
}
}
}
}
scoreMap.put(BizConst.THIRD_INDEX_NAME,thirdTemplateDetail.getName());
scoreMap.put(BizConst.INDEX_SCORE,thirdTemplateDetail.getIndexScore());
scoreMap.put(BizConst.INDEX_DETAIL,thirdTemplateDetail.getIndexDetail());
scoreMap.put(BizConst.GRADE_DETAIL,thirdTemplateDetail.getGradeDetail());
scoreMap.put(BizConst.SUPPORT_MATERIAL,thirdTemplateDetail.getSupportMaterial());

PerformanceAppraisalScoreInfo appraisalScoreInfo = scoreInfoMap.get(thirdTemplateDetail.getId());
// 构建自评和复评打分信息
if (AppraisalTypeEnum.SELF_APPRAISAL.getCode().equals(appraisalScoreInfo.getAppraisalType())){
scoreMap.put(BizConst.SELF_APPRAISAL_BASIS,appraisalScoreInfo.getAppraisalBasis());
scoreMap.put(BizConst.SELF_APPRAISAL_SCORE,appraisalScoreInfo.getAppraisalScore());
} else if (AppraisalTypeEnum.RE_APPRAISAL.getCode().equals(appraisalScoreInfo.getAppraisalType())) {
scoreMap.put(appraisalScoreInfo.getAppraisalEmployeeName() + BizConst.RE_APPRAISAL_BASIS, appraisalScoreInfo.getAppraisalBasis());
scoreMap.put(appraisalScoreInfo.getAppraisalEmployeeName() + BizConst.RE_APPRAISAL_SCORE, appraisalScoreInfo.getAppraisalScore());
} else if (AppraisalTypeEnum.EXPERT_VERIFY.getCode().equals(appraisalScoreInfo.getAppraisalType())) {
scoreMap.put(appraisalScoreInfo.getAppraisalEmployeeName() + BizConst.VERIFY_BASIS, appraisalScoreInfo.getAppraisalBasis());
scoreMap.put(appraisalScoreInfo.getAppraisalEmployeeName() + BizConst.VERIFY_SCORE, appraisalScoreInfo.getAppraisalScore());
}

if (Boolean.TRUE.equals(thirdTemplateDetail.getIsAdditional())) {
scoreMap.put(BizConst.IS_ADDITIONAL,CommonEnum.YES.getDesc());
} else if (Boolean.FALSE.equals(thirdTemplateDetail.getIsAdditional())) {
scoreMap.put(BizConst.IS_ADDITIONAL,CommonEnum.NO.getDesc());
}
if (Boolean.FALSE.equals(thirdTemplateDetail.getIsAdditional())) {
exportDataList.add(scoreMap);
}else {
exportAdditionalDataList.add(scoreMap);
}
}
exportDataList.addAll(exportAdditionalDataList);
String fileName = "绩效评价_专家核查_评分明细表";
ExcelDownUtil.setFileName(fileName, response);
int[] mergeColumnIndex = {0};
// 需要从第几行开始合并
int mergeRowIndex = 2;

List<ExcelHead> headList = Lists.newArrayList();
headList.add(new ExcelHead(BizConst.FIRST_INDEX_NAME,BizConst.FIRST_INDEX_TITLE,StrPool.EMPTY));
headList.add(new ExcelHead(BizConst.SECOND_INDEX_NAME,BizConst.SECOND_INDEX_TITLE,StrPool.EMPTY));
headList.add(new ExcelHead(BizConst.THIRD_INDEX_NAME,BizConst.THIRD_INDEX_TITLE,StrPool.EMPTY));
headList.add(new ExcelHead(BizConst.INDEX_SCORE,BizConst.INDEX_SCORE_TITLE,StrPool.EMPTY));
headList.add(new ExcelHead(BizConst.INDEX_DETAIL,BizConst.INDEX_DETAIL_TITLE,StrPool.EMPTY));
headList.add(new ExcelHead(BizConst.GRADE_DETAIL,BizConst.GRADE_DETAIL_TITLE,StrPool.EMPTY));
headList.add(new ExcelHead(BizConst.SUPPORT_MATERIAL,BizConst.SUPPORT_MATERIAL_TITLE,StrPool.EMPTY));
headList.add(new ExcelHead(BizConst.SELF_APPRAISAL_BASIS,BizConst.SELF_APPRAISAL_BASIS_TITLE,StrPool.EMPTY));
headList.add(new ExcelHead(BizConst.SELF_APPRAISAL_SCORE,BizConst.SELF_APPRAISAL_SCORE_TITLE,StrPool.EMPTY));
for (String reUser : reUserList) {
headList.add(new ExcelHead(reUser + BizConst.RE_APPRAISAL_BASIS,BizConst.RE_APPRAISAL_BASIS_TITLE,StrPool.EMPTY));
headList.add(new ExcelHead(reUser + BizConst.RE_APPRAISAL_SCORE,BizConst.RE_APPRAISAL_SCORE_TITLE,StrPool.EMPTY));
}

for (String verifyUser : verifyUserList) {
headList.add(new ExcelHead(verifyUser + BizConst.VERIFY_BASIS,BizConst.VERIFY_BASIS_TITLE,StrPool.EMPTY));
headList.add(new ExcelHead(verifyUser + BizConst.VERIFY_SCORE,BizConst.VERIFY_SCORE_TITLE,StrPool.EMPTY));
}
headList.add(new ExcelHead(BizConst.IS_ADDITIONAL,BizConst.IS_ADDITIONAL_TITLE,StrPool.EMPTY));

// 数据导出处理函数
try {
response.setCharacterEncoding(CharsetUtil.UTF_8);
response.setContentType(ContentTypeUtils.APPLICATION_EXCEL);
ExcelWriterBuilder writerBuilder = EasyExcel.write();
writerBuilder.file(response.getOutputStream());
writerBuilder.autoCloseStream(true);
writerBuilder.registerWriteHandler(new ExcelSheetVerticalCellStyleStrategy());
writerBuilder.registerWriteHandler(new MultiColumnMergeStrategy(exportDataList.size(),0,1));
writerBuilder.registerWriteHandler(new ExcelFillCellMergeStrategy(mergeRowIndex,mergeColumnIndex));
writerBuilder.head(ExcelUtils.getHead(reUserList,verifyUserList))
.sheet(fileName)
.doWrite(ExcelUtils.convertData(headList, exportDataList));
} catch (IOException e) {
throw new BizException(e.getMessage());
}
}

}

+ 27
- 0
pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/ReAppraisalInfoDTO.java Целия файл

@@ -0,0 +1,27 @@
package com.ningdatech.pmapi.performance.model.dto;

import java.io.Serializable;
import java.math.BigDecimal;

import javax.validation.constraints.NotNull;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
* 应用评价信息
* @return
* @author CMM
* @since 2023/08/08 18:46
*/
@Data
public class ReAppraisalInfoDTO implements Serializable {

private static final long serialVersionUID = 1L;

@ApiModelProperty("复评依据")
private String reAppraisalBasis;

@ApiModelProperty("复评得分")
private BigDecimal reAppraisalScore;
}

+ 2
- 1
pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/ReAppraisalScoreExportDTO.java Целия файл

@@ -2,6 +2,7 @@ package com.ningdatech.pmapi.performance.model.dto;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

import com.alibaba.excel.annotation.ExcelProperty;

@@ -57,7 +58,7 @@ public class ReAppraisalScoreExportDTO implements Serializable {

@ApiModelProperty("复评依据")
@ExcelProperty(value = "复评依据",index = 9)
private String reAppraisalBasis;
private String refAppraisalBasis;

@ApiModelProperty("复评得分")
@ExcelProperty(value = "复评得分",index = 10)


+ 36
- 0
pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/ExcelHead.java Целия файл

@@ -0,0 +1,36 @@
package com.ningdatech.pmapi.performance.model.entity;

/**
* @author CMM
* @since 2023/08/17 21:03
*/

import lombok.Data;

/**
* Excel 导出类 - ExcelHead
*/
@Data
public class ExcelHead<T> {
/**
* 内容里的字段名称
*/
private String fieldName;
/**
* 显示值,一般为中文的
*/
private String title;
/**
* 如果为 null 的值
*/
private T nullValue;
public ExcelHead(String fieldName, String title) {
this.fieldName = fieldName;
this.title = title;
}
public ExcelHead(String fieldName, String title, T nullValue) {
this.fieldName = fieldName;
this.title = title;
this.nullValue = nullValue;
}
}

+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/performance/model/req/PerformanceAppraisalExportReq.java Целия файл

@@ -12,7 +12,7 @@ import lombok.Data;
@Data
public class PerformanceAppraisalExportReq {

@ApiModelProperty("计划名称")
@ApiModelProperty("项目编号")
private String projectCode;

@ApiModelProperty("评价计划Id")


+ 6
- 0
pmapi/src/main/java/com/ningdatech/pmapi/performance/model/req/PerformanceAppraisalListReq.java Целия файл

@@ -48,4 +48,10 @@ public class PerformanceAppraisalListReq extends PagePo {

@ApiModelProperty("评价计划ID")
private Long appraisalId;

@ApiModelProperty("项目类型")
private Integer projectType;

@ApiModelProperty("预算年度")
private Integer projectYear;
}

+ 37
- 0
pmapi/src/main/java/com/ningdatech/pmapi/performance/util/ContentTypeUtils.java Целия файл

@@ -0,0 +1,37 @@
package com.ningdatech.pmapi.performance.util;

/**
* @author CMM
* @since 2023/08/17 21:02
*/

import cn.hutool.core.util.CharsetUtil;
import com.ningdatech.basic.exception.BizException;
import com.wflow.config.ResponseCode;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

/**
* Content-type 工具类
* @return
* @author CMM
* @since 2023/08/17 21:05
*/
public final class ContentTypeUtils {
public static final String CONTENT_DISPOSITION;
public static final String APPLICATION_EXCEL;
static {
CONTENT_DISPOSITION = "Content-Disposition";
APPLICATION_EXCEL = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
}
public static String encode(String fileName) {

try {
return "attachment;filename=" + URLEncoder.encode(fileName, CharsetUtil.UTF_8) + ".xlsx";
} catch (UnsupportedEncodingException e) {
throw new BizException(e.getMessage());
}
}
}


+ 37
- 0
pmapi/src/main/java/com/ningdatech/pmapi/performance/util/ExcelSheetVerticalCellStyleStrategy.java Целия файл

@@ -0,0 +1,37 @@
package com.ningdatech.pmapi.performance.util;

/**
* @author CMM
* @since 2023/08/17 21:01
*/

import com.alibaba.excel.metadata.Head;
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.style.AbstractVerticalCellStyleStrategy;

/**
* excel 样式设置
* @return
* @author CMM
* @since 2023/08/17 21:07
*/
public class ExcelSheetVerticalCellStyleStrategy extends AbstractVerticalCellStyleStrategy {
/**
* 头部样式
*
* @return 样式
*/
@Override
protected WriteCellStyle headCellStyle(Head head) {
return ExcelUtils.writeCellStyle();
}
/**
* 内容样式
*
* @return 样式
*/
@Override
protected WriteCellStyle contentCellStyle(Head head) {
return ExcelUtils.writeCellStyle();
}
}

+ 118
- 0
pmapi/src/main/java/com/ningdatech/pmapi/performance/util/ExcelUtils.java Целия файл

@@ -0,0 +1,118 @@
package com.ningdatech.pmapi.performance.util;

/**
* @author CMM
* @since 2023/08/17 20:59
*/

import java.util.List;
import java.util.Map;

import cn.hutool.core.collection.CollUtil;
import com.ningdatech.pmapi.performance.constant.BizConst;
import org.apache.poi.ss.formula.functions.T;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment;

import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.google.common.collect.Lists;
import com.ningdatech.pmapi.performance.model.entity.ExcelHead;

/**
* excel 工具类
* @return
* @author CMM
* @since 2023/08/17 21:07
*/
public class ExcelUtils {
/**
* 构造excel基础样式
*
* @return 样式
*/
public static WriteCellStyle writeCellStyle() {
WriteCellStyle writeCellStyle = new WriteCellStyle();
writeCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
writeCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
writeCellStyle.setWrapped(true);
writeCellStyle.setBorderBottom(BorderStyle.THIN);
writeCellStyle.setBorderLeft(BorderStyle.THIN);
writeCellStyle.setBorderRight(BorderStyle.THIN);
writeCellStyle.setBorderTop(BorderStyle.THIN);
return writeCellStyle;
}

/**
* 表内容数据转换
*
* @param headList 表头数据
* @param dataList 表内容数据转换
* @return List<List<Object>>
*/
public static List<List<Object>> convertData(List<ExcelHead> headList, List<Map<String, Object>> dataList) {
List<List<Object>> result = Lists.newArrayList();
//对 dataList 转为 easyExcel 的数据格式
for (Map<String, Object> data : dataList) {
List<Object> row = Lists.newArrayList();
for (ExcelHead<T> h : headList) {
Object o = data.get(h.getFieldName());
//需要对null的处理,转换为空字符串
row.add(handler(o, h.getNullValue()));
}
result.add(row);
}
return result;
}
/**
* null 值处理
* @param nullValue 默认值
* @return 默认值
*/
private static Object handler(Object o, Object nullValue) {
return o != null ? o : nullValue;
}

public static List<List<String>> getHead(List<String> reUserList,List<String> verifyUserList) {

List<List<String>> list = Lists.newArrayList();
list.add(Lists.newArrayList(BizConst.FIRST_INDEX_TITLE));
list.add(Lists.newArrayList(BizConst.SECOND_INDEX_TITLE));
list.add(Lists.newArrayList(BizConst.THIRD_INDEX_TITLE));
list.add(Lists.newArrayList(BizConst.INDEX_SCORE_TITLE));
list.add(Lists.newArrayList(BizConst.INDEX_DETAIL_TITLE));
list.add(Lists.newArrayList(BizConst.GRADE_DETAIL_TITLE));
list.add(Lists.newArrayList(BizConst.SUPPORT_MATERIAL_TITLE));
list.add(Lists.newArrayList(BizConst.SELF_APPRAISAL_BASIS_TITLE));
list.add(Lists.newArrayList(BizConst.SELF_APPRAISAL_SCORE_TITLE));
if (CollUtil.isNotEmpty(reUserList)) {
List<String> reUserHead = Lists.newArrayList();
reUserHead.add(BizConst.RE_APPRAISAL_BASIS_TITLE);
reUserHead.add(BizConst.RE_APPRAISAL_SCORE_TITLE);
for (String reUser : reUserList) {
for (String h : reUserHead) {
List<String> reUsers = Lists.newArrayList();
reUsers.add(reUser + BizConst.RE_APPRAISAL);
reUsers.add(h);
list.add(reUsers);
}
}
}

if (CollUtil.isNotEmpty(verifyUserList)) {
List<String> verifyUserHead = Lists.newArrayList();
verifyUserHead.add(BizConst.VERIFY_BASIS_TITLE);
verifyUserHead.add(BizConst.VERIFY_SCORE_TITLE);
for (String verifyUser : reUserList) {
for (String h : verifyUserHead) {
List<String> reUsers = Lists.newArrayList();
reUsers.add(verifyUser + BizConst.VERIFY);
reUsers.add(h);
list.add(reUsers);
}
}
}
list.add(Lists.newArrayList(BizConst.IS_ADDITIONAL_TITLE));
return list;
}
}

Loading…
Отказ
Запис