提交 08f0cd24 authored 作者: taojinlong's avatar taojinlong

feat: kettle 未运行时,禁用抽取数据

上级 1eb4d7f2
...@@ -4,6 +4,7 @@ import io.dataease.base.domain.DatasetGroup; ...@@ -4,6 +4,7 @@ import io.dataease.base.domain.DatasetGroup;
import io.dataease.controller.request.dataset.DataSetGroupRequest; import io.dataease.controller.request.dataset.DataSetGroupRequest;
import io.dataease.dto.dataset.DataSetGroupDTO; import io.dataease.dto.dataset.DataSetGroupDTO;
import io.dataease.service.dataset.DataSetGroupService; import io.dataease.service.dataset.DataSetGroupService;
import io.dataease.service.dataset.ExtractDataService;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -18,7 +19,8 @@ import java.util.List; ...@@ -18,7 +19,8 @@ import java.util.List;
public class DataSetGroupController { public class DataSetGroupController {
@Resource @Resource
private DataSetGroupService dataSetGroupService; private DataSetGroupService dataSetGroupService;
@Resource
private ExtractDataService extractDataService;
@PostMapping("/save") @PostMapping("/save")
public DataSetGroupDTO save(@RequestBody DatasetGroup datasetGroup) { public DataSetGroupDTO save(@RequestBody DatasetGroup datasetGroup) {
return dataSetGroupService.save(datasetGroup); return dataSetGroupService.save(datasetGroup);
...@@ -38,4 +40,9 @@ public class DataSetGroupController { ...@@ -38,4 +40,9 @@ public class DataSetGroupController {
public DatasetGroup getScene(@PathVariable String id) { public DatasetGroup getScene(@PathVariable String id) {
return dataSetGroupService.getScene(id); return dataSetGroupService.getScene(id);
} }
@PostMapping("/isKettleRunning")
public boolean isKettleRunning(){
return extractDataService.isKettleRunning();
}
} }
...@@ -23,9 +23,15 @@ import org.apache.commons.collections4.CollectionUtils; ...@@ -23,9 +23,15 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.pentaho.di.cluster.SlaveServer; import org.pentaho.di.cluster.SlaveServer;
import org.pentaho.di.core.database.DatabaseMeta; import org.pentaho.di.core.database.DatabaseMeta;
import org.pentaho.di.core.row.ValueMetaInterface; import org.pentaho.di.core.row.ValueMetaInterface;
import org.pentaho.di.core.util.HttpClientManager;
import org.pentaho.di.core.util.Utils;
import org.pentaho.di.job.Job; import org.pentaho.di.job.Job;
import org.pentaho.di.job.JobExecutionConfiguration; import org.pentaho.di.job.JobExecutionConfiguration;
import org.pentaho.di.job.JobHopMeta; import org.pentaho.di.job.JobHopMeta;
...@@ -54,7 +60,10 @@ import org.springframework.beans.factory.annotation.Value; ...@@ -54,7 +60,10 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.naming.AuthenticationException;
import java.io.File; import java.io.File;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
...@@ -529,6 +538,31 @@ public class ExtractDataService { ...@@ -529,6 +538,31 @@ public class ExtractDataService {
return userDefinedJavaClassStep; return userDefinedJavaClassStep;
} }
public boolean isKettleRunning(){
try {
if (InetAddress.getByName(carte).isReachable(1000)) {
HttpClient httpClient;
HttpGet getMethod = new HttpGet( "http://" + carte + ":" + port);
HttpClientManager.HttpClientBuilderFacade clientBuilder = HttpClientManager.getInstance().createBuilder();
clientBuilder.setConnectionTimeout(1);
clientBuilder.setCredentials(user, passwd);
httpClient = clientBuilder.build();
HttpResponse httpResponse = httpClient.execute( getMethod );
int statusCode = httpResponse.getStatusLine().getStatusCode();
if ( statusCode != -1 ) {
if ( statusCode == HttpStatus.SC_UNAUTHORIZED ) {
return false;
}
}
}else {
return false;
}
}catch (Exception e){
return false;
}
return false;
}
private static String code = "import org.pentaho.di.core.row.ValueMetaInterface;\n" + private static String code = "import org.pentaho.di.core.row.ValueMetaInterface;\n" +
"import java.util.List;\n" + "import java.util.List;\n" +
"import java.io.File;\n" + "import java.io.File;\n" +
......
...@@ -119,4 +119,12 @@ export function fieldValues(fieldId) { ...@@ -119,4 +119,12 @@ export function fieldValues(fieldId) {
}) })
} }
export function isKettleRunning() {
return request({
url: '/dataset/group/isKettleRunning',
method: 'post',
loading: true
})
}
export default { loadTable, getScene, addGroup, delGroup, addTable, delTable, groupTree } export default { loadTable, getScene, addGroup, delGroup, addTable, delTable, groupTree }
...@@ -811,7 +811,8 @@ export default { ...@@ -811,7 +811,8 @@ export default {
target_table: '被关联表', target_table: '被关联表',
target_field: '被关联字段', target_field: '被关联字段',
union_relation: '关联关系', union_relation: '关联关系',
pls_setting_union_success: '请正确设置关联关系' pls_setting_union_success: '请正确设置关联关系',
invalid_dataset:'Kettle未运行,无效数据集'
}, },
datasource: { datasource: {
datasource: '数据源', datasource: '数据源',
......
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
</el-form-item> </el-form-item>
<el-form-item class="form-item"> <el-form-item class="form-item">
<el-select v-model="mode" filterable :placeholder="$t('dataset.connect_mode')" size="mini"> <el-select v-model="mode" filterable :placeholder="$t('dataset.connect_mode')" size="mini">
<el-option :label="$t('dataset.direct_connect')" value="0" /> <el-option :label="$t('dataset.direct_connect')" value="0" />
<el-option :label="$t('dataset.sync_data')" value="1" /> <el-option :label="$t('dataset.sync_data')" value="1" :disabled="!isKettleRunning"/>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item class="form-item" style="float: right;"> <el-form-item class="form-item" style="float: right;">
...@@ -66,6 +66,10 @@ export default { ...@@ -66,6 +66,10 @@ export default {
param: { param: {
type: Object, type: Object,
default: null default: null
},
isKettleRunning: {
type: Boolean,
default: false
} }
}, },
data() { data() {
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
<el-form-item class="form-item"> <el-form-item class="form-item">
<el-select v-model="mode" filterable :placeholder="$t('dataset.connect_mode')" size="mini"> <el-select v-model="mode" filterable :placeholder="$t('dataset.connect_mode')" size="mini">
<el-option :label="$t('dataset.direct_connect')" value="0" /> <el-option :label="$t('dataset.direct_connect')" value="0" />
<el-option :label="$t('dataset.sync_data')" value="1" /> <el-option :label="$t('dataset.sync_data')" value="1" :disabled="!isKettleRunning" />
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-form> </el-form>
...@@ -121,6 +121,10 @@ export default { ...@@ -121,6 +121,10 @@ export default {
param: { param: {
type: Object, type: Object,
required: true required: true
},
isKettleRunning: {
type: Boolean,
default: false
} }
}, },
data() { data() {
......
...@@ -103,12 +103,13 @@ ...@@ -103,12 +103,13 @@
</template> </template>
<script> <script>
import { post } from '@/api/dataset/dataset' import {isKettleRunning, post} from '@/api/dataset/dataset'
export default { export default {
name: 'DatasetGroupSelector', name: 'DatasetGroupSelector',
data() { data() {
return { return {
isKettleRunning: false,
sceneMode: false, sceneMode: false,
search: '', search: '',
data: [], data: [],
...@@ -132,10 +133,6 @@ export default { ...@@ -132,10 +133,6 @@ export default {
}, },
computed: {}, computed: {},
watch: { watch: {
// search(val){
// this.groupForm.name = val;
// this.tree(this.groupForm);
// }
search(val) { search(val) {
if (val && val !== '') { if (val && val !== '') {
this.tableData = JSON.parse(JSON.stringify(this.tables.filter(ele => { return ele.name.includes(val) }))) this.tableData = JSON.parse(JSON.stringify(this.tables.filter(ele => { return ele.name.includes(val) })))
...@@ -152,7 +149,15 @@ export default { ...@@ -152,7 +149,15 @@ export default {
this.tree(this.groupForm) this.tree(this.groupForm)
this.tableTree() this.tableTree()
}, },
created(){
this.kettleRunning()
},
methods: { methods: {
kettleRunning(){
isKettleRunning().then(res => {
this.isKettleRunning = res.data
})
},
close() { close() {
this.editGroup = false this.editGroup = false
this.groupForm = { this.groupForm = {
...@@ -186,14 +191,17 @@ export default { ...@@ -186,14 +191,17 @@ export default {
sceneId: this.currGroup.id sceneId: this.currGroup.id
}).then(response => { }).then(response => {
this.tables = response.data this.tables = response.data
for (let i = 0; i < this.tables.length; i++) {
if(this.tables[i].mode===1 && this.isKettleRunning === false){
this.$set(this.tables[i],"disabled",true)
}
}
this.tableData = JSON.parse(JSON.stringify(this.tables)) this.tableData = JSON.parse(JSON.stringify(this.tables))
}) })
} }
}, },
nodeClick(data, node) { nodeClick(data, node) {
// console.log(data);
// console.log(node);
if (data.type === 'scene') { if (data.type === 'scene') {
this.sceneMode = true this.sceneMode = true
this.currGroup = data this.currGroup = data
...@@ -215,7 +223,14 @@ export default { ...@@ -215,7 +223,14 @@ export default {
}, },
sceneClick(data, node) { sceneClick(data, node) {
// console.log(data); if(data.disabled){
this.$message({
type: 'warning',
message: this.$t('dataset.invalid_dataset'),
showClose: true
})
return
}
this.$emit('getTable', data) this.$emit('getTable', data)
} }
} }
......
...@@ -242,7 +242,7 @@ ...@@ -242,7 +242,7 @@
</template> </template>
<script> <script>
import { loadTable, getScene, addGroup, delGroup, addTable, delTable, groupTree } from '@/api/dataset/dataset' import { loadTable, getScene, addGroup, delGroup, addTable, delTable, groupTree, isKettleRunning} from '@/api/dataset/dataset'
export default { export default {
name: 'Group', name: 'Group',
...@@ -288,16 +288,11 @@ export default { ...@@ -288,16 +288,11 @@ export default {
}, },
computed: { computed: {
sceneData: function() { sceneData: function() {
console.log(this.$store.state.dataset.sceneData + ' do post')
this.tableTree() this.tableTree()
return this.$store.state.dataset.sceneData return this.$store.state.dataset.sceneData
} }
}, },
watch: { watch: {
// search(val){
// this.groupForm.name = val;
// this.tree(this.groupForm);
// }
search(val) { search(val) {
if (val && val !== '') { if (val && val !== '') {
this.tableData = JSON.parse(JSON.stringify(this.tables.filter(ele => { return ele.name.includes(val) }))) this.tableData = JSON.parse(JSON.stringify(this.tables.filter(ele => { return ele.name.includes(val) })))
...@@ -310,9 +305,16 @@ export default { ...@@ -310,9 +305,16 @@ export default {
this.tree(this.groupForm) this.tree(this.groupForm)
this.refresh() this.refresh()
this.tableTree() this.tableTree()
// this.$router.push('/dataset'); },
created(){
this.kettleRunning()
}, },
methods: { methods: {
kettleRunning(){
isKettleRunning().then(res => {
this.isKettleRunning = res.data
})
},
clickAdd(param) { clickAdd(param) {
// console.log(param); // console.log(param);
this.add(param.type) this.add(param.type)
...@@ -552,7 +554,7 @@ export default { ...@@ -552,7 +554,7 @@ export default {
}, },
addData(name) { addData(name) {
this.$emit('switchComponent', { name: name, param: this.currGroup }) this.$emit('switchComponent', { name: name, param: this.currGroup, isKettleRunning: this.isKettleRunning})
}, },
sceneClick(data, node) { sceneClick(data, node) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论