11111
parent
53fae64087
commit
369a9478c5
|
@ -0,0 +1,58 @@
|
|||
package com.muyu.rule.common.domain;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
class Person {
|
||||
private String name;
|
||||
private int age;
|
||||
|
||||
public Person(String name, int age) {
|
||||
this.name = name;
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Person person = (Person) o;
|
||||
return age == person.age &&
|
||||
Objects.equals(name, person.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name, age);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Person{" +
|
||||
"name='" + name + '\'' +
|
||||
", age=" + age +
|
||||
'}';
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
Person[] people = new Person[]{
|
||||
new Person("Alice", 30),
|
||||
new Person("Alice", 30),
|
||||
new Person("Bob", 25),
|
||||
new Person("Alice", 30),
|
||||
new Person("Charlie", 35)
|
||||
};
|
||||
|
||||
// 使用 HashSet 去重
|
||||
Set<Person> uniquePeople = new HashSet<>(Arrays.asList(people));
|
||||
|
||||
// 将 Set 转换回数组
|
||||
Person[] uniqueArray = uniquePeople.toArray(new Person[0]);
|
||||
|
||||
// 输出结果
|
||||
System.out.println(Arrays.toString(uniqueArray));
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -72,8 +72,10 @@ String sourceCode ="public class HelloWorld {\n" +
|
|||
|
||||
try {
|
||||
GetObjectRequest getObjectRequest = new GetObjectRequest(bucketName, "test");
|
||||
OSSObject ossObject = ossClientReader.getObject(getObjectRequest);
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(ossObject.getObjectContent()));
|
||||
BufferedReader reader;
|
||||
try (OSSObject ossObject = ossClientReader.getObject(getObjectRequest)) {
|
||||
reader = new BufferedReader(new InputStreamReader(ossObject.getObjectContent()));
|
||||
}
|
||||
StringBuilder content = new StringBuilder();
|
||||
String line=null;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
|
|
|
@ -11,8 +11,8 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||
*/
|
||||
public class EngineConfig {
|
||||
|
||||
public static final AtomicReference<String> executionMethodName = new AtomicReference<>("execute");
|
||||
//public static final AtomicReference<String> executionMethodName = new AtomicReference<>("run");
|
||||
//public static final AtomicReference<String> executionMethodName = new AtomicReference<>("execute");
|
||||
public static final AtomicReference<String> executionMethodName = new AtomicReference<>("run");
|
||||
|
||||
/**
|
||||
* 本地包名称
|
||||
|
@ -22,20 +22,29 @@ public class EngineConfig {
|
|||
|
||||
// E:\\临时\\2024年8月23日\\
|
||||
/**
|
||||
* 本地目录名称
|
||||
* 本地项目目录名称
|
||||
*/
|
||||
private String location = "E:\\practical_training\\cloud-etl-rule\\cloud-rule-server\\src\\main\\java\\com\\muyu\\rule\\server\\engine\\";
|
||||
/**
|
||||
* 本地源代码目录
|
||||
*/
|
||||
private String localSource ="D:\\config\\engine\\source\\";
|
||||
|
||||
/**
|
||||
* 本地编译目录
|
||||
*/
|
||||
private String localTarget ="D:\\config\\engine\\target\\";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 服务器目录
|
||||
* 服务器目录路径
|
||||
* @return
|
||||
*/
|
||||
// private String serverWay = "home/";
|
||||
private String serverWay = "/home/config/source";
|
||||
// private String serverPath = "home/";
|
||||
private String serverPath = "home/config/source/";
|
||||
|
||||
/**
|
||||
* 服务器的包名
|
||||
|
@ -44,6 +53,30 @@ public class EngineConfig {
|
|||
|
||||
private String serverPack="com.muyu.rule.server.basic.engine.value.";
|
||||
|
||||
public String getServerPath() {
|
||||
return serverPath;
|
||||
}
|
||||
|
||||
public void setServerPath(String serverPath) {
|
||||
this.serverPath = serverPath;
|
||||
}
|
||||
|
||||
public String getLocalSource() {
|
||||
return localSource;
|
||||
}
|
||||
|
||||
public void setLocalSource(String localSource) {
|
||||
this.localSource = localSource;
|
||||
}
|
||||
|
||||
public String getLocalTarget() {
|
||||
return localTarget;
|
||||
}
|
||||
|
||||
public void setLocalTarget(String localTarget) {
|
||||
this.localTarget = localTarget;
|
||||
}
|
||||
|
||||
public String getServerPack() {
|
||||
return serverPack;
|
||||
}
|
||||
|
@ -52,13 +85,7 @@ public class EngineConfig {
|
|||
this.serverPack = serverPack;
|
||||
}
|
||||
|
||||
public String getServerWay() {
|
||||
return serverWay;
|
||||
}
|
||||
|
||||
public void setServerWay(String serverWay) {
|
||||
this.serverWay = serverWay;
|
||||
}
|
||||
|
||||
public String getPack() {
|
||||
return pack;
|
||||
|
|
|
@ -41,8 +41,10 @@ public class EngineTest {
|
|||
stringClassMap.forEach(EngineContainer::loadEngineInstance);
|
||||
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("idcard","142021200212215977");
|
||||
Object engineObject = EngineExecution.engineExe("Engine_2024_8_23_2347", params);
|
||||
|
||||
params.put("idcard","142021200212215977");
|
||||
|
||||
Object engineObject = EngineExecution.engineExe("Engine_2024_8_23_2347", params);
|
||||
|
||||
System.out.println("====>"+engineObject);
|
||||
|
||||
|
|
|
@ -17,13 +17,17 @@ public class Main {
|
|||
|
||||
static Map<String , BasicEngine<DataValue>> engineMap = new ConcurrentHashMap<>();
|
||||
|
||||
static Map<String,BasicEngine<DataValue[]>> engineRowMap = new ConcurrentHashMap<>();
|
||||
|
||||
static {
|
||||
try {
|
||||
Class<?> aClass = Class.forName("com.muyu.rule.server.basic.engine.value.ENGINE_VALUE_VFD1000_V1");
|
||||
Class<?> aClass2 = Class.forName("com.muyu.rule.server.basic.engine.value.ENGINE_VALUE_VFD1000_V2");
|
||||
Class<?> aClass3 = Class.forName("com.muyu.rule.server.basic.engine.row.ENGINE_ROW_HANG_R1");
|
||||
try {
|
||||
engineMap.put("ENGINE_VALUE_VFD1000_V1", (BasicEngine<DataValue>) aClass.newInstance());
|
||||
engineMap.put("ENGINE_VALUE_VFD1000_V2", (BasicEngine<DataValue>) aClass2.newInstance());
|
||||
engineRowMap.put("ENGINE_ROW_HANG_R1",(BasicEngine<DataValue[]>) aClass3.newInstance());
|
||||
} catch (InstantiationException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
|
@ -36,6 +40,20 @@ public class Main {
|
|||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
DataValue[] dataValues = new DataValue[]{
|
||||
new DataValue("name","String",null,"张三"),
|
||||
new DataValue("name","String",null,"李四"),
|
||||
new DataValue("name","String",null,"王五"),
|
||||
new DataValue("name","String",null,"张三")
|
||||
};
|
||||
|
||||
BasicEngine<DataValue[]> engineRowHangR1 = engineRowMap.get("ENGINE_ROW_HANG_R1");
|
||||
|
||||
engineRowHangR1.set(dataValues);
|
||||
engineRowHangR1.execution();
|
||||
|
||||
|
||||
DataValue dataValue = DataValue.builder()
|
||||
.type("String")
|
||||
.label("姓名")
|
||||
|
@ -49,11 +67,6 @@ public class Main {
|
|||
|
||||
engineValue.execution();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -67,6 +80,9 @@ public class Main {
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package com.muyu.rule.server.basic.abstracts;
|
||||
|
||||
import com.muyu.rule.common.domain.DataValue;
|
||||
import com.muyu.rule.server.basic.BasicEngine;
|
||||
import com.muyu.rule.server.basic.handler.DataEngineDataSetHandler;
|
||||
import com.muyu.rule.server.basic.handler.DataEngineRowHandler;
|
||||
|
||||
/**
|
||||
* @Author:张承志
|
||||
* @Package:com.muyu.rule.server.basic.abstracts
|
||||
* @Project:cloud-etl-rule
|
||||
* @name:DataEngineValueAu
|
||||
* @Date:2024/8/29 15:11
|
||||
*/
|
||||
public abstract class DataEngineDataSetActuator implements BasicEngine<DataValue[][]> {
|
||||
|
||||
public void set(DataValue[][] dataValue){
|
||||
DataEngineDataSetHandler.set(dataValue);
|
||||
}
|
||||
|
||||
public DataValue[][] get(){
|
||||
return DataEngineDataSetHandler.get();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,9 +1,14 @@
|
|||
package com.muyu.rule.server.basic.engine.row;
|
||||
|
||||
import com.muyu.rule.common.domain.DataValue;
|
||||
|
||||
import com.muyu.rule.server.basic.abstracts.DataEngineRowActuator;
|
||||
import com.muyu.rule.server.basic.handler.DataEngineRowHandler;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @Author:张承志
|
||||
* @Package:com.muyu.rule.server.basic.engine.row
|
||||
|
@ -13,16 +18,22 @@ import com.muyu.rule.server.basic.handler.DataEngineRowHandler;
|
|||
*/
|
||||
public class ENGINE_ROW_HANG_R1 extends DataEngineRowActuator {
|
||||
|
||||
/**
|
||||
* 数据行去重
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void execution() {
|
||||
DataValue[] dataValues = get();
|
||||
|
||||
// 使用 HashSet 去重
|
||||
Set<DataValue> uniquePeople = new HashSet<>(Arrays.asList(dataValues));
|
||||
|
||||
// 将 Set 转换回数组
|
||||
DataValue[] uniqueArray = uniquePeople.toArray(new DataValue[0]);
|
||||
|
||||
System.out.println(Arrays.toString(uniqueArray));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package com.muyu.rule.server.basic.engine.value;
|
||||
|
||||
import com.muyu.rule.common.domain.DataValue;
|
||||
|
||||
/**
|
||||
* @Author:张承志
|
||||
* @Package:com.muyu.rule.server.basic.engine.value
|
||||
* @Project:cloud-etl-rule
|
||||
* @name:ENGINE_TEST_V1
|
||||
* @Date:2024/9/2 14:43
|
||||
*/
|
||||
public class ENGINE_PHONE_TEST_V1 {
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -17,7 +17,8 @@ public class ENGINE_VALUE_VFD1000_V1 extends DataEngineValueActuator {
|
|||
DataValue dataValue = get();
|
||||
if (dataValue.getValue() == null){
|
||||
System.out.println("数据为空");
|
||||
throw new RuleEngineException("数据为空");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package com.muyu.rule.server.basic.handler;
|
||||
|
||||
import com.muyu.rule.common.domain.DataValue;
|
||||
|
||||
/**
|
||||
* @Author:张承志
|
||||
* @Package:com.muyu.rule.server.basic.handler
|
||||
* @Project:cloud-etl-rule
|
||||
* @name:DataEngineValueHandler
|
||||
* @Date:2024/8/29 14:35
|
||||
* @Description:数据值处理对象
|
||||
*/
|
||||
public class DataEngineDataSetHandler {
|
||||
|
||||
public static void set(DataValue[][] dataDescribe){DataEngineHandler.set(dataDescribe);}
|
||||
|
||||
public static DataValue[][] get(){
|
||||
return DataEngineHandler.get();
|
||||
}
|
||||
|
||||
}
|
|
@ -23,7 +23,6 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
@RequestMapping("/dispose")
|
||||
public class DataSourceDisposeController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private SourceDisposeService sourceDisposeService;
|
||||
|
||||
|
@ -51,11 +50,4 @@ public class DataSourceDisposeController {
|
|||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -176,7 +176,6 @@ public Result look (){
|
|||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -41,8 +41,7 @@ import static com.muyu.rule.server.constant.SuffixClass.Suffix_JAVA;
|
|||
*/
|
||||
@Log4j2
|
||||
@Service
|
||||
public class RuleEngineServiceImpl extends ServiceImpl<RuleEngineVersionMapper,RuleEngineVersion> implements RuleEngineVersionService {
|
||||
|
||||
public class RuleEngineServiceImpl extends ServiceImpl<RuleEngineVersionMapper, RuleEngineVersion> implements RuleEngineVersionService {
|
||||
|
||||
@Override
|
||||
public List<RuleEngineVersion> selectRuleEngineVersion(Long id) {
|
||||
|
@ -50,11 +49,10 @@ public class RuleEngineServiceImpl extends ServiceImpl<RuleEngineVersionMapper,R
|
|||
LambdaQueryWrapper<RuleEngineVersion> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
queryWrapper.eq(
|
||||
RuleEngineVersion::getRuleId,id);
|
||||
RuleEngineVersion::getRuleId, id);
|
||||
|
||||
List<RuleEngineVersion> versionList = this.list(queryWrapper);
|
||||
|
||||
|
||||
return versionList;
|
||||
}
|
||||
|
||||
|
@ -72,30 +70,28 @@ public class RuleEngineServiceImpl extends ServiceImpl<RuleEngineVersionMapper,R
|
|||
public String dataGenerate(String dataSource) {
|
||||
|
||||
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* bucket名称
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private static String bucketName = "zcz-vfd-1000";
|
||||
|
||||
/**
|
||||
*
|
||||
* @param versionClazz java源代码
|
||||
* @param className 类的名
|
||||
* @param className 类的名
|
||||
*/
|
||||
@Override
|
||||
public void Upload(String versionClazz,String className) {
|
||||
|
||||
public void Upload(String versionClazz, String className) {
|
||||
|
||||
/**
|
||||
* 将java源码存入OSS
|
||||
*/
|
||||
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(versionClazz.getBytes());
|
||||
OssUtil.uploadFileInputStreamForBucket(bucketName,className+Suffix_JAVA,byteArrayInputStream);
|
||||
OssUtil.uploadFileInputStreamForBucket(bucketName, className + Suffix_JAVA, byteArrayInputStream);
|
||||
|
||||
}
|
||||
|
||||
|
@ -104,29 +100,28 @@ public class RuleEngineServiceImpl extends ServiceImpl<RuleEngineVersionMapper,R
|
|||
|
||||
String string = OssUtil.readFileContentFromOSS(bucketName, className);
|
||||
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void HotLoadClass(String className, String versionClazz) {
|
||||
|
||||
String ossFilePath = className+Suffix_JAVA;
|
||||
|
||||
String filePath ="home/"+ossFilePath;
|
||||
|
||||
OssUtil.downloadFileForBucket(bucketName,ossFilePath,filePath);
|
||||
String ossFilePath = className + Suffix_JAVA;
|
||||
|
||||
EngineConfig engineConfig = new EngineConfig();
|
||||
|
||||
SourceCodeComplier.javaCompilerPath(engineConfig.getServerWay());
|
||||
// String filePath ="home/"+ossFilePath;
|
||||
String filePath = engineConfig.getServerPath() + ossFilePath;
|
||||
|
||||
OssUtil.downloadFileForBucket(bucketName, ossFilePath, filePath);
|
||||
|
||||
SourceCodeComplier.javaCompilerPath(engineConfig.getServerPath());
|
||||
|
||||
//对class文件进行自定义类加载规则引擎
|
||||
Map<String ,Class<?>> stringClassMap = JavaBinaryClassLoader.loadClassesByLocation(engineConfig.getServerPack(),engineConfig.getServerWay());
|
||||
Map<String, Class<?>> stringClassMap = JavaBinaryClassLoader.loadClassesByLocation(engineConfig.getServerPack(), engineConfig.getServerPath());
|
||||
}
|
||||
|
||||
static Map<String , BasicEngine<DataValue>> engineMap = new ConcurrentHashMap<>();
|
||||
|
||||
static Map<String, BasicEngine<DataValue>> engineMap = new ConcurrentHashMap<>();
|
||||
|
||||
static {
|
||||
try {
|
||||
|
@ -155,26 +150,20 @@ public class RuleEngineServiceImpl extends ServiceImpl<RuleEngineVersionMapper,R
|
|||
|
||||
valueBasicEngine.execution();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改激活
|
||||
*
|
||||
* @param id
|
||||
* @param open
|
||||
*/
|
||||
public void updateOpen(Long id, String open){
|
||||
|
||||
public void updateOpen(Long id, String open) {
|
||||
|
||||
UpdateWrapper<RuleEngineVersion> updateWrapper = new UpdateWrapper<>();
|
||||
|
||||
updateWrapper.eq("id",id).set("open",open);
|
||||
updateWrapper.eq("id", id).set("open", open);
|
||||
|
||||
this.update(updateWrapper);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue