2021与蓝度共同重构项目,服务端
liuhaonan
2022-05-16 c2e93e1d046878fab50eb5379470baff822b493e
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightService.java
@@ -41,10 +41,9 @@
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
/**
@@ -280,9 +279,13 @@
            }
        }
        Integer week = now.getDayOfWeek().getValue();
        Map map = new HashMap();
        //获取当前星期几 1-7
        int week = now.getDayOfWeek().getValue();
        Map map = new LinkedHashMap();
        //获取日期 精确到天
        LocalDateTime localDateTime = now.with(LocalTime.MIN);
        for (int i = 1; i < 8; i++) {
@@ -290,7 +293,8 @@
            if (week < 1) {
                week = 7;
            }
            map.put(i, getlist(week));
            String format = localDateTime.minusDays(i).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
            map.put(localDateTime.minusDays(i).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")), getlist(week));
        }
@@ -349,7 +353,9 @@
        Integer week = now.getDayOfWeek().getValue();
        Map map = new HashMap();
        Map map = new LinkedHashMap();
        //获取当前日期  格式为yyyy-MM-dd
        LocalDateTime localDateTime = now.with(LocalTime.MIN);
        for (int i = 1; i < 8; i++) {
@@ -357,7 +363,7 @@
            if (week < 1) {
                week = 7;
            }
            map.put(i, getlistEnergy(week));
            map.put(localDateTime.minusDays(i).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")), getlistEnergy(week));
        }
@@ -693,11 +699,11 @@
            min = 0;
        }
        //计算时长
        BigDecimal totalTime = BigDecimal.valueOf(hour*60+min);
        BigDecimal totalTime = BigDecimal.valueOf(hour * 60 + min);
        //计算节能率 ( (1-v1.getBrightness()/100)*totalTime/3600 )   保留两位小数
        BigDecimal energySaving = BigDecimal.valueOf((1 - v1.getBrightness() / 100) * totalTime.doubleValue() / 3600).setScale(2, BigDecimal.ROUND_HALF_UP);
        System.out.println(energySaving+"节能率");
        System.out.println(energySaving + "节能率");
        return energySaving;
    }