fase()规则引擎初始化
parent
34bf35a398
commit
881752d134
|
@ -29,6 +29,12 @@
|
|||
<artifactId>muyu-common-system</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-goods-edition-remote</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-data-test-common</artifactId>
|
||||
|
|
|
@ -3,16 +3,13 @@ package muyu.data.test.clinet.config;
|
|||
import lombok.extern.log4j.Log4j2;
|
||||
import muyu.data.test.clinet.config.runner.AccessConfigRunner;
|
||||
import muyu.data.test.common.dataSoutce.DataSourceConfig;
|
||||
import muyu.data.test.common.domain.DataModel;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import muyu.data.test.common.domain.model.DataModel;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import java.awt.*;
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 规则引擎客户端配置类
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package muyu.data.test.clinet.config;
|
||||
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import muyu.data.test.clinet.config.runner.DataEditionConfigRunner;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
@Log4j2
|
||||
@ComponentScan
|
||||
@Import(value = DataEditionConfigRunner.class)
|
||||
public class DataEditionConfig {
|
||||
}
|
|
@ -29,7 +29,7 @@ public class AccessConfigRunner implements ApplicationRunner {
|
|||
public void run(ApplicationArguments args) throws Exception {
|
||||
//远程调用
|
||||
Result<List<DataAccess>> lists = remoteSystemManageService.lists();
|
||||
log.info("数据源调用状态:{}",lists);
|
||||
// log.info("数据源调用状态:{}",lists);
|
||||
//判断非空
|
||||
if (lists.getData() == null || lists.getData().isEmpty()){
|
||||
log.error("数据为空");
|
||||
|
@ -37,7 +37,7 @@ public class AccessConfigRunner implements ApplicationRunner {
|
|||
}
|
||||
//获取数据源集合
|
||||
List<DataAccess> listResultData = lists.getData();
|
||||
log.info("远程调用:{}",listResultData);
|
||||
// log.info("远程调用:{}",listResultData);
|
||||
//存入map
|
||||
//创建map
|
||||
HashMap<Long, DataAccess> frimaryVoHashMap = new HashMap<>();
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
package muyu.data.test.clinet.config.runner;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.edition.domain.Edition;
|
||||
import com.muyu.edition.domain.RuleEngine;
|
||||
import com.muyu.goods.edition.remote.EditionDataRemoteService;
|
||||
import com.muyu.goods.edition.remote.RemoteDataManagerService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import muyu.data.test.common.dataSoutce.EditionSoutceConfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Log4j2
|
||||
@Component
|
||||
@Configuration
|
||||
public class DataEditionConfigRunner implements ApplicationRunner {
|
||||
@Autowired
|
||||
private RemoteDataManagerService remoteDataManagerService;
|
||||
@Autowired
|
||||
private EditionDataRemoteService editionDataRemoteService;
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
//获取引擎
|
||||
Result<List<RuleEngine>> listResult = remoteDataManagerService.list();
|
||||
// log.info("获取引擎:{}",listResult);
|
||||
List<RuleEngine> listResultData = listResult.getData();
|
||||
//获取规则
|
||||
Result<List<Edition>> tableDataInfoResult = editionDataRemoteService.lists();
|
||||
// log.info("获取规则:{}",tableDataInfoResult);
|
||||
List<Edition> editionList = tableDataInfoResult.getData();
|
||||
//处理获取的引擎和规则
|
||||
for (RuleEngine listResultDatum : listResultData) {
|
||||
List<Edition> editions = editionList.stream().filter(e -> e.getRuleId().equals(listResultDatum.getRuleId())).collect(Collectors.toList());
|
||||
EditionSoutceConfig.indexByte(editions);
|
||||
for (Edition edition : editionList.stream().filter(e -> e.getRuleId().equals(listResultDatum.getRuleId())).collect(Collectors.toList())) {
|
||||
EditionSoutceConfig.index(listResultDatum.getRuleId(),edition);
|
||||
}
|
||||
}
|
||||
Long ruleId = listResultData.get(0).getRuleId();
|
||||
Long id = editionList.get(0).getId();
|
||||
// HashMap<Long, Edition> editionHashMap = EditionSoutceConfig.get(ruleId);
|
||||
// log.info("查看第一批:{}",editionHashMap);
|
||||
|
||||
HashMap<Long, Map<String, byte[]>> even = EditionSoutceConfig.even();
|
||||
Map<String, byte[]> aByte = EditionSoutceConfig.getByte(id);
|
||||
log.info("总表:{}",even);
|
||||
log.info("第一个:{}",aByte);
|
||||
String versionClass = editionList.get(0).getVersionClass();
|
||||
byte[] bytes = aByte.get(versionClass);
|
||||
String s = new String(bytes);
|
||||
System.out.println(s);
|
||||
|
||||
}
|
||||
}
|
|
@ -1 +1,2 @@
|
|||
muyu.data.test.clinet.config.AccessConfig
|
||||
muyu.data.test.clinet.config.DataEditionConfig
|
||||
|
|
|
@ -17,16 +17,29 @@
|
|||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-system</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-modules-system</artifactId>
|
||||
<version>3.6.3</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-goods-edition-common</artifactId>
|
||||
<version>3.6.3</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
package muyu.data.test.common.context;
|
||||
|
||||
|
||||
import com.muyu.edition.model.process.DataModelProcessModel;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 数据模型上下文
|
||||
* @ClassName DataModelContextHolder
|
||||
* @Author 森静若林
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
public class DataModelContextHolder{
|
||||
|
||||
private static final ThreadLocal<DataModelProcessModel> THREAD_LOCAL=new ThreadLocal<>();
|
||||
|
||||
private RecordContextHolder recordContextHolder;
|
||||
|
||||
public static DataModelContextHolder build(RecordContextHolder recordContextHolder){
|
||||
return DataModelContextHolder.builder()
|
||||
.recordContextHolder(recordContextHolder)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static DataModelProcessModel get() {
|
||||
return THREAD_LOCAL.get();
|
||||
}
|
||||
|
||||
public static void set(DataModelProcessModel dataModelProcessModel) {
|
||||
THREAD_LOCAL.set(dataModelProcessModel);
|
||||
}
|
||||
|
||||
public static void remove() {
|
||||
THREAD_LOCAL.remove();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package muyu.data.test.common.context;
|
||||
|
||||
import com.muyu.edition.model.process.DataSetProcessModel;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 数据集上下文
|
||||
* @ClassName DataSetContextHolder
|
||||
* @Author 森静若林
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
public class DataSetContextHolder{
|
||||
|
||||
private static final ThreadLocal<DataSetProcessModel> THREAD_LOCAL=new ThreadLocal<>();
|
||||
|
||||
private TaskContextHolder taskContextHolder;
|
||||
|
||||
public static DataSetContextHolder build(TaskContextHolder taskContextHolder){
|
||||
return DataSetContextHolder.builder()
|
||||
.taskContextHolder(taskContextHolder)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static DataSetProcessModel get() {
|
||||
return THREAD_LOCAL.get();
|
||||
}
|
||||
|
||||
public static void set(DataSetProcessModel dataSetProcessModel) {
|
||||
THREAD_LOCAL.set(dataSetProcessModel);
|
||||
}
|
||||
|
||||
public static void remove() {
|
||||
THREAD_LOCAL.remove();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package muyu.data.test.common.context;
|
||||
|
||||
import com.muyu.edition.model.process.RecordProcessModel;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 记录上下文
|
||||
* @ClassName RecordContextHolder
|
||||
* @Author 森静若林
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
public class RecordContextHolder{
|
||||
|
||||
private static final ThreadLocal<RecordProcessModel> THREAD_LOCAL=new ThreadLocal<>();
|
||||
|
||||
private DataSetContextHolder dataSetContextHolder;
|
||||
|
||||
public static RecordContextHolder build(DataSetContextHolder dataSetContextHolder){
|
||||
return RecordContextHolder.builder()
|
||||
.dataSetContextHolder(dataSetContextHolder)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static RecordProcessModel get() {
|
||||
return THREAD_LOCAL.get();
|
||||
}
|
||||
|
||||
public static void set(RecordProcessModel recordProcessModel) {
|
||||
THREAD_LOCAL.set(recordProcessModel);
|
||||
}
|
||||
|
||||
public static void remove() {
|
||||
THREAD_LOCAL.remove();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package muyu.data.test.common.context;
|
||||
|
||||
/**
|
||||
* 任务上下文
|
||||
* @ClassName TaskContextHolder
|
||||
* @Author 森静若林
|
||||
*/
|
||||
public class TaskContextHolder {
|
||||
|
||||
public static TaskContextHolder build(){
|
||||
return new TaskContextHolder();
|
||||
}
|
||||
}
|
|
@ -35,7 +35,6 @@ public class DataSourceConfig {
|
|||
String databaseName = dataAccess.getDatabaseName();
|
||||
// url
|
||||
String url = String.format("jdbc:mysql://"+ host+":"+port+"/"+databaseName);
|
||||
log.info("集成化的url:{}",url);
|
||||
DruidDataSource dataSource = new DruidDataSource();
|
||||
//初始化链接池数量
|
||||
dataSource.setInitialSize(dataAccess.getInitNum().intValue());
|
||||
|
@ -53,9 +52,7 @@ public class DataSourceConfig {
|
|||
dataSource.setPassword(dataAccess.getPassword());
|
||||
dataSource.init();// 初始化
|
||||
hashMap.put(dataAccess.getId(),dataSource);
|
||||
log.info("储存线程池:{}",hashMap);
|
||||
// HashMap<Long, DruidDataSource> dataSourceHashMap = SpringHashMap(hashMap);
|
||||
// log.info("hashmap存储",dataSourceHashMap);
|
||||
// log.info("储存线程池:{}",hashMap);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -87,7 +84,7 @@ public class DataSourceConfig {
|
|||
public static DruidDataSource verify(Long key) throws SQLException {
|
||||
DruidDataSource dataSource = hashMap.get(key);
|
||||
// 获取连接
|
||||
log.info("查看连接上的线程池:{}",dataSource);
|
||||
// log.info("查看连接上的线程池:{}",dataSource);
|
||||
return dataSource;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
package muyu.data.test.common.dataSoutce;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.muyu.edition.constant.RuleOperationConstants;
|
||||
import com.muyu.edition.domain.Edition;
|
||||
import com.muyu.edition.domain.RuleEngine;
|
||||
import lombok.Data;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import muyu.data.test.common.dymamicLoad.DynamicLoader;
|
||||
import org.bouncycastle.pqc.crypto.newhope.NHSecretKeyProcessor;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
@Component
|
||||
@Configuration
|
||||
@Log4j2
|
||||
public class EditionSoutceConfig {
|
||||
private static HashMap<Long, HashMap<Long, Edition>> hashMap = new HashMap<>();
|
||||
private static HashMap<Long, Map<String, byte[]>> longHashMapHashMap = new HashMap<>();
|
||||
|
||||
public static void index(Long ruleId, Edition edition){
|
||||
HashMap<Long, Edition> editionHashMap = new HashMap<>();
|
||||
editionHashMap.put(edition.getId(),edition);
|
||||
hashMap.put(ruleId,editionHashMap);
|
||||
}
|
||||
|
||||
public static void indexByte(List<Edition> list){
|
||||
list.stream().forEach(engine -> {
|
||||
//获取版本内容
|
||||
String content = engine.getRuleContent().replaceAll("\r\n", "");
|
||||
//编译生成class文件存放到Map中
|
||||
Map<String, byte[]> compile = DynamicLoader.compile( engine.getVersionClass() + RuleOperationConstants.FILE_SUFFIX, content);
|
||||
longHashMapHashMap.put(engine.getId(),compile);
|
||||
});
|
||||
}
|
||||
|
||||
public static HashMap<Long,Edition> get(Long ruleId){
|
||||
return hashMap.get(ruleId);
|
||||
}
|
||||
|
||||
public static Map<String,byte[]> getByte(Long id){
|
||||
return longHashMapHashMap.get(id);
|
||||
}
|
||||
|
||||
public static HashMap<Long , Map<String, byte[]>> even(){
|
||||
return longHashMapHashMap;
|
||||
}
|
||||
}
|
|
@ -1,10 +1,17 @@
|
|||
package muyu.data.test.common.domain;
|
||||
package muyu.data.test.common.domain.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 数据模型,字段值
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DataModel {
|
||||
/**
|
||||
* 键 字段名
|
|
@ -0,0 +1,17 @@
|
|||
package muyu.data.test.common.domain.model;
|
||||
|
||||
import com.alibaba.nacos.api.annotation.NacosProperties;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DataSetModel {
|
||||
private List<RecordModel> list;
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package muyu.data.test.common.domain.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class RecordModel {
|
||||
private List<DataModel> modelList;
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
package muyu.data.test.common.dymamicLoad;
|
||||
|
||||
import javax.tools.JavaCompiler;
|
||||
import javax.tools.JavaFileObject;
|
||||
import javax.tools.StandardJavaFileManager;
|
||||
import javax.tools.ToolProvider;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @ClassName DynamicLoader
|
||||
* @Author 森静若林
|
||||
* @Date 2024/5/1 20:37
|
||||
*/
|
||||
public class DynamicLoader {
|
||||
/**
|
||||
* 通过类名和其代码(Java代码字符串),编译得到字节码,返回类名及其对应类的字节码,封装于Map中,值得注意的是,
|
||||
* 平常类中就编译出来的字节码只有一个类,但是考虑到内部类的情况, 会出现很多个类名及其字节码,所以用Map封装方便。
|
||||
*
|
||||
* @param javaName 类名
|
||||
* @return map
|
||||
*/
|
||||
public static Map<String, byte[]> compile(String javaName, String javaSrc) {
|
||||
// 调用java编译器接口
|
||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||
StandardJavaFileManager stdManager = compiler
|
||||
.getStandardFileManager(null, null, null);
|
||||
|
||||
try (MemoryJavaFileManager manager = new MemoryJavaFileManager(
|
||||
stdManager)) {
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
JavaFileObject javaFileObject = manager.makeStringSource(javaName,
|
||||
javaSrc);
|
||||
JavaCompiler.CompilationTask task = compiler.getTask(null, manager,
|
||||
null, null, null, Arrays.asList(javaFileObject));
|
||||
if (task.call()) {
|
||||
return manager.getClassBytes();
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 先根据类名在内存中查找是否已存在该类,若不存在则调用 URLClassLoader的 defineClass方法加载该类
|
||||
* URLClassLoader的具体作用就是将class文件加载到jvm虚拟机中去
|
||||
*
|
||||
* @author Administrator
|
||||
*/
|
||||
public static class MemoryClassLoader extends URLClassLoader {
|
||||
Map<String, byte[]> classBytes = new HashMap<String, byte[]>();
|
||||
|
||||
public MemoryClassLoader(Map<String, byte[]> classBytes) {
|
||||
super(new URL[0], MemoryClassLoader.class.getClassLoader());
|
||||
this.classBytes.putAll(classBytes);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?> findClass(String name)
|
||||
throws ClassNotFoundException {
|
||||
byte[] buf = classBytes.get(name);
|
||||
if (buf == null) {
|
||||
return super.findClass(name);
|
||||
}
|
||||
classBytes.remove(name);
|
||||
return defineClass(name, buf, 0, buf.length);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,135 @@
|
|||
package muyu.data.test.common.dymamicLoad;
|
||||
|
||||
import javax.tools.*;
|
||||
import java.io.*;
|
||||
import java.net.URI;
|
||||
import java.nio.CharBuffer;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 将编译好的.class文件保存到内存当中,这里的内存也就是map映射当中
|
||||
*
|
||||
* @ClassName MemoryJavaFileManager
|
||||
* @Author 森静若林
|
||||
* @Date 2024/5/1 20:38
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public final class MemoryJavaFileManager extends ForwardingJavaFileManager {
|
||||
|
||||
private final static String EXT = ".java";// Java源文件的扩展名
|
||||
private Map<String, byte[]> classBytes;// 用于存放.class文件的内存
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public MemoryJavaFileManager(JavaFileManager fileManager) {
|
||||
super(fileManager);
|
||||
classBytes = new HashMap<String, byte[]>();
|
||||
}
|
||||
|
||||
static JavaFileObject makeStringSource(String name, String code) {
|
||||
return new StringInputBuffer(name, code);
|
||||
}
|
||||
|
||||
static URI toURI(String name) {
|
||||
File file = new File(name);
|
||||
if (file.exists()) {// 如果文件存在,返回他的URI
|
||||
return file.toURI();
|
||||
} else {
|
||||
try {
|
||||
final StringBuilder newUri = new StringBuilder();
|
||||
newUri.append("mfm:///");
|
||||
newUri.append(name.replace('.', '/'));
|
||||
if (name.endsWith(EXT)) {
|
||||
newUri.replace(newUri.length() - EXT.length(),
|
||||
newUri.length(), EXT);
|
||||
}
|
||||
return URI.create(newUri.toString());
|
||||
} catch (Exception exp) {
|
||||
return URI.create("mfm:///com/sun/script/java/java_source");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, byte[]> getClassBytes() {
|
||||
return classBytes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
classBytes = new HashMap<String, byte[]>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaFileObject getJavaFileForOutput(
|
||||
Location location, String className,
|
||||
JavaFileObject.Kind kind, FileObject sibling) throws IOException {
|
||||
if (kind == JavaFileObject.Kind.CLASS) {
|
||||
return new ClassOutputBuffer(className);
|
||||
} else {
|
||||
return super.getJavaFileForOutput(location, className, kind,
|
||||
sibling);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 一个文件对象,用来表示从string中获取到的source,一下类容是按照jkd给出的例子写的
|
||||
*/
|
||||
private static class StringInputBuffer extends SimpleJavaFileObject {
|
||||
// The source code of this "file".
|
||||
final String code;
|
||||
|
||||
/**
|
||||
* Constructs a new JavaSourceFromString.
|
||||
*
|
||||
* @param name 此文件对象表示的编译单元的name
|
||||
* @param code 此文件对象表示的编译单元source的code
|
||||
*/
|
||||
StringInputBuffer(String name, String code) {
|
||||
super(toURI(name), Kind.SOURCE);
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharBuffer getCharContent(boolean ignoreEncodingErrors) {
|
||||
return CharBuffer.wrap(code);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Reader openReader() {
|
||||
return new StringReader(code);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将Java字节码存储到classBytes映射中的文件对象
|
||||
*/
|
||||
private class ClassOutputBuffer extends SimpleJavaFileObject {
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* @param name className
|
||||
*/
|
||||
ClassOutputBuffer(String name) {
|
||||
super(toURI(name), Kind.CLASS);
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream openOutputStream() {
|
||||
return new FilterOutputStream(new ByteArrayOutputStream()) {
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
out.close();
|
||||
ByteArrayOutputStream bos = (ByteArrayOutputStream) out;
|
||||
|
||||
// 这里需要修改
|
||||
classBytes.put(name, bos.toByteArray());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package muyu.data.test.common.engine;
|
||||
|
||||
/**
|
||||
* 引擎
|
||||
* @ClassName Engine
|
||||
* @Author: 森静若林
|
||||
* @Date: 2024/5/6 13:48
|
||||
*/
|
||||
public interface Engine<V> {
|
||||
|
||||
public void execution();
|
||||
|
||||
public V get();
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package muyu.data.test.common.engine.action;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
|
||||
/**
|
||||
* 记录动作
|
||||
* @ClassName ActionRecords
|
||||
* @Author 森静若林
|
||||
* @Date 2024/5/13 22:31
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Log4j2
|
||||
public class ActionRecords extends RuntimeException{
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name="记录";
|
||||
|
||||
/**
|
||||
* 数据模型
|
||||
*/
|
||||
private Object object;
|
||||
|
||||
public ActionRecords(Object object) {
|
||||
this.object = object;
|
||||
}
|
||||
|
||||
public void records(){
|
||||
log.info("记录的数据是:{}",this.object);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package muyu.data.test.common.engine.action;
|
||||
|
||||
import com.muyu.edition.model.DataModel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 移除动作
|
||||
* @ClassName ActionRemove
|
||||
* @Author: 森静若林
|
||||
* @Date: 2024/5/6 13:48
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
public class ActionRemove extends RuntimeException{
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name="移除";
|
||||
/**
|
||||
* 数据模型
|
||||
*/
|
||||
private DataModel dataModel;
|
||||
|
||||
public ActionRemove(DataModel dataModel) {
|
||||
this.dataModel = dataModel;
|
||||
}
|
||||
|
||||
public void remove(){
|
||||
this.dataModel.setValue(null);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package muyu.data.test.common.engine.action;
|
||||
|
||||
import com.muyu.edition.model.DataModel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 替换动作
|
||||
* @ClassName ActionReplace
|
||||
* @Author: 森静若林
|
||||
* @Date: 2024/5/6 13:48
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class ActionReplace extends RuntimeException{
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name="替换";
|
||||
/**
|
||||
* 新值
|
||||
*/
|
||||
private String newValue;
|
||||
/**
|
||||
* 数据模型
|
||||
*/
|
||||
private DataModel dataModel;
|
||||
|
||||
public ActionReplace(String newValue,DataModel dataModel) {
|
||||
super();
|
||||
this.newValue = newValue;
|
||||
this.dataModel = dataModel;
|
||||
}
|
||||
|
||||
public ActionReplace() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void replace(){
|
||||
this.dataModel.setValue(this.newValue);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package muyu.data.test.common.engine.scope;
|
||||
|
||||
|
||||
import com.muyu.edition.context.DataModelContextHolder;
|
||||
import com.muyu.edition.model.DataModel;
|
||||
import com.muyu.edition.model.process.DataModelProcessModel;
|
||||
import muyu.data.test.common.engine.Engine;
|
||||
|
||||
/**
|
||||
* 数据模型引擎
|
||||
* @ClassName DataModelEngine
|
||||
* @Author: 森静若林
|
||||
* @Date: 2024/5/6 13:48
|
||||
*/
|
||||
public abstract class DataModelEngine implements Engine<DataModelProcessModel> {
|
||||
|
||||
@Override
|
||||
public DataModelProcessModel get (){
|
||||
return DataModelContextHolder.get();
|
||||
}
|
||||
|
||||
public DataModel getModel(){
|
||||
return get().getDataModel();
|
||||
}
|
||||
|
||||
|
||||
public String getKey () {
|
||||
return getModel().getKey();
|
||||
}
|
||||
|
||||
public Object getValue () {
|
||||
return getModel().getValue();
|
||||
}
|
||||
|
||||
public String getSourceType () {
|
||||
return getModel().getSourceType();
|
||||
}
|
||||
|
||||
public String getProcessType () {
|
||||
return getModel().getProcessType();
|
||||
}
|
||||
|
||||
public Class<?> getProcessClass () {
|
||||
return getModel().getProcessClass();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package muyu.data.test.common.engine.scope;
|
||||
|
||||
|
||||
import com.muyu.edition.context.DataSetContextHolder;
|
||||
import com.muyu.edition.model.DataSetModel;
|
||||
import com.muyu.edition.model.RecordModel;
|
||||
import com.muyu.edition.model.process.DataSetProcessModel;
|
||||
import muyu.data.test.common.engine.Engine;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据集引擎
|
||||
* @ClassName DataSetEngine
|
||||
* @Author: 森静若林
|
||||
* @Date: 2024/5/6 13:48
|
||||
*/
|
||||
public abstract class DataSetEngine implements Engine<DataSetProcessModel> {
|
||||
|
||||
@Override
|
||||
public DataSetProcessModel get (){
|
||||
return DataSetContextHolder.get();
|
||||
}
|
||||
|
||||
public DataSetModel getModel(){
|
||||
return get().getDataSetModel();
|
||||
}
|
||||
|
||||
public List<RecordModel> getRecordModels () {
|
||||
return getModel().getRecordModels();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package muyu.data.test.common.engine.scope;
|
||||
|
||||
|
||||
import com.muyu.edition.context.RecordContextHolder;
|
||||
import com.muyu.edition.model.DataModel;
|
||||
import com.muyu.edition.model.RecordModel;
|
||||
import com.muyu.edition.model.process.RecordProcessModel;
|
||||
import muyu.data.test.common.engine.Engine;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 记录引擎
|
||||
* @ClassName RecordEngine
|
||||
* @Author: 森静若林
|
||||
* @Date: 2024/5/6 13:48
|
||||
*/
|
||||
public abstract class RecordEngine implements Engine<RecordProcessModel> {
|
||||
|
||||
@Override
|
||||
public RecordProcessModel get (){
|
||||
return RecordContextHolder.get();
|
||||
}
|
||||
|
||||
public List<String> getKeys(){
|
||||
return get().getKeys();
|
||||
}
|
||||
|
||||
public RecordModel getModel(){
|
||||
return get().getRecordModel();
|
||||
}
|
||||
|
||||
public List<DataModel> getDataModels () {
|
||||
return getModel().getDataModels();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package muyu.data.test.common.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 数据模型
|
||||
* @ClassName DataModel
|
||||
* @Author 森静若林
|
||||
* @Date 2024/5/5 18:48
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DataModel {
|
||||
/**
|
||||
* 键
|
||||
*/
|
||||
private String key;
|
||||
|
||||
/**
|
||||
* 值
|
||||
*/
|
||||
private Object value;
|
||||
|
||||
/**
|
||||
* 原标准
|
||||
*/
|
||||
private String sourceType;
|
||||
|
||||
/**
|
||||
* 处理标准
|
||||
*/
|
||||
private String processType;
|
||||
|
||||
/**
|
||||
* 处理类型
|
||||
*/
|
||||
private Class<?> processClass;
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package muyu.data.test.common.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据集模型
|
||||
* @ClassName DataSetModel
|
||||
* @Author 森静若林
|
||||
* @Date 2024/5/5 18:48
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DataSetModel {
|
||||
|
||||
private List<RecordModel> recordModels;
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package muyu.data.test.common.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 记录模型
|
||||
* @ClassName RecordModel
|
||||
* @Author 森静若林
|
||||
* @Date 2024/5/5 18:48
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class RecordModel {
|
||||
|
||||
private List<DataModel> dataModels;
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package muyu.data.test.common.model.process;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import muyu.data.test.common.model.DataModel;
|
||||
|
||||
/**
|
||||
* 数据模型处理模型
|
||||
* @ClassName DataModelProcessModel
|
||||
* @Author 森静若林
|
||||
* @Date 2024/5/5 18:37
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DataModelProcessModel {
|
||||
private DataModel dataModel;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package muyu.data.test.common.model.process;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import muyu.data.test.common.model.DataSetModel;
|
||||
|
||||
/**
|
||||
* 数据集处理模型
|
||||
* @ClassName DataSetProcessModel
|
||||
* @Author 森静若林
|
||||
* @Date 2024/5/5 18:37
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DataSetProcessModel {
|
||||
private DataSetModel dataSetModel;
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package muyu.data.test.common.model.process;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import muyu.data.test.common.model.RecordModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 记录处理模型
|
||||
* @ClassName RecordProcessModel
|
||||
* @Author 森静若林
|
||||
* @Date 2024/5/5 18:37
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class RecordProcessModel {
|
||||
private List<String> keys;
|
||||
private RecordModel recordModel;
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package muyu.data.test.common.scope;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 数据模型上下文
|
||||
*
|
||||
* @ClassName DataModelContextHolder
|
||||
* @Author 森静若林
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Data
|
||||
public class DataModelContextHolder {
|
||||
|
||||
private final RecordContextHolder recordContextHolder;
|
||||
|
||||
public static DataModelContextHolder build(RecordContextHolder recordContextHolder) {
|
||||
return new DataModelContextHolder(recordContextHolder);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package muyu.data.test.common.scope;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 数据集上下文
|
||||
*
|
||||
* @ClassName DataSetContextHolder
|
||||
* @Author 森静若林
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Data
|
||||
public class DataSetContextHolder {
|
||||
|
||||
private final TaskContextHolder taskContextHolder;
|
||||
|
||||
public static DataSetContextHolder build(TaskContextHolder taskContextHolder) {
|
||||
return new DataSetContextHolder(taskContextHolder);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package muyu.data.test.common.scope;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 记录上下文
|
||||
*
|
||||
* @ClassName RecordContextHolder
|
||||
* @Author 森静若林
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Data
|
||||
public class RecordContextHolder {
|
||||
|
||||
private final DataSetContextHolder dataSetContextHolder;
|
||||
|
||||
public static RecordContextHolder build(DataSetContextHolder dataSetContextHolder) {
|
||||
return new RecordContextHolder(dataSetContextHolder);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package muyu.data.test.common.scope;
|
||||
|
||||
/**
|
||||
* 任务上下文
|
||||
*
|
||||
* @ClassName TaskContextHolder
|
||||
* @Author 森静若林
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public class TaskContextHolder {
|
||||
|
||||
public static TaskContextHolder build() {
|
||||
return new TaskContextHolder();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
import java.util.List;
|
||||
|
||||
public class TestClass {
|
||||
public static String ruleTest(List<String> list) {
|
||||
return "1";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
import com.muyu.edition.engine.action.ActionRecords;
|
||||
import com.muyu.edition.engine.scope.parentClass;
|
||||
|
||||
/**
|
||||
* @Description: this.form.name-this.form.versionCode
|
||||
*/
|
||||
public class this.form.versionCode extends parentClass {
|
||||
@Override
|
||||
public void execution () {
|
||||
|
||||
}
|
||||
}`;
|
|
@ -1,24 +1,17 @@
|
|||
package com.data.test.common;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.data.test.server.TestService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import muyu.data.test.common.dataSoutce.DataSourceConfig;
|
||||
import muyu.data.test.common.domain.DataModel;
|
||||
import muyu.data.test.common.domain.Table;
|
||||
import org.bouncycastle.pqc.crypto.newhope.NHSecretKeyProcessor;
|
||||
import muyu.data.test.common.domain.model.DataModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
@Log4j2
|
||||
@RestController
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.data.test.server;
|
||||
|
||||
import muyu.data.test.common.domain.DataModel;
|
||||
import muyu.data.test.common.domain.model.DataModel;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.data.test.server.impl;
|
|||
|
||||
import com.data.test.server.TestService;
|
||||
import muyu.data.test.clinet.config.AccessConfig;
|
||||
import muyu.data.test.common.domain.DataModel;
|
||||
import muyu.data.test.common.domain.model.DataModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
|
@ -9,7 +9,7 @@
|
|||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>muyu-goods-edition-clinet</artifactId>
|
||||
<artifactId>muyu-goods-edition-client</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
|
@ -29,13 +29,6 @@
|
|||
<artifactId>muyu-goods-edition-remote</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-modules-system</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -1,11 +1,11 @@
|
|||
package com.muyu.efition.clinet;
|
||||
package com.muyu.goods.clinet;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class MuyuClinetApplication {
|
||||
public class DataClientApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(MuyuClinetApplication.class);
|
||||
SpringApplication.run(DataClientApplication.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.muyu.goods.clinet.config;
|
||||
|
||||
import com.muyu.goods.clinet.config.runner.GoodsEditionConfigRunner;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
@Log4j2
|
||||
@ComponentScan
|
||||
@Import(value = GoodsEditionConfigRunner.class)
|
||||
public class GoodsEditionConfig {
|
||||
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
package com.muyu.efition.clinet.config.runner;
|
||||
package com.muyu.goods.clinet.config.runner;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.edition.domain.RuleEngine;
|
||||
import com.muyu.goods.edition.remote.RemoteDataManagerService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -16,14 +16,12 @@ import java.util.List;
|
|||
@Log4j2
|
||||
@Component
|
||||
@Configuration
|
||||
public class DataGoodsConfigRunner implements ApplicationRunner {
|
||||
public class GoodsEditionConfigRunner implements ApplicationRunner {
|
||||
@Autowired
|
||||
private RemoteDataManagerService remoteDataManagerService;
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
Result<List<RuleEngine>> list = remoteDataManagerService.list();
|
||||
List<RuleEngine> rows = list.getData();
|
||||
// log.info("引擎远程调用成功:{}",rows);
|
||||
log.info("获取远程:{}",list);
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
com.muyu.goods.clinet.config.GoodsEditionConfig
|
|
@ -1,13 +0,0 @@
|
|||
package com.muyu.efition.clinet.config;
|
||||
|
||||
import com.muyu.efition.clinet.config.runner.AccessConfigRunner;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
/**
|
||||
* 规则引擎客户端配置类
|
||||
*/
|
||||
@ComponentScan
|
||||
@Import(value = AccessConfigRunner.class)
|
||||
public class AccessConfig {
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package com.muyu.efition.clinet.config;
|
||||
|
||||
import com.muyu.efition.clinet.config.runner.DataGoodsConfigRunner;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
/**
|
||||
* 规则引擎客户端配置类
|
||||
*/
|
||||
@ComponentScan
|
||||
@Import(value = DataGoodsConfigRunner.class)
|
||||
public class DataGoodsConfig {
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package com.muyu.efition.clinet.config;
|
||||
|
||||
import com.muyu.efition.clinet.config.runner.DataRangeConfigRunner;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
/**
|
||||
* 规则引擎客户端配置类
|
||||
*/
|
||||
@ComponentScan
|
||||
@Import(value = DataRangeConfigRunner.class)
|
||||
public class DataRangeConfig {
|
||||
}
|
|
@ -1,137 +0,0 @@
|
|||
package com.muyu.efition.clinet.config.runner;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.edition.domain.RuleEngine;
|
||||
import com.muyu.edition.domain.vo.RuleEngineVO;
|
||||
import com.muyu.edition.domain.vo.UnitVo;
|
||||
import com.muyu.goods.edition.remote.RemoteDataManagerService;
|
||||
import com.muyu.system.domain.DataAccess;
|
||||
import com.muyu.system.domain.vo.FrimaryVo;
|
||||
import com.muyu.system.remote.RemoteSystemManageService;
|
||||
import com.muyu.system.remote.factory.DataMangSystemFactory;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* 初始化加载
|
||||
*/
|
||||
@Log4j2
|
||||
@Component
|
||||
@Configuration
|
||||
public class AccessConfigRunner implements ApplicationRunner {
|
||||
// @Autowired
|
||||
// private RemoteSystemManageService remoteSystemManageService;
|
||||
// @Autowired
|
||||
// private RemoteSystemManageService remoteSystemManageService;
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
//远程调用
|
||||
System.out.println("远程调用");
|
||||
// Result<List<DataAccess>> list = remoteSystemManageService.lists();
|
||||
// //判断非空
|
||||
// if (list.getData() == null || list.getData().isEmpty()){
|
||||
// log.error("数据为空");
|
||||
// return;
|
||||
// }else{
|
||||
// log.info("远程调用:",list);
|
||||
// }
|
||||
// //获取数据源集合
|
||||
// List<DataAccess> listResultData = list.getData();
|
||||
// log.info("远程调用成功:{}",listResultData);
|
||||
// //存入map
|
||||
// //创建map
|
||||
// HashMap<Long, DataAccess> frimaryVoHashMap = new HashMap<>();
|
||||
// //遍历循环存入map
|
||||
// listResultData.forEach(res -> {
|
||||
// frimaryVoHashMap.put(res.getId(),res);
|
||||
// });
|
||||
// log.info("map:{}",frimaryVoHashMap);
|
||||
// HashMap<String, UnitVo> hashMap = new HashMap<>();
|
||||
// //遍历添加到hashMap
|
||||
// for (DataAccess listResultDatum : listResultData) {
|
||||
// if (listResultDatum.getType() == "MySql"){
|
||||
// //主机地址
|
||||
// String host = listResultDatum.getHost();
|
||||
// //端口号
|
||||
// String port = listResultDatum.getPort();
|
||||
// //数据库名
|
||||
// String databaseName = listResultDatum.getDatabaseName();
|
||||
// // url
|
||||
// String url = String.format("jdbc:mysql://"+ host+":"+port+":"+databaseName);
|
||||
// log.info("集成化的url:{}",url);
|
||||
// //连接对象 url/用户名/密码
|
||||
// Connection connection = DriverManager.getConnection(url,listResultDatum.getUsername(),listResultDatum.getPassword());
|
||||
// log.info("连接对象:{}",connection);
|
||||
// DruidDataSource dataSource = new DruidDataSource();
|
||||
// //初始化链接池数量
|
||||
// dataSource.setInitialSize(listResultDatum.getInitNum().intValue());
|
||||
// //最大线程池
|
||||
// dataSource.setMaxActive(listResultDatum.getMaxNum().intValue());
|
||||
// //最大等待时间
|
||||
// dataSource.setMaxWait(listResultDatum.getMaxWaitTime());
|
||||
// //配置数据库的基本信息
|
||||
// dataSource.setDriverClassName("com.mysql/jdbc.Driver");
|
||||
// //数据库连接池
|
||||
// dataSource.setUrl("jdbc:mysql://"+
|
||||
// listResultDatum.getHost()+":"+listResultDatum.getPort()+":"+listResultDatum.getDatabaseName());
|
||||
// //数据库用户名
|
||||
// dataSource.setUsername(listResultDatum.getUsername());
|
||||
// //数据库密码
|
||||
// dataSource.setPassword(listResultDatum.getPassword());
|
||||
// log.info("获取连接池对象:{}",dataSource);
|
||||
// //封装对象
|
||||
// //SuperBuilder方法
|
||||
// UnitVo build = UnitVo.builder()
|
||||
// .connection(connection)
|
||||
// .dataSource(dataSource)
|
||||
// .build();
|
||||
// //存入map
|
||||
// hashMap.put(host+"_"+port+"_"+databaseName,build);
|
||||
// //查看连接池
|
||||
// DataAccess dataAccess = listResultData.get(0);
|
||||
// UnitVo unitVo = hashMap.get(dataAccess.getHost() + "_" + dataAccess.getPort() + "_" + dataAccess.getDatabaseName());
|
||||
// log.info("存在的连接池有:--{}",unitVo);
|
||||
// //取出连接池
|
||||
//
|
||||
// //返回连接池
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// //将对象传入Spring
|
||||
// SpringHashMap(hashMap);
|
||||
}
|
||||
|
||||
// @Bean
|
||||
// public HashMap<String,UnitVo> SpringHashMap(HashMap<String,UnitVo> hashMap) {
|
||||
// return hashMap;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
package com.muyu.efition.clinet.config.runner;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.edition.dataSoutce.DataSourceConfig;
|
||||
import com.muyu.system.domain.DataAccess;
|
||||
import com.muyu.system.remote.RemoteSystemManageService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 初始化加载
|
||||
*/
|
||||
@Log4j2
|
||||
@Component
|
||||
@Configuration
|
||||
public class DataRangeConfigRunner implements ApplicationRunner {
|
||||
@Autowired
|
||||
private RemoteSystemManageService remoteSystemManageService;// 远程调用
|
||||
@Autowired
|
||||
private DataSourceConfig dataSourceConfig;
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
//远程调用
|
||||
Result<List<DataAccess>> lists = remoteSystemManageService.lists();
|
||||
log.info("数据源调用状态:{}",lists);
|
||||
//判断非空
|
||||
if (lists.getData() == null || lists.getData().isEmpty()){
|
||||
log.error("数据为空");
|
||||
return;
|
||||
}
|
||||
//获取数据源集合
|
||||
List<DataAccess> listResultData = lists.getData();
|
||||
log.info("远程调用:{}",listResultData);
|
||||
//存入map
|
||||
//创建map
|
||||
HashMap<Long, DataAccess> frimaryVoHashMap = new HashMap<>();
|
||||
//遍历循环存入map
|
||||
listResultData.forEach(res -> {
|
||||
frimaryVoHashMap.put(res.getId(),res);
|
||||
});
|
||||
//遍历添加到hashMap
|
||||
for (DataAccess listResultDatum : listResultData) {
|
||||
if (listResultDatum.getType().equals("MySql")){
|
||||
//记录线程池
|
||||
dataSourceConfig.index(listResultDatum);
|
||||
}
|
||||
}
|
||||
//连接上线程池
|
||||
DataAccess dataAccess = listResultData.get(0);
|
||||
dataSourceConfig.verify(dataAccess.getId());
|
||||
//获取一个线程池
|
||||
Connection connection = dataSourceConfig.getConnection(dataAccess.getId());
|
||||
log.info("获取一个线程:{}",connection);
|
||||
dataSourceConfig.verify(dataAccess.getId());
|
||||
//归还线程池
|
||||
dataSourceConfig.returnConnection(connection);
|
||||
dataSourceConfig.verify(dataAccess.getId());
|
||||
//将对象传入Spring
|
||||
//SpringHashMap(hashMap);
|
||||
}
|
||||
|
||||
// @Bean
|
||||
// public HashMap<Long, DruidDataSource> SpringHashMap(HashMap<Long,DruidDataSource> hashMap) {
|
||||
// return hashMap;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
com.muyu.efition.clinet.config.AccessConfig
|
||||
com.muyu.efition.clinet.config.DataGoodsConfig
|
||||
com.muyu.efition.clinet.config.DataRangeConfig
|
|
@ -21,6 +21,7 @@
|
|||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-modules-system</artifactId>
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package com.muyu.edition.context;
|
||||
|
||||
|
||||
import com.muyu.edition.model.process.DataModelProcessModel;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.sql.Connection;
|
||||
|
||||
/**
|
||||
* 数据模型上下文
|
||||
* @ClassName DataModelContextHolder
|
||||
* @Author 森静若林
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
public class DataModelContextHolder{
|
||||
|
||||
private static final ThreadLocal<DataModelProcessModel> THREAD_LOCAL=new ThreadLocal<>();
|
||||
|
||||
private RecordContextHolder recordContextHolder;
|
||||
|
||||
public static DataModelContextHolder build(RecordContextHolder recordContextHolder){
|
||||
return DataModelContextHolder.builder()
|
||||
.recordContextHolder(recordContextHolder)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static DataModelProcessModel get() {
|
||||
return THREAD_LOCAL.get();
|
||||
}
|
||||
|
||||
public static void set(DataModelProcessModel dataModelProcessModel) {
|
||||
THREAD_LOCAL.set(dataModelProcessModel);
|
||||
}
|
||||
|
||||
public static void remove() {
|
||||
THREAD_LOCAL.remove();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.muyu.edition.context;
|
||||
|
||||
import com.muyu.edition.model.process.DataSetProcessModel;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 数据集上下文
|
||||
* @ClassName DataSetContextHolder
|
||||
* @Author 森静若林
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
public class DataSetContextHolder{
|
||||
|
||||
private static final ThreadLocal<DataSetProcessModel> THREAD_LOCAL=new ThreadLocal<>();
|
||||
|
||||
private TaskContextHolder taskContextHolder;
|
||||
|
||||
public static DataSetContextHolder build(TaskContextHolder taskContextHolder){
|
||||
return DataSetContextHolder.builder()
|
||||
.taskContextHolder(taskContextHolder)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static DataSetProcessModel get() {
|
||||
return THREAD_LOCAL.get();
|
||||
}
|
||||
|
||||
public static void set(DataSetProcessModel dataSetProcessModel) {
|
||||
THREAD_LOCAL.set(dataSetProcessModel);
|
||||
}
|
||||
|
||||
public static void remove() {
|
||||
THREAD_LOCAL.remove();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.muyu.edition.context;
|
||||
|
||||
import com.muyu.edition.model.process.RecordProcessModel;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 记录上下文
|
||||
* @ClassName RecordContextHolder
|
||||
* @Author 森静若林
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
public class RecordContextHolder{
|
||||
|
||||
private static final ThreadLocal<RecordProcessModel> THREAD_LOCAL=new ThreadLocal<>();
|
||||
|
||||
private DataSetContextHolder dataSetContextHolder;
|
||||
|
||||
public static RecordContextHolder build(DataSetContextHolder dataSetContextHolder){
|
||||
return RecordContextHolder.builder()
|
||||
.dataSetContextHolder(dataSetContextHolder)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static RecordProcessModel get() {
|
||||
return THREAD_LOCAL.get();
|
||||
}
|
||||
|
||||
public static void set(RecordProcessModel recordProcessModel) {
|
||||
THREAD_LOCAL.set(recordProcessModel);
|
||||
}
|
||||
|
||||
public static void remove() {
|
||||
THREAD_LOCAL.remove();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.muyu.edition.context;
|
||||
|
||||
/**
|
||||
* 任务上下文
|
||||
* @ClassName TaskContextHolder
|
||||
* @Author 森静若林
|
||||
*/
|
||||
public class TaskContextHolder {
|
||||
|
||||
public static TaskContextHolder build(){
|
||||
return new TaskContextHolder();
|
||||
}
|
||||
}
|
|
@ -1,93 +0,0 @@
|
|||
package com.muyu.edition.dataSoutce;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.alibaba.druid.pool.DruidPooledConnection;
|
||||
import com.muyu.system.domain.DataAccess;
|
||||
import lombok.Data;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* 线程池配置
|
||||
*/
|
||||
@Data
|
||||
@Component
|
||||
@Configuration
|
||||
@Log4j2
|
||||
public class DataSourceConfig {
|
||||
|
||||
private static HashMap<Long,DruidDataSource> hashMap = new HashMap<>();
|
||||
/**
|
||||
* 添加线程池
|
||||
* 线程池初始化
|
||||
*/
|
||||
public static void index(DataAccess dataAccess) throws SQLException {
|
||||
//主机地址
|
||||
String host = dataAccess.getHost();
|
||||
//端口号
|
||||
String port = dataAccess.getPort();
|
||||
//数据库名
|
||||
String databaseName = dataAccess.getDatabaseName();
|
||||
// url
|
||||
String url = String.format("jdbc:mysql://"+ host+":"+port+"/"+databaseName);
|
||||
log.info("集成化的url:{}",url);
|
||||
DruidDataSource dataSource = new DruidDataSource();
|
||||
//初始化链接池数量
|
||||
dataSource.setInitialSize(dataAccess.getInitNum().intValue());
|
||||
//最大线程池
|
||||
dataSource.setMaxActive(dataAccess.getMaxNum().intValue());
|
||||
//最大等待时间
|
||||
dataSource.setMaxWait(dataAccess.getMaxWaitTime());
|
||||
//配置数据库的基本信息
|
||||
dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
|
||||
//数据库连接池
|
||||
dataSource.setUrl(url);
|
||||
//数据库用户名
|
||||
dataSource.setUsername(dataAccess.getUsername());
|
||||
//数据库密码
|
||||
dataSource.setPassword(dataAccess.getPassword());
|
||||
dataSource.init();// 初始化
|
||||
hashMap.put(dataAccess.getId(),dataSource);
|
||||
log.info("储存线程池:{}",hashMap);
|
||||
// HashMap<Long, DruidDataSource> dataSourceHashMap = SpringHashMap(hashMap);
|
||||
// log.info("hashmap存储",dataSourceHashMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取出线程池
|
||||
*/
|
||||
public static Connection getConnection(Long key){
|
||||
DruidDataSource dataSource = hashMap.get(key);
|
||||
try {
|
||||
DruidPooledConnection connection = dataSource.getConnection();
|
||||
return connection;
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 归还线程池
|
||||
*/
|
||||
public static void returnConnection(Connection connection){
|
||||
try {
|
||||
connection.close();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 连接线程池
|
||||
* 验证线程池
|
||||
*/
|
||||
public static void verify(Long key) throws SQLException {
|
||||
DruidDataSource dataSource = hashMap.get(key);
|
||||
// 获取连接
|
||||
log.info("查看连接上的线程池:{}",dataSource);
|
||||
}
|
||||
}
|
|
@ -2,6 +2,10 @@ package com.muyu.edition.domain;
|
|||
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
|
@ -11,6 +15,10 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
|||
* @author muyu
|
||||
* @date 2024-05-06
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Edition extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
@ -64,102 +72,6 @@ public class Edition extends BaseEntity {
|
|||
@Excel(name = "内容描述")
|
||||
private String editionContent;
|
||||
|
||||
@Excel(name = "规则内容")
|
||||
@Excel(name = "版本内容")
|
||||
private String ruleContent;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getRuleId() {
|
||||
return ruleId;
|
||||
}
|
||||
|
||||
public void setRuleId(Long ruleId) {
|
||||
this.ruleId = ruleId;
|
||||
}
|
||||
|
||||
public String getVersionClass() {
|
||||
return versionClass;
|
||||
}
|
||||
|
||||
public void setVersionClass(String versionClass) {
|
||||
this.versionClass = versionClass;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getVersionCode() {
|
||||
return versionCode;
|
||||
}
|
||||
|
||||
public void setVersionCode(String versionCode) {
|
||||
this.versionCode = versionCode;
|
||||
}
|
||||
|
||||
public Integer getEditionStatus() {
|
||||
return editionStatus;
|
||||
}
|
||||
|
||||
public void setEditionStatus(Integer editionStatus) {
|
||||
this.editionStatus = editionStatus;
|
||||
}
|
||||
|
||||
public String getRuleStatus() {
|
||||
return ruleStatus;
|
||||
}
|
||||
|
||||
public void setRuleStatus(String ruleStatus) {
|
||||
this.ruleStatus = ruleStatus;
|
||||
}
|
||||
|
||||
public Integer getRuleIsTest() {
|
||||
return ruleIsTest;
|
||||
}
|
||||
|
||||
public void setRuleIsTest(Integer ruleIsTest) {
|
||||
this.ruleIsTest = ruleIsTest;
|
||||
}
|
||||
|
||||
public String getEditionContent() {
|
||||
return editionContent;
|
||||
}
|
||||
|
||||
public void setEditionContent(String editionContent) {
|
||||
this.editionContent = editionContent;
|
||||
}
|
||||
|
||||
public String getRuleContent() {
|
||||
return ruleContent;
|
||||
}
|
||||
|
||||
public void setRuleContent(String ruleContent) {
|
||||
this.ruleContent = ruleContent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("ruleId", getRuleId())
|
||||
.append("versionClass", getVersionClass())
|
||||
.append("name", getName())
|
||||
.append("versionCode", getVersionCode())
|
||||
.append("editionStatus", getEditionStatus())
|
||||
.append("ruleStatus", getRuleStatus())
|
||||
.append("ruleIsTest", getRuleIsTest())
|
||||
.append("ruleContent", getRuleContent())
|
||||
.append("editionContent", getEditionContent())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package com.muyu.edition.engine;
|
||||
|
||||
/**
|
||||
* 引擎
|
||||
* @ClassName Engine
|
||||
* @Author: 森静若林
|
||||
* @Date: 2024/5/6 13:48
|
||||
*/
|
||||
public interface Engine<V> {
|
||||
|
||||
public void execution();
|
||||
|
||||
public V get();
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.muyu.edition.engine.action;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
|
||||
/**
|
||||
* 记录动作
|
||||
* @ClassName ActionRecords
|
||||
* @Author 森静若林
|
||||
* @Date 2024/5/13 22:31
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Log4j2
|
||||
public class ActionRecords extends RuntimeException{
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name="记录";
|
||||
|
||||
/**
|
||||
* 数据模型
|
||||
*/
|
||||
private Object object;
|
||||
|
||||
public ActionRecords(Object object) {
|
||||
this.object = object;
|
||||
}
|
||||
|
||||
public void records(){
|
||||
log.info("记录的数据是:{}",this.object);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.muyu.edition.engine.action;
|
||||
|
||||
import com.muyu.edition.model.DataModel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 移除动作
|
||||
* @ClassName ActionRemove
|
||||
* @Author: 森静若林
|
||||
* @Date: 2024/5/6 13:48
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
public class ActionRemove extends RuntimeException{
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name="移除";
|
||||
/**
|
||||
* 数据模型
|
||||
*/
|
||||
private DataModel dataModel;
|
||||
|
||||
public ActionRemove(DataModel dataModel) {
|
||||
this.dataModel = dataModel;
|
||||
}
|
||||
|
||||
public void remove(){
|
||||
this.dataModel.setValue(null);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package com.muyu.edition.engine.action;
|
||||
|
||||
import com.muyu.edition.model.DataModel;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 替换动作
|
||||
* @ClassName ActionReplace
|
||||
* @Author: 森静若林
|
||||
* @Date: 2024/5/6 13:48
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class ActionReplace extends RuntimeException{
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name="替换";
|
||||
/**
|
||||
* 新值
|
||||
*/
|
||||
private String newValue;
|
||||
/**
|
||||
* 数据模型
|
||||
*/
|
||||
private DataModel dataModel;
|
||||
|
||||
public ActionReplace(String newValue,DataModel dataModel) {
|
||||
super();
|
||||
this.newValue = newValue;
|
||||
this.dataModel = dataModel;
|
||||
}
|
||||
|
||||
public ActionReplace() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void replace(){
|
||||
this.dataModel.setValue(this.newValue);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package com.muyu.edition.engine.scope;
|
||||
|
||||
|
||||
import com.muyu.edition.context.DataModelContextHolder;
|
||||
import com.muyu.edition.engine.Engine;
|
||||
import com.muyu.edition.model.DataModel;
|
||||
import com.muyu.edition.model.process.DataModelProcessModel;
|
||||
|
||||
/**
|
||||
* 数据模型引擎
|
||||
* @ClassName DataModelEngine
|
||||
* @Author: 森静若林
|
||||
* @Date: 2024/5/6 13:48
|
||||
*/
|
||||
public abstract class DataModelEngine implements Engine<DataModelProcessModel> {
|
||||
|
||||
@Override
|
||||
public DataModelProcessModel get (){
|
||||
return DataModelContextHolder.get();
|
||||
}
|
||||
|
||||
public DataModel getModel(){
|
||||
return get().getDataModel();
|
||||
}
|
||||
|
||||
|
||||
public String getKey () {
|
||||
return getModel().getKey();
|
||||
}
|
||||
|
||||
public Object getValue () {
|
||||
return getModel().getValue();
|
||||
}
|
||||
|
||||
public String getSourceType () {
|
||||
return getModel().getSourceType();
|
||||
}
|
||||
|
||||
public String getProcessType () {
|
||||
return getModel().getProcessType();
|
||||
}
|
||||
|
||||
public Class<?> getProcessClass () {
|
||||
return getModel().getProcessClass();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.muyu.edition.engine.scope;
|
||||
|
||||
|
||||
import com.muyu.edition.context.DataSetContextHolder;
|
||||
import com.muyu.edition.engine.Engine;
|
||||
import com.muyu.edition.model.DataSetModel;
|
||||
import com.muyu.edition.model.RecordModel;
|
||||
import com.muyu.edition.model.process.DataSetProcessModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据集引擎
|
||||
* @ClassName DataSetEngine
|
||||
* @Author: 森静若林
|
||||
* @Date: 2024/5/6 13:48
|
||||
*/
|
||||
public abstract class DataSetEngine implements Engine<DataSetProcessModel> {
|
||||
|
||||
@Override
|
||||
public DataSetProcessModel get (){
|
||||
return DataSetContextHolder.get();
|
||||
}
|
||||
|
||||
public DataSetModel getModel(){
|
||||
return get().getDataSetModel();
|
||||
}
|
||||
|
||||
public List<RecordModel> getRecordModels () {
|
||||
return getModel().getRecordModels();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.muyu.edition.engine.scope;
|
||||
|
||||
|
||||
import com.muyu.edition.context.RecordContextHolder;
|
||||
import com.muyu.edition.engine.Engine;
|
||||
import com.muyu.edition.model.DataModel;
|
||||
import com.muyu.edition.model.RecordModel;
|
||||
import com.muyu.edition.model.process.RecordProcessModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 记录引擎
|
||||
* @ClassName RecordEngine
|
||||
* @Author: 森静若林
|
||||
* @Date: 2024/5/6 13:48
|
||||
*/
|
||||
public abstract class RecordEngine implements Engine<RecordProcessModel> {
|
||||
|
||||
@Override
|
||||
public RecordProcessModel get (){
|
||||
return RecordContextHolder.get();
|
||||
}
|
||||
|
||||
public List<String> getKeys(){
|
||||
return get().getKeys();
|
||||
}
|
||||
|
||||
public RecordModel getModel(){
|
||||
return get().getRecordModel();
|
||||
}
|
||||
|
||||
public List<DataModel> getDataModels () {
|
||||
return getModel().getDataModels();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.muyu.edition.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 数据模型
|
||||
* @ClassName DataModel
|
||||
* @Author 森静若林
|
||||
* @Date 2024/5/5 18:48
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DataModel {
|
||||
/**
|
||||
* 键
|
||||
*/
|
||||
private String key;
|
||||
|
||||
/**
|
||||
* 值
|
||||
*/
|
||||
private Object value;
|
||||
|
||||
/**
|
||||
* 原标准
|
||||
*/
|
||||
private String sourceType;
|
||||
|
||||
/**
|
||||
* 处理标准
|
||||
*/
|
||||
private String processType;
|
||||
|
||||
/**
|
||||
* 处理类型
|
||||
*/
|
||||
private Class<?> processClass;
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.muyu.edition.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据集模型
|
||||
* @ClassName DataSetModel
|
||||
* @Author 森静若林
|
||||
* @Date 2024/5/5 18:48
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DataSetModel {
|
||||
|
||||
private List<RecordModel> recordModels;
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.muyu.edition.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 记录模型
|
||||
* @ClassName RecordModel
|
||||
* @Author 森静若林
|
||||
* @Date 2024/5/5 18:48
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class RecordModel {
|
||||
|
||||
private List<DataModel> dataModels;
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.muyu.edition.model.process;
|
||||
|
||||
import com.muyu.edition.model.DataModel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 数据模型处理模型
|
||||
* @ClassName DataModelProcessModel
|
||||
* @Author 森静若林
|
||||
* @Date 2024/5/5 18:37
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DataModelProcessModel {
|
||||
private DataModel dataModel;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.muyu.edition.model.process;
|
||||
|
||||
import com.muyu.edition.model.DataSetModel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 数据集处理模型
|
||||
* @ClassName DataSetProcessModel
|
||||
* @Author 森静若林
|
||||
* @Date 2024/5/5 18:37
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DataSetProcessModel {
|
||||
private DataSetModel dataSetModel;
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.muyu.edition.model.process;
|
||||
|
||||
import com.muyu.edition.model.RecordModel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 记录处理模型
|
||||
* @ClassName RecordProcessModel
|
||||
* @Author 森静若林
|
||||
* @Date 2024/5/5 18:37
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class RecordProcessModel {
|
||||
private List<String> keys;
|
||||
private RecordModel recordModel;
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.muyu.goods.edition.remote;
|
||||
|
||||
import com.muyu.common.core.constant.ServiceNameConstants;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.edition.domain.Edition;
|
||||
import com.muyu.goods.edition.remote.factory.DataMangFacrory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 远程调用
|
||||
*/
|
||||
@FeignClient(
|
||||
contextId = "editionSel",
|
||||
value = ServiceNameConstants.EDITION_MUYU,
|
||||
fallbackFactory = DataMangFacrory.class,
|
||||
path = "/edition"
|
||||
)
|
||||
public interface EditionDataRemoteService {
|
||||
@PostMapping("lists")
|
||||
public Result<List<Edition>> lists();
|
||||
}
|
|
@ -18,6 +18,7 @@ import java.util.List;
|
|||
fallbackFactory = DataMangFacrory.class,
|
||||
path = "/engine"
|
||||
)
|
||||
|
||||
public interface RemoteDataManagerService {
|
||||
@PostMapping("/lists")
|
||||
public Result<List<RuleEngine>> list();
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package com.muyu.goods.edition.remote.factory;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.edition.domain.Edition;
|
||||
import com.muyu.goods.edition.remote.EditionDataRemoteService;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 熔断
|
||||
*/
|
||||
public class EditioMangFarory implements FallbackFactory<EditionDataRemoteService> {
|
||||
@Override
|
||||
public EditionDataRemoteService create(Throwable cause) {
|
||||
return new EditionDataRemoteService() {
|
||||
@Override
|
||||
public Result<List<Edition>> lists() {
|
||||
return Result.error(cause.getMessage());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -95,12 +95,7 @@
|
|||
<artifactId>mssql-jdbc</artifactId>
|
||||
<version>9.4.0.jre8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-goods-edition-clinet</artifactId>
|
||||
<version>3.6.3</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -38,6 +38,11 @@ public class EditionController extends BaseController {
|
|||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@PostMapping("lists")
|
||||
public Result<List<Edition>> lists() {
|
||||
return success(editionService.lists());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取相应的规则引擎版本
|
||||
*
|
||||
|
|
|
@ -13,8 +13,6 @@ import java.util.Map;
|
|||
|
||||
/**
|
||||
* @ClassName DynamicLoader
|
||||
* @Author 森静若林
|
||||
* @Date 2024/5/1 20:37
|
||||
*/
|
||||
public class DynamicLoader {
|
||||
/**
|
||||
|
|
|
@ -57,4 +57,6 @@ public interface EditionMapper {
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteEditionByIds(Long[] ids);
|
||||
|
||||
List<Edition> lists();
|
||||
}
|
||||
|
|
|
@ -1,25 +1,13 @@
|
|||
let packageName = "com.muyu.rule.goods";
|
||||
let customName = "custom";
|
||||
let templateName = "template";
|
||||
let parentClass = "DataModelEngine";
|
||||
let ruleContent = `package ${packageName}.${customName};
|
||||
|
||||
import com.muyu.engine.action.ActionDiscard;
|
||||
import com.muyu.engine.scope.parentClass;
|
||||
import com.muyu.edition.engine.action.ActionRecords;
|
||||
import com.muyu.edition.engine.scope.parentClass;
|
||||
|
||||
/**
|
||||
* @Author: DongZeLiang
|
||||
* @date: 2024/5/6
|
||||
* @Description: this.form.name-this.form.versionCode
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public class this.form.versionCode extends parentClass {
|
||||
public class val.val extends parentClass {
|
||||
@Override
|
||||
public void execution () {
|
||||
Object value = getValue();
|
||||
|
||||
if (value == null || "".equals(value) || "null".equals(value)) {
|
||||
throw new ActionDiscard();
|
||||
}
|
||||
}
|
||||
}`;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ public interface IEditionService {
|
|||
*/
|
||||
public Edition selectEditionById(Long id);
|
||||
|
||||
List<Edition> lists();
|
||||
/**
|
||||
* 获取相应的规则引擎版本
|
||||
*
|
||||
|
|
|
@ -31,6 +31,11 @@ public class EditionServiceImpl implements IEditionService {
|
|||
return editionMapper.selectEditionById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Edition> lists() {
|
||||
return editionMapper.lists();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取相应的规则引擎版本
|
||||
*
|
||||
|
|
|
@ -138,7 +138,10 @@ public class RuleEngineServiceImpl implements IRuleEngineService {
|
|||
|
||||
@Override
|
||||
public Result spliceNameToCode(String name, String code, Integer level) {
|
||||
List<String> stringList = List.of(new String[]{"questEngine", "dataSetEngine", "recordsEngine", "fieldEngine"});
|
||||
List<String> stringList = List.of(new String[]{"QuestEngine", "DataSetEngine", "RecordEngine", "DataModelEngine"});
|
||||
// DataModelEngine
|
||||
// DataSetEngine
|
||||
// RecordEngine
|
||||
RuleEditionReq ruleEditionReq = new RuleEditionReq();
|
||||
String val = name + "_" + code;
|
||||
String scope = ConfigCodeConstants.CONFIG_FILE_NAME_CODE[0];
|
||||
|
@ -148,10 +151,10 @@ public class RuleEngineServiceImpl implements IRuleEngineService {
|
|||
cod = Files.readString(Paths.get(path));
|
||||
String s1 = Pattern.compile("this.form.name").matcher(cod).replaceAll(name);
|
||||
String s2 = Pattern.compile("this.form.versionCode").matcher(s1).replaceAll(code);
|
||||
String s3 = Pattern.compile("parentClass").matcher(s2).replaceAll(stringList.get(level - 1));
|
||||
String s3 = Pattern.compile("val.val").matcher(s2).replaceAll(code);
|
||||
String s4 = Pattern.compile("parentClass").matcher(s3).replaceAll(stringList.get(level - 1));
|
||||
ruleEditionReq.setVal(val);
|
||||
ruleEditionReq.setCode(s3);
|
||||
System.out.println(cod);
|
||||
ruleEditionReq.setCode(s4);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
|
|
@ -39,6 +39,9 @@
|
|||
<include refid="selectEditionVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
<select id="lists" resultType="com.muyu.edition.domain.Edition">
|
||||
<include refid="selectEditionVo"/>
|
||||
</select>
|
||||
|
||||
<insert id="insertEdition" parameterType="com.muyu.edition.domain.Edition" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into edition
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<module>muyu-goods-edition-common</module>
|
||||
<module>muyu-goods-edition-remote</module>
|
||||
<module>muyu-goods-edition-server</module>
|
||||
<module>muyu-goods-edition-clinet</module>
|
||||
<module>muyu-goods-edition-client</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
|
|
|
@ -17,93 +17,5 @@
|
|||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos Config -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Sentinel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot Actuator -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Swagger UI -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${swagger.fox.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common DataSource -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-datasource</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common DataScope -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-datascope</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common Log -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common Swagger -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-swagger</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- 加入maven deploy插件,当在deploy时,忽略些model-->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class strasd {
|
||||
public static void main(String[] args) {
|
||||
java.lang.String sss = "sabacdeaces";
|
||||
Pattern es = Pattern.compile("es");
|
||||
Matcher matcher = es.matcher(sss);
|
||||
String s = matcher.replaceAll("a1");
|
||||
System.out.println(s);
|
||||
}
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class stream {
|
||||
public static void main(String[] args) throws IOException {
|
||||
// stream 获取list
|
||||
List<Integer> list = Arrays.asList(1, 2, 3);
|
||||
System.out.println(list);
|
||||
Stream<Integer> integerStream = list.stream();
|
||||
List<Integer> collect1 = integerStream.collect(Collectors.toList());
|
||||
System.out.println(collect1);
|
||||
// stream 获取数组
|
||||
Integer[] array = {1, 2, 3};
|
||||
Stream<Integer> arrStream = Arrays.stream(array);
|
||||
List<Integer> collect = arrStream.collect(Collectors.toList());
|
||||
System.out.println(collect);
|
||||
//中间处理
|
||||
List<String> stringList = new ArrayList<>();
|
||||
stringList.add("123456789@163.com");
|
||||
stringList.add("2596325@163.com");
|
||||
stringList.add("157492533@qq.com");
|
||||
stringList.add("1547859633@qq.com");
|
||||
stringList.add("1547859633@qq.com");
|
||||
//filter 筛选操作
|
||||
stringList.stream().filter(c -> c.contains("@163")).forEach(System.out::println);
|
||||
//map 映射 map(表::展示字段)
|
||||
System.out.println("筛选操作");
|
||||
stringList.stream().map(String::new).forEach(System.out::println);
|
||||
//flatMap 将每个元素映射为一个Stream对象,并将所有的Stream对象的元素合并为一个steam对象
|
||||
System.out.println("将所有的Stream对象的元素合并为一个steam对象");
|
||||
stringList.stream().flatMap(c -> Arrays.asList(c).stream()).forEach(System.out::println);
|
||||
// distinct 去除重复元素
|
||||
System.out.println("去除重复元素");
|
||||
stringList.stream().distinct().forEach(System.out::println);
|
||||
// sorted 对元素进行排序
|
||||
System.out.println("排序");
|
||||
stringList.stream().sorted((a, b) -> a.length() - b.length()).forEach(System.out::println);
|
||||
// peek 对每个元素进行特定操作
|
||||
System.out.println("对每个元素进行特定操作");
|
||||
stringList.stream().peek(c -> System.out.println(c.length())).map(p -> p.length() % 2 == 0).forEach(System.out::println);
|
||||
// limit 限制stream中的元素数量
|
||||
System.out.println("限制stream中的元素数量");
|
||||
stringList.stream().limit(1).forEach(System.out::println);
|
||||
//结束
|
||||
// forEach 对每个元素进行指定操作,无返回值
|
||||
//toArray 将流中的元素转为数组
|
||||
System.out.println("将流中的元素转为数组");
|
||||
String[] array1 = stringList.stream().toArray(String[]::new);
|
||||
for (String s : array1) {
|
||||
System.out.println(s);
|
||||
}
|
||||
//reduce 将流中的元素按照指定的操作进行归约,返回一个值
|
||||
// identity是初始值,accumulator是一个二次元操作符,通常用于与流中的元素进行聚合操作
|
||||
System.out.println("归约");
|
||||
Optional<Integer> reduce = list.stream().map(Integer::bitCount).reduce(Integer::compare);
|
||||
System.out.println(reduce.get());
|
||||
// collect 将流中的元素收集到一个集合中
|
||||
System.out.println("将流中的元素收集到一个集合中");
|
||||
Set<Integer> collect2 = list.stream().collect(Collectors.toSet());
|
||||
for (Integer i : collect2) {
|
||||
System.out.println(i);
|
||||
}
|
||||
//min 返回最小值 max返回最大值
|
||||
//count 返回流中的个数
|
||||
//allMatch 判断流中的所有元素是否满足给定的条件
|
||||
//noneMatch 判断流中所有的元素是否不满足给定条件
|
||||
//findFirst 返回流的第一个元素
|
||||
System.out.println("返回流的第一个元素");
|
||||
Optional<String> first = stringList.stream().findFirst();
|
||||
System.out.println(first.stream().collect(Collectors.toSet()));
|
||||
//findAny 返回流的任意一个元素
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class yes {
|
||||
public static void main(String[] args) {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("1424587994@163com");
|
||||
list.add("2949451835@qq.com");
|
||||
list.add("15975632@qq.com");
|
||||
Stream<String> stream = list.stream();
|
||||
stream.filter(c -> !c.contains("@163")).forEach(System.out::println);
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9501
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
application:
|
||||
# 应用名称
|
||||
name: muyu-goods
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 129.211.23.219:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 129.211.23.219:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
logging:
|
||||
level:
|
||||
com.muyu.edition.mapper: DEBUG
|
Loading…
Reference in New Issue