mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-10 11:07:06 +00:00
Compare commits
15 Commits
90dcf09c8b
...
2f4f2027a5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f4f2027a5 | ||
|
|
47c2595fb8 | ||
|
|
9bddd4457e | ||
|
|
55ac3d1aa5 | ||
|
|
0427917624 | ||
|
|
d8fe2ed2b3 | ||
|
|
11d1264d38 | ||
|
|
32675387d7 | ||
|
|
e408204690 | ||
|
|
fa65b6eff7 | ||
|
|
0ab44c0866 | ||
|
|
449fdf180f | ||
|
|
d275a145d5 | ||
|
|
c8f690c1c2 | ||
|
|
38af6e3a28 |
@@ -88,10 +88,10 @@ public class WebServiceQuery extends PluginSemanticQuery {
|
|||||||
restTemplate = ContextUtils.getBean(RestTemplate.class);
|
restTemplate = ContextUtils.getBean(RestTemplate.class);
|
||||||
try {
|
try {
|
||||||
responseEntity =
|
responseEntity =
|
||||||
restTemplate.exchange(requestUrl, HttpMethod.POST, entity, Object.class);
|
restTemplate.exchange(requestUrl, HttpMethod.POST, entity, String.class);
|
||||||
objectResponse = responseEntity.getBody();
|
objectResponse = responseEntity.getBody();
|
||||||
log.info("objectResponse:{}", objectResponse);
|
log.info("objectResponse:{}", objectResponse);
|
||||||
Map<String, Object> response = JsonUtil.objectToMap(objectResponse);
|
Map<String, Object> response = JSON.parseObject(objectResponse.toString());
|
||||||
webServiceResponse.setResult(response);
|
webServiceResponse.setResult(response);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.info("Exception:{}", e.getMessage());
|
log.info("Exception:{}", e.getMessage());
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class ParseContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean enableNL2SQL() {
|
public boolean enableNL2SQL() {
|
||||||
return Objects.nonNull(agent) && agent.containsDatasetTool();
|
return Objects.nonNull(agent) && agent.containsDatasetTool()&&response.getSelectedParses().size() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean enableLLM() {
|
public boolean enableLLM() {
|
||||||
|
|||||||
@@ -23,9 +23,11 @@ public class SqlExecuteReq {
|
|||||||
private Integer limit = 1000;
|
private Integer limit = 1000;
|
||||||
|
|
||||||
public String getSql() {
|
public String getSql() {
|
||||||
if (StringUtils.isNotBlank(sql) && sql.endsWith(";")) {
|
if(StringUtils.isNotBlank(sql)){
|
||||||
sql = sql.substring(0, sql.length() - 1);
|
sql=sql.replaceAll("^[\\n]+|[\\n]+$", "");
|
||||||
|
sql=StringUtils.removeEnd(sql,";");
|
||||||
}
|
}
|
||||||
|
|
||||||
return String.format(LIMIT_WRAPPER, sql, limit);
|
return String.format(LIMIT_WRAPPER, sql, limit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ public abstract class BaseMapper implements SchemaMapper {
|
|||||||
Map<MatchText, List<T>> matchResult = matchStrategy.match(chatQueryContext, terms,
|
Map<MatchText, List<T>> matchResult = matchStrategy.match(chatQueryContext, terms,
|
||||||
chatQueryContext.getRequest().getDataSetIds());
|
chatQueryContext.getRequest().getDataSetIds());
|
||||||
List<T> matches = new ArrayList<>();
|
List<T> matches = new ArrayList<>();
|
||||||
if (Objects.isNull(matchResult)) {
|
if (Objects.isNull(matchResult) || matchResult.isEmpty()) {
|
||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
Optional<List<T>> first = matchResult.entrySet().stream()
|
Optional<List<T>> first = matchResult.entrySet().stream()
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ public class SqlBuilder {
|
|||||||
GraphPath<String, DefaultEdge> selectedGraphPath = null;
|
GraphPath<String, DefaultEdge> selectedGraphPath = null;
|
||||||
for (String fromModel : queryModels) {
|
for (String fromModel : queryModels) {
|
||||||
for (String toModel : queryModels) {
|
for (String toModel : queryModels) {
|
||||||
if (fromModel != toModel) {
|
if (!fromModel.equals(toModel)) {
|
||||||
GraphPath<String, DefaultEdge> path = dijkstraAlg.getPath(fromModel, toModel);
|
GraphPath<String, DefaultEdge> path = dijkstraAlg.getPath(fromModel, toModel);
|
||||||
if (isGraphPathContainsAll(path, queryModels)) {
|
if (isGraphPathContainsAll(path, queryModels)) {
|
||||||
selectedGraphPath = path;
|
selectedGraphPath = path;
|
||||||
@@ -100,13 +100,13 @@ public class SqlBuilder {
|
|||||||
if (selectedGraphPath == null) {
|
if (selectedGraphPath == null) {
|
||||||
return dataModels;
|
return dataModels;
|
||||||
}
|
}
|
||||||
Set<String> modelNames = Sets.newHashSet();
|
Set<String> modelNames = Sets.newLinkedHashSet();
|
||||||
for (DefaultEdge edge : selectedGraphPath.getEdgeList()) {
|
for (DefaultEdge edge : selectedGraphPath.getEdgeList()) {
|
||||||
modelNames.add(selectedGraphPath.getGraph().getEdgeSource(edge));
|
modelNames.add(selectedGraphPath.getGraph().getEdgeSource(edge));
|
||||||
modelNames.add(selectedGraphPath.getGraph().getEdgeTarget(edge));
|
modelNames.add(selectedGraphPath.getGraph().getEdgeTarget(edge));
|
||||||
}
|
}
|
||||||
return modelNames.stream().map(m -> ontology.getModelMap().get(m))
|
return modelNames.stream().map(m -> ontology.getModelMap().get(m))
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isGraphPathContainsAll(GraphPath<String, DefaultEdge> graphPath,
|
private boolean isGraphPathContainsAll(GraphPath<String, DefaultEdge> graphPath,
|
||||||
|
|||||||
@@ -109,9 +109,14 @@ public class MetricRepositoryImpl implements MetricRepository {
|
|||||||
}
|
}
|
||||||
if (StringUtils.isNotBlank(metricFilter.getKey())) {
|
if (StringUtils.isNotBlank(metricFilter.getKey())) {
|
||||||
String key = metricFilter.getKey();
|
String key = metricFilter.getKey();
|
||||||
queryWrapper.lambda().like(MetricDO::getName, key).or().like(MetricDO::getBizName, key)
|
queryWrapper.lambda()
|
||||||
.or().like(MetricDO::getDescription, key).or().like(MetricDO::getAlias, key)
|
.and(wrapper -> wrapper
|
||||||
.or().like(MetricDO::getCreatedBy, key);
|
.like(MetricDO::getName, key)
|
||||||
|
.or().like(MetricDO::getBizName, key)
|
||||||
|
.or().like(MetricDO::getDescription, key)
|
||||||
|
.or().like(MetricDO::getAlias, key)
|
||||||
|
.or().like(MetricDO::getCreatedBy, key)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return metricDOMapper.selectList(queryWrapper);
|
return metricDOMapper.selectList(queryWrapper);
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@@ -50,10 +51,8 @@ public class DataSetController {
|
|||||||
|
|
||||||
@GetMapping("/getDataSetList")
|
@GetMapping("/getDataSetList")
|
||||||
public List<DataSetResp> getDataSetList(@RequestParam("domainId") Long domainId) {
|
public List<DataSetResp> getDataSetList(@RequestParam("domainId") Long domainId) {
|
||||||
MetaFilter metaFilter = new MetaFilter();
|
List<Integer> statuCodeList = Arrays.asList(StatusEnum.ONLINE.getCode(),StatusEnum.OFFLINE.getCode());
|
||||||
metaFilter.setDomainId(domainId);
|
return dataSetService.getDataSetList(domainId,statuCodeList);
|
||||||
metaFilter.setStatus(StatusEnum.ONLINE.getCode());
|
|
||||||
return dataSetService.getDataSetList(metaFilter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ public interface DataSetService {
|
|||||||
|
|
||||||
List<DataSetResp> getDataSetList(MetaFilter metaFilter);
|
List<DataSetResp> getDataSetList(MetaFilter metaFilter);
|
||||||
|
|
||||||
|
List<DataSetResp> getDataSetList(Long domainId ,List<Integer> statuCodesList);
|
||||||
|
|
||||||
void delete(Long id, User user);
|
void delete(Long id, User user);
|
||||||
|
|
||||||
Map<Long, List<Long>> getModelIdToDataSetIds(List<Long> dataSetIds, User user);
|
Map<Long, List<Long>> getModelIdToDataSetIds(List<Long> dataSetIds, User user);
|
||||||
|
|||||||
@@ -102,6 +102,20 @@ public class DataSetServiceImpl extends ServiceImpl<DataSetDOMapper, DataSetDO>
|
|||||||
return list(wrapper).stream().map(this::convert).collect(Collectors.toList());
|
return list(wrapper).stream().map(this::convert).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DataSetResp> getDataSetList(Long domainId, List<Integer> statuCodesList) {
|
||||||
|
if(domainId==null || CollectionUtils.isEmpty(statuCodesList)){
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
QueryWrapper<DataSetDO> wrapper = new QueryWrapper<>();
|
||||||
|
wrapper.lambda().eq(DataSetDO::getDomainId, domainId);
|
||||||
|
wrapper.lambda().in(DataSetDO::getStatus, statuCodesList);
|
||||||
|
wrapper.lambda().ne(DataSetDO::getStatus, StatusEnum.DELETED.getCode());
|
||||||
|
|
||||||
|
return list(wrapper).stream().map(this::convert).collect(Collectors.toList());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(Long id, User user) {
|
public void delete(Long id, User user) {
|
||||||
DataSetDO dataSetDO = getById(id);
|
DataSetDO dataSetDO = getById(id);
|
||||||
|
|||||||
@@ -277,7 +277,7 @@ public class DictUtils {
|
|||||||
ModelResp model = modelService.getModel(dictItemResp.getModelId());
|
ModelResp model = modelService.getModel(dictItemResp.getModelId());
|
||||||
String tableStr = StringUtils.isNotBlank(model.getModelDetail().getTableQuery())
|
String tableStr = StringUtils.isNotBlank(model.getModelDetail().getTableQuery())
|
||||||
? model.getModelDetail().getTableQuery()
|
? model.getModelDetail().getTableQuery()
|
||||||
: "(" + model.getModelDetail().getSqlQuery() + ")";
|
: "(" + model.getModelDetail().getSqlQuery() + ") AS t";
|
||||||
String sqlPattern =
|
String sqlPattern =
|
||||||
"select %s,count(1) from %s %s group by %s order by count(1) desc limit %d";
|
"select %s,count(1) from %s %s group by %s order by count(1) desc limit %d";
|
||||||
String dimBizName = dictItemResp.getBizName();
|
String dimBizName = dictItemResp.getBizName();
|
||||||
|
|||||||
@@ -420,4 +420,4 @@ ALTER TABLE s2_chat_model add column is_open tinyint DEFAULT NULL COMMENT '是
|
|||||||
ALTER TABLE s2_database add column is_open tinyint DEFAULT NULL COMMENT '是否公开';
|
ALTER TABLE s2_database add column is_open tinyint DEFAULT NULL COMMENT '是否公开';
|
||||||
|
|
||||||
--20250321
|
--20250321
|
||||||
ALTER TABLE s2_user add column last_loin datetime DEFAULT NULL;
|
ALTER TABLE s2_user add column last_login datetime DEFAULT NULL;
|
||||||
|
|||||||
@@ -416,11 +416,10 @@ const ChatItem: React.FC<Props> = ({
|
|||||||
|
|
||||||
const onExportData = () => {
|
const onExportData = () => {
|
||||||
const { queryColumns, queryResults } = data || {};
|
const { queryColumns, queryResults } = data || {};
|
||||||
if (!!queryResults) {
|
if (!!queryResults && !!queryColumns) {
|
||||||
const exportData = queryResults.map(item => {
|
const exportData = queryResults.map(item => {
|
||||||
return Object.keys(item).reduce((result, key) => {
|
return queryColumns.reduce((result, column) => {
|
||||||
const columnName = queryColumns?.find(column => column.nameEn === key)?.name || key;
|
result[column.name || column.nameEn] = item[column.nameEn];
|
||||||
result[columnName] = item[key];
|
|
||||||
return result;
|
return result;
|
||||||
}, {});
|
}, {});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ const Table: React.FC<Props> = ({ data, size, loading, question, onApplyAuth })
|
|||||||
dataIndex: bizName,
|
dataIndex: bizName,
|
||||||
key: bizName,
|
key: bizName,
|
||||||
title: name || bizName,
|
title: name || bizName,
|
||||||
defaultSortOrder: 'descend',
|
|
||||||
sorter:
|
sorter:
|
||||||
showType === 'NUMBER'
|
showType === 'NUMBER'
|
||||||
? (a, b) => {
|
? (a, b) => {
|
||||||
@@ -43,8 +42,8 @@ const Table: React.FC<Props> = ({ data, size, loading, question, onApplyAuth })
|
|||||||
{`${
|
{`${
|
||||||
value
|
value
|
||||||
? formatByDataFormatType(value, dataFormatType, dataFormat)
|
? formatByDataFormatType(value, dataFormatType, dataFormat)
|
||||||
: 0
|
: '0%'
|
||||||
}%`}
|
}`}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -73,10 +72,11 @@ const Table: React.FC<Props> = ({ data, size, loading, question, onApplyAuth })
|
|||||||
return index % 2 !== 0 ? `${prefixCls}-even-row` : '';
|
return index % 2 !== 0 ? `${prefixCls}-even-row` : '';
|
||||||
};
|
};
|
||||||
|
|
||||||
const dateColumn = queryColumns.find(column => column.type === 'DATE');
|
const dateColumn = queryColumns.find(column => column.type === 'DATE' || column.showType === 'DATE');
|
||||||
const dataSource = dateColumn
|
const dataSource = dateColumn
|
||||||
? queryResults.sort((a, b) => moment(a[dateColumn.bizName]).diff(moment(b[dateColumn.bizName])))
|
? queryResults.sort((a, b) => moment(a[dateColumn.bizName]).diff(moment(b[dateColumn.bizName])))
|
||||||
: queryResults;
|
: queryResults;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={prefixCls}>
|
<div className={prefixCls}>
|
||||||
{question && (
|
{question && (
|
||||||
|
|||||||
Reference in New Issue
Block a user