|
@@ -150,15 +150,16 @@ public class AppDeviceService {
|
|
|
public SensorEchartDataResult queryDataByDeviceIdAndRoads(AppDeviceQueryParams appDeviceQueryParams) {
|
|
|
Assert.notNull(appDeviceQueryParams, "appDeviceQueryParams cannot be null");
|
|
|
// 获取用户选择的聚合维度,优先使用用户选择的聚合维度,如果没有选择则根据时间范围计算
|
|
|
+ AggregationWindow window = null;
|
|
|
String aggregationWindow = appDeviceQueryParams.getAggregationWindow();
|
|
|
if (StrUtil.isBlank(aggregationWindow)) {
|
|
|
- aggregationWindow = AggregationWindow.determineAggregationWindow(
|
|
|
+ window = AggregationWindow.determineAggregationWindow(
|
|
|
appDeviceQueryParams.getStartTime(),
|
|
|
- appDeviceQueryParams.getEndTime()).getCode();
|
|
|
+ appDeviceQueryParams.getEndTime());
|
|
|
+ } else {
|
|
|
+ // 如果用户选择了聚合维度,但不在枚举中,使用默认的聚合窗口
|
|
|
+ window = AggregationWindow.fromString(aggregationWindow);
|
|
|
}
|
|
|
- // 根据聚合维度获取相应的聚合窗口
|
|
|
- AggregationWindow window = AggregationWindow.fromString(aggregationWindow);
|
|
|
-
|
|
|
// 查找监控目标区域
|
|
|
MonitorTargetRegion monitorTarget = monitorTargetRegionService.findOneByDeviceCodeAndSensorNo(
|
|
|
appDeviceQueryParams.getSensorCode(),
|
|
@@ -185,6 +186,7 @@ public class AppDeviceService {
|
|
|
SensorEchartDataResult result = new SensorEchartDataResult();
|
|
|
|
|
|
// 遍历传感器类型映射
|
|
|
+ AggregationWindow finalWindow = window;
|
|
|
sensorMapping.forEach((key, dataType) -> {
|
|
|
// 如果传感器类型包含对应的字符
|
|
|
if (sensorType.toLowerCase().contains(key)) {
|
|
@@ -194,7 +196,7 @@ public class AppDeviceService {
|
|
|
appDeviceQueryParams.getSensorRoute(),
|
|
|
appDeviceQueryParams.getStartTime(),
|
|
|
appDeviceQueryParams.getEndTime(),
|
|
|
- dataType,window
|
|
|
+ dataType, finalWindow
|
|
|
);
|
|
|
|
|
|
// 处理数据并设置到对应的字段
|
|
@@ -217,7 +219,6 @@ public class AppDeviceService {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
public Boolean updateDeviceAlarm(AppDeviceAlarmParam appDeviceAlarmParam) {
|
|
|
Assert.notNull(appDeviceAlarmParam, "appDeviceAlarmParam cannot be null");
|
|
|
MonitorTargetRegion monitorTargetRegion = monitorTargetRegionService.getById(appDeviceAlarmParam.getMonitorTargetRegionId());
|