From a0fe2290b235be4460d2118bac76ef3d64980d47 Mon Sep 17 00:00:00 2001
From: cjl <276999030@qq.com>
Date: Sat, 07 Oct 2023 11:54:59 +0800
Subject: [PATCH] ci:补充提交
---
screen-api/src/main/java/com/moral/api/service/impl/DeviceServiceImpl.java | 32 +++++-----
screen-api/src/main/java/com/moral/api/mapper/HistoryFiveMinutelyMapper.java | 5 +
screen-api/src/main/java/com/moral/api/service/impl/HistoryFiveMinutelyServiceImpl.java | 33 ++++++----
screen-api/src/main/resources/mapper/HistoryFiveMinutelyMapper.xml | 11 +++
screen-api/src/main/java/com/moral/api/mapper/HistoryHourlyMapper.java | 2
screen-api/src/main/java/com/moral/api/config/mybatis/MybatisPlusConfig.java | 18 +++++
screen-manage/src/main/java/com/moral/api/kafka/consumer/DeviceConsumer.java | 2
screen-api/src/main/resources/mapper/HistoryHourlyMapper.xml | 21 +++++++
8 files changed, 93 insertions(+), 31 deletions(-)
diff --git a/screen-api/src/main/java/com/moral/api/config/mybatis/MybatisPlusConfig.java b/screen-api/src/main/java/com/moral/api/config/mybatis/MybatisPlusConfig.java
index 804a61f..9b40ff2 100644
--- a/screen-api/src/main/java/com/moral/api/config/mybatis/MybatisPlusConfig.java
+++ b/screen-api/src/main/java/com/moral/api/config/mybatis/MybatisPlusConfig.java
@@ -1,12 +1,16 @@
package com.moral.api.config.mybatis;
import com.baomidou.mybatisplus.annotation.DbType;
+import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer;
+import com.baomidou.mybatisplus.core.MybatisConfiguration;
import com.baomidou.mybatisplus.extension.parsers.DynamicTableNameParser;
import com.baomidou.mybatisplus.extension.parsers.ITableNameHandler;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
+import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.handler.TableNameHandler;
import com.baomidou.mybatisplus.extension.plugins.inner.DynamicTableNameInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
+import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
import com.moral.api.entity.HistoryFiveMinutely;
import com.moral.api.mapper.HistoryFiveMinutelyMapper;
import com.moral.api.service.HistorySecondUavService;
@@ -14,10 +18,13 @@
import com.moral.api.service.impl.OrganizationServiceImpl;
import org.apache.ibatis.reflection.MetaObject;
import org.apache.ibatis.session.SqlSessionFactory;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import javax.sql.DataSource;
import java.text.SimpleDateFormat;
import java.util.*;
@@ -25,7 +32,7 @@
/*@Configuration*/
public class MybatisPlusConfig {
- public static ThreadLocal<String> tableName = new ThreadLocal<>();
+
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
@@ -42,8 +49,15 @@
dynamicTableNameInnerInterceptor.setTableNameHandlerMap(map);
interceptor.addInnerInterceptor(dynamicTableNameInnerInterceptor);
-
+ interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
return interceptor;
}
+ @Bean
+ public ConfigurationCustomizer configurationCustomizer() {
+ return configuration -> configuration.setUseDeprecatedExecutor(false);
+ }
+
+
+ public static ThreadLocal<String> tableName = new ThreadLocal<>();
}
diff --git a/screen-api/src/main/java/com/moral/api/mapper/HistoryFiveMinutelyMapper.java b/screen-api/src/main/java/com/moral/api/mapper/HistoryFiveMinutelyMapper.java
index 2ec37a9..93fdaad 100644
--- a/screen-api/src/main/java/com/moral/api/mapper/HistoryFiveMinutelyMapper.java
+++ b/screen-api/src/main/java/com/moral/api/mapper/HistoryFiveMinutelyMapper.java
@@ -5,6 +5,7 @@
import com.moral.api.entity.HistoryFiveMinutely;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.moral.api.entity.HistoryHourly;
import com.moral.api.pojo.dto.Wind.WindData;
/**
@@ -19,4 +20,8 @@
List<WindData> getAreaWindData(Map<String, Object> params);
+ List<HistoryFiveMinutely> listResult(Map<String, Object> params);
+
+ List<HistoryFiveMinutely> listResultOne(Map<String, Object> params);
+
}
diff --git a/screen-api/src/main/java/com/moral/api/mapper/HistoryHourlyMapper.java b/screen-api/src/main/java/com/moral/api/mapper/HistoryHourlyMapper.java
index 6384a47..7e88222 100644
--- a/screen-api/src/main/java/com/moral/api/mapper/HistoryHourlyMapper.java
+++ b/screen-api/src/main/java/com/moral/api/mapper/HistoryHourlyMapper.java
@@ -42,4 +42,6 @@
void insertHistoryHourly(Map<String, Object> params);
void updateHistoryHourly(Map<String, Object> params);
+
+ List<HistoryHourly> listResult(Map<String, Object> params);
}
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 bd62813..ea2d2a4 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
@@ -229,10 +229,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 +341,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<>();
@@ -539,25 +541,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;
}
diff --git a/screen-api/src/main/java/com/moral/api/service/impl/HistoryFiveMinutelyServiceImpl.java b/screen-api/src/main/java/com/moral/api/service/impl/HistoryFiveMinutelyServiceImpl.java
index 0a3d387..893e445 100644
--- a/screen-api/src/main/java/com/moral/api/service/impl/HistoryFiveMinutelyServiceImpl.java
+++ b/screen-api/src/main/java/com/moral/api/service/impl/HistoryFiveMinutelyServiceImpl.java
@@ -141,14 +141,12 @@
//������������������������������������
if (sensorValues != null)
return sensorValues;
- QueryWrapper<HistoryFiveMinutely> queryWrapper = new QueryWrapper<>();
- queryWrapper.eq("mac", mac);
- queryWrapper.orderByDesc("time");
- queryWrapper.last("limit 0,1");
+ Map<String, Object> mapParams = new HashMap<>();
+ mapParams.put("mac",mac);
//���������������������
Date date = new Date();
List<String> tableNames = MybatisPLUSUtils.getTableNamesByWrapper(date, date, SeparateTableType.MONTH);
- List<HistoryFiveMinutely> datas = multiTableQuery(queryWrapper, tableNames);
+ List<HistoryFiveMinutely> datas = multiTableQuery(mapParams, tableNames);
if (ObjectUtils.isEmpty(datas))
return null;
HistoryFiveMinutely historyFiveMinutely = datas.get(0);
@@ -480,11 +478,12 @@
* @Date: 2021/9/23
*/
public List<HistoryFiveMinutely> getValueByMacAndTime(String mac, Date startDate, Date endDate) {
- QueryWrapper<HistoryFiveMinutely> wrapper = new QueryWrapper<>();
- wrapper.eq("mac", mac);
- wrapper.between("time", startDate, 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<HistoryFiveMinutely> datas = multiTableQuery(wrapper, tableNames);
+ List<HistoryFiveMinutely> datas = multiTableQueryResult(mapParams, tableNames);
return datas;
}
@@ -496,14 +495,22 @@
* @Author: ���������
* @Date: 2021/9/23
*/
- private List<HistoryFiveMinutely> multiTableQuery(QueryWrapper<HistoryFiveMinutely> wrapper, List<String> tableNames) {
+ private List<HistoryFiveMinutely> multiTableQuery(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.listResultOne(params);
result.addAll(datas);
}
- MybatisPlusConfig.tableName.remove();
+ return result;
+ }
+ private List<HistoryFiveMinutely> multiTableQueryResult(Map<String, Object> params, List<String> tableNames) {
+ List<HistoryFiveMinutely> result = new ArrayList<>();
+ for (String tableName : tableNames) {
+ params.put("table",tableName);
+ List<HistoryFiveMinutely> datas = historyFiveMinutelyMapper.listResult(params);
+ result.addAll(datas);
+ }
return result;
}
}
diff --git a/screen-api/src/main/resources/mapper/HistoryFiveMinutelyMapper.xml b/screen-api/src/main/resources/mapper/HistoryFiveMinutelyMapper.xml
index 0de8ee6..360ff73 100644
--- a/screen-api/src/main/resources/mapper/HistoryFiveMinutelyMapper.xml
+++ b/screen-api/src/main/resources/mapper/HistoryFiveMinutelyMapper.xml
@@ -21,4 +21,15 @@
AND h.time = (SELECT max(time) FROM history_five_minutely_${timeUnits})
</select>
+ <select id="listResult" resultType="com.moral.api.entity.HistoryFiveMinutely">
+ SELECT mac,time,value FROM history_five_minutely${table}
+ WHERE (mac = #{mac} AND time BETWEEN #{startDate} AND #{endDate})
+ order by time desc
+ </select>
+ <select id="listResultOne" resultType="com.moral.api.entity.HistoryFiveMinutely">
+ SELECT mac,time,value FROM history_five_minutely${table}
+ WHERE (mac = #{mac})
+ order by time desc
+ limit 1
+ </select>
</mapper>
\ No newline at end of file
diff --git a/screen-api/src/main/resources/mapper/HistoryHourlyMapper.xml b/screen-api/src/main/resources/mapper/HistoryHourlyMapper.xml
index b707ec4..42e5f83 100644
--- a/screen-api/src/main/resources/mapper/HistoryHourlyMapper.xml
+++ b/screen-api/src/main/resources/mapper/HistoryHourlyMapper.xml
@@ -86,4 +86,25 @@
UPDATE history_hourly_${timeUnits} SET `value` = #{value}
where mac = #{mac} and time = #{time} and version = #{version}
</insert>
+
+ <select id="listResult" resultType="com.moral.api.entity.HistoryHourly">
+ SELECT mac,time,value,version FROM history_hourly${table}
+ WHERE 1 =1
+ <if test="macs != null and macs.size!=0">
+ and mac in
+ <foreach collection="macs" item="id" index="index" open="(" close=")" separator=",">
+ #{id}
+ </foreach>
+ </if>
+ <if test="mac != null and mac != ''">
+ and mac = #{mac}
+ </if>
+ <if test="startDate!=null and startDate!='' ">
+ and time BETWEEN #{startDate} and #{endDate}
+ </if>
+ <if test="time!=null and time!='' ">
+ and time =#{time} and limit 1
+ </if>
+ order by time desc
+ </select>
</mapper>
\ No newline at end of file
diff --git a/screen-manage/src/main/java/com/moral/api/kafka/consumer/DeviceConsumer.java b/screen-manage/src/main/java/com/moral/api/kafka/consumer/DeviceConsumer.java
index 3d3378d..9f80360 100644
--- a/screen-manage/src/main/java/com/moral/api/kafka/consumer/DeviceConsumer.java
+++ b/screen-manage/src/main/java/com/moral/api/kafka/consumer/DeviceConsumer.java
@@ -1,3 +1,4 @@
+/*
package com.moral.api.kafka.consumer;
import com.alibaba.fastjson.JSONObject;
@@ -223,3 +224,4 @@
}
}
}
+*/
--
Gitblit v1.8.0