fix() 修改测试数据的展示
parent
2a13586cf7
commit
28f98b4e9c
|
@ -35,7 +35,7 @@ public class DataAccessClientRunner implements ApplicationRunner {
|
|||
MyDataSource.size(key);
|
||||
Thread.sleep(500);
|
||||
System.out.println("取出一个链接,查看连接池:");
|
||||
Connection con = MyDataSource.getCon(key);
|
||||
Connection con = MyDataSource.getConnection(key);
|
||||
MyDataSource.size(key);
|
||||
Thread.sleep(500);
|
||||
System.out.println("返回一个链接,查看连接池:");
|
||||
|
|
|
@ -1,19 +1,24 @@
|
|||
package com.muyu.etl.datasource;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.etl.domain.DataSource;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.SQLFeatureNotSupportedException;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* @ClassName MyDataSource
|
||||
* @Description 描述
|
||||
* @Author Peng.Jiang
|
||||
* @Description 数据库连接池管理
|
||||
* @Author Xin.Yao
|
||||
* @Date 2024/5/9 19:36
|
||||
*/
|
||||
@Component
|
||||
|
@ -21,38 +26,51 @@ import java.util.List;
|
|||
public class MyDataSource {
|
||||
private static HashMap<String, DruidDataSource> pools = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 总数据库连接池初始化
|
||||
* @param dataSourceList
|
||||
*/
|
||||
public static void info(List<DataSource> dataSourceList){
|
||||
dataSourceList.stream().forEach(dataSource -> {
|
||||
String jdbcUrl = "jdbc:"+dataSource.getType().toLowerCase()+"://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName();
|
||||
String key = dataSource.getDataSourceName() + "-" + dataSource.getId();
|
||||
// 创建德鲁伊数据源
|
||||
DruidDataSource druidSource = new DruidDataSource();
|
||||
dataSourceList.stream().forEach(dataSource -> {
|
||||
String jdbcUrl = "jdbc:"+dataSource.getType().toLowerCase()+"://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName();
|
||||
String key = dataSource.getDataSourceName()+"_"+dataSource.getId();
|
||||
// 创建德鲁伊数据源
|
||||
DruidDataSource druidSource = new DruidDataSource();
|
||||
// 配置数据库连接信息
|
||||
druidSource.setUrl(jdbcUrl);
|
||||
druidSource.setUsername(dataSource.getUsername());
|
||||
druidSource.setPassword(dataSource.getPassword());
|
||||
// 配置连接池大小
|
||||
druidSource.setInitialSize(Integer.valueOf(dataSource.getInitNum().toString()));
|
||||
druidSource.setMinIdle(5);
|
||||
druidSource.setMaxActive(Integer.valueOf(dataSource.getMaxNum().toString()));
|
||||
try {
|
||||
druidSource.init();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
addDataSource(key,druidSource);
|
||||
});
|
||||
|
||||
// 配置数据库连接信息
|
||||
druidSource.setUrl(jdbcUrl);
|
||||
druidSource.setUsername(dataSource.getUsername());
|
||||
druidSource.setPassword(dataSource.getPassword());
|
||||
// 配置连接池大小
|
||||
druidSource.setInitialSize(Integer.valueOf(dataSource.getInitNum().toString()));
|
||||
druidSource.setMinIdle(5);
|
||||
druidSource.setMaxActive(Integer.valueOf(dataSource.getMaxNum().toString()));
|
||||
try {
|
||||
druidSource.init();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
pools.put(dataSource.getDataSourceName()+"_"+dataSource.getId(),druidSource);
|
||||
});
|
||||
}
|
||||
|
||||
//添加新的连接池
|
||||
/**
|
||||
* 添加新的连接池
|
||||
* @param key
|
||||
* @param druidDataSource
|
||||
*/
|
||||
public static void addDataSource(String key,DruidDataSource druidDataSource){
|
||||
if(!pools.containsKey(key)){
|
||||
if (!pools.containsKey(key)){
|
||||
pools.put(key,druidDataSource);
|
||||
}
|
||||
}
|
||||
|
||||
public static Connection getCon(String key) {
|
||||
/**
|
||||
* 根据 key 获取连接池中的连接
|
||||
* @param key
|
||||
* @return Connection
|
||||
*/
|
||||
public static Connection getConnection(String key){
|
||||
try {
|
||||
//根据key获取连接池
|
||||
DruidDataSource druidDataSource = pools.get(key);
|
||||
|
@ -63,7 +81,11 @@ public class MyDataSource {
|
|||
}
|
||||
}
|
||||
|
||||
// 4 提供非静态方法,用来归还链接
|
||||
/**
|
||||
* 归还连接池中的连接
|
||||
* @param connection
|
||||
*/
|
||||
|
||||
public static void addBack(Connection connection){
|
||||
try {
|
||||
connection.close();
|
||||
|
@ -72,7 +94,15 @@ public class MyDataSource {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 key 查看连接池连接信息
|
||||
* @param key
|
||||
*/
|
||||
public static void size(String key){
|
||||
for (String s : pools.keySet()) {
|
||||
log.info("连接池名称: "+s);
|
||||
}
|
||||
|
||||
//根据key获取连接池
|
||||
DruidDataSource druidDataSource = pools.get(key);
|
||||
//获取正在使用的连接数量
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package com.muyu.etl;
|
||||
|
||||
import com.muyu.common.core.constant.ServiceNameConstants;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.etl.domain.AssetModel;
|
||||
import com.muyu.etl.factory.DataAccessFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
@FeignClient(contextId = "remoteAssetModelService",
|
||||
value = ServiceNameConstants.DATA_ACCESS_SERVICE,
|
||||
fallbackFactory = DataAccessFallbackFactory.class)
|
||||
public interface RemoteAssetModelService {
|
||||
@PostMapping("/model/list")
|
||||
public Result<TableDataInfo<AssetModel>> list(@RequestBody AssetModel assetModel);
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.muyu.etl.factory;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.etl.RemoteAssetModelService;
|
||||
import com.muyu.etl.domain.AssetModel;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
|
||||
public class AssetModelFallbackFactory implements FallbackFactory<RemoteAssetModelService> {
|
||||
@Override
|
||||
public RemoteAssetModelService create(Throwable cause) {
|
||||
return new RemoteAssetModelService() {
|
||||
@Override
|
||||
public Result<TableDataInfo<AssetModel>> list(AssetModel assetModel) {
|
||||
return Result.error("获取数据模型列表失败");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -24,6 +24,18 @@
|
|||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-engine-common</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-data-access-client</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-modules-system</artifactId>
|
||||
|
|
|
@ -30,8 +30,8 @@ public class AssetModelController extends BaseController
|
|||
/**
|
||||
* 查询【请填写功能名称】列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<AssetModel>> list(AssetModel assetModel)
|
||||
@PostMapping("/list")
|
||||
public Result<TableDataInfo<AssetModel>> list(@RequestBody AssetModel assetModel)
|
||||
{
|
||||
startPage();
|
||||
List<AssetModel> list = assetModelService.selectAssetModelList(assetModel);
|
||||
|
|
|
@ -77,9 +77,9 @@ public class DataSourceController extends BaseController
|
|||
}
|
||||
|
||||
@PostMapping("/StructureList")
|
||||
public Result structureList(@RequestBody DataSource dataSource)
|
||||
public Result structureList(@RequestBody DataAsset dataAsset)
|
||||
{
|
||||
return dataSourceService.structureList(dataSource);
|
||||
return dataSourceService.structureList(dataAsset);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,15 +8,15 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* 【请填写功能名称】Service接口
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-04-20
|
||||
*/
|
||||
public interface IDataSourceService
|
||||
public interface IDataSourceService
|
||||
{
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
*
|
||||
*
|
||||
* @param id 【请填写功能名称】主键
|
||||
* @return 【请填写功能名称】
|
||||
*/
|
||||
|
@ -24,7 +24,7 @@ public interface IDataSourceService
|
|||
|
||||
/**
|
||||
* 查询【请填写功能名称】列表
|
||||
*
|
||||
*
|
||||
* @param dataSource 【请填写功能名称】
|
||||
* @return 【请填写功能名称】集合
|
||||
*/
|
||||
|
@ -32,7 +32,7 @@ public interface IDataSourceService
|
|||
|
||||
/**
|
||||
* 新增【请填写功能名称】
|
||||
*
|
||||
*
|
||||
* @param dataSource 【请填写功能名称】
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -40,7 +40,7 @@ public interface IDataSourceService
|
|||
|
||||
/**
|
||||
* 修改【请填写功能名称】
|
||||
*
|
||||
*
|
||||
* @param dataSource 【请填写功能名称】
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -48,7 +48,7 @@ public interface IDataSourceService
|
|||
|
||||
/**
|
||||
* 批量删除【请填写功能名称】
|
||||
*
|
||||
*
|
||||
* @param ids 需要删除的【请填写功能名称】主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -56,7 +56,7 @@ public interface IDataSourceService
|
|||
|
||||
/**
|
||||
* 删除【请填写功能名称】信息
|
||||
*
|
||||
*
|
||||
* @param id 【请填写功能名称】主键
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -66,7 +66,7 @@ public interface IDataSourceService
|
|||
|
||||
Result assetsList(DataSource dataSource);
|
||||
|
||||
Result structureList(DataSource dataSource);
|
||||
Result structureList(DataAsset dataAsset);
|
||||
|
||||
Result synchronousData(DataSource dataSource);
|
||||
|
||||
|
|
|
@ -251,8 +251,8 @@ public class DataSourceServiceImpl implements IDataSourceService
|
|||
* @return AssetsModule 包含查询结果和列信息的模块化对象。
|
||||
*/
|
||||
//获取数据模型的数据(KVT结构)
|
||||
public AssetsModule getStructure(DataSource dataSource){
|
||||
|
||||
public AssetsModule getStructure(DataAsset dataAsset){
|
||||
DataSource dataSource = dataSourceMapper.selectDataSourceById(dataAsset.getDataSourceId());
|
||||
String jdbcUrl = "jdbc:"+dataSource.getType().toLowerCase()+"://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName();
|
||||
if (dataSource.getConnectionParam()!=null && dataSource.getConnectionParam()!=""){
|
||||
jdbcUrl = jdbcUrl+"?"+dataSource.getConnectionParam();
|
||||
|
@ -287,7 +287,8 @@ public class DataSourceServiceImpl implements IDataSourceService
|
|||
for (int i = 1; i <= columnCount; i++) {
|
||||
// 获取列名和类型,并封装数据
|
||||
String columnName = rsd.getColumnName(i);
|
||||
String type = map.get(columnName);
|
||||
String[] split = rsd.getColumnClassName(i).split("\\.");
|
||||
String type = split[split.length-1];
|
||||
Object value = resultSet.getObject(i);
|
||||
if (value==null){
|
||||
stringVTClassHashMap.put(columnName,new VTClass("",type));
|
||||
|
@ -438,8 +439,8 @@ public class DataSourceServiceImpl implements IDataSourceService
|
|||
|
||||
@Override
|
||||
@Transactional
|
||||
public Result structureList(DataSource dataSource) {
|
||||
AssetsModule kvt = getStructure(dataSource);
|
||||
public Result structureList(DataAsset dataAsset) {
|
||||
AssetsModule kvt = getStructure(dataAsset);
|
||||
return Result.success(kvt);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,11 @@
|
|||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-data-access-common</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package com.muyu.rule.engine.req;
|
||||
|
||||
import com.muyu.etl.domain.DataAsset;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.poi.poifs.nio.DataSource;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DataSourceAssetModelReq {
|
||||
|
||||
private DataSource dataSource;
|
||||
|
||||
private DataAsset dataAsset;
|
||||
|
||||
}
|
|
@ -6,11 +6,11 @@ import lombok.Data;
|
|||
public class RecordModel {
|
||||
|
||||
private RecordModel(int dataModelLength){
|
||||
dataModelArr = new DataModel[dataModelLength];
|
||||
this.dataModelArr = new DataModel[dataModelLength];
|
||||
}
|
||||
|
||||
private RecordModel(DataModel[] dataModelArr){
|
||||
dataModelArr = dataModelArr;
|
||||
this.dataModelArr = dataModelArr;
|
||||
}
|
||||
|
||||
private DataModel[] dataModelArr = null;
|
||||
|
|
|
@ -1,19 +1,32 @@
|
|||
package com.muyu.rule.scope;
|
||||
|
||||
import com.muyu.rule.scope.model.DataProcessModel;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class DataModelContext implements ScopeContext <DataProcessModel>{
|
||||
|
||||
private static final ThreadLocal<DataProcessModel> THREAD_LOCAL = new ThreadLocal<>();
|
||||
|
||||
private final DataSetContext dataSetContext;
|
||||
private final RecordContext recordContext;
|
||||
|
||||
public DataModelContext (DataSetContext dataSetContext) {
|
||||
this.dataSetContext = dataSetContext;
|
||||
public DataModelContext (RecordContext recordContext) {
|
||||
this.recordContext = recordContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataProcessModel get () {
|
||||
return THREAD_LOCAL.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(DataProcessModel dataProcessModel){
|
||||
THREAD_LOCAL.set(dataProcessModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear(){
|
||||
THREAD_LOCAL.remove();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,15 +6,25 @@ public class DataSetContext implements ScopeContext <DataSetProcessModel>{
|
|||
|
||||
private static final ThreadLocal<DataSetProcessModel> THREAD_LOCAL = new ThreadLocal<>();
|
||||
|
||||
private final RecordContext recordContext;
|
||||
private final TaskContext taskContext;
|
||||
|
||||
public DataSetContext (RecordContext recordContext) {
|
||||
this.recordContext = recordContext;
|
||||
public DataSetContext (TaskContext taskContext) {
|
||||
this.taskContext = taskContext;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DataSetProcessModel get() {
|
||||
return THREAD_LOCAL.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear(){
|
||||
THREAD_LOCAL.remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(DataSetProcessModel dataSetProcessModel){
|
||||
THREAD_LOCAL.set(dataSetProcessModel);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,15 +8,29 @@ import com.muyu.rule.scope.model.RecordProcessModel;
|
|||
* @Description: 记录/资产模型
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public class RecordContext {
|
||||
public class RecordContext implements ScopeContext<RecordProcessModel>{
|
||||
|
||||
private static final ThreadLocal<RecordProcessModel> THREAD_LOCAL = new ThreadLocal<>();
|
||||
|
||||
private final TaskContext taskContext;
|
||||
private final DataSetContext dataSetContext;
|
||||
|
||||
private RecordContext (TaskContext taskContext) {
|
||||
this.taskContext = taskContext;
|
||||
private RecordContext (DataSetContext dataSetContext) {
|
||||
this.dataSetContext = dataSetContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecordProcessModel get() {
|
||||
return THREAD_LOCAL.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
THREAD_LOCAL.remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(RecordProcessModel recordProcessModel) {
|
||||
THREAD_LOCAL.set(recordProcessModel);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,4 +9,7 @@ package com.muyu.rule.scope;
|
|||
public interface ScopeContext<V> {
|
||||
|
||||
V get();
|
||||
void clear();
|
||||
void set(V v);
|
||||
|
||||
}
|
||||
|
|
|
@ -19,6 +19,12 @@
|
|||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-data-access-client</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-engine-common</artifactId>
|
||||
|
|
|
@ -6,7 +6,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.muyu.rule.engine.domain.EngineMaintenance;
|
||||
import com.muyu.rule.engine.service.IEngineMaintenanceService;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.List;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.muyu.rule.engine.domain.EngineMaintenance;
|
||||
import com.muyu.rule.engine.req.DataSourceAssetModelReq;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
|
@ -81,6 +82,14 @@ public class EngineVersionController extends BaseController
|
|||
return toAjax(engineVersionService.updateEngineVersion(engineVersion));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据域列表
|
||||
*/
|
||||
@PostMapping("/GetDataRegionList")
|
||||
public Result getDataRegionList(@RequestBody DataSourceAssetModelReq dataSourceAssetModelReq){
|
||||
return engineVersionService.getDataRegionList(dataSourceAssetModelReq);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成规则版本代码
|
||||
*/
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.rule.engine.service;
|
|||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.rule.engine.domain.EngineVersion;
|
||||
import com.muyu.rule.engine.req.DataSourceAssetModelReq;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -65,4 +66,6 @@ public interface IEngineVersionService
|
|||
|
||||
Result initializeRuleEngine(EngineVersion engineVersion);
|
||||
|
||||
Result getDataRegionList(DataSourceAssetModelReq dataSourceAssetModelReq);
|
||||
|
||||
}
|
||||
|
|
|
@ -2,16 +2,19 @@ package com.muyu.rule.engine.service.impl;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.DateUtils;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.etl.datasource.MyDataSource;
|
||||
import com.muyu.etl.domain.custom.VTClass;
|
||||
import com.muyu.rule.engine.constant.GenerateConstant;
|
||||
import com.muyu.rule.engine.constant.PathConstant;
|
||||
import com.muyu.rule.engine.domain.EngineMaintenance;
|
||||
import com.muyu.rule.engine.mapper.EngineMaintenanceMapper;
|
||||
import com.muyu.rule.engine.req.DataSourceAssetModelReq;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -118,10 +121,17 @@ public class EngineVersionServiceImpl implements IEngineVersionService
|
|||
|
||||
@Override
|
||||
public Result generatedCode(EngineVersion engineVersion) {
|
||||
// //根据引擎ID获取规则引擎信息
|
||||
// EngineMaintenance engineMaintenance = engineMaintenanceMapper.selectEngineMaintenanceById(engineVersion.getEngineMaintenanceId());
|
||||
// //生成规则版本类名
|
||||
// engineVersion.setVersionCode(engineMaintenance.getEngineCode()+"_"+engineVersion.getCode());
|
||||
// //生成规则版本代码
|
||||
// engineVersion.setCodeIng(GenerateConstant.generateConstant(engineMaintenance,engineVersion));
|
||||
// return Result.success(engineVersion);
|
||||
//根据引擎ID获取规则引擎信息
|
||||
EngineMaintenance engineMaintenance = engineMaintenanceMapper.selectEngineMaintenanceById(engineVersion.getEngineMaintenanceId());
|
||||
//生成规则版本类名
|
||||
engineVersion.setVersionCode(engineMaintenance.getEngineCode()+"_"+engineVersion.getCode());
|
||||
engineVersion.setVersionCode(engineMaintenance.getEngineCode()+"-"+engineVersion.getCode());
|
||||
//生成规则版本代码
|
||||
engineVersion.setCodeIng(GenerateConstant.generateConstant(engineMaintenance,engineVersion));
|
||||
return Result.success(engineVersion);
|
||||
|
@ -178,4 +188,42 @@ public class EngineVersionServiceImpl implements IEngineVersionService
|
|||
}
|
||||
return Result.error("初始化失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result getDataRegionList(DataSourceAssetModelReq dataSourceAssetModelReq) {
|
||||
ArrayList<Map<String, VTClass>> kvtList = new ArrayList<>();
|
||||
log.info("数据源: "+dataSourceAssetModelReq.getDataSource().toString());
|
||||
try {
|
||||
String sql = "select * from "+(dataSourceAssetModelReq.getDataSource().getModeName() == null ? "" : dataSourceAssetModelReq.getDataSource().getModeName()+".")+dataSourceAssetModelReq.getDataAsset().getTableName() +" limit 5";
|
||||
Connection connection = MyDataSource.getConnection(dataSourceAssetModelReq.getDataSource().getDataSourceName() + "_" + dataSourceAssetModelReq.getDataSource().getId());
|
||||
PreparedStatement pst = connection.prepareStatement(sql);
|
||||
ResultSet resultSet = pst.executeQuery();
|
||||
ResultSetMetaData rsd = resultSet.getMetaData();
|
||||
|
||||
int columnCount = rsd.getColumnCount();
|
||||
// 遍历查询结果,将每行数据转换为 Map 形式存储
|
||||
while (resultSet.next()){
|
||||
Map<String, VTClass> stringVTClassHashMap = new HashMap<>();
|
||||
for (int i = 1; i <= columnCount; i++) {
|
||||
// 获取列名和类型,并封装数据
|
||||
String columnName = rsd.getColumnName(i);
|
||||
String[] split = rsd.getColumnClassName(i).split("\\.");
|
||||
String type = split[split.length-1];
|
||||
Object value = resultSet.getObject(i);
|
||||
if (value==null){
|
||||
stringVTClassHashMap.put(columnName,new VTClass("",type));
|
||||
}else{
|
||||
stringVTClassHashMap.put(columnName,new VTClass(value.toString(),type));
|
||||
}
|
||||
}
|
||||
kvtList.add(stringVTClassHashMap);
|
||||
}
|
||||
// 关闭资源
|
||||
pst.close();
|
||||
MyDataSource.addBack(connection);
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return Result.success(kvtList);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue