Merge pull request #10591 from ulleo/dev-v2

fix(图表): 修复区间条形图使用时间维度范围时查询数据报错的问题
This commit is contained in:
ulleo 2024-06-28 11:41:30 +08:00 committed by GitHub
commit 548d2c89b0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 7 deletions

View File

@ -1,6 +1,5 @@
package io.dataease.chart.charts.impl.bar;
import io.dataease.chart.charts.impl.DefaultChartHandler;
import io.dataease.chart.charts.impl.YoyChartHandler;
import io.dataease.chart.utils.ChartDataBuild;
import io.dataease.datasource.provider.CalciteProvider;
@ -19,13 +18,14 @@ import java.util.Map;
@Component
public class RangeBarHandler extends YoyChartHandler {
@Getter
private String type = "bar-range";
private final String type = "bar-range";
@Override
public AxisFormatResult formatAxis(ChartViewDTO view) {
var result = super.formatAxis(view);
var yAxis = new ArrayList<ChartViewFieldDTO>();
var xAxis = new ArrayList<ChartViewFieldDTO>(view.getXAxis());
var xAxisBase = new ArrayList<ChartViewFieldDTO>(view.getXAxis());
boolean skipBarRange = false;
boolean barRangeDate = false;
if (CollectionUtils.isNotEmpty(view.getYAxis()) && CollectionUtils.isNotEmpty(view.getYAxisExt())) {
@ -56,6 +56,7 @@ public class RangeBarHandler extends YoyChartHandler {
result.getContext().put("barRangeDate", barRangeDate);
result.getAxisMap().put(ChartAxis.xAxis, xAxis);
result.getAxisMap().put(ChartAxis.yAxis, yAxis);
result.getContext().put("xAxisBase", xAxisBase);
return result;
}
@ -67,9 +68,10 @@ public class RangeBarHandler extends YoyChartHandler {
.anyMatch(ele -> ele.getFilterType() == 1);
var xAxis = formatResult.getAxisMap().get(ChartAxis.xAxis);
var yAxis = formatResult.getAxisMap().get(ChartAxis.yAxis);
var xAxisBase = (List<ChartViewFieldDTO>) formatResult.getContext().get("xAxisBase");
var skipBarRange = (boolean) formatResult.getContext().get("skipBarRange");
var barRangeDate = (boolean) formatResult.getContext().get("barRangeDate");
Map<String, Object> result = ChartDataBuild.transBarRangeDataAntV(skipBarRange, barRangeDate, xAxis, xAxis, yAxis, view, data, isDrill);
Map<String, Object> result = ChartDataBuild.transBarRangeDataAntV(skipBarRange, barRangeDate, xAxisBase, xAxis, yAxis, view, data, isDrill);
return result;
}

View File

@ -1,7 +1,6 @@
package io.dataease.chart.server;
import io.dataease.api.chart.ChartDataApi;
import io.dataease.extensions.view.dto.ChartViewDTO;
import io.dataease.api.chart.dto.ViewDetailField;
import io.dataease.api.chart.request.ChartExcelRequest;
import io.dataease.api.chart.request.ChartExcelRequestInner;
@ -12,6 +11,7 @@ import io.dataease.constant.CommonConstants;
import io.dataease.engine.constant.DeTypeConstants;
import io.dataease.exception.DEException;
import io.dataease.exportCenter.manage.ExportCenterManage;
import io.dataease.extensions.view.dto.ChartViewDTO;
import io.dataease.result.ResultCode;
import io.dataease.utils.LogUtil;
import io.dataease.visualization.manage.VisualizationTemplateExtendDataManage;
@ -70,10 +70,10 @@ public class ChartDataServer implements ChartDataApi {
try {
ChartViewDTO viewDTO = request.getViewInfo();
viewDTO.setIsExcelExport(true);
if(ChartConstants.VIEW_RESULT_MODE.CUSTOM.equals(viewDTO.getResultMode())){
if (ChartConstants.VIEW_RESULT_MODE.CUSTOM.equals(viewDTO.getResultMode())) {
Integer limitCount = viewDTO.getResultCount();
viewDTO.setResultCount(limitCount>limit?limit:limitCount);
}else{
viewDTO.setResultCount(limitCount > limit ? limit : limitCount);
} else {
viewDTO.setResultCount(limit);
}
ChartViewDTO chartViewInfo = getData(viewDTO);