From 52cbdcf985d429f11f752e9c17f863fe28fb61ac Mon Sep 17 00:00:00 2001
From: jinpengyong <jpy123456>
Date: Tue, 26 Oct 2021 14:24:02 +0800
Subject: [PATCH] 账号过期code ,msg添加

---
 screen-job/src/main/java/com/moral/api/service/impl/HistoryHourlyServiceImpl.java |   52 +++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 45 insertions(+), 7 deletions(-)

diff --git a/screen-job/src/main/java/com/moral/api/service/impl/HistoryHourlyServiceImpl.java b/screen-job/src/main/java/com/moral/api/service/impl/HistoryHourlyServiceImpl.java
index 8f5f0b5..7fe292a 100644
--- a/screen-job/src/main/java/com/moral/api/service/impl/HistoryHourlyServiceImpl.java
+++ b/screen-job/src/main/java/com/moral/api/service/impl/HistoryHourlyServiceImpl.java
@@ -2,6 +2,7 @@
 
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.moral.api.config.mybatis.MybatisPlusConfig;
 import com.moral.api.entity.HistoryHourly;
 import com.moral.api.entity.Sensor;
 import com.moral.api.mapper.HistoryHourlyMapper;
@@ -10,9 +11,11 @@
 import com.moral.api.service.SensorService;
 import com.moral.constant.Constants;
 import com.moral.constant.RedisConstants;
+import com.moral.constant.SeparateTableType;
 import com.moral.util.AmendUtils;
 import com.moral.util.DateUtils;
 
+import com.moral.util.MybatisPLUSUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
@@ -116,14 +119,14 @@
                 .collect(Collectors.groupingBy(o -> (String) o.get("mac")));
 
         //���������������������������
-        List<HistoryHourly> insertData = new ArrayList<>();
+        List<Map<String, Object>> insertData = new ArrayList<>();
 
         data.forEach((key, value) -> {
-            HistoryHourly historyHourly = new HistoryHourly();
-            historyHourly.setMac(key);
-            historyHourly.setTime(end);
-            Map<String, Object> jsonMap = new HashMap<>();
+            Map<String, Object> historyHourly = new HashMap<>();
+            historyHourly.put("mac", key);
+            historyHourly.put("time", end);
 
+            Map<String, Object> jsonMap = new HashMap<>();
             Map<String, Object> map = new HashMap<>();
             map.put("data", value);
             map.put("type", "hour");
@@ -211,8 +214,8 @@
                     }
                 }
             });
-            historyHourly.setValue(JSONObject.toJSONString(jsonMap));
-            historyHourly.setVersion((Integer) value.get(0).get("version"));
+            historyHourly.put("version", value.get(0).get("version"));
+            historyHourly.put("value", JSONObject.toJSONString(jsonMap));
             insertData.add(historyHourly);
         });
 
@@ -224,4 +227,39 @@
     public List<Map<String, Object>> selectDailyData(Map<String, Object> params) {
         return historyHourlyMapper.selectDailyData(params);
     }
+
+    /**
+     * @Description: ���������������������������mac���������
+     * @Param: [mac, startDate, endDate]
+     * @return: java.util.List<com.moral.api.entity.HistoryHourly>
+     * @Author: ���������
+     * @Date: 2021/9/23
+     */
+    @Override
+    public List<HistoryHourly> getValueByMacAndTime(String mac, Date startDate, Date endDate){
+        QueryWrapper<HistoryHourly> wrapper = new QueryWrapper<>();
+        wrapper.eq("mac",mac);
+        wrapper.between("time",startDate,endDate);
+        List<String> tableNames = MybatisPLUSUtils.getTableNamesByWrapper(startDate, endDate, SeparateTableType.MONTH);
+        List<HistoryHourly> datas = multiTableQuery(wrapper, tableNames);
+        return datas;
+    }
+
+    /**
+     * @Description: ������������������������������������������������wrapper���������������
+     * @Param: [wrapper, tableNames]
+     * @return: java.util.List<com.moral.api.entity.HistoryHourly>
+     * @Author: ���������
+     * @Date: 2021/9/23
+     */
+    private List<HistoryHourly> multiTableQuery(QueryWrapper<HistoryHourly> wrapper,List<String> tableNames){
+        List<HistoryHourly> result = new ArrayList<>();
+        for (String tableName : tableNames) {
+            MybatisPlusConfig.tableName.set(tableName);
+            List<HistoryHourly> datas = historyHourlyMapper.selectList(wrapper);
+            result.addAll(datas);
+        }
+        MybatisPlusConfig.tableName.remove();
+        return result;
+    }
 }

--
Gitblit v1.8.0