diff --git a/core/core-backend/src/main/java/io/dataease/chart/charts/impl/mix/GroupMixHandler.java b/core/core-backend/src/main/java/io/dataease/chart/charts/impl/mix/GroupMixHandler.java index 1012ba60b6..4b58abfbc0 100644 --- a/core/core-backend/src/main/java/io/dataease/chart/charts/impl/mix/GroupMixHandler.java +++ b/core/core-backend/src/main/java/io/dataease/chart/charts/impl/mix/GroupMixHandler.java @@ -41,6 +41,7 @@ public class GroupMixHandler extends MixHandler { xAxisGroup.addAll(view.getXAxisExt()); axisMap.put(ChartAxis.xAxis, xAxisGroup); context.put("xAxisBase", xAxis); + axisMap.put(ChartAxis.drill, new ArrayList<>(view.getDrillFields())); return result; } @@ -49,45 +50,4 @@ public class GroupMixHandler extends MixHandler { return super.buildNormalResult(view, formatResult, filterResult, data); } - @Override - public ChartViewDTO buildChart(ChartViewDTO view, ChartCalcDataResult calcResult, AxisFormatResult formatResult, CustomFilterResult filterResult) { - var desensitizationList = (Map) filterResult.getContext().get("desensitizationList"); - var leftCalcResult = (ChartCalcDataResult) calcResult.getData().get("left"); - var leftFields = new ArrayList(); - leftFields.addAll(view.getXAxis()); - leftFields.addAll(view.getXAxisExt()); - leftFields.addAll(view.getYAxis()); - var leftOriginData = leftCalcResult.getOriginData(); - var leftTable = ChartDataBuild.transTableNormal(leftFields, view, leftOriginData, desensitizationList); - mergeAssistField(leftCalcResult.getDynamicAssistFields(), leftCalcResult.getAssistData()); - var leftData = new HashMap(leftTable); - leftData.putAll(leftCalcResult.getData()); - leftData.put("dynamicAssistLines", leftCalcResult.getDynamicAssistFields()); - - var rightCalcResult = (ChartCalcDataResult) calcResult.getData().get("right"); - var rightFields = new ArrayList(); - rightFields.addAll(view.getXAxis()); - rightFields.addAll(view.getExtBubble()); - rightFields.addAll(view.getYAxisExt()); - var rightOriginData = rightCalcResult.getOriginData(); - var rightTable = ChartDataBuild.transTableNormal(rightFields, view, rightOriginData, desensitizationList); - mergeAssistField(rightCalcResult.getDynamicAssistFields(), rightCalcResult.getAssistData()); - var rightData = new HashMap(rightTable); - rightData.putAll(rightCalcResult.getData()); - rightData.put("dynamicAssistLines", rightCalcResult.getDynamicAssistFields()); - - var allFields = (List) filterResult.getContext().get("allFields"); - // 构建结果 - Map chartData = new TreeMap<>(); - chartData.put("left", leftData); - chartData.put("right", rightData); - - var drillFilters = filterResult.getFilterList().stream().filter(f -> f.getFilterType() == 1).collect(Collectors.toList()); - var isDrill = CollectionUtils.isNotEmpty(drillFilters); - view.setDrillFilters(drillFilters); - view.setDrill(isDrill); - view.setSql(leftCalcResult.getQuerySql()); - view.setData(chartData); - return view; - } } diff --git a/core/core-backend/src/main/java/io/dataease/chart/charts/impl/mix/MixHandler.java b/core/core-backend/src/main/java/io/dataease/chart/charts/impl/mix/MixHandler.java index 5fa6c93d31..f04cc6fd52 100644 --- a/core/core-backend/src/main/java/io/dataease/chart/charts/impl/mix/MixHandler.java +++ b/core/core-backend/src/main/java/io/dataease/chart/charts/impl/mix/MixHandler.java @@ -45,6 +45,7 @@ public class MixHandler extends YoyChartHandler { //图表整体主维度 axisMap.put(ChartAxis.xAxis, new ArrayList<>(view.getXAxis())); context.put("xAxisBase", new ArrayList<>(view.getXAxis())); + axisMap.put(ChartAxis.drill, new ArrayList<>(view.getDrillFields())); return result; } @@ -93,26 +94,46 @@ public class MixHandler extends YoyChartHandler { } catch (Exception e) { e.printStackTrace(); } + + AxisFormatResult formatResult2 = new AxisFormatResult(); + var axisMap = new HashMap>(); + axisMap.put(ChartAxis.xAxis, new ArrayList<>(formatResult.getAxisMap().get(ChartAxis.xAxis))); + axisMap.put(ChartAxis.extStack, new ArrayList<>()); + axisMap.put(ChartAxis.xAxisExt, new ArrayList<>()); + axisMap.put(ChartAxis.extBubble, new ArrayList<>(formatResult.getAxisMap().get(ChartAxis.extBubble))); + axisMap.put(ChartAxis.yAxisExt, new ArrayList<>(formatResult.getAxisMap().get(ChartAxis.yAxisExt))); + axisMap.put(ChartAxis.extLabel, new ArrayList<>(formatResult.getAxisMap().get(ChartAxis.extLabel))); + axisMap.put(ChartAxis.extTooltip, new ArrayList<>(formatResult.getAxisMap().get(ChartAxis.extTooltip))); + axisMap.put(ChartAxis.drill, new ArrayList<>(formatResult.getAxisMap().get(ChartAxis.drill))); + formatResult2.setAxisMap(axisMap); + formatResult2.setContext(formatResult.getContext()); + // 计算右轴,包含 xAxis,xAxisExt,yAxisExt,需要去掉 group 和 stack - var xAxis = formatResult.getAxisMap().get(ChartAxis.xAxis); - var extStack = formatResult.getAxisMap().get(ChartAxis.extStack); - var xAxisExt = formatResult.getAxisMap().get(ChartAxis.xAxisExt); - xAxis = xAxis.subList(0, xAxis.size() - extStack.size() - xAxisExt.size()); - var extBubble = formatResult.getAxisMap().get(ChartAxis.extBubble); + var xAxis = new ArrayList<>(view.getXAxis()); + var extStack = formatResult2.getAxisMap().get(ChartAxis.extStack); + var xAxisExt = formatResult2.getAxisMap().get(ChartAxis.xAxisExt); + //xAxis = xAxis.subList(0, xAxis.size() - extStack.size() - xAxisExt.size()); + var extBubble = formatResult2.getAxisMap().get(ChartAxis.extBubble); xAxis.addAll(extBubble); - formatResult.getAxisMap().put(ChartAxis.xAxis, xAxis); - formatResult.getAxisMap().put(ChartAxis.xAxisExt, extBubble); - var yAxisExt = formatResult.getAxisMap().get(ChartAxis.yAxisExt); - formatResult.getAxisMap().put(ChartAxis.yAxis, yAxisExt); - formatResult.getContext().remove("yoyFiltered"); + var dillAxis = (ArrayList) formatResult.getContext().get("dillAxis"); + xAxis.addAll(dillAxis); + formatResult2.getAxisMap().put(ChartAxis.xAxis, xAxis); + formatResult2.getAxisMap().put(ChartAxis.xAxisExt, extBubble); + var yAxisExt = formatResult2.getAxisMap().get(ChartAxis.yAxisExt); + formatResult2.getAxisMap().put(ChartAxis.yAxis, yAxisExt); + formatResult2.getContext().remove("yoyFiltered"); + + + formatResult.getContext().put("subAxisMap", axisMap); + // 右轴重新检测同环比过滤 - customFilter(view, filterResult.getFilterList(), formatResult); - var rightResult = (T) super.calcChartResult(view, formatResult, filterResult, sqlMap, sqlMeta, provider); + customFilter(view, filterResult.getFilterList(), formatResult2); + var rightResult = (T) super.calcChartResult(view, formatResult2, filterResult, sqlMap, sqlMeta, provider); try { //如果有同环比过滤,应该用原始sql var originSql = rightResult.getQuerySql(); var rightAssistFields = dynamicAssistFields.stream().filter(x -> StringUtils.equalsAnyIgnoreCase(x.getYAxisType(), "right")).toList(); - var yAxis = formatResult.getAxisMap().get(ChartAxis.yAxis); + var yAxis = formatResult2.getAxisMap().get(ChartAxis.yAxis); var assistFields = getAssistFields(rightAssistFields, yAxis); if (CollectionUtils.isNotEmpty(assistFields)) { var req = new DatasourceRequest(); @@ -140,8 +161,8 @@ public class MixHandler extends YoyChartHandler { var desensitizationList = (Map) filterResult.getContext().get("desensitizationList"); var leftCalcResult = (ChartCalcDataResult) calcResult.getData().get("left"); var leftFields = new ArrayList(); - leftFields.addAll(view.getXAxis()); - leftFields.addAll(view.getYAxis()); + leftFields.addAll(formatResult.getAxisMap().get(ChartAxis.xAxis)); + leftFields.addAll(formatResult.getAxisMap().get(ChartAxis.yAxis)); mergeAssistField(leftCalcResult.getDynamicAssistFields(), leftCalcResult.getAssistData()); var leftOriginData = leftCalcResult.getOriginData(); var leftTable = ChartDataBuild.transTableNormal(leftFields, view, leftOriginData, desensitizationList); @@ -151,13 +172,14 @@ public class MixHandler extends YoyChartHandler { var rightCalcResult = (ChartCalcDataResult) calcResult.getData().get("right"); var rightFields = new ArrayList(); - rightFields.addAll(view.getXAxis()); - rightFields.addAll(view.getExtBubble()); - rightFields.addAll(view.getYAxisExt()); + + var subAxisMap = (HashMap>) formatResult.getContext().get("subAxisMap"); + rightFields.addAll(subAxisMap.get(ChartAxis.xAxis)); + rightFields.addAll(subAxisMap.get(ChartAxis.yAxis)); + mergeAssistField(rightCalcResult.getDynamicAssistFields(), rightCalcResult.getAssistData()); var rightOriginData = rightCalcResult.getOriginData(); var rightTable = ChartDataBuild.transTableNormal(rightFields, view, rightOriginData, desensitizationList); - mergeAssistField(rightCalcResult.getDynamicAssistFields(), rightCalcResult.getAssistData()); var rightData = new HashMap(rightTable); rightData.putAll(rightCalcResult.getData()); rightData.put("dynamicAssistLines", rightCalcResult.getDynamicAssistFields()); diff --git a/core/core-backend/src/main/java/io/dataease/chart/charts/impl/mix/StackMixHandler.java b/core/core-backend/src/main/java/io/dataease/chart/charts/impl/mix/StackMixHandler.java index d130b7119b..4d2ff9883d 100644 --- a/core/core-backend/src/main/java/io/dataease/chart/charts/impl/mix/StackMixHandler.java +++ b/core/core-backend/src/main/java/io/dataease/chart/charts/impl/mix/StackMixHandler.java @@ -41,6 +41,7 @@ public class StackMixHandler extends MixHandler { xAxisStack.addAll(view.getExtStack()); axisMap.put(ChartAxis.xAxis, xAxisStack); context.put("xAxisBase", xAxis); + axisMap.put(ChartAxis.drill, new ArrayList<>(view.getDrillFields())); return result; } @@ -61,49 +62,7 @@ public class StackMixHandler extends MixHandler { var xAxisBase = (List) formatResult.getContext().get("xAxisBase"); var xAxis = formatResult.getAxisMap().get(ChartAxis.xAxis); var xAxisExt = formatResult.getAxisMap().get(ChartAxis.xAxisExt); - return ChartDataBuild.transMixChartDataAntV(xAxisBase, xAxis, xAxisExt, yAxis, view, data, isDrill); + return super.buildNormalResult(view, formatResult, filterResult, data); } } - - @Override - public ChartViewDTO buildChart(ChartViewDTO view, ChartCalcDataResult calcResult, AxisFormatResult formatResult, CustomFilterResult filterResult) { - var desensitizationList = (Map) filterResult.getContext().get("desensitizationList"); - var leftCalcResult = (ChartCalcDataResult) calcResult.getData().get("left"); - var leftFields = new ArrayList(); - leftFields.addAll(view.getXAxis()); - leftFields.addAll(view.getExtStack()); - leftFields.addAll(view.getYAxis()); - var leftOriginData = leftCalcResult.getOriginData(); - var leftTable = ChartDataBuild.transTableNormal(leftFields, view, leftOriginData, desensitizationList); - mergeAssistField(leftCalcResult.getDynamicAssistFields(), leftCalcResult.getAssistData()); - var leftData = new HashMap(leftTable); - leftData.putAll(leftCalcResult.getData()); - leftData.put("dynamicAssistLines", leftCalcResult.getDynamicAssistFields()); - - var rightCalcResult = (ChartCalcDataResult) calcResult.getData().get("right"); - var rightFields = new ArrayList(); - rightFields.addAll(view.getXAxis()); - rightFields.addAll(view.getExtBubble()); - rightFields.addAll(view.getYAxisExt()); - var rightOriginData = rightCalcResult.getOriginData(); - var rightTable = ChartDataBuild.transTableNormal(rightFields, view, rightOriginData, desensitizationList); - mergeAssistField(rightCalcResult.getDynamicAssistFields(), rightCalcResult.getAssistData()); - var rightData = new HashMap(rightTable); - rightData.putAll(rightCalcResult.getData()); - rightData.put("dynamicAssistLines", rightCalcResult.getDynamicAssistFields()); - - var allFields = (List) filterResult.getContext().get("allFields"); - // 构建结果 - Map chartData = new TreeMap<>(); - chartData.put("left", leftData); - chartData.put("right", rightData); - - var drillFilters = filterResult.getFilterList().stream().filter(f -> f.getFilterType() == 1).collect(Collectors.toList()); - var isDrill = CollectionUtils.isNotEmpty(drillFilters); - view.setDrillFilters(drillFilters); - view.setDrill(isDrill); - view.setSql(leftCalcResult.getQuerySql()); - view.setData(chartData); - return view; - } } diff --git a/core/core-backend/src/main/java/io/dataease/chart/manage/ChartDataManage.java b/core/core-backend/src/main/java/io/dataease/chart/manage/ChartDataManage.java index 591f6b6c9f..e55f69e960 100644 --- a/core/core-backend/src/main/java/io/dataease/chart/manage/ChartDataManage.java +++ b/core/core-backend/src/main/java/io/dataease/chart/manage/ChartDataManage.java @@ -104,9 +104,7 @@ public class ChartDataManage { DEException.throwException(ResultCode.DATA_IS_WRONG.code(), Translator.get("i18n_chart_not_handler") + ": " + view.getRender() + "," + view.getType()); } - AxisFormatResult formatResult = chartHandler.formatAxis(view); - var xAxis = formatResult.getAxisMap().get(ChartAxis.xAxis); - var yAxis = formatResult.getAxisMap().get(ChartAxis.yAxis); + var dillAxis = new ArrayList(); DatasetGroupInfoDTO table = datasetGroupManage.getDatasetGroupInfoDTO(view.getTableId(), null); if (table == null) { @@ -122,7 +120,6 @@ public class ChartDataManage { } List allFields = getAllChartFields(view); - formatResult.getContext().put("allFields", allFields); // column permission Map desensitizationList = new HashMap<>(); List columnPermissionFields = permissionManage.filterColumnPermissions(transFields(allFields), desensitizationList, table.getId(), chartExtRequest.getUser()); @@ -130,13 +127,18 @@ public class ChartDataManage { List rowPermissionsTree = permissionManage.getRowPermissionsTree(table.getId(), chartExtRequest.getUser()); //将没有权限的列删掉 List dataeaseNames = columnPermissionFields.stream().map(DatasetTableFieldDTO::getDataeaseName).collect(Collectors.toList()); - dataeaseNames.add("*"); + + AxisFormatResult formatResult = chartHandler.formatAxis(view); + formatResult.getContext().put("desensitizationList", desensitizationList); + var xAxis = formatResult.getAxisMap().get(ChartAxis.xAxis); + var yAxis = formatResult.getAxisMap().get(ChartAxis.yAxis); + formatResult.getContext().put("allFields", allFields); var axisMap = formatResult.getAxisMap(); axisMap.forEach((axis, fields) -> { Iterator iterator = fields.iterator(); while (iterator.hasNext()) { ChartViewFieldDTO fieldDTO = iterator.next(); - if (desensitizationList.containsKey(fieldDTO.getDataeaseName()) || !dataeaseNames.contains(fieldDTO.getDataeaseName())) { + if (!dataeaseNames.contains(fieldDTO.getDataeaseName())) { iterator.remove(); } } @@ -290,6 +292,7 @@ public class ChartDataManage { if (!fields.contains(dim.getId())) { viewField.setSource(FieldSource.DRILL); xAxis.add(viewField); + dillAxis.add(viewField); fields.add(dim.getId()); } if (i == drillRequestList.size() - 1) { @@ -298,13 +301,19 @@ public class ChartDataManage { viewField.setSource(FieldSource.DRILL); nextDrillField.setSort(getDrillSort(xAxis, drill.get(0))); xAxis.add(nextDrillField); + dillAxis.add(nextDrillField); fields.add(nextDrillField.getId()); + } else { + dillAxis.add(nextDrillField); } } } } } } + + formatResult.getContext().put("dillAxis", dillAxis); + //转义特殊字符 extFilterList = extFilterList.stream().peek(ele -> { if (ObjectUtils.isNotEmpty(ele.getValue())) { @@ -352,10 +361,10 @@ public class ChartDataManage { Dimension2SQLObj.dimension2sqlObj(sqlMeta, xAxis, FieldUtil.transFields(allFields), crossDs, dsMap); Quota2SQLObj.quota2sqlObj(sqlMeta, yAxis, FieldUtil.transFields(allFields), crossDs, dsMap); String querySql = SQLProvider.createQuerySQL(sqlMeta, true, needOrder, view); + querySql = SqlUtils.rebuildSQL(querySql, sqlMeta, crossDs, dsMap); filterResult.getContext().put("querySql", querySql); } ChartCalcDataResult calcResult = chartHandler.calcChartResult(view, formatResult, filterResult, sqlMap, sqlMeta, calciteProvider); - formatResult.getContext().put("desensitizationList", desensitizationList); return chartHandler.buildChart(view, calcResult, formatResult, filterResult); } diff --git a/core/core-backend/src/main/java/io/dataease/datasource/provider/CalciteProvider.java b/core/core-backend/src/main/java/io/dataease/datasource/provider/CalciteProvider.java index 819ad48dc5..b490103f14 100644 --- a/core/core-backend/src/main/java/io/dataease/datasource/provider/CalciteProvider.java +++ b/core/core-backend/src/main/java/io/dataease/datasource/provider/CalciteProvider.java @@ -453,13 +453,15 @@ public class CalciteProvider extends Provider { if (StringUtils.isEmpty(configuration.getSchema())) { DEException.throwException(Translator.get("i18n_schema_is_empty")); } + sql = String.format("SELECT \n" + - " c.name ,t.name,ep.value \n" + + " c.name ,t.name ,ep.value \n" + "FROM \n" + " sys.columns AS c\n" + "LEFT JOIN sys.extended_properties AS ep ON c.object_id = ep.major_id AND c.column_id = ep.minor_id\n" + "LEFT JOIN sys.types AS t ON c.user_type_id = t.user_type_id\n" + - "WHERE c.object_id = OBJECT_ID('%s') ", datasourceRequest.getTable()); + "LEFT JOIN sys.objects AS o ON c.object_id = o.object_id\n" + + "WHERE o.name = '%s'", datasourceRequest.getTable()); break; case pg: configuration = JsonUtil.parseObject(datasourceRequest.getDatasource().getConfiguration(), Pg.class); diff --git a/core/core-frontend/src/assets/svg/chart-mix-group-origin.svg b/core/core-frontend/src/assets/svg/chart-mix-group-origin.svg index 1435dcdfb1..a83362739c 100644 --- a/core/core-frontend/src/assets/svg/chart-mix-group-origin.svg +++ b/core/core-frontend/src/assets/svg/chart-mix-group-origin.svg @@ -5,4 +5,4 @@ - + \ No newline at end of file diff --git a/core/core-frontend/src/assets/svg/chart-mix-stack-origin.svg b/core/core-frontend/src/assets/svg/chart-mix-stack-origin.svg index 69d8dbb0be..1800cfccc0 100644 --- a/core/core-frontend/src/assets/svg/chart-mix-stack-origin.svg +++ b/core/core-frontend/src/assets/svg/chart-mix-stack-origin.svg @@ -9,4 +9,4 @@ - + \ No newline at end of file diff --git a/core/core-frontend/src/custom-component/component-group/UserViewGroup.vue b/core/core-frontend/src/custom-component/component-group/UserViewGroup.vue index 887eeac210..fe0624c6b2 100644 --- a/core/core-frontend/src/custom-component/component-group/UserViewGroup.vue +++ b/core/core-frontend/src/custom-component/component-group/UserViewGroup.vue @@ -81,7 +81,10 @@ const loadPluginCategory = data => { while (stack?.length) { const parent = stack.pop() if (parent.category === category) { - parent.details.push(node) + const chart = parent.details.find(chart => chart.value === node.value) + if (!chart) { + parent.details.push(node) + } findParent = true } } diff --git a/core/core-frontend/src/models/chart/chart.d.ts b/core/core-frontend/src/models/chart/chart.d.ts index ca902de2b9..f124dfa417 100644 --- a/core/core-frontend/src/models/chart/chart.d.ts +++ b/core/core-frontend/src/models/chart/chart.d.ts @@ -57,6 +57,7 @@ declare interface Chart { jumpActive: boolean aggregate?: boolean plugin?: CustomPlugin + isPlugin: boolean } declare type CustomAttr = DeepPartial | JSONString> declare type CustomStyle = DeepPartial | JSONString> diff --git a/core/core-frontend/src/store/modules/data-visualization/dvMain.ts b/core/core-frontend/src/store/modules/data-visualization/dvMain.ts index 8c535207d7..a994231fee 100644 --- a/core/core-frontend/src/store/modules/data-visualization/dvMain.ts +++ b/core/core-frontend/src/store/modules/data-visualization/dvMain.ts @@ -393,6 +393,7 @@ export const dvMainStore = defineStore('dataVisualization', { id: component.id, type: component.innerType, render: component.render, + isPlugin: component.isPlugin, plugin: { isPlugin: component.isPlugin, staticMap: component.staticMap diff --git a/core/core-frontend/src/views/chart/components/editor/editor-style/components/BasicStyleSelector.vue b/core/core-frontend/src/views/chart/components/editor/editor-style/components/BasicStyleSelector.vue index f9c6b6bbbe..6b39db4dad 100644 --- a/core/core-frontend/src/views/chart/components/editor/editor-style/components/BasicStyleSelector.vue +++ b/core/core-frontend/src/views/chart/components/editor/editor-style/components/BasicStyleSelector.vue @@ -348,7 +348,7 @@ onMounted(() => { {