zxl
2025-04-17 b85a7f932b9d789a2e9bdb36e366c36c2e1eb3cc
查询考核成绩为null,为前端添加数据默认为0
1个文件已修改
29 ■■■■■ 已修改文件
ycl-server/src/main/java/com/ycl/platform/service/impl/CheckScoreServiceImpl.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-server/src/main/java/com/ycl/platform/service/impl/CheckScoreServiceImpl.java
@@ -167,7 +167,7 @@
//        }
        List<CheckScore> checkScores = scoreMapper.selectCheckScoreMap(checkScore);
        log.error("打印:{}",checkScores);
        // 如果数据为空,则查询之前的数据
        if (CollectionUtils.isEmpty(checkScores) && (query.getStartDate() ==null || query.getStartDate() ==null)) {
            CheckScore one = scoreMapper.getLast(checkScore);
@@ -180,7 +180,32 @@
        }
        //分数保留一位小数
        checkScores.stream().forEach(item -> item.setScore(item.getScore().setScale(1, RoundingMode.HALF_UP)));
        return checkScores.stream().collect(Collectors.groupingBy(CheckScore::getDeptId));
        Map<Long, List<CheckScore>> map = checkScores.stream().collect(Collectors.groupingBy(CheckScore::getDeptId));
        log.error("map :{}",map);
        for (Map.Entry<Long, List<CheckScore>> entry : map.entrySet()) {
            List<CheckScore> tempList = new ArrayList<>(); // 临时存储需要添加的元素
            Iterator<CheckScore> iterator = entry.getValue().iterator();
            while (iterator.hasNext()) {
                CheckScore listCheckScore = iterator.next();
                if (listCheckScore.getExamineCategory() == 1 && entry.getValue().size() == 1) {
                    CheckScore face = new CheckScore();
                    face.setExamineCategory((short) 2);
                    face.setScore(new BigDecimal("0.0"));
                    CheckScore car = new CheckScore();
                    car.setExamineCategory((short) 3);
                    car.setScore(new BigDecimal("0.0"));
                    tempList.add(face);
                    tempList.add(car);
                }
            }
            // 迭代结束后,将新元素添加到原始列表中
            entry.getValue().addAll(tempList);
        }
        return map;
    }
    private void getCheckScore(CheckScore checkScore) {