mirror of
https://github.com/dataease/dataease.git
synced 2026-05-15 05:22:13 +08:00
fix(X-Pack): 定时报告查询组件没有作用于导出的图表数据
This commit is contained in:
committed by
fit2cloud-chenyw
parent
0a0074fee0
commit
c95162617a
@@ -6,8 +6,8 @@ import io.dataease.chart.constant.ChartConstants;
|
||||
import io.dataease.chart.manage.ChartDataManage;
|
||||
import io.dataease.chart.manage.ChartViewManege;
|
||||
import io.dataease.constant.CommonConstants;
|
||||
import io.dataease.dataset.server.DatasetFieldServer;
|
||||
import io.dataease.constant.DeTypeConstants;
|
||||
import io.dataease.dataset.server.DatasetFieldServer;
|
||||
import io.dataease.exception.DEException;
|
||||
import io.dataease.exportCenter.util.ExportCenterUtils;
|
||||
import io.dataease.extensions.view.dto.ChartExtFilterDTO;
|
||||
@@ -52,15 +52,15 @@ public class CoreVisualizationExportManage {
|
||||
private DatasetFieldServer datasetFieldServer;
|
||||
|
||||
public String getResourceName(Long dvId, String busiFlag) {
|
||||
DataVisualizationVO visualization = extDataVisualizationMapper.findDvInfo(dvId, busiFlag,"core");
|
||||
DataVisualizationVO visualization = extDataVisualizationMapper.findDvInfo(dvId, busiFlag, "core");
|
||||
if (ObjectUtils.isEmpty(visualization)) DEException.throwException("资源不存在或已经被删除...");
|
||||
return visualization.getName();
|
||||
}
|
||||
|
||||
public File exportExcel(Long dvId, String busiFlag, List<Long> viewIdList, boolean onlyDisplay) throws Exception {
|
||||
DataVisualizationVO visualization = extDataVisualizationMapper.findDvInfo(dvId, busiFlag,"core");
|
||||
public File exportExcel(Long dvId, String busiFlag, List<Long> viewIdList, boolean onlyDisplay, String filterJson) throws Exception {
|
||||
DataVisualizationVO visualization = extDataVisualizationMapper.findDvInfo(dvId, busiFlag, "core");
|
||||
if (ObjectUtils.isEmpty(visualization)) DEException.throwException("资源不存在或已经被删除...");
|
||||
List<ChartViewDTO> chartViewDTOS = chartViewManege.listBySceneId(dvId,CommonConstants.RESOURCE_TABLE.CORE);
|
||||
List<ChartViewDTO> chartViewDTOS = chartViewManege.listBySceneId(dvId, CommonConstants.RESOURCE_TABLE.CORE);
|
||||
|
||||
String componentsJson = visualization.getComponentData();
|
||||
List<Map<String, Object>> components = JsonUtil.parseList(componentsJson, tokenType);
|
||||
@@ -70,11 +70,11 @@ public class CoreVisualizationExportManage {
|
||||
chartViewDTOS = chartViewDTOS.stream().filter(item -> idList.contains(item.getId()) && viewIdList.contains(item.getId())).collect(Collectors.toList());
|
||||
}
|
||||
if (CollectionUtils.isEmpty(chartViewDTOS)) return null;
|
||||
Map<String, ChartExtRequest> chartExtRequestMap = buildViewRequest(visualization, onlyDisplay);
|
||||
Map<Long, ChartExtRequest> chartExtRequestMap = buildViewRequest(filterJson);
|
||||
List<ExcelSheetModel> sheets = new ArrayList<>();
|
||||
for (int i = 0; i < chartViewDTOS.size(); i++) {
|
||||
ChartViewDTO view = chartViewDTOS.get(i);
|
||||
ChartExtRequest extRequest = chartExtRequestMap.get(view.getId().toString());
|
||||
ChartExtRequest extRequest = chartExtRequestMap.get(view.getId());
|
||||
if (ObjectUtils.isNotEmpty(extRequest)) {
|
||||
view.setChartExtRequest(extRequest);
|
||||
}
|
||||
@@ -187,6 +187,13 @@ public class CoreVisualizationExportManage {
|
||||
private final TypeReference<List<Map<String, Object>>> tokenType = new TypeReference<List<Map<String, Object>>>() {
|
||||
};
|
||||
|
||||
private Map<Long, ChartExtRequest> buildViewRequest(String filterJson) {
|
||||
if (StringUtils.isBlank(filterJson)) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
return JsonUtil.parseObject(filterJson, new TypeReference<Map<Long, ChartExtRequest>>() {
|
||||
});
|
||||
}
|
||||
|
||||
private Map<String, ChartExtRequest> buildViewRequest(DataVisualizationVO panelDto, Boolean justView) {
|
||||
String componentsJson = panelDto.getComponentData();
|
||||
|
||||
@@ -54,7 +54,8 @@ import request from '@/config/axios'
|
||||
import { store } from '@/store'
|
||||
import { clearExtremum } from '@/views/chart/components/js/extremumUitl'
|
||||
import DePreviewPopDialog from '@/components/visualization/DePreviewPopDialog.vue'
|
||||
|
||||
import { useRoute } from 'vue-router'
|
||||
const route = useRoute()
|
||||
const { wsCache } = useCache()
|
||||
const chartComponent = ref<any>()
|
||||
const { t } = useI18n()
|
||||
@@ -368,7 +369,7 @@ const chartClick = param => {
|
||||
// 仪表板和大屏所有额外过滤参数都在此处
|
||||
const filter = (firstLoad?: boolean) => {
|
||||
const { filter } = useFilter(view.value.id, firstLoad)
|
||||
return {
|
||||
const result = {
|
||||
user: wsCache.get('user.uid'),
|
||||
filter,
|
||||
linkageFilters: element.value.linkageFilters,
|
||||
@@ -378,6 +379,18 @@ const filter = (firstLoad?: boolean) => {
|
||||
resultCount: resultCount.value,
|
||||
resultMode: resultMode.value
|
||||
}
|
||||
// 定时报告相关勿动
|
||||
if (route.path === '/preview' && route.query.taskId) {
|
||||
const sceneId = view.value['sceneId']
|
||||
const filterJson = window[`de-report-filter-${sceneId}`]
|
||||
let filterObj = {}
|
||||
if (filterJson) {
|
||||
filterObj = JSON.parse(filterJson)
|
||||
}
|
||||
filterObj[view.value.id] = result
|
||||
window[`de-report-filter-${sceneId}`] = JSON.stringify(filterObj)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
const onDrillFilters = param => {
|
||||
|
||||
@@ -14,6 +14,7 @@ import java.util.List;
|
||||
public class JsonUtil {
|
||||
|
||||
private static final ObjectMapper objectMapper;
|
||||
|
||||
static {
|
||||
objectMapper = new ObjectMapper();
|
||||
// 配置更大的 StreamReadConstraints 限制
|
||||
@@ -47,6 +48,17 @@ public class JsonUtil {
|
||||
return t;
|
||||
}
|
||||
|
||||
public static <T> T parseObject(String json, TypeReference<T> typeReference) {
|
||||
if (json == null) return null;
|
||||
T t = null;
|
||||
try {
|
||||
t = objectMapper.readValue(json, typeReference);
|
||||
} catch (JsonProcessingException e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
public static <T> List<T> parseList(String json, TypeReference<List<T>> classOfT) {
|
||||
if (ObjectUtils.isEmpty(json)) return Collections.emptyList();
|
||||
List<T> t = null;
|
||||
|
||||
Reference in New Issue
Block a user