11111
parent
bb101c92b3
commit
9a492da4a3
|
@ -1,4 +1,4 @@
|
|||
package com.muyu.rule.common.basic.engine.dataSet;
|
||||
package com.muyu.rule.common.engine.dataSet;
|
||||
|
||||
import com.muyu.rule.common.basic.abstracts.DataEngineDataSetActuator;
|
||||
import com.muyu.rule.common.domain.DataValue;
|
|
@ -1,4 +1,4 @@
|
|||
package com.muyu.rule.common.basic.engine.row;
|
||||
package com.muyu.rule.common.engine.row;
|
||||
|
||||
import com.muyu.rule.common.basic.abstracts.DataEngineRowActuator;
|
||||
import com.muyu.rule.common.domain.DataValue;
|
|
@ -1,4 +1,4 @@
|
|||
package com.muyu.rule.common.basic.engine.value;
|
||||
package com.muyu.rule.common.engine.value;
|
||||
|
||||
import com.muyu.rule.common.domain.DataValue;
|
||||
import com.muyu.rule.common.basic.abstracts.DataEngineValueActuator;
|
||||
|
@ -15,7 +15,9 @@ public class ENGINE_VALUE_VFD1000_V1 extends DataEngineValueActuator {
|
|||
public void run() {
|
||||
DataValue dataValue = get();
|
||||
if (dataValue.getValue() == null){
|
||||
|
||||
System.out.println("数据为空");
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.muyu.rule.common.basic.engine.value;
|
||||
package com.muyu.rule.common.engine.value;
|
||||
|
||||
import com.muyu.rule.common.basic.abstracts.DataEngineValueActuator;
|
||||
import com.muyu.rule.common.domain.DataValue;
|
|
@ -1,4 +1,4 @@
|
|||
package com.muyu.rule.common.basic.engine.value;
|
||||
package com.muyu.rule.common.engine.value;
|
||||
|
||||
import com.muyu.rule.common.domain.DataValue;
|
||||
import com.muyu.rule.common.basic.abstracts.DataEngineValueActuator;
|
|
@ -1,7 +1,9 @@
|
|||
package com.muyu.rule.common.utils;
|
||||
|
||||
import com.aliyun.oss.ClientException;
|
||||
import com.aliyun.oss.OSS;
|
||||
import com.aliyun.oss.OSSClientBuilder;
|
||||
import com.aliyun.oss.OSSException;
|
||||
import com.aliyun.oss.model.GetObjectRequest;
|
||||
import com.aliyun.oss.model.OSSObject;
|
||||
import com.aliyun.oss.model.PutObjectRequest;
|
||||
|
@ -198,6 +200,19 @@ public class OssUtil {
|
|||
}
|
||||
}
|
||||
|
||||
public static void ssss(String fileName){
|
||||
try {
|
||||
// 假设这是你的.class文件路径
|
||||
String filePath = "/home/lib/com/muyu/rule/common/engine/value/"+fileName+".class";
|
||||
ossClient.putObject(bucketName, fileName+".class", new File(filePath));
|
||||
log.info("存储oss成功"+fileName+".class");
|
||||
} catch (OSSException oe) {
|
||||
System.err.println("存储失败: " + oe.getErrorCode() + oe.getErrorMessage());
|
||||
} catch (ClientException ce) {
|
||||
System.err.println("存储失败: " + ce.getErrorMessage());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ import java.io.IOException;
|
|||
* 实现项目启动时,把文件下载到服务器里
|
||||
*/
|
||||
@Log4j2
|
||||
//@Component
|
||||
@Component
|
||||
public class DownloadOss implements ApplicationRunner {
|
||||
|
||||
private static final String endPoint = "oss-cn-beijing.aliyuncs.com";
|
||||
|
@ -51,6 +51,11 @@ private static String serverPath ="home/source/";
|
|||
String key = objectSummary.getKey();
|
||||
downloadFile(ossClient, bucketName, key, serverPath);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 关闭OSSClient
|
||||
ossClient.shutdown();
|
||||
}
|
||||
|
|
|
@ -22,10 +22,10 @@ public class Main {
|
|||
static Map<String,BasicEngine<DataValue[][]>> engineDataSetMap = new ConcurrentHashMap<>();
|
||||
static {
|
||||
try {
|
||||
Class<?> aClass = Class.forName("com.muyu.rule.common.basic.engine.value.ENGINE_VALUE_VFD1000_V1");
|
||||
Class<?> aClass2 = Class.forName("com.muyu.rule.common.basic.engine.value.ENGINE_VALUE_VFD1000_V2");
|
||||
Class<?> aClass3 = Class.forName("com.muyu.rule.common.basic.engine.row.ENGINE_ROW_HANG_R1");
|
||||
Class<?> aClass4 = Class.forName("com.muyu.rule.common.basic.engine.dataSet.ENGINE_DataSet_asdf_S1");
|
||||
Class<?> aClass = Class.forName("com.muyu.rule.common.engine.value.ENGINE_VALUE_VFD1000_V1");
|
||||
Class<?> aClass2 = Class.forName("com.muyu.rule.common.engine.value.ENGINE_VALUE_VFD1000_V2");
|
||||
Class<?> aClass3 = Class.forName("com.muyu.rule.common.engine.row.ENGINE_ROW_HANG_R1");
|
||||
Class<?> aClass4 = Class.forName("com.muyu.rule.common.engine.dataSet.ENGINE_DataSet_asdf_S1");
|
||||
try {
|
||||
engineMap.put("ENGINE_VALUE_VFD1000_V1", (BasicEngine<DataValue>) aClass.newInstance());
|
||||
engineMap.put("ENGINE_VALUE_VFD1000_V2", (BasicEngine<DataValue>) aClass2.newInstance());
|
||||
|
|
|
@ -51,7 +51,7 @@ public class OSSClassLoaderExample {
|
|||
|
||||
Class<?> aClass = null;
|
||||
try {
|
||||
aClass = Class.forName("com.muyu.rule.common.basic.engine.value.ENGINE_phone_zzzzz_V9");
|
||||
aClass = Class.forName("com.muyu.rule.common.engine.value.ENGINE_phone_zzzzz_V9");
|
||||
|
||||
BasicEngine<DataValue> object =(BasicEngine<DataValue>)aClass.newInstance();
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ public class RuleEngineVersionController {
|
|||
String versionClazz = ver.getVersionClazz();
|
||||
String className = ver.getClassName();
|
||||
|
||||
versionService.Upload(versionClazz,className);
|
||||
// versionService.Upload(versionClazz,className);
|
||||
|
||||
return Result.success();
|
||||
}
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
package com.muyu.rule.server.engine;
|
||||
|
||||
|
||||
import com.muyu.rule.server.annotation.EngineParam;
|
||||
import com.muyu.rule.server.pool.container.EngineContainer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.Period;
|
||||
import java.util.Date;
|
||||
public class Engine_2024_8_23_2347 {
|
||||
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(Engine_2024_8_23_2347.class);
|
||||
|
||||
public String execute( @EngineParam(name = "idcard") String idcard) {
|
||||
|
||||
String msg = "";
|
||||
System.out.println();
|
||||
try {
|
||||
// 提取年份
|
||||
String yearStr = idcard.substring(6, 10);
|
||||
Integer year = Integer.parseInt(yearStr);
|
||||
|
||||
// 获取当前年份
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
// Integer currentYear = currentDate.getYear();
|
||||
|
||||
// 计算年龄
|
||||
Period age = Period.between(LocalDate.of(year, 1, 1), currentDate);
|
||||
msg = "这个身份证的年龄是: " + age.getYears();
|
||||
|
||||
// 判断性别
|
||||
String genderStr = idcard.substring(16, 17);
|
||||
Integer gender = Integer.parseInt(genderStr);
|
||||
if (gender % 2 == 0) {
|
||||
msg += ", 这个身份证是女生";
|
||||
} else {
|
||||
msg += ", 这个身份证是男生";
|
||||
}
|
||||
|
||||
// 获取规则引擎数量
|
||||
Integer sumEngine = EngineContainer.getSumEngine();
|
||||
log.info("项目中规则引擎数量为: {}", sumEngine);
|
||||
|
||||
// 可选:获取 User 对象并打印信息
|
||||
// User user = Springutils.getBean(User.class);
|
||||
// log.info("{} --- {}", user.getName(), user.getAge());
|
||||
|
||||
return msg;
|
||||
} catch (Exception e) {
|
||||
log.error("处理身份证号码时发生错误: {}", e.getMessage(), e);
|
||||
return "处理身份证号码时发生错误: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,7 +14,6 @@ import com.muyu.rule.server.load.ExternalClassLoader;
|
|||
import com.muyu.rule.server.mapper.RuleEngineVersionMapper;
|
||||
import com.muyu.rule.server.service.RuleEngineVersionService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.tools.JavaCompiler;
|
||||
|
@ -99,12 +98,12 @@ public class RuleEngineVersionServiceImpl extends ServiceImpl<RuleEngineVersionM
|
|||
return string;
|
||||
}
|
||||
|
||||
static Map<String, BasicEngine<DataValue>> engineMap = new ConcurrentHashMap<>();
|
||||
public static Map<String, BasicEngine<DataValue>> engineMap = new ConcurrentHashMap<>();
|
||||
public static final String engineWorkSourcePath = "home/source/";
|
||||
public static final String engineWorkClassPath = "home/class/";
|
||||
//
|
||||
//
|
||||
public static final String className_prefix = "com.muyu.rule.common.basic.engine.value.";
|
||||
public static final String className_prefix = "com.muyu.rule.common.engine.value.";
|
||||
|
||||
|
||||
//todo
|
||||
|
@ -149,9 +148,12 @@ public class RuleEngineVersionServiceImpl extends ServiceImpl<RuleEngineVersionM
|
|||
} else {
|
||||
System.out.println("错误");
|
||||
}
|
||||
|
||||
OssUtil.ssss(className);
|
||||
|
||||
// 假设这是你的外部类文件路径
|
||||
String externalClassFilePath =
|
||||
"home/lib/" + "com/muyu/rule/common/basic/engine/value/" + className + Suffix_CLASS;
|
||||
"home/lib/" + "com/muyu/rule/common/engine/value/" + className + Suffix_CLASS;
|
||||
Path classFilePath = Paths.get(externalClassFilePath);
|
||||
String externalClassDir = externalClassFilePath.substring(0, externalClassFilePath.lastIndexOf('/'));
|
||||
URL[] urls = new URL[]{new File(externalClassDir).toURI().toURL()};
|
||||
|
@ -198,6 +200,11 @@ public class RuleEngineVersionServiceImpl extends ServiceImpl<RuleEngineVersionM
|
|||
@Override
|
||||
public void testValue(String versionClazz, DataValue dataValue) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
BasicEngine<DataValue> valueBasicEngine = engineMap.get(versionClazz);
|
||||
|
||||
valueBasicEngine.set(dataValue);
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue