09061026:对这个资产展示使用线程池的方法去做,第六次优化代码

master
冷调 2024-09-06 10:26:49 +08:00
parent 7cea57439c
commit c431f36d19
1 changed files with 20 additions and 1 deletions

View File

@ -373,7 +373,26 @@ public class DataValueServiceImpl extends ServiceImpl<DataValueMapper, DataValue
}
}
@Override
public Integer getTableValueTotal(DataValueModel dataValueModel) {
MysqlQuery mysqlQuery = new MysqlQuery();
mysqlQuery.setDataSourceId(String.valueOf(dataValueModel.getBasicId()));
DataSource dataSource = dataSourceService.getById(dataValueModel.getBasicId());
MysqlPool mysqlPool = new MysqlPool(dataSource);
mysqlPool.init();
Connection conn = mysqlPool.getConn();
try (Statement statement = conn.createStatement();
ResultSet resultSet = statement.executeQuery(dataValueModel.getSql())) {
if (resultSet.next()) {
return resultSet.getInt(1);
}
} catch (SQLException e) {
throw new RuntimeException(e);
}
return 0;
}
}