From ee8bb47024e9ef5a585a5f4d61d1ab236c9d4341 Mon Sep 17 00:00:00 2001
From: cjl <909710561@qq.com>
Date: Tue, 23 Apr 2024 15:05:33 +0800
Subject: [PATCH] fix:因子相关性比较均值

---
 screen-api/src/main/java/com/moral/api/service/impl/HistoryHourlyServiceImpl.java |   62 ++++++++++++++++++++++++++++++
 1 files changed, 61 insertions(+), 1 deletions(-)

diff --git a/screen-api/src/main/java/com/moral/api/service/impl/HistoryHourlyServiceImpl.java b/screen-api/src/main/java/com/moral/api/service/impl/HistoryHourlyServiceImpl.java
index 745c803..b675bc2 100644
--- a/screen-api/src/main/java/com/moral/api/service/impl/HistoryHourlyServiceImpl.java
+++ b/screen-api/src/main/java/com/moral/api/service/impl/HistoryHourlyServiceImpl.java
@@ -5,6 +5,7 @@
 import com.moral.api.entity.*;
 import com.moral.api.mapper.ServicesScopeDeviceMapper;
 import com.moral.api.mapper.ServicesScopeMapper;
+import com.moral.api.pojo.vo.historyMonthly.HistoryResultVo;
 import com.moral.api.vo.HistoryHourlyVo;
 import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -765,7 +766,17 @@
         List<HistoryHourly> datas = multiTableQuery(mapParams, tableNames);
         return datas;
     }
-
+    @Override
+    public List<HistoryResultVo> getAvgValueByMacAndTime(List<String> mac,String type, Date startDate, Date endDate) {
+        Map<String, Object> mapParams = new HashMap<>();
+        mapParams.put("startTime",startDate);
+        mapParams.put("endTime",endDate);
+        mapParams.put("type",type);
+        mapParams.put("macs",mac);
+        List<String> tableNames = MybatisPLUSUtils.getTableNamesByWrapper(startDate, endDate, SeparateTableType.MONTH);
+        List<HistoryResultVo> datas = multiTableQueryAvg(mapParams, tableNames);
+        return datas;
+    }
     @Override
     public List<HistoryHourly> getValueByMacs(List<String> macs, String time) {
         Map<String, Object> mapParams = new HashMap<>();
@@ -858,6 +869,34 @@
         }
         return result;
     }
+
+    private List<HistoryResultVo> multiTableQueryAvg(Map<String, Object> params, List<String> tableNames) {
+        List<HistoryResultVo> result = new ArrayList<>();
+        for (String tableName : tableNames) {
+            params.put("table",tableName);
+            List<HistoryResultVo> datas = historyHourlyMapper.listAvgResult(params);
+            result.addAll(datas);
+        }
+        return result;
+    }
+
+    /**
+     * @Description: ������������������������������������������������wrapper���������������
+     * @Param: [wrapper, tableNames]
+     * @return: java.util.List<com.moral.api.entity.HistoryHourly>
+     * @Author: ���������
+     * @Date: 2021/9/23
+     */
+    private List<HistoryMinutely> HistoryMinutelyQuery(Map<String, Object> params, List<String> tableNames) {
+        List<HistoryMinutely> result = new ArrayList<>();
+        for (String tableName : tableNames) {
+            params.put("table",tableName);
+            List<HistoryMinutely> historyMinutelies = historyHourlyMapper.HistoryMinutelyQuery(params);
+            result.addAll(historyMinutelies);
+        }
+        return result;
+    }
+
     private List<HistoryHourly> multiTableQueryLike(Map<String, Object> params, List<String> tableNames) {
         List<HistoryHourly> result = new ArrayList<>();
         for (String tableName : tableNames) {
@@ -920,4 +959,25 @@
         }
         return true;
     }
+
+    /**
+     * @param mac
+     * @param startDate
+     * @param endDate
+     * @Description: ������������mac���������������������������������
+     * @Param: [mac, startDate, endDate]
+     * @return: java.util.Map<java.lang.String, com.moral.api.entity.HistoryDaily>
+     * @Author: ���������
+     * @Date: 2021/9/26
+     */
+    @Override
+    public List<HistoryMinutely> getHistoryMinutely(String mac, Date startDate, Date endDate) {
+        Map<String, Object> mapParams = new HashMap<>();
+        mapParams.put("startDate",startDate);
+        mapParams.put("endDate",endDate);
+        mapParams.put("mac",mac);
+        List<String> tableNames = MybatisPLUSUtils.getTableNamesByWrapper(startDate, endDate, SeparateTableType.MONTH);
+        List<HistoryMinutely> datas = HistoryMinutelyQuery(mapParams, tableNames);
+        return datas;
+    }
 }

--
Gitblit v1.8.0