From 9d386d432430fd641dc2a845350f46df8f786726 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Sat, 2 Apr 2022 22:02:58 +0800 Subject: [PATCH 1/9] =?UTF-8?q?fix:=20=E6=94=AF=E6=8C=81=20es8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/dataease/provider/datasource/EsProvider.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backend/src/main/java/io/dataease/provider/datasource/EsProvider.java b/backend/src/main/java/io/dataease/provider/datasource/EsProvider.java index 077c25c5d9..de1595045e 100644 --- a/backend/src/main/java/io/dataease/provider/datasource/EsProvider.java +++ b/backend/src/main/java/io/dataease/provider/datasource/EsProvider.java @@ -239,6 +239,11 @@ public class EsProvider extends DatasourceProvider { tableDesc.setName(row[0]); tables.add(tableDesc); } + if (row.length == 4 && row[2].contains("TABLE") && row[3].equalsIgnoreCase("INDEX")) { + TableDesc tableDesc = new TableDesc(); + tableDesc.setName(row[1]); + tables.add(tableDesc); + } } return tables; } From 7efd82b6e57bf032be28dd805e6085e9ce1ffcef Mon Sep 17 00:00:00 2001 From: taojinlong Date: Sat, 2 Apr 2022 22:20:46 +0800 Subject: [PATCH 2/9] =?UTF-8?q?fix:=20=E9=BB=98=E8=AE=A4=E6=8E=88=E6=9D=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/dataease/service/dataset/DataSetTableService.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java index f4ae1d03d2..53e30ce5d4 100644 --- a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java +++ b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java @@ -172,6 +172,7 @@ public class DataSetTableService { DataTableInfoDTO info = new DataTableInfoDTO(); info.setExcelSheetDataList(excelSheetDataList); sheetTable.setInfo(new Gson().toJson(info)); + sysAuthService.copyAuth(datasetTable.getId(), SysAuthConstants.AUTH_SOURCE_TYPE_DATASET); datasetTableMapper.insert(sheetTable); saveExcelTableField(sheetTable.getId(), excelSheetDataList.get(0).getFields(), true); datasetIdList.add(sheetTable.getId()); @@ -202,6 +203,7 @@ public class DataSetTableService { info.setExcelSheetDataList(excelSheetDataList); sheetTable.setInfo(new Gson().toJson(info)); datasetTableMapper.insert(sheetTable); + sysAuthService.copyAuth(datasetTable.getId(), SysAuthConstants.AUTH_SOURCE_TYPE_DATASET); saveExcelTableField(sheetTable.getId(), sheet.getFields(), true); datasetIdList.add(sheetTable.getId()); } From 9b48e7a2a40473952b08836acb03a8bfaa8ca3e0 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Sat, 2 Apr 2022 23:03:20 +0800 Subject: [PATCH 3/9] =?UTF-8?q?fix:=20=E9=BB=98=E8=AE=A4=E6=8E=88=E6=9D=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/dataease/service/dataset/DataSetTableService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java index 53e30ce5d4..21eb7aa271 100644 --- a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java +++ b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java @@ -172,8 +172,8 @@ public class DataSetTableService { DataTableInfoDTO info = new DataTableInfoDTO(); info.setExcelSheetDataList(excelSheetDataList); sheetTable.setInfo(new Gson().toJson(info)); - sysAuthService.copyAuth(datasetTable.getId(), SysAuthConstants.AUTH_SOURCE_TYPE_DATASET); datasetTableMapper.insert(sheetTable); + sysAuthService.copyAuth(sheetTable.getId(), SysAuthConstants.AUTH_SOURCE_TYPE_DATASET); saveExcelTableField(sheetTable.getId(), excelSheetDataList.get(0).getFields(), true); datasetIdList.add(sheetTable.getId()); } @@ -203,7 +203,7 @@ public class DataSetTableService { info.setExcelSheetDataList(excelSheetDataList); sheetTable.setInfo(new Gson().toJson(info)); datasetTableMapper.insert(sheetTable); - sysAuthService.copyAuth(datasetTable.getId(), SysAuthConstants.AUTH_SOURCE_TYPE_DATASET); + sysAuthService.copyAuth(sheetTable.getId(), SysAuthConstants.AUTH_SOURCE_TYPE_DATASET); saveExcelTableField(sheetTable.getId(), sheet.getFields(), true); datasetIdList.add(sheetTable.getId()); } From ed325a863a6193955795644c8f79dc3218631fed Mon Sep 17 00:00:00 2001 From: taojinlong Date: Sun, 3 Apr 2022 19:34:48 +0800 Subject: [PATCH 4/9] =?UTF-8?q?fix:=20=E6=9B=BF=E6=8D=A2excel=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E5=88=87=E6=8D=A2tab=20=E5=88=B7=E6=96=B0=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../provider/datasource/JdbcProvider.java | 4 +- frontend/src/views/dataset/data/ViewTable.vue | 106 +++++++++++------- 2 files changed, 69 insertions(+), 41 deletions(-) diff --git a/backend/src/main/java/io/dataease/provider/datasource/JdbcProvider.java b/backend/src/main/java/io/dataease/provider/datasource/JdbcProvider.java index d193600cb1..200f7afdad 100644 --- a/backend/src/main/java/io/dataease/provider/datasource/JdbcProvider.java +++ b/backend/src/main/java/io/dataease/provider/datasource/JdbcProvider.java @@ -284,8 +284,8 @@ public class JdbcProvider extends DatasourceProvider { String f = metaData.getColumnName(j + 1); String l = StringUtils.isNotEmpty(metaData.getColumnLabel(j + 1)) ? metaData.getColumnLabel(j + 1) : f; String t = metaData.getColumnTypeName(j + 1); - if (datasourceRequest.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.hive.name()) && l.contains("\\.")) { - l = l.split("\\.")[1]; + if (datasourceRequest.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.hive.name()) && l.contains(".")) { + l = l.split(".")[1]; } TableField field = new TableField(); field.setFieldName(l); diff --git a/frontend/src/views/dataset/data/ViewTable.vue b/frontend/src/views/dataset/data/ViewTable.vue index 841d07f9d7..46f82ab45e 100644 --- a/frontend/src/views/dataset/data/ViewTable.vue +++ b/frontend/src/views/dataset/data/ViewTable.vue @@ -11,12 +11,14 @@ @show="showTab" @hide="hideTab" > - + - + - + {{ $t('dataset.edit_excel') }} @@ -40,44 +42,53 @@ - + - + - - + + - - + + - - + + - - + + - - + + From 05cbd335ce77420336346f44032f4bc77222ea8d Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Mon, 4 Apr 2022 21:34:05 +0800 Subject: [PATCH 5/9] =?UTF-8?q?fix:=20=E6=8F=92=E4=BB=B6=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=89=88=E6=9C=AC=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/dataease/base/domain/MyPlugin.java | 2 + .../io/dataease/commons/utils/CodingUtil.java | 12 +++ .../dataease/service/sys/PluginService.java | 78 ++++++++++++++++++- frontend/src/lang/en.js | 4 +- frontend/src/lang/tw.js | 6 +- frontend/src/lang/zh.js | 6 +- frontend/src/views/system/plugin/index.vue | 20 +++-- 7 files changed, 113 insertions(+), 15 deletions(-) diff --git a/backend/src/main/java/io/dataease/base/domain/MyPlugin.java b/backend/src/main/java/io/dataease/base/domain/MyPlugin.java index e7c9e0ca76..a79291d8e1 100644 --- a/backend/src/main/java/io/dataease/base/domain/MyPlugin.java +++ b/backend/src/main/java/io/dataease/base/domain/MyPlugin.java @@ -35,5 +35,7 @@ public class MyPlugin implements Serializable { private String icon; + private String require = "1.9.0"; + private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/backend/src/main/java/io/dataease/commons/utils/CodingUtil.java b/backend/src/main/java/io/dataease/commons/utils/CodingUtil.java index ec283b549b..714392e36f 100644 --- a/backend/src/main/java/io/dataease/commons/utils/CodingUtil.java +++ b/backend/src/main/java/io/dataease/commons/utils/CodingUtil.java @@ -195,4 +195,16 @@ public class CodingUtil { } return shortBuffer.toString(); } + + public static Integer string2Integer(String str) { + StringBuffer sb = new StringBuffer(); + if (StringUtils.isBlank(str)) return null; + for (int i = 0; i < str.length(); i++) { + char c = str.charAt(i); + if (Character.isDigit(c)) { + sb.append(c); + } + } + return sb.length() > 0 ? Integer.parseInt(sb.toString()) : null; + } } diff --git a/backend/src/main/java/io/dataease/service/sys/PluginService.java b/backend/src/main/java/io/dataease/service/sys/PluginService.java index 282f3fe68f..cce8a8b175 100644 --- a/backend/src/main/java/io/dataease/service/sys/PluginService.java +++ b/backend/src/main/java/io/dataease/service/sys/PluginService.java @@ -1,17 +1,22 @@ package io.dataease.service.sys; +import cn.hutool.core.io.FileUtil; import com.google.gson.Gson; import io.dataease.base.domain.MyPlugin; import io.dataease.base.mapper.MyPluginMapper; import io.dataease.base.mapper.ext.ExtSysPluginMapper; import io.dataease.base.mapper.ext.query.GridExample; import io.dataease.commons.constants.AuthConstants; +import io.dataease.commons.exception.DEException; +import io.dataease.commons.utils.CodingUtil; import io.dataease.commons.utils.DeFileUtils; +import io.dataease.commons.utils.LogUtil; import io.dataease.commons.utils.ZipUtils; import io.dataease.controller.sys.base.BaseGridRequest; import io.dataease.listener.util.CacheUtils; import io.dataease.plugins.config.LoadjarUtil; import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -22,8 +27,10 @@ import javax.annotation.Resource; import java.io.File; import java.io.IOException; import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; @Service @@ -43,6 +50,9 @@ public class PluginService { @Autowired private LoadjarUtil loadjarUtil; + @Value("${version}") + private String version; + public List query(BaseGridRequest request) { GridExample gridExample = request.convertExample(); @@ -66,7 +76,9 @@ public class PluginService { DeFileUtils.deleteFile(pluginDir + "temp/"); DeFileUtils.deleteFile(folder); // 需要删除文件 - e.printStackTrace(); + // e.printStackTrace(); + LogUtil.error(e.getMessage(), e); + DEException.throwException(e); } //3.解析plugin.json 失败则 直接返回错误 删除文件 File folderFile = new File(folder); @@ -74,15 +86,31 @@ public class PluginService { if (ArrayUtils.isEmpty(jsonFiles)) { DeFileUtils.deleteFile(pluginDir + "temp/"); DeFileUtils.deleteFile(folder); - throw new RuntimeException("缺少插件描述文件"); + String msg = "缺少插件描述文件【plugin.json】"; + LogUtil.error(msg); + DEException.throwException(new RuntimeException(msg)); } MyPlugin myPlugin = formatJsonFile(jsonFiles[0]); + + if (!versionMatch(myPlugin.getRequire())) { + String msg = "当前插件要求系统版本最低为:" + myPlugin.getRequire(); + LogUtil.error(msg); + DEException.throwException(new RuntimeException(msg)); + } //4.加载jar包 失败则 直接返回错误 删除文件 File[] jarFiles = folderFile.listFiles(this::isPluginJar); if (ArrayUtils.isEmpty(jarFiles)) { DeFileUtils.deleteFile(pluginDir + "temp/"); DeFileUtils.deleteFile(folder); - throw new RuntimeException("缺少插件jar文件"); + String msg = "缺少插件jar文件"; + LogUtil.error(msg); + DEException.throwException(new RuntimeException(msg)); + } + + if (pluginExist(myPlugin)) { + String msg = "插件【"+myPlugin.getName()+"】已存在,请先卸载"; + LogUtil.error(msg); + DEException.throwException(new RuntimeException(msg)); } String targetDir = null; try { @@ -100,7 +128,8 @@ public class PluginService { if (StringUtils.isNotEmpty(targetDir)) { DeFileUtils.deleteFile(targetDir); } - e.printStackTrace(); + LogUtil.error(e.getMessage(), e); + DEException.throwException(e); } finally { DeFileUtils.deleteFile(pluginDir + "temp/"); DeFileUtils.deleteFile(folder); @@ -122,6 +151,19 @@ public class PluginService { return dir; } + /** + * 检测插件是否已存在 + * @param myPlugin + * @return + */ + public boolean pluginExist(MyPlugin myPlugin) { + GridExample gridExample = new GridExample(); + List plugins = extSysPluginMapper.query(gridExample); + return plugins.stream().anyMatch(plugin -> { + return StringUtils.equals(myPlugin.getName(), plugin.getName()) || StringUtils.equals(myPlugin.getModuleName(), plugin.getModuleName()); + }); + } + /** * 卸载插件 * @@ -129,6 +171,13 @@ public class PluginService { * @return */ public Boolean uninstall(Long pluginId) { + MyPlugin myPlugin = myPluginMapper.selectByPrimaryKey(pluginId); + if (ObjectUtils.isEmpty(myPlugin)) { + String msg = "当前插件不存在"; + LogUtil.error(msg); + DEException.throwException(new RuntimeException(msg)); + } + deleteJarFile(myPlugin); CacheUtils.removeAll(AuthConstants.USER_CACHE_NAME); CacheUtils.removeAll(AuthConstants.USER_ROLE_CACHE_NAME); CacheUtils.removeAll(AuthConstants.USER_PERMISSION_CACHE_NAME); @@ -136,6 +185,15 @@ public class PluginService { return true; } + private void deleteJarFile(MyPlugin plugin) { + String version = plugin.getVersion(); + String moduleName = plugin.getModuleName(); + String fileName = moduleName + "-" + version + ".jar"; + String path = pluginDir + plugin.getStore() + "/" + fileName; + File jarFile = new File(path); + FileUtil.del(jarFile); + } + /** * 改变插件状态 * @@ -195,4 +253,16 @@ public class PluginService { public Map remoteInstall(Map params) { return null; } + + public boolean versionMatch(String pluginVersion) { + List versionLists = Arrays.stream(version.split(".")).map(CodingUtil::string2Integer).collect(Collectors.toList()); + List requireVersionLists = Arrays.stream(pluginVersion.split(".")).map(CodingUtil::string2Integer).collect(Collectors.toList()); + int maxSize = Math.max(versionLists.size(), requireVersionLists.size()); + for (int i = 0; i < maxSize; i++) { + Integer currentV = versionLists.size() == i ? 0 : versionLists.get(i); + Integer requireV = requireVersionLists.size() == i ? 0 : requireVersionLists.get(i); + if (requireV > currentV) return false; + } + return false; + } } diff --git a/frontend/src/lang/en.js b/frontend/src/lang/en.js index 1b42f95804..1a98d948fa 100644 --- a/frontend/src/lang/en.js +++ b/frontend/src/lang/en.js @@ -1646,7 +1646,9 @@ export default { uninstall_cancel: 'Cancel uninstall plugin', setting_background: 'BackGround', setting_jump: 'Jump Setting', - select_view: 'Select View' + select_view: 'Select View', + un_install_success: 'Uninstall is successful and restart takes effect', + un_install_error: 'Uninstall failed, please contact the administrator' }, display: { logo: 'Head system logo', diff --git a/frontend/src/lang/tw.js b/frontend/src/lang/tw.js index a72a0b0de1..57da2c32a8 100644 --- a/frontend/src/lang/tw.js +++ b/frontend/src/lang/tw.js @@ -1645,9 +1645,11 @@ export default { creator: '作者', install_time: '安裝時間', release_time: '時間', - un_install: '卸載', + un_install: '卸載(重啟服務後生效)', uninstall_confirm: '確定卸載該插件', - uninstall_cancel: '取消卸載插件' + uninstall_cancel: '取消卸載插件', + un_install_success: '卸載成功,重啟生效', + un_install_error: '卸載失敗,請聯系管理員' }, display: { logo: '頭部繫統logo', diff --git a/frontend/src/lang/zh.js b/frontend/src/lang/zh.js index 543b426f68..1ad39b8f82 100644 --- a/frontend/src/lang/zh.js +++ b/frontend/src/lang/zh.js @@ -1654,9 +1654,11 @@ export default { creator: '作者', install_time: '安装时间', release_time: '时间', - un_install: '卸载', + un_install: '卸载(卸载并重启服务后生效)', uninstall_confirm: '确定卸载该插件', - uninstall_cancel: '取消卸载插件' + uninstall_cancel: '取消卸载插件', + un_install_success: '卸载成功,重启生效', + un_install_error: '卸载失败,请联系管理员' }, display: { logo: '头部系统logo', diff --git a/frontend/src/views/system/plugin/index.vue b/frontend/src/views/system/plugin/index.vue index 99c08b8f62..3713f245ee 100644 --- a/frontend/src/views/system/plugin/index.vue +++ b/frontend/src/views/system/plugin/index.vue @@ -8,7 +8,6 @@ @search="search" > - + @@ -72,6 +71,10 @@ export default { // label: this.$t('commons.delete'), icon: 'el-icon-delete', type: 'danger', click: this.del, // show: checkPermission(['user:del']) // } + { + label: this.$t('plugin.un_install'), icon: 'el-icon-delete', type: 'danger', click: this.del, + disabled: this.btnDisabled + } ], searchConfig: { useQuickSearch: true, @@ -113,6 +116,8 @@ export default { this.uploading = true }, uploadFail(response, file, fileList) { + const msg = response && response.message || '安装失败' + this.$error(msg) this.uploading = false }, uploadSuccess(response, file, fileList) { @@ -121,20 +126,23 @@ export default { }, del(row) { - this.$confirm(this.$t('user.delete_confirm'), '', { + this.$confirm(this.$t('plugin.uninstall_confirm'), '', { confirmButtonText: this.$t('commons.confirm'), cancelButtonText: this.$t('commons.cancel'), type: 'warning' }).then(() => { uninstall(row.pluginId).then(res => { this.search() - this.$success('卸载成功') + this.$success(this.$t('plugin.un_install_success')) }).catch(() => { - this.$error('卸载失败') + this.$error(this.$t('plugin.un_install_error')) }) }).catch(() => { - this.$info(this.$t('commons.delete_cancel')) + this.$info(this.$t('plugin.uninstall_cancel')) }) + }, + btnDisabled(row) { + return row.pluginId < 4 } } From 9f3ef8e1f97fda7ca7ea5f3194991d7600cb862f Mon Sep 17 00:00:00 2001 From: junjun Date: Mon, 4 Apr 2022 22:02:42 +0800 Subject: [PATCH 6/9] =?UTF-8?q?fix:=20=E8=87=AA=E5=AE=9A=E4=B9=89=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=9B=86=E6=8A=A5=E9=94=99=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/dataease/service/dataset/DataSetTableService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java index 21eb7aa271..00b46582d4 100644 --- a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java +++ b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java @@ -1101,10 +1101,10 @@ public class DataSetTableService { Map customInfo = new TreeMap<>(); for (DataTableInfoCustomUnion ele : dataTableInfoDTO.getList()) { DatasetTable datasetTable = datasetTableMapper.selectByPrimaryKey(ele.getTableId()); - String table = new Gson().fromJson(datasetTable.getInfo(), DataTableInfoDTO.class).getTable(); if (ObjectUtils.isEmpty(datasetTable)) { throw new RuntimeException(Translator.get("i18n_custom_ds_delete")); } + String table = new Gson().fromJson(datasetTable.getInfo(), DataTableInfoDTO.class).getTable(); List fields = dataSetTableFieldsService.getListByIdsEach(ele.getCheckedFields()); if (CollectionUtils.isEmpty(fields)) { throw new RuntimeException(Translator.get("i18n_cst_ds_tb_or_field_deleted")); From 0a9d2a8810c83a85c35292e6c344f1f6b9a57e8c Mon Sep 17 00:00:00 2001 From: taojinlong Date: Tue, 5 Apr 2022 11:57:29 +0800 Subject: [PATCH 7/9] =?UTF-8?q?fix:=20StarRocks=E3=80=81tidb=20=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/dataease/service/dataset/ExtractDataService.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java b/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java index 6d6f441a42..fe31d15721 100644 --- a/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java +++ b/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java @@ -872,6 +872,8 @@ public class ExtractDataService { case ds_doris: case mariadb: case mysql: + case TiDB: + case StarRocks: MysqlConfiguration mysqlConfiguration = new Gson().fromJson(datasource.getConfiguration(), MysqlConfiguration.class); dataMeta = new DatabaseMeta("db", "MYSQL", "Native", mysqlConfiguration.getHost().trim(), mysqlConfiguration.getDataBase().trim(), mysqlConfiguration.getPort().toString(), mysqlConfiguration.getUsername(), mysqlConfiguration.getPassword()); dataMeta.addExtraOption("MYSQL", "characterEncoding", "UTF-8"); From 9a9a1a1c0fe37fa5c3a8d5b2e282e59f1690ed0b Mon Sep 17 00:00:00 2001 From: taojinlong Date: Tue, 5 Apr 2022 17:30:49 +0800 Subject: [PATCH 8/9] =?UTF-8?q?fix:=20=E6=A3=80=E6=B5=8B=E5=B9=B6=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E5=A4=B1=E8=B4=A5=E4=BB=BB=E5=8A=A1=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../listener/DataSourceInitStartListener.java | 3 +- .../service/dataset/DataSetTableService.java | 33 +++++++++++-------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/backend/src/main/java/io/dataease/listener/DataSourceInitStartListener.java b/backend/src/main/java/io/dataease/listener/DataSourceInitStartListener.java index 8918c488b8..d3170c606b 100644 --- a/backend/src/main/java/io/dataease/listener/DataSourceInitStartListener.java +++ b/backend/src/main/java/io/dataease/listener/DataSourceInitStartListener.java @@ -19,8 +19,7 @@ public class DataSourceInitStartListener implements ApplicationListener qrtzSchedulerState.getLastCheckinTime() + qrtzSchedulerState.getCheckinInterval() + 1000 > utilMapper.currentTimestamp()) .map(QrtzSchedulerStateKey::getInstanceName).collect(Collectors.toList()); - List jobStoppeddDatasetTables = new ArrayList<>(); DatasetTableExample example = new DatasetTableExample(); example.createCriteria().andSyncStatusEqualTo(JobStatus.Underway.name()); + List jobStoppeddDatasetTables = new ArrayList<>(); + datasetTableMapper.selectByExample(example).forEach(datasetTable -> { if (StringUtils.isEmpty(datasetTable.getQrtzInstance()) || !activeQrtzInstances.contains( datasetTable.getQrtzInstance().substring(0, datasetTable.getQrtzInstance().length() - 13))) { @@ -2235,21 +2236,25 @@ public class DataSetTableService { return; } + //Task + DatasetTableTaskExample datasetTableTaskExample = new DatasetTableTaskExample(); + DatasetTableTaskExample.Criteria criteria = datasetTableTaskExample.createCriteria(); + criteria.andTableIdIn(jobStoppeddDatasetTables.stream().map(DatasetTable::getId).collect(Collectors.toList())).andLastExecStatusEqualTo(JobStatus.Underway.name()); + List datasetTableTasks = dataSetTableTaskService.list(datasetTableTaskExample); + if (CollectionUtils.isEmpty(datasetTableTasks)) { + return; + } + + dataSetTableTaskService.updateTaskStatus(datasetTableTasks, JobStatus.Error); + //DatasetTable DatasetTable record = new DatasetTable(); record.setSyncStatus(JobStatus.Error.name()); example.clear(); example.createCriteria().andSyncStatusEqualTo(JobStatus.Underway.name()) - .andIdIn(jobStoppeddDatasetTables.stream().map(DatasetTable::getId).collect(Collectors.toList())); + .andIdIn(datasetTableTasks.stream().map(DatasetTableTask::getTableId).collect(Collectors.toList())); datasetTableMapper.updateByExampleSelective(record, example); - //Task - DatasetTableTaskExample datasetTableTaskExample = new DatasetTableTaskExample(); - DatasetTableTaskExample.Criteria criteria = datasetTableTaskExample.createCriteria(); - criteria.andTableIdIn(jobStoppeddDatasetTables.stream().map(DatasetTable::getId).collect(Collectors.toList())).andStatusEqualTo(JobStatus.Underway.name()); - List datasetTableTasks = dataSetTableTaskService.list(datasetTableTaskExample); - dataSetTableTaskService.updateTaskStatus(datasetTableTasks, JobStatus.Error); - //TaskLog DatasetTableTaskLog datasetTableTaskLog = new DatasetTableTaskLog(); datasetTableTaskLog.setStatus(JobStatus.Error.name()); @@ -2257,13 +2262,13 @@ public class DataSetTableService { DatasetTableTaskLogExample datasetTableTaskLogExample = new DatasetTableTaskLogExample(); datasetTableTaskLogExample.createCriteria().andStatusEqualTo(JobStatus.Underway.name()) - .andTableIdIn(jobStoppeddDatasetTables.stream().map(DatasetTable::getId).collect(Collectors.toList())); + .andTableIdIn(datasetTableTasks.stream().map(DatasetTableTask::getTableId).collect(Collectors.toList())); datasetTableTaskLogMapper.updateByExampleSelective(datasetTableTaskLog, datasetTableTaskLogExample); - for (DatasetTable jobStoppeddDatasetTable : jobStoppeddDatasetTables) { - extractDataService.deleteFile("all_scope", jobStoppeddDatasetTable.getId()); - extractDataService.deleteFile("incremental_add", jobStoppeddDatasetTable.getId()); - extractDataService.deleteFile("incremental_delete", jobStoppeddDatasetTable.getId()); + for (DatasetTableTask datasetTableTask : datasetTableTasks) { + extractDataService.deleteFile("all_scope", datasetTableTask.getTableId()); + extractDataService.deleteFile("incremental_add", datasetTableTask.getTableId()); + extractDataService.deleteFile("incremental_delete", datasetTableTask.getTableId()); } } From 8c0d7ae0ade1f7fdb4cc9202c85a0747e702cb90 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Tue, 5 Apr 2022 17:54:47 +0800 Subject: [PATCH 9/9] =?UTF-8?q?fix:=20=E9=9B=86=E7=BE=A4=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/engine/KettleController.java | 4 ++-- .../io/dataease/service/kettle/KettleService.java | 12 +++++++++--- frontend/src/api/system/kettle.js | 2 +- .../views/system/SysParam/ClusterModeSetting.vue | 13 ++++++++++--- .../src/views/system/SysParam/KettleSetting.vue | 2 +- 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/backend/src/main/java/io/dataease/controller/engine/KettleController.java b/backend/src/main/java/io/dataease/controller/engine/KettleController.java index b33b62747d..bbf67c7a7f 100644 --- a/backend/src/main/java/io/dataease/controller/engine/KettleController.java +++ b/backend/src/main/java/io/dataease/controller/engine/KettleController.java @@ -43,8 +43,8 @@ public class KettleController { @ApiIgnore @PostMapping("validate") - public void validate(@RequestBody KettleDTO kettleDTO) throws Exception{ - kettleService.validate(kettleDTO); + public ResultHolder validate(@RequestBody KettleDTO kettleDTO) throws Exception{ + return kettleService.validate(kettleDTO); } @RequiresPermissions("sysparam:read") diff --git a/backend/src/main/java/io/dataease/service/kettle/KettleService.java b/backend/src/main/java/io/dataease/service/kettle/KettleService.java index aff3dc667f..960783fb34 100644 --- a/backend/src/main/java/io/dataease/service/kettle/KettleService.java +++ b/backend/src/main/java/io/dataease/service/kettle/KettleService.java @@ -60,12 +60,18 @@ public class KettleService { deEngineMapper.deleteByPrimaryKey(id); } - public void validate(KettleDTO kettleDTO) throws Exception { + public ResultHolder validate(KettleDTO kettleDTO) throws Exception { HttpClientConfig httpClientConfig = new HttpClientConfig(); String authValue = "Basic " + Base64.getUrlEncoder().encodeToString((kettleDTO.getUser() + ":" + kettleDTO.getPasswd()).getBytes()); httpClientConfig.addHeader("Authorization", authValue); - String response = HttpClientUtil.get("http://" + kettleDTO.getCarte() + ":" + kettleDTO.getPort() + "/kettle/status/", httpClientConfig); + try { + String response = HttpClientUtil.get("http://" + kettleDTO.getCarte() + ":" + kettleDTO.getPort() + "/kettle/status/", httpClientConfig); + + return ResultHolder.error("Kettle is valid."); + }catch (Exception e){ + return ResultHolder.error("Kettle is invalid: " + e.getMessage()); + } } public ResultHolder validate(String id) { @@ -116,7 +122,7 @@ public class KettleService { remoteSlaveServer.setHostname(kettleDTO.getCarte()); remoteSlaveServer.setPort(kettleDTO.getPort()); remoteSlaveServer.setUsername(kettleDTO.getUser()); - remoteSlaveServer.setPort(kettleDTO.getPasswd()); + remoteSlaveServer.setPassword(kettleDTO.getPasswd()); } return remoteSlaveServer; } diff --git a/frontend/src/api/system/kettle.js b/frontend/src/api/system/kettle.js index dc8ceea939..213ef62de7 100644 --- a/frontend/src/api/system/kettle.js +++ b/frontend/src/api/system/kettle.js @@ -31,7 +31,7 @@ export function save(data) { export function deleteKettle(id) { return request({ - url: '/delete/' + id, + url: '/kettle/delete/' + id, method: 'delete', loading: true }) diff --git a/frontend/src/views/system/SysParam/ClusterModeSetting.vue b/frontend/src/views/system/SysParam/ClusterModeSetting.vue index 55497e578a..9e3b62bff1 100644 --- a/frontend/src/views/system/SysParam/ClusterModeSetting.vue +++ b/frontend/src/views/system/SysParam/ClusterModeSetting.vue @@ -46,7 +46,7 @@ - + @@ -156,6 +156,13 @@ export default { trigger: ['change', 'blur'] } ], + 'configuration.httpPort': [ + { + required: true, + message: this.$t('datasource.please_input_port'), + trigger: ['change', 'blur'] + } + ], 'configuration.dataBase': [ { required: true, @@ -212,7 +219,7 @@ export default { this.show = false }, save() { - if (this.form.configuration.dataSourceType === 'jdbc' && this.form.configuration.port <= 0) { + if (this.form.configuration.dataSourceType === 'jdbc' && (this.form.configuration.port <= 0 || this.form.configuration.httpPort <= 0)) { this.$message.error(i18n.t('datasource.port_no_less_then_0')) return } @@ -256,7 +263,7 @@ export default { this.$message.error(i18n.t('datasource.please_choose_schema')) return } - if (this.form.configuration.dataSourceType === 'jdbc' && this.form.configuration.port <= 0) { + if (this.form.configuration.dataSourceType === 'jdbc' && (this.form.configuration.port <= 0 || this.form.configuration.httpPort <= 0)) { this.$message.error(i18n.t('datasource.port_no_less_then_0')) return } diff --git a/frontend/src/views/system/SysParam/KettleSetting.vue b/frontend/src/views/system/SysParam/KettleSetting.vue index 4a43f68110..fa4f9acdf0 100644 --- a/frontend/src/views/system/SysParam/KettleSetting.vue +++ b/frontend/src/views/system/SysParam/KettleSetting.vue @@ -118,7 +118,7 @@ export default { }], 'configuration.passwd': [{ required: true, - message: this.$t('dcommons.required'), + message: this.$t('commons.required'), trigger: 'blur' }] }