Merge remote-tracking branch 'origin/main' into main

This commit is contained in:
wangjiahao 2021-06-02 17:45:49 +08:00
commit 974d7549f6
20 changed files with 87 additions and 55 deletions

View File

@ -6,16 +6,9 @@ import org.quartz.impl.triggers.CronTriggerImpl;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
@Component
public class ScheduleManager {

View File

@ -7,5 +7,7 @@ package io.dataease.provider;
public abstract class DDLProvider {
public abstract String createView(String name, String viewSQL);
public abstract String dropTableOrView(String name);
public abstract String dropTable(String name);
public abstract String dropView(String name);
}

View File

@ -15,7 +15,12 @@ public class DorisDDLProvider extends DDLProvider {
}
@Override
public String dropTableOrView(String name) {
public String dropTable(String name) {
return "DROP TABLE IF EXISTS " + name;
}
@Override
public String dropView(String name) {
return "DROP VIEW IF EXISTS " + name;
}
}

View File

@ -15,7 +15,12 @@ public class MysqlDDLProvider extends DDLProvider {
}
@Override
public String dropTableOrView(String name) {
public String dropTable(String name) {
return "DROP TABLE IF EXISTS " + name;
}
@Override
public String dropView(String name) {
return "DROP VIEW IF EXISTS " + name;
}
}

View File

@ -34,9 +34,9 @@ public class ScheduleService {
endTime = null;
} else {
endTime = new Date(datasetTableTask.getEndTime());
if (endTime.before(new Date())) {
return;
}
// if (endTime.before(new Date())) {
// return;
// }
}
scheduleManager.addOrUpdateCronJob(new JobKey(datasetTableTask.getId(), datasetTableTask.getTableId()),

View File

@ -127,28 +127,36 @@ public class DataSetTableService {
}
public void delete(String id) throws Exception {
DatasetTable table = datasetTableMapper.selectByPrimaryKey(id);
datasetTableMapper.deleteByPrimaryKey(id);
dataSetTableFieldsService.deleteByTableId(id);
// 删除同步任务
dataSetTableTaskService.deleteByTableId(id);
try {
deleteDorisTable(id);
deleteDorisTable(id, table);
} catch (Exception e) {
}
}
private void deleteDorisTable(String datasetId) throws Exception {
private void deleteDorisTable(String datasetId, DatasetTable table) throws Exception {
String dorisTableName = DorisTableUtils.dorisName(datasetId);
Datasource dorisDatasource = (Datasource) CommonBeanFactory.getBean("DorisDatasource");
JdbcProvider jdbcProvider = CommonBeanFactory.getBean(JdbcProvider.class);
DatasourceRequest datasourceRequest = new DatasourceRequest();
datasourceRequest.setDatasource(dorisDatasource);
DDLProvider ddlProvider = ProviderFactory.getDDLProvider(dorisDatasource.getType());
datasourceRequest.setQuery(ddlProvider.dropTableOrView(dorisTableName));
jdbcProvider.exec(datasourceRequest);
datasourceRequest.setQuery(ddlProvider.dropTableOrView(DorisTableUtils.dorisTmpName(dorisTableName)));
jdbcProvider.exec(datasourceRequest);
if (StringUtils.equalsIgnoreCase("custom", table.getType())) {
datasourceRequest.setQuery(ddlProvider.dropView(dorisTableName));
jdbcProvider.exec(datasourceRequest);
datasourceRequest.setQuery(ddlProvider.dropView(DorisTableUtils.dorisTmpName(dorisTableName)));
jdbcProvider.exec(datasourceRequest);
} else {
datasourceRequest.setQuery(ddlProvider.dropTable(dorisTableName));
jdbcProvider.exec(datasourceRequest);
datasourceRequest.setQuery(ddlProvider.dropTable(DorisTableUtils.dorisTmpName(dorisTableName)));
jdbcProvider.exec(datasourceRequest);
}
}
public List<DataSetTableDTO> list(DataSetTableRequest dataSetTableRequest) {
@ -351,6 +359,9 @@ public class DataSetTableService {
datasourceRequest.setDatasource(ds);
String sql = new Gson().fromJson(dataSetTableRequest.getInfo(), DataTableInfoDTO.class).getSql();
// 使用输入的sql先预执行一次,并拿到所有字段
if(StringUtils.isEmpty(sql)){
throw new Exception(Translator.get("i18n_sql_not_empty"));
}
datasourceRequest.setQuery(sql);
List<TableFiled> previewFields = datasourceProvider.fetchResultField(datasourceRequest);
// 正式执行
@ -567,7 +578,7 @@ public class DataSetTableService {
datasourceRequest.setDatasource(dorisDatasource);
DDLProvider ddlProvider = ProviderFactory.getDDLProvider(dorisDatasource.getType());
// 先删除表
datasourceRequest.setQuery(ddlProvider.dropTableOrView(dorisTableName));
datasourceRequest.setQuery(ddlProvider.dropView(dorisTableName));
jdbcProvider.exec(datasourceRequest);
datasourceRequest.setQuery(ddlProvider.createView(dorisTableName, customSql));
jdbcProvider.exec(datasourceRequest);
@ -702,9 +713,9 @@ public class DataSetTableService {
tableFiled.setFieldName(columnName);
tableFiled.setRemarks(columnName);
fields.add(tableFiled);
} else if (i == 1){
} else if (i == 1) {
r[j] = readCell(row.getCell(j), true, fields.get(j));
}else {
} else {
r[j] = readCell(row.getCell(j), false, null);
}
}
@ -735,16 +746,16 @@ public class DataSetTableService {
TableFiled tableFiled = new TableFiled();
tableFiled.setFieldType("TEXT");
tableFiled.setFieldSize(1024);
String columnName = readCell(row.getCell(j),false, null);
String columnName = readCell(row.getCell(j), false, null);
if (StringUtils.isEmpty(columnName)) {
columnName = "NONE_" + String.valueOf(j);
}
tableFiled.setFieldName(columnName);
tableFiled.setRemarks(columnName);
fields.add(tableFiled);
} else if (i == 1){
} else if (i == 1) {
r[j] = readCell(row.getCell(j), true, fields.get(j));
}else {
} else {
r[j] = readCell(row.getCell(j), false, null);
}
}
@ -798,28 +809,36 @@ public class DataSetTableService {
private String readCell(Cell cell, boolean cellType, TableFiled tableFiled) {
CellType cellTypeEnum = cell.getCellTypeEnum();
if (cellTypeEnum.equals(CellType.STRING)) {
if(cellType){ tableFiled.setFieldType("TEXT"); }
if (cellType) {
tableFiled.setFieldType("TEXT");
}
return cell.getStringCellValue();
}
if (cellTypeEnum.equals(CellType.NUMERIC)) {
if(HSSFDateUtil.isCellDateFormatted(cell)){
if(cellType) { tableFiled.setFieldType("DATETIME"); }
if (HSSFDateUtil.isCellDateFormatted(cell)) {
if (cellType) {
tableFiled.setFieldType("DATETIME");
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
return sdf.format(cell.getDateCellValue());
}catch (Exception e){
} catch (Exception e) {
return "";
}
}else {
} else {
double d = cell.getNumericCellValue();
try {
Double value = new Double(d);
double eps = 1e-10;
if(value - Math.floor(value) < eps){
if(cellType) { tableFiled.setFieldType("LONG"); }
if (value - Math.floor(value) < eps) {
if (cellType) {
tableFiled.setFieldType("LONG");
}
return value.longValue() + "";
}else {
if(cellType){ tableFiled.setFieldType("DOUBLE");}
} else {
if (cellType) {
tableFiled.setFieldType("DOUBLE");
}
NumberFormat nf = NumberFormat.getInstance();
nf.setGroupingUsed(false);
return nf.format(value);

View File

@ -244,4 +244,5 @@ i18n_username_exists=ID is already exists
i18n_ds_name_exists=Datasource name exists
i18n_sync_job_exists=There is already a synchronization task running, please try again later
i18n_datasource_check_fail=Invalid,please check config
i18n_not_find_user=Can not find user.
i18n_not_find_user=Can not find user.
i18n_sql_not_empty=SQL can not be empty.

View File

@ -246,4 +246,5 @@ i18n_username_exists=用户 ID 已存在
i18n_ds_name_exists=数据源名称已存在
i18n_sync_job_exists=已经有同步任务在运行,稍后重试
i18n_datasource_check_fail=校验失败,请检查配置信息
i18n_not_find_user=未找到用户
i18n_not_find_user=未找到用户
i18n_sql_not_empty=SQL 不能为空

View File

@ -246,4 +246,5 @@ i18n_username_exists=用戶ID已存在
i18n_ds_name_exists=數據源名稱已存在
i18n_sync_job_exists=已經有同步任務在運行,稍後重試
i18n_datasource_check_fail=校驗失敗,請檢查配置信息
i18n_not_find_user=未找到用戶
i18n_not_find_user=未找到用戶
i18n_sql_not_empty=SQL 不能為空

View File

@ -85,10 +85,10 @@ export function getPreviewData(data) {
})
}
export function fieldList(id) {
export function fieldList(id, showLoading = true) {
return request({
url: '/dataset/field/list/' + id,
loading: true,
loading: showLoading,
method: 'post'
})
}
@ -102,11 +102,11 @@ export function batchEdit(data) {
})
}
export function post(url, data) {
export function post(url, data, showLoading = true) {
return request({
url: url,
method: 'post',
loading: true,
loading: showLoading,
data
})
}

View File

@ -153,7 +153,7 @@ export default {
}
</script>
<style lang="css">
<style lang="css" scoped>
.el-checkbox+.el-checkbox {
margin-left: 10px;
}

View File

@ -135,7 +135,7 @@ export default {
}
</script>
<style lang="css">
<style lang="css" scoped>
.el-checkbox+.el-checkbox {
margin-left: 10px;
}

View File

@ -136,7 +136,7 @@ export default {
}
</script>
<style lang="css">
<style lang="css" scoped>
.el-checkbox+.el-checkbox {
margin-left: 10px;
}

View File

@ -139,7 +139,7 @@ export default {
}
</script>
<style lang="css">
<style lang="css" scoped>
.el-checkbox+.el-checkbox {
margin-left: 10px;
}

View File

@ -150,7 +150,7 @@ export default {
}
</script>
<style lang="css">
<style lang="css" scoped>
.el-checkbox+.el-checkbox {
margin-left: 10px;
}

View File

@ -123,7 +123,7 @@ export default {
}
</script>
<style lang="css">
<style lang="css" scoped>
.el-checkbox+.el-checkbox {
margin-left: 10px;
}

View File

@ -161,7 +161,7 @@ export default {
},
'table': function() {
if (this.table && this.table.sceneId) {
post('dataset/group/getScene/' + this.table.sceneId, {}).then(response => {
post('dataset/group/getScene/' + this.table.sceneId, {}, false).then(response => {
this.currGroup = response.data
this.$nextTick(function() {
@ -213,7 +213,7 @@ export default {
tree(group) {
this.dsLoading = true
post('/dataset/group/tree', group).then(response => {
post('/dataset/group/tree', group, false).then(response => {
this.data = response.data
this.dsLoading = false
})
@ -227,7 +227,7 @@ export default {
sort: 'type asc,create_time desc,name asc',
sceneId: this.currGroup.id,
mode: this.mode < 0 ? null : this.mode
}).then(response => {
}, false).then(response => {
this.tables = response.data
for (let i = 0; i < this.tables.length; i++) {
if (this.tables[i].mode === 1 && this.kettleRunning === false) {
@ -278,7 +278,7 @@ export default {
}
// check mode=1doris
if (data.mode === 1) {
post('/dataset/table/checkDorisTableIsExists/' + data.id, {}).then(response => {
post('/dataset/table/checkDorisTableIsExists/' + data.id, {}, false).then(response => {
if (response.data) {
this.$nextTick(function() {
this.$emit('getTable', data)

View File

@ -67,7 +67,7 @@ export default {
if (this.table.id) {
this.dataLoading = true
this.table.row = 100
post('/dataset/table/getPreviewData/1/100', this.table).then(response => {
post('/dataset/table/getPreviewData/1/100', this.table, false).then(response => {
this.fields = response.data.fields
this.data = response.data.data
const datas = this.data

View File

@ -2,7 +2,7 @@
<layout-content :header="formType=='add' ? $t('user.create') : $t('user.modify')" back-name="system-user">
<el-form ref="createUserForm" :model="form" :rules="rule" size="small" label-width="auto" label-position="right">
<el-form-item label="ID" prop="username">
<el-input v-model="form.username" />
<el-input v-model="form.username" :disabled="formType !== 'add'" />
</el-form-item>
<el-form-item :label="$t('commons.phone')" prop="phone">
<el-input v-model="form.phone" />
@ -27,7 +27,7 @@
</el-radio-group>
</el-form-item>
<el-form-item :label="$t('commons.status')">
<el-radio-group v-model="form.enabled" style="width: 140px">
<el-radio-group v-model="form.enabled" :disabled="formType !== 'add' && form.isAdmin" style="width: 140px">
<el-radio :label="1">{{ $t('commons.enable') }}</el-radio>
<el-radio :label="0">{{ $t('commons.disable') }}</el-radio>
</el-radio-group>
@ -47,6 +47,7 @@
<el-select
v-model="form.roleIds"
style="width: 100%"
:disabled="formType !== 'add' && form.isAdmin"
multiple
:placeholder="$t('commons.please_select')"
@remove-tag="deleteTag"

View File

@ -187,6 +187,7 @@ export default {
show: this.checkPermission(['user:edit'])
}, {
label: this.$t('commons.delete'), icon: 'el-icon-delete', type: 'danger', click: this.del,
disabled: this.btnDisabled,
show: this.checkPermission(['user:del'])
}, {
label: this.$t('member.edit_password'), icon: 'el-icon-s-tools', type: 'success', click: this.editPassword,
@ -489,6 +490,9 @@ export default {
allRoles().then(res => {
this.roles = res.data
})
},
btnDisabled(row) {
return row.userId === 1
}
}
}