Merge pull request #4488 from dataease/pr@dev@refactor_view-export

refactor(视图): 分页表格导出时支持导出全量数据
This commit is contained in:
王嘉豪 2023-02-09 10:46:55 +08:00 committed by GitHub
commit 0822847aa2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 109 additions and 45 deletions

View File

@ -5,6 +5,7 @@ import io.dataease.plugins.common.request.chart.ChartExtFilterRequest;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.util.List; import java.util.List;
/** /**
@ -48,4 +49,6 @@ public class ChartExtRequest {
private Long pageSize; private Long pageSize;
private Boolean excelExportFlag = false;
} }

View File

@ -1,5 +1,6 @@
package io.dataease.controller.request.panel; package io.dataease.controller.request.panel;
import io.dataease.controller.request.chart.ChartExtRequest;
import lombok.Data; import lombok.Data;
import java.util.List; import java.util.List;
@ -30,4 +31,8 @@ public class PanelViewDetailsRequest {
private ViewDetailField[] detailFields; private ViewDetailField[] detailFields;
private ChartExtRequest componentFilterInfo;
private List<String> excelHeaderKeys;
} }

View File

@ -526,7 +526,8 @@ public class ChartViewService {
} }
} }
List<ChartViewFieldDTO> xAxisForRequest = new ArrayList<>(); List<ChartViewFieldDTO> xAxisForRequest = new ArrayList<>();
xAxisForRequest.addAll(xAxis); xAxisForRequest.addAll(extStack); xAxisForRequest.addAll(xAxis);
xAxisForRequest.addAll(extStack);
datasourceRequest.setXAxis(xAxisForRequest); datasourceRequest.setXAxis(xAxisForRequest);
data = datasourceProvider.getData(datasourceRequest); data = datasourceProvider.getData(datasourceRequest);
} else if (table.getMode() == 1) {// 抽取 } else if (table.getMode() == 1) {// 抽取
@ -655,7 +656,7 @@ public class ChartViewService {
Map<String, Object> mapAttr = gson.fromJson(view.getCustomAttr(), Map.class); Map<String, Object> mapAttr = gson.fromJson(view.getCustomAttr(), Map.class);
Map<String, Object> mapSize = (Map<String, Object>) mapAttr.get("size"); Map<String, Object> mapSize = (Map<String, Object>) mapAttr.get("size");
if (StringUtils.equalsIgnoreCase(view.getType(), "table-info") && table.getMode() == 0) { if (StringUtils.equalsIgnoreCase(view.getType(), "table-info") && table.getMode() == 0) {
if (StringUtils.equalsIgnoreCase((String) mapSize.get("tablePageMode"), "page")) { if (StringUtils.equalsIgnoreCase((String) mapSize.get("tablePageMode"), "page") && !chartExtRequest.getExcelExportFlag()) {
if (chartExtRequest.getGoPage() == null) { if (chartExtRequest.getGoPage() == null) {
chartExtRequest.setGoPage(1L); chartExtRequest.setGoPage(1L);
} }
@ -1043,7 +1044,8 @@ public class ChartViewService {
datasourceRequest.setQuery(querySql); datasourceRequest.setQuery(querySql);
List<ChartViewFieldDTO> xAxisForRequest = new ArrayList<>(); List<ChartViewFieldDTO> xAxisForRequest = new ArrayList<>();
xAxisForRequest.addAll(xAxis); xAxisForRequest.addAll(extStack); xAxisForRequest.addAll(xAxis);
xAxisForRequest.addAll(extStack);
datasourceRequest.setXAxis(xAxisForRequest); datasourceRequest.setXAxis(xAxisForRequest);
data = datasourceProvider.getData(datasourceRequest); data = datasourceProvider.getData(datasourceRequest);
if (CollectionUtils.isNotEmpty(assistFields)) { if (CollectionUtils.isNotEmpty(assistFields)) {

View File

@ -10,6 +10,7 @@ import io.dataease.auth.api.dto.CurrentUserDto;
import io.dataease.commons.constants.*; import io.dataease.commons.constants.*;
import io.dataease.commons.utils.*; import io.dataease.commons.utils.*;
import io.dataease.controller.request.authModel.VAuthModelRequest; import io.dataease.controller.request.authModel.VAuthModelRequest;
import io.dataease.controller.request.chart.ChartExtRequest;
import io.dataease.controller.request.dataset.DataSetTableRequest; import io.dataease.controller.request.dataset.DataSetTableRequest;
import io.dataease.controller.request.panel.*; import io.dataease.controller.request.panel.*;
import io.dataease.dto.DatasourceDTO; import io.dataease.dto.DatasourceDTO;
@ -652,6 +653,7 @@ public class PanelGroupService {
public void exportPanelViewDetails(PanelViewDetailsRequest request, HttpServletResponse response) throws IOException { public void exportPanelViewDetails(PanelViewDetailsRequest request, HttpServletResponse response) throws IOException {
OutputStream outputStream = response.getOutputStream(); OutputStream outputStream = response.getOutputStream();
try { try {
findExcelData(request);
String snapshot = request.getSnapshot(); String snapshot = request.getSnapshot();
List<Object[]> details = request.getDetails(); List<Object[]> details = request.getDetails();
Integer[] excelTypes = request.getExcelTypes(); Integer[] excelTypes = request.getExcelTypes();
@ -1089,6 +1091,32 @@ public class PanelGroupService {
request.setUpdateTime(time); request.setUpdateTime(time);
request.setUpdateBy(AuthUtils.getUser().getUsername()); request.setUpdateBy(AuthUtils.getUser().getUsername());
panelGroupMapper.updateByPrimaryKeySelective(request); panelGroupMapper.updateByPrimaryKeySelective(request);
}
public void findExcelData(PanelViewDetailsRequest request) {
ChartViewWithBLOBs viewInfo = chartViewService.get(request.getViewId());
if ("table-info".equals(viewInfo.getType())) {
try {
List<String> excelHeaderKeys = request.getExcelHeaderKeys();
ChartExtRequest componentFilterInfo = request.getComponentFilterInfo();
componentFilterInfo.setGoPage(1l);
componentFilterInfo.setPageSize(1000000l);
componentFilterInfo.setExcelExportFlag(true);
ChartViewDTO chartViewInfo = chartViewService.getData(request.getViewId(), componentFilterInfo);
List<Map> tableRow = (List) chartViewInfo.getData().get("tableRow");
List<Object[]> result = new ArrayList<>();
for (Map detailMap : tableRow) {
List<Object> detailObj = new ArrayList<>();
for (String key : excelHeaderKeys) {
detailObj.add(detailMap.get(key));
}
result.add(detailObj.toArray());
}
request.setDetails(result);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
} }
} }

View File

@ -770,6 +770,9 @@ export default {
if (response.success) { if (response.success) {
this.chart = response.data this.chart = response.data
this.view = response.data this.view = response.data
if (this.chart.type.includes('table')) {
this.$store.commit('setLastViewRequestInfo', { viewId: id, requestInfo: requestInfo })
}
this.buildInnerRefreshTimer(this.chart.refreshViewEnable, this.chart.refreshUnit, this.chart.refreshTime) this.buildInnerRefreshTimer(this.chart.refreshViewEnable, this.chart.refreshUnit, this.chart.refreshTime)
this.$emit('fill-chart-2-parent', this.chart) this.$emit('fill-chart-2-parent', this.chart)
this.getDataOnly(response.data, dataBroadcast) this.getDataOnly(response.data, dataBroadcast)

View File

@ -87,9 +87,20 @@ import html2canvas from 'html2canvasde'
import { hexColorToRGBA } from '@/views/chart/chart/util' import { hexColorToRGBA } from '@/views/chart/chart/util'
import { deepCopy, exportImg, imgUrlTrans } from '@/components/canvas/utils/utils' import { deepCopy, exportImg, imgUrlTrans } from '@/components/canvas/utils/utils'
import { getLinkToken, getToken } from '@/utils/auth' import { getLinkToken, getToken } from '@/utils/auth'
export default { export default {
name: 'UserViewDialog', name: 'UserViewDialog',
components: { LabelNormalText, ChartComponentS2, ChartComponentG2, DeMainContainer, DeContainer, ChartComponent, TableNormal, LabelNormal, PluginCom }, components: {
LabelNormalText,
ChartComponentS2,
ChartComponentG2,
DeMainContainer,
DeContainer,
ChartComponent,
TableNormal,
LabelNormal,
PluginCom
},
props: { props: {
chart: { chart: {
type: Object, type: Object,
@ -123,8 +134,7 @@ export default {
return this.chart.type === 'table-normal' || this.chart.type === 'table-info' return this.chart.type === 'table-normal' || this.chart.type === 'table-info'
}, },
customStyle() { customStyle() {
let style = { let style = {}
}
if (this.canvasStyleData.openCommonStyle) { if (this.canvasStyleData.openCommonStyle) {
if (this.canvasStyleData.panel.backgroundType === 'image' && this.canvasStyleData.panel.imageUrl) { if (this.canvasStyleData.panel.backgroundType === 'image' && this.canvasStyleData.panel.imageUrl) {
style = { style = {
@ -186,7 +196,8 @@ export default {
'isClickComponent', 'isClickComponent',
'curComponent', 'curComponent',
'componentData', 'componentData',
'canvasStyleData' 'canvasStyleData',
'lastViewRequestInfo'
]), ]),
mapChart() { mapChart() {
if (this.chart.type && (this.chart.type === 'map' || this.chart.type === 'buddle-map')) { if (this.chart.type && (this.chart.type === 'map' || this.chart.type === 'buddle-map')) {
@ -211,7 +222,7 @@ export default {
} }
}) })
} }
const result = { ...temp, ...{ DetailAreaCode: DetailAreaCode }} const result = { ...temp, ...{ DetailAreaCode: DetailAreaCode } }
this.setLastMapChart(result) this.setLastMapChart(result)
return result return result
} }
@ -285,6 +296,8 @@ export default {
snapshot: snapshot, snapshot: snapshot,
snapshotWidth: width, snapshotWidth: width,
snapshotHeight: height, snapshotHeight: height,
componentFilterInfo: this.lastViewRequestInfo[this.chart.id],
excelHeaderKeys: excelHeaderKeys,
detailFields detailFields
} }
let method = innerExportDetails let method = innerExportDetails
@ -313,43 +326,49 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.ms-aside-container { .ms-aside-container {
height: 70vh; height: 70vh;
min-width: 400px; min-width: 400px;
max-width: 400px; max-width: 400px;
padding: 0 0; padding: 0 0;
} }
.ms-main-container {
height: 70vh;
border: 1px solid #E6E6E6;
}
.chart-class{
height: 100%;
}
.table-class{
height: 100%;
}
.canvas-class{
position: relative;
width: 100%;
height: 100%;
background-size: 100% 100% !important;
}
.abs-container {
position: absolute;
width: 100%;
margin-left: -20px;
.ms-main-container {
padding: 0px !important;
}
}
.svg-background { .ms-main-container {
position: absolute; height: 70vh;
top: 0; border: 1px solid #E6E6E6;
left: 0; }
width: 100%;
height: 100%; .chart-class {
height: 100%;
}
.table-class {
height: 100%;
}
.canvas-class {
position: relative;
width: 100%;
height: 100%;
background-size: 100% 100% !important;
}
.abs-container {
position: absolute;
width: 100%;
margin-left: -20px;
.ms-main-container {
padding: 0px !important;
} }
}
.svg-background {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
</style> </style>

View File

@ -152,7 +152,8 @@ const data = {
}, },
previewVisible: false, previewVisible: false,
previewComponentData: [], previewComponentData: [],
currentCanvasNewId: [] currentCanvasNewId: [],
lastViewRequestInfo: {}
}, },
mutations: { mutations: {
...animation.mutations, ...animation.mutations,
@ -610,6 +611,9 @@ const data = {
resetViewEditInfo(state) { resetViewEditInfo(state) {
state.panelViewEditInfo = {} state.panelViewEditInfo = {}
}, },
setLastViewRequestInfo(state, viewRequestInfo) {
state.lastViewRequestInfo[viewRequestInfo.viewId] = viewRequestInfo.requestInfo
},
removeCurBatchComponentWithId(state, id) { removeCurBatchComponentWithId(state, id) {
for (let index = 0; index < state.curBatchOptComponents.length; index++) { for (let index = 0; index < state.curBatchOptComponents.length; index++) {
const element = state.curBatchOptComponents[index] const element = state.curBatchOptComponents[index]