diff --git a/backend/src/main/java/io/dataease/dto/chart/ChartViewDTO.java b/backend/src/main/java/io/dataease/dto/chart/ChartViewDTO.java index 16eb7007fe..923699b4c1 100644 --- a/backend/src/main/java/io/dataease/dto/chart/ChartViewDTO.java +++ b/backend/src/main/java/io/dataease/dto/chart/ChartViewDTO.java @@ -43,4 +43,5 @@ public class ChartViewDTO extends ChartViewWithBLOBs { private String yAxisExt; private long totalPage; + private long totalItems; } diff --git a/backend/src/main/java/io/dataease/provider/query/ck/CKQueryProvider.java b/backend/src/main/java/io/dataease/provider/query/ck/CKQueryProvider.java index 0be43013ff..cc3e7a1759 100644 --- a/backend/src/main/java/io/dataease/provider/query/ck/CKQueryProvider.java +++ b/backend/src/main/java/io/dataease/provider/query/ck/CKQueryProvider.java @@ -17,6 +17,7 @@ import io.dataease.plugins.common.dto.sqlObj.SQLObj; import io.dataease.plugins.common.request.chart.ChartExtFilterRequest; import io.dataease.plugins.common.request.permission.DataSetRowPermissionsTreeDTO; import io.dataease.plugins.common.request.permission.DatasetRowPermissionsTreeItem; +import io.dataease.plugins.datasource.entity.PageInfo; import io.dataease.plugins.datasource.query.QueryProvider; import io.dataease.plugins.datasource.query.Utils; import org.apache.commons.collections4.CollectionUtils; @@ -393,8 +394,21 @@ public class CKQueryProvider extends QueryProvider { return sqlLimit(st.render(), view); } + @Override + public String getSQLWithPage(boolean isTable, String table, List xAxis, List fieldCustomFilter, List rowPermissionsTree, List extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, PageInfo pageInfo) { + if (isTable) { + return originalTableInfo(table, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view) + " LIMIT " + (pageInfo.getGoPage() - 1) * pageInfo.getPageSize() + "," + pageInfo.getPageSize(); + } else { + return originalTableInfo("(" + sqlFix(table) + ")", xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view) + " LIMIT " + (pageInfo.getGoPage() - 1) * pageInfo.getPageSize() + "," + pageInfo.getPageSize(); + } + } + @Override public String getSQLTableInfo(String table, List xAxis, List fieldCustomFilter, List rowPermissionsTree, List extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) { + return sqlLimit(originalTableInfo(table, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view), view); + } + + private String originalTableInfo(String table, List xAxis, List fieldCustomFilter, List rowPermissionsTree, List extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) { SQLObj tableObj = SQLObj.builder() .tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(CKConstants.KEYWORD_TABLE, table)) .tableAlias(String.format(TABLE_ALIAS_PREFIX, 0)) @@ -466,7 +480,7 @@ public class CKQueryProvider extends QueryProvider { .build(); if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders); if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL); - return sqlLimit(st.render(), view); + return st.render(); } @Override @@ -1072,10 +1086,14 @@ public class CKQueryProvider extends QueryProvider { if (ObjectUtils.isNotEmpty(datasetTableField) && datasetTableField.getDeType() == DeTypeConstants.DE_TIME && StringUtils.equalsIgnoreCase(request.getOperator(), "between")) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); request.setOperator("ge"); - request.setValue(new ArrayList(){{add(String.format(toDateTime64, "'" + simpleDateFormat.format(new Date(Long.parseLong(requestValue.get(0)))) + "'"));}}); + request.setValue(new ArrayList() {{ + add(String.format(toDateTime64, "'" + simpleDateFormat.format(new Date(Long.parseLong(requestValue.get(0)))) + "'")); + }}); ChartExtFilterRequest requestCopy = BeanUtils.copyBean(new ChartExtFilterRequest(), request); requestCopy.setOperator("le"); - requestCopy.setValue(new ArrayList(){{add(String.format(toDateTime64, "'" + simpleDateFormat.format(new Date(Long.parseLong(requestValue.get(1)))) + "'"));}}); + requestCopy.setValue(new ArrayList() {{ + add(String.format(toDateTime64, "'" + simpleDateFormat.format(new Date(Long.parseLong(requestValue.get(1)))) + "'")); + }}); atomicReference.set(requestCopy); } }); diff --git a/backend/src/main/java/io/dataease/service/chart/ChartViewService.java b/backend/src/main/java/io/dataease/service/chart/ChartViewService.java index 2cafbeb0e6..0754b70fb3 100644 --- a/backend/src/main/java/io/dataease/service/chart/ChartViewService.java +++ b/backend/src/main/java/io/dataease/service/chart/ChartViewService.java @@ -860,6 +860,7 @@ public class ChartViewService { String querySql = null; long totalPage = 0l; + long totalItems = 0l; String totalPageSql = null; PageInfo pageInfo = new PageInfo(); pageInfo.setGoPage(chartExtRequest.getGoPage() != null ? chartExtRequest.getGoPage() : 1); @@ -941,8 +942,8 @@ public class ChartViewService { } if (StringUtils.isNotEmpty(totalPageSql)) { datasourceRequest.setQuery(totalPageSql); - totalPage = Long.valueOf(datasourceProvider.getData(datasourceRequest).get(0)[0]); - totalPage = totalPage / pageInfo.getPageSize() + totalPage % pageInfo.getPageSize() > 0 ? 1 : 0; + totalItems = Long.valueOf(datasourceProvider.getData(datasourceRequest).get(0)[0]); + totalPage = totalItems / pageInfo.getPageSize() + totalItems % pageInfo.getPageSize() > 0 ? 1 : 0; } datasourceRequest.setQuery(querySql); @@ -1158,6 +1159,7 @@ public class ChartViewService { Map mapTableNormal = ChartDataBuild.transTableNormal(xAxis, yAxis, view, data, extStack, desensitizationList); chartViewDTO = uniteViewResult(datasourceRequest.getQuery(), mapChart, mapTableNormal, view, isDrill, drillFilters, dynamicAssistFields, assistData); chartViewDTO.setTotalPage(totalPage); + chartViewDTO.setTotalItems(totalItems); return chartViewDTO; }