mirror of
https://github.com/dataease/dataease.git
synced 2026-06-12 16:31:11 +08:00
feat: 【数据集】数据集增加排序字段,方便导出排序
This commit is contained in:
@@ -120,6 +120,11 @@ public class ChartDataServer implements ChartDataApi {
|
||||
TypeReference<List<ChartViewFieldDTO>> listTypeReference = new TypeReference<List<ChartViewFieldDTO>>() {
|
||||
};
|
||||
viewDTO.setXAxis(JsonUtil.parseList(JsonUtil.toJSONString(sourceFields).toString(), listTypeReference));
|
||||
viewDTO.getXAxis().forEach(x -> {
|
||||
if (x.getOrderChecked()) {
|
||||
x.setSort("asc");
|
||||
}
|
||||
});
|
||||
}
|
||||
int curLimit = Math.toIntExact(ExportCenterUtils.getExportLimit("view"));
|
||||
int curDsLimit = Math.toIntExact(ExportCenterUtils.getExportLimit("dataset"));
|
||||
@@ -833,10 +838,12 @@ public class ChartDataServer implements ChartDataApi {
|
||||
}
|
||||
|
||||
@DeLog(id = "#p0", ot = LogOT.EXPORT, st = LogST.PANEL)
|
||||
public void exportPanelViewLog(Long id) {}
|
||||
public void exportPanelViewLog(Long id) {
|
||||
}
|
||||
|
||||
@DeLog(id = "#p0", ot = LogOT.EXPORT, st = LogST.SCREEN)
|
||||
public void exportScreenViewLog(Long id) {}
|
||||
public void exportScreenViewLog(Long id) {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.io.Serializable;
|
||||
* </p>
|
||||
*
|
||||
* @author fit2cloud
|
||||
* @since 2025-02-06
|
||||
* @since 2025-11-26
|
||||
*/
|
||||
@TableName("core_dataset_table_field")
|
||||
public class CoreDatasetTableField implements Serializable {
|
||||
@@ -141,6 +141,11 @@ public class CoreDatasetTableField implements Serializable {
|
||||
*/
|
||||
private String params;
|
||||
|
||||
/**
|
||||
* 是否排序
|
||||
*/
|
||||
private Boolean orderChecked;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -341,6 +346,14 @@ public class CoreDatasetTableField implements Serializable {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
public Boolean getOrderChecked() {
|
||||
return orderChecked;
|
||||
}
|
||||
|
||||
public void setOrderChecked(Boolean orderChecked) {
|
||||
this.orderChecked = orderChecked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CoreDatasetTableField{" +
|
||||
@@ -369,6 +382,7 @@ public class CoreDatasetTableField implements Serializable {
|
||||
", dateFormat = " + dateFormat +
|
||||
", dateFormatType = " + dateFormatType +
|
||||
", params = " + params +
|
||||
", orderChecked = " + orderChecked +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
* </p>
|
||||
*
|
||||
* @author fit2cloud
|
||||
* @since 2025-02-06
|
||||
* @since 2025-11-26
|
||||
*/
|
||||
@Mapper
|
||||
public interface CoreDatasetTableFieldMapper extends BaseMapper<CoreDatasetTableField> {
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package io.dataease.engine.trans;
|
||||
|
||||
import io.dataease.api.chart.dto.DeSortField;
|
||||
import io.dataease.constant.SQLConstants;
|
||||
import io.dataease.extensions.datasource.dto.DatasetTableFieldDTO;
|
||||
import io.dataease.extensions.datasource.model.SQLMeta;
|
||||
import io.dataease.extensions.datasource.model.SQLObj;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Author Junjun
|
||||
*/
|
||||
public class DatasetOrder2SQLObj {
|
||||
|
||||
public static void getOrders(SQLMeta meta, List<DeSortField> sortFields, List<DatasetTableFieldDTO> originFields) {
|
||||
SQLObj tableObj = meta.getTable();
|
||||
List<SQLObj> xOrders = meta.getXOrders() == null ? new ArrayList<>() : meta.getXOrders();
|
||||
if (ObjectUtils.isEmpty(tableObj)) {
|
||||
return;
|
||||
}
|
||||
if (ObjectUtils.isNotEmpty(sortFields)) {
|
||||
for (int i = 0; i < sortFields.size(); i++) {
|
||||
DeSortField deSortField = sortFields.get(i);
|
||||
for (int j = 0; j < originFields.size(); j++) {
|
||||
if (deSortField.getId().equals(originFields.get(j).getId())) {
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
||||
SQLObj order = SQLObj.builder()
|
||||
.orderField(String.format(SQLConstants.FIELD_DOT, fieldAlias))
|
||||
.orderAlias(String.format(SQLConstants.FIELD_DOT, fieldAlias))
|
||||
.orderDirection(deSortField.getOrderDirection()).build();
|
||||
xOrders.add(order);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
meta.setXOrders(xOrders);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -152,6 +152,7 @@ public class Field2SQLObj {
|
||||
return SQLObj.builder()
|
||||
.fieldName(fieldName)
|
||||
.fieldAlias(fieldAlias)
|
||||
.id(f.getId())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.dataease.exportCenter.manage;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import io.dataease.api.chart.dto.DeSortField;
|
||||
import io.dataease.api.chart.dto.ViewDetailField;
|
||||
import io.dataease.api.chart.request.ChartExcelRequest;
|
||||
import io.dataease.api.chart.request.ChartExcelRequestInner;
|
||||
@@ -24,10 +25,7 @@ import io.dataease.dataset.dao.auto.mapper.CoreDatasetGroupMapper;
|
||||
import io.dataease.dataset.manage.*;
|
||||
import io.dataease.datasource.utils.DatasourceUtils;
|
||||
import io.dataease.engine.sql.SQLProvider;
|
||||
import io.dataease.engine.trans.Field2SQLObj;
|
||||
import io.dataease.engine.trans.Order2SQLObj;
|
||||
import io.dataease.engine.trans.Table2SQLObj;
|
||||
import io.dataease.engine.trans.WhereTree2Str;
|
||||
import io.dataease.engine.trans.*;
|
||||
import io.dataease.engine.utils.Utils;
|
||||
import io.dataease.exception.DEException;
|
||||
import io.dataease.exportCenter.dao.auto.entity.CoreExportTask;
|
||||
@@ -283,7 +281,17 @@ public class ExportCenterDownLoadManage {
|
||||
Table2SQLObj.table2sqlobj(sqlMeta, null, "(" + sql + ")", crossDs);
|
||||
Field2SQLObj.field2sqlObj(sqlMeta, allFields, allFields, crossDs, dsMap, Utils.getParams(allFields), null, pluginManage);
|
||||
WhereTree2Str.transFilterTrees(sqlMeta, rowPermissionsTree, allFields, crossDs, dsMap, Utils.getParams(allFields), null, pluginManage);
|
||||
Order2SQLObj.getOrders(sqlMeta, dto.getSortFields(), allFields, crossDs, dsMap, Utils.getParams(allFields), null, pluginManage);
|
||||
List<DeSortField> sortFields = new ArrayList<>();
|
||||
for (DatasetTableFieldDTO field : allFields) {
|
||||
if (field.getOrderChecked()) {
|
||||
DeSortField sortField = new DeSortField();
|
||||
BeanUtils.copyBean(sortField, field);
|
||||
sortField.setOrderDirection("asc");
|
||||
sortFields.add(sortField);
|
||||
}
|
||||
}
|
||||
dto.setSortFields(sortFields);
|
||||
DatasetOrder2SQLObj.getOrders(sqlMeta, dto.getSortFields(), allFields);
|
||||
String replaceSql = provider.rebuildSQL(SQLProvider.createQuerySQL(sqlMeta, false, false, false), sqlMeta, crossDs, dsMap);
|
||||
Long totalCount = datasetDataManage.getDatasetTotal(dto, replaceSql, null);
|
||||
Long curLimit = ExportCenterUtils.getExportLimit("dataset");
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
alter table `core_dataset_table_field`
|
||||
add `order_checked` tinyint(1) default 0 null comment '是否排序';
|
||||
@@ -2215,6 +2215,12 @@ const getIconNameCalc = (deType, extField, dimension = false) => {
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column :label="t('chart.total_sort_field')" align="center" width="90">
|
||||
<template #default="scope">
|
||||
<el-checkbox v-model="scope.row.orderChecked" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column fixed="right" :label="t('chart.dimension')">
|
||||
<template #default="scope">
|
||||
<el-tooltip
|
||||
@@ -2414,6 +2420,12 @@ const getIconNameCalc = (deType, extField, dimension = false) => {
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column :label="t('chart.total_sort_field')" align="center" width="90">
|
||||
<template #default="scope">
|
||||
<el-checkbox v-model="scope.row.orderChecked" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column fixed="right" :label="t('chart.quota')">
|
||||
<template #default="scope">
|
||||
<el-tooltip
|
||||
|
||||
@@ -138,6 +138,9 @@ public class DatasetTableFieldDTO implements Serializable {
|
||||
*/
|
||||
private Boolean desensitized;
|
||||
|
||||
private Boolean orderChecked;
|
||||
|
||||
|
||||
/**
|
||||
* 计算字段参数
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user