| | |
| | | // } |
| | | |
| | | List<CheckScore> checkScores = scoreMapper.selectCheckScoreMap(checkScore); |
| | | |
| | | log.error("打印:{}",checkScores); |
| | | // 如果数据为空,则查询之前的数据 |
| | | if (CollectionUtils.isEmpty(checkScores) && (query.getStartDate() ==null || query.getStartDate() ==null)) { |
| | | CheckScore one = scoreMapper.getLast(checkScore); |
| | |
| | | } |
| | | //分数保留一位小数 |
| | | 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)); |
| | | for (Map.Entry<Long, List<CheckScore>> entry : map.entrySet()) { |
| | | List<CheckScore> tempList = getCheckScores(entry); |
| | | // 迭代结束后,将新元素添加到原始列表中 |
| | | entry.getValue().addAll(tempList); |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | private List<CheckScore> getCheckScores(Map.Entry<Long, List<CheckScore>> entry) { |
| | | List<CheckScore> tempList = new ArrayList<>(); // 临时存储需要添加的元素 |
| | | |
| | | boolean hasFace = false; |
| | | boolean hasCar = false; |
| | | for (int i =0;i <entry.getValue().size();i++) { |
| | | CheckScore checkScore = entry.getValue().get(i); |
| | | if (checkScore.getExamineCategory() == 2){ |
| | | hasCar = true; |
| | | }else if (checkScore.getExamineCategory() == 3){ |
| | | hasFace = true; |
| | | } |
| | | } |
| | | if (!hasCar){ |
| | | CheckScore car = new CheckScore(); |
| | | car.setExamineCategory((short) 2); |
| | | car.setScore(new BigDecimal("0.0")); |
| | | tempList.add(car); |
| | | } |
| | | if (!hasFace){ |
| | | CheckScore face = new CheckScore(); |
| | | face.setExamineCategory((short) 3); |
| | | face.setScore(new BigDecimal("0.0")); |
| | | tempList.add(face); |
| | | } |
| | | |
| | | return tempList; |
| | | } |
| | | |
| | | private void getCheckScore(CheckScore checkScore) { |