|
@@ -63,10 +63,10 @@ public class QueryTdengineDataServiceImpl extends AbstractCrudService<QueryTdeng
|
|
|
|
|
|
|
|
// 遍历设备表集合,自动忽略表中不存在的字段,用有效字段构建查询,避免错误
|
|
// 遍历设备表集合,自动忽略表中不存在的字段,用有效字段构建查询,避免错误
|
|
|
for (int i = 0; i < deviceUUIds.size(); i++) {
|
|
for (int i = 0; i < deviceUUIds.size(); i++) {
|
|
|
- try (Connection connection = dataSource.getConnection()) {
|
|
|
|
|
|
|
|
|
|
- String tablename = "_"+deviceUUIds.get(i);
|
|
|
|
|
|
|
+ String tablename = "_"+deviceUUIds.get(i);
|
|
|
|
|
|
|
|
|
|
+ try (Connection connection = dataSource.getConnection()) {
|
|
|
String sql = "describe " + tablename;
|
|
String sql = "describe " + tablename;
|
|
|
|
|
|
|
|
try (PreparedStatement itemStmt = connection.prepareStatement(sql)) {
|
|
try (PreparedStatement itemStmt = connection.prepareStatement(sql)) {
|
|
@@ -123,6 +123,15 @@ public class QueryTdengineDataServiceImpl extends AbstractCrudService<QueryTdeng
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ } catch (SQLException e) {
|
|
|
|
|
+ // 判断TDengine专属错误码 0x2603 = 表不存在
|
|
|
|
|
+ if (e.getMessage().contains("0x2603") || e.getMessage().contains("Table does not exist")) {
|
|
|
|
|
+ System.out.println("表" + tablename + "不存在,跳过");
|
|
|
|
|
+ log.error("表" + tablename + "不存在,跳过");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 其他异常正常打印堆栈
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|
|
@@ -141,10 +150,10 @@ public class QueryTdengineDataServiceImpl extends AbstractCrudService<QueryTdeng
|
|
|
|
|
|
|
|
// 遍历设备表集合,自动忽略表中不存在的字段,用有效字段构建查询,避免错误
|
|
// 遍历设备表集合,自动忽略表中不存在的字段,用有效字段构建查询,避免错误
|
|
|
for (int i = 0; i < deviceUUIds.size(); i++) {
|
|
for (int i = 0; i < deviceUUIds.size(); i++) {
|
|
|
- try (Connection connection = dataSource.getConnection()) {
|
|
|
|
|
|
|
|
|
|
- String tablename = "_"+deviceUUIds.get(i);
|
|
|
|
|
|
|
+ String tablename = "_"+deviceUUIds.get(i);
|
|
|
|
|
|
|
|
|
|
+ try (Connection connection = dataSource.getConnection()) {
|
|
|
String sql = "describe " + tablename;
|
|
String sql = "describe " + tablename;
|
|
|
|
|
|
|
|
try (PreparedStatement itemStmt = connection.prepareStatement(sql)) {
|
|
try (PreparedStatement itemStmt = connection.prepareStatement(sql)) {
|
|
@@ -228,6 +237,15 @@ public class QueryTdengineDataServiceImpl extends AbstractCrudService<QueryTdeng
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ } catch (SQLException e) {
|
|
|
|
|
+ // 判断TDengine专属错误码 0x2603 = 表不存在
|
|
|
|
|
+ if (e.getMessage().contains("0x2603") || e.getMessage().contains("Table does not exist")) {
|
|
|
|
|
+ System.out.println("表" + tablename + "不存在,跳过");
|
|
|
|
|
+ log.error("表" + tablename + "不存在,跳过");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 其他异常正常打印堆栈
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|
|
@@ -352,7 +370,6 @@ public class QueryTdengineDataServiceImpl extends AbstractCrudService<QueryTdeng
|
|
|
}
|
|
}
|
|
|
} catch (SQLException e) {
|
|
} catch (SQLException e) {
|
|
|
log.error("能耗分项汇总查询失败, sql=" + sql + ", " + e.getMessage());
|
|
log.error("能耗分项汇总查询失败, sql=" + sql + ", " + e.getMessage());
|
|
|
- throw new BusinessException("能耗分项汇总查询失败: " + e.getMessage());
|
|
|
|
|
}
|
|
}
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
@@ -405,7 +422,6 @@ public class QueryTdengineDataServiceImpl extends AbstractCrudService<QueryTdeng
|
|
|
}
|
|
}
|
|
|
} catch (SQLException e) {
|
|
} catch (SQLException e) {
|
|
|
log.error("能耗分项趋势查询失败, sql=" + sql + ", " + e.getMessage());
|
|
log.error("能耗分项趋势查询失败, sql=" + sql + ", " + e.getMessage());
|
|
|
- throw new BusinessException("能耗分项趋势查询失败: " + e.getMessage());
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
result.setPoints(points);
|
|
result.setPoints(points);
|