forked from github/dataease
refactor(图表、数据集): 增加数据集图表导出数据总量license校验
This commit is contained in:
parent
bbb4e29645
commit
2386cc755c
@ -16,6 +16,7 @@ import io.dataease.exportCenter.manage.ExportCenterManage;
|
||||
import io.dataease.extensions.datasource.dto.DatasetTableFieldDTO;
|
||||
import io.dataease.extensions.view.dto.ChartViewDTO;
|
||||
import io.dataease.extensions.view.dto.ChartViewFieldDTO;
|
||||
import io.dataease.license.config.LicSt;
|
||||
import io.dataease.result.ResultCode;
|
||||
import io.dataease.utils.JsonUtil;
|
||||
import io.dataease.utils.LogUtil;
|
||||
@ -53,12 +54,19 @@ public class ChartDataServer implements ChartDataApi {
|
||||
|
||||
@Resource
|
||||
private VisualizationTemplateExtendDataManage extendDataManage;
|
||||
@Value("${dataease.export.views.limit:500000}")
|
||||
@Value("${dataease.export.views.limit:100000}")
|
||||
private Integer limit;
|
||||
|
||||
@Resource
|
||||
private DatasetFieldServer datasetFieldServer;
|
||||
|
||||
@Resource(name = "LimitConfig")
|
||||
private LicSt limitConfig;
|
||||
|
||||
private Integer getExportLimit() {
|
||||
return Math.toIntExact(Math.min(limitConfig.ALLATORIxDEMO(), limit));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChartViewDTO getData(ChartViewDTO chartViewDTO) throws Exception {
|
||||
try {
|
||||
@ -94,11 +102,12 @@ public class ChartDataServer implements ChartDataApi {
|
||||
};
|
||||
viewDTO.setXAxis(JsonUtil.parseList(JsonUtil.toJSONString(sourceFields).toString(),listTypeReference));
|
||||
}
|
||||
Integer curLimit = getExportLimit();
|
||||
if (ChartConstants.VIEW_RESULT_MODE.CUSTOM.equals(viewDTO.getResultMode())) {
|
||||
Integer limitCount = viewDTO.getResultCount();
|
||||
viewDTO.setResultCount(limitCount > limit ? limit : limitCount);
|
||||
viewDTO.setResultCount(Math.min(curLimit,limitCount));
|
||||
} else {
|
||||
viewDTO.setResultCount(limit);
|
||||
viewDTO.setResultCount(curLimit);
|
||||
}
|
||||
ChartViewDTO chartViewInfo = getData(viewDTO);
|
||||
List<Object[]> tableRow = (List) chartViewInfo.getData().get("sourceData");
|
||||
|
@ -12,6 +12,7 @@ import io.dataease.api.dataset.union.DatasetGroupInfoDTO;
|
||||
import io.dataease.api.dataset.union.UnionDTO;
|
||||
import io.dataease.extensions.datasource.api.PluginManageApi;
|
||||
import io.dataease.extensions.view.dto.DatasetRowPermissionsTreeObj;
|
||||
import io.dataease.license.config.LicSt;
|
||||
import io.dataease.model.ExportTaskDTO;
|
||||
import io.dataease.api.permissions.dataset.dto.DataSetRowPermissionsTreeDTO;
|
||||
import io.dataease.auth.bo.TokenUserBO;
|
||||
@ -116,6 +117,9 @@ public class ExportCenterManage {
|
||||
@Resource
|
||||
private DatasetDataManage datasetDataManage;
|
||||
|
||||
@Resource(name = "LimitConfig")
|
||||
private LicSt limitConfig;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(core);
|
||||
@ -145,7 +149,11 @@ public class ExportCenterManage {
|
||||
}
|
||||
|
||||
public String exportLimit() {
|
||||
return String.valueOf(limit);
|
||||
return String.valueOf(getExportLimit());
|
||||
}
|
||||
|
||||
private Long getExportLimit() {
|
||||
return Math.min(limitConfig.ALLATORIxDEMO(),limit);
|
||||
}
|
||||
|
||||
public void download(String id, HttpServletResponse response) throws Exception {
|
||||
@ -404,7 +412,8 @@ public class ExportCenterManage {
|
||||
|
||||
String replaceSql = provider.rebuildSQL(SQLProvider.createQuerySQL(sqlMeta, false, false, false), sqlMeta, crossDs, dsMap);
|
||||
Long totalCount = datasetDataManage.getDatasetTotal(dto, replaceSql, null);
|
||||
totalCount = totalCount > limit ? limit : totalCount;
|
||||
Long curLimit = getExportLimit();
|
||||
totalCount = totalCount > curLimit ? curLimit : totalCount;
|
||||
Long totalPage = (totalCount / extractPageSize) + (totalCount % extractPageSize > 0 ? 1 : 0);
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user