Browse Source

feat 日志增加行数

wangrui 5 months ago
parent
commit
17466827c4

+ 3 - 3
platomix-gmetry-bi-api/pom.xml

@@ -16,17 +16,17 @@
         <dependency>
             <groupId>com.platomix</groupId>
             <artifactId>platomix-gmetry-framework</artifactId>
-            <version>2.3.4</version>
+            <version>2.3.5</version>
         </dependency>
         <dependency>
             <groupId>com.platomix</groupId>
             <artifactId>platomix-gmetry-system-client</artifactId>
-            <version>1.1.11</version>
+            <version>1.1.12</version>
         </dependency>
         <dependency>
             <groupId>com.platomix</groupId>
             <artifactId>platomix-gmetry-bi-client</artifactId>
-            <version>1.1.27</version>
+            <version>1.1.28</version>
         </dependency>
         <dependency>
             <groupId>com.platomix</groupId>

+ 0 - 24
platomix-gmetry-bi-api/src/main/java/org/springblade/config/MyConfig.java

@@ -1,24 +0,0 @@
-package org.springblade.config;
-
-import org.springframework.context.annotation.Bean;
-import org.springframework.core.task.TaskExecutor;
-import org.springframework.scheduling.annotation.EnableAsync;
-import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
-
-import java.util.concurrent.ThreadPoolExecutor;
-
-@EnableAsync
-public class MyConfig {
-
-    @Bean
-    public TaskExecutor executor(){
-        ThreadPoolTaskExecutor executor=new ThreadPoolTaskExecutor();
-        executor.setCorePoolSize(10); //核心线程数
-        executor.setMaxPoolSize(20);  //最大线程数
-        executor.setQueueCapacity(1000); //队列大小
-        executor.setKeepAliveSeconds(300); //线程最大空闲时间
-        executor.setThreadNamePrefix("fsx-Executor-"); //指定用于新创建的线程名称的前缀。
-        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
-        return executor;
-    }
-}

+ 1 - 1
platomix-gmetry-bi-api/src/main/java/org/springblade/cube/controller/CubeDataController.java

@@ -407,7 +407,7 @@ public class CubeDataController extends BladeController {
         //获取数据源
         ReportDatasource datasource = reportDatasourceService.getByDsId(datasourceId);
         if (datasource == null) {
-            throw new ServiceException("数据源不存在");
+            throw new ServiceException("当前代码行数:"+Thread.currentThread().getStackTrace()[1].getLineNumber()+"数据源不存在");
         }
         List<TableColumnDto> reportColumnList = dialectContext.getDialect(datasource.getDsTypeSyl()).listTableColumnsByTableViewName(datasource, tableName);
         if (reportColumnList.isEmpty()) {

+ 2 - 0
platomix-gmetry-bi-api/src/main/java/org/springblade/cube/model/CubeTableColumn.java

@@ -44,6 +44,8 @@ public class CubeTableColumn extends TenantAppEntity implements Serializable {
 
     @ApiModelProperty("数据集ID")
     private Integer cubeDataId;
+    @ApiModelProperty("数据集字段业务ID")
+    private Integer cubeTableColumnId;
 
     public void setCubeDataId(Integer cubeDataId) {
         this.cubeDataId = cubeDataId;

+ 7 - 7
platomix-gmetry-bi-api/src/main/java/org/springblade/cube/service/CubeDataBrowserService.java

@@ -109,7 +109,7 @@ public class CubeDataBrowserService {
 
         ReportDatasource reportDatasource = reportDatasourceService.getByDsId(cubeData.getDatasourceId());
         if (reportDatasource == null) {
-            throw new ServiceException("数据源不存在");
+            throw new ServiceException("当前代码行数:"+Thread.currentThread().getStackTrace()[1].getLineNumber()+"数据源不存在");
         }
         DsTypeEnum dsTypeEnum = DsTypeEnum.resolve(reportDatasource.getDsType());
         String fromSql = cubeData.getQuerySql();
@@ -223,7 +223,7 @@ public class CubeDataBrowserService {
 
         ReportDatasource reportDatasource = reportDatasourceService.getByDsId(cubeData.getDatasourceId());
         if (reportDatasource == null) {
-            throw new ServiceException("数据源不存在");
+            throw new ServiceException("当前代码行数:"+Thread.currentThread().getStackTrace()[1].getLineNumber()+"数据源不存在");
         }
         DsTypeEnum dsTypeEnum = DsTypeEnum.resolve(reportDatasource.getDsType());
         String fromSql = cubeData.getQuerySql();
@@ -380,7 +380,7 @@ public class CubeDataBrowserService {
         }
         ReportDatasource reportDatasource = reportDatasourceService.getByDsId(cubeData.getDatasourceId());
         if (reportDatasource == null) {
-            throw new ServiceException("数据源不存在");
+            throw new ServiceException("当前代码行数:"+Thread.currentThread().getStackTrace()[1].getLineNumber()+"数据源不存在");
         }
         DsTypeEnum dsTypeEnum = DsTypeEnum.resolve(reportDatasource.getDsType());
         // 构造Select模块
@@ -518,7 +518,7 @@ public class CubeDataBrowserService {
         }
         ReportDatasource reportDatasource = reportDatasourceService.getByDsId(cubeData.getDatasourceId());
         if (reportDatasource == null) {
-            throw new ServiceException("数据源不存在");
+            throw new ServiceException("当前代码行数:"+Thread.currentThread().getStackTrace()[1].getLineNumber()+"数据源不存在");
         }
         DsTypeEnum dsTypeEnum = DsTypeEnum.resolve(reportDatasource.getDsType());
         // 构造Select模块
@@ -539,9 +539,9 @@ public class CubeDataBrowserService {
         for (CubeTableColumn column : columnList) {
             masterTableColumnMap.put(column.getId(), column.getColumnName());
             //获取别名
-            String tableColumnAlias = masterTableColumnAliasMap.get(column.getId());
+            String tableColumnAlias = masterTableColumnAliasMap.get(column.getCubeTableColumnId());
             // 计算字段包含聚合函数 OR 列权限包含该列,不做查询
-            if (StrUtil.isBlank(tableColumnAlias) || Optional.<Integer>ofNullable(column.getVirtualAggregationStatus()).orElse(0) == 1 || excludeColumnIdSet.contains(column.getId())) {
+            if (StrUtil.isBlank(tableColumnAlias) || Optional.<Integer>ofNullable(column.getVirtualAggregationStatus()).orElse(0) == 1 || excludeColumnIdSet.contains(column.getCubeTableColumnId())) {
                 continue;
             }
             // 处理全局参数变量
@@ -565,7 +565,7 @@ public class CubeDataBrowserService {
             selectSqlList.add(selectColumnName + " as \"" + tableColumnAlias + "\"");
             // 是否包含在查询参数中
 //            BrowserParam browserParam = CollectionUtil.isNotEmpty(paramList) ? paramList.stream().filter(item -> item.getCubeColumnId().equals(column.getId())).findFirst().orElse(null) : null;
-            List<BrowserParam> collect = paramList.stream().filter(item -> item.getCubeColumnId().equals(column.getId())).collect(Collectors.toList());
+            List<BrowserParam> collect = paramList.stream().filter(item -> item.getCubeColumnId().equals(column.getCubeTableColumnId())).collect(Collectors.toList());
             if (CollectionUtil.isNotEmpty(collect)) {
                 for (BrowserParam browserParam : collect) {
                     String conditionSql = browserParam.getFunction().handle(queryColumnName, column.getViewDataType(), browserParam.getValues(), dsTypeEnum);

+ 2 - 0
platomix-gmetry-bi-api/src/main/java/org/springblade/cube/service/CubeDataService.java

@@ -19,6 +19,7 @@ import org.springblade.cube.model.CubeDataPermission;
 import org.springblade.cube.model.CubeSqlView;
 import org.springblade.cube.model.CubeTableColumn;
 import org.springblade.cube.utils.CubeConstants;
+import org.springblade.cube.utils.SnowFlowIntUtil;
 import org.springblade.datasource.context.DialectContext;
 import org.springblade.datasource.enums.DsTypeEnum;
 import org.springblade.datasource.model.TableColumnDto;
@@ -103,6 +104,7 @@ public class CubeDataService extends ServiceImpl<CubeDataMapper, CubeData> {
 			for(CubeTableColumn tableColumn : columnList) {
 				tableColumn.setCubeDataId(cubeData.getCubeId());
 				tableColumn.setTenantId(bladeUser.getTenantId());
+				tableColumn.setCubeTableColumnId(SnowFlowIntUtil.nextId());
 				if(tableColumn.getId() == null || tableColumn.getId() <= 0) {
 					tableColumn.setId(null);
 					addList.add(tableColumn);

+ 2 - 2
platomix-gmetry-bi-api/src/main/java/org/springblade/cube/service/CubeTableStaticService.java

@@ -97,7 +97,7 @@ public class CubeTableStaticService extends ServiceImpl<CubeTableStaticMapper, C
         //获取数据源
         ReportDatasource datasource = reportDatasourceService.getByDsId(dataParam.getDatasourceId());
         if (datasource == null) {
-            throw new ServiceException("数据源不存在");
+            throw new ServiceException("当前代码行数:"+Thread.currentThread().getStackTrace()[1].getLineNumber()+"数据源不存在");
         }
         //系统默认设置表名[表名注意大小写的问题]
         dataParam.setTableName("STATIC_TABLE_" + DateUtil.format(new Date(), "yyyyMMddHHmmss") + RandomUtil.randomNumbers(1));
@@ -163,7 +163,7 @@ public class CubeTableStaticService extends ServiceImpl<CubeTableStaticMapper, C
         //获取数据源
         ReportDatasource datasource = reportDatasourceService.getByDsId(param.getDatasourceId());
         if (datasource == null) {
-            throw new ServiceException("数据源不存在");
+            throw new ServiceException("当前代码行数:"+Thread.currentThread().getStackTrace()[1].getLineNumber()+"数据源不存在");
         }
         List<CubeData> salveCubeDataList = new ArrayList<>();
         HashMap<String, Object> hashMap = new HashMap<>();

+ 1 - 1
platomix-gmetry-bi-api/src/main/java/org/springblade/report/controller/TableCategoryController.java

@@ -219,7 +219,7 @@ public class TableCategoryController extends BladeController {
 		String sqlStatement = "alter table " + tableViewName + " comment '" + tableComments + "'";
 		ReportDatasource reportDatasource = reportDatasourceService.getByDsId(datasourceId);
 		if(reportDatasource == null) {
-			throw new ServiceException("数据源不存在");
+			throw new ServiceException("当前代码行数:"+Thread.currentThread().getStackTrace()[1].getLineNumber()+"数据源不存在");
 		}
 		// 0-mysql 1-oracle 2-sqlserver 3-postgresql 4-clickhouse 5-kingbase
 		if (reportDatasource.getDsType() == 1 || reportDatasource.getDsType() == 5 || reportDatasource.getDsType() == 3){

+ 32 - 7
platomix-gmetry-bi-api/src/main/java/org/springblade/resouces/AppCopyService.java

@@ -1,6 +1,7 @@
 package org.springblade.resouces;
 
 import cn.hutool.core.exceptions.ExceptionUtil;
+import cn.hutool.json.JSONUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.cube.model.*;
@@ -59,34 +60,40 @@ public class AppCopyService {
     @Resource
     private AppClient appClient;
     @Async
-    public boolean copy(List<Integer> cubeIds, List<Integer> dsIds, String appId, PlatomixAppCopyLogModel platomixAppCopyLogModel) {
+    public void copy(List<Integer> cubeIds, List<Integer> dsIds, String appId, PlatomixAppCopyLogModel platomixAppCopyLogModel) {
 
         try {
             long start = System.currentTimeMillis();
             copyCube(cubeIds, appId);
+            platomixAppCopyLogModel.setCubeResult(0);
+            appClient.taskInfo(platomixAppCopyLogModel);
             System.out.println("copyCube 时长=" + (start - System.currentTimeMillis()));
         } catch (Exception e) {
             platomixAppCopyLogModel.setCubeResult(1);
             platomixAppCopyLogModel.setErrorInfo(ExceptionUtil.stacktraceToString(e));
             appClient.taskInfo(platomixAppCopyLogModel);
-            return false;
+            log.error("copyCube复制失败:"+ExceptionUtil.stacktraceToString(e));
         }
         try {
             long start1 = System.currentTimeMillis();
             copyDs(dsIds, appId, platomixAppCopyLogModel);
+            platomixAppCopyLogModel.setDsResult(0);
+            appClient.taskInfo(platomixAppCopyLogModel);
             System.out.println("start1 时长=" + (start1 - System.currentTimeMillis()));
         } catch (Exception e) {
             platomixAppCopyLogModel.setDsResult(1);
             platomixAppCopyLogModel.setErrorInfo(ExceptionUtil.stacktraceToString(e));
             appClient.taskInfo(platomixAppCopyLogModel);
-            return false;
+            log.error("数据源 复制失败:"+ExceptionUtil.stacktraceToString(e));
         }
 
-        return true;
     }
 
     private void copyDs(List<Integer> dsIds, String appId, PlatomixAppCopyLogModel platomixAppCopyLogModel) {
-        List<ReportDatasource> list = reportDatasourceService.lambdaQuery().in(ReportDatasource::getDsId, dsIds).list();
+        List<ReportDatasource> list = reportDatasourceService.lambdaQuery()
+                .in(ReportDatasource::getDsId, dsIds)
+                .eq(ReportDatasource::getAppId,appId)
+                .list();
         List<Integer> collect = list.stream().map(ReportDatasource::getDsId).collect(Collectors.toList());
         if (!list.isEmpty()) {
             List<Integer> newIds = new ArrayList<>();
@@ -98,7 +105,13 @@ public class AppCopyService {
             }
             dsIds = newIds;
         }
+
         long start1 = System.currentTimeMillis();
+        if (dsIds.isEmpty()){
+            platomixAppCopyLogModel.setDbResult(0);
+            appClient.taskInfo(platomixAppCopyLogModel);
+            return;
+        }
         if (!reportDatasourceService(dsIds, appId, platomixAppCopyLogModel)) {
             return;
         }
@@ -184,11 +197,16 @@ public class AppCopyService {
         List<ReportDatasource> list = reportDatasourceService.lambdaQuery().in(ReportDatasource::getDsId, dsIds).list();
         List<ReportDatasource> copy = null;
         try {
+            String jsonStr = JSONUtil.toJsonStr(list);
+            System.out.println("数据库复制参数"+jsonStr);
             copy = dsHandler.copy(list);
+            platomixAppCopyLogModel.setDbResult(0);
+            appClient.taskInfo(platomixAppCopyLogModel);
         } catch (Exception e) {
-            platomixAppCopyLogModel.setDsResult(1);
+            platomixAppCopyLogModel.setDbResult(1);
             platomixAppCopyLogModel.setErrorInfo(ExceptionUtil.stacktraceToString(e));
             appClient.taskInfo(platomixAppCopyLogModel);
+            log.error("数据库 复制失败:"+ExceptionUtil.stacktraceToString(e));
             return false;
         }
         for (ReportDatasource obj : copy) {
@@ -203,7 +221,10 @@ public class AppCopyService {
     }
 
     private void copyCube(List<Integer> ids, String appId) {
-        List<CubeData> list = cubeDataService.lambdaQuery().in(CubeData::getCubeId, ids).eq(CubeData::getAppId, appId).list();
+        List<CubeData> list = cubeDataService.lambdaQuery()
+                .in(CubeData::getCubeId, ids)
+                .eq(CubeData::getAppId, appId)
+                .list();
         List<Integer> collect = list.stream().map(CubeData::getCubeId).collect(Collectors.toList());
         if (!list.isEmpty()) {
             List<Integer> newIds = new ArrayList<>();
@@ -215,6 +236,9 @@ public class AppCopyService {
             }
             ids = newIds;
         }
+        if (ids.isEmpty()) {
+            return;
+        }
         cubeDataService(ids, appId);
         cubeDataPermissionService(ids, appId);
         cubeTableColumnService(ids, appId);
@@ -237,6 +261,7 @@ public class AppCopyService {
         for (CubeTableColumn obj : list) {
             obj.setId(null);
             obj.setAppId(appId);
+            obj.setCubeTableColumnId(SnowFlowIntUtil.nextId());
             cubeTableColumnService.save(obj);
         }
     }

+ 2 - 2
platomix-gmetry-bi-api/src/main/java/org/springblade/resouces/CubeDataResouce.java

@@ -115,13 +115,13 @@ public class CubeDataResouce implements CubeDataClient {
     }
 
     @Override
-    public boolean copy( AppCopyParams appCopyParams) {
+    public void copy( AppCopyParams appCopyParams) {
         String appId = appCopyParams.getAppId();
         List<Integer> cubeIds = appCopyParams.getCubeIds();
         List<Integer> dsIds = appCopyParams.getDsIds();
         String platomixAppCopyLogModelStr = appCopyParams.getPlatomixAppCopyLogModelStr();
         PlatomixAppCopyLogModel platomixAppCopyLogModel = JSONUtil.toBean(platomixAppCopyLogModelStr, PlatomixAppCopyLogModel.class);
-        return  appCopyService.copy( cubeIds,dsIds,appId,platomixAppCopyLogModel);
+          appCopyService.copy( cubeIds,dsIds,appId,platomixAppCopyLogModel);
 
     }
 

+ 1 - 1
platomix-gmetry-bi-api/src/main/java/org/springblade/visual/service/DefineGroupSqlService.java

@@ -95,7 +95,7 @@ public class DefineGroupSqlService {
 		//2.查询数据源
 		ReportDatasource reportDatasource = reportDatasourceService.getByDsId(cubeData.getDatasourceId());
 		if(reportDatasource == null) {
-			log.error("数据源不存在|id={}", cubeData.getDatasourceId());
+			log.error("当前代码行数:"+Thread.currentThread().getStackTrace()[1].getLineNumber()+"数据源不存在|id={}", cubeData.getDatasourceId());
 			return R.fail("数据源不存在");
 		}
 		DsTypeEnum dsTypeEnum = DsTypeEnum.resolve(reportDatasource.getDsType());

+ 2 - 2
platomix-gmetry-bi-api/src/main/java/org/springblade/visual/service/QuerySqlService.java

@@ -106,7 +106,7 @@ public class QuerySqlService {
         //2.查询数据源
         ReportDatasource reportDatasource = reportDatasourceService.getByDsId(cubeData.getDatasourceId());
         if (reportDatasource == null) {
-            log.error("数据源不存在|id={}", cubeData.getDatasourceId());
+            log.error("当前代码行数:"+Thread.currentThread().getStackTrace()[1].getLineNumber()+"数据源不存在|id={}", cubeData.getDatasourceId());
             return R.fail("数据源不存在");
         }
         return parseQuerySql(cubeData, reportDatasource, previewDto, bladeUser, compType);
@@ -461,7 +461,7 @@ public class QuerySqlService {
         //2.查询数据源
         ReportDatasource reportDatasource = reportDatasourceService.getByDsId(cubeData.getDatasourceId());
         if (reportDatasource == null) {
-            log.error("数据源不存在|id={}", cubeData.getDatasourceId());
+            log.error("当前代码行数:"+Thread.currentThread().getStackTrace()[1].getLineNumber()+"数据源不存在|id={}", cubeData.getDatasourceId());
             return R.fail("数据源不存在");
         }
         //遍历维度

+ 7 - 1
platomix-gmetry-bi-api/src/main/resources/application-test.yml

@@ -133,4 +133,10 @@ platomix:
             ip: 121.204.252.205
             port: 3306
             userName: root
-            passWord: Platomix@mysql123
+            passWord: Platomix@mysql123
+
+logging:
+   level:
+      org.springblade.bi.client.*: DEBUG
+      org.springblade.workflow.client.*: DEBUG
+      org.springblade.bi.client.CubeDataClient: DEBUG

+ 1 - 1
platomix-gmetry-bi-client/pom.xml

@@ -8,7 +8,7 @@
 		<version>1.0.0</version>
 	</parent>
 	<artifactId>platomix-gmetry-bi-client</artifactId>
-	<version>1.1.27</version>
+	<version>1.1.28</version>
 
 	<dependencies>
 		<dependency>

+ 1 - 1
platomix-gmetry-bi-client/src/main/java/org/springblade/bi/client/CubeDataClient.java

@@ -65,5 +65,5 @@ public interface CubeDataClient {
      * @return
      */
     @PostMapping(OpenFeignConstants.BI_SERVICE + "/cube/copy")
-    public boolean copy(@RequestBody AppCopyParams appCopyParams);
+    public void copy(@RequestBody AppCopyParams appCopyParams);
 }

+ 1 - 2
platomix-gmetry-bi-client/src/main/java/org/springblade/bi/client/factory/CubeDataClientFallbackFactory.java

@@ -51,8 +51,7 @@ public class CubeDataClientFallbackFactory implements FallbackFactory<CubeDataCl
 			}
 
 			@Override
-			public boolean copy(AppCopyParams appCopyParams) {
-				return false;
+			public void copy(AppCopyParams appCopyParams) {
 			}
 		};
 	}