完胜报表功能需要的方法
This commit is contained in:
@@ -70,7 +70,7 @@ public class InfluxExecutor {
|
|||||||
//处理tag分组数据
|
//处理tag分组数据
|
||||||
for (String columnName : tags.keySet()) {
|
for (String columnName : tags.keySet()) {
|
||||||
for (Field declaredField : fields) {
|
for (Field declaredField : fields) {
|
||||||
if (columnName.equalsIgnoreCase(InfluxQueryWrapper.getColumnName(declaredField))) {
|
if (columnName.replace("_","").equalsIgnoreCase(InfluxQueryWrapper.getColumnName(declaredField))) {
|
||||||
//获取属性定义的类型
|
//获取属性定义的类型
|
||||||
declaredField.setAccessible(true);
|
declaredField.setAccessible(true);
|
||||||
//判断是否过滤该条记录,当数据返回 null时
|
//判断是否过滤该条记录,当数据返回 null时
|
||||||
@@ -109,7 +109,7 @@ public class InfluxExecutor {
|
|||||||
String columnName = columns.get(i);
|
String columnName = columns.get(i);
|
||||||
//属性名有下划线的替换掉
|
//属性名有下划线的替换掉
|
||||||
for (Field declaredField : fields) {
|
for (Field declaredField : fields) {
|
||||||
if (columnName.equalsIgnoreCase(InfluxQueryWrapper.getColumnName(declaredField))) {
|
if (columnName.replace("_","").equalsIgnoreCase(InfluxQueryWrapper.getColumnName(declaredField))) {
|
||||||
//获取属性定义的类型
|
//获取属性定义的类型
|
||||||
declaredField.setAccessible(true);
|
declaredField.setAccessible(true);
|
||||||
//判断是否过滤该条记录,当数据返回 null时
|
//判断是否过滤该条记录,当数据返回 null时
|
||||||
@@ -123,16 +123,16 @@ public class InfluxExecutor {
|
|||||||
declaredField.set(object, InstantUtil.stringToInstant(columnValue.get(i).toString().replace("+08:00", "Z")));
|
declaredField.set(object, InstantUtil.stringToInstant(columnValue.get(i).toString().replace("+08:00", "Z")));
|
||||||
//字符串
|
//字符串
|
||||||
} else if (declaredField.getType() == String.class) {
|
} else if (declaredField.getType() == String.class) {
|
||||||
declaredField.set(object, columnValue.get(i).toString());
|
declaredField.set(object,Objects.isNull(columnValue.get(i))?"":columnValue.get(i).toString());
|
||||||
//浮点双精度
|
//浮点双精度
|
||||||
} else if (declaredField.getType() == Double.class) {
|
} else if (declaredField.getType() == Double.class) {
|
||||||
declaredField.set(object, Double.parseDouble(columnValue.get(i).toString()));
|
declaredField.set(object,Objects.isNull(columnValue.get(i))?null: Double.parseDouble(columnValue.get(i).toString()));
|
||||||
//浮点
|
//浮点
|
||||||
} else if (declaredField.getType() == Float.class) {
|
} else if (declaredField.getType() == Float.class) {
|
||||||
declaredField.set(object, Float.parseFloat(columnValue.get(i).toString()));
|
declaredField.set(object, Objects.isNull(columnValue.get(i))?null: Float.parseFloat(columnValue.get(i).toString()));
|
||||||
//整型
|
//整型
|
||||||
} else if (declaredField.getType() == Integer.class) {
|
} else if (declaredField.getType() == Integer.class) {
|
||||||
declaredField.set(object, Integer.parseInt(columnValue.get(i).toString()));
|
declaredField.set(object,Objects.isNull(columnValue.get(i))?null: Integer.parseInt(columnValue.get(i).toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -221,5 +221,4 @@ public class InfluxExecutor {
|
|||||||
return originalSql.concat(InfluxDbSqlConstant.TZ);
|
return originalSql.concat(InfluxDbSqlConstant.TZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -924,6 +924,22 @@ public class InfluxQueryWrapper {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public <T, R> InfluxQueryWrapper percentile(String columnName,String resultName, int percent) {
|
||||||
|
String selectFragment = InfluxDbSqlConstant.PERCENTILE +
|
||||||
|
InfluxDbSqlConstant.LBK +
|
||||||
|
InfluxDbSqlConstant.DQM +
|
||||||
|
columnName +
|
||||||
|
InfluxDbSqlConstant.DQM +
|
||||||
|
StrPool.COMMA +
|
||||||
|
percent +
|
||||||
|
InfluxDbSqlConstant.RBK +
|
||||||
|
InfluxDbSqlConstant.AS +
|
||||||
|
resultName +
|
||||||
|
StrPool.C_SPACE;
|
||||||
|
selectColumns.add(selectFragment);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* 批量返回field key较大的百分之N的值。
|
* 批量返回field key较大的百分之N的值。
|
||||||
* @author xuyang
|
* @author xuyang
|
||||||
@@ -1278,6 +1294,7 @@ public class InfluxQueryWrapper {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public <T, R, O> InfluxQueryWrapper or(String columnName, List<O> columnValues) {
|
public <T, R, O> InfluxQueryWrapper or(String columnName, List<O> columnValues) {
|
||||||
if (CollectionUtil.isEmpty(columnValues)) {
|
if (CollectionUtil.isEmpty(columnValues)) {
|
||||||
throw new RuntimeException("查询数值集合为空,请校验!");
|
throw new RuntimeException("查询数值集合为空,请校验!");
|
||||||
@@ -1346,6 +1363,20 @@ public class InfluxQueryWrapper {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public <T, R> InfluxQueryWrapper regular(String fieldName, List<String> columnValues) {
|
||||||
|
if (CollectionUtil.isEmpty(columnValues)) {
|
||||||
|
throw new RuntimeException("查询数值集合为空,请校验!");
|
||||||
|
}
|
||||||
|
String columnName = this.getColumnName(measurement, fieldName);
|
||||||
|
String conditionSql = columnName + InfluxDbSqlConstant.EQ;
|
||||||
|
String middleSql = String.join(InfluxDbSqlConstant.REGULAR_MIDDLE, columnValues);
|
||||||
|
conditionSql = conditionSql + InfluxDbSqlConstant.REGULAR_PREFIX
|
||||||
|
+ middleSql
|
||||||
|
+ InfluxDbSqlConstant.REGULAR_SUFFIX;
|
||||||
|
conditions.add(conditionSql);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/********************* [WHERE_clause] [GROUP_BY_clause] [ORDER_BY_clause] [LIMIT_clause] [OFFSET_clause] [SLIMIT_clause] [SOFFSET_clause]*********************/
|
/********************* [WHERE_clause] [GROUP_BY_clause] [ORDER_BY_clause] [LIMIT_clause] [OFFSET_clause] [SLIMIT_clause] [SOFFSET_clause]*********************/
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user