diff --git a/core/core-backend/src/main/java/io/dataease/chart/charts/impl/map/SymbolicMapHandler.java b/core/core-backend/src/main/java/io/dataease/chart/charts/impl/map/SymbolicMapHandler.java index ecd44e7f00..e93cfa0704 100644 --- a/core/core-backend/src/main/java/io/dataease/chart/charts/impl/map/SymbolicMapHandler.java +++ b/core/core-backend/src/main/java/io/dataease/chart/charts/impl/map/SymbolicMapHandler.java @@ -38,20 +38,16 @@ public class SymbolicMapHandler extends GroupChartHandler { @Override public AxisFormatResult formatAxis(ChartViewDTO view) { var result = super.formatAxis(view); - var yAxis = result.getAxisMap().get(ChartAxis.yAxis); - yAxis.addAll(view.getExtBubble()); + result.getAxisMap().put(ChartAxis.extBubble, view.getExtBubble()); return result; } private Map customBuildResult(ChartViewDTO view, AxisFormatResult formatResult, CustomFilterResult filterResult, List data, List detailFields, List detailData) { - boolean isDrill = filterResult - .getFilterList() - .stream() - .anyMatch(ele -> ele.getFilterType() == 1); var xAxis = formatResult.getAxisMap().get(ChartAxis.xAxis); + var extBubble = formatResult.getAxisMap().get(ChartAxis.extBubble); var yAxis = formatResult.getAxisMap().get(ChartAxis.yAxis); - Map result = ChartDataBuild.transSymbolicMapNormalWithDetail(xAxis, yAxis, data, detailFields, detailData); + Map result = ChartDataBuild.transSymbolicMapNormalWithDetail(xAxis, yAxis, extBubble, data, detailFields, detailData); return result; } @@ -67,15 +63,21 @@ public class SymbolicMapHandler extends GroupChartHandler { DatasourceRequest datasourceRequest = new DatasourceRequest(); datasourceRequest.setDsList(dsMap); var xAxis = formatResult.getAxisMap().get(ChartAxis.xAxis); - var yAxis = formatResult.getAxisMap().get(ChartAxis.yAxis); + var extBubble = formatResult.getAxisMap().get(ChartAxis.extBubble); var allFields = (List) filterResult.getContext().get("allFields"); + List countField =chartViewManege.transFieldDTO(Collections.singletonList(chartViewManege.createCountField(view.getTableId()))); + List datasetTableFieldDTOList = FieldUtil.transFields(allFields); SQLMeta sqlMeta1 = new SQLMeta(); BeanUtils.copyBean(sqlMeta1, sqlMeta); - Dimension2SQLObj.dimension2sqlObj(sqlMeta, xAxis, FieldUtil.transFields(allFields), crossDs, dsMap, Utils.getParams(FieldUtil.transFields(allFields)), view.getCalParams(), pluginManage); - List yFields = new ArrayList<>(); - yFields.addAll(chartViewManege.transFieldDTO(Collections.singletonList(chartViewManege.createCountField(view.getTableId())))); - yAxis.addAll(yFields); - Quota2SQLObj.quota2sqlObj(sqlMeta, yAxis, FieldUtil.transFields(allFields), crossDs, dsMap, Utils.getParams(FieldUtil.transFields(allFields)), view.getCalParams(), pluginManage); + Dimension2SQLObj.dimension2sqlObj(sqlMeta, xAxis, datasetTableFieldDTOList, crossDs, dsMap, Utils.getParams(datasetTableFieldDTOList), view.getCalParams(), pluginManage); + List yAxis = new ArrayList<>(); + if(!extBubble.isEmpty() && !"*".equals(extBubble.get(0).getDataeaseName())){ + yAxis.addAll(extBubble); + } + yAxis.addAll(countField); + datasetTableFieldDTOList.addAll(FieldUtil.transFields(countField)); + formatResult.getAxisMap().put(ChartAxis.yAxis,countField); + Quota2SQLObj.quota2sqlObj(sqlMeta, yAxis, datasetTableFieldDTOList, crossDs, dsMap, Utils.getParams(datasetTableFieldDTOList), view.getCalParams(), pluginManage); String querySql = SQLProvider.createQuerySQL(sqlMeta, true, needOrder, view); querySql = provider.rebuildSQL(querySql, sqlMeta, crossDs, dsMap); datasourceRequest.setQuery(querySql); @@ -107,8 +109,6 @@ public class SymbolicMapHandler extends GroupChartHandler { } //自定义排序 data = ChartDataUtil.resultCustomSort(xAxis, data); - //快速计算 - quickCalc(xAxis, yAxis, data); //数据重组逻辑可重载 var result = customBuildResult(view, formatResult, filterResult, data, detailFields, detailData); T calcResult = (T) new ChartCalcDataResult(); @@ -116,6 +116,7 @@ public class SymbolicMapHandler extends GroupChartHandler { calcResult.setContext(filterResult.getContext()); calcResult.setQuerySql(querySql); calcResult.setOriginData(data); + formatResult.getAxisMap().put(ChartAxis.yAxis,new ArrayList<>()); return calcResult; } @@ -124,11 +125,11 @@ public class SymbolicMapHandler extends GroupChartHandler { var desensitizationList = (Map) filterResult.getContext().get("desensitizationList"); var allFields = (List) filterResult.getContext().get("allFields"); var xAxis = formatResult.getAxisMap().get(ChartAxis.xAxis); - var yAxis = formatResult.getAxisMap().get(ChartAxis.yAxis); + var extBubble = formatResult.getAxisMap().get(ChartAxis.extBubble); // 如果是表格导出查询 则在此处直接就可以返回 var extStack = formatResult.getAxisMap().get(ChartAxis.extStack); if (view.getIsExcelExport()) { - Map sourceInfo = ChartDataBuild.transTableNormal(xAxis, yAxis, view, calcResult.getOriginData(), extStack, desensitizationList); + Map sourceInfo = ChartDataBuild.transTableNormal(xAxis, extBubble, view, calcResult.getOriginData(), extStack, desensitizationList); sourceInfo.put("sourceData", calcResult.getOriginData()); view.setData(sourceInfo); return view; diff --git a/core/core-backend/src/main/java/io/dataease/chart/utils/ChartDataBuild.java b/core/core-backend/src/main/java/io/dataease/chart/utils/ChartDataBuild.java index b259e4ff61..7519fbb1b4 100644 --- a/core/core-backend/src/main/java/io/dataease/chart/utils/ChartDataBuild.java +++ b/core/core-backend/src/main/java/io/dataease/chart/utils/ChartDataBuild.java @@ -1748,7 +1748,7 @@ public class ChartDataBuild { } } - public static Map transSymbolicMapNormalWithDetail(List xAxis, List yAxis, List data, List detailFields, List detailData) { + public static Map transSymbolicMapNormalWithDetail(List xAxis, List yAxis, List extBubble, List data, List detailFields, List detailData) { int detailIndex = xAxis.size(); List realDetailFields = detailFields.subList(detailIndex, detailFields.size()); @@ -1756,22 +1756,24 @@ public class ChartDataBuild { List fields = new ArrayList<>(); if (ObjectUtils.isNotEmpty(xAxis)) fields.addAll(xAxis); + if (ObjectUtils.isNotEmpty(extBubble)) + fields.addAll(extBubble); if (ObjectUtils.isNotEmpty(yAxis)) fields.addAll(yAxis); Map map = transTableNormal(fields, null, data, new HashMap<>()); List> tableRow = (List>) map.get("tableRow"); final int xEndIndex = detailIndex; Map> groupDataList = detailData.stream().collect(Collectors.groupingBy(item -> "(" + StringUtils.join(ArrayUtils.subarray(item, 0, xEndIndex), ")-de-(") + ")")); - + String extBubbleDataeaseName = ObjectUtils.isNotEmpty(extBubble)?extBubble.get(0).getDataeaseName():""; tableRow.forEach(row -> { - BigDecimal rowValue = new BigDecimal(row.get(yAxis.get(0).getDataeaseName()).toString()); + BigDecimal rowValue = row.get(extBubbleDataeaseName) == null ? BigDecimal.ZERO : new BigDecimal(row.get(extBubbleDataeaseName).toString()); String key = xAxis.stream().map(x -> String.format(format, row.get(x.getDataeaseName()).toString())).collect(Collectors.joining("-de-")); List detailFieldValueList = groupDataList.get(key); List> detailValueMapList = Optional.ofNullable(detailFieldValueList).orElse(new ArrayList<>()).stream().map((detailArr -> { Map temp = new HashMap<>(); for (int i = 0; i < realDetailFields.size(); i++) { ChartViewFieldDTO realDetailField = realDetailFields.get(i); - if(StringUtils.equalsIgnoreCase(yAxis.get(0).getDataeaseName(),realDetailField.getDataeaseName())){ + if(StringUtils.equalsIgnoreCase(extBubbleDataeaseName,realDetailField.getDataeaseName())){ temp.put(realDetailField.getDataeaseName(), rowValue); }else{ temp.put(realDetailField.getDataeaseName(), detailArr[detailIndex + i]); @@ -1782,7 +1784,15 @@ public class ChartDataBuild { //详情只要一个 row.put("details", !detailValueMapList.isEmpty() ?Collections.singletonList(detailValueMapList.getFirst()):detailValueMapList); }); - map.put("fields", fields); + // 先过滤掉所有记录数字段 + List filterCountAxis = fields.stream() + .filter(item -> !StringUtils.equalsIgnoreCase(item.getDataeaseName(), "*")) + .collect(Collectors.toList()); + // 如果气泡大小是记录数,添加到字段列表中 + if (ObjectUtils.isNotEmpty(extBubble) && "*".equals(extBubble.get(0).getDataeaseName())) { + filterCountAxis.addAll(yAxis); + } + map.put("fields", filterCountAxis); map.put("detailFields", realDetailFields); map.put("tableRow", tableRow); return map;