From 42f9c8cf31cc8a694c6478b12c832c1991bf35b7 Mon Sep 17 00:00:00 2001
From: jinpengyong <jpy123456>
Date: Mon, 21 Aug 2023 15:58:10 +0800
Subject: [PATCH] chore:测试提交

---
 screen-api/src/main/java/com/moral/api/service/impl/DeviceServiceImpl.java |  442 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 427 insertions(+), 15 deletions(-)

diff --git a/screen-api/src/main/java/com/moral/api/service/impl/DeviceServiceImpl.java b/screen-api/src/main/java/com/moral/api/service/impl/DeviceServiceImpl.java
index 561c8b6..0a1b3c9 100644
--- a/screen-api/src/main/java/com/moral/api/service/impl/DeviceServiceImpl.java
+++ b/screen-api/src/main/java/com/moral/api/service/impl/DeviceServiceImpl.java
@@ -1,25 +1,33 @@
 package com.moral.api.service.impl;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.moral.api.entity.Device;
-import com.moral.api.entity.Sensor;
+import com.moral.api.config.mybatis.MybatisPlusConfig;
+import com.moral.api.entity.*;
 import com.moral.api.mapper.DeviceMapper;
+import com.moral.api.mapper.HistoryFiveMinutelyMapper;
+import com.moral.api.mapper.HistoryHourlyMapper;
+import com.moral.api.mapper.OrganizationUnitAlarmMapper;
+import com.moral.api.mapper.UnitConversionMapper;
 import com.moral.api.service.DeviceService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.moral.api.service.SensorService;
+import com.moral.api.service.UnitConversionService;
 import com.moral.constant.Constants;
 import com.moral.constant.RedisConstants;
+import com.moral.constant.SeparateTableType;
 import com.moral.util.DateUtils;
 
+import com.moral.util.MybatisPLUSUtils;
+import org.apache.kafka.streams.state.internals.metrics.Sensors;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
+import org.springframework.util.ObjectUtils;
 
-import java.util.ArrayList;
-
-import java.util.HashMap;
-
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -38,16 +46,46 @@
     @Autowired
     private RedisTemplate redisTemplate;
 
+    @Autowired
+    OrganizationUnitAlarmMapper organizationUnitAlarmMapper;
+
+    @Autowired
+    SensorService sensorService;
+
+    @Autowired
+    UnitConversionService unitConversionService;
+
+    @Autowired
+    HistoryHourlyMapper historyHourlyMapper;
+
+    @Autowired
+    HistoryFiveMinutelyMapper historyFiveMinutelyMapper;
+
     @Override
     public List<Device> getDevicesByMonitorPointId(Integer monitorPointId) {
         QueryWrapper<Device> wrapper = new QueryWrapper();
         wrapper.eq("monitor_point_id", monitorPointId);
         wrapper.eq("is_delete", Constants.NOT_DELETE);
+        wrapper.orderByAsc("dev_num");
         return deviceMapper.selectList(wrapper);
     }
 
     @Override
     public Map<String, Object> getSensorsByMac(Map<String, Object> params) {
+        List<String> sensorCodes = Arrays.asList(Constants.SENSOR_CODE_PM25
+                , Constants.SENSOR_CODE_PM10
+                , Constants.SENSOR_CODE_SO2
+                , Constants.SENSOR_CODE_NO2
+                , Constants.SENSOR_CODE_CO
+                , Constants.SENSOR_CODE_O3
+                , Constants.SENSOR_CODE_TEMP
+                , "a01002"
+                , Constants.SENSOR_CODE_WIND_SPEED
+                , Constants.SENSOR_CODE_WIND_DIR
+                , "a01006"
+                , "a00e12"
+        );
+
         //������mac
         List<String> macs = (List<String>) params.remove("macs");
         List<Map<String, Object>> elementLists = new ArrayList<>();
@@ -65,13 +103,21 @@
             elementLists.add(map);
         }
 
-        Map<String, Object> map = elementLists.parallelStream()
+        Map<String, Object> map = elementLists.stream()
                 .filter(elementList -> elementList.size() != 0)
                 .reduce((a, b) -> {
                     a.keySet().retainAll(b.keySet());
                     return a;
                 }).orElse(new HashMap<>());
-        return map;
+        Map<String, Object> result = new LinkedHashMap<>();
+        sensorCodes.forEach(sensorCode -> {
+            Object o = map.remove(sensorCode);
+            if (o != null) {
+                result.put(sensorCode, o);
+            }
+        });
+        result.putAll(map);
+        return result;
     }
 
     @Override
@@ -84,33 +130,36 @@
         queryWrapper.select("mac", "name").in("mac", macs);
         List<Device> devices = deviceMapper.selectList(queryWrapper);
 
-
         //������������
         List<String> times = (List<String>) params.remove("times");
         //������code
         String sensorCode = params.get("sensorCode").toString();
         String end;
         String timeUnits;
-
+        String dateFormat;
         //���������������,time=data
         List<Map<String, Object>> result = new ArrayList<>();
 
         for (String start : times) {
             if ("hour".equals(type)) {
                 end = DateUtils.getDateAddDay(start, 1);
-                timeUnits = "hourly";
+                String yearAndMonth = DateUtils.dateToDateString(DateUtils.getDate(start, DateUtils.yyyy_MM_dd_EN), DateUtils.yyyyMM_EN);
+                timeUnits = "hourly_" + yearAndMonth;
+                dateFormat = "%Y-%m-%d %H";
             } else if ("day".equals(type)) {
                 end = DateUtils.getDateAddMonth(start, 1);
                 timeUnits = "daily";
+                dateFormat = "%Y-%m-%d";
             } else {
                 end = DateUtils.getDateAddYear(start, 1);
                 timeUnits = "monthly";
+                dateFormat = "%Y-%m";
             }
             params.put("timeUnits", timeUnits);
             params.put("start", start);
             params.put("end", end);
             params.put("macs", macs);
-            params.put("dateFormat", "%Y-%m-%d %H:%i:%s");
+            params.put("dateFormat", dateFormat);
             //���������������������������������
             List<Map<String, Object>> list = deviceMapper.getTrendChartData(params);
 
@@ -121,7 +170,7 @@
                 for (Device device : devices) {
                     Map<String, Object> valueMap = new HashMap<>();
                     valueMap.put("name", device.getName());
-                    valueMap.put("sensorValue", "");
+                    valueMap.put("sensorValue", "0.0");
                     for (Map<String, Object> map : list) {
                         Object time = map.get("time");
                         Object sensorValue = map.get(sensorCode);
@@ -139,5 +188,368 @@
         return result;
     }
 
+    @Override
+    public List<Map<String, Object>> getTrendChartDataV2(Map<String, Object> params) {
+        Object type = params.get("type");
+        //������mac
+        List<String> macs = (List<String>) params.remove("macs");
+
+        QueryWrapper<Device> queryWrapper = new QueryWrapper<>();
+        queryWrapper.select("mac", "name").in("mac", macs);
+        List<Device> devices = deviceMapper.selectList(queryWrapper);
+        Map<String,Object> devicesInfo = new HashMap<>();
+        for (Device device:devices) {
+            devicesInfo.put(device.getMac(),device.getName());
+        }
+
+        //������������
+        List<String> times = (List<String>) params.remove("times");
+        String startTime = times.get(0);
+        String endTime = times.get(1);
+        //������code
+        String sensorCode = params.get("sensorCode").toString();
+        String end;
+        String timeUnits;
+        String dateFormat;
+        //���������������,time=data
+        List<Map<String, Object>> result = new ArrayList<>();
+        List<Map<String, Object>> list = new ArrayList<>();
+        if ("hour".equals(type)) {
+            Date startDate = DateUtils.getDate(startTime,DateUtils.yyyy_MM_dd_HH_EN);
+            Date endDate = DateUtils.getDate(endTime,DateUtils.yyyy_MM_dd_HH_EN);
+            List<String> tableNames = MybatisPLUSUtils.getTableNamesByWrapper(startDate, endDate, SeparateTableType.MONTH);
+            for (String mac:macs) {
+                QueryWrapper<HistoryHourly> wrapper = new QueryWrapper<>();
+                wrapper.eq("mac", mac);
+                wrapper.between("time", startDate, endDate);
+                List<HistoryHourly> historyHourlies = multiTableQuery(wrapper, tableNames);
+                historyHourlies = historyHourlies.stream().distinct().collect(Collectors.toList());
+                List<HistoryHourly> distinctHistoryHourlies = new ArrayList<>();
+                Map<String, Object> disMap = new HashMap<>();
+                for (HistoryHourly historyHourly:historyHourlies) {
+                    Date time = historyHourly.getTime();
+                    String timeStr = DateUtils.dateToDateString(time,DateUtils.yyyy_MM_dd_HH_mm_ss_EN);
+                    if (!disMap.containsKey(timeStr)){
+                        distinctHistoryHourlies.add(historyHourly);
+                        disMap.put(timeStr,true);
+                    }
+                }
+                for (HistoryHourly historyHourly:distinctHistoryHourlies) {
+                    Map<String,Object> historyHourlyMap = new HashMap<>();
+                    historyHourlyMap.put("mac",mac);
+                    JSONObject value = JSONObject.parseObject(historyHourly.getValue());
+                    Double sensorValue = Double.parseDouble(value.get(sensorCode).toString());
+                    historyHourlyMap.put(sensorCode,sensorValue);
+                    Date time = historyHourly.getTime();
+                    String timeStr = DateUtils.dateToDateString(time, DateUtils.yyyy_MM_dd_HH_EN);
+                    historyHourlyMap.put("time",timeStr);
+                    list.add(historyHourlyMap);
+                }
+            }
+            Date middleDate = DateUtils.getDate(startTime,DateUtils.yyyy_MM_dd_HH_EN);
+            while (DateUtils.compareDateStr(endTime,DateUtils.dateToDateString(middleDate,DateUtils.yyyy_MM_dd_HH_EN),DateUtils.yyyy_MM_dd_HH_EN)<=0){
+                for (String mac:macs) {
+                    boolean flag = true;
+                    for (Map map:list) {
+                        if (map.get("time").equals(DateUtils.dateToDateString(middleDate, DateUtils.yyyy_MM_dd_HH_EN)) && map.get("mac").toString().equals(mac.toString())){
+                            flag = false;
+                        }
+                    }
+                    if (flag){
+                        Map<String,Object> historyHourlyMap = new HashMap<>();
+                        historyHourlyMap.put("mac",mac);
+                        historyHourlyMap.put(sensorCode,"0.0");
+                        historyHourlyMap.put("time",DateUtils.dateToDateString(middleDate,DateUtils.yyyy_MM_dd_HH_EN));
+                        list.add(historyHourlyMap);
+                    }
+                }
+                middleDate = DateUtils.addHours(middleDate,1);
+            }
+        } else if ("day".equals(type)) {
+            end = DateUtils.getDateAddDay(endTime,1);
+            timeUnits = "daily";
+            dateFormat = "%Y-%m-%d";
+            params.put("timeUnits", timeUnits);
+            params.put("start", startTime);
+            params.put("end", end);
+            params.put("macs", macs);
+            params.put("dateFormat", dateFormat);
+            //���������������������������������
+            list = deviceMapper.getTrendChartData(params);
+            Date middleDate = DateUtils.getDate(startTime,DateUtils.yyyy_MM_dd_EN);
+            while (DateUtils.compareDateStr(endTime,DateUtils.dateToDateString(middleDate,DateUtils.yyyy_MM_dd_EN),DateUtils.yyyy_MM_dd_EN)<=0){
+                for (String mac:macs) {
+                    boolean flag = true;
+                    for (Map map:list) {
+                        if (map.get("time").equals(DateUtils.dateToDateString(middleDate, DateUtils.yyyy_MM_dd_EN)) && map.get("mac").toString().equals(mac.toString())){
+                            flag = false;
+                        }
+                    }
+                    if (flag){
+                        Map<String,Object> historyDailyMap = new HashMap<>();
+                        historyDailyMap.put("mac",mac);
+                        historyDailyMap.put(sensorCode,"0.0");
+                        historyDailyMap.put("time",DateUtils.dateToDateString(middleDate,DateUtils.yyyy_MM_dd_EN));
+                        list.add(historyDailyMap);
+                    }
+                }
+                middleDate = DateUtils.addDays(middleDate,1);
+            }
+        } else if ("month".equals(type)){
+            end = DateUtils.getDateAddMonth(endTime, 1);
+            timeUnits = "monthly";
+            dateFormat = "%Y-%m";
+            params.put("timeUnits", timeUnits);
+            params.put("start", startTime);
+            params.put("end", end);
+            params.put("macs", macs);
+            params.put("dateFormat", dateFormat);
+            //���������������������������������
+            list = deviceMapper.getTrendChartData(params);
+            Date middleDate = DateUtils.getDate(startTime,DateUtils.yyyy_MM_EN);
+            while (DateUtils.compareDateStr(endTime,DateUtils.dateToDateString(middleDate,DateUtils.yyyy_MM_EN),DateUtils.yyyy_MM_EN)<=0){
+                for (String mac:macs) {
+                    boolean flag = true;
+                    for (Map map:list) {
+                        if (map.get("time").equals(DateUtils.dateToDateString(middleDate, DateUtils.yyyy_MM_EN)) && map.get("mac").toString().equals(mac.toString())){
+                            flag = false;
+                        }
+                    }
+                    if (flag){
+                        Map<String,Object> historyMonthlyMap = new HashMap<>();
+                        historyMonthlyMap.put("mac",mac);
+                        historyMonthlyMap.put(sensorCode,"0.0");
+                        historyMonthlyMap.put("time",DateUtils.dateToDateString(middleDate,DateUtils.yyyy_MM_EN));
+                        list.add(historyMonthlyMap);
+                    }
+                }
+                middleDate = DateUtils.addMonths(middleDate,1);
+            }
+        }else {
+            Date startDate = DateUtils.getDate(startTime,DateUtils.yyyy_MM_dd_HH_mm_ss_EN);
+            Date endDate = DateUtils.getDate(endTime,DateUtils.yyyy_MM_dd_HH_mm_ss_EN);
+            List<String> tableNames = MybatisPLUSUtils.getTableNamesByWrapper(startDate, endDate, SeparateTableType.MONTH);
+            for (String mac:macs) {
+                QueryWrapper<HistoryFiveMinutely> wrapper = new QueryWrapper<>();
+                wrapper.eq("mac", mac);
+                wrapper.between("time", startDate, endDate);
+                List<HistoryFiveMinutely> HistoryFiveMinutelys = FiveMinuteTableQuery(wrapper, tableNames);
+                HistoryFiveMinutelys = HistoryFiveMinutelys.stream().distinct().collect(Collectors.toList());
+                List<HistoryFiveMinutely> distinctHistoryHourlies = new ArrayList<>();
+                Map<String, Object> disMap = new HashMap<>();
+                for (HistoryFiveMinutely historyFiveMinutely:HistoryFiveMinutelys) {
+                    Date time = historyFiveMinutely.getTime();
+                    String timeStr = DateUtils.dateToDateString(time,DateUtils.yyyy_MM_dd_HH_mm_ss_EN);
+                    if (!disMap.containsKey(timeStr)){
+                        distinctHistoryHourlies.add(historyFiveMinutely);
+                        disMap.put(timeStr,true);
+                    }
+                }
+                for (HistoryFiveMinutely historyFiveMinutely:distinctHistoryHourlies) {
+                    Map<String,Object> historyHourlyMap = new HashMap<>();
+                    historyHourlyMap.put("mac",mac);
+                    JSONObject value = JSONObject.parseObject(historyFiveMinutely.getValue());
+                    if (value.get(sensorCode)==null){
+                        historyHourlyMap.put(sensorCode,0.0);
+                    }else {
+                        Double sensorValue = Double.parseDouble(value.get(sensorCode).toString());
+                        historyHourlyMap.put(sensorCode,sensorValue);
+                    }
+//                    Double sensorValue = Double.parseDouble(value.get(sensorCode).toString());
+//                    historyHourlyMap.put(sensorCode,sensorValue);
+                    Date time = historyFiveMinutely.getTime();
+                    String timeStr = DateUtils.dateToDateString(time, DateUtils.yyyy_MM_dd_HH_mm_ss_EN);
+                    historyHourlyMap.put("time",timeStr);
+                    list.add(historyHourlyMap);
+                }
+            }
+        }
+        for (Map map:list) {
+            String time = map.get("time").toString();
+            Map<String,Object> deviceMap = new HashMap<>();
+            deviceMap.put("name",devicesInfo.get(map.get("mac")));
+            deviceMap.put("sensorValue",map.get(sensorCode));
+            if (result.size()>0){
+                boolean flag = true;
+                for (Map resultMap:result) {
+                    if (resultMap.get("time").toString().equals(time)){
+                        List<Map<String,Object>> deviceData = new ArrayList<>();
+                        deviceData = (List<Map<String,Object>>)resultMap.get("deviceData");
+                        deviceData.add(deviceMap);
+                        Collections.sort(deviceData, (map1,map2) -> {
+                            String name1 = map1.get("name").toString();//name1���������list������������������������
+                            String name2 = map2.get("name").toString(); //name1���������list���������������������������name
+                            return name1.compareTo(name2);
+                        });
+                        resultMap.put("deviceData",deviceData);
+                        //result.add(resultMap);
+                        flag = false;
+                        break;
+                    }
+                }
+                if (flag){
+                    List<Map<String,Object>> deviceData = new ArrayList<>();
+                    deviceData.add(deviceMap);
+                    Collections.sort(deviceData, (map1,map2) -> {
+                        String name1 = map1.get("name").toString();//name1���������list������������������������
+                        String name2 = map2.get("name").toString(); //name1���������list���������������������������name
+                        return name1.compareTo(name2);
+                    });
+                    Map<String,Object> resultMap = new HashMap<>();
+                    resultMap.put("deviceData",deviceData);
+                    resultMap.put("time",time);
+                    result.add(resultMap);
+                }
+            }else {
+                List<Map<String,Object>> deviceData = new ArrayList<>();
+                deviceData.add(deviceMap);
+                Collections.sort(deviceData, (map1,map2) -> {
+                    String name1 = map1.get("name").toString();//name1���������list������������������������
+                    String name2 = map2.get("name").toString(); //name1���������list���������������������������name
+                    return name1.compareTo(name2);
+                });
+                Map<String,Object> resultMap = new HashMap<>();
+                resultMap.put("deviceData",deviceData);
+                resultMap.put("time",time);
+                result.add(resultMap);
+            }
+        }
+        Collections.sort(result, new Comparator<Map<String, Object>>() {
+            public int compare(Map<String, Object> o1, Map<String, Object> o2) {
+                String id1 = (String) o1.get("time");
+                String id2 = (String) o2.get("time");
+                return id1.compareTo(id2);
+            }
+
+        });
+        return result;
+    }
+
+    @Override
+    public Device getDeviceByMac(String mac) {
+        Map<String, Object> deviceMap = (Map<String, Object>) redisTemplate.opsForHash().get(RedisConstants.DEVICE, mac);
+        Device device = JSON.parseObject(JSON.toJSONString(deviceMap), Device.class);
+        //���map������organizationId���monitorPointId������versionId
+        Map<String, Object> organizationMap = (Map<String, Object>) deviceMap.get("organization");
+        Map<String, Object> monitorPointMap = (Map<String, Object>) deviceMap.get("monitorPoint");
+        Map<String, Object> versionMap = (Map<String, Object>) deviceMap.get("version");
+        device.setDeviceVersionId((Integer) versionMap.get("id"));
+        device.setOrganizationId((Integer) organizationMap.get("id"));
+        device.setMonitorPointId((Integer) monitorPointMap.get("id"));
+        //������������������������������������
+        if (ObjectUtils.isEmpty(device)) {
+            return getDeviceByMacFromDB(mac);
+        }
+        return device;
+    }
+
+    @Override
+    public List<Map<String, Object>> getDevicesByOrganizationId(Integer orgId) {
+        //������������������mac
+        List macs = getMacsByOrganizationId(orgId);
+        //���redis������������������������
+        List<Map<String, Object>> result = new ArrayList<>();
+        for (Object mac : macs) {
+            Map<String, Object> map = (Map<String, Object>) redisTemplate.opsForHash().get(RedisConstants.DEVICE, mac.toString());
+            result.add(map);
+        }
+        return result;
+    }
+
+    @Override
+    public List getMacsByOrganizationId(Integer organizationId) {
+        QueryWrapper<Device> queryWrapper = new QueryWrapper<>();
+        queryWrapper.select("mac")
+                .eq("organization_id", organizationId)
+                .eq("is_delete", Constants.NOT_DELETE);
+        return deviceMapper.selectObjs(queryWrapper);
+    }
+
+    @Override
+    public List getMacsByOrgIdAndRegionCode(Integer organizationId, Integer regionCode) {
+        QueryWrapper<Device> queryWrapper = new QueryWrapper<>();
+        queryWrapper.select("mac")
+                .eq("organization_id", organizationId)
+                .eq("is_delete", Constants.NOT_DELETE)
+                .eq("town_code", regionCode);
+        return deviceMapper.selectObjs(queryWrapper);
+    }
+
+    @Override
+    public Device getDeviceUnitAlramInforByMac(String mac) {
+        Device device = (Device) redisTemplate.opsForHash().get(RedisConstants.DEVICE_INFO,mac);
+        if(device==null)
+            return getDeviceUnitAlramInforByMacFromDb(mac);
+        return device;
+    }
+
+    private Device getDeviceUnitAlramInforByMacFromDb(String mac){
+        QueryWrapper<Device> wrapper = new QueryWrapper<>();
+        wrapper.eq("mac",mac);
+        wrapper.eq("is_delete",Constants.NOT_DELETE);
+        Device device = deviceMapper.selectOne(wrapper);
+        if(device==null)
+            return null;
+        QueryWrapper<OrganizationUnitAlarm> unitAlarmQueryWrapper = new QueryWrapper<>();
+        unitAlarmQueryWrapper.eq("organization_id",device.getOrganizationId());
+        unitAlarmQueryWrapper.eq("version_id",device.getDeviceVersionId());
+        unitAlarmQueryWrapper.eq("is_delete",Constants.NOT_DELETE);
+        List<OrganizationUnitAlarm> organizationUnitAlarms = organizationUnitAlarmMapper.selectList(unitAlarmQueryWrapper);
+        Version version = new Version();
+        version.setId(device.getDeviceVersionId());
+        List<Sensor> sensors = new ArrayList<>();
+        for (OrganizationUnitAlarm organizationUnitAlarm : organizationUnitAlarms) {
+            Sensor sensor = sensorService.getSensorByCode(organizationUnitAlarm.getSensorCode());
+            sensor.setUnit(organizationUnitAlarm.getUnitKey());
+            sensor.setShowUnit(organizationUnitAlarm.getShowUnitKey());
+            sensor.setShowUnitKey(organizationUnitAlarm.getShowUnitKey());
+            sensor.setUnitKey(organizationUnitAlarm.getUnitKey());
+            sensor.setAlarmLevel(organizationUnitAlarm.getAlarmLevel());
+            String formula = unitConversionService.getFormula(Integer.valueOf(organizationUnitAlarm.getUnitKey()), Integer.valueOf(organizationUnitAlarm.getShowUnitKey()),sensor.getCode());
+            sensor.setFormula(formula);
+            sensors.add(sensor);
+        }
+        version.setSensors(sensors);
+        device.setVersion(version);
+        redisTemplate.opsForHash().put(RedisConstants.DEVICE_INFO,mac,device);
+        return device;
+    }
+
+    private Device getDeviceByMacFromDB(String mac) {
+        QueryWrapper<Device> wrapper = new QueryWrapper<>();
+        wrapper.eq("mac", mac);
+        wrapper.eq("is_delete", Constants.NOT_DELETE);
+        return deviceMapper.selectOne(wrapper);
+    }
+
+    /**
+     * @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;
+    }
+
+    private List<HistoryFiveMinutely> FiveMinuteTableQuery(QueryWrapper<HistoryFiveMinutely> wrapper, List<String> tableNames) {
+        List<HistoryFiveMinutely> result = new ArrayList<>();
+        for (String tableName : tableNames) {
+            MybatisPlusConfig.tableName.set(tableName);
+            List<HistoryFiveMinutely> datas = historyFiveMinutelyMapper.selectList(wrapper);
+            result.addAll(datas);
+        }
+        MybatisPlusConfig.tableName.remove();
+        return result;
+    }
+
 
 }

--
Gitblit v1.8.0