longz
2026-07-21 52d8968190b5757ad549bcfe38ecf8083fe873a6
fix: 修正企业充电间隔计算精度
1个文件已修改
12 ■■■■■ 已修改文件
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
@@ -3069,16 +3069,16 @@
        if (times == null || times.size() < 2) {
            return BigDecimal.ZERO;
        }
        long totalMinutes = 0L;
        long totalSeconds = 0L;
        for (int i = 1; i < times.size(); i++) {
            long minutes = ChronoUnit.MINUTES.between(times.get(i - 1), times.get(i));
            if (minutes > 0) {
                totalMinutes += minutes;
            long seconds = Duration.between(times.get(i - 1), times.get(i)).getSeconds();
            if (seconds > 0) {
                totalSeconds += seconds;
            }
        }
        return BigDecimal.valueOf(totalMinutes)
        return BigDecimal.valueOf(totalSeconds)
                .divide(BigDecimal.valueOf(times.size() - 1L), 4, RoundingMode.HALF_UP)
                .divide(BigDecimal.valueOf(60), 2, RoundingMode.HALF_UP);
                .divide(BigDecimal.valueOf(3600), 2, RoundingMode.HALF_UP);
    }
    @Override