From cdec9062c85f52d43e8d74e82cbcf9f8606ebb01 Mon Sep 17 00:00:00 2001
From: jinpengyong <jpy123456>
Date: Tue, 30 Jan 2024 16:39:59 +0800
Subject: [PATCH] chore:设备在线率接口提交

---
 screen-api/src/main/java/com/moral/api/service/impl/DeviceServiceImpl.java |  462 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 444 insertions(+), 18 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 74d4260..aae96af 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
@@ -2,30 +2,47 @@
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.OrderItem;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.moral.api.config.Interceptor.UserHelper;
 import com.moral.api.config.mybatis.MybatisPlusConfig;
+import com.moral.api.dto.OnlineRatePageCond;
 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.pojo.dust.OnlineRateLogsForm;
+import com.moral.api.pojo.vo.device.AppDeviceVo;
+import com.moral.api.pojo.vo.user.QxUser;
 import com.moral.api.service.DeviceService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.moral.api.service.HistoryDailyService;
+import com.moral.api.service.HistoryFiveMinutelyService;
+import com.moral.api.service.HistoryHourlyService;
+import com.moral.api.service.HistoryMonthlyService;
 import com.moral.api.service.SensorService;
 import com.moral.api.service.UnitConversionService;
+import com.moral.api.vo.OnlineRateVo;
 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 com.sun.org.apache.regexp.internal.RE;
+
+import org.apache.commons.collections4.CollectionUtils;
 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.text.DecimalFormat;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -57,6 +74,12 @@
 
     @Autowired
     HistoryHourlyMapper historyHourlyMapper;
+
+    @Autowired
+    HistoryHourlyService historyHourlyService;
+
+    @Autowired
+    HistoryDailyService historyDailyService;
 
     @Autowired
     HistoryFiveMinutelyMapper historyFiveMinutelyMapper;
@@ -229,10 +252,11 @@
             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);
+                Map<String, Object> mapParams = new HashMap<>();
+                mapParams.put("startDate",startDate);
+                mapParams.put("endDate",endDate);
+                mapParams.put("mac",mac);
+                List<HistoryHourly> historyHourlies = multiTableQuery(mapParams, tableNames);
                 historyHourlies = historyHourlies.stream().distinct().collect(Collectors.toList());
                 List<HistoryHourly> distinctHistoryHourlies = new ArrayList<>();
                 Map<String, Object> disMap = new HashMap<>();
@@ -340,10 +364,11 @@
             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);
+                Map<String, Object> mapParams = new HashMap<>();
+                mapParams.put("startDate",startDate);
+                mapParams.put("endDate",endDate);
+                mapParams.put("mac",mac);
+                List<HistoryFiveMinutely> HistoryFiveMinutelys = FiveMinuteTableQuery(mapParams, tableNames);
                 HistoryFiveMinutelys = HistoryFiveMinutelys.stream().distinct().collect(Collectors.toList());
                 List<HistoryFiveMinutely> distinctHistoryHourlies = new ArrayList<>();
                 Map<String, Object> disMap = new HashMap<>();
@@ -359,8 +384,14 @@
                     Map<String,Object> historyHourlyMap = new HashMap<>();
                     historyHourlyMap.put("mac",mac);
                     JSONObject value = JSONObject.parseObject(historyFiveMinutely.getValue());
-                    Double sensorValue = Double.parseDouble(value.get(sensorCode).toString());
-                    historyHourlyMap.put(sensorCode,sensorValue);
+                    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);
@@ -487,6 +518,403 @@
         return device;
     }
 
