11111
parent
51c8699f86
commit
877eb048d3
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
<artifactId>cloud-rule-common</artifactId>
|
<artifactId>cloud-rule-common</artifactId>
|
||||||
|
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
<maven.compiler.target>17</maven.compiler.target>
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
@ -23,6 +24,12 @@
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
<artifactId>cloud-common-core</artifactId>
|
<artifactId>cloud-common-core</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- oss 图片上传 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.aliyun.oss</groupId>
|
||||||
|
<artifactId>aliyun-sdk-oss</artifactId>
|
||||||
|
<version>3.12.0</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.muyu.rule.common.domain;
|
package com.muyu.rule.common.domain;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@ -12,9 +13,10 @@ import lombok.NoArgsConstructor;
|
||||||
* @Date:2024/8/27 9:18
|
* @Date:2024/8/27 9:18
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@Builder
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class DataDescribe {
|
public class DataValue {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 键
|
* 键
|
|
@ -35,6 +35,11 @@ public class RuleEngineVersion extends BaseEntity {
|
||||||
* 版本名称
|
* 版本名称
|
||||||
*/
|
*/
|
||||||
private String versionName;
|
private String versionName;
|
||||||
|
/**
|
||||||
|
* 版本类名
|
||||||
|
*/
|
||||||
|
|
||||||
|
private String className;
|
||||||
/**
|
/**
|
||||||
* 版本编码
|
* 版本编码
|
||||||
*/
|
*/
|
||||||
|
@ -75,6 +80,7 @@ public class RuleEngineVersion extends BaseEntity {
|
||||||
.versionName(versionAddReq.getVersionName())
|
.versionName(versionAddReq.getVersionName())
|
||||||
.versionCode(versionAddReq.getVersionCode())
|
.versionCode(versionAddReq.getVersionCode())
|
||||||
.versionClazz(versionAddReq.getVersionClazz())
|
.versionClazz(versionAddReq.getVersionClazz())
|
||||||
|
.className(versionAddReq.getClassName())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,12 @@ public class VersionAddReq {
|
||||||
* 版本名称
|
* 版本名称
|
||||||
*/
|
*/
|
||||||
private String versionName;
|
private String versionName;
|
||||||
|
/**
|
||||||
|
* 版本类名
|
||||||
|
*/
|
||||||
|
|
||||||
|
private String className;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 版本编码
|
* 版本编码
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,162 @@
|
||||||
|
package com.muyu.rule.common.utils;
|
||||||
|
|
||||||
|
import com.aliyun.oss.OSS;
|
||||||
|
import com.aliyun.oss.OSSClientBuilder;
|
||||||
|
import com.aliyun.oss.model.GetObjectRequest;
|
||||||
|
import com.aliyun.oss.model.PutObjectRequest;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Oss服务调用
|
||||||
|
*/
|
||||||
|
@Log4j2
|
||||||
|
public class OssUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Endpoint 存储对象概述 阿里云主账号AccessKey,accessKeySecret拥有所有API的访问权限 访问路径前缀 存储对象概述
|
||||||
|
*/
|
||||||
|
private static String endPoint = "oss-cn-shanghai.aliyuncs.com";
|
||||||
|
private static String accessKeyId = "LTAI5tDbRqXkC5i3SMrCSDcX";
|
||||||
|
private static String accessKeySecret = "XUzMZoHPLsjNLafHsdQnMElBWZATsu";
|
||||||
|
private static String accessPre = "https://mall-bw.oss-cn-shanghai.aliyuncs.com/";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* bucket名称
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private static String bucketName = "mall-bw";
|
||||||
|
|
||||||
|
private static OSS ossClient;
|
||||||
|
|
||||||
|
static {
|
||||||
|
ossClient = new OSSClientBuilder().build(
|
||||||
|
endPoint,
|
||||||
|
accessKeyId,
|
||||||
|
accessKeySecret);
|
||||||
|
log.info("oss服务连接成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认路径上传本地文件
|
||||||
|
*
|
||||||
|
* @param filePath
|
||||||
|
*/
|
||||||
|
public static String uploadFile(String filePath) {
|
||||||
|
return uploadFileForBucket(bucketName, getOssFilePath(filePath), filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认路径上传multipartFile文件
|
||||||
|
*
|
||||||
|
* @param multipartFile
|
||||||
|
*/
|
||||||
|
public static String uploadMultipartFile(MultipartFile multipartFile) {
|
||||||
|
return uploadMultipartFile(bucketName, getOssFilePath(multipartFile.getOriginalFilename()), multipartFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传 multipartFile 类型文件
|
||||||
|
*
|
||||||
|
* @param bucketName
|
||||||
|
* @param ossPath
|
||||||
|
* @param multipartFile
|
||||||
|
*/
|
||||||
|
public static String uploadMultipartFile(String bucketName, String ossPath, MultipartFile multipartFile) {
|
||||||
|
InputStream inputStream = null;
|
||||||
|
try {
|
||||||
|
inputStream = multipartFile.getInputStream();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
uploadFileInputStreamForBucket(bucketName, ossPath, inputStream);
|
||||||
|
return accessPre + ossPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用File上传PutObject上传文件 ** 程序默认使用次方法上传
|
||||||
|
*
|
||||||
|
* @param bucketName 实例名称
|
||||||
|
* @param ossPath oss存储路径
|
||||||
|
* @param filePath 本地文件路径
|
||||||
|
*/
|
||||||
|
public static String uploadFileForBucket(String bucketName, String ossPath, String filePath) {
|
||||||
|
// 创建PutObjectRequest对象。
|
||||||
|
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, ossPath, new File(filePath));
|
||||||
|
|
||||||
|
// 上传
|
||||||
|
ossClient.putObject(putObjectRequest);
|
||||||
|
return accessPre + ossPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用文件流上传到指定的bucket实例
|
||||||
|
*
|
||||||
|
* @param bucketName 实例名称
|
||||||
|
* @param ossPath oss存储路径
|
||||||
|
* @param filePath 本地文件路径
|
||||||
|
*/
|
||||||
|
public static String uploadFileInputStreamForBucket(String bucketName, String ossPath, String filePath) {
|
||||||
|
|
||||||
|
// 填写本地文件的完整路径。如果未指定本地路径,则默认从示例程序所属项目对应本地路径中上传文件流。
|
||||||
|
InputStream inputStream = null;
|
||||||
|
try {
|
||||||
|
inputStream = new FileInputStream(filePath);
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
// 填写Bucket名称和Object完整路径。Object完整路径中不能包含Bucket名称。
|
||||||
|
uploadFileInputStreamForBucket(bucketName, ossPath, inputStream);
|
||||||
|
return accessPre + ossPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void uploadFileInputStreamForBucket(String bucketName, String ossPath, InputStream inputStream) {
|
||||||
|
ossClient.putObject(bucketName, ossPath, inputStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载
|
||||||
|
*
|
||||||
|
* @param ossFilePath
|
||||||
|
* @param filePath
|
||||||
|
*/
|
||||||
|
public static void downloadFile(String ossFilePath, String filePath) {
|
||||||
|
downloadFileForBucket(bucketName, ossFilePath, filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载
|
||||||
|
*
|
||||||
|
* @param bucketName 实例名称
|
||||||
|
* @param ossFilePath oss存储路径
|
||||||
|
* @param filePath 本地文件路径
|
||||||
|
*/
|
||||||
|
public static void downloadFileForBucket(String bucketName, String ossFilePath, String filePath) {
|
||||||
|
ossClient.getObject(new GetObjectRequest(bucketName, ossFilePath), new File(filePath));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getOssDefaultPath() {
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
String url =
|
||||||
|
now.getYear() + "/" +
|
||||||
|
now.getMonth() + "/" +
|
||||||
|
now.getDayOfMonth() + "/" +
|
||||||
|
now.getHour() + "/" +
|
||||||
|
now.getMinute() + "/";
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getOssFilePath(String filePath) {
|
||||||
|
String fileSuf = filePath.substring(filePath.indexOf(".") + 1);
|
||||||
|
return getOssDefaultPath() + UUID.randomUUID().toString() + "." + fileSuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
package com.muyu.rule.server;
|
package com.muyu.rule.server;
|
||||||
|
|
||||||
import com.muyu.rule.common.domain.DataDescribe;
|
import com.muyu.rule.common.domain.DataValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:张承志
|
* @Author:张承志
|
||||||
|
@ -12,7 +12,7 @@ import com.muyu.rule.common.domain.DataDescribe;
|
||||||
public class DataTest {
|
public class DataTest {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
DataDescribe describe = new DataDescribe();
|
DataValue describe = new DataValue();
|
||||||
|
|
||||||
|
|
||||||
describe.setKey("name");
|
describe.setKey("name");
|
||||||
|
|
|
@ -35,7 +35,6 @@ public class EngineTest {
|
||||||
params.put("idcard","142021200212215977");
|
params.put("idcard","142021200212215977");
|
||||||
Object engineObject = EngineExecution.engineExe("Engine_2024_8_23_2347", params);
|
Object engineObject = EngineExecution.engineExe("Engine_2024_8_23_2347", params);
|
||||||
|
|
||||||
|
|
||||||
System.out.println("====>"+engineObject);
|
System.out.println("====>"+engineObject);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
package com.muyu.rule.server;
|
||||||
|
|
||||||
|
import com.muyu.rule.common.domain.DataValue;
|
||||||
|
import com.muyu.rule.server.basic.BasicEngine;
|
||||||
|
import com.muyu.rule.server.basic.engine.ENGINE_VALUE_VFD1000_V1;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:张承志
|
||||||
|
* @Package:com.muyu.rule.server
|
||||||
|
* @Project:cloud-etl-rule
|
||||||
|
* @name:Main
|
||||||
|
* @Date:2024/8/29 15:57
|
||||||
|
*/
|
||||||
|
public class Main {
|
||||||
|
|
||||||
|
static Map<String , BasicEngine<DataValue>> engineMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
Class<?> aClass = Class.forName("com.muyu.rule.server.basic.engine.ENGINE_VALUE_VFD1000_V1");
|
||||||
|
|
||||||
|
try {
|
||||||
|
engineMap.put("ENGINE_VALUE_VFD1000_V1", (BasicEngine<DataValue>) aClass.newInstance());
|
||||||
|
} catch (InstantiationException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
DataValue dataValue = DataValue.builder()
|
||||||
|
.type("String")
|
||||||
|
.label("姓名")
|
||||||
|
.key("name")
|
||||||
|
.value(null)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
BasicEngine<DataValue> engineValue = engineMap.get("ENGINE_VALUE_VFD1000_V1");
|
||||||
|
|
||||||
|
engineValue.set(dataValue);
|
||||||
|
|
||||||
|
engineValue.execution();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.muyu.rule.server.basic;
|
||||||
|
|
||||||
|
import com.muyu.rule.common.domain.DataValue;
|
||||||
|
import com.muyu.rule.server.basic.handler.DataEngineHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:张承志
|
||||||
|
* @Package:com.muyu.rule.server.basic
|
||||||
|
* @Project:cloud-etl-rule
|
||||||
|
* @name:BasicEngine
|
||||||
|
* @Date:2024/8/29 14:29
|
||||||
|
*/
|
||||||
|
public interface BasicEngine<V> {
|
||||||
|
|
||||||
|
public void set(V dataValue);
|
||||||
|
|
||||||
|
public V get();
|
||||||
|
|
||||||
|
public default void remove(){
|
||||||
|
DataEngineHandler.remove();
|
||||||
|
}
|
||||||
|
public void execution();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -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.DataEngineRowHandler;
|
||||||
|
import com.muyu.rule.server.basic.handler.DataEngineValueHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:张承志
|
||||||
|
* @Package:com.muyu.rule.server.basic.abstracts
|
||||||
|
* @Project:cloud-etl-rule
|
||||||
|
* @name:DataEngineValueAu
|
||||||
|
* @Date:2024/8/29 15:11
|
||||||
|
*/
|
||||||
|
public abstract class DataEngineRowActuator implements BasicEngine<DataValue[]> {
|
||||||
|
|
||||||
|
public void set(DataValue[] dataValue){
|
||||||
|
DataEngineRowHandler.set(dataValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataValue[] get(){
|
||||||
|
return DataEngineRowHandler.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
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.DataEngineValueHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:张承志
|
||||||
|
* @Package:com.muyu.rule.server.basic.abstracts
|
||||||
|
* @Project:cloud-etl-rule
|
||||||
|
* @name:DataEngineValueAu
|
||||||
|
* @Date:2024/8/29 15:11
|
||||||
|
*/
|
||||||
|
public abstract class DataEngineValueActuator implements BasicEngine<DataValue> {
|
||||||
|
|
||||||
|
public void set(DataValue dataValue){
|
||||||
|
DataEngineValueHandler.set(dataValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataValue get(){
|
||||||
|
return DataEngineValueHandler.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execution() {
|
||||||
|
this.run();
|
||||||
|
this.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void run();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.muyu.rule.server.basic.engine;
|
||||||
|
|
||||||
|
import com.muyu.rule.common.domain.DataValue;
|
||||||
|
import com.muyu.rule.server.basic.abstracts.DataEngineValueActuator;
|
||||||
|
|
||||||
|
import javax.xml.crypto.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:张承志
|
||||||
|
* @Package:com.muyu.rule.server.basic.engine
|
||||||
|
* @Project:cloud-etl-rule
|
||||||
|
* @name:ENGINE_VALUE_VFD1000_V1
|
||||||
|
* @Date:2024/8/29 15:51
|
||||||
|
*/
|
||||||
|
public class ENGINE_VALUE_VFD1000_V1 extends DataEngineValueActuator {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
DataValue dataValue = get();
|
||||||
|
if (dataValue.getValue() == null){
|
||||||
|
System.out.println("数据为空");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.muyu.rule.server.basic.engine;
|
||||||
|
|
||||||
|
import com.muyu.rule.common.domain.DataValue;
|
||||||
|
import com.muyu.rule.common.utils.Desensitization;
|
||||||
|
import com.muyu.rule.server.basic.abstracts.DataEngineValueActuator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:张承志
|
||||||
|
* @Package:com.muyu.rule.server.basic.engine
|
||||||
|
* @Project:cloud-etl-rule
|
||||||
|
* @name:ENGINE_VALUE_VFD1000_V1
|
||||||
|
* @Date:2024/8/29 15:51
|
||||||
|
*/
|
||||||
|
public class ENGINE_VALUE_VFD1000_V2 extends DataEngineValueActuator {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
DataValue dataValue = get();
|
||||||
|
|
||||||
|
String string = Desensitization.mobilePhoneDesensitization((String) dataValue.getValue());
|
||||||
|
|
||||||
|
System.out.println("手机号脱敏的结果是====>"+string);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.muyu.rule.server.basic.handler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:张承志
|
||||||
|
* @Package:com.muyu.rule.server.basic
|
||||||
|
* @Project:cloud-etl-rule
|
||||||
|
* @name:DataEngineHandler
|
||||||
|
* @Date:2024/8/29 14:21
|
||||||
|
*/
|
||||||
|
public class DataEngineHandler {
|
||||||
|
|
||||||
|
private static final ThreadLocal<Object> dataEngineHandler = new ThreadLocal<>();
|
||||||
|
|
||||||
|
public static void set(final Object handler){
|
||||||
|
|
||||||
|
dataEngineHandler.set(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> T get(){
|
||||||
|
|
||||||
|
return (T) dataEngineHandler.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void remove(){
|
||||||
|
dataEngineHandler.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.muyu.rule.server.basic.handler;
|
||||||
|
|
||||||
|
import com.muyu.common.core.text.Convert;
|
||||||
|
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 DataEngineRowHandler {
|
||||||
|
|
||||||
|
public static void set(DataValue[] dataDescribe){DataEngineHandler.set(dataDescribe);}
|
||||||
|
|
||||||
|
public static DataValue[] get(){
|
||||||
|
return DataEngineHandler.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
package com.muyu.rule.server.basic.handler;
|
||||||
|
|
||||||
|
import com.muyu.common.core.text.Convert;
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
public class DataEngineValueHandler {
|
||||||
|
|
||||||
|
|
||||||
|
public static void set(DataValue dataDescribe){
|
||||||
|
|
||||||
|
DataEngineHandler.set(dataDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static DataValue get(){
|
||||||
|
return DataEngineHandler.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void remove(){
|
||||||
|
DataEngineHandler.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static Object getValue(){
|
||||||
|
return get().getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Integer getInt(){
|
||||||
|
return Convert.toInt(getValue(),null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Binary file not shown.
|
@ -25,7 +25,7 @@ public class Engine_2024_8_23_2347 {
|
||||||
|
|
||||||
// 获取当前年份
|
// 获取当前年份
|
||||||
LocalDate currentDate = LocalDate.now();
|
LocalDate currentDate = LocalDate.now();
|
||||||
Integer currentYear = currentDate.getYear();
|
// Integer currentYear = currentDate.getYear();
|
||||||
|
|
||||||
// 计算年龄
|
// 计算年龄
|
||||||
Period age = Period.between(LocalDate.of(year, 1, 1), currentDate);
|
Period age = Period.between(LocalDate.of(year, 1, 1), currentDate);
|
||||||
|
|
|
@ -0,0 +1,81 @@
|
||||||
|
package com.muyu.rule.server.util;
|
||||||
|
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:张承志
|
||||||
|
* @Package:com.muyu.rule.server.util
|
||||||
|
* @Project:cloud-etl-rule
|
||||||
|
* @name:FileUtil
|
||||||
|
* @Date:2024/8/29 8:39
|
||||||
|
*/
|
||||||
|
@Log4j2
|
||||||
|
public class FileLoadUtil {
|
||||||
|
|
||||||
|
public static void writeFile(String filePath,String fileName,String content){
|
||||||
|
try {
|
||||||
|
String javaFile = fileName + filePath.split(".")[0];
|
||||||
|
|
||||||
|
// File file = new File(filePath + "//" + fileName + ".java");
|
||||||
|
|
||||||
|
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(javaFile));
|
||||||
|
//写入
|
||||||
|
bufferedWriter.write(content);
|
||||||
|
//刷新
|
||||||
|
bufferedWriter.flush();
|
||||||
|
bufferedWriter.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String readFile(String filePath,String fileName){
|
||||||
|
File file = new File(filePath + '\\' + fileName + ".java");
|
||||||
|
|
||||||
|
try {
|
||||||
|
BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
|
||||||
|
|
||||||
|
String content;
|
||||||
|
String len;
|
||||||
|
for (content = "";(len=bufferedReader.readLine())!= null;content = content +len + "\n"){
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return null;
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.info("读取[{}]文件失败 ---> {}",fileName,e.getMessage(),e);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue