forked from github/dataease
Merge pull request #11369 from dataease/pr@dev-v2@feat_source-details-export
feat(仪表板): 支持原始明细导出
This commit is contained in:
commit
306d419835
@ -5,8 +5,10 @@ import io.dataease.api.visualization.vo.DataVisualizationVO;
|
|||||||
import io.dataease.chart.manage.ChartDataManage;
|
import io.dataease.chart.manage.ChartDataManage;
|
||||||
import io.dataease.chart.manage.ChartViewManege;
|
import io.dataease.chart.manage.ChartViewManege;
|
||||||
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.extensions.datasource.dto.DatasetTableFieldDTO;
|
||||||
import io.dataease.extensions.view.dto.ChartExtFilterDTO;
|
import io.dataease.extensions.view.dto.ChartExtFilterDTO;
|
||||||
import io.dataease.extensions.view.dto.ChartExtRequest;
|
import io.dataease.extensions.view.dto.ChartExtRequest;
|
||||||
import io.dataease.extensions.view.dto.ChartViewDTO;
|
import io.dataease.extensions.view.dto.ChartViewDTO;
|
||||||
@ -45,6 +47,9 @@ public class CoreVisualizationExportManage {
|
|||||||
@Resource
|
@Resource
|
||||||
private VisualizationTemplateExtendDataManage extendDataManage;
|
private VisualizationTemplateExtendDataManage extendDataManage;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DatasetFieldServer datasetFieldServer;
|
||||||
|
|
||||||
public File exportExcel(Long dvId, String busiFlag, List<Long> viewIdList, boolean onlyDisplay) throws Exception {
|
public File exportExcel(Long dvId, String busiFlag, List<Long> viewIdList, boolean onlyDisplay) throws Exception {
|
||||||
DataVisualizationVO visualization = extDataVisualizationMapper.findDvInfo(dvId, busiFlag);
|
DataVisualizationVO visualization = extDataVisualizationMapper.findDvInfo(dvId, busiFlag);
|
||||||
if (ObjectUtils.isEmpty(visualization)) DEException.throwException("资源不存在或已经被删除...");
|
if (ObjectUtils.isEmpty(visualization)) DEException.throwException("资源不存在或已经被删除...");
|
||||||
@ -81,7 +86,27 @@ 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);
|
||||||
}
|
}
|
||||||
|
@ -41,10 +41,21 @@
|
|||||||
icon="Download"
|
icon="Download"
|
||||||
size="middle"
|
size="middle"
|
||||||
:loading="exportLoading"
|
:loading="exportLoading"
|
||||||
@click="downloadViewDetails"
|
@click="downloadViewDetails('view')"
|
||||||
>
|
>
|
||||||
导出Excel
|
导出Excel
|
||||||
</el-button>
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
class="m-button"
|
||||||
|
v-if="optType === 'details' && authShow"
|
||||||
|
link
|
||||||
|
icon="Download"
|
||||||
|
size="middle"
|
||||||
|
:loading="exportLoading"
|
||||||
|
@click="downloadViewDetails('dataset')"
|
||||||
|
>
|
||||||
|
导出原始明细
|
||||||
|
</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
class="m-button"
|
class="m-button"
|
||||||
v-if="optType === 'details' && authShow && viewInfo.type === 'table-pivot'"
|
v-if="optType === 'details' && authShow && viewInfo.type === 'table-pivot'"
|
||||||
@ -275,14 +286,15 @@ const downloadViewImage = () => {
|
|||||||
htmlToImage()
|
htmlToImage()
|
||||||
}
|
}
|
||||||
|
|
||||||
const downloadViewDetails = () => {
|
const downloadViewDetails = (downloadType = 'view') => {
|
||||||
const viewDataInfo = dvMainStore.getViewDataDetails(viewInfo.value.id)
|
const viewDataInfo = dvMainStore.getViewDataDetails(viewInfo.value.id)
|
||||||
const chartExtRequest = dvMainStore.getLastViewRequestInfo(viewInfo.value.id)
|
const chartExtRequest = dvMainStore.getLastViewRequestInfo(viewInfo.value.id)
|
||||||
const chart = {
|
const chart = {
|
||||||
...viewInfo.value,
|
...viewInfo.value,
|
||||||
chartExtRequest,
|
chartExtRequest,
|
||||||
data: viewDataInfo,
|
data: viewDataInfo,
|
||||||
type: sourceViewType.value
|
type: sourceViewType.value,
|
||||||
|
downloadType: downloadType
|
||||||
}
|
}
|
||||||
exportLoading.value = true
|
exportLoading.value = true
|
||||||
exportExcelDownload(chart, () => {
|
exportExcelDownload(chart, () => {
|
||||||
|
@ -35,4 +35,7 @@ public class ChartViewDTO extends ChartViewBaseDTO {
|
|||||||
*/
|
*/
|
||||||
@JsonSerialize(using = ToStringSerializer.class)
|
@JsonSerialize(using = ToStringSerializer.class)
|
||||||
private Long sourceTableId;
|
private Long sourceTableId;
|
||||||
|
|
||||||
|
// 数据下载模式 dataset 指的是现在原始数据
|
||||||
|
private String downloadType;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user