+    /**
+     * ������������
+     *
+     * @param mac
+     * @return
+     */
+    @Override
+    public List<AppDeviceVo> getFuzzySearch(String mac) {
+        QxUser user = UserHelper.getCurrentUser();
+        Integer organizationId = user.getOrganizationId();
+//        Integer organizationId = 24;
+        List<AppDeviceVo> devices;
+        if (organizationId!=24){
+             devices = deviceMapper.getDevices(mac,organizationId);
+        }else {
+             devices = deviceMapper.getDevices(mac,null);
+        }
+        return devices;
+    }
+
+
+    /**
+     * ������������������������
+     *
+     * @param id
+     * @return
+     */
+    @Override
+    public List<Device> getOrganizationDevice(Integer id) {
+        LambdaQueryWrapper<Device> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(Device::getMonitorPointId,id);
+        wrapper.eq(Device::getIsDelete,Constants.NOT_DELETE);
+        wrapper.orderByAsc(Device::getCreateTime);
+        List<Device> devices = deviceMapper.selectList(wrapper);
+        return devices;
+    }
+
+    /**
+     * ���������
+     * @param onlineRatePageCond
+     * @return
+     */
+    @Override
+    public List<OnlineRateVo> getPage(OnlineRatePageCond onlineRatePageCond) {
+        int nh = 1000 * 60 * 60;
+        String startTime = onlineRatePageCond.getStartTime();
+        String endTime = onlineRatePageCond.getEndTime();
+        Date start = DateUtils.getDate(startTime, DateUtils.yyyy_MM_dd_HH_mm_ss_EN);
+        Date end = DateUtils.getDate(endTime, DateUtils.yyyy_MM_dd_HH_mm_ss_EN);
+        long diff = end.getTime() - start.getTime(); //������������
+        long hour = (diff / nh)+1; //������������������������
+
+        List<OnlineRateVo> OnlineRateVoList = deviceMapper.getList(onlineRatePageCond.getOrganizationId());
+        if (!ObjectUtils.isEmpty(OnlineRateVoList)){
+            for (OnlineRateVo onlineRateVo : OnlineRateVoList) {
+                List<HistoryHourly> valueByMacAndTime = historyHourlyService.getValueByMacAndTime(onlineRateVo.getMac(), start, end);
+                ArrayList<Date> dates = new ArrayList<>();
+                ArrayList<Date> dates1 = new ArrayList<>();
+                ArrayList<Date> dates2 = new ArrayList<>();
+                ArrayList<Integer> list = new ArrayList<>();
+                Date start1 = DateUtils.getDate(startTime, DateUtils.yyyy_MM_dd_HH_mm_ss_EN);
+                if (!ObjectUtils.isEmpty(valueByMacAndTime)){
+                    for (HistoryHourly historyHourly : valueByMacAndTime) {
+                        dates.add(historyHourly.getTime());
+                    }
+                    boolean flag= true;
+                    int i = 0;
+                    while (DateUtils.isTimeBeforE(end,start1)){
+                        if (dates.contains(start1)){
+                            if (flag){
+                                list.add(i);
+                            }else {
+                                i++;
+                                list.add(i);
+                                dates2.add(start1);
+                                flag= true;
+                            }
+                        }else {
+                            if (flag){
+                                i++;
+                                list.add(i);
+                                dates1.add(start1);
+                                flag=false;
+                            }else {
+                                list.add(i);
+                            }
+                        }
+                        start1 = DateUtils.getDateAddHour(start1,1);
+                    }
+                    if (!ObjectUtils.isEmpty(dates2)){
+                        onlineRateVo.setStartTime(DateUtils.dateToDateString(dates2.get(dates2.size()-1)));
+                    }
+                    if (!ObjectUtils.isEmpty(dates1)){
+                        onlineRateVo.setEndTime(DateUtils.dateToDateString(dates1.get(dates1.size()-1)));
+                    }
+//               it.setEndTime(DateUtils.dateToDateString(dates1.get(dates1.size()-1)));
+                    onlineRateVo.setNum(dates1.size()+"");
+                    onlineRateVo.setOnlineTime(valueByMacAndTime.size());
+                    double number = (double) valueByMacAndTime.size() / hour * 100;
+                    String result = String.format("%.2f", number);
+                    onlineRateVo.setOnlineRate(result+"%");
+                }
+            }
+
+        }
+     /*   Page<OnlineRateVo> page = deviceMapper.getPage(onlineRatePageCond.getPage().convertPage(), onlineRatePageCond.getOrganizationId());
+        if(CollectionUtils.isNotEmpty(page.getRecords())){
+            page.getRecords().forEach(it->{
+                Date start1 = DateUtils.getDate(startTime, DateUtils.yyyy_MM_dd_HH_mm_ss_EN);
+                List<HistoryHourly> valueByMacAndTime = historyHourlyService.getValueByMacAndTime(it.getMac(), start, end);
+                ArrayList<Date> dates = new ArrayList<>();
+                ArrayList<Date> dates1 = new ArrayList<>();
+                ArrayList<Date> dates2 = new ArrayList<>();
+
+                ArrayList<Integer> list = new ArrayList<>();
+                if (!ObjectUtils.isEmpty(valueByMacAndTime)){
+                    for (HistoryHourly historyHourly : valueByMacAndTime) {
+                        dates.add(historyHourly.getTime());
+                    }
+                    boolean flag= true;
+                    int i = 0;
+                    while (DateUtils.isTimeBeforE(end,start1)){
+                    if (dates.contains(start1)){
+                        if (flag){
+                          list.add(i);
+                        }else {
+                          i++;
+                          list.add(i);
+                          dates2.add(start1);
+                          flag= true;
+                        }
+                    }else {
+                        if (flag){
+                            i++;
+                            list.add(i);
+                            dates1.add(start1);
+                            flag=false;
+                        }else {
+                          list.add(i);
+                        }
+                    }
+                        start1 = DateUtils.getDateAddHour(start1,1);
+                    }
+                    if (!ObjectUtils.isEmpty(dates2)){
+                        it.setStartTime(DateUtils.dateToDateString(dates2.get(dates2.size()-1)));
+                    }
+                    if (!ObjectUtils.isEmpty(dates1)){
+                        it.setEndTime(DateUtils.dateToDateString(dates1.get(dates1.size()-1)));
+                    }
+//                    it.setEndTime(DateUtils.dateToDateString(dates1.get(dates1.size()-1)));
+                    it.setNum(dates1.size()+"");
+                    it.setOnlineTime(valueByMacAndTime.size());
+                    double number = (double) valueByMacAndTime.size() / hour * 100;
+                    String result = String.format("%.2f", number);
+                    it.setOnlineRate(result+"%");
+                }
+            });
+        }*/
+        return OnlineRateVoList;
+    }
+
+    /**
+     * ���������������������
+     *
+     * @param mac
+     * @param startTime
+     * @param endTime
+     * @param type
+     * @return
+     */
+    @Override
+    public Map<String,Object> detail(String mac, String startTime, String endTime, String type) {
+        int nh = 1000 * 60 * 60;
+        long nd = 1000 * 24 * 60 * 60;
+        long nm = 1000 * 60;
+        HashMap<String, Object> rsMap = new HashMap<>();
+        Map<String, Object> map = new TreeMap<>(
+                new Comparator<String>() {
+                    @Override
+                    public int compare(String o1, String o2) {
+                        return o2.compareTo(o1);
+                    }
+                }
+        );
+//        HashMap<String, Object> map = new HashMap<>();
+        //������������
+        ArrayList<Date> EndDates = new ArrayList<>();
+        //������������
+        ArrayList<Date> StartDates = new ArrayList<>();
+        ArrayList<Date> dates = new ArrayList<>();
+
+        if (type.equals("hour")){
+            Date start = DateUtils.getDate(startTime, DateUtils.yyyy_MM_dd_HH_EN);
+            Date end = DateUtils.getDate(endTime, DateUtils.yyyy_MM_dd_HH_EN);
+            List<HistoryHourly> valueByMacAndTime = historyHourlyService.getValueByMacAndTime(mac, start, end);
+            if (!ObjectUtils.isEmpty(valueByMacAndTime)){
+                for (HistoryHourly historyHourly : valueByMacAndTime) {
+                    map.put(DateUtils.dateToDateString(historyHourly.getTime()),1);
+                    dates.add(historyHourly.getTime());
+                }
+                boolean flag= true;
+                while (DateUtils.isTimeBeforE(end,start)){
+                    if (dates.contains(start)){
+                        if (!flag){
+                            StartDates.add(start);
+                            flag= true;
+                        }
+                    }else {
+                        if (flag){
+                            EndDates.add(start);
+                            flag=false;
+                        }
+                        map.put(DateUtils.dateToDateString(start),0);
+                    }
+                    start = DateUtils.getDateAddHour(start,1);
+                }
+            }
+            //������
+            ArrayList<OnlineRateLogsForm> OrfList = new ArrayList<>();
+            if (!ObjectUtils.isEmpty(EndDates)){
+                for (int i = 0; i < EndDates.size(); i++) {
+                    OnlineRateLogsForm onlineRateLogsForm = new OnlineRateLogsForm();
+                    onlineRateLogsForm.setEndTime(DateUtils.dateToDateString(EndDates.get(i)));
+                    onlineRateLogsForm.setStartTime(ObjectUtils.isEmpty(StartDates)?"-":DateUtils.dateToDateString(StartDates.get(i)));
+//                    if (!ObjectUtils.isEmpty(StartDates)){
+//                        long l = EndDates.get(i).getTime() - StartDates.get(i).getTime();
+//                        onlineRateLogsForm.setMun(Long.toString(l/nh));
+//                        StartDates.remove(i);
+//                    }else {
+//                        onlineRateLogsForm.setMun("-");
+//                    }
+                    onlineRateLogsForm.setDate("������");
+                    OrfList.add(onlineRateLogsForm);
+                }
+            }
+            //���������
+            ArrayList<String> list1 = new ArrayList<>();
+            ArrayList<Integer> list2 = new ArrayList<>();
+            Set<String> strings = map.keySet();
+            for (String string : strings) {
+                list1.add(string);
+                list2.add(Integer.parseInt(map.get(string).toString()));
+            }
+            rsMap.put("lineChart1",list1);
+            rsMap.put("lineChart2",list2);
+            rsMap.put("tabulation",OrfList);
+            //���������������������
+            int endNumber = map.size() - dates.size();
+            double number = (double) dates.size() / map.size() * 100;
+            String result = String.format("%.2f", number);
+            rsMap.put("pieChart1",endNumber);
+            rsMap.put("pieChart2",dates.size());
+            rsMap.put("code","���"+map.size()+"���������"+"������"+dates.size()+"���������"+"���������"+result);
+
+        } else if (type.equals("day")){
+            Date start = DateUtils.getDate(startTime, DateUtils.yyyy_MM_dd_EN);
+            Date end = DateUtils.getDate(endTime, DateUtils.yyyy_MM_dd_EN);
+            List<HistoryDaily> historyDailys = historyDailyService.getHistoryDailyByMacAndTimeSlot(mac, start, end);
+            if (!ObjectUtils.isEmpty(historyDailys)){
+                for (HistoryDaily historyDaily : historyDailys) {
+                    map.put(DateUtils.dateToDateString(historyDaily.getTime()),1);
+                    dates.add(historyDaily.getTime());
+                }
+                boolean flag= true;
+                while (DateUtils.isTimeBeforE(end,start)){
+                    if (dates.contains(start)){
+                        if (!flag){
+                            StartDates.add(start);
+                            flag= true;
+                        }
+                    }else {
+                        if (flag){
+                            EndDates.add(start);
+                            flag=false;
+                        }
+                        map.put(DateUtils.dateToDateString(start),0);
+                    }
+//                    start = DateUtils.getDateAddHour(start,24);
+                    start = DateUtils.getDateOfDay(start,1);
+                }
+            }
+            //������
+            ArrayList<OnlineRateLogsForm> OrfList = new ArrayList<>();
+            if (!ObjectUtils.isEmpty(EndDates)){
+                for (int i = 0; i < EndDates.size(); i++) {
+                    OnlineRateLogsForm onlineRateLogsForm = new OnlineRateLogsForm();
+                    onlineRateLogsForm.setEndTime(DateUtils.dateToDateString(EndDates.get(i)));
+//                    onlineRateLogsForm.setStartTime(ObjectUtils.isEmpty(StartDates)?"-":DateUtils.dateToDateString(StartDates.get(i)));
+                    if (ObjectUtils.isEmpty(StartDates)){
+                        onlineRateLogsForm.setStartTime("-");
+                        onlineRateLogsForm.setMun("-");
+                    }else {
+                        if (EndDates.size()>StartDates.size()&& i==EndDates.size()-1){
+                            onlineRateLogsForm.setStartTime("-");
+                            onlineRateLogsForm.setMun("-");
+                        }
+                        onlineRateLogsForm.setStartTime(DateUtils.dateToDateString(StartDates.get(i)));
+                        long l = EndDates.get(i).getTime() - StartDates.get(i).getTime();
+                        onlineRateLogsForm.setMun(Long.toString(l/nd));
+                    }
+//                    if (!ObjectUtils.isEmpty(StartDates)){
+//                        long l = EndDates.get(i).getTime() - StartDates.get(i).getTime();
+//                        onlineRateLogsForm.setMun(Long.toString(l/nd));
+//                    }else {
+//                        onlineRateLogsForm.setMun("-");
+//                    }
+                    onlineRateLogsForm.setDate("���");
+                    OrfList.add(onlineRateLogsForm);
+                }
+            }
+            //���������
+            ArrayList<String> list1 = new ArrayList<>();
+            ArrayList<Integer> list2 = new ArrayList<>();
+            Set<String> strings = map.keySet();
+            for (String string : strings) {
+                list1.add(string);
+                list2.add(Integer.parseInt(map.get(string).toString()));
+            }
+
+
+            rsMap.put("lineChart1",list1);
+            rsMap.put("lineChart2",list2);
+            rsMap.put("tabulation",OrfList);
+            //���������������
+            int endNumber = map.size() - dates.size();
+            double number = (double) dates.size() / map.size() * 100;
+            String result = String.format("%.2f", number);
+            rsMap.put("pieChart1",endNumber);
+            rsMap.put("pieChart2",dates.size());
+            rsMap.put("code","���"+map.size()+"������"+"������"+dates.size()+"������"+"���������"+result);
+        }else {
+            Date start = DateUtils.getDate(startTime,"yyyy-MM-dd HH:mm:00");
+            Date end = DateUtils.getDate(endTime, "yyyy-MM-dd HH:mm:00");
+            List<HistoryMinutely> historyMinutelys = historyHourlyService.getHistoryMinutely(mac, start, end);
+            if (!ObjectUtils.isEmpty(historyMinutelys)){
+                for (HistoryMinutely historyMinutely : historyMinutelys) {
+                    map.put(DateUtils.dateToDateString(historyMinutely.getTime()),1);
+                    dates.add(historyMinutely.getTime());
+                }
+                boolean flag= true;
+                while (DateUtils.isTimeBeforE(end,start)){
+                    if (dates.contains(start)){
+                        if (!flag){
+                            StartDates.add(start);
+                            flag= true;
+                        }
+                    }else {
+                        if (flag){
+                            EndDates.add(start);
+                            flag=false;
+                        }
+                        map.put(DateUtils.dateToDateString(start),0);
+                    }
+//                    start = DateUtils.getDateAddHour(start,24);
+                    start = DateUtils.getDateOfMin(start,1);
+                }
+            }
+            //������
+            ArrayList<OnlineRateLogsForm> OrfList = new ArrayList<>();
+            if (!ObjectUtils.isEmpty(EndDates)){
+                for (int i = 0; i < EndDates.size(); i++) {
+                    OnlineRateLogsForm onlineRateLogsForm = new OnlineRateLogsForm();
+                    onlineRateLogsForm.setEndTime(DateUtils.dateToDateString(EndDates.get(i)));
+                    onlineRateLogsForm.setStartTime(ObjectUtils.isEmpty(StartDates)?"-":DateUtils.dateToDateString(StartDates.get(i)));
+//                    if (!ObjectUtils.isEmpty(StartDates)){
+//                        long l = EndDates.get(i).getTime() - StartDates.get(i).getTime();
+//                        onlineRateLogsForm.setMun(Long.toString(l/nm));
+//                    }else {
+//                        onlineRateLogsForm.setMun("-");
+//                    }
+                    onlineRateLogsForm.setDate("������");
+                    OrfList.add(onlineRateLogsForm);
+                }
+            }
+            //���������
+            ArrayList<String> list1 = new ArrayList<>();
+            ArrayList<Integer> list2 = new ArrayList<>();
+            Set<String> strings = map.keySet();
+            for (String string : strings) {
+                list1.add(string);
+                list2.add(Integer.parseInt(map.get(string).toString()));
+            }
+            rsMap.put("lineChart1",list1);
+            rsMap.put("lineChart2",list2);
+            rsMap.put("tabulation",OrfList);
+            //���������������
+            int endNumber = map.size() - dates.size();
+            double number = (double) dates.size() / map.size() * 100;
+            String result = String.format("%.2f", number);
+            rsMap.put("pieChart1",endNumber);
+            rsMap.put("pieChart2",dates.size());
+            rsMap.put("code","���"+map.size()+"���������"+"������"+dates.size()+"���������"+"���������"+result);
+        }
+
+        return rsMap;
+    }
+
     private Device getDeviceUnitAlramInforByMacFromDb(String mac){
         QueryWrapper<Device> wrapper = new QueryWrapper<>();
         wrapper.eq("mac",mac);
@@ -533,25 +961,23 @@
      * @Author: ���������
      * @Date: 2021/9/23
      */
-    private List<HistoryHourly> multiTableQuery(QueryWrapper<HistoryHourly> wrapper, List<String> tableNames) {
+    private List<HistoryHourly> multiTableQuery(Map<String, Object> params, List<String> tableNames) {
         List<HistoryHourly> result = new ArrayList<>();
         for (String tableName : tableNames) {
-            MybatisPlusConfig.tableName.set(tableName);
-            List<HistoryHourly> datas = historyHourlyMapper.selectList(wrapper);
+            params.put("table",tableName);
+            List<HistoryHourly> datas = historyHourlyMapper.listResult(params);
             result.addAll(datas);
         }
-        MybatisPlusConfig.tableName.remove();
         return result;
     }
 
-    private List<HistoryFiveMinutely> FiveMinuteTableQuery(QueryWrapper<HistoryFiveMinutely> wrapper, List<String> tableNames) {
+    private List<HistoryFiveMinutely> FiveMinuteTableQuery(Map<String, Object> params, List<String> tableNames) {
         List<HistoryFiveMinutely> result = new ArrayList<>();
         for (String tableName : tableNames) {
-            MybatisPlusConfig.tableName.set(tableName);
-            List<HistoryFiveMinutely> datas = historyFiveMinutelyMapper.selectList(wrapper);
+            params.put("table",tableName);
+            List<HistoryFiveMinutely> datas = historyFiveMinutelyMapper.listResult(params);
             result.addAll(datas);
         }
-        MybatisPlusConfig.tableName.remove();
         return result;
     }
 

--
Gitblit v1.8.0