Compare commits

..

3 Commits

Author SHA1 Message Date
xy
a6fba7db34 feat(influx): 添加相邻时间点差值计算功能
- 在InfluxDbSqlConstant中新增DIFFERENCE常量定义
- 在InfluxQueryWrapper中添加difference方法实现差值计算功能
- 实现相邻时间点数据差值查询的SQL片段构建逻辑
- 支持通过字段名进行差值计算并返回查询包装器实例
2026-06-03 10:12:55 +08:00
xy
0088ac746d Merge remote-tracking branch 'origin/master' 2025-12-03 16:03:46 +08:00
xy
88bf4b215b 方法微调 2025-12-03 16:01:33 +08:00
2 changed files with 27 additions and 3 deletions

View File

@@ -110,6 +110,7 @@ public interface InfluxDbSqlConstant {
String REGULAR_PREFIX="~/^";
String REGULAR_SUFFIX="$/";
String REGULAR_MIDDLE="|";
String DIFFERENCE = "DIFFERENCE";
/**
* “ tz('Asia/Shanghai')”

View File

@@ -13,7 +13,10 @@ import org.influxdb.annotation.Column;
import org.influxdb.annotation.Measurement;
import java.lang.reflect.Field;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
/**
* @author hongawen
@@ -595,6 +598,25 @@ public class InfluxQueryWrapper {
return this;
}
/***
* 计算相邻时间点之间的差值
* @author xy
* @param columnName 表字段名
* @return InfluxQueryWrapper
* DIFFERENCE("columnName")
*/
public <T, R> InfluxQueryWrapper difference(String columnName) {
String selectFragment = InfluxDbSqlConstant.DIFFERENCE +
InfluxDbSqlConstant.LBK +
InfluxDbSqlConstant.DQM +
columnName +
InfluxDbSqlConstant.DQM +
InfluxDbSqlConstant.RBK +
InfluxDbSqlConstant.AS_VALUE;
selectColumns.add(selectFragment);
return this;
}
/***
* 注:该函数还需调研,暂时不要用
* 统计指定字段邻近值的变化率
@@ -986,8 +1008,9 @@ public class InfluxQueryWrapper {
throw new RuntimeException("查询数值集合为空,请校验!");
}
for (Object obj : diffContent) {
String fieldName = prefix + obj + suffix;
this.select(fieldName,fieldName);
String fieldName = prefix + obj;
String resultName = suffix + obj;
this.select(fieldName,resultName);
}
return this;
}