2021与蓝度共同重构项目,服务端
liuhaonan
2022-05-16 3b8877b6d8c13e37f8c7769282a2751b0faeb499
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;
/**
@@ -228,6 +227,20 @@
            }
        }
        /**
         * 服务端批量控灯日志记录开始
         */
        String content = "{控灯请求:" + paramList.toString()
                + ", 控灯结果:" + resultList.toString() + "}";
        List<String> codeList = new ArrayList<>();
        for (LightControlParam bean : paramList) {
            codeList.add(bean.getDeviceCode());
        }
        StoreOperationRecordsUtils.storeOperationData(codeList, null, "服务端批量控灯", content);
        /**
         * 服务端批量控灯日志记录结束
         */
        return resultList;
    }
@@ -280,9 +293,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 +307,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 +367,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 +377,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 +713,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;
    }