|
@@ -1,5 +1,7 @@
|
|
|
package com.gyee.dataadapter.dao_mqtt_influxdb_taos;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.gyee.dataadapter.dao.IHistoryDao;
|
|
|
import com.gyee.dataadapter.entity.PointData;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -20,6 +22,7 @@ public class TaosDataService implements IHistoryDao {
|
|
|
@Override
|
|
|
public Map<String, PointData> getLatest(List<String> tagNames) throws Exception {
|
|
|
Map<String, PointData> tsDataMap = new HashMap<>();
|
|
|
+ if(CollUtil.isEmpty(tagNames)) return tsDataMap;
|
|
|
Statement st = config.getInstance().createStatement();
|
|
|
String collect = tagNames.stream().map(s -> "'" + s.toLowerCase() + "'").collect(Collectors.joining(","));
|
|
|
StringBuilder sql = new StringBuilder();
|
|
@@ -35,6 +38,7 @@ public class TaosDataService implements IHistoryDao {
|
|
|
@Override
|
|
|
public List<PointData> getHistoryRaw(String tagName, Date startTime, Date endTime) throws Exception {
|
|
|
List<PointData> tsDataList = new ArrayList<>();
|
|
|
+ if(StrUtil.isBlank(tagName)) return tsDataList;
|
|
|
Statement st = config.getInstance().createStatement();
|
|
|
String sql = getHistoryRawSql(tagName, startTime.getTime(), endTime.getTime());
|
|
|
ResultSet rs = st.executeQuery(sql);
|
|
@@ -62,6 +66,7 @@ public class TaosDataService implements IHistoryDao {
|
|
|
@Override
|
|
|
public List<PointData> getHistorySnap(String tagName, Date startTime, Date endTime, Integer interval) throws Exception {
|
|
|
List<PointData> tsDataList = new ArrayList<>();
|
|
|
+ if(StrUtil.isBlank(tagName)) return tsDataList;
|
|
|
Statement st = config.getInstance().createStatement();
|
|
|
String sql = getHistorySnapSql(tagName, startTime.getTime(), endTime.getTime(), interval);
|
|
|
ResultSet rs = st.executeQuery(sql);
|
|
@@ -74,6 +79,7 @@ public class TaosDataService implements IHistoryDao {
|
|
|
@Override
|
|
|
public List<PointData> getHistoryStat(String tagName, Date startTime, Date endTime, Integer interval, Integer type) throws Exception {
|
|
|
List<PointData> result = new ArrayList<>();
|
|
|
+ if(StrUtil.isBlank(tagName)) return result;
|
|
|
Statement st = config.getInstance().createStatement();
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
if (type == 2) {
|
|
@@ -95,6 +101,8 @@ public class TaosDataService implements IHistoryDao {
|
|
|
|
|
|
@Override
|
|
|
public PointData getHistoryStat0(String tagName, Date startTime, Date endTime, Integer type) throws Exception {
|
|
|
+ PointData pd = new PointData(endTime, 0);
|
|
|
+ if(StrUtil.isBlank(tagName)) return pd;
|
|
|
Statement st = config.getInstance().createStatement();
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
if (type == 2) {
|
|
@@ -110,12 +118,13 @@ public class TaosDataService implements IHistoryDao {
|
|
|
while (rs.next()) {
|
|
|
return new PointData(endTime, rs.getDouble(1));
|
|
|
}
|
|
|
- return new PointData(endTime, 0);
|
|
|
+ return pd;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Map<String, PointData> getHistorySection(Date ts, List<String> tagNames) throws Exception {
|
|
|
Map<String, PointData> tsDataMap = new HashMap<>();
|
|
|
+ if(CollUtil.isEmpty(tagNames)) return tsDataMap;
|
|
|
Statement st = config.getInstance().createStatement();
|
|
|
String collect = tagNames.stream().map(s -> "'" + s.toLowerCase() + "'").collect(Collectors.joining(","));
|
|
|
StringBuilder sql = new StringBuilder();
|