11111
parent
70a649d045
commit
39fc26d102
|
@ -24,12 +24,19 @@
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
<artifactId>cloud-common-core</artifactId>
|
<artifactId>cloud-common-core</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- oss 图片上传 -->
|
<!-- oss 文件上传 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.aliyun.oss</groupId>
|
<groupId>com.aliyun.oss</groupId>
|
||||||
<artifactId>aliyun-sdk-oss</artifactId>
|
<artifactId>aliyun-sdk-oss</artifactId>
|
||||||
<version>3.12.0</version>
|
<version>3.12.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-devtools</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -17,7 +17,6 @@ public class Main {
|
||||||
|
|
||||||
static Map<String , BasicEngine<DataValue>> engineMap = new ConcurrentHashMap<>();
|
static Map<String , BasicEngine<DataValue>> engineMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
Class<?> aClass = Class.forName("com.muyu.rule.server.basic.engine.value.ENGINE_VALUE_VFD1000_V1");
|
Class<?> aClass = Class.forName("com.muyu.rule.server.basic.engine.value.ENGINE_VALUE_VFD1000_V1");
|
||||||
|
@ -36,7 +35,6 @@ public class Main {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
DataValue dataValue = DataValue.builder()
|
DataValue dataValue = DataValue.builder()
|
||||||
.type("String")
|
.type("String")
|
||||||
|
|
|
@ -20,16 +20,13 @@ import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
public class OSSClassLoaderExample {
|
public class OSSClassLoaderExample {
|
||||||
|
|
||||||
|
|
||||||
static Map<String , BasicEngine<DataValue>> engineMap = new ConcurrentHashMap<>();
|
static Map<String , BasicEngine<DataValue>> engineMap = new ConcurrentHashMap<>();
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
|
||||||
|
|
||||||
String filePath = "cloud-rule-server/src/main/java/com/muyu/rule/server/basic/engine/value/";
|
String filePath = "cloud-rule-server/src/main/java/com/muyu/rule/server/basic/engine/value/";
|
||||||
|
|
||||||
String pack = "com.muyu.rule.server.basic.engine.value.";
|
String pack = "com.muyu.rule.server.basic.engine.value.";
|
||||||
|
|
||||||
|
|
||||||
File file = new File(filePath+"ENGINE_phone_zzzzz_V9.java");
|
File file = new File(filePath+"ENGINE_phone_zzzzz_V9.java");
|
||||||
|
|
||||||
String ossFilePath = "ENGINE_phone_zzzzz_V9.java";
|
String ossFilePath = "ENGINE_phone_zzzzz_V9.java";
|
||||||
|
@ -37,7 +34,6 @@ public class OSSClassLoaderExample {
|
||||||
try {
|
try {
|
||||||
boolean newFile = file.createNewFile();
|
boolean newFile = file.createNewFile();
|
||||||
|
|
||||||
|
|
||||||
String string = OssUtil.readFileContentFromOSS("zcz-vfd-1000",ossFilePath);
|
String string = OssUtil.readFileContentFromOSS("zcz-vfd-1000",ossFilePath);
|
||||||
System.out.println(string);
|
System.out.println(string);
|
||||||
try (FileWriter writer = new FileWriter(file)) {
|
try (FileWriter writer = new FileWriter(file)) {
|
||||||
|
@ -72,27 +68,10 @@ public class OSSClassLoaderExample {
|
||||||
//
|
//
|
||||||
// object.execution();
|
// object.execution();
|
||||||
//
|
//
|
||||||
//
|
|
||||||
// } catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
// throw new RuntimeException(e);
|
// throw new RuntimeException(e);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,12 +20,6 @@ public class ENGINE_ROW_HANG_R1 extends DataEngineRowActuator {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,8 +49,6 @@ public class EtlRuleController {
|
||||||
RuleEngine etlRule = etlRuleService.queryById(id);
|
RuleEngine etlRule = etlRuleService.queryById(id);
|
||||||
return Result.success(etlRule);
|
return Result.success(etlRule);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
@Operation(summary = "查看规则引擎", description = "根据规则引擎的名称,类型,是否激活,状态等可以进行对规则的筛选")
|
@Operation(summary = "查看规则引擎", description = "根据规则引擎的名称,类型,是否激活,状态等可以进行对规则的筛选")
|
||||||
public Result<List<EtlRuleResp>> selectList(@Validated @RequestBody EtlRuleListReq req){
|
public Result<List<EtlRuleResp>> selectList(@Validated @RequestBody EtlRuleListReq req){
|
||||||
|
@ -109,10 +107,8 @@ public class EtlRuleController {
|
||||||
@Operation(summary = "规则作用域列表", description = "查询所有作用域的信息")
|
@Operation(summary = "规则作用域列表", description = "查询所有作用域的信息")
|
||||||
public Result<List<RuleRegion>> findAllRuleRegion(){
|
public Result<List<RuleRegion>> findAllRuleRegion(){
|
||||||
|
|
||||||
|
|
||||||
List<RuleRegion> list = etlRuleService.findAllRuleRegion();
|
List<RuleRegion> list = etlRuleService.findAllRuleRegion();
|
||||||
|
|
||||||
|
|
||||||
return Result.success(list);
|
return Result.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +116,6 @@ public class EtlRuleController {
|
||||||
* 查看维护规则版本
|
* 查看维护规则版本
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/selectRuleAndVersionById/{id}")
|
@PostMapping("/selectRuleAndVersionById/{id}")
|
||||||
@Operation(summary = "规则引擎的维护", description = "通过Id查询规则引擎和规则引擎的版本")
|
@Operation(summary = "规则引擎的维护", description = "通过Id查询规则引擎和规则引擎的版本")
|
||||||
public Result<EtlRuleResp> selectRuleAndVersionById(@PathVariable("id") Long id){
|
public Result<EtlRuleResp> selectRuleAndVersionById(@PathVariable("id") Long id){
|
||||||
|
|
|
@ -86,7 +86,6 @@ public class RuleEngineVersionController {
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将源码写入到OSS中
|
* 将源码写入到OSS中
|
||||||
* @param
|
* @param
|
||||||
|
@ -106,7 +105,6 @@ public class RuleEngineVersionController {
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/readByOss/{className}")
|
@PostMapping("/readByOss/{className}")
|
||||||
public Result readByOss(@PathVariable String className){
|
public Result readByOss(@PathVariable String className){
|
||||||
|
|
||||||
|
@ -115,7 +113,6 @@ Object o= versionService.readByOss(className);
|
||||||
return Result.success(o);
|
return Result.success(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/testvalue/{versionClazz}")
|
@PostMapping("/testvalue/{versionClazz}")
|
||||||
public Result testValue(@PathVariable("versionClazz") String versionClazz,@RequestBody DataValue dataValue){
|
public Result testValue(@PathVariable("versionClazz") String versionClazz,@RequestBody DataValue dataValue){
|
||||||
|
|
||||||
|
@ -131,7 +128,6 @@ public Result test(){
|
||||||
|
|
||||||
String pack = "com.muyu.rule.server.basic.engine.value.";
|
String pack = "com.muyu.rule.server.basic.engine.value.";
|
||||||
|
|
||||||
|
|
||||||
File file = new File(filePath+"ENGINE_phone_zzzzz_V9.java");
|
File file = new File(filePath+"ENGINE_phone_zzzzz_V9.java");
|
||||||
|
|
||||||
String ossFilePath = "ENGINE_phone_zzzzz_V9.java";
|
String ossFilePath = "ENGINE_phone_zzzzz_V9.java";
|
||||||
|
@ -139,7 +135,6 @@ public Result test(){
|
||||||
try {
|
try {
|
||||||
boolean newFile = file.createNewFile();
|
boolean newFile = file.createNewFile();
|
||||||
|
|
||||||
|
|
||||||
String string = OssUtil.readFileContentFromOSS("zcz-vfd-1000",ossFilePath);
|
String string = OssUtil.readFileContentFromOSS("zcz-vfd-1000",ossFilePath);
|
||||||
System.out.println(string);
|
System.out.println(string);
|
||||||
try (FileWriter writer = new FileWriter(file)) {
|
try (FileWriter writer = new FileWriter(file)) {
|
||||||
|
@ -158,22 +153,18 @@ public Result test(){
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// stringClassMap.forEach(EngineContainer::loadEngineInstance);
|
// stringClassMap.forEach(EngineContainer::loadEngineInstance);
|
||||||
|
|
||||||
|
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
@PostMapping("/look")
|
@PostMapping("/look")
|
||||||
public Result look (){
|
public Result look (){
|
||||||
|
|
||||||
|
|
||||||
String ossFilePath = "ENGINE_phone_zzzzz_V9.java";
|
String ossFilePath = "ENGINE_phone_zzzzz_V9.java";
|
||||||
|
|
||||||
String filePath ="home/"+ossFilePath;
|
String filePath ="home/"+ossFilePath;
|
||||||
|
|
||||||
OssUtil.downloadFileForBucket("zcz-vfd-1000",ossFilePath,filePath);
|
OssUtil.downloadFileForBucket("zcz-vfd-1000",ossFilePath,filePath);
|
||||||
|
|
||||||
EngineConfig engineConfig = new EngineConfig();
|
EngineConfig engineConfig = new EngineConfig();
|
||||||
|
|
||||||
|
@ -182,13 +173,11 @@ public Result look (){
|
||||||
//对class文件进行自定义类加载规则引擎
|
//对class文件进行自定义类加载规则引擎
|
||||||
Map<String ,Class<?>> stringClassMap = JavaBinaryClassLoader.loadClassesByLocation(engineConfig.getPack(),engineConfig.getLocation());
|
Map<String ,Class<?>> stringClassMap = JavaBinaryClassLoader.loadClassesByLocation(engineConfig.getPack(),engineConfig.getLocation());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
package com.muyu.rule.server.engine.custom;
|
|
||||||
|
|
||||||
import com.muyu.rule.server.exception.ActionDiscard;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:张承志
|
|
||||||
* @Package:com.muyu.rule.server.engine
|
|
||||||
* @Project:cloud-etl-rule
|
|
||||||
* @name:DataModelEngine
|
|
||||||
* @Date:2024/8/26 22:00
|
|
||||||
*/
|
|
||||||
public abstract class DataModelEngine {
|
|
||||||
|
|
||||||
public abstract void execution();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Object getValue(){
|
|
||||||
|
|
||||||
|
|
||||||
Class<?> field;
|
|
||||||
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
package com.muyu.rule.server.engine.custom.child;
|
|
||||||
|
|
||||||
import com.muyu.rule.common.utils.Desensitization;
|
|
||||||
import com.muyu.rule.server.engine.custom.DataModelEngine;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:张承志
|
|
||||||
* @Package:com.muyu.rule.server.engine.custom.child
|
|
||||||
* @Project:cloud-etl-rule
|
|
||||||
* @name:Engine_Reginx
|
|
||||||
* @Date:2024/8/27 15:13
|
|
||||||
*/
|
|
||||||
public class Engine_Reginx extends DataModelEngine {
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execution() {
|
|
||||||
Object value = getValue();
|
|
||||||
|
|
||||||
String string = Desensitization.mobilePhoneDesensitization((String) value);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
package com.muyu.rule.server.engine.custom.child;
|
|
||||||
import com.muyu.rule.server.engine.custom.DataModelEngine;
|
|
||||||
import com.muyu.rule.server.exception.ActionDiscard;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:张承志
|
|
||||||
* @Package:com.muyu.rule.server.engine
|
|
||||||
* @Project:cloud-etl-rule
|
|
||||||
* @name:Engine_not_null
|
|
||||||
* @Date:2024/8/26 21:57
|
|
||||||
*/
|
|
||||||
public class Engine_not_null extends DataModelEngine {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execution() {
|
|
||||||
Object value = getValue();
|
|
||||||
|
|
||||||
if (value == null || "".equals(value) || "null".equals(value)) {
|
|
||||||
throw new ActionDiscard();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -10,7 +10,10 @@ import com.muyu.rule.common.domain.DataValue;
|
||||||
import com.muyu.rule.common.domain.RuleEngine;
|
import com.muyu.rule.common.domain.RuleEngine;
|
||||||
import com.muyu.rule.common.domain.RuleEngineVersion;
|
import com.muyu.rule.common.domain.RuleEngineVersion;
|
||||||
import com.muyu.rule.common.utils.OssUtil;
|
import com.muyu.rule.common.utils.OssUtil;
|
||||||
|
import com.muyu.rule.server.EngineConfig;
|
||||||
import com.muyu.rule.server.basic.BasicEngine;
|
import com.muyu.rule.server.basic.BasicEngine;
|
||||||
|
import com.muyu.rule.server.complie.SourceCodeComplier;
|
||||||
|
import com.muyu.rule.server.load.JavaBinaryClassLoader;
|
||||||
import com.muyu.rule.server.mapper.RuleEngineVersionMapper;
|
import com.muyu.rule.server.mapper.RuleEngineVersionMapper;
|
||||||
import com.muyu.rule.server.scan.JavaCodeScan;
|
import com.muyu.rule.server.scan.JavaCodeScan;
|
||||||
import com.muyu.rule.server.service.RuleEngineVersionService;
|
import com.muyu.rule.server.service.RuleEngineVersionService;
|
||||||
|
@ -111,6 +114,18 @@ public class RuleEngineServiceImpl extends ServiceImpl<RuleEngineVersionMapper,R
|
||||||
|
|
||||||
OssUtil.downloadFileForBucket(bucketName,className+Suffix_JAVA,"D:\\桌面");
|
OssUtil.downloadFileForBucket(bucketName,className+Suffix_JAVA,"D:\\桌面");
|
||||||
|
|
||||||
|
String ossFilePath = className+Suffix_JAVA;
|
||||||
|
|
||||||
|
String filePath ="home/"+ossFilePath;
|
||||||
|
|
||||||
|
OssUtil.downloadFileForBucket("zcz-vfd-1000",ossFilePath,filePath);
|
||||||
|
|
||||||
|
EngineConfig engineConfig = new EngineConfig();
|
||||||
|
|
||||||
|
SourceCodeComplier.javaCompilerPath(engineConfig.getLocation());
|
||||||
|
|
||||||
|
//对class文件进行自定义类加载规则引擎
|
||||||
|
Map<String ,Class<?>> stringClassMap = JavaBinaryClassLoader.loadClassesByLocation(engineConfig.getPack(),engineConfig.getLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
static Map<String , BasicEngine<DataValue>> engineMap = new ConcurrentHashMap<>();
|
static Map<String , BasicEngine<DataValue>> engineMap = new ConcurrentHashMap<>();
|
||||||
|
|
Loading…
Reference in New Issue