Merge pull request #10920 from dataease/pr@dev-v2@feat_copilot

feat: 新增copilot所需接口
This commit is contained in:
Junjun 2024-07-12 10:58:51 +08:00 committed by GitHub
commit a4a7ccca2a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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<AxisFieldDTO> columns = new ArrayList<>();
columns.add(receiveDTO.getChart().getAxis().getX());
columns.add(receiveDTO.getChart().getAxis().getY());
receiveDTO.getChart().setColumns(columns);
}
}
public List<MsgDTO> getList(Long userId) {