From 0fcf57c0d763a74ad64463c18f3e33d44aa55f2d Mon Sep 17 00:00:00 2001 From: junjun Date: Fri, 12 Jul 2024 10:54:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9Ecopilot=E6=89=80?= =?UTF-8?q?=E9=9C=80=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/dataease/copilot/manage/CopilotManage.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/core/core-backend/src/main/java/io/dataease/copilot/manage/CopilotManage.java b/core/core-backend/src/main/java/io/dataease/copilot/manage/CopilotManage.java index 9f5c846725..b00c69fe0d 100644 --- a/core/core-backend/src/main/java/io/dataease/copilot/manage/CopilotManage.java +++ b/core/core-backend/src/main/java/io/dataease/copilot/manage/CopilotManage.java @@ -71,6 +71,8 @@ public class CopilotManage { @Resource private F2CLicManage f2CLicManage; + private String[] chartType = {"bar", "line", "pie"}; + public MsgDTO chat(MsgDTO msgDTO) throws Exception { CoreDatasetGroup coreDatasetGroup = coreDatasetGroupMapper.selectById(msgDTO.getDatasetGroupId()); if (coreDatasetGroup == null) { @@ -294,7 +296,7 @@ public class CopilotManage { if (StringUtils.equalsIgnoreCase(receiveDTO.getChart().getType(), "pie")) { AxisFieldDTO column = receiveDTO.getChart().getColumn(); if (fields.size() != 2 || column == null) { - DEException.throwException("当前字段不足以构建饼图"); + DEException.throwException("当前字段不足以构建饼图: " + JsonUtil.toJSONString(receiveDTO)); } AxisDTO axisDTO = new AxisDTO(); AxisFieldDTO x = new AxisFieldDTO(); @@ -310,7 +312,7 @@ public class CopilotManage { y.setName(column.getName()); y.setValue(column.getValue()); } else { - DEException.throwException("当前字段不足以构建饼图"); + DEException.throwException("当前字段不足以构建饼图: " + JsonUtil.toJSONString(receiveDTO)); } axisDTO.setX(x); axisDTO.setY(y); @@ -328,6 +330,14 @@ public class CopilotManage { receiveDTO.getChart().setColumns(columns); } } + + // 所有图表都加上columns字段用于切换明细表展示 + if (Arrays.asList(chartType).contains(receiveDTO.getChart().getType())) { + List columns = new ArrayList<>(); + columns.add(receiveDTO.getChart().getAxis().getX()); + columns.add(receiveDTO.getChart().getAxis().getY()); + receiveDTO.getChart().setColumns(columns); + } } public List getList(Long userId) {