feat:规则引擎(数据源接入,测试)
parent
7dcbe492a5
commit
df32e7d7eb
|
@ -1,21 +0,0 @@
|
||||||
package com.etl.data.domain.config;
|
|
||||||
|
|
||||||
import com.alibaba.druid.pool.DruidDataSource;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ClassName DataSourceConfig
|
|
||||||
* @Description 描述
|
|
||||||
* @Author YunFei.Du
|
|
||||||
* @Date 2024/5/10 9:44
|
|
||||||
*/
|
|
||||||
public class DataSourceConfig {
|
|
||||||
public static DruidDataSource dataSource(String ip , String name, String port , String username, String password) {
|
|
||||||
DruidDataSource dataSource = new DruidDataSource();
|
|
||||||
dataSource.setUsername(username);
|
|
||||||
dataSource.setPassword(password);
|
|
||||||
dataSource.setUrl("jdbc:mysql://"+ip+":"+port+"/"+name+"?useSSL=false");
|
|
||||||
dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
|
|
||||||
return dataSource;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.etl.data.source.remote;
|
||||||
|
|
||||||
|
import com.etl.common.core.constant.ServiceNameConstants;
|
||||||
|
import com.etl.data.source.remote.factory.AssetModelFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName RemoteAssetModelService
|
||||||
|
* @Description 描述
|
||||||
|
* @Author YunFei.Du
|
||||||
|
* @Date 2024/5/13 15:08
|
||||||
|
*/
|
||||||
|
@FeignClient(
|
||||||
|
contextId = "RemoteAssetModelService",
|
||||||
|
value = ServiceNameConstants.DATA_SOURCE_SERVICE,
|
||||||
|
fallbackFactory = AssetModelFactory.class,
|
||||||
|
path = "/model"
|
||||||
|
)
|
||||||
|
public interface RemoteAssetModelService {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.etl.data.source.remote.factory;
|
||||||
|
|
||||||
|
import com.etl.data.source.remote.RemoteAssetModelService;
|
||||||
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName AssetModelFactory
|
||||||
|
* @Description 描述
|
||||||
|
* @Author YunFei.Du
|
||||||
|
* @Date 2024/5/13 15:07
|
||||||
|
*/
|
||||||
|
public class AssetModelFactory implements FallbackFactory< RemoteAssetModelService > {
|
||||||
|
@Override
|
||||||
|
public RemoteAssetModelService create(Throwable cause) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -31,6 +31,9 @@ public class DataSourceController extends BaseController {
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
public Result< TableDataInfo<DataSource> > getDataSourceList (@RequestBody DataSourceQueryReq req) {
|
public Result< TableDataInfo<DataSource> > getDataSourceList (@RequestBody DataSourceQueryReq req) {
|
||||||
startPage();
|
startPage();
|
||||||
|
ThreadLocal< String > local = new ThreadLocal<> ( );
|
||||||
|
String s = local.get ( );
|
||||||
|
System.out.println ("asd"+s );
|
||||||
List<DataSource> list = dataSourceService.selectDataSourceList(req);
|
List<DataSource> list = dataSourceService.selectDataSourceList(req);
|
||||||
return getDataAsset (list);
|
return getDataAsset (list);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
package com.etl.data.unit.controller;/**
|
||||||
|
* @ClassName TextController
|
||||||
|
* @Description 描述
|
||||||
|
* @Author YunFei Du
|
||||||
|
* @Date 2024/05/13 15:21
|
||||||
|
*/
|
||||||
|
|
||||||
|
import com.etl.data.unit.domain.DataModel;
|
||||||
|
import com.etl.data.unit.domain.TreadConstant;
|
||||||
|
import com.etl.data.unit.service.Basic;
|
||||||
|
import com.etl.data.unit.service.impl.A;
|
||||||
|
import com.etl.data.unit.service.impl.B;
|
||||||
|
import com.etl.data.unit.service.impl.C;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*TextController
|
||||||
|
* 描述
|
||||||
|
* YunFei Du
|
||||||
|
*2024/05/13 15:21
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
public class TextController {
|
||||||
|
private static final ConcurrentHashMap<String, Basic> ruleConcurrentHashMap= new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
public static void init(){
|
||||||
|
ruleConcurrentHashMap.put("a",new A());
|
||||||
|
ruleConcurrentHashMap.put("b",new B());
|
||||||
|
ruleConcurrentHashMap.put("c",new C());
|
||||||
|
}
|
||||||
|
@PostMapping("text")
|
||||||
|
public void text(){
|
||||||
|
DataModel dataModel = new DataModel();
|
||||||
|
dataModel.setValue("王五");
|
||||||
|
dataModel.setKey("name");
|
||||||
|
dataModel.setProcessClass(String.class);
|
||||||
|
dataModel.setSourceType("varchar");
|
||||||
|
dataModel.setProcessType("String");
|
||||||
|
TreadConstant.set(dataModel);
|
||||||
|
Basic a = ruleConcurrentHashMap.get("a");
|
||||||
|
Basic b = ruleConcurrentHashMap.get("b");
|
||||||
|
Basic c = ruleConcurrentHashMap.get("c");
|
||||||
|
a.execution();
|
||||||
|
b.execution();
|
||||||
|
c.execution();
|
||||||
|
TreadConstant.remove();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.etl.data.unit.domain;/**
|
||||||
|
* @ClassName DataModel
|
||||||
|
* @Description 描述
|
||||||
|
* @Author YunFei Du
|
||||||
|
* @Date 2024/05/13 14:55
|
||||||
|
*/
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*DataModel
|
||||||
|
* 描述
|
||||||
|
* YunFei Du
|
||||||
|
*2024/05/13 14:55
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DataModel {
|
||||||
|
|
||||||
|
private String key;
|
||||||
|
private Object value;
|
||||||
|
|
||||||
|
private String sourceType;
|
||||||
|
private String processType;
|
||||||
|
|
||||||
|
private Class<?> processClass;
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
package com.etl.data.unit.domain;/**
|
||||||
|
* @ClassName TreadConstant
|
||||||
|
* @Description 描述
|
||||||
|
* @Author YunFei Du
|
||||||
|
* @Date 2024/05/13 14:58
|
||||||
|
*/
|
||||||
|
|
||||||
|
import com.etl.data.unit.domain.DataModel;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*TreadConstant
|
||||||
|
* 描述
|
||||||
|
* YunFei Du
|
||||||
|
*2024/05/13 14:58
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class TreadConstant {
|
||||||
|
|
||||||
|
private static ThreadLocal<DataModel> threadLocal= new ThreadLocal<>();
|
||||||
|
|
||||||
|
public static DataModel get(){
|
||||||
|
return threadLocal.get();
|
||||||
|
}
|
||||||
|
public static void set(DataModel dataModel){
|
||||||
|
threadLocal.set(dataModel);
|
||||||
|
}
|
||||||
|
public static void remove(){
|
||||||
|
threadLocal.remove();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.etl.data.unit.service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName Basic
|
||||||
|
* @Description 描述
|
||||||
|
* @Author YunFei Du
|
||||||
|
* @Date 2024/05/13 15:11
|
||||||
|
*/
|
||||||
|
public interface Basic {
|
||||||
|
public void execution();
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.etl.rule.engine.action;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: YunFei.Du
|
||||||
|
* @date: 2024/5/6
|
||||||
|
* @Description: 丢弃
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
public class ActionDiscard extends RuntimeException{
|
||||||
|
}
|
|
@ -20,6 +20,7 @@ public class DataModelContext implements ScopeContext <DataProcessModel>{
|
||||||
this.recordContext = recordContext;
|
this.recordContext = recordContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataProcessModel get () {
|
public DataProcessModel get () {
|
||||||
return THREAD_LOCAL.get();
|
return THREAD_LOCAL.get();
|
||||||
|
|
|
@ -5,10 +5,9 @@ import com.etl.rule.engine.model.DataSetModel;
|
||||||
import com.etl.rule.engine.scope.model.DataSetProcessModel;
|
import com.etl.rule.engine.scope.model.DataSetProcessModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: YunFei.Du
|
* 数据模型引擎接口
|
||||||
* @date: 2024/5/6
|
* @author YunFei.Du
|
||||||
* @Description: 数据模型引擎接口
|
* @date 8:52 2024/5/15
|
||||||
* @Version: 1.0
|
|
||||||
*/
|
*/
|
||||||
public abstract class DataSetEngine implements Engine<DataSetProcessModel> {
|
public abstract class DataSetEngine implements Engine<DataSetProcessModel> {
|
||||||
private DataSetContext dataSetContext;
|
private DataSetContext dataSetContext;
|
||||||
|
|
|
@ -3,10 +3,9 @@ package com.etl.rule.engine.scope;
|
||||||
import com.etl.rule.engine.scope.model.RecordProcessModel;
|
import com.etl.rule.engine.scope.model.RecordProcessModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: YunFei.Du
|
* 记录/资产模型
|
||||||
* @date: 2024/4/29
|
* @author YunFei.Du
|
||||||
* @Description: 记录/资产模型
|
* @date 8:50 2024/5/15
|
||||||
* @Version: 1.0
|
|
||||||
*/
|
*/
|
||||||
public class RecordContext implements ScopeContext<RecordProcessModel>{
|
public class RecordContext implements ScopeContext<RecordProcessModel>{
|
||||||
|
|
||||||
|
|
|
@ -39,10 +39,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectEngineMaintenanceById" parameterType="Long" resultMap="EngineMaintenanceResult">
|
|
||||||
<include refid="selectEngineMaintenanceVo"/>
|
|
||||||
where id = #{id}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<insert id="insertEngineMaintenance" parameterType="com.etl.rule.engine.domain.EngineMaintenance" useGeneratedKeys="true" keyProperty="id">
|
<insert id="insertEngineMaintenance" parameterType="com.etl.rule.engine.domain.EngineMaintenance" useGeneratedKeys="true" keyProperty="id">
|
||||||
insert into engine_maintenance
|
insert into engine_maintenance
|
|
@ -1,152 +0,0 @@
|
||||||
package com.etl.rule.engine.domain;
|
|
||||||
|
|
||||||
import com.etl.common.core.annotation.Excel;
|
|
||||||
import com.etl.common.core.web.domain.BaseEntity;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 【请填写功能名称】对象 engine_maintenance
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
* @date 2024-05-02
|
|
||||||
*/
|
|
||||||
public class EngineMaintenance extends BaseEntity {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/** $column.columnComment */
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/** 规则引擎名称 */
|
|
||||||
@Excel(name = "规则引擎名称")
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
/** 规则引擎类型 */
|
|
||||||
@Excel(name = "规则引擎类型")
|
|
||||||
private String type;
|
|
||||||
|
|
||||||
/** 规则引擎激活状态 */
|
|
||||||
@Excel(name = "规则引擎激活状态")
|
|
||||||
private String isActivate;
|
|
||||||
|
|
||||||
/** 规则引擎状态 */
|
|
||||||
@Excel(name = "规则引擎状态")
|
|
||||||
private String status;
|
|
||||||
|
|
||||||
/** 规则引擎描述 */
|
|
||||||
@Excel(name = "规则引擎描述")
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
/** 规则引擎编码 */
|
|
||||||
@Excel(name = "规则引擎编码")
|
|
||||||
private String code;
|
|
||||||
|
|
||||||
/** 规则引擎级别 */
|
|
||||||
@Excel(name = "规则引擎级别")
|
|
||||||
private String level;
|
|
||||||
|
|
||||||
/** 编辑代码文本 */
|
|
||||||
@Excel(name = "编辑代码文本")
|
|
||||||
private String codeText;
|
|
||||||
|
|
||||||
public String getCodeText() {
|
|
||||||
return codeText;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCodeText(String codeText) {
|
|
||||||
this.codeText = codeText;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Long id)
|
|
||||||
{
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getId()
|
|
||||||
{
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
public void setName(String name)
|
|
||||||
{
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName()
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
public void setType(String type)
|
|
||||||
{
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getType()
|
|
||||||
{
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
public void setIsActivate(String isActivate)
|
|
||||||
{
|
|
||||||
this.isActivate = isActivate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIsActivate()
|
|
||||||
{
|
|
||||||
return isActivate;
|
|
||||||
}
|
|
||||||
public void setStatus(String status)
|
|
||||||
{
|
|
||||||
this.status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getStatus()
|
|
||||||
{
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
public void setDescription(String description)
|
|
||||||
{
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription()
|
|
||||||
{
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
public void setCode(String code)
|
|
||||||
{
|
|
||||||
this.code = code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCode()
|
|
||||||
{
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
public void setLevel(String level)
|
|
||||||
{
|
|
||||||
this.level = level;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLevel()
|
|
||||||
{
|
|
||||||
return level;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
|
||||||
.append("id", getId())
|
|
||||||
.append("name", getName())
|
|
||||||
.append("type", getType())
|
|
||||||
.append("isActivate", getIsActivate())
|
|
||||||
.append("status", getStatus())
|
|
||||||
.append("description", getDescription())
|
|
||||||
.append("code", getCode())
|
|
||||||
.append("level", getLevel())
|
|
||||||
.append("codeText", getCodeText())
|
|
||||||
.append("remark", getRemark())
|
|
||||||
.append("createBy", getCreateBy())
|
|
||||||
.append("createTime", getCreateTime())
|
|
||||||
.append("updateBy", getUpdateBy())
|
|
||||||
.append("updateTime", getUpdateTime())
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,62 +0,0 @@
|
||||||
package com.etl.rule.engine.mapper;
|
|
||||||
|
|
||||||
import com.etl.rule.engine.domain.EngineMaintenance;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 【请填写功能名称】Mapper接口
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
* @date 2024-05-02
|
|
||||||
*/
|
|
||||||
public interface EngineMaintenanceMapper
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* 查询【请填写功能名称】
|
|
||||||
*
|
|
||||||
* @param id 【请填写功能名称】主键
|
|
||||||
* @return 【请填写功能名称】
|
|
||||||
*/
|
|
||||||
public EngineMaintenance selectEngineMaintenanceById(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询【请填写功能名称】列表
|
|
||||||
*
|
|
||||||
* @param engineMaintenance 【请填写功能名称】
|
|
||||||
* @return 【请填写功能名称】集合
|
|
||||||
*/
|
|
||||||
public List<EngineMaintenance> selectEngineMaintenanceList(EngineMaintenance engineMaintenance);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增【请填写功能名称】
|
|
||||||
*
|
|
||||||
* @param engineMaintenance 【请填写功能名称】
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int insertEngineMaintenance(EngineMaintenance engineMaintenance);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改【请填写功能名称】
|
|
||||||
*
|
|
||||||
* @param engineMaintenance 【请填写功能名称】
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int updateEngineMaintenance(EngineMaintenance engineMaintenance);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除【请填写功能名称】
|
|
||||||
*
|
|
||||||
* @param id 【请填写功能名称】主键
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int deleteEngineMaintenanceById(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除【请填写功能名称】
|
|
||||||
*
|
|
||||||
* @param ids 需要删除的数据主键集合
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int deleteEngineMaintenanceByIds(Long[] ids);
|
|
||||||
}
|
|
|
@ -1,70 +0,0 @@
|
||||||
package com.etl.rule.engine.service;
|
|
||||||
|
|
||||||
import com.etl.common.core.domain.Result;
|
|
||||||
import com.etl.rule.engine.domain.EngineMaintenance;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 【请填写功能名称】Service接口
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
* @date 2024-05-02
|
|
||||||
*/
|
|
||||||
public interface IEngineMaintenanceService
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* 查询【请填写功能名称】
|
|
||||||
*
|
|
||||||
* @param id 【请填写功能名称】主键
|
|
||||||
* @return 【请填写功能名称】
|
|
||||||
*/
|
|
||||||
public EngineMaintenance selectEngineMaintenanceById(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询【请填写功能名称】列表
|
|
||||||
*
|
|
||||||
* @param engineMaintenance 【请填写功能名称】
|
|
||||||
* @return 【请填写功能名称】集合
|
|
||||||
*/
|
|
||||||
public List<EngineMaintenance> selectEngineMaintenanceList(EngineMaintenance engineMaintenance);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增【请填写功能名称】
|
|
||||||
*
|
|
||||||
* @param engineMaintenance 【请填写功能名称】
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int insertEngineMaintenance(EngineMaintenance engineMaintenance);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改【请填写功能名称】
|
|
||||||
*
|
|
||||||
* @param engineMaintenance 【请填写功能名称】
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int updateEngineMaintenance(EngineMaintenance engineMaintenance);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除【请填写功能名称】
|
|
||||||
*
|
|
||||||
* @param ids 需要删除的【请填写功能名称】主键集合
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int deleteEngineMaintenanceByIds(Long[] ids);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除【请填写功能名称】信息
|
|
||||||
*
|
|
||||||
* @param id 【请填写功能名称】主键
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int deleteEngineMaintenanceById(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 初始化规则引擎类
|
|
||||||
*/
|
|
||||||
Result initializeRuleEngine(EngineMaintenance engineMaintenance);
|
|
||||||
|
|
||||||
Result testMethod(String code);
|
|
||||||
}
|
|
Loading…
Reference in New Issue