你可以使用forEach方法来遍历流中的元素,并在遍历过程中执行一些操作。下面是使用流的示例代码:

final List<ComputeResultExportDTO> computeResultExportDTOS = new ArrayList<>();
levelSubtotal.forEach((empNameAndCode, scoreItemLevelSubtotal) -> {
    scoreItemLevelSubtotal.forEach((levelName, bigDecimals) -> {
        final String id = IdUtil.fastUUID();
        bigDecimals.forEach(bigDecimal -> {
            final ComputeResultExportDTO computeResultExportDTO = new ComputeResultExportDTO();
            computeResultExportDTO.setExamineEvaluationId(id);
            final String[] empNameAndCodes = StringUtils.split(empNameAndCode, Constants.SPLIT_FLAG);
            computeResultExportDTO.setEmpCode(empNameAndCodes[1]);
            computeResultExportDTO.setEmpName(empNameAndCodes[0]);
            computeResultExportDTO.setLevelName("级别小计");
            computeResultExportDTO.setLevelGroup(levelName);
            computeResultExportDTOS.add(computeResultExportDTO);
        });
    });
});

return computeResultExportDTOS;

在上面的代码中,使用了两层嵌套的forEach方法来遍历levelSubtotalscoreItemLevelSubtotal的键值对,并使用bigDecimals.forEach方法遍历bigDecimals列表中的元素。在遍历过程中创建了ComputeResultExportDTO对象并设置其属性,最后将对象添加到computeResultExportDTOS列表中

final ListComputeResultExportDTO computeResultExportDTOS = new ArrayList; for final String empNameAndCode levelSubtotalkeySet final MapString ListBigDecimal scoreItemLevelSubtotal

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

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