feat(steady-checksquare): 新增数据校验功能模块
- 添加数据校验历史记录查询接口 - 实现数据校验任务创建功能 - 新增数据校验详情查询接口 - 添加谐波奇偶关系异常检测规则 - 实现数据校验明细数据结构 - 添加数据校验编号生成工具 - 优化InfluxDB查询组件并增加缓存机制 - 添加数据校验常量定义 - 实现数据校验值生成器中的派生字段处理逻辑 - 新增数据校验相关的VO、PO、DTO类 - 添加数据校验组件单元测试
This commit is contained in:
@@ -223,7 +223,8 @@ public class AddDataValueGenerator {
|
||||
if (baseValue == null) {
|
||||
throw new IllegalStateException("派生字段缺少主值:" + column);
|
||||
}
|
||||
double factor = noise(state.sharedSeed + column.hashCode(), 0.01D, 0.05D);
|
||||
String baseColumn = resolveDerivedBaseColumn(column, metricType);
|
||||
double factor = noise(state.sharedSeed + baseColumn.hashCode(), 0.01D, 0.05D);
|
||||
double delta = Math.max(Math.abs(baseValue) * factor, 0.005D);
|
||||
double value;
|
||||
if (MetricType.MAX.equals(metricType)) {
|
||||
@@ -239,6 +240,16 @@ public class AddDataValueGenerator {
|
||||
return round(value, 4);
|
||||
}
|
||||
|
||||
private String resolveDerivedBaseColumn(String column, MetricType metricType) {
|
||||
if (MetricType.MAX.equals(metricType)) {
|
||||
return removeSuffix(column, SUFFIX_MAX);
|
||||
}
|
||||
if (MetricType.MIN.equals(metricType)) {
|
||||
return removeSuffix(column, SUFFIX_MIN);
|
||||
}
|
||||
return removeSuffix(column, SUFFIX_CP95);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建同源基础状态。
|
||||
*
|
||||
|
||||
@@ -25,4 +25,24 @@ class AddDataValueGeneratorTest {
|
||||
|
||||
Assertions.assertEquals(0, row.get(3));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldKeepStatValuesOrderedForSameTimeAndMetric() {
|
||||
AddDataValueGenerator generator = new AddDataValueGenerator();
|
||||
AddDataTableDefinition definition = new AddDataTableDefinition("data_v",
|
||||
Arrays.asList("TIMEID", "LINEID", "PHASIC_TYPE", "QUALITYFLAG",
|
||||
"RMS", "RMS_MAX", "RMS_CP95", "RMS_MIN"),
|
||||
Arrays.asList("A"), 100, AddDataTableDefinition.TimeAxisType.REQUEST_INTERVAL);
|
||||
|
||||
List<Object> row = generator.generateRow(definition, "line-001",
|
||||
LocalDateTime.of(2026, 5, 18, 10, 0, 0), "A");
|
||||
|
||||
double avg = ((Number) row.get(4)).doubleValue();
|
||||
double max = ((Number) row.get(5)).doubleValue();
|
||||
double cp95 = ((Number) row.get(6)).doubleValue();
|
||||
double min = ((Number) row.get(7)).doubleValue();
|
||||
Assertions.assertTrue(max >= cp95, "MAX should be greater than or equal to CP95");
|
||||
Assertions.assertTrue(cp95 >= avg, "CP95 should be greater than or equal to AVG");
|
||||
Assertions.assertTrue(avg >= min, "AVG should be greater than or equal to MIN");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user