11111
parent
c1a3bb406b
commit
3e43395902
|
@ -59,6 +59,9 @@ public class RuleEngine extends BaseEntity {
|
||||||
private String status ;
|
private String status ;
|
||||||
|
|
||||||
|
|
||||||
|
/** 规则引擎描述 */
|
||||||
|
private String ruleDesc;
|
||||||
|
|
||||||
public static RuleEngine updBuild(EtlRuleUpdReq etlRule, Supplier<Long> longSupplier){
|
public static RuleEngine updBuild(EtlRuleUpdReq etlRule, Supplier<Long> longSupplier){
|
||||||
|
|
||||||
return RuleEngine.builder().id(longSupplier.get())
|
return RuleEngine.builder().id(longSupplier.get())
|
||||||
|
@ -68,6 +71,7 @@ public class RuleEngine extends BaseEntity {
|
||||||
.status(etlRule.getStatus())
|
.status(etlRule.getStatus())
|
||||||
.code(etlRule.getCode())
|
.code(etlRule.getCode())
|
||||||
.remark(etlRule.getRemark())
|
.remark(etlRule.getRemark())
|
||||||
|
.ruleDesc(etlRule.getRuleDesc())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -80,6 +84,7 @@ public class RuleEngine extends BaseEntity {
|
||||||
.regionName(etlRule.getRegionName())
|
.regionName(etlRule.getRegionName())
|
||||||
.status(etlRule.getStatus())
|
.status(etlRule.getStatus())
|
||||||
.code(etlRule.getCode())
|
.code(etlRule.getCode())
|
||||||
|
.ruleDesc(etlRule.getRuleDesc())
|
||||||
.remark(etlRule.getRemark())
|
.remark(etlRule.getRemark())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
package com.muyu.rule.common.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:张承志
|
||||||
|
* @Package:com.muyu.rule.common.domain.resp
|
||||||
|
* @Project:cloud-etl-rule
|
||||||
|
* @name:RuleEngineVersion
|
||||||
|
* @Date:2024/8/25 10:34
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName(value = "rule_engine_version",autoResultMap = true)
|
||||||
|
public class RuleEngineVersion extends BaseEntity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 版本主键
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 版本名称
|
||||||
|
*/
|
||||||
|
private String versionName;
|
||||||
|
/**
|
||||||
|
* 版本编码
|
||||||
|
*/
|
||||||
|
private String code;
|
||||||
|
/**
|
||||||
|
* 规则引擎外键
|
||||||
|
*/
|
||||||
|
private String ruleId;
|
||||||
|
/**
|
||||||
|
* 是否开启规则引擎
|
||||||
|
*/
|
||||||
|
private String open;
|
||||||
|
/**
|
||||||
|
* 版本描述
|
||||||
|
*/
|
||||||
|
private String versionDesc;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -27,7 +27,7 @@ public class EtlRuleAddReq {
|
||||||
private String code;
|
private String code;
|
||||||
|
|
||||||
/** 是否公开 0已激活 1未激活 */
|
/** 是否公开 0已激活 1未激活 */
|
||||||
private String open ;
|
private String open;
|
||||||
|
|
||||||
/** 规则作用域 */
|
/** 规则作用域 */
|
||||||
private String regionName;
|
private String regionName;
|
||||||
|
@ -35,10 +35,12 @@ public class EtlRuleAddReq {
|
||||||
/** 状态 0正常 1停用 */
|
/** 状态 0正常 1停用 */
|
||||||
private String status ;
|
private String status ;
|
||||||
|
|
||||||
|
/** 规则引擎描述 */
|
||||||
|
private String ruleDesc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,8 @@ public class EtlRuleListReq {
|
||||||
/** 状态 0正常 1停用 */
|
/** 状态 0正常 1停用 */
|
||||||
private String status ;
|
private String status ;
|
||||||
|
|
||||||
|
/** 规则引擎描述 */
|
||||||
|
private String ruleDesc;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,10 @@ public class EtlRuleUpdReq {
|
||||||
/** 状态 0正常 1停用 */
|
/** 状态 0正常 1停用 */
|
||||||
private String status ;
|
private String status ;
|
||||||
|
|
||||||
|
|
||||||
|
/** 规则引擎描述 */
|
||||||
|
private String ruleDesc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import com.muyu.rule.common.domain.RuleEngine;
|
import com.muyu.rule.common.domain.RuleEngine;
|
||||||
|
import com.muyu.rule.common.domain.RuleEngineVersion;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
@ -13,6 +14,7 @@ import lombok.NoArgsConstructor;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:张承志
|
* @Author:张承志
|
||||||
|
@ -51,6 +53,10 @@ public class EtlRuleResp {
|
||||||
/** 是否激活 */
|
/** 是否激活 */
|
||||||
private String open ;
|
private String open ;
|
||||||
|
|
||||||
|
/** 规则引擎描述 */
|
||||||
|
private String ruleDesc;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "创建人", defaultValue = "muyu", type = "String")
|
@Schema(description = "创建人", defaultValue = "muyu", type = "String")
|
||||||
private String createBy;
|
private String createBy;
|
||||||
|
|
||||||
|
@ -62,6 +68,10 @@ public class EtlRuleResp {
|
||||||
@Schema(description = "创建时间", defaultValue = "2024-8-1 0:22:36", type = "Date")
|
@Schema(description = "创建时间", defaultValue = "2024-8-1 0:22:36", type = "Date")
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
|
|
||||||
|
List<RuleEngineVersion> versionList;
|
||||||
|
|
||||||
|
|
||||||
public static EtlRuleResp etlRuleRespBuilder(RuleEngine etlRule){
|
public static EtlRuleResp etlRuleRespBuilder(RuleEngine etlRule){
|
||||||
|
|
||||||
return EtlRuleResp.builder()
|
return EtlRuleResp.builder()
|
||||||
|
@ -71,6 +81,7 @@ public static EtlRuleResp etlRuleRespBuilder(RuleEngine etlRule){
|
||||||
.status(etlRule.getStatus())
|
.status(etlRule.getStatus())
|
||||||
.open(etlRule.getOpen())
|
.open(etlRule.getOpen())
|
||||||
.regionName(etlRule.getRegionName())
|
.regionName(etlRule.getRegionName())
|
||||||
|
.ruleDesc(etlRule.getRuleDesc())
|
||||||
.createBy(etlRule.getCreateBy())
|
.createBy(etlRule.getCreateBy())
|
||||||
.createTime(etlRule.getCreateTime()).build();
|
.createTime(etlRule.getCreateTime()).build();
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,9 @@
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
<artifactId>cloud-common-nacos-api</artifactId>
|
<artifactId>cloud-common-nacos-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class EngineConfig {
|
||||||
* 本地目录名称
|
* 本地目录名称
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private String location ="E:\\临时\\2021年5月28日\\";
|
private String location ="E:\\临时\\2024年8月23日\\";
|
||||||
|
|
||||||
|
|
||||||
public String getPack() {
|
public String getPack() {
|
||||||
|
|
|
@ -22,18 +22,18 @@ public class EngineTest {
|
||||||
|
|
||||||
EngineConfig engineConfig = new EngineConfig();
|
EngineConfig engineConfig = new EngineConfig();
|
||||||
|
|
||||||
//扫描原码进行编译
|
//扫描原码进行编译+-+-
|
||||||
SourceCodeComplier.javaCompilerPath(engineConfig.getLocation());
|
SourceCodeComplier.javaCompilerPath(engineConfig.getLocation());
|
||||||
|
//对class文件进行自定义类加载规则引擎
|
||||||
Map<String ,Class<?>> stringClassMap = JavaBinaryClassLoader.loadClassesByLocation(engineConfig.getPack(),engineConfig.getLocation());
|
Map<String ,Class<?>> stringClassMap = JavaBinaryClassLoader.loadClassesByLocation(engineConfig.getPack(),engineConfig.getLocation());
|
||||||
|
//
|
||||||
stringClassMap.forEach((key,value)->{
|
// stringClassMap.forEach((key,value)->{
|
||||||
EngineContainer.loadEngineInstance(key,value);
|
// EngineContainer.loadEngineInstance(key,value);
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
Map<String, Object> params = new HashMap<>();
|
// Map<String, Object> params = new HashMap<>();
|
||||||
params.put("idcard","142021 200212215977");
|
//params.put("idcard","142021 200212215977");
|
||||||
Object engineObject = EngineExecution.engineExe("Engine_2020_11_3_2347", params);
|
// Object engineObject = EngineExecution.engineExe("Engine_2024_8_23_2347", params);
|
||||||
//
|
//
|
||||||
// System.out.println(engineObject);
|
// System.out.println(engineObject);
|
||||||
|
|
||||||
|
|
|
@ -113,6 +113,18 @@ public class EtlRuleController {
|
||||||
return Result.success(list);
|
return Result.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查看维护规则版本
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/selectRuleAndVersionById/{id}")
|
||||||
|
public Result<EtlRuleResp> selectRuleAndVersionById(@PathVariable("id") Long id){
|
||||||
|
|
||||||
|
EtlRuleResp etlRuleResp = etlRuleService.selectRuleAndVersionById(id);
|
||||||
|
|
||||||
|
return Result.success(etlRuleResp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.muyu.rule.server.controller;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:张承志
|
||||||
|
* @Package:com.muyu.rule.server.controller
|
||||||
|
* @Project:cloud-etl-rule
|
||||||
|
* @name:RuleEngineVersionController
|
||||||
|
* @Date:2024/8/25 10:41
|
||||||
|
*/
|
||||||
|
public class RuleEngineVersionController {
|
||||||
|
}
|
|
@ -47,7 +47,7 @@ private static Class<?> loadClassByNameAndLocation(String name,String pack,File
|
||||||
System.out.println(pack+"======"+name);
|
System.out.println(pack+"======"+name);
|
||||||
//通过byte数组加载Class对象
|
//通过byte数组加载Class对象
|
||||||
String cc = pack+name;
|
String cc = pack+name;
|
||||||
System.out.println(cc);
|
|
||||||
Class<?> aClass = loader.defineClass(cc, datas, 0, datas.length);
|
Class<?> aClass = loader.defineClass(cc, datas, 0, datas.length);
|
||||||
log.info("成功加载规则引擎-> {} ",aClass.getName());
|
log.info("成功加载规则引擎-> {} ",aClass.getName());
|
||||||
return aClass;
|
return aClass;
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.muyu.rule.server.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.muyu.rule.common.domain.RuleEngineVersion;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:张承志
|
||||||
|
* @Package:com.muyu.rule.server.mapper
|
||||||
|
* @Project:cloud-etl-rule
|
||||||
|
* @name:RuleEngineVersionMapper
|
||||||
|
* @Date:2024/8/25 14:15
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface RuleEngineVersionMapper extends BaseMapper<RuleEngineVersion> {
|
||||||
|
}
|
|
@ -50,4 +50,12 @@ public interface EtlRuleService extends IService<RuleEngine> {
|
||||||
|
|
||||||
List<RuleRegion> findAllRuleRegion();
|
List<RuleRegion> findAllRuleRegion();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询规则和版本的接口
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
|
||||||
|
EtlRuleResp selectRuleAndVersionById(Long id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.muyu.rule.server.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.rule.common.domain.RuleEngineVersion;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:张承志
|
||||||
|
* @Package:com.muyu.rule.server.service
|
||||||
|
* @Project:cloud-etl-rule
|
||||||
|
* @name:RuleEngineService
|
||||||
|
* @Date:2024/8/25 14:16
|
||||||
|
*/
|
||||||
|
public interface RuleEngineVersionService extends IService<RuleEngineVersion> {
|
||||||
|
|
||||||
|
|
||||||
|
List<RuleEngineVersion> selectRuleEngineVersion(Long id);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -9,6 +9,7 @@ import com.muyu.rule.common.domain.req.EtlRuleListReq;
|
||||||
import com.muyu.rule.common.domain.resp.EtlRuleResp;
|
import com.muyu.rule.common.domain.resp.EtlRuleResp;
|
||||||
import com.muyu.rule.server.mapper.EtlRuleMapper;
|
import com.muyu.rule.server.mapper.EtlRuleMapper;
|
||||||
import com.muyu.rule.server.service.EtlRuleService;
|
import com.muyu.rule.server.service.EtlRuleService;
|
||||||
|
import com.muyu.rule.server.service.RuleEngineVersionService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@ -27,6 +28,11 @@ public class EtlRuleServiceImpl extends ServiceImpl<EtlRuleMapper, RuleEngine>
|
||||||
@Autowired
|
@Autowired
|
||||||
private EtlRuleMapper etlRuleMapper;
|
private EtlRuleMapper etlRuleMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RuleEngineVersionService versionService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过ID查询单条数据
|
* 通过ID查询单条数据
|
||||||
*
|
*
|
||||||
|
@ -83,12 +89,22 @@ public class EtlRuleServiceImpl extends ServiceImpl<EtlRuleMapper, RuleEngine>
|
||||||
public List<RuleRegion> findAllRuleRegion() {
|
public List<RuleRegion> findAllRuleRegion() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return etlRuleMapper.findAllRuleRegion();
|
return etlRuleMapper.findAllRuleRegion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EtlRuleResp selectRuleAndVersionById(Long id) {
|
||||||
|
|
||||||
|
RuleEngine ruleEngine = etlRuleMapper.selectById(id);
|
||||||
|
|
||||||
|
EtlRuleResp etlRuleResp = EtlRuleResp.etlRuleRespBuilder(ruleEngine);
|
||||||
|
|
||||||
|
etlRuleResp.setVersionList(versionService.selectRuleEngineVersion(ruleEngine.getId()));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return etlRuleResp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.muyu.rule.server.service.impl;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.muyu.rule.common.domain.RuleEngineVersion;
|
||||||
|
import com.muyu.rule.server.service.RuleEngineVersionService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:张承志
|
||||||
|
* @Package:com.muyu.rule.server.service.impl
|
||||||
|
* @Project:cloud-etl-rule
|
||||||
|
* @name:RuleEngineServiceImpl
|
||||||
|
* @Date:2024/8/25 14:17
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class RuleEngineServiceImpl extends ServiceImpl<BaseMapper<RuleEngineVersion>,RuleEngineVersion> implements RuleEngineVersionService {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RuleEngineVersion> selectRuleEngineVersion(Long id) {
|
||||||
|
|
||||||
|
LambdaQueryWrapper<RuleEngineVersion> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
|
queryWrapper.eq(
|
||||||
|
RuleEngineVersion::getRuleId,id);
|
||||||
|
|
||||||
|
List<RuleEngineVersion> versionList = this.list(queryWrapper);
|
||||||
|
|
||||||
|
|
||||||
|
return versionList;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue