Ver código fonte

Merge branch 'feature-refactor' of ssh://10.10.100.21/source/platform-bi-server into feature-refactor

zhuth 7 anos atrás
pai
commit
95ac68826d
18 arquivos alterados com 97 adições e 57 exclusões
  1. 7 7
      bi-core/src/main/java/com/usoftchina/bi/core/jdbc/DynamicDataSourceContextHolder.java
  2. 7 7
      bi-core/src/main/java/com/usoftchina/bi/core/jdbc/DynamicDataSourceRegister.java
  3. 4 4
      bi-server/src/main/java/com/usoftchina/bi/server/aspect/DynamicDattaSourceAspect.java
  4. 22 0
      bi-server/src/main/java/com/usoftchina/bi/server/dao/dashboard/DashboardsMapper.java
  5. 11 4
      bi-server/src/main/java/com/usoftchina/bi/server/service/chart/ChartsUtilService.java
  6. 2 2
      bi-server/src/main/java/com/usoftchina/bi/server/service/chart/GetChartsDataUtilService.java
  7. 2 2
      bi-server/src/main/java/com/usoftchina/bi/server/service/chart/ShowHistogramService.java
  8. 2 2
      bi-server/src/main/java/com/usoftchina/bi/server/service/chart/ShowIndividualService.java
  9. 2 2
      bi-server/src/main/java/com/usoftchina/bi/server/service/chart/ShowLineService.java
  10. 2 2
      bi-server/src/main/java/com/usoftchina/bi/server/service/chart/ShowPieService.java
  11. 2 2
      bi-server/src/main/java/com/usoftchina/bi/server/service/chart/ShowPopulationService.java
  12. 2 2
      bi-server/src/main/java/com/usoftchina/bi/server/service/chart/ShowScatterService.java
  13. 17 7
      bi-server/src/main/java/com/usoftchina/bi/server/service/dashboard/DashboardsService.java
  14. 10 10
      bi-server/src/main/java/com/usoftchina/bi/server/service/dataSource/ColumnScreenService.java
  15. 1 1
      bi-server/src/main/java/com/usoftchina/bi/server/service/dataSource/DataBasesService.java
  16. 2 2
      bi-server/src/main/java/com/usoftchina/bi/server/service/dataSource/DataConnectorService.java
  17. 1 0
      bi-server/src/main/java/com/usoftchina/bi/server/service/dataSource/ImplementSqlService.java
  18. 1 1
      bi-server/src/test/java/com/usoftchina/bi/test/server/TestDataSource.java

+ 7 - 7
bi-core/src/main/java/com/usoftchina/bi/core/jdbc/DynamicDataSourceContextHolder.java

@@ -10,25 +10,25 @@ import java.util.Set;
 public class DynamicDataSourceContextHolder {
 
     //存放当前线程使用的数据源类型信息
-    private static final ThreadLocal<String> contextHolder = new ThreadLocal<String>();
+    private static final ThreadLocal<Object> contextHolder = new ThreadLocal<Object>();
     //存放数据源id
-    private static Set<String> dataSourceIds = new HashSet<String>();
+    private static Set<Object> dataSourceIds = new HashSet<Object>();
 
-    public static Set<String> getDataSourceIds() {
+    public static Set<Object> getDataSourceIds() {
         return dataSourceIds;
     }
 
-    public static void setDataSourceIds(Set<String> dataSourceIds) {
+    public static void setDataSourceIds(Set<Object> dataSourceIds) {
         DynamicDataSourceContextHolder.dataSourceIds = dataSourceIds;
     }
 
     //设置数据源
-    public static void setDataSourceType(String dataSourceType) {
+    public static void setDataSourceType(Object dataSourceType) {
         contextHolder.set(dataSourceType);
     }
 
     //获取数据源
-    public static String getDataSourceType() {
+    public static Object getDataSourceType() {
         return contextHolder.get();
     }
 
@@ -38,7 +38,7 @@ public class DynamicDataSourceContextHolder {
     }
 
     //判断当前数据源是否存在
-    public static boolean isContainsDataSource(String dataSourceId) {
+    public static boolean isContainsDataSource(Object dataSourceId) {
         return dataSourceIds.contains(dataSourceId);
     }
 }

+ 7 - 7
bi-core/src/main/java/com/usoftchina/bi/core/jdbc/DynamicDataSourceRegister.java

@@ -31,7 +31,7 @@ public class DynamicDataSourceRegister implements ImportBeanDefinitionRegistrar,
     //默认数据源
     private DataSource defaultDataSource;
     //用户自定义数据源
-    private Map<String, DataSource> slaveDataSources = new HashMap<>();
+    private Map<Object, DataSource> slaveDataSources = new HashMap<>();
 
     private static final Logger LOGGER = LoggerFactory.getLogger(DynamicDataSourceRegister.class);
 
@@ -45,11 +45,11 @@ public class DynamicDataSourceRegister implements ImportBeanDefinitionRegistrar,
         this.defaultDataSource = defaultDataSource;
     }
 
-    public Map<String, DataSource> getSlaveDataSources() {
+    public Map<Object, DataSource> getSlaveDataSources() {
         return slaveDataSources;
     }
 
-    public void setSlaveDataSources(Map<String, DataSource> slaveDataSources) {
+    public void setSlaveDataSources(Map<Object, DataSource> slaveDataSources) {
         this.slaveDataSources = slaveDataSources;
     }
 
@@ -105,7 +105,7 @@ public class DynamicDataSourceRegister implements ImportBeanDefinitionRegistrar,
                 dsMap.put("username", rs.getString("user_name"));
                 dsMap.put("password", rs.getString("pass_word"));
                 DataSource ds = buildDataSource(dsMap);
-                slaveDataSources.put(rs.getString("id"), ds);
+                slaveDataSources.put(rs.getInt("id"), ds);
             }
         } catch (ClassNotFoundException e) {
             e.printStackTrace();
@@ -127,13 +127,13 @@ public class DynamicDataSourceRegister implements ImportBeanDefinitionRegistrar,
     public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, BeanDefinitionRegistry beanDefinitionRegistry) {
         //添加默认数据源
         targetDataSources.put("dataSource", this.defaultDataSource);
-        Set<String> dataSourceIds = DynamicDataSourceContextHolder.getDataSourceIds();
+        Set<Object> dataSourceIds = DynamicDataSourceContextHolder.getDataSourceIds();
         dataSourceIds.add(String.valueOf(dataSourceIds));
         DynamicDataSourceContextHolder.setDataSourceIds(dataSourceIds);
         //添加其他数据源
         targetDataSources.putAll(slaveDataSources);
-        Set<String> dataSourceIdSet = DynamicDataSourceContextHolder.getDataSourceIds();
-        for (String key : slaveDataSources.keySet()) {
+        Set<Object> dataSourceIdSet = DynamicDataSourceContextHolder.getDataSourceIds();
+        for (Object key : slaveDataSources.keySet()) {
             dataSourceIdSet.add(key);
         }
         DynamicDataSourceContextHolder.setDataSourceIds(dataSourceIdSet);

+ 4 - 4
bi-server/src/main/java/com/usoftchina/bi/server/aspect/DynamicDattaSourceAspect.java

@@ -52,11 +52,11 @@ public class DynamicDattaSourceAspect {
         }
         int baseId = toSql.getId();
 
-        if (!DynamicDataSourceContextHolder.isContainsDataSource(String.valueOf(baseId))) {
-            logger.info("数据源 -> {} 不存在,使用默认的数据源 -> {}",String.valueOf(baseId), joinPoint.getSignature());
+        if (!DynamicDataSourceContextHolder.isContainsDataSource(baseId)) {
+            logger.info("数据源 -> {} 不存在,使用默认的数据源 -> {}",baseId, joinPoint.getSignature());
         } else {
-            logger.info("使用数据源:{}", String.valueOf(baseId));
-            DynamicDataSourceContextHolder.setDataSourceType(String.valueOf(baseId));
+            logger.info("使用数据源:{}", baseId);
+            DynamicDataSourceContextHolder.setDataSourceType(baseId);
         }
     }
 

+ 22 - 0
bi-server/src/main/java/com/usoftchina/bi/server/dao/dashboard/DashboardsMapper.java

@@ -91,6 +91,17 @@ public interface DashboardsMapper {
     @ResultMap("DashBoardsResultMap")
     List<Dashboards> getListDashboards(@Param("userId") int userId, TestPage testPage);
 
+    /*
+    查询看板列表
+     */
+    @Select("select id, bd_note as bdNote, bd_name as bdName, CONFIGURATION as bdConfiguration, CREATE_BY as createBy, create_id as createId, CREATE_DATE as createDate, BD_THUMBNAIL as thumbnail, filters, demo, bd_code,bd_menuId  " +
+            "from BI_DASHBOARDS where id in " +
+            " (select bo_da_id from bi_DASHBOARDS_object " +
+            "where (bo_type = '0' and bo_ob_id in (select br_user_group from bi_user_rel_groups)) " +
+            " or (BO_TYPE='1'))")
+    @ResultMap("DashBoardsResultMap")
+    List<Dashboards> getListDashboardsWithoutLimit(TestPage testPage);
+
     /*
     查询看板
      */
@@ -117,6 +128,17 @@ public interface DashboardsMapper {
     })
     Dashboards getDashboards(@Param("userId") int userId, @Param("id") int id);
 
+    /*
+   查询看板
+    */
+    @Select("select id, bd_note as bdNote, bd_name as bdName, CONFIGURATION as bdConfiguration, CREATE_BY as createBy, create_id as createId, CREATE_DATE as createDate, BD_THUMBNAIL as thumbnail, relation_columns as relationColumns, filters, demo, bd_code,bd_menuId " +
+            " from BI_DASHBOARDS where (id in " +
+            " (select bo_da_id from bi_DASHBOARDS_object " +
+            " where (bo_type = '0' and bo_ob_id in (select br_user_group from bi_user_rel_groups))" +
+            " or (BO_TYPE='1'))) and id = #{id}")
+    @ResultMap("DashBoardsResultMap")
+    Dashboards getDashboardsWithoutLimit(@Param("id") int id);
+
     @Select("SELECT id, bd_note as bdNote, bd_name as bdName, CONFIGURATION as bdConfiguration, CREATE_BY as createBy, create_id as createId, CREATE_DATE as createDate, BD_THUMBNAIL as thumbnail, relation_columns as relationColumns, filters, demo, bd_code,bd_menuId FROM BI_DASHBOARDS WHERE BD_CODE = #{code}")
     @ResultMap("DashBoardsResultMap")
     Dashboards getDashboardByCode(String code);

+ 11 - 4
bi-server/src/main/java/com/usoftchina/bi/server/service/chart/ChartsUtilService.java

@@ -1,5 +1,7 @@
 package com.usoftchina.bi.server.service.chart;
 
+import com.usoftchina.bi.core.base.BaseContextHolder;
+import com.usoftchina.bi.core.base.RoleConstant;
 import com.usoftchina.bi.core.utils.GetTokenDataUtil;
 import com.usoftchina.bi.server.dao.chart.ChartsConfigMapper;
 import com.usoftchina.bi.server.dao.dataSource.DataConnectorMapper;
@@ -32,6 +34,7 @@ public class ChartsUtilService {
     public String getSqlStr(String token, int id, int dashId) {
         Map<String, String> resultMap = GetTokenDataUtil.getTokenData(token);
         int userId = Integer.parseInt(resultMap.get("id"));
+        String role = resultMap.get("role");
         int createID;
         int baseId;
         try {
@@ -42,7 +45,7 @@ public class ChartsUtilService {
         }
         String tableName = chartsConfigMapper.getTableName(id);
         if (dashId == 0) {
-            if (userId == createID) {
+            if (userId == createID || RoleConstant.SUPER_ADMIN.getRole().equals(role)) {
                 //如果数据源创建人ID跟用户ID一样,获得数据源全部权限
                 if (tableName == null || "".equals(tableName)) {
                     return "";
@@ -62,7 +65,7 @@ public class ChartsUtilService {
     public String columnNameUtil(int userId, int baseId, String tableName, boolean isOrder, int id, int createBId){
         //用户不是创建人
         List<String> strList = new ArrayList<>();
-
+        String role = BaseContextHolder.getRole();
         if (isOrder){
             int baseCreateId;
             if (id != 0) {
@@ -70,13 +73,17 @@ public class ChartsUtilService {
             }else {
                 baseCreateId = createBId;
             }
-            if (baseCreateId == userId ){
+            if (baseCreateId == userId || RoleConstant.SUPER_ADMIN.getRole().equals(role)){
                 return "(" + tableName +")";
             }else {
                 strList = strategysBdMapper.getSqlStr(userId, baseId);
             }
         }else {
-            strList = strategysChartMapper.getSqlStr(userId, id);
+            if (RoleConstant.SUPER_ADMIN.getRole().equals(role)) {
+                return "(" + tableName +")";
+            }else {
+                strList = strategysChartMapper.getSqlStr(userId, id);
+            }
         }
 
         if (strList.size() == 0){

+ 2 - 2
bi-server/src/main/java/com/usoftchina/bi/server/service/chart/GetChartsDataUtilService.java

@@ -81,10 +81,10 @@ public class GetChartsDataUtilService {
         }
         List<Map<String, Object>> values = new ArrayList<>();
         try {
-            if (!DynamicDataSourceContextHolder.isContainsDataSource(String.valueOf(baseId))) {
+            if (!DynamicDataSourceContextHolder.isContainsDataSource(baseId)) {
                 return new RepEntity(RepCode.DataSourceNull);
             } else {
-                DynamicDataSourceContextHolder.setDataSourceType(String.valueOf(baseId));
+                DynamicDataSourceContextHolder.setDataSourceType(baseId);
             }
             values = chartsConfigMapper.getChartsData(sql, showDataChartInfo.getTestPage().enablePaging());
             PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(values);

+ 2 - 2
bi-server/src/main/java/com/usoftchina/bi/server/service/chart/ShowHistogramService.java

@@ -62,10 +62,10 @@ public class ShowHistogramService {
         int baseId = getChartsDataUtilService.getBaseId(id);
 
         try{
-            if (!DynamicDataSourceContextHolder.isContainsDataSource(String.valueOf(baseId))) {
+            if (!DynamicDataSourceContextHolder.isContainsDataSource(baseId)) {
                 return new RepEntity(RepCode.DataSourceNull);
             } else {
-                DynamicDataSourceContextHolder.setDataSourceType(String.valueOf(baseId));
+                DynamicDataSourceContextHolder.setDataSourceType(baseId);
             }
 
             String xColumn = histogramConfigInfo.getxAxis().getColumnRename();

+ 2 - 2
bi-server/src/main/java/com/usoftchina/bi/server/service/chart/ShowIndividualService.java

@@ -59,10 +59,10 @@ public class ShowIndividualService {
         int baseId = getChartsDataUtilService.getBaseId(id);
 
         try{
-            if (!DynamicDataSourceContextHolder.isContainsDataSource(String.valueOf(baseId))) {
+            if (!DynamicDataSourceContextHolder.isContainsDataSource(baseId)) {
                 return new RepEntity(RepCode.DataSourceNull);
             } else {
-                DynamicDataSourceContextHolder.setDataSourceType(String.valueOf(baseId));
+                DynamicDataSourceContextHolder.setDataSourceType(baseId);
             }
 
             //取筛选列表

+ 2 - 2
bi-server/src/main/java/com/usoftchina/bi/server/service/chart/ShowLineService.java

@@ -63,10 +63,10 @@ public class ShowLineService {
         int baseId = getChartsDataUtilService.getBaseId(id);
 
         try{
-            if (!DynamicDataSourceContextHolder.isContainsDataSource(String.valueOf(baseId))) {
+            if (!DynamicDataSourceContextHolder.isContainsDataSource(baseId)) {
                 return new RepEntity(RepCode.DataSourceNull);
             } else {
-                DynamicDataSourceContextHolder.setDataSourceType(String.valueOf(baseId));
+                DynamicDataSourceContextHolder.setDataSourceType(baseId);
             }
 
         String xColumn = lineConfigInfo.getxAxis().getColumnRename();

+ 2 - 2
bi-server/src/main/java/com/usoftchina/bi/server/service/chart/ShowPieService.java

@@ -55,10 +55,10 @@ public class ShowPieService {
 
         int baseId = getChartsDataUtilService.getBaseId(id);
         try{
-            if (!DynamicDataSourceContextHolder.isContainsDataSource(String.valueOf(baseId))) {
+            if (!DynamicDataSourceContextHolder.isContainsDataSource(baseId)) {
                 return new RepEntity(RepCode.DataSourceNull);
             } else {
-                DynamicDataSourceContextHolder.setDataSourceType(String.valueOf(baseId));
+                DynamicDataSourceContextHolder.setDataSourceType(baseId);
             }
 
         String xColumn = pieConfigInfo.getLegendData().getColumnRename();

+ 2 - 2
bi-server/src/main/java/com/usoftchina/bi/server/service/chart/ShowPopulationService.java

@@ -54,10 +54,10 @@ public class ShowPopulationService {
         int baseId = getChartsDataUtilService.getBaseId(id);
 
         try{
-            if (!DynamicDataSourceContextHolder.isContainsDataSource(String.valueOf(baseId))) {
+            if (!DynamicDataSourceContextHolder.isContainsDataSource(baseId)) {
                 return new RepEntity(RepCode.DataSourceNull);
             } else {
-                DynamicDataSourceContextHolder.setDataSourceType(String.valueOf(baseId));
+                DynamicDataSourceContextHolder.setDataSourceType(baseId);
             }
             List<String> groupByList = populationInfo.getGroupByList();  //分组
 

+ 2 - 2
bi-server/src/main/java/com/usoftchina/bi/server/service/chart/ShowScatterService.java

@@ -59,10 +59,10 @@ public class ShowScatterService {
         int baseId = getChartsDataUtilService.getBaseId(id);
 
         try{
-            if (!DynamicDataSourceContextHolder.isContainsDataSource(String.valueOf(baseId))) {
+            if (!DynamicDataSourceContextHolder.isContainsDataSource(baseId)) {
                 return new RepEntity(RepCode.DataSourceNull);
             } else {
-                DynamicDataSourceContextHolder.setDataSourceType(String.valueOf(baseId));
+                DynamicDataSourceContextHolder.setDataSourceType(baseId);
             }
 
         String xColumn = scatterConfigInfo.getxAxis().getColumnRename();

+ 17 - 7
bi-server/src/main/java/com/usoftchina/bi/server/service/dashboard/DashboardsService.java

@@ -3,7 +3,7 @@ package com.usoftchina.bi.server.service.dashboard;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.usoftchina.bi.core.base.BaseContextHolder;
+import com.usoftchina.bi.core.base.*;
 import com.usoftchina.bi.core.exception.MyException;
 import com.usoftchina.bi.core.utils.EncryUtil;
 import com.usoftchina.bi.server.dao.chart.ChartsConfigMapper;
@@ -15,9 +15,6 @@ import com.usoftchina.bi.server.model.bo.DashOrder;
 import com.usoftchina.bi.server.model.bo.ShareReqBO;
 import com.usoftchina.bi.server.model.po.ChartConfig;
 import com.usoftchina.bi.server.model.po.Dashboards;
-import com.usoftchina.bi.core.base.RepCode;
-import com.usoftchina.bi.core.base.RepEntity;
-import com.usoftchina.bi.core.base.TestPage;
 import com.usoftchina.bi.server.model.vo.configVo.ChangeOrderInfo;
 import com.usoftchina.bi.server.model.vo.configVo.DashboardsInfo;
 import com.usoftchina.bi.server.model.vo.dataVo.DashboardCopyInfo;
@@ -186,7 +183,13 @@ public class DashboardsService {
      */
     public RepEntity getListDashboards(String token, TestPage testPage) {
         int id = BaseContextHolder.getUserId();
-        List<Dashboards> getListDashboards = dashboardsMapper.getListDashboards(id, testPage.enablePaging());
+        String role = BaseContextHolder.getRole();
+        List<Dashboards> getListDashboards = new ArrayList<>();
+        if (RoleConstant.SUPER_ADMIN.getRole().equals(role)) {
+            getListDashboards = dashboardsMapper.getListDashboardsWithoutLimit(testPage.enablePaging());
+        }else {
+            getListDashboards = dashboardsMapper.getListDashboards(id, testPage.enablePaging());
+        }
         PageInfo<Dashboards> pageInfo = new PageInfo<>(getListDashboards);
         return new RepEntity(RepCode.success, pageInfo);
     }
@@ -196,7 +199,13 @@ public class DashboardsService {
      */
     public RepEntity getDashboards(String token, int id) {
         int userId = BaseContextHolder.getUserId();
-        Dashboards dashboards = dashboardsMapper.getDashboards(userId, id);
+        String role = BaseContextHolder.getRole();
+        Dashboards dashboards = new Dashboards();
+        if (RoleConstant.SUPER_ADMIN.getRole().equals(role)) {
+            dashboards = dashboardsMapper.getDashboardsWithoutLimit(id);
+        }else {
+            dashboards = dashboardsMapper.getDashboards(userId, id);
+        }
         if (dashboards == null){
             return new RepEntity(RepCode.DashboardNonExistent);
         }
@@ -286,8 +295,9 @@ public class DashboardsService {
      */
     public RepEntity changeDashOrder(String token, ChangeOrderInfo changeOrderInfo) {
         int userId = BaseContextHolder.getUserId();
+        String role = BaseContextHolder.getRole();
         int createId = dashboardsMapper.getCreateIdById(changeOrderInfo.getId());
-        if (userId != createId) {
+        if (userId != createId && !RoleConstant.SUPER_ADMIN.getRole().equals(role)) {
             return new RepEntity(RepCode.NoAuthority);
         }
         String name = userMapper.getName(changeOrderInfo.getUserId());

+ 10 - 10
bi-server/src/main/java/com/usoftchina/bi/server/service/dataSource/ColumnScreenService.java

@@ -41,15 +41,15 @@ public class ColumnScreenService {
         List<Object> data = new ArrayList<>();
 
         int baseId = getChartsDataUtilService.getBaseId(id);
-        logger.info("切换数据库: {}", String.valueOf(baseId));
+        logger.info("切换数据库: {}", baseId);
 
         try{
-            if (!DynamicDataSourceContextHolder.isContainsDataSource(String.valueOf(baseId))) {
-                logger.info("数据源:{} 不存在,使用默认的数据源", String.valueOf(baseId));
+            if (!DynamicDataSourceContextHolder.isContainsDataSource(baseId)) {
+                logger.info("数据源:{} 不存在,使用默认的数据源", baseId);
                 return new RepEntity(RepCode.DataSourceNull);
             } else {
-                logger.info("使用数据源:{}", String.valueOf(baseId));
-                DynamicDataSourceContextHolder.setDataSourceType(String.valueOf(baseId));
+                logger.info("使用数据源:{}", baseId);
+                DynamicDataSourceContextHolder.setDataSourceType(baseId);
             }
             data =  showChartsMapper.getScreenData(columnScreenInfo.getColumnName(), tableName, columnScreenInfo.getKeyword(), columnScreenInfo.getCount());
         }catch (Exception e){
@@ -80,15 +80,15 @@ public class ColumnScreenService {
         List<Object> data = new ArrayList<>();
 
         int baseId =  getChartsDataUtilService.getBaseIdByConnect(connectId);
-        logger.info("切换数据库={}", String.valueOf(baseId));
+        logger.info("切换数据库={}", baseId);
 
         try{
-            if (!DynamicDataSourceContextHolder.isContainsDataSource(String.valueOf(baseId))) {
-                logger.info("数据源: {}不存在,使用默认的数据源", String.valueOf(baseId));
+            if (!DynamicDataSourceContextHolder.isContainsDataSource(baseId)) {
+                logger.info("数据源: {}不存在,使用默认的数据源", baseId);
                 return new RepEntity(RepCode.DataSourceNull);
             } else {
-                logger.info("使用数据源:{}", String.valueOf(baseId));
-                DynamicDataSourceContextHolder.setDataSourceType(String.valueOf(baseId));
+                logger.info("使用数据源:{}", baseId);
+                DynamicDataSourceContextHolder.setDataSourceType(baseId);
             }
             data =  showChartsMapper.getScreenData(columnScreenInfo.getColumnName(), tableName, columnScreenInfo.getKeyword(), columnScreenInfo.getCount());
         }catch (Exception e){

+ 1 - 1
bi-server/src/main/java/com/usoftchina/bi/server/service/dataSource/DataBasesService.java

@@ -239,7 +239,7 @@ public class DataBasesService {
             datasource.setTargetDataSources(target);
             datasource.afterPropertiesSet();
 
-            Set<String> dataSourceIds = DynamicDataSourceContextHolder.getDataSourceIds();
+            Set<Object> dataSourceIds = DynamicDataSourceContextHolder.getDataSourceIds();
 
             dataSourceIds.add(String.valueOf(databasesInfo.getId()));
 

+ 2 - 2
bi-server/src/main/java/com/usoftchina/bi/server/service/dataSource/DataConnectorService.java

@@ -381,11 +381,11 @@ public class DataConnectorService {
         String sqls = chartsUtilService.columnNameUtil(id, dataId, sql, true, 0, createId);
 
         try {
-            if (!DynamicDataSourceContextHolder.isContainsDataSource(String.valueOf(baseId))) {
+            if (!DynamicDataSourceContextHolder.isContainsDataSource(baseId)) {
                 logger.info("数据源:{} 不存在, 使用默认的数据源", baseId);
             } else {
                 logger.info("使用数据源:", baseId);
-                DynamicDataSourceContextHolder.setDataSourceType(String.valueOf(baseId));
+                DynamicDataSourceContextHolder.setDataSourceType(baseId);
             }
             List<Map<String, Object>> val = new ArrayList<>();
             if (id == createId) {

+ 1 - 0
bi-server/src/main/java/com/usoftchina/bi/server/service/dataSource/ImplementSqlService.java

@@ -1,6 +1,7 @@
 package com.usoftchina.bi.server.service.dataSource;
 
 import com.usoftchina.bi.core.exception.MyException;
+import com.usoftchina.bi.core.jdbc.DynamicDataSourceContextHolder;
 import com.usoftchina.bi.server.dao.dataSource.DataColumnMapper;
 import com.usoftchina.bi.server.dao.dataSource.DataConnectorMapper;
 import com.usoftchina.bi.server.model.bo.ToSql;

+ 1 - 1
bi-server/src/test/java/com/usoftchina/bi/test/server/TestDataSource.java

@@ -72,7 +72,7 @@ public class TestDataSource{
         datasource.setTargetDataSources(target);
         datasource.afterPropertiesSet();
 
-        Set<String> dataSourceIds = DynamicDataSourceContextHolder.getDataSourceIds();
+        Set<Object> dataSourceIds = DynamicDataSourceContextHolder.getDataSourceIds();
         dataSourceIds.add("UAS_TEST");
         DynamicDataSourceContextHolder.setDataSourceIds(dataSourceIds);