@@ -137,7 +136,6 @@ import { isFirefox } from 'data-room-ui/js/utils/userAgent'
import { handleResData } from 'data-room-ui/js/store/actions.js'
import { EventBus } from 'data-room-ui/js/utils/eventBus'
import NotPermission from 'data-room-ui/NotPermission'
-import { themeToSetting } from 'data-room-ui/js/utils/themeFormatting'
export default {
name: 'BigScreenDesign',
components: {
@@ -218,8 +216,7 @@ export default {
hasGrid: (state) => state.bigScreen.hasGrid,
zoom: (state) => state.bigScreen.zoom,
fitZoom: (state) => state.bigScreen.fitZoom,
- iframeDialog: (state) => state.bigScreen.iframeDialog,
- activeCode: state => state.bigScreen.activeCode
+ iframeDialog: (state) => state.bigScreen.iframeDialog
}),
pageCode () {
return this.code || this.$route.query.code
@@ -280,9 +277,7 @@ export default {
'changeZoom',
'clearTimeline',
'saveTimeLine',
- 'changeIframeDialog',
- 'changePageInfo',
- 'changeActiveItemConfig'
+ 'changeIframeDialog'
]),
// 判断页面权限
permission () {
@@ -409,12 +404,6 @@ export default {
})
.catch(() => {})
},
- // 切换主题时更新主题配置
- updateTheme (theme) {
- const pageInfo = this.pageInfo
- pageInfo.chartList = themeToSetting(pageInfo.chartList, theme, this)
- this.changePageInfo(pageInfo)
- },
// 自定义属性更新
updateSetting (config) {
if (config.type === 'map' || config.type === 'video') {
diff --git a/data-room-ui/packages/BizComponent/Preview.vue b/data-room-ui/packages/BizComponent/Preview.vue
index 5e09a01e..2bd54f7e 100644
--- a/data-room-ui/packages/BizComponent/Preview.vue
+++ b/data-room-ui/packages/BizComponent/Preview.vue
@@ -16,6 +16,8 @@
import remoteVueLoader from 'remote-vue-loader'
import { getBizComponentInfo } from 'data-room-ui/js/api/bigScreenApi'
import innerRemoteComponents, { getRemoteComponents } from 'data-room-ui/RemoteComponents/remoteComponentsList'
+import * as _echarts from 'echarts'
+
export default {
name: 'BsComponentPreview',
props: {
@@ -39,6 +41,8 @@ export default {
let title = ''
// eslint-disable-next-line prefer-const, no-unused-vars
let data = []
+ // eslint-disable-next-line prefer-const, no-unused-vars
+ let echarts = _echarts
// eslint-disable-next-line prefer-const
let settingContent = this.settingContentInner?.replaceAll('const ', '')
// 去掉 export default及后面代码
@@ -47,7 +51,8 @@ export default {
return {
title,
option,
- setting
+ setting,
+ echarts
}
},
set (val) {}
diff --git a/data-room-ui/packages/DataSourceManagement/src/setDatasource.vue b/data-room-ui/packages/DataSourceManagement/src/setDatasource.vue
index 2b32e41b..0d08658f 100644
--- a/data-room-ui/packages/DataSourceManagement/src/setDatasource.vue
+++ b/data-room-ui/packages/DataSourceManagement/src/setDatasource.vue
@@ -227,7 +227,8 @@ export default {
{ name: 'Mysql', code: 'mysql' },
{ name: 'ClickHouse', code: 'clickhouse' },
{ name: 'PostgreSQL', code: 'postgresql' },
- { name: 'Oracle', code: 'oracle' }
+ { name: 'Oracle', code: 'oracle' },
+ { name: 'Hive', code: 'hive' }
],
driverCLassList: [
{ code: 'mysqlDriver', name: 'com.mysql.jdbc.Driver' },
@@ -365,6 +366,7 @@ export default {
let driverName = ''
driverName = code + 'Driver'
// 从驱动列表中获取驱动的对应的jdbcUrl
+ console.info(driverName)
this.driverCLassList.forEach(driver => {
if (driverName === driver.code) {
this.dataForm.driverClassName = driver.name
diff --git a/data-room-ui/packages/PlotRender/index.vue b/data-room-ui/packages/PlotRender/index.vue
index 818fad90..12a7ef7f 100644
--- a/data-room-ui/packages/PlotRender/index.vue
+++ b/data-room-ui/packages/PlotRender/index.vue
@@ -20,7 +20,6 @@ import { mapState, mapMutations } from 'vuex'
import * as g2Plot from '@antv/g2plot'
import plotList, { getCustomPlots } from '../G2Plots/plotList'
import { settingToTheme } from 'data-room-ui/js/utils/themeFormatting'
-import _ from 'lodash'
export default {
name: 'PlotCustomComponent',
@@ -41,8 +40,7 @@ export default {
computed: {
...mapState('bigScreen', {
pageInfo: state => state.pageInfo,
- customTheme: state => state.pageInfo.pageConfig.customTheme,
- activeCode: state => state.activeCode
+ customTheme: state => state.pageInfo.pageConfig.customTheme
}),
chatId () {
let prefix = 'chart_'
@@ -71,8 +69,9 @@ export default {
}
},
methods: {
- ...mapMutations('bigScreen', ['changeChartConfig', 'changeActiveItemConfig']),
+ ...mapMutations('bigScreen', ['changeChartConfig']),
chartInit () {
+
let config = this.config
// key和code相等,说明是一进来刷新,调用list接口
if (this.config.code === this.config.key || this.isPreview) {
@@ -82,8 +81,7 @@ export default {
this.changeDataByCode(config).then((res) => {
// 初始化图表
this.newChart(res)
- }).catch(() => {
- })
+ }).catch(() => {})
} else {
// 否则说明是更新,这里的更新只指更新数据(改变样式时是直接调取changeStyle方法),因为更新数据会改变key,调用chart接口
this.changeData(config).then((res) => {
@@ -181,15 +179,13 @@ export default {
console.error(e)
}
}
- // 将设置好的主题保存起来
- config.theme = settingToTheme(_.cloneDeep(config), this.customTheme)
- this.changeChartConfig(config)
- if (config.code === this.activeCode) {
- this.changeActiveItemConfig(config)
- }
if (this.chart) {
this.chart.update(config.option)
}
+ this.changeChartConfig(config)
+ // 将设置好的主题保存起来
+ console.log('changeStyle')
+ config.theme = settingToTheme(config, this.customTheme)
return config
}
}
diff --git a/data-room-ui/packages/RemoteComponents/index.vue b/data-room-ui/packages/RemoteComponents/index.vue
index 2f222c96..34721f94 100644
--- a/data-room-ui/packages/RemoteComponents/index.vue
+++ b/data-room-ui/packages/RemoteComponents/index.vue
@@ -19,6 +19,7 @@ import remoteVueLoader from 'remote-vue-loader'
import { mapMutations, mapState } from 'vuex'
import innerRemoteComponents, { getRemoteComponents } from 'data-room-ui/RemoteComponents/remoteComponentsList'
import { getBizComponentInfo } from 'data-room-ui/js/api/bigScreenApi'
+import * as _echarts from 'echarts'
export default {
name: 'LcdpRemoteComponent',
mixins: [linkageMixins, commonMixins],
@@ -76,6 +77,10 @@ export default {
if (!this.config?.option?.data) {
this.resolveStrSetting(settingContent)
this.config = this.dataFormatting(this.config, { success: false })
+ } else {
+ if (!this.config?.echarts) {
+ this.config.echarts = _echarts
+ }
}
this.remoteComponent = remoteVueLoader('data:text/plain,' + encodeURIComponent(vueContent))
}).finally(() => {
@@ -116,16 +121,22 @@ export default {
let title = []
// eslint-disable-next-line prefer-const, no-unused-vars
let data = []
+ // eslint-disable-next-line prefer-const, no-unused-vars
+ let echarts = _echarts
// eslint-disable-next-line prefer-const
settingContent = settingContent.replaceAll('const ', '')
// 去掉 export default及后面代码
settingContent = settingContent.replace(/export default[\s\S]*/, '')
+
eval(settingContent)
+ console.info('处理当前组件的字符串配置', setting)
+
this.config.option = {
...this.config.option,
...option
}
this.config.setting = setting
+ this.config.echarts = echarts
return {
option,
setting
@@ -136,7 +147,7 @@ export default {
* @returns {Promise
}
*/
// 将config.setting的配置转化为option里的配置,这里之所以将转化的方法提出来,是因为在改变维度指标和样式的时候都需要转化
- transformSettingToOption (config, type) {
+ transformSettingToOption (config, type, data) {
let option = null
config.setting.forEach(set => {
if (set.optionField) {
@@ -146,7 +157,7 @@ export default {
if (index === optionField.length - 1) {
// 数据配置时,必须有值才更新
if ((set.tabName === type && type === 'data' && set.value) || (set.tabName === type && type === 'custom')) {
- option[field] = set.value
+ option[field] = set.echarts ? this.getAttrByArr(data, set.value) : set.value
}
} else {
option = option[field]
@@ -157,11 +168,35 @@ export default {
config.option = { ...config.option, ...option }
return config
},
+ getAttrByArr (arr, attrs) {
+ const res = []
+ if (arr === undefined || arr === null) {
+ return res
+ }
+ if (arr instanceof Array) {
+ for (const arrElement of arr) {
+ if (attrs instanceof Array) {
+ const obj = {}
+ for (const attr of attrs) {
+ if (attr instanceof Object) {
+ obj[attr[Object.keys(attr)[0]]] = arrElement[Object.keys(attr)[0]]
+ } else {
+ obj[attr] = arrElement[attr]
+ }
+ }
+ res.push(obj)
+ } else {
+ res.push(arrElement[attrs])
+ }
+ }
+ }
+ return res
+ },
dataFormatting (config, data) {
// 数据返回成功则赋值
if (data.success) {
data = data.data
- config = this.transformSettingToOption(config, 'data')
+ config = this.transformSettingToOption(config, 'data', data)
// 获取到后端返回的数据,有则赋值
const option = config.option
const setting = config.setting
diff --git a/data-room-ui/packages/Render/index.vue b/data-room-ui/packages/Render/index.vue
index cce8539f..5c937c57 100644
--- a/data-room-ui/packages/Render/index.vue
+++ b/data-room-ui/packages/Render/index.vue
@@ -105,7 +105,8 @@ export default {
// 临时冻结拖拽
freeze: false,
plotList,
- rawChart: []
+ rawChart: [],
+ open: true
}
},
computed: {
@@ -211,6 +212,30 @@ export default {
this.setPresetLine({
...chart
})
+ this.Throttle(() => {
+ this.changeChartConfig({
+ ...chart,
+ w: width,
+ h: height,
+ x: x,
+ y: y
+ })
+ }, 100)()
+ },
+ Throttle (fn, delay) {
+ const that = this
+ return function (...data) {
+ if (!that.open) {
+ // 休息时间 暂不接客
+ return false
+ }
+ // 工作时间,执行函数并且在间隔期内把状态位设为无效
+ that.open = false
+ setTimeout(() => {
+ fn(...data)
+ that.open = true
+ }, delay)
+ }
},
/**
*
@@ -329,8 +354,9 @@ export default {
}
config.key = config.code
// TODO:新添加一个组件时应该有默认的两套主题
+ console.log('add')
// 先暂时只考虑g2组件
- if (['customComponent'].includes(_chart.type)) {
+ if (['customComponent'].includes(chart.type)){
config.theme = settingToTheme(config, 'dark')
config.theme = settingToTheme(config, 'light')
}
diff --git a/data-room-ui/packages/js/utils/themeFormatting.js b/data-room-ui/packages/js/utils/themeFormatting.js
index fda771d3..80ffa149 100644
--- a/data-room-ui/packages/js/utils/themeFormatting.js
+++ b/data-room-ui/packages/js/utils/themeFormatting.js
@@ -1,12 +1,9 @@
-import _ from 'lodash'
-
/**
* @Description: 主题设置格式化
* @author liu.shiyi
* @date 2023/8/17 14:47
*/
// 将组件中的setting里面的主题设置(颜色)存放到theme里面
-
export function settingToTheme (config, type) {
// 考虑与上一次保存过的主题进行合并
// 排除掉主题非暗黑非明亮的情况
@@ -23,11 +20,12 @@ export function settingToTheme (config, type) {
}
}
// 将保存的theme主题设置(颜色)存放到chartList
-export function themeToSetting (chartList, type, _this) {
+export function themeToSetting (chartList, type) {
// 排除掉主题非暗黑非明亮的情况
if (['dark', 'light'].includes(type)) {
chartList.forEach(chart => {
chart.option.theme = type
+ chart.key = new Date().getTime()
if (chart.theme && chart.theme[type]) {
for (const item of chart.setting) {
// 检查 obj 中是否存在与 item.field 相对应的属性
@@ -37,9 +35,6 @@ export function themeToSetting (chartList, type, _this) {
}
}
}
- if (_this && _this.$refs.Render?.$refs['RenderCard' + chart.code][0] && _this.$refs.Render.$refs['RenderCard' + chart.code][0].$refs[chart.code].changeStyle) {
- _this.$refs.Render.$refs['RenderCard' + chart.code][0].$refs[chart.code].changeStyle(_.cloneDeep(chart))
- }
})
}
return chartList
diff --git a/data-room-ui/public/config/index-development.js b/data-room-ui/public/config/index-development.js
index 67c95da5..87f4c10c 100644
--- a/data-room-ui/public/config/index-development.js
+++ b/data-room-ui/public/config/index-development.js
@@ -1,6 +1,6 @@
window.ENV = 'development'
var developmentConfig = {
- baseUrl: 'http://gcpaas.gccloud.com/bigScreenServer'
+ baseUrl: 'http://127.0.0.1:8081/bigScreenServer'
}
// 必须的
window.CONFIG = configDeepMerge(window.CONFIG, developmentConfig)
--
Gitee
From e6bea64ef2731ebb6f322faf311d315beab4a33b Mon Sep 17 00:00:00 2001
From: luolongwu <506258220@qq.com>
Date: Mon, 28 Aug 2023 15:51:36 +0800
Subject: [PATCH 2/5] =?UTF-8?q?=E6=8F=90=E4=BA=A4hive=E9=A9=B1=E5=8A=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DataRoom/dataroom-core/pom.xml | 28 ++++
.../datasource/HiveDatasourceServiceImpl.java | 139 ++++++++++++++++++
DataRoom/pom.xml | 3 +-
3 files changed, 169 insertions(+), 1 deletion(-)
create mode 100644 DataRoom/dataroom-core/src/main/java/com/gccloud/dataroom/core/service/impl/datasource/HiveDatasourceServiceImpl.java
diff --git a/DataRoom/dataroom-core/pom.xml b/DataRoom/dataroom-core/pom.xml
index 1d27e360..fb726f09 100644
--- a/DataRoom/dataroom-core/pom.xml
+++ b/DataRoom/dataroom-core/pom.xml
@@ -69,5 +69,33 @@
jackson-datatype-json-org
${jackson.version.core}
+
+
+ org.apache.hive
+ hive-jdbc
+ ${hive.version}
+
+
+ org.apache.hive
+ hive-service
+
+
+
+
+ org.apache.hive
+ hive-service
+ ${hive.version}
+
+
+ *
+ *
+
+
+
+
+
+
+
+
diff --git a/DataRoom/dataroom-core/src/main/java/com/gccloud/dataroom/core/service/impl/datasource/HiveDatasourceServiceImpl.java b/DataRoom/dataroom-core/src/main/java/com/gccloud/dataroom/core/service/impl/datasource/HiveDatasourceServiceImpl.java
new file mode 100644
index 00000000..13ed9b58
--- /dev/null
+++ b/DataRoom/dataroom-core/src/main/java/com/gccloud/dataroom/core/service/impl/datasource/HiveDatasourceServiceImpl.java
@@ -0,0 +1,139 @@
+package com.gccloud.dataroom.core.service.impl.datasource;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gccloud.common.vo.PageVO;
+import com.gccloud.dataset.constant.DatasetConstant;
+import com.gccloud.dataset.dao.DatasourceDao;
+import com.gccloud.dataset.entity.DatasourceEntity;
+import com.gccloud.dataset.service.IBaseDatasourceService;
+import com.gccloud.dataset.utils.DBUtils;
+import com.gccloud.dataset.vo.*;
+import com.google.common.collect.Lists;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Hive数据源服务实现类
+ * @author apisflorea
+ * @version 1.0
+ * @date 2023年8月25日 10点43分
+ */
+
+@Slf4j
+@Service(DatasetConstant.DatasourceType.HIVE)
+public class HiveDatasourceServiceImpl extends ServiceImpl implements IBaseDatasourceService {
+
+ @Override
+ public DataVO executeSql(DatasourceEntity datasource, String sql) {
+ DbDataVO dbDataVO = DBUtils.getSqlValue(sql, datasource);
+ return new DataVO(dbDataVO.getData(), dbDataVO.getStructure());
+ }
+
+ @Override
+ public DataVO executeSqlPage(DatasourceEntity datasource, String sql, Integer current, Integer size) {
+ if (sql.endsWith(";")) {
+ sql = sql.substring(0, sql.length() - 1);
+ }
+ // 组装计算总条数的sql
+ String countSql = "SELECT COUNT(1) AS COUNT FROM (" + sql + ") AS t";
+ log.info("数据集数据详情计算总条数 sql语句:{}", countSql);
+ DbDataVO countData = DBUtils.getSqlValue(countSql, datasource);
+ Object count = countData.getData().get(0).get("COUNT");
+ int total = Integer.parseInt(count.toString());
+ // 组装分页sql
+ int start = (current - 1) * size;
+ String pageSql = "SELECT * FROM (" + sql + ") AS t LIMIT " + start + "," + size;
+ log.info("数据集数据详情分页 sql语句:{}", pageSql);
+ DbDataVO pageData = DBUtils.getSqlValue(pageSql, datasource);
+ PageVO