mirror of
https://github.com/dataease/dataease.git
synced 2026-05-15 05:22:13 +08:00
fix: 【数据源】解决API数据源同步日志较多时,切换数据源查看页面卡慢问题
This commit is contained in:
@@ -48,8 +48,6 @@ import io.dataease.system.dao.auto.entity.CoreSysSetting;
|
||||
import io.dataease.system.manage.CoreUserManage;
|
||||
import io.dataease.utils.*;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.ServletOutputStream;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -57,7 +55,6 @@ import org.quartz.JobDataMap;
|
||||
import org.quartz.JobKey;
|
||||
import org.quartz.TriggerKey;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -67,8 +64,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -723,13 +719,6 @@ public class DatasourceServer implements DatasourceApi {
|
||||
datasourceRequest.setDatasource(datasourceDTO);
|
||||
if (coreDatasource.getType().contains(DatasourceConfiguration.DatasourceType.API.name())) {
|
||||
List<DatasetTableDTO> datasetTableDTOS = (List<DatasetTableDTO>) invokeMethod(coreDatasource.getType(), "getApiTables", DatasourceRequest.class, datasourceRequest);
|
||||
datasetTableDTOS.forEach(datasetTableDTO1 -> {
|
||||
CoreDatasourceTaskLog log = datasourceTaskServer.lastSyncLogForTable(datasetTableDTO.getDatasourceId(), datasetTableDTO1.getTableName());
|
||||
if (log != null) {
|
||||
datasetTableDTO1.setLastUpdateTime(log.getStartTime());
|
||||
datasetTableDTO1.setStatus(log.getTaskStatus());
|
||||
}
|
||||
});
|
||||
return datasetTableDTOS;
|
||||
}
|
||||
if (coreDatasource.getType().contains("Excel")) {
|
||||
@@ -739,6 +728,33 @@ public class DatasourceServer implements DatasourceApi {
|
||||
return provider.getTables(datasourceRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DatasetTableDTO> getTableStatus(DatasetTableDTO datasetTableDTO) throws DEException {
|
||||
CoreDatasource coreDatasource = dataSourceManage.getCoreDatasource(datasetTableDTO.getDatasourceId());
|
||||
if (coreDatasource == null) {
|
||||
DEException.throwException("无效数据源!");
|
||||
}
|
||||
List<DatasetTableDTO> datasetTableDTOS = new ArrayList<>();
|
||||
DatasourceDTO datasourceDTO = new DatasourceDTO();
|
||||
BeanUtils.copyBean(datasourceDTO, coreDatasource);
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
datasourceRequest.setDatasource(datasourceDTO);
|
||||
if (coreDatasource.getType().contains(DatasourceConfiguration.DatasourceType.API.name())) {
|
||||
datasetTableDTOS = (List<DatasetTableDTO>) invokeMethod(coreDatasource.getType(), "getApiTables", DatasourceRequest.class, datasourceRequest);
|
||||
}
|
||||
if (coreDatasource.getType().equalsIgnoreCase(DatasourceConfiguration.DatasourceType.ExcelRemote.name())) {
|
||||
datasetTableDTOS = ExcelUtils.getTables(datasourceRequest);
|
||||
}
|
||||
datasetTableDTOS.forEach(datasetTableDTO1 -> {
|
||||
CoreDatasourceTaskLog log = datasourceTaskServer.lastSyncLogForTable(datasetTableDTO.getDatasourceId(), datasetTableDTO1.getTableName());
|
||||
if (log != null) {
|
||||
datasetTableDTO1.setLastUpdateTime(log.getStartTime());
|
||||
datasetTableDTO1.setStatus(log.getTaskStatus());
|
||||
}
|
||||
});
|
||||
return datasetTableDTOS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TableField> getTableField(Map<String, String> req) throws DEException {
|
||||
String tableName = req.get("tableName");
|
||||
|
||||
@@ -60,6 +60,12 @@ export const listDatasourceTables = async (data = {}): Promise<IResponse> => {
|
||||
})
|
||||
}
|
||||
|
||||
export const getTableStatus = async (data = {}): Promise<IResponse> => {
|
||||
return request.post({ url: '/datasource/getTableStatus', data }).then(res => {
|
||||
return res
|
||||
})
|
||||
}
|
||||
|
||||
export const getSchema = (data = {}) => {
|
||||
return request.post({ url: '/datasource/getSchema', data })
|
||||
}
|
||||
|
||||
@@ -49,7 +49,8 @@ import {
|
||||
uploadFile,
|
||||
perDeleteDatasource,
|
||||
getSimpleDs,
|
||||
supportSetKey
|
||||
supportSetKey,
|
||||
getTableStatus
|
||||
} from '@/api/datasource'
|
||||
import CreatDsGroup from './form/CreatDsGroup.vue'
|
||||
import type { Tree } from '../dataset/form/CreatDsGroup.vue'
|
||||
@@ -960,8 +961,29 @@ const handleClick = (tabName: TabPaneName) => {
|
||||
case 'table':
|
||||
tableData.value = []
|
||||
listDatasourceTables({ datasourceId: nodeInfo.id }).then(res => {
|
||||
console.log(nodeInfo)
|
||||
tableData.value = res.data
|
||||
initSearch()
|
||||
if (nodeInfo.type.startsWith('API') || nodeInfo.type === 'ExcelRemote') {
|
||||
getTableStatus({ datasourceId: nodeInfo.id }).then(res => {
|
||||
for (let i = 0; i < state.filterTable.length; i++) {
|
||||
for (let j = 0; j < res.data.length; j++) {
|
||||
if (state.filterTable[i].tableName === res.data[j].tableName) {
|
||||
state.filterTable[i].lastUpdateTime = res.data[j].lastUpdateTime
|
||||
state.filterTable[i].status = res.data[j].status
|
||||
}
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < tableData.value.length; i++) {
|
||||
for (let j = 0; j < res.data.length; j++) {
|
||||
if (tableData.value[i].tableName === res.data[j].tableName) {
|
||||
tableData.value[i].lastUpdateTime = res.data[j].lastUpdateTime
|
||||
tableData.value[i].status = res.data[j].status
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
break
|
||||
default:
|
||||
|
||||
@@ -127,6 +127,11 @@ public interface DatasourceApi {
|
||||
@Operation(summary = "获取表")
|
||||
List<DatasetTableDTO> getTables(@RequestBody DatasetTableDTO datasetTableDTO) throws DEException;
|
||||
|
||||
@DePermit({"#p0.datasourceId+':read'"})
|
||||
@PostMapping("getTableStatus")
|
||||
@Operation(summary = "获取数据表更新状态")
|
||||
List<DatasetTableDTO> getTableStatus(@RequestBody DatasetTableDTO datasetTableDTO) throws DEException;
|
||||
|
||||
@PostMapping("/checkApiDatasource")
|
||||
@Operation(summary = "校验API数据源")
|
||||
ApiDefinition checkApiDatasource(@RequestBody Map<String, String> data) throws DEException;
|
||||
|
||||
Reference in New Issue
Block a user