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); } }