forked from github/dataease
Merge pull request #719 from dataease/pr@dev@feat_ds_invalid_msg
feat: 完善数据源失效消息
This commit is contained in:
commit
2ff07ba064
@ -7,6 +7,7 @@ import io.dataease.base.mapper.*;
|
|||||||
import io.dataease.base.mapper.ext.ExtDataSourceMapper;
|
import io.dataease.base.mapper.ext.ExtDataSourceMapper;
|
||||||
import io.dataease.base.mapper.ext.query.GridExample;
|
import io.dataease.base.mapper.ext.query.GridExample;
|
||||||
import io.dataease.commons.exception.DEException;
|
import io.dataease.commons.exception.DEException;
|
||||||
|
import io.dataease.commons.model.AuthURD;
|
||||||
import io.dataease.commons.utils.AuthUtils;
|
import io.dataease.commons.utils.AuthUtils;
|
||||||
import io.dataease.commons.utils.CommonThreadPool;
|
import io.dataease.commons.utils.CommonThreadPool;
|
||||||
import io.dataease.commons.utils.LogUtil;
|
import io.dataease.commons.utils.LogUtil;
|
||||||
@ -25,6 +26,8 @@ import io.dataease.dto.dataset.DataTableInfoDTO;
|
|||||||
import io.dataease.exception.DataEaseException;
|
import io.dataease.exception.DataEaseException;
|
||||||
import io.dataease.i18n.Translator;
|
import io.dataease.i18n.Translator;
|
||||||
import io.dataease.service.dataset.DataSetGroupService;
|
import io.dataease.service.dataset.DataSetGroupService;
|
||||||
|
import io.dataease.service.message.DeMsgutil;
|
||||||
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@ -34,7 +37,10 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@ -238,7 +244,8 @@ public class DatasourceService {
|
|||||||
public void updateDatasourceStatus(){
|
public void updateDatasourceStatus(){
|
||||||
List<Datasource> datasources = datasourceMapper.selectByExampleWithBLOBs(new DatasourceExample());
|
List<Datasource> datasources = datasourceMapper.selectByExampleWithBLOBs(new DatasourceExample());
|
||||||
datasources.forEach(datasource -> {
|
datasources.forEach(datasource -> {
|
||||||
checkAndUpdateDatasourceStatus(datasource);
|
// checkAndUpdateDatasourceStatus(datasource);
|
||||||
|
checkAndUpdateDatasourceStatus(datasource, true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,4 +262,43 @@ public class DatasourceService {
|
|||||||
datasourceMapper.updateByPrimaryKeySelective(datasource);
|
datasourceMapper.updateByPrimaryKeySelective(datasource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkAndUpdateDatasourceStatus(Datasource datasource, Boolean withMsg){
|
||||||
|
try {
|
||||||
|
DatasourceProvider datasourceProvider = ProviderFactory.getProvider(datasource.getType());
|
||||||
|
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||||
|
datasourceRequest.setDatasource(datasource);
|
||||||
|
datasourceProvider.checkStatus(datasourceRequest);
|
||||||
|
datasource.setStatus("Success");
|
||||||
|
datasourceMapper.updateByPrimaryKeySelective(datasource);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Datasource temp = datasourceMapper.selectByPrimaryKey(datasource.getId());
|
||||||
|
datasource.setStatus("Error");
|
||||||
|
if (!StringUtils.equals(temp.getStatus(), "Error")) {
|
||||||
|
sendWebMsg(datasource);
|
||||||
|
datasourceMapper.updateByPrimaryKeySelective(datasource);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void sendWebMsg(Datasource datasource) {
|
||||||
|
|
||||||
|
String id = datasource.getId();
|
||||||
|
AuthURD authURD = AuthUtils.authURDR(id);
|
||||||
|
Set<Long> userIds = AuthUtils.userIdsByURD(authURD);
|
||||||
|
Long typeId = 8L;// 代表数据源失效
|
||||||
|
Gson gson = new Gson();
|
||||||
|
userIds.forEach(userId -> {
|
||||||
|
Map<String, Object> param = new HashMap<>();
|
||||||
|
param.put("id", id);
|
||||||
|
param.put("name", datasource.getName());
|
||||||
|
|
||||||
|
|
||||||
|
String content = "数据源【" + datasource.getName() + "】无效";
|
||||||
|
|
||||||
|
DeMsgutil.sendMsg(userId, typeId, 1L, content, gson.toJson(param));
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
7
backend/src/main/resources/db/migration/V26__de1.3.sql
Normal file
7
backend/src/main/resources/db/migration/V26__de1.3.sql
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
-- ----------------------------
|
||||||
|
-- Records of sys_msg_type
|
||||||
|
-- ----------------------------
|
||||||
|
BEGIN;
|
||||||
|
INSERT INTO `sys_msg_type` VALUES (7, 0, 'i18n_msg_type_ds_invalid', 'datasource', 'to-msg-ds');
|
||||||
|
INSERT INTO `sys_msg_type` VALUES (8, 7, 'i18n_msg_type_ds_invalid', 'datasource', 'to-msg-ds');
|
||||||
|
COMMIT;
|
@ -1361,6 +1361,7 @@ export default {
|
|||||||
i18n_msg_type_dataset_sync_success: 'Dataset synchronization successful',
|
i18n_msg_type_dataset_sync_success: 'Dataset synchronization successful',
|
||||||
i18n_msg_type_dataset_sync_faild: 'Dataset synchronization failed',
|
i18n_msg_type_dataset_sync_faild: 'Dataset synchronization failed',
|
||||||
i18n_msg_type_all: 'All type',
|
i18n_msg_type_all: 'All type',
|
||||||
|
i18n_msg_type_ds_invalid: 'Datasource invalid',
|
||||||
channel_inner_msg: 'On site news'
|
channel_inner_msg: 'On site news'
|
||||||
},
|
},
|
||||||
denumberrange: {
|
denumberrange: {
|
||||||
|
@ -1359,6 +1359,7 @@ export default {
|
|||||||
i18n_msg_type_dataset_sync: '數據集同步',
|
i18n_msg_type_dataset_sync: '數據集同步',
|
||||||
i18n_msg_type_dataset_sync_success: '數據集同步成功',
|
i18n_msg_type_dataset_sync_success: '數據集同步成功',
|
||||||
i18n_msg_type_dataset_sync_faild: '數據集同步失敗',
|
i18n_msg_type_dataset_sync_faild: '數據集同步失敗',
|
||||||
|
i18n_msg_type_ds_invalid: '數據源失效',
|
||||||
i18n_msg_type_all: '全部類型',
|
i18n_msg_type_all: '全部類型',
|
||||||
channel_inner_msg: '站內消息'
|
channel_inner_msg: '站內消息'
|
||||||
},
|
},
|
||||||
|
@ -1362,6 +1362,7 @@ export default {
|
|||||||
i18n_msg_type_dataset_sync: '数据集同步',
|
i18n_msg_type_dataset_sync: '数据集同步',
|
||||||
i18n_msg_type_dataset_sync_success: '数据集同步成功',
|
i18n_msg_type_dataset_sync_success: '数据集同步成功',
|
||||||
i18n_msg_type_dataset_sync_faild: '数据集同步失败',
|
i18n_msg_type_dataset_sync_faild: '数据集同步失败',
|
||||||
|
i18n_msg_type_ds_invalid: '数据源失效',
|
||||||
i18n_msg_type_all: '全部类型',
|
i18n_msg_type_all: '全部类型',
|
||||||
channel_inner_msg: '站内消息'
|
channel_inner_msg: '站内消息'
|
||||||
},
|
},
|
||||||
|
@ -55,6 +55,9 @@ export default {
|
|||||||
},
|
},
|
||||||
refreshTree() {
|
refreshTree() {
|
||||||
this.$refs.dsTree && this.$refs.dsTree.queryTreeDatas()
|
this.$refs.dsTree && this.$refs.dsTree.queryTreeDatas()
|
||||||
|
},
|
||||||
|
msg2Current(sourceParam) {
|
||||||
|
this.$refs.dsTree && this.$refs.dsTree.markInvalid(sourceParam)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,11 +41,11 @@
|
|||||||
<svg-icon icon-class="datasource" class="ds-icon-scene" />
|
<svg-icon icon-class="datasource" class="ds-icon-scene" />
|
||||||
</span>
|
</span>
|
||||||
<span v-if="data.status === 'Error'">
|
<span v-if="data.status === 'Error'">
|
||||||
<svg-icon icon-class="exclamationmark" class="ds-icon-scene" />
|
<svg-icon icon-class="exclamationmark" class="ds-icon-scene" />
|
||||||
<el-tooltip v-if="data.status === 'Error'" style="margin-left: 6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;" effect="dark" :content="$t('datasource.in_valid')" placement="right">
|
<el-tooltip v-if="data.status === 'Error'" style="margin-left: 6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;" effect="dark" :content="$t('datasource.in_valid')" placement="right">
|
||||||
<el-button type="text" > {{ data.name }} </el-button>
|
<el-button type="text" :style="!!data.msgNode ? {'color': 'red'} : {}"> {{ data.name }} </el-button>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</span>
|
</span>
|
||||||
<span v-if="data.type === 'folder'">
|
<span v-if="data.type === 'folder'">
|
||||||
<i class="el-icon-folder" />
|
<i class="el-icon-folder" />
|
||||||
</span>
|
</span>
|
||||||
@ -129,6 +129,11 @@ export default {
|
|||||||
const newArr = []
|
const newArr = []
|
||||||
for (let index = 0; index < array.length; index++) {
|
for (let index = 0; index < array.length; index++) {
|
||||||
const element = array[index]
|
const element = array[index]
|
||||||
|
if (this.msgNodeId) {
|
||||||
|
if (element.id === this.msgNodeId) {
|
||||||
|
element.msgNode = true
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!(element.type in types)) {
|
if (!(element.type in types)) {
|
||||||
types[element.type] = []
|
types[element.type] = []
|
||||||
// newArr.push(...element, ...{ children: types[element.type] })
|
// newArr.push(...element, ...{ children: types[element.type] })
|
||||||
@ -147,7 +152,7 @@ export default {
|
|||||||
return 'SQL Server'
|
return 'SQL Server'
|
||||||
} else if (type === 'oracle') {
|
} else if (type === 'oracle') {
|
||||||
return 'Oracle'
|
return 'Oracle'
|
||||||
}else if (type === 'pg') {
|
} else if (type === 'pg') {
|
||||||
return 'PostgreSQL'
|
return 'PostgreSQL'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -208,6 +213,21 @@ export default {
|
|||||||
component,
|
component,
|
||||||
componentParam
|
componentParam
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
markInvalid(msgParam) {
|
||||||
|
const param = JSON.parse(msgParam)
|
||||||
|
const msgNodeId = param.id
|
||||||
|
this.msgNodeId = msgNodeId
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.tData.forEach(folder => {
|
||||||
|
const nodes = folder.children
|
||||||
|
nodes.forEach(node => {
|
||||||
|
if (node.id === msgNodeId) {
|
||||||
|
node.msgNode = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -303,4 +323,10 @@ export default {
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
.msg-node-class {
|
||||||
|
color: red;
|
||||||
|
>>> i{
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<de-container v-loading="$store.getters.loadingMap[$store.getters.currentPath]" style="background-color: #f7f8fa">
|
<de-container v-loading="$store.getters.loadingMap[$store.getters.currentPath]" style="background-color: #f7f8fa">
|
||||||
<de-main-container>
|
<de-main-container>
|
||||||
<ds-main />
|
<ds-main ref="dsMain" />
|
||||||
</de-main-container>
|
</de-main-container>
|
||||||
</de-container>
|
</de-container>
|
||||||
</template>
|
</template>
|
||||||
@ -10,7 +10,7 @@
|
|||||||
import DeMainContainer from '@/components/dataease/DeMainContainer'
|
import DeMainContainer from '@/components/dataease/DeMainContainer'
|
||||||
import DeContainer from '@/components/dataease/DeContainer'
|
import DeContainer from '@/components/dataease/DeContainer'
|
||||||
import DsMain from './DsMain'
|
import DsMain from './DsMain'
|
||||||
|
import bus from '@/utils/bus'
|
||||||
export default {
|
export default {
|
||||||
name: 'Panel',
|
name: 'Panel',
|
||||||
components: { DeMainContainer, DeContainer, DsMain },
|
components: { DeMainContainer, DeContainer, DsMain },
|
||||||
@ -22,10 +22,36 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
bus.$on('to-msg-ds', params => {
|
||||||
|
this.toMsgDs(params)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.$store.dispatch('app/toggleSideBarHide', true)
|
||||||
|
const routerParam = this.$router.currentRoute.params
|
||||||
|
this.toMsgDs(routerParam)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
toMsgDs(routerParam) {
|
||||||
|
if (routerParam !== null && routerParam.msgNotification) {
|
||||||
|
const panelShareTypeIds = [7, 8]
|
||||||
|
// 说明是从消息通知跳转过来的
|
||||||
|
if (panelShareTypeIds.includes(routerParam.msgType)) { // 是数据集同步
|
||||||
|
if (routerParam.sourceParam) {
|
||||||
|
try {
|
||||||
|
// const msgParam = JSON.parse(routerParam.sourceParam)
|
||||||
|
// this.param = msgParam.id
|
||||||
|
// this.component = ViewTable
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.dsMain && this.$refs.dsMain.msg2Current && this.$refs.dsMain.msg2Current(routerParam.sourceParam)
|
||||||
|
})
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user