feat(仪表板): 原始明细导出优化
This commit is contained in:
parent
3f6c717864
commit
d573545fba
@ -1,5 +1,6 @@
|
|||||||
package io.dataease.chart.server;
|
package io.dataease.chart.server;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import io.dataease.api.chart.ChartDataApi;
|
import io.dataease.api.chart.ChartDataApi;
|
||||||
import io.dataease.api.chart.dto.ViewDetailField;
|
import io.dataease.api.chart.dto.ViewDetailField;
|
||||||
import io.dataease.api.chart.request.ChartExcelRequest;
|
import io.dataease.api.chart.request.ChartExcelRequest;
|
||||||
@ -8,11 +9,15 @@ import io.dataease.chart.constant.ChartConstants;
|
|||||||
import io.dataease.chart.manage.ChartDataManage;
|
import io.dataease.chart.manage.ChartDataManage;
|
||||||
import io.dataease.constant.AuthConstant;
|
import io.dataease.constant.AuthConstant;
|
||||||
import io.dataease.constant.CommonConstants;
|
import io.dataease.constant.CommonConstants;
|
||||||
|
import io.dataease.dataset.server.DatasetFieldServer;
|
||||||
import io.dataease.engine.constant.DeTypeConstants;
|
import io.dataease.engine.constant.DeTypeConstants;
|
||||||
import io.dataease.exception.DEException;
|
import io.dataease.exception.DEException;
|
||||||
import io.dataease.exportCenter.manage.ExportCenterManage;
|
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.ChartViewDTO;
|
||||||
|
import io.dataease.extensions.view.dto.ChartViewFieldDTO;
|
||||||
import io.dataease.result.ResultCode;
|
import io.dataease.result.ResultCode;
|
||||||
|
import io.dataease.utils.JsonUtil;
|
||||||
import io.dataease.utils.LogUtil;
|
import io.dataease.utils.LogUtil;
|
||||||
import io.dataease.visualization.manage.VisualizationTemplateExtendDataManage;
|
import io.dataease.visualization.manage.VisualizationTemplateExtendDataManage;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
@ -51,6 +56,9 @@ public class ChartDataServer implements ChartDataApi {
|
|||||||
@Value("${export.views.limit:500000}")
|
@Value("${export.views.limit:500000}")
|
||||||
private Integer limit;
|
private Integer limit;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DatasetFieldServer datasetFieldServer;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChartViewDTO getData(ChartViewDTO chartViewDTO) throws Exception {
|
public ChartViewDTO getData(ChartViewDTO chartViewDTO) throws Exception {
|
||||||
try {
|
try {
|
||||||
@ -70,6 +78,22 @@ public class ChartDataServer implements ChartDataApi {
|
|||||||
try {
|
try {
|
||||||
ChartViewDTO viewDTO = request.getViewInfo();
|
ChartViewDTO viewDTO = request.getViewInfo();
|
||||||
viewDTO.setIsExcelExport(true);
|
viewDTO.setIsExcelExport(true);
|
||||||
|
String[] dsHeader = null;
|
||||||
|
Integer[] dsTypes = null;
|
||||||
|
//downloadType = dataset 为下载原始名字 这里做数据转换模拟 table-info类型图表导出
|
||||||
|
if ("dataset".equals(request.getDownloadType())) {
|
||||||
|
viewDTO.setType("table-info");
|
||||||
|
List<DatasetTableFieldDTO> sourceFields = datasetFieldServer.listByDatasetGroup(viewDTO.getTableId());
|
||||||
|
dsHeader = sourceFields.stream()
|
||||||
|
.map(DatasetTableFieldDTO::getName)
|
||||||
|
.toArray(String[]::new);
|
||||||
|
dsTypes = sourceFields.stream()
|
||||||
|
.map(DatasetTableFieldDTO::getDeType)
|
||||||
|
.toArray(Integer[]::new);
|
||||||
|
TypeReference<List<ChartViewFieldDTO>> listTypeReference = new TypeReference<List<ChartViewFieldDTO>>(){
|
||||||
|
};
|
||||||
|
viewDTO.setXAxis(JsonUtil.parseList(JsonUtil.toJSONString(sourceFields).toString(),listTypeReference));
|
||||||
|
}
|
||||||
if (ChartConstants.VIEW_RESULT_MODE.CUSTOM.equals(viewDTO.getResultMode())) {
|
if (ChartConstants.VIEW_RESULT_MODE.CUSTOM.equals(viewDTO.getResultMode())) {
|
||||||
Integer limitCount = viewDTO.getResultCount();
|
Integer limitCount = viewDTO.getResultCount();
|
||||||
viewDTO.setResultCount(limitCount > limit ? limit : limitCount);
|
viewDTO.setResultCount(limitCount > limit ? limit : limitCount);
|
||||||
@ -78,6 +102,10 @@ public class ChartDataServer implements ChartDataApi {
|
|||||||
}
|
}
|
||||||
ChartViewDTO chartViewInfo = getData(viewDTO);
|
ChartViewDTO chartViewInfo = getData(viewDTO);
|
||||||
List<Object[]> tableRow = (List) chartViewInfo.getData().get("sourceData");
|
List<Object[]> tableRow = (List) chartViewInfo.getData().get("sourceData");
|
||||||
|
if ("dataset".equals(request.getDownloadType())) {
|
||||||
|
request.setHeader(dsHeader);
|
||||||
|
request.setExcelTypes(dsTypes);
|
||||||
|
}
|
||||||
request.setDetails(tableRow);
|
request.setDetails(tableRow);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
|||||||
@ -86,27 +86,7 @@ public class CoreVisualizationExportManage {
|
|||||||
chartViewDTO = extendDataManage.getChartDataInfo(request.getId(), request);
|
chartViewDTO = extendDataManage.getChartDataInfo(request.getId(), request);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
List<String> dsHeader = null;
|
|
||||||
Integer[] dsTypes = null;
|
|
||||||
//downloadType = dataset 为下载原始名字 这里做数据转换模拟 table-info类型图表导出
|
|
||||||
if ("dataset".equals(request.getDownloadType())) {
|
|
||||||
request.setType("table-info");
|
|
||||||
request.setIsPlugin(false);
|
|
||||||
List<DatasetTableFieldDTO> sourceFields = datasetFieldServer.listByDatasetGroup(request.getTableId());
|
|
||||||
dsHeader = sourceFields.stream()
|
|
||||||
.map(DatasetTableFieldDTO::getName)
|
|
||||||
.toList();
|
|
||||||
dsTypes = sourceFields.stream()
|
|
||||||
.map(DatasetTableFieldDTO::getDeType)
|
|
||||||
.toArray(Integer[]::new);
|
|
||||||
TypeReference<List<ChartViewFieldDTO>> listTypeReference = new TypeReference<List<ChartViewFieldDTO>>(){
|
|
||||||
};
|
|
||||||
request.setXAxis(JsonUtil.parseList(JsonUtil.toJSONString(sourceFields).toString(),listTypeReference));
|
|
||||||
}
|
|
||||||
chartViewDTO = chartDataManage.calcData(request);
|
chartViewDTO = chartDataManage.calcData(request);
|
||||||
if ("dataset".equals(request.getDownloadType())) {
|
|
||||||
result.getData().addFirst(dsHeader);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -82,6 +82,7 @@
|
|||||||
:class="{
|
:class="{
|
||||||
'enlarge-inner-with-header': optType === 'details' && sourceViewType.includes('chart-mix')
|
'enlarge-inner-with-header': optType === 'details' && sourceViewType.includes('chart-mix')
|
||||||
}"
|
}"
|
||||||
|
v-loading="requestStore.loadingMap[permissionStore.currentPath]"
|
||||||
ref="viewContainer"
|
ref="viewContainer"
|
||||||
:style="customExport"
|
:style="customExport"
|
||||||
>
|
>
|
||||||
@ -139,9 +140,13 @@ import { assign } from 'lodash-es'
|
|||||||
import { useEmitt } from '@/hooks/web/useEmitt'
|
import { useEmitt } from '@/hooks/web/useEmitt'
|
||||||
import { ElMessage, ElButton } from 'element-plus-secondary'
|
import { ElMessage, ElButton } from 'element-plus-secondary'
|
||||||
import { exportPivotExcel } from '@/views/chart/components/js/panel/common/common_table'
|
import { exportPivotExcel } from '@/views/chart/components/js/panel/common/common_table'
|
||||||
|
import { useRequestStoreWithOut } from '@/store/modules/request'
|
||||||
|
import { usePermissionStoreWithOut } from '@/store/modules/permission'
|
||||||
const downLoading = ref(false)
|
const downLoading = ref(false)
|
||||||
const dvMainStore = dvMainStoreWithOut()
|
const dvMainStore = dvMainStoreWithOut()
|
||||||
const dialogShow = ref(false)
|
const dialogShow = ref(false)
|
||||||
|
const requestStore = useRequestStoreWithOut()
|
||||||
|
const permissionStore = usePermissionStoreWithOut()
|
||||||
let viewInfo = ref<DeepPartial<ChartObj>>(null)
|
let viewInfo = ref<DeepPartial<ChartObj>>(null)
|
||||||
const config = ref(null)
|
const config = ref(null)
|
||||||
const canvasStyleData = ref(null)
|
const canvasStyleData = ref(null)
|
||||||
|
|||||||
@ -500,7 +500,8 @@ export const exportExcelDownload = (chart, callBack?) => {
|
|||||||
proxy: null,
|
proxy: null,
|
||||||
viewId: chart.id,
|
viewId: chart.id,
|
||||||
viewInfo: chart,
|
viewInfo: chart,
|
||||||
viewName: excelName
|
viewName: excelName,
|
||||||
|
downloadType: chart.downloadType
|
||||||
}
|
}
|
||||||
if (chart.type.includes('chart-mix')) {
|
if (chart.type.includes('chart-mix')) {
|
||||||
const req1 = getExcelDownloadRequest(chart.data.left)
|
const req1 = getExcelDownloadRequest(chart.data.left)
|
||||||
|
|||||||
@ -24,4 +24,6 @@ public class ChartExcelRequest extends ChartExcelRequestInner {
|
|||||||
|
|
||||||
private boolean dataEaseBi = false;
|
private boolean dataEaseBi = false;
|
||||||
|
|
||||||
|
private String downloadType;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user