forked from github/dataease
fix: 数据源定时监测失败
This commit is contained in:
parent
e1163c9a27
commit
24d553e9fc
@ -112,21 +112,21 @@ public class DatasourceSyncManage {
|
||||
LogUtil.info("Skip synchronization task for datasource due to exist others, datasource ID : " + datasourceId);
|
||||
return;
|
||||
}
|
||||
|
||||
DatasourceServer.UpdateType updateType = DatasourceServer.UpdateType.valueOf(coreDatasourceTask.getUpdateType());
|
||||
if (context != null) {
|
||||
UpdateWrapper<CoreDatasource> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.eq("id", datasourceId);
|
||||
CoreDatasource record = new CoreDatasource();
|
||||
record.setQrtzInstance(context.getFireInstanceId());
|
||||
datasourceMapper.update(record, updateWrapper);
|
||||
}
|
||||
extractedData(taskId, coreDatasource, updateType, coreDatasourceTask.getSyncRate());
|
||||
try {
|
||||
DatasourceServer.UpdateType updateType = DatasourceServer.UpdateType.valueOf(coreDatasourceTask.getUpdateType());
|
||||
if (context != null) {
|
||||
UpdateWrapper<CoreDatasource> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.eq("id", datasourceId);
|
||||
CoreDatasource record = new CoreDatasource();
|
||||
record.setQrtzInstance(context.getFireInstanceId());
|
||||
datasourceMapper.update(record, updateWrapper);
|
||||
}
|
||||
extractedData(taskId, coreDatasource, updateType, coreDatasourceTask.getSyncRate());
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
} finally {
|
||||
datasourceTaskServer.updateTaskStatus(coreDatasourceTask);
|
||||
updateDsTaskStatus(datasourceId);
|
||||
} catch (Exception ignore) {
|
||||
LogUtil.error(ignore);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,6 @@ public class ApiUtils {
|
||||
if (field.getOriginName().equalsIgnoreCase(param)) {
|
||||
String resultStr = execHttpRequest(definition, definition.getApiQueryTimeout() == null || apiDefinition.getApiQueryTimeout() <= 0 ? 10 : apiDefinition.getApiQueryTimeout(), null);
|
||||
List<String[]> dataList = fetchResult(resultStr, definition);
|
||||
System.out.println(dataList.get(0)[i]);
|
||||
if (dataList.size() > 0) {
|
||||
httpClientConfig.addHeader(header.get("name").toString(), dataList.get(0)[i]);
|
||||
}
|
||||
|
@ -480,7 +480,8 @@ public class DatasourceServer implements DatasourceApi {
|
||||
BeanUtils.copyBean(coreDatasource, dataSourceDTO);
|
||||
checkDatasourceStatus(dataSourceDTO);
|
||||
DatasourceDTO result = new DatasourceDTO();
|
||||
result.setStatus(coreDatasource.getStatus());
|
||||
result.setType(dataSourceDTO.getType());
|
||||
result.setStatus(dataSourceDTO.getStatus());
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -679,59 +680,24 @@ public class DatasourceServer implements DatasourceApi {
|
||||
}
|
||||
|
||||
private DatasourceDTO validate(CoreDatasource coreDatasource) {
|
||||
String lastStatus = coreDatasource.getStatus();
|
||||
DatasourceDTO datasourceDTO = new DatasourceDTO();
|
||||
BeanUtils.copyBean(datasourceDTO, coreDatasource);
|
||||
try {
|
||||
checkDatasourceStatus(datasourceDTO);
|
||||
calciteProvider.updateDsPoolAfterCheckStatus(datasourceDTO);
|
||||
if (!Arrays.asList("API", "Excel", "folder").contains(coreDatasource.getType())) {
|
||||
calciteProvider.updateDsPoolAfterCheckStatus(datasourceDTO);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
coreDatasource.setStatus("Error");
|
||||
DEException.throwException(e.getMessage());
|
||||
} finally {
|
||||
datasourceDTO.setStatus(coreDatasource.getStatus());
|
||||
QueryWrapper<CoreDatasource> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("id", coreDatasource.getId());
|
||||
CoreDatasource originData = datasourceMapper.selectById(coreDatasource.getId());
|
||||
String originStatus = originData.getStatus();
|
||||
coreDatasource.setStatus(datasourceDTO.getStatus());
|
||||
dataSourceManage.innerEditStatus(coreDatasource);
|
||||
}
|
||||
datasourceDTO.setConfiguration("");
|
||||
return datasourceDTO;
|
||||
}
|
||||
|
||||
private int getExtraFlag(Object typeObj, Object statusObj) {
|
||||
if (ObjectUtils.isNotEmpty(statusObj)) {
|
||||
String status = statusObj.toString();
|
||||
if (typeObj.toString().equalsIgnoreCase("API")) {
|
||||
TypeReference<List<ObjectNode>> listTypeReference = new TypeReference<List<ObjectNode>>() {
|
||||
};
|
||||
List<ObjectNode> apiStatus = JsonUtil.parseList(status, listTypeReference);
|
||||
boolean hasError = false;
|
||||
for (ObjectNode jsonNodes : apiStatus) {
|
||||
if (jsonNodes.get("status") != null && jsonNodes.get("status").asText().equalsIgnoreCase("Error")) {
|
||||
hasError = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (hasError) {
|
||||
return -DataSourceType.valueOf(typeObj.toString()).getFlag();
|
||||
} else {
|
||||
return DataSourceType.valueOf(typeObj.toString()).getFlag();
|
||||
}
|
||||
|
||||
} else {
|
||||
if (StringUtils.equalsIgnoreCase(status, "Error")) {
|
||||
return -DataSourceType.valueOf(typeObj.toString()).getFlag();
|
||||
} else {
|
||||
return DataSourceType.valueOf(typeObj.toString()).getFlag();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return DataSourceType.valueOf(typeObj.toString()).getFlag();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BusiNodeVO> tree(BusiNodeRequest request) throws DEException {
|
||||
return dataSourceManage.tree(request);
|
||||
|
@ -236,7 +236,6 @@ const saveDataset = () => {
|
||||
nodeType: nodeType.value as 'folder' | 'datasource',
|
||||
name: datasetForm.name
|
||||
}
|
||||
|
||||
switch (cmd.value) {
|
||||
case 'move':
|
||||
params.pid = activeAll.value ? '0' : (datasetForm.pid as string)
|
||||
@ -276,8 +275,8 @@ const saveDataset = () => {
|
||||
checkRepeat(request).then(res => {
|
||||
let method = request.id === '' ? save : update
|
||||
if (res) {
|
||||
ElMessageBox.confirm(t('datasource.has_same_ds'), options as ElMessageBoxOptions).then(
|
||||
() => {
|
||||
ElMessageBox.confirm(t('datasource.has_same_ds'), options as ElMessageBoxOptions)
|
||||
.then(() => {
|
||||
method({ ...request, name: datasetForm.name, pid: params.pid })
|
||||
.then(res => {
|
||||
if (res !== undefined) {
|
||||
@ -290,8 +289,12 @@ const saveDataset = () => {
|
||||
.finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
)
|
||||
})
|
||||
.catch(() => {
|
||||
console.log('aaa')
|
||||
loading.value = false
|
||||
createDataset.value = false
|
||||
})
|
||||
} else {
|
||||
method({ ...request, name: datasetForm.name, pid: params.pid })
|
||||
.then(res => {
|
||||
|
@ -364,6 +364,7 @@ const resetForm = () => {
|
||||
const returnItem = apiItem => {
|
||||
var find = false
|
||||
if (apiItem.type !== 'params') {
|
||||
apiItem.status = 'Success'
|
||||
for (let i = 0; i < form.value.apiConfiguration.length; i++) {
|
||||
if (form.value.apiConfiguration[i].serialNumber === apiItem.serialNumber) {
|
||||
find = true
|
||||
@ -907,41 +908,6 @@ defineExpose({
|
||||
autocomplete="off"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="['oracle', 'sqlServer', 'pg', 'redshift', 'db2'].includes(form.type)"
|
||||
class="schema-label"
|
||||
:prop="showSchema ? '' : 'configuration.schema'"
|
||||
>
|
||||
<template v-slot:label>
|
||||
<span class="name">{{ t('datasource.schema') }}<i class="required" /></span>
|
||||
<el-button text size="small" @click="getDsSchema()">
|
||||
<template #icon>
|
||||
<Icon name="icon_add_outlined"></Icon>
|
||||
</template>
|
||||
{{ t('datasource.get_schema') }}
|
||||
</el-button>
|
||||
</template>
|
||||
<el-select
|
||||
v-model="form.configuration.schema"
|
||||
filterable
|
||||
:placeholder="t('common.please_select')"
|
||||
class="de-select"
|
||||
@change="validatorSchema"
|
||||
@blur="validatorSchema"
|
||||
>
|
||||
<el-option v-for="item in schemas" :key="item" :label="item" :value="item" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
:label="t('datasource.extra_params')"
|
||||
v-if="form.configuration.urlType !== 'jdbcUrl'"
|
||||
>
|
||||
<el-input
|
||||
:placeholder="t('common.inputText') + t('datasource.extra_params')"
|
||||
v-model="form.configuration.extraParams"
|
||||
autocomplete="off"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
:label="t('datasource.auth_method')"
|
||||
prop="configuration.authMethod"
|
||||
@ -1013,6 +979,41 @@ defineExpose({
|
||||
{{ t('datasource.oracle_service_name') }}
|
||||
</el-radio>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="['oracle', 'sqlServer', 'pg', 'redshift', 'db2'].includes(form.type)"
|
||||
class="schema-label"
|
||||
:prop="showSchema ? '' : 'configuration.schema'"
|
||||
>
|
||||
<template v-slot:label>
|
||||
<span class="name">{{ t('datasource.schema') }}<i class="required" /></span>
|
||||
<el-button text size="small" @click="getDsSchema()">
|
||||
<template #icon>
|
||||
<Icon name="icon_add_outlined"></Icon>
|
||||
</template>
|
||||
{{ t('datasource.get_schema') }}
|
||||
</el-button>
|
||||
</template>
|
||||
<el-select
|
||||
v-model="form.configuration.schema"
|
||||
filterable
|
||||
:placeholder="t('common.please_select')"
|
||||
class="de-select"
|
||||
@change="validatorSchema"
|
||||
@blur="validatorSchema"
|
||||
>
|
||||
<el-option v-for="item in schemas" :key="item" :label="item" :value="item" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
:label="t('datasource.extra_params')"
|
||||
v-if="form.configuration.urlType !== 'jdbcUrl'"
|
||||
>
|
||||
<el-input
|
||||
:placeholder="t('common.inputText') + t('datasource.extra_params')"
|
||||
v-model="form.configuration.extraParams"
|
||||
autocomplete="off"
|
||||
/>
|
||||
</el-form-item>
|
||||
<span
|
||||
v-if="!['es', 'api'].includes(form.type)"
|
||||
class="de-expand"
|
||||
|
@ -260,7 +260,10 @@ const validateDS = () => {
|
||||
ElMessage.error('需要添加数据表')
|
||||
return
|
||||
}
|
||||
request.configuration = Base64.encode(JSON.stringify(request.apiConfiguration))
|
||||
let apiItems = []
|
||||
apiItems = apiItems.concat(request.apiConfiguration)
|
||||
apiItems = apiItems.concat(request.paramsConfiguration)
|
||||
request.configuration = Base64.encode(JSON.stringify(apiItems))
|
||||
request.syncSetting.startTime = new Date(request.syncSetting.startTime).getTime()
|
||||
request.syncSetting.endTime = new Date(request.syncSetting.endTime).getTime()
|
||||
} else {
|
||||
@ -272,11 +275,16 @@ const validateDS = () => {
|
||||
validate(request).then(res => {
|
||||
if (res.data.type === 'API') {
|
||||
let error = 0
|
||||
const status = JSON.parse(res.data.status) as Array<{ status: string }>
|
||||
const status = JSON.parse(res.data.status) as Array<{ status: string; name: string }>
|
||||
for (let i = 0; i < status.length; i++) {
|
||||
if (status[i].status === 'Error') {
|
||||
error++
|
||||
}
|
||||
for (let j = 0; j < form.apiConfiguration.length; j++) {
|
||||
if (status[i].name === form.apiConfiguration[j].name) {
|
||||
form.apiConfiguration[j].status = status[i].status
|
||||
}
|
||||
}
|
||||
}
|
||||
if (error === 0) {
|
||||
ElMessage.success(t('datasource.validate_success'))
|
||||
|
@ -634,7 +634,7 @@ const handleEdit = async data => {
|
||||
}
|
||||
|
||||
const handleCopy = async data => {
|
||||
getById(nodeInfo.id).then(res => {
|
||||
getById(data.id).then(res => {
|
||||
let {
|
||||
name,
|
||||
createBy,
|
||||
|
Loading…
Reference in New Issue
Block a user