public class ComputeResultExportDTO {

'/**
 * 考核测评id。
 */'
private String examineEvaluationId;

'/**
 * 员工编号。
 */'
private String empCode;

'/**
 * 员工名称。
 */'
private String empName;

'/**
 * 部门名称。
 */'
private String deptName;

'/**
 * 权重级别名称。
 */'
private String levelName;

'/**
 * 权重级别分组。
 */'
private String levelGroup;

'/**
 * 考核人权重。
 */'
private BigDecimal examineWight;

'/**
 * 权重组名称。
 */'
private String weightGroupName;

'/**
 * 总分。
 */'
private BigDecimal totalScore;

'/**
 * 廉洁测评总分。
 */'
private BigDecimal incorruptibleTotalScore;

'/**
 * 评分项分数(5分制)。
 */'
private BigDecimal assessScore;

'/**
 * 评分项分数(百分制)。
 */'
private BigDecimal centennialScore;

'/**
 * 评分项。
 */'
private String evaluationDimension;

'/**
 * 评分项权重。
 */'
private BigDecimal scoreWight;

'/**
 * 维度层级。
 */'
private Integer dimensionLevel;

'/**
 * 权重。
 */'
private BigDecimal levelWeight;

'/**
 * 评分项Id。
 */'
private String scoreItemId;

'/**
 * 表格名称。
 */'
private String tableName;

'/**
 * 表格名称。
 */'
private int tableSort;

'/**
 * 建议等级。
 */'
private String suggestedLevel;

'/**
 * 身份。
 */'
private String identity;

}

final List scoreResult ; 先按 'empName-empCode' 分组,再按 levelName 分组,使用 LinkenHasMap 保证有序,使用 stream

scoreResult.stream() .collect(Collectors.groupingBy(dto -> dto.getEmpName() + "-" + dto.getEmpCode(), LinkedHashMap::new, Collectors.groupingBy(ComputeResultExportDTO::getLevelName, LinkedHashMap::new, Collectors.toList()))) .entrySet().stream() .map(empGroup -> { Map<String, List> levelGroup = empGroup.getValue(); List<Map<String, Object>> levelGroupList = levelGroup.entrySet().stream() .map(levelEntry -> { Map<String, Object> levelGroupMap = new HashMap<>(); levelGroupMap.put("levelName", levelEntry.getKey()); levelGroupMap.put("results", levelEntry.getValue()); return levelGroupMap; }) .collect(Collectors.toList()); Map<String, Object> empGroupMap = new HashMap<>(); empGroupMap.put("empName", empGroup.getKey().split("-")[0]); empGroupMap.put("empCode", empGroup.getKey().split("-")[1]); empGroupMap.put("levelGroups", levelGroupList); return empGroupMap; }) .collect(Collectors.toList());

Java DTO for Computing and Exporting Result Data

原文地址: https://www.cveoy.top/t/topic/lR9v 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录