11111
parent
cbeb41ba7a
commit
c79f4f974f
|
@ -13,11 +13,15 @@ import com.muyu.rule.common.basic.handler.DataEngineHandler;
|
||||||
* @Date:2024/8/29 15:11
|
* @Date:2024/8/29 15:11
|
||||||
*/
|
*/
|
||||||
public abstract class DataEngineDataSetActuator implements BasicEngine<DataValue[][]> {
|
public abstract class DataEngineDataSetActuator implements BasicEngine<DataValue[][]> {
|
||||||
|
|
||||||
|
|
||||||
public void setDataValue(String dataValue){
|
public void setDataValue(String dataValue){
|
||||||
DataEngineHandler.set(dataValue);
|
DataEngineHandler.set(dataValue);
|
||||||
}
|
}
|
||||||
public String getDataValue(){return DataEngineHandler.get();}
|
public String getDataValue(){return DataEngineHandler.get();}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void set(DataValue[][] dataValue){
|
public void set(DataValue[][] dataValue){
|
||||||
DataEngineDataSetHandler.set(dataValue);
|
DataEngineDataSetHandler.set(dataValue);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.muyu.rule.common.engine.dataSet;
|
package com.muyu.rule.common.engine;
|
||||||
|
|
||||||
import com.muyu.common.domain.DataValue;
|
import com.muyu.common.domain.DataValue;
|
||||||
import com.muyu.rule.common.basic.abstracts.DataEngineDataSetActuator;
|
import com.muyu.rule.common.basic.abstracts.DataEngineDataSetActuator;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.muyu.rule.common.engine.dataSet;
|
package com.muyu.rule.common.engine;
|
||||||
|
|
||||||
import cn.hutool.core.util.DesensitizedUtil;
|
import cn.hutool.core.util.DesensitizedUtil;
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.muyu.rule.common.engine.row;
|
package com.muyu.rule.common.engine;
|
||||||
|
|
||||||
import com.muyu.common.domain.DataValue;
|
import com.muyu.common.domain.DataValue;
|
||||||
import com.muyu.rule.common.basic.abstracts.DataEngineRowActuator;
|
import com.muyu.rule.common.basic.abstracts.DataEngineRowActuator;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.muyu.rule.common.engine.value;
|
package com.muyu.rule.common.engine;
|
||||||
|
|
||||||
import com.muyu.common.domain.DataValue;
|
import com.muyu.common.domain.DataValue;
|
||||||
import com.muyu.rule.common.basic.abstracts.DataEngineValueActuator;
|
import com.muyu.rule.common.basic.abstracts.DataEngineValueActuator;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.muyu.rule.common.engine.value;
|
package com.muyu.rule.common.engine;
|
||||||
|
|
||||||
import com.muyu.common.domain.DataValue;
|
import com.muyu.common.domain.DataValue;
|
||||||
import com.muyu.common.enums.DataType;
|
import com.muyu.common.enums.DataType;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.muyu.rule.common.engine.value;
|
package com.muyu.rule.common.engine;
|
||||||
|
|
||||||
import com.muyu.common.domain.DataValue;
|
import com.muyu.common.domain.DataValue;
|
||||||
import com.muyu.rule.common.basic.abstracts.DataEngineValueActuator;
|
import com.muyu.rule.common.basic.abstracts.DataEngineValueActuator;
|
|
@ -1,40 +0,0 @@
|
||||||
package com.muyu.rule.common.engine.row;
|
|
||||||
|
|
||||||
import com.muyu.common.domain.DataValue;
|
|
||||||
import com.muyu.rule.common.basic.abstracts.DataEngineRowActuator;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:张承志
|
|
||||||
* @Package:com.muyu.rule.server.basic.engine.row
|
|
||||||
* @Project:cloud-etl-rule
|
|
||||||
* @name:ENGINE_ROW_HANG_R1
|
|
||||||
* @Date:2024/8/30 11:13
|
|
||||||
*/
|
|
||||||
public class ENGINE_ROW_HANG_R1 extends DataEngineRowActuator {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据行去重
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
DataValue[] dataValues = get();
|
|
||||||
System.out.println(Arrays.toString(dataValues));
|
|
||||||
// 使用 HashSet 去重
|
|
||||||
Set<DataValue> uniquePeople = new HashSet<>(Arrays.asList(dataValues));
|
|
||||||
|
|
||||||
// 将 Set 转换回数组
|
|
||||||
DataValue[] uniqueArray = uniquePeople.toArray(new DataValue[0]);
|
|
||||||
System.out.println(Arrays.toString(uniqueArray));
|
|
||||||
set(uniqueArray);
|
|
||||||
DataValue[] dataValues1 = get();
|
|
||||||
System.out.println(Arrays.toString(dataValues1));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
package com.muyu.rule.common.engine.value;
|
|
||||||
|
|
||||||
import com.muyu.common.domain.DataValue;
|
|
||||||
import com.muyu.rule.common.basic.abstracts.DataEngineValueActuator;
|
|
||||||
import com.muyu.rule.common.exception.DeliteException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:张承志
|
|
||||||
* @Package:com.muyu.rule.server.basic.engine
|
|
||||||
* @Project:cloud-etl-rule
|
|
||||||
* @name:非空抛出异常 进行删除
|
|
||||||
* @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){
|
|
||||||
throw new DeliteException("数据为空,需要丢弃!");
|
|
||||||
}else{
|
|
||||||
System.out.println("数据非空:"+dataValue.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,45 +0,0 @@
|
||||||
package com.muyu.rule.common.engine.value;
|
|
||||||
|
|
||||||
import com.muyu.common.domain.DataValue;
|
|
||||||
import com.muyu.common.enums.DataType;
|
|
||||||
import com.muyu.rule.common.basic.abstracts.DataEngineValueActuator;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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();
|
|
||||||
|
|
||||||
if (dataValue.getValue()==null){
|
|
||||||
|
|
||||||
DataType type = dataValue.getType();
|
|
||||||
// 如果为空,添加默认值
|
|
||||||
|
|
||||||
//为整数 默认值为0
|
|
||||||
// if ("Integer".equals(string)){
|
|
||||||
// dataValue.setValue(0);
|
|
||||||
// }
|
|
||||||
// //为字符串 默认值为null
|
|
||||||
// if ("String".equals(string)){
|
|
||||||
// dataValue.setValue(null);
|
|
||||||
// }
|
|
||||||
// //为时间 默认值为当前时间
|
|
||||||
// if ("Date".equals(string)){
|
|
||||||
// LocalDateTime dateTime = LocalDateTime.now();
|
|
||||||
// dataValue.setValue(dateTime);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
package com.muyu.rule.common.engine.value;
|
|
||||||
|
|
||||||
import com.muyu.common.domain.DataValue;
|
|
||||||
import com.muyu.rule.common.basic.abstracts.DataEngineValueActuator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:张承志
|
|
||||||
* @Package:com.muyu.rule.server.basic.engine
|
|
||||||
* @Project:cloud-etl-rule
|
|
||||||
* @name:字典字段 转换
|
|
||||||
* @Date:2024/8/29 15:51
|
|
||||||
*/
|
|
||||||
public class ENGINE_VALUE_VFD1000_V3 extends DataEngineValueActuator {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
|
|
||||||
DataValue dataValue = get();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -38,7 +38,7 @@ public class DownloadOssSynchronization implements ApplicationRunner {
|
||||||
/**
|
/**
|
||||||
* 服务器项目路径放文件
|
* 服务器项目路径放文件
|
||||||
*/
|
*/
|
||||||
private static String serverClassPath = "home/lib/com/muyu/rule/common/engine/value/";
|
private static String serverClassPath = "home/lib/com/muyu/rule/common/engine/";
|
||||||
|
|
||||||
private static String bucketName = "zcz-vfd-1000";
|
private static String bucketName = "zcz-vfd-1000";
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,10 @@ public class Main {
|
||||||
static Map<String,BasicEngine<DataValue[][]>> engineDataSetMap = new ConcurrentHashMap<>();
|
static Map<String,BasicEngine<DataValue[][]>> engineDataSetMap = new ConcurrentHashMap<>();
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
Class<?> aClass = Class.forName("com.muyu.rule.common.engine.value.ENGINE_VALUE_VFD1000_V1");
|
Class<?> aClass = Class.forName("com.muyu.rule.common.engine.ENGINE_VALUE_VFD1000_V1");
|
||||||
Class<?> aClass2 = Class.forName("com.muyu.rule.common.engine.value.ENGINE_VALUE_VFD1000_V2");
|
Class<?> aClass2 = Class.forName("com.muyu.rule.common.engine.ENGINE_VALUE_VFD1000_V2");
|
||||||
Class<?> aClass3 = Class.forName("com.muyu.rule.common.engine.row.ENGINE_ROW_HANG_R1");
|
Class<?> aClass3 = Class.forName("com.muyu.rule.common.engine.ENGINE_ROW_HANG_R1");
|
||||||
Class<?> aClass4 = Class.forName("com.muyu.rule.common.engine.dataSet.ENGINE_DataSet_asdf_S1");
|
Class<?> aClass4 = Class.forName("com.muyu.rule.common.engine.ENGINE_DataSet_asdf_S1");
|
||||||
try {
|
try {
|
||||||
engineMap.put("ENGINE_VALUE_VFD1000_V1", (BasicEngine<DataValue>) aClass.newInstance());
|
engineMap.put("ENGINE_VALUE_VFD1000_V1", (BasicEngine<DataValue>) aClass.newInstance());
|
||||||
engineMap.put("ENGINE_VALUE_VFD1000_V2", (BasicEngine<DataValue>) aClass2.newInstance());
|
engineMap.put("ENGINE_VALUE_VFD1000_V2", (BasicEngine<DataValue>) aClass2.newInstance());
|
||||||
|
|
|
@ -15,7 +15,7 @@ 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/";
|
||||||
|
|
||||||
String pack = "com.muyu.rule.server.basic.engine.value.";
|
String pack = "com.muyu.rule.server.basic.engine.value.";
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ public class OSSClassLoaderExample {
|
||||||
|
|
||||||
Class<?> aClass = null;
|
Class<?> aClass = null;
|
||||||
try {
|
try {
|
||||||
aClass = Class.forName("com.muyu.rule.common.engine.value.ENGINE_phone_zzzzz_V9");
|
aClass = Class.forName("com.muyu.rule.common.engine.ENGINE_VALUE_VFD1000_V1");
|
||||||
|
|
||||||
BasicEngine<DataValue> object =(BasicEngine<DataValue>)aClass.newInstance();
|
BasicEngine<DataValue> object =(BasicEngine<DataValue>)aClass.newInstance();
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,6 @@ import java.util.List;
|
||||||
@Tag(name = "规则版本控制层", description = "规则版本管理,查看等相关操作")
|
@Tag(name = "规则版本控制层", description = "规则版本管理,查看等相关操作")
|
||||||
public class RuleEngineVersionController {
|
public class RuleEngineVersionController {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存代码
|
* 保存代码
|
||||||
* @param ruleEngineVersion
|
* @param ruleEngineVersion
|
||||||
|
@ -115,14 +114,25 @@ public class RuleEngineVersionController {
|
||||||
//String versionClass = versionService.deposit(type);
|
//String versionClass = versionService.deposit(type);
|
||||||
|
|
||||||
versionAddReq.setVersionClazz("");
|
versionAddReq.setVersionClazz("");
|
||||||
|
String parentClass = null;
|
||||||
|
if (type==1){
|
||||||
|
parentClass = "DataEngineValueActuator";
|
||||||
|
}else if (type==2){
|
||||||
|
parentClass="DataEngineRowActuator";
|
||||||
|
}else if (type==3){
|
||||||
|
parentClass="DataEngineDataSetActuator";
|
||||||
|
}
|
||||||
|
|
||||||
String template = "package com.muyu.rule.common.engine.value;\n" +
|
|
||||||
|
|
||||||
|
|
||||||
|
String template = "package com.muyu.rule.common.engine;\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"import cn.hutool.core.util.DesensitizedUtil;\n" +
|
"import cn.hutool.core.util.DesensitizedUtil;\n" +
|
||||||
"import com.alibaba.fastjson2.JSON;\n" +
|
"import com.alibaba.fastjson2.JSON;\n" +
|
||||||
"import com.alibaba.fastjson2.JSONObject;\n" +
|
"import com.alibaba.fastjson2.JSONObject;\n" +
|
||||||
"import com.muyu.common.domain.DataValue;\n" +
|
"import com.muyu.common.domain.DataValue;\n" +
|
||||||
"import com.muyu.rule.common.basic.abstracts.DataEngineDataSetActuator;\n" +
|
"import com.muyu.rule.common.basic.abstracts.${parentClass};\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"/**\n" +
|
"/**\n" +
|
||||||
|
@ -133,7 +143,7 @@ public class RuleEngineVersionController {
|
||||||
" * @Date:2024/8/30 11:13\n" +
|
" * @Date:2024/8/30 11:13\n" +
|
||||||
" */\n" +
|
" */\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"public class ${className} extends DataEngineDataSetActuator {\n" +
|
"public class ${className} extends ${parentClass} {\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
" @Override\n" +
|
" @Override\n" +
|
||||||
" public void run() {\n" +
|
" public void run() {\n" +
|
||||||
|
@ -159,6 +169,7 @@ public class RuleEngineVersionController {
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
String versionClass = template.replace("${className}", versionAddReq.getClassName());
|
String versionClass = template.replace("${className}", versionAddReq.getClassName());
|
||||||
|
versionClass = template.replace("${parentClass}",parentClass);
|
||||||
|
|
||||||
versionAddReq.setVersionClazz(versionClass);
|
versionAddReq.setVersionClazz(versionClass);
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@ public static final String importClassAndPackPath="home/lib/";
|
||||||
/**
|
/**
|
||||||
* 规则引擎的包的路径
|
* 规则引擎的包的路径
|
||||||
*/
|
*/
|
||||||
public static final String className_prefix = "com.muyu.rule.common.engine.value.";
|
public static final String className_prefix = "com.muyu.rule.common.engine.";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 服务器存放引擎的class文件的位置
|
* 服务器存放引擎的class文件的位置
|
||||||
|
@ -126,7 +126,7 @@ public static final String importClassAndPackPath="home/lib/";
|
||||||
* @param versionClazz 源代码
|
* @param versionClazz 源代码
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static final String serverClassPath = "com/muyu/rule/common/engine/value/";
|
public static final String serverClassPath = "com/muyu/rule/common/engine/";
|
||||||
|
|
||||||
|
|
||||||
//todo
|
//todo
|
||||||
|
|
Binary file not shown.
|
@ -1,25 +0,0 @@
|
||||||
package com.muyu.rule.common.basic;
|
|
||||||
|
|
||||||
import com.muyu.rule.common.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();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,39 +0,0 @@
|
||||||
package com.muyu.rule.common.basic.abstracts;
|
|
||||||
|
|
||||||
import com.muyu.common.domain.DataValue;
|
|
||||||
import com.muyu.rule.common.basic.BasicEngine;
|
|
||||||
import com.muyu.rule.common.basic.handler.DataEngineDataSetHandler;
|
|
||||||
import com.muyu.rule.common.basic.handler.DataEngineHandler;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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 setDataValue(String dataValue){
|
|
||||||
DataEngineHandler.set(dataValue);
|
|
||||||
}
|
|
||||||
public String getDataValue(){return DataEngineHandler.get();}
|
|
||||||
|
|
||||||
public void set(DataValue[][] dataValue){
|
|
||||||
DataEngineDataSetHandler.set(dataValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public DataValue[][] get(){
|
|
||||||
return DataEngineDataSetHandler.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execution() {
|
|
||||||
this.run();
|
|
||||||
this.remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void run();
|
|
||||||
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,32 +0,0 @@
|
||||||
package com.muyu.rule.common.basic.abstracts;
|
|
||||||
|
|
||||||
import com.muyu.common.domain.DataValue;
|
|
||||||
import com.muyu.rule.common.basic.BasicEngine;
|
|
||||||
import com.muyu.rule.common.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 DataEngineRowActuator implements BasicEngine<DataValue[]> {
|
|
||||||
|
|
||||||
public void set(DataValue[] dataValue){
|
|
||||||
DataEngineRowHandler.set(dataValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
public DataValue[] get(){
|
|
||||||
return DataEngineRowHandler.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execution() {
|
|
||||||
this.run();
|
|
||||||
this.remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void run();
|
|
||||||
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,33 +0,0 @@
|
||||||
package com.muyu.rule.common.basic.abstracts;
|
|
||||||
|
|
||||||
import com.muyu.common.domain.DataValue;
|
|
||||||
import com.muyu.rule.common.basic.BasicEngine;
|
|
||||||
import com.muyu.rule.common.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();
|
|
||||||
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,21 +0,0 @@
|
||||||
package com.muyu.rule.common.basic.handler;
|
|
||||||
|
|
||||||
import com.muyu.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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,36 +0,0 @@
|
||||||
package com.muyu.rule.common.basic.handler;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:张承志
|
|
||||||
* @Package:com.muyu.rule.server.basic
|
|
||||||
* @Project:cloud-etl-rule
|
|
||||||
* @name:规则引擎作用域
|
|
||||||
* @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();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,20 +0,0 @@
|
||||||
package com.muyu.rule.common.basic.handler;
|
|
||||||
|
|
||||||
import com.muyu.common.domain.DataValue;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:张承志
|
|
||||||
* @Package:com.muyu.rule.server.basic.handler
|
|
||||||
* @Project:cloud-etl-rule
|
|
||||||
* @name:数据记录/行作用域
|
|
||||||
* @Date:2024/8/29 14:35
|
|
||||||
*/
|
|
||||||
public class DataEngineRowHandler {
|
|
||||||
|
|
||||||
public static void set(DataValue[] dataDescribe){DataEngineHandler.set(dataDescribe);}
|
|
||||||
|
|
||||||
public static DataValue[] get(){
|
|
||||||
return DataEngineHandler.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,37 +0,0 @@
|
||||||
package com.muyu.rule.common.basic.handler;
|
|
||||||
|
|
||||||
import com.muyu.common.core.text.Convert;
|
|
||||||
import com.muyu.common.domain.DataValue;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:张承志
|
|
||||||
* @Package:com.muyu.rule.server.basic.handler
|
|
||||||
* @Project:cloud-etl-rule
|
|
||||||
* @name:数据值作用域
|
|
||||||
* @Date:2024/8/29 14:35
|
|
||||||
*/
|
|
||||||
public class DataEngineValueHandler {
|
|
||||||
|
|
||||||
|
|
||||||
public static void set(DataValue dataValue){
|
|
||||||
|
|
||||||
DataEngineHandler.set(dataValue);
|
|
||||||
|
|
||||||
}
|
|
||||||
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.
|
@ -1,92 +0,0 @@
|
||||||
package com.muyu.rule.common.domain;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
|
||||||
import com.muyu.rule.common.domain.req.EtlRuleAddReq;
|
|
||||||
import com.muyu.rule.common.domain.req.EtlRuleUpdReq;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:张承志
|
|
||||||
* @Package:com.muyu.damain
|
|
||||||
* @Project:cloud-etl
|
|
||||||
* @name:Rule
|
|
||||||
* @Date:2024/8/21 11:33
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@SuperBuilder
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@TableName(value = "rule_engine",autoResultMap = true)
|
|
||||||
public class RuleEngine extends BaseEntity {
|
|
||||||
|
|
||||||
/**
|
|
||||||
*主键
|
|
||||||
*/
|
|
||||||
@TableId(value = "id" , type = IdType.AUTO)
|
|
||||||
private Long id ;
|
|
||||||
/** 规则名称 */
|
|
||||||
|
|
||||||
private String name ;
|
|
||||||
/** 规则类型 */
|
|
||||||
|
|
||||||
|
|
||||||
/** 引擎编码 */
|
|
||||||
private String code;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** 规则作用域 */
|
|
||||||
private String regionName;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** 是否公开 0已激活 1未激活 */
|
|
||||||
private String open;
|
|
||||||
|
|
||||||
|
|
||||||
/** 状态 0正常 1停用 */
|
|
||||||
private String status ;
|
|
||||||
|
|
||||||
|
|
||||||
/** 规则引擎描述 */
|
|
||||||
private String ruleDesc;
|
|
||||||
|
|
||||||
public static RuleEngine updBuild(EtlRuleUpdReq etlRule, Supplier<Long> longSupplier){
|
|
||||||
|
|
||||||
return RuleEngine.builder().id(longSupplier.get())
|
|
||||||
.open(etlRule.getOpen())
|
|
||||||
.name(etlRule.getName())
|
|
||||||
.regionName(etlRule.getRegionName())
|
|
||||||
.status(etlRule.getStatus())
|
|
||||||
.code(etlRule.getCode())
|
|
||||||
.remark(etlRule.getRemark())
|
|
||||||
.ruleDesc(etlRule.getRuleDesc())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static RuleEngine addBuild(EtlRuleAddReq etlRule){
|
|
||||||
|
|
||||||
return RuleEngine.builder()
|
|
||||||
.open(etlRule.getOpen())
|
|
||||||
.name(etlRule.getName())
|
|
||||||
.regionName(etlRule.getRegionName())
|
|
||||||
.status(etlRule.getStatus())
|
|
||||||
.code(etlRule.getCode())
|
|
||||||
.ruleDesc(etlRule.getRuleDesc())
|
|
||||||
.remark(etlRule.getRemark())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,91 +0,0 @@
|
||||||
package com.muyu.rule.common.domain;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
|
||||||
import com.muyu.rule.common.domain.req.VersionAddReq;
|
|
||||||
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 {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 版本主键
|
|
||||||
*/
|
|
||||||
@TableId(value = "id" , type = IdType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
/**
|
|
||||||
* 版本名称
|
|
||||||
*/
|
|
||||||
private String versionName;
|
|
||||||
/**
|
|
||||||
* 版本类名
|
|
||||||
*/
|
|
||||||
|
|
||||||
private String className;
|
|
||||||
/**
|
|
||||||
* 版本编码
|
|
||||||
*/
|
|
||||||
private String versionCode;
|
|
||||||
/**
|
|
||||||
* 规则引擎外键
|
|
||||||
*/
|
|
||||||
private String ruleId;
|
|
||||||
/**
|
|
||||||
* 是否开启规则引擎
|
|
||||||
*/
|
|
||||||
private String open;
|
|
||||||
/**
|
|
||||||
* 版本描述
|
|
||||||
*/
|
|
||||||
private String versionDesc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 状态 0正常 1.停用
|
|
||||||
*/
|
|
||||||
|
|
||||||
private String status;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 引擎类
|
|
||||||
*/
|
|
||||||
|
|
||||||
private String versionClazz;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static RuleEngineVersion addBuild(VersionAddReq versionAddReq){
|
|
||||||
|
|
||||||
return RuleEngineVersion.builder()
|
|
||||||
.ruleId(versionAddReq.getRuleId())
|
|
||||||
.open(versionAddReq.getOpen())
|
|
||||||
.status(versionAddReq.getStatus())
|
|
||||||
.versionName(versionAddReq.getVersionName())
|
|
||||||
.versionCode(versionAddReq.getVersionCode())
|
|
||||||
.versionDesc(versionAddReq.getVersionDesc())
|
|
||||||
.versionClazz(versionAddReq.getVersionClazz())
|
|
||||||
.className(versionAddReq.getClassName())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,28 +0,0 @@
|
||||||
package com.muyu.rule.common.domain;
|
|
||||||
|
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:张承志
|
|
||||||
* @Package:com.muyu.rule.common.domain.resp
|
|
||||||
* @Project:cloud-etl-rule
|
|
||||||
* @name:RuleRegion
|
|
||||||
* @Date:2024/8/23 9:03
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Tag(name = "规则作用域")
|
|
||||||
public class RuleRegion extends BaseEntity {
|
|
||||||
|
|
||||||
private Long regionId;
|
|
||||||
|
|
||||||
private String regionName;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,48 +0,0 @@
|
||||||
package com.muyu.rule.common.domain.req;
|
|
||||||
|
|
||||||
import com.muyu.rule.common.utils.OssUtil;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:张承志
|
|
||||||
* @Package:com.muyu.etl.common.domain.req
|
|
||||||
* @Project:cloud-etl
|
|
||||||
* @name:EtlRuleAddReq
|
|
||||||
* @Date:2024/8/21 23:49
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@SuperBuilder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Tag(name = "客户端规则添加请求对象")
|
|
||||||
public class EtlRuleAddReq {
|
|
||||||
|
|
||||||
/** 规则名称 */
|
|
||||||
private String name ;
|
|
||||||
|
|
||||||
/** 引擎编码 */
|
|
||||||
private String code;
|
|
||||||
|
|
||||||
/** 是否公开 0已激活 1未激活 */
|
|
||||||
private String open;
|
|
||||||
|
|
||||||
/** 规则作用域 */
|
|
||||||
private String regionName;
|
|
||||||
|
|
||||||
/** 状态 0正常 1停用 */
|
|
||||||
private String status ;
|
|
||||||
|
|
||||||
/** 规则引擎描述 */
|
|
||||||
private String ruleDesc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 备注
|
|
||||||
*/
|
|
||||||
private String remark;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,42 +0,0 @@
|
||||||
package com.muyu.rule.common.domain.req;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:张承志
|
|
||||||
* @Package:com.muyu.etl.common.domain.req
|
|
||||||
* @Project:cloud-etl
|
|
||||||
* @name:EtlRuleListReq
|
|
||||||
* @Date:2024/8/21 21:42
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@SuperBuilder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Tag(name = "客户端规则列表请求对象")
|
|
||||||
public class EtlRuleListReq {
|
|
||||||
|
|
||||||
/** 引擎编码 */
|
|
||||||
private String code;
|
|
||||||
|
|
||||||
/** 数据来源名称 */
|
|
||||||
private String name ;
|
|
||||||
|
|
||||||
/** 是否激活公开 Y已激活 N未激活 */
|
|
||||||
private String open ;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** 状态 0正常 1停用 */
|
|
||||||
private String status ;
|
|
||||||
|
|
||||||
/** 规则引擎描述 */
|
|
||||||
private String ruleDesc;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,50 +0,0 @@
|
||||||
package com.muyu.rule.common.domain.req;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:张承志
|
|
||||||
* @Package:com.muyu.etl.common.domain.req
|
|
||||||
* @Project:cloud-etl
|
|
||||||
* @name:EtlRuleUpdReq
|
|
||||||
* @Date:2024/8/21 23:48
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@SuperBuilder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Tag(name = "客户端规则修改请求对象")
|
|
||||||
public class EtlRuleUpdReq {
|
|
||||||
|
|
||||||
|
|
||||||
/** 规则名称 */
|
|
||||||
private String name ;
|
|
||||||
|
|
||||||
/** 引擎编码 */
|
|
||||||
private String code;
|
|
||||||
|
|
||||||
/** 是否公开 0已激活 1未激活 */
|
|
||||||
private String open ;
|
|
||||||
|
|
||||||
/** 规则作用域 */
|
|
||||||
private String regionName;
|
|
||||||
|
|
||||||
/** 状态 0正常 1停用 */
|
|
||||||
private String status ;
|
|
||||||
|
|
||||||
|
|
||||||
/** 规则引擎描述 */
|
|
||||||
private String ruleDesc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 备注
|
|
||||||
*/
|
|
||||||
|
|
||||||
private String remark;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,69 +0,0 @@
|
||||||
package com.muyu.rule.common.domain.req;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:张承志
|
|
||||||
* @Package:com.muyu.rule.common.domain.req
|
|
||||||
* @Project:cloud-etl-rule
|
|
||||||
* @name:VersionAddReq
|
|
||||||
* @Date:2024/8/26 9:47
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@SuperBuilder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Tag(name = "规则版本添加请求对象")
|
|
||||||
public class VersionAddReq {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 版本名称
|
|
||||||
*/
|
|
||||||
private String versionName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 版本类名
|
|
||||||
*/
|
|
||||||
private String className;
|
|
||||||
/**
|
|
||||||
* 版本编码
|
|
||||||
*/
|
|
||||||
private String versionCode;
|
|
||||||
/**
|
|
||||||
* 规则引擎外键
|
|
||||||
*/
|
|
||||||
private String ruleId;
|
|
||||||
/**
|
|
||||||
* 是否开启规则引擎
|
|
||||||
*/
|
|
||||||
private String open;
|
|
||||||
/**
|
|
||||||
* 版本描述
|
|
||||||
*/
|
|
||||||
private String versionDesc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 状态 0正常 1.停用
|
|
||||||
*/
|
|
||||||
|
|
||||||
private String status;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 引擎类代码
|
|
||||||
*/
|
|
||||||
|
|
||||||
private String versionClazz;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 备注
|
|
||||||
*/
|
|
||||||
private String remark;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,92 +0,0 @@
|
||||||
package com.muyu.rule.common.domain.resp;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
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.tags.Tag;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:张承志
|
|
||||||
* @Package:com.muyu.etl.common.domain.resp
|
|
||||||
* @Project:cloud-etl
|
|
||||||
* @name:EtlRuleResp
|
|
||||||
* @Date:2024/8/21 21:57
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Tag(name = "规则信息相应对象", description = "负责规则信息查询的响应结果")
|
|
||||||
public class EtlRuleResp {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*主键
|
|
||||||
*/
|
|
||||||
@TableId(value = "id" , type = IdType.AUTO)
|
|
||||||
private Long id ;
|
|
||||||
|
|
||||||
/** 规则名称 */
|
|
||||||
private String name ;
|
|
||||||
|
|
||||||
/** 引擎编码 */
|
|
||||||
private String code;
|
|
||||||
|
|
||||||
|
|
||||||
/** 规则作用域 */
|
|
||||||
private String regionName;
|
|
||||||
|
|
||||||
/** 状态 0正常 1停用 */
|
|
||||||
private String status ;
|
|
||||||
|
|
||||||
/** 是否激活 */
|
|
||||||
private String open ;
|
|
||||||
|
|
||||||
/** 规则引擎描述 */
|
|
||||||
private String ruleDesc;
|
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "创建人", defaultValue = "muyu", type = "String")
|
|
||||||
private String createBy;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@Schema(description = "创建时间", defaultValue = "2024-8-1 0:22:36", type = "Date")
|
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
|
|
||||||
List<RuleEngineVersion> versionList;
|
|
||||||
|
|
||||||
|
|
||||||
public static EtlRuleResp etlRuleRespBuilder(RuleEngine etlRule){
|
|
||||||
|
|
||||||
return EtlRuleResp.builder()
|
|
||||||
.id(etlRule.getId())
|
|
||||||
.code(etlRule.getCode())
|
|
||||||
.name(etlRule.getName())
|
|
||||||
.status(etlRule.getStatus())
|
|
||||||
.open(etlRule.getOpen())
|
|
||||||
.regionName(etlRule.getRegionName())
|
|
||||||
.ruleDesc(etlRule.getRuleDesc())
|
|
||||||
.createBy(etlRule.getCreateBy())
|
|
||||||
.createTime(etlRule.getCreateTime()).build();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,27 +0,0 @@
|
||||||
package com.muyu.rule.common.engine.dataSet;
|
|
||||||
|
|
||||||
import com.muyu.common.domain.DataValue;
|
|
||||||
import com.muyu.rule.common.basic.abstracts.DataEngineDataSetActuator;
|
|
||||||
import com.muyu.rule.common.exception.DeliteException;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:张承志
|
|
||||||
* @Package:com.muyu.rule.server.basic.engine.row
|
|
||||||
* @Project:cloud-etl-rule
|
|
||||||
* @name:ENGINE_ROW_HANG_R1
|
|
||||||
* @Date:2024/8/30 11:13
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class ENGINE_DataSet_asdf_S1 extends DataEngineDataSetActuator {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
DataValue[][] dataValues = get();
|
|
||||||
if (dataValues == null || "".equals(dataValues) || "null".equals(dataValues)) {
|
|
||||||
throw new DeliteException();
|
|
||||||
}else {
|
|
||||||
System.out.println("数据检测无异常");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,41 +0,0 @@
|
||||||
package com.muyu.rule.common.engine.dataSet;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.DesensitizedUtil;
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
|
||||||
import com.muyu.common.domain.DataValue;
|
|
||||||
import com.muyu.rule.common.basic.abstracts.DataEngineDataSetActuator;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:张承志
|
|
||||||
* @Package:com.muyu.rule.server.basic.engine.row
|
|
||||||
* @Project:cloud-etl-rule
|
|
||||||
* @name:数据集指定字段进行脱敏
|
|
||||||
* @Date:2024/8/30 11:13
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class ENGINE_DataSet_ytrrt_S2 extends DataEngineDataSetActuator {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
|
|
||||||
DataValue[][] dataValues = get();
|
|
||||||
|
|
||||||
String dataValue = getDataValue();
|
|
||||||
|
|
||||||
JSONObject jsonObject = JSON.parseObject(dataValue);
|
|
||||||
|
|
||||||
String key = (String)jsonObject.get("key");
|
|
||||||
|
|
||||||
for (DataValue[] value : dataValues) {
|
|
||||||
for (DataValue dataValue1 : value) {
|
|
||||||
if (dataValue1.getKey().equals(key)){
|
|
||||||
dataValue1.setValue(DesensitizedUtil.mobilePhone((String) dataValue1.getValue()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
set(dataValues);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,30 +0,0 @@
|
||||||
package com.muyu.rule.common.exception;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:张承志
|
|
||||||
* @Package:com.muyu.rule.server.exception
|
|
||||||
* @Project:cloud-etl-rule
|
|
||||||
* @name:ActionDiscard
|
|
||||||
* @Date:2024/8/26 22:08
|
|
||||||
*/
|
|
||||||
public class DeliteException extends RuntimeException {
|
|
||||||
public DeliteException() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public DeliteException(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public DeliteException(String message, Throwable cause) {
|
|
||||||
super(message, cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
public DeliteException(Throwable cause) {
|
|
||||||
super(cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected DeliteException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
|
||||||
super(message, cause, enableSuppression, writableStackTrace);
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,271 +0,0 @@
|
||||||
package com.muyu.rule.common.utils;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import com.muyu.common.core.utils.StringUtils;
|
|
||||||
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 敏感数据脱敏工具类
|
|
||||||
*/
|
|
||||||
public class Desensitization {
|
|
||||||
/**
|
|
||||||
* 身份证号脱敏
|
|
||||||
*
|
|
||||||
* @param idCard
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String idCardDesensitization(String idCard) {
|
|
||||||
if (StringUtils.isNotEmpty(idCard)) {
|
|
||||||
// 身份证号脱敏规则一:保留前六后三
|
|
||||||
if (idCard.length() == 15) {
|
|
||||||
idCard = idCard.replaceAll("(\\w{6})\\w*(\\w{3})", "$1******$2");
|
|
||||||
} else if (idCard.length() == 18) {
|
|
||||||
idCard = idCard.replaceAll("(\\w{6})\\w*(\\w{3})", "$1*********$2");
|
|
||||||
}
|
|
||||||
// 身份证号脱敏规则二:保留前三后四
|
|
||||||
// idCard = idCard.replaceAll("(?<=\\w{3})\\w(?=\\w{4})", "*");
|
|
||||||
}
|
|
||||||
return idCard;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 手机号码脱敏
|
|
||||||
* @param mobilePhone
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String mobilePhoneDesensitization(String mobilePhone) {
|
|
||||||
// 手机号码保留前三后四
|
|
||||||
if (StringUtils.isNotEmpty(mobilePhone)) {
|
|
||||||
mobilePhone = mobilePhone.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
|
|
||||||
}
|
|
||||||
return mobilePhone;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 电子邮箱脱敏
|
|
||||||
*
|
|
||||||
* @param email
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String emailDesensitization(String email) {
|
|
||||||
// 电子邮箱隐藏@前面的3个字符
|
|
||||||
if (StringUtils.isEmpty(email)) {
|
|
||||||
return email;
|
|
||||||
}
|
|
||||||
String encrypt = email.replaceAll("(\\w+)\\w{3}@(\\w+)", "$1***@$2");
|
|
||||||
if (email.equalsIgnoreCase(encrypt)) {
|
|
||||||
encrypt = email.replaceAll("(\\w*)\\w{1}@(\\w+)", "$1*@$2");
|
|
||||||
}
|
|
||||||
return encrypt;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 银行账号脱敏
|
|
||||||
*
|
|
||||||
* @param acctNo
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String acctNoDesensitization(String acctNo) {
|
|
||||||
// 银行账号保留前六后四
|
|
||||||
if (StringUtils.isNotEmpty(acctNo)) {
|
|
||||||
String regex = "(\\w{6})(.*)(\\w{4})";
|
|
||||||
Matcher m = Pattern.compile(regex).matcher(acctNo);
|
|
||||||
if (m.find()) {
|
|
||||||
String rep = m.group(2);
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
for (int i = 0; i < rep.length(); i++) {
|
|
||||||
sb.append("*");
|
|
||||||
}
|
|
||||||
acctNo = acctNo.replaceAll(rep, sb.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return acctNo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 客户名称脱敏
|
|
||||||
*
|
|
||||||
* @param custName
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String custNameDesensitization(String custName) {
|
|
||||||
// 规则说明:
|
|
||||||
// 姓名:字符长度小于5位;企业名称:字符长度大于等于5位。
|
|
||||||
// 姓名规则
|
|
||||||
// 规则一:1个字则不脱敏,如"张"-->"张"
|
|
||||||
// 规则二:2个字则脱敏第二个字,如"张三"-->"张*"
|
|
||||||
// 规则三:3个字则脱敏第二个字,如"张三丰"-->"张*丰"
|
|
||||||
// 规则四:4个字则脱敏中间两个字,如"易烊千玺"-->"易**玺"
|
|
||||||
// 企业名称规则:
|
|
||||||
// 从第4位开始隐藏,最多隐藏6位。
|
|
||||||
|
|
||||||
if (StringUtils.isNotEmpty(custName)) {
|
|
||||||
char[] chars = custName.toCharArray();
|
|
||||||
if (chars.length < 5) {// 表示姓名
|
|
||||||
if (chars.length > 1) {
|
|
||||||
StringBuffer sb = new StringBuffer();
|
|
||||||
for (int i = 0; i < chars.length - 2; i++) {
|
|
||||||
sb.append("*");
|
|
||||||
}
|
|
||||||
custName = custName.replaceAll(custName.substring(1, chars.length - 1), sb.toString());
|
|
||||||
}
|
|
||||||
} else {// 企业名称
|
|
||||||
int start = 4;
|
|
||||||
// 第一部分
|
|
||||||
String str1 = custName.substring(0, start);
|
|
||||||
// 第二部分
|
|
||||||
String str2 = "";
|
|
||||||
if (chars.length == 5) {
|
|
||||||
str2 = "*";
|
|
||||||
} else if (chars.length == 6) {
|
|
||||||
str2 = "**";
|
|
||||||
} else if (chars.length == 7) {
|
|
||||||
str2 = "***";
|
|
||||||
} else if (chars.length == 8) {
|
|
||||||
str2 = "****";
|
|
||||||
} else if (chars.length == 9) {
|
|
||||||
str2 = "*****";
|
|
||||||
} else {
|
|
||||||
str2 = "******";
|
|
||||||
}
|
|
||||||
// 通过计算得到第三部分需要从第几个字符截取
|
|
||||||
int subIndex = start + str2.length();
|
|
||||||
// 第三部分
|
|
||||||
String str3 = custName.substring(subIndex);
|
|
||||||
StringBuffer sb = new StringBuffer();
|
|
||||||
sb.append(str1);
|
|
||||||
sb.append(str2);
|
|
||||||
sb.append(str3);
|
|
||||||
custName = sb.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return custName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 家庭地址脱敏
|
|
||||||
*
|
|
||||||
* @param address
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String addressDesensitization(String address) {
|
|
||||||
// 规则说明:从第4位开始隐藏,隐藏8位。
|
|
||||||
if (StringUtils.isNotEmpty(address)) {
|
|
||||||
char[] chars = address.toCharArray();
|
|
||||||
if (chars.length > 11) {// 由于需要从第4位开始,隐藏8位,因此数据长度必须大于11位
|
|
||||||
// 获取第一部分内容
|
|
||||||
String str1 = address.substring(0, 4);
|
|
||||||
// 获取第二部分
|
|
||||||
String str2 = "********";
|
|
||||||
// 获取第三部分
|
|
||||||
String str3 = address.substring(12);
|
|
||||||
StringBuffer sb = new StringBuffer();
|
|
||||||
sb.append(str1);
|
|
||||||
sb.append(str2);
|
|
||||||
sb.append(str3);
|
|
||||||
address = sb.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return address;
|
|
||||||
}
|
|
||||||
|
|
||||||
//下面代码是从别人博客看到的。
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 定义所有常量
|
|
||||||
*/
|
|
||||||
public static final int ONE = 1;
|
|
||||||
public static final int TWO = 2;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 姓名脱敏
|
|
||||||
*
|
|
||||||
* @param realName
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String desensitizedName(String realName) {
|
|
||||||
if (realName == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (realName.length() == ONE) {
|
|
||||||
return realName;
|
|
||||||
} else if (realName.length() == TWO) {
|
|
||||||
return realName.substring(0, 1) +"*";
|
|
||||||
} else {
|
|
||||||
Integer length = realName.length();
|
|
||||||
StringBuffer middle = new StringBuffer();
|
|
||||||
for (int i = 0; i < realName.substring(1, length - 1).length(); i++) {
|
|
||||||
middle.append("*");
|
|
||||||
}
|
|
||||||
return realName.substring(0, 1) + middle + realName.substring(length - 1, length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 详细地址脱敏
|
|
||||||
*
|
|
||||||
* @param address
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String desensitizedAddress(String address){
|
|
||||||
//江西省宜春市丰城市剑南街道人才教育小区41号丰城住总运营有限公司-->江西省宜春市丰城市剑南街道人才教育小区*************
|
|
||||||
if (StringUtils.isNotEmpty(address)) {
|
|
||||||
int length = address.length();
|
|
||||||
int indes = address.indexOf("区");
|
|
||||||
if (indes == -1) {
|
|
||||||
indes = address.indexOf("市");
|
|
||||||
}
|
|
||||||
address = address.substring(0, indes + 1);
|
|
||||||
StringBuffer middle = new StringBuffer();
|
|
||||||
for (int i = 0; i < length - indes; i++) {
|
|
||||||
middle.append("*");
|
|
||||||
}
|
|
||||||
return address + middle;
|
|
||||||
}
|
|
||||||
return address;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 对字符串进行脱敏操作
|
|
||||||
*
|
|
||||||
* @param origin 原始字符串
|
|
||||||
* @param prefixNoMaskLen 左侧需要保留几位明文字段
|
|
||||||
* @param suffixNoMaskLen 右侧需要保留几位明文字段
|
|
||||||
* @param maskStr 用于遮罩的字符串, 如'*'
|
|
||||||
* @return 脱敏后结果
|
|
||||||
*/
|
|
||||||
public static String desValue(String origin, int prefixNoMaskLen, int suffixNoMaskLen, String maskStr) {
|
|
||||||
if (origin == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
for (int i = 0, n = origin.length(); i < n; i++) {
|
|
||||||
if (i < prefixNoMaskLen) {
|
|
||||||
sb.append(origin.charAt(i));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (i > (n - suffixNoMaskLen - 1)) {
|
|
||||||
sb.append(origin.charAt(i));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
sb.append(maskStr);
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 中文姓名,只显示最后一个汉字,其他隐藏为星号,比如:**梦
|
|
||||||
*
|
|
||||||
* @param fullName
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String chineseName(String fullName) {
|
|
||||||
if (fullName == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return desValue(fullName, 0, 1, "*");
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,231 +0,0 @@
|
||||||
package com.muyu.rule.common.utils;
|
|
||||||
|
|
||||||
import com.aliyun.oss.*;
|
|
||||||
import com.aliyun.oss.model.GetObjectRequest;
|
|
||||||
import com.aliyun.oss.model.OSSObject;
|
|
||||||
import com.aliyun.oss.model.PutObjectRequest;
|
|
||||||
import com.aliyun.oss.model.VoidResult;
|
|
||||||
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-beijing.aliyuncs.com";
|
|
||||||
private static String accessKeyId = "LTAI5tRRrrYqiSXddVq7RvqW";
|
|
||||||
private static String accessKeySecret = "GhEg1LlHTOx4q0rxs1S3pCaSQayCVL";
|
|
||||||
private static String accessPre = "https://zcz-vfd-1000.oss-cn-beijing.aliyuncs.com/";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* bucket名称
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private static String bucketName = "zcz-vfd-1000";
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 直接读取OSS中的文件内容
|
|
||||||
*
|
|
||||||
* @param bucketName 存储空间名称
|
|
||||||
* @param ossFilePath OSS中的对象名称
|
|
||||||
* @return 文件内容
|
|
||||||
*/
|
|
||||||
public static String readFileContentFromOSS(String bucketName, String ossFilePath) {
|
|
||||||
// 创建OSSClient实例。
|
|
||||||
OSS ossClient = new OSSClientBuilder().build(endPoint,accessKeyId,accessKeySecret);
|
|
||||||
|
|
||||||
try {
|
|
||||||
GetObjectRequest getObjectRequest = new GetObjectRequest(bucketName, ossFilePath);
|
|
||||||
OSSObject ossObject = ossClient.getObject(getObjectRequest);
|
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(ossObject.getObjectContent()));
|
|
||||||
StringBuilder content = new StringBuilder();
|
|
||||||
String line=null;
|
|
||||||
while ((line = reader.readLine()) != null) {
|
|
||||||
content.append(line).append("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
return content.toString();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return "读取失败:" + e.getMessage();
|
|
||||||
} finally {
|
|
||||||
// 关闭OSSClient。
|
|
||||||
ossClient.shutdown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将指定路径文件上传Oss
|
|
||||||
* @param fileName
|
|
||||||
*/
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void deliteOssClient(String key){
|
|
||||||
|
|
||||||
OSS ossClient = new OSSClientBuilder().build(endPoint, accessKeyId, accessKeySecret);
|
|
||||||
|
|
||||||
|
|
||||||
VoidResult voidResult = ossClient.deleteBucket(key);
|
|
||||||
|
|
||||||
|
|
||||||
log.info(voidResult);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue