From 41d3be9e1a2928a79da02358ff083cad4183f430 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=B7=E6=88=90=E4=BC=9F?= Date: Fri, 6 Dec 2024 11:50:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9avgv=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/service/impl/DataServiceImpl.java | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/das/src/main/java/com/das/modules/data/service/impl/DataServiceImpl.java b/das/src/main/java/com/das/modules/data/service/impl/DataServiceImpl.java index 2b9995d6..43fc2235 100644 --- a/das/src/main/java/com/das/modules/data/service/impl/DataServiceImpl.java +++ b/das/src/main/java/com/das/modules/data/service/impl/DataServiceImpl.java @@ -274,12 +274,13 @@ public class DataServiceImpl implements DataService { return null; } String tableName = ""; - if (cacheService.getIotModelCache().isHighSpeed(deviceInfoCache.getIotModelId(), attr)){ - tableName = String.format("h_%s", deviceInfoCache.getDeviceId()); + if (cacheService.getIotModelCache().isCalculate(deviceInfoCache.getIotModelId(), attr)){ + tableName = String.format("c_%d_%s", deviceInfoCache.getDeviceId(), attr.toLowerCase()); + return tdEngineService.getTimeSumCalcValue(tableName, attr.toLowerCase(), startTime, endTime); + } else if (cacheService.getIotModelCache().isHighSpeed(deviceInfoCache.getIotModelId(), attr)){ + tableName = String.format("h%d", deviceInfoCache.getDeviceId()); } else if (cacheService.getIotModelCache().isLowSpeed(deviceInfoCache.getIotModelId(), attr)){ - tableName = String.format("l_%s", deviceInfoCache.getDeviceId()); - } else if (cacheService.getIotModelCache().isCalculate(deviceInfoCache.getIotModelId(), attr)){ - tableName = String.format("c_%s", deviceInfoCache.getDeviceId()); + tableName = String.format("l%d", deviceInfoCache.getDeviceId()); } return tdEngineService.getTimeTopValue(tableName, attr, startTime, endTime); } @@ -292,14 +293,14 @@ public class DataServiceImpl implements DataService { } String tableName = ""; if (cacheService.getIotModelCache().isCalculate(deviceInfoCache.getIotModelId(), attr)){ - tableName = String.format("c_%s_%s", deviceInfoCache.getDeviceId(), attr.toLowerCase()); - return tdEngineService.getTimeSumCalcValue(tableName, attr, startTime, endTime); - } else if (cacheService.getIotModelCache().isHighSpeed(deviceInfoCache.getIotModelId(), attr.toLowerCase())){ - tableName = String.format("h_%s", deviceInfoCache.getDeviceId()); - } else if (cacheService.getIotModelCache().isLowSpeed(deviceInfoCache.getIotModelId(), attr.toLowerCase())){ - tableName = String.format("l_%s", deviceInfoCache.getDeviceId(), attr.toLowerCase()); + tableName = String.format("c_%d_%s", deviceInfoCache.getDeviceId(), attr.toLowerCase()); + return tdEngineService.getTimeSumCalcValue(tableName, attr.toLowerCase(), startTime, endTime); + } else if (cacheService.getIotModelCache().isHighSpeed(deviceInfoCache.getIotModelId(), attr)){ + tableName = String.format("h%d", deviceInfoCache.getDeviceId()); + } else if (cacheService.getIotModelCache().isLowSpeed(deviceInfoCache.getIotModelId(), attr)){ + tableName = String.format("l%d", deviceInfoCache.getDeviceId()); } - return tdEngineService.getTimeSumValue(tableName, attr, startTime, endTime); + return tdEngineService.getTimeSumValue(tableName, attr.toLowerCase(), startTime, endTime); } @Override @@ -310,13 +311,13 @@ public class DataServiceImpl implements DataService { } String tableName = ""; if (cacheService.getIotModelCache().isCalculate(deviceInfoCache.getIotModelId(), attr)){ - tableName = String.format("c_%s_%s", deviceInfoCache.getDeviceId(), attr.toLowerCase()); - return tdEngineService.getTimeAvgCalcValue(tableName, attr, startTime, endTime); - } else if (cacheService.getIotModelCache().isHighSpeed(deviceInfoCache.getIotModelId(), attr.toLowerCase())){ - tableName = String.format("h_%s", deviceInfoCache.getDeviceId()); - } else if (cacheService.getIotModelCache().isLowSpeed(deviceInfoCache.getIotModelId(), attr.toLowerCase())){ - tableName = String.format("l_%s", deviceInfoCache.getDeviceId(), attr.toLowerCase()); + tableName = String.format("c_%d_%s", deviceInfoCache.getDeviceId(), attr.toLowerCase()); + return tdEngineService.getTimeAvgCalcValue(tableName, attr.toLowerCase(), startTime, endTime); + } else if (cacheService.getIotModelCache().isHighSpeed(deviceInfoCache.getIotModelId(), attr)){ + tableName = String.format("h%d", deviceInfoCache.getDeviceId()); + } else if (cacheService.getIotModelCache().isLowSpeed(deviceInfoCache.getIotModelId(), attr)){ + tableName = String.format("l%d", deviceInfoCache.getDeviceId()); } - return tdEngineService.getTimeAvgValue(tableName, attr, startTime, endTime); + return tdEngineService.getTimeAvgValue(tableName, attr.toLowerCase(), startTime, endTime); } }