fix(record): 优化获取记录表名称列表逻辑

- 将表存在性检查移至循环内,避免生成不必要的表名
- 如果表不存在,则跳过,不添加到结果列表中
- 移除了循环外的冗余表存在性检查
boardTest
zch 4 weeks ago
parent 79b4d4f6ad
commit 5fe810b279

@ -152,17 +152,14 @@ public class RecordIotenvInstantServiceImpl implements IRecordIotenvInstantServi
while (!currentDate.after(endDateOnly)) { while (!currentDate.after(endDateOnly)) {
String tableSuffix = tableFormat.format(currentDate); String tableSuffix = tableFormat.format(currentDate);
String tableName = "record_iotenv_instant_" + tableSuffix; String tableName = "record_iotenv_instant_" + tableSuffix;
if (isTableExists(tableName)){
tableNames.add(tableName); tableNames.add(tableName);
}
// 日期加1天 // 日期加1天
calendar.setTime(currentDate); calendar.setTime(currentDate);
calendar.add(Calendar.DAY_OF_MONTH, 1); calendar.add(Calendar.DAY_OF_MONTH, 1);
currentDate = calendar.getTime(); currentDate = calendar.getTime();
} }
for (String tableName : tableNames){
if (!isTableExists(tableName)){
return new ArrayList<>();
}
}
return tableNames; return tableNames;
} }

Loading…
Cancel
Save