| | |
| | | checkScores = scoreMapper.selectCheckScoreMap(checkScore); |
| | | } |
| | | } |
| | | //分数保留一位小数 |
| | | checkScores.stream().forEach(item -> item.setScore(item.getScore().setScale(3, RoundingMode.HALF_UP))); |
| | | checkScores.stream().forEach(item -> item.setScore(item.getScore().setScale(4, RoundingMode.HALF_UP))); |
| | | 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); |
| | |
| | | if (!hasCar){ |
| | | CheckScore car = new CheckScore(); |
| | | car.setExamineCategory((short) 2); |
| | | car.setScore(new BigDecimal("0.00")); |
| | | car.setScore(new BigDecimal("0.000")); |
| | | tempList.add(car); |
| | | } |
| | | if (!hasFace){ |
| | | CheckScore face = new CheckScore(); |
| | | face.setExamineCategory((short) 3); |
| | | face.setScore(new BigDecimal("0.00")); |
| | | face.setScore(new BigDecimal("0.000")); |
| | | tempList.add(face); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public Map<String, Map<String, Object>> dashboard(DashboardQuery dashboardQuery) { |
| | | Date now = new Date(); |
| | | |
| | | // Calendar cal = Calendar.getInstance(); |
| | | // |
| | | //// 2. 设置为今年10月12号 00:00:00(清除时分秒,避免当前时间干扰) |
| | | // cal.set(Calendar.MONTH, Calendar.OCTOBER); // 10月(用常量更直观,避免记0基) |
| | | //// cal.set(Calendar.MONTH, 9); // 也可以用数字9(不推荐,可读性差) |
| | | // cal.set(Calendar.DAY_OF_MONTH, 12); // 日期设为12号 |
| | | // cal.set(Calendar.HOUR_OF_DAY, 12); // 小时设为0(24小时制) |
| | | // cal.set(Calendar.MINUTE, 0); // 分钟设为0 |
| | | // cal.set(Calendar.SECOND, 0); // 秒设为0 |
| | | // cal.set(Calendar.MILLISECOND, 0); // 毫秒设为0 |
| | | // |
| | | //// 3. 转成Date对象 |
| | | // Date now = cal.getTime(); |
| | | |
| | | |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | dashboardQuery.setStartTime(format.format(DateUtils.getDayStart(now))); |
| | | dashboardQuery.setEndTime(format.format(DateUtils.getDayEnd(now))); |
| | |
| | | Map<String, Object> map = resultMap.get(checkScore.getDeptName()); |
| | | BigDecimal score = checkScore.getScore(); |
| | | // 核心逻辑:原始score ×10 → 保留两位小数 → 拼接百分号 |
| | | BigDecimal scoreMultiplied = score.multiply(new BigDecimal("10")); // 4.6160 ×10 = 46.160 |
| | | BigDecimal scoreMultiplied = score.multiply(new BigDecimal("100")); |
| | | BigDecimal scoreWithTwoDecimals = scoreMultiplied.setScale(2, RoundingMode.HALF_UP); // 保留两位小数:46.16 |
| | | String formattedScore = scoreWithTwoDecimals + "%"; // 拼接百分号:46.16% |
| | | |