feat():4层作用域响应值

修复bug:数据库查询超时,数据量过大导致内存溢出
master
Saisai Liu 2024-05-13 20:29:05 +08:00
parent 6af3adc8fb
commit de495030a9
32 changed files with 186 additions and 130 deletions

View File

@ -1,4 +1,4 @@
package com.muyu.engine.domain.engine; package com.muyu.etl.domain.scope.engine;
/** /**
* @Author: DongZeLiang * @Author: DongZeLiang

View File

@ -1,4 +1,4 @@
package com.muyu.engine.domain.engine.action; package com.muyu.etl.domain.scope.engine.action;
/** /**
* @Author: DongZeLiang * @Author: DongZeLiang

View File

@ -1,8 +1,8 @@
package com.muyu.engine.domain.engine.custom; package com.muyu.etl.domain.scope.engine.custom;
import com.muyu.engine.domain.engine.action.ActionDiscard; import com.muyu.etl.domain.scope.engine.action.ActionDiscard;
import com.muyu.engine.domain.engine.scope.DataModelEngine; import com.muyu.etl.domain.scope.engine.scope.DataModelEngine;
/** /**
* @Author: DongZeLiang * @Author: DongZeLiang

View File

@ -1,10 +1,11 @@
package com.muyu.engine.domain.engine.scope; package com.muyu.etl.domain.scope.engine.scope;
import com.muyu.engine.domain.engine.Engine; import com.muyu.etl.domain.scope.engine.Engine;
import com.muyu.engine.domain.model.DataModel; import com.muyu.etl.domain.scope.model.DataModel;
import com.muyu.engine.domain.scope.DataModelContext; import com.muyu.etl.domain.scope.scope.DataModelContext;
import com.muyu.engine.domain.scope.model.DataProcessModel; import com.muyu.etl.domain.scope.scope.model.DataProcessModel;
import lombok.Data;
/** /**
* @Author: DongZeLiang * @Author: DongZeLiang
@ -12,6 +13,7 @@ import com.muyu.engine.domain.scope.model.DataProcessModel;
* @Description: * @Description:
* @Version: 1.0 * @Version: 1.0
*/ */
@Data
public abstract class DataModelEngine implements Engine<DataProcessModel> { public abstract class DataModelEngine implements Engine<DataProcessModel> {
private DataModelContext dataModelContext; private DataModelContext dataModelContext;

View File

@ -1,9 +1,11 @@
package com.muyu.engine.domain.engine.scope; package com.muyu.etl.domain.scope.engine.scope;
import com.muyu.engine.domain.engine.Engine;
import com.muyu.engine.domain.model.DataSetModel; import com.muyu.etl.domain.scope.engine.Engine;
import com.muyu.engine.domain.scope.DataSetContext; import com.muyu.etl.domain.scope.model.DataSetModel;
import com.muyu.engine.domain.scope.model.DataSetProcessModel; import com.muyu.etl.domain.scope.scope.DataSetContext;
import com.muyu.etl.domain.scope.scope.model.DataSetProcessModel;
import lombok.Data;
/** /**
* *
@ -12,6 +14,7 @@ import com.muyu.engine.domain.scope.model.DataSetProcessModel;
* @Description: * @Description:
* @Version: 1.0 * @Version: 1.0
*/ */
@Data
public abstract class DataSetEngine implements Engine<DataSetProcessModel> { public abstract class DataSetEngine implements Engine<DataSetProcessModel> {
//上下文对象 //上下文对象
private DataSetContext dataSetContext; private DataSetContext dataSetContext;

View File

@ -1,10 +1,11 @@
package com.muyu.engine.domain.engine.scope; package com.muyu.etl.domain.scope.engine.scope;
import com.muyu.engine.domain.engine.Engine; import com.muyu.etl.domain.scope.engine.Engine;
import com.muyu.engine.domain.model.RecordModel; import com.muyu.etl.domain.scope.model.RecordModel;
import com.muyu.engine.domain.scope.RecordContext; import com.muyu.etl.domain.scope.scope.RecordContext;
import com.muyu.engine.domain.scope.model.RecordProcessModel; import com.muyu.etl.domain.scope.scope.model.RecordProcessModel;
import lombok.Data;
/** /**
* @Author: DongZeLiang * @Author: DongZeLiang
@ -12,6 +13,7 @@ import com.muyu.engine.domain.scope.model.RecordProcessModel;
* @Description: * @Description:
* @Version: 1.0 * @Version: 1.0
*/ */
@Data
public abstract class RecordEngine implements Engine<RecordProcessModel> { public abstract class RecordEngine implements Engine<RecordProcessModel> {
private RecordContext recordContext; private RecordContext recordContext;

View File

@ -1,4 +1,4 @@
package com.muyu.engine.domain.model; package com.muyu.etl.domain.scope.model;
import lombok.Data; import lombok.Data;

View File

@ -1,4 +1,8 @@
package com.muyu.engine.domain.model; package com.muyu.etl.domain.scope.model;
import lombok.Data;
import java.io.Serializable;
/** /**
* *
@ -7,7 +11,8 @@ package com.muyu.engine.domain.model;
* @Description: * @Description:
* @Version: 1.0 * @Version: 1.0
*/ */
public class DataSetModel { @Data
public class DataSetModel implements Serializable {
// [[DataModel,DataModel,DataModel],[DataModel,DataModel,DataModel]] // [[DataModel,DataModel,DataModel],[DataModel,DataModel,DataModel]]

View File

@ -1,4 +1,4 @@
package com.muyu.engine.domain.model; package com.muyu.etl.domain.scope.model;
/** /**
* *

View File

@ -1,4 +1,4 @@
package com.muyu.engine.domain.model; package com.muyu.etl.domain.scope.model;
/** /**
* *

View File

@ -1,7 +1,7 @@
package com.muyu.engine.domain.scope; package com.muyu.etl.domain.scope.scope;
import com.muyu.engine.domain.scope.model.DataProcessModel; import com.muyu.etl.domain.scope.scope.model.DataProcessModel;
/** /**
* @Author: DongZeLiang * @Author: DongZeLiang

View File

@ -1,7 +1,7 @@
package com.muyu.engine.domain.scope; package com.muyu.etl.domain.scope.scope;
import com.muyu.engine.domain.scope.model.DataSetProcessModel; import com.muyu.etl.domain.scope.scope.model.DataSetProcessModel;
/** /**
* @Author: DongZeLiang * @Author: DongZeLiang
@ -23,4 +23,6 @@ public class DataSetContext implements ScopeContext<DataSetProcessModel>{
public DataSetProcessModel get() { public DataSetProcessModel get() {
return THREAD_LOCAL.get(); return THREAD_LOCAL.get();
} }
} }

View File

@ -1,7 +1,7 @@
package com.muyu.engine.domain.scope; package com.muyu.etl.domain.scope.scope;
import com.muyu.engine.domain.scope.model.RecordProcessModel; import com.muyu.etl.domain.scope.scope.model.RecordProcessModel;
/** /**
* @Author: DongZeLiang * @Author: DongZeLiang

View File

@ -1,4 +1,4 @@
package com.muyu.engine.domain.scope; package com.muyu.etl.domain.scope.scope;
/** /**
* @Author: DongZeLiang * @Author: DongZeLiang

View File

@ -1,4 +1,4 @@
package com.muyu.engine.domain.scope; package com.muyu.etl.domain.scope.scope;
/** /**
* @Author: DongZeLiang * @Author: DongZeLiang

View File

@ -1,7 +1,7 @@
package com.muyu.engine.domain.scope.model; package com.muyu.etl.domain.scope.scope.model;
import com.muyu.engine.domain.model.DataModel; import com.muyu.etl.domain.scope.model.DataModel;
import lombok.Data; import lombok.Data;
/** /**

View File

@ -1,7 +1,7 @@
package com.muyu.engine.domain.scope.model; package com.muyu.etl.domain.scope.scope.model;
import com.muyu.engine.domain.model.DataSetModel; import com.muyu.etl.domain.scope.model.DataSetModel;
import lombok.Data; import lombok.Data;
/** /**

View File

@ -1,7 +1,6 @@
package com.muyu.engine.domain.scope.model; package com.muyu.etl.domain.scope.scope.model;
import com.muyu.etl.domain.scope.model.RecordModel;
import com.muyu.engine.domain.model.RecordModel;
import lombok.Data; import lombok.Data;
/** /**

View File

@ -0,0 +1,22 @@
package com.muyu.etl.domain.scope.test;
import com.muyu.etl.domain.scope.engine.action.ActionDiscard;
import com.muyu.etl.domain.scope.engine.scope.DataModelEngine;
/**
* @Author: Saisai
* @date: 2024/4/3
* @Description: -test
* @Version: 1.0
*/
public class Engine_custom_email_test extends DataModelEngine {
@Override
public void execution () {
Object value = getValue();
if (value == null || "".equals(value) || "null".equals(value)) {
throw new ActionDiscard();
}
}
}

View File

@ -20,7 +20,6 @@ public class JDBCUtils {
Properties properties = new Properties(); Properties properties = new Properties();
try { try {
//Class.forName(driver); //Class.forName(driver);
properties.load(new FileInputStream("src/api/connection/mysql.properties")); properties.load(new FileInputStream("src/api/connection/mysql.properties"));
driver = properties.getProperty("driver"); driver = properties.getProperty("driver");
url = properties.getProperty("url"); url = properties.getProperty("url");

View File

@ -14,17 +14,15 @@ import com.muyu.etl.domain.resp.BasicTableInfoResp;
import com.muyu.etl.domain.resp.StructureValueResp; import com.muyu.etl.domain.resp.StructureValueResp;
import com.muyu.etl.domain.resp.TableInfoStructureResp; import com.muyu.etl.domain.resp.TableInfoStructureResp;
import com.muyu.etl.domain.resp.TableTreeResp; import com.muyu.etl.domain.resp.TableTreeResp;
import com.muyu.etl.domain.scope.model.DataModel;
import com.muyu.etl.domain.scope.model.DataSetModel;
import com.muyu.etl.domain.scope.model.RecordModel;
import com.muyu.etl.domain.scope.scope.DataModelContext;
import com.muyu.etl.mapper.BasicConfigInfoMapper; import com.muyu.etl.mapper.BasicConfigInfoMapper;
import com.muyu.etl.service.BasicConfigInfoService; import com.muyu.etl.service.BasicConfigInfoService;
import com.muyu.etl.service.StructureService; import com.muyu.etl.service.StructureService;
import com.muyu.etl.service.TableInfoService; import com.muyu.etl.service.TableInfoService;
import lombok.SneakyThrows;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -32,9 +30,8 @@ import org.springframework.transaction.annotation.Transactional;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import java.sql.*; import java.sql.*;
import java.util.*;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.Future; import java.util.concurrent.Future;
@ -66,7 +63,7 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMappe
* *
* *
* @param id * @param id
* @return * @return BasicConfigInfo
*/ */
@Override @Override
public BasicConfigInfo selectBasicConfigInfoById(Long id) { public BasicConfigInfo selectBasicConfigInfoById(Long id) {
@ -161,9 +158,10 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMappe
System.out.println("Connected to the MySQL server successfully."); System.out.println("Connected to the MySQL server successfully.");
//同步数据库信息 //同步数据库信息
basicConfigInfo.setIsTest("1"); basicConfigInfo.setIsTest("1");
this.update(basicConfigInfo, new LambdaUpdateWrapper<>(BasicConfigInfo.class) {{ // this.saveOrUpdate(basicConfigInfo, new LambdaUpdateWrapper<>(BasicConfigInfo.class) {{
eq(BasicConfigInfo::getId, basicConfigInfo.getId()); // eq(BasicConfigInfo::getId, basicConfigInfo.getId());
}}); // }});
this.updateById(basicConfigInfo);
//树级结构,库,表 //树级结构,库,表
TableInfo tableInfoInsert = TableInfo.builder() TableInfo tableInfoInsert = TableInfo.builder()
.basicId(basicConfigInfo.getId()) .basicId(basicConfigInfo.getId())
@ -175,7 +173,7 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMappe
.createBy(SecurityUtils.getUsername()) .createBy(SecurityUtils.getUsername())
.createTime(new Date()) .createTime(new Date())
.build(); .build();
tableInfoService.saveOrUpdate(tableInfoInsert, new LambdaUpdateWrapper<TableInfo>(TableInfo.class) {{ tableInfoService.saveOrUpdate(tableInfoInsert, new LambdaUpdateWrapper<>(TableInfo.class) {{
eq(TableInfo::getTableName, tableInfoInsert.getTableName()); eq(TableInfo::getTableName, tableInfoInsert.getTableName());
eq(TableInfo::getBasicId, basicConfigInfo.getId()); eq(TableInfo::getBasicId, basicConfigInfo.getId());
}}); }});
@ -189,12 +187,11 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMappe
//表名 //表名
String tableName = rs.getString("TABLE_NAME"); String tableName = rs.getString("TABLE_NAME");
String tableRemark = rs.getString("REMARKS"); String tableRemark = rs.getString("REMARKS");
Connection finalConn = conn; PreparedStatement ps = conn.prepareStatement("Select COUNT(*) FROM " + tableName);
PreparedStatement ps = conn.prepareStatement("select * from " + tableName);
ResultSet rset = ps.executeQuery(); ResultSet rset = ps.executeQuery();
Long rowCount = 0L; Long rowCount = 0L;
while (rset.next()) { while (rset.next()) {
rowCount++; rowCount = rset.getLong(1);
} }
TableInfo build = TableInfo.builder() TableInfo build = TableInfo.builder()
.basicId(basicConfigInfo.getId()) .basicId(basicConfigInfo.getId())
@ -215,10 +212,9 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMappe
TableInfo table = tableInfoService.selectTableInfoByName(build); TableInfo table = tableInfoService.selectTableInfoByName(build);
//线程池 //线程池
ExecutorService threadPool = Executors.newCachedThreadPool(); ExecutorService threadPool = Executors.newCachedThreadPool();
threadPool.submit(() -> { threadPool.submit(() -> {
try { try {
syncData(finalConn, databaseName, table); syncData(conn, databaseName, table);
} catch (SQLException e) { } catch (SQLException e) {
try { try {
throw new ServletException("同步数据失败"); throw new ServletException("同步数据失败");
@ -227,21 +223,6 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMappe
} }
} }
}); });
// Runnable thread = new Runnable() {
// @SneakyThrows
// @Override
// public void run() {
// try {
// //同步
// syncData(finalConn, databaseName, table);
// } catch (SQLException e) {
// log.error(e.getMessage());
//
// throw new ServletException("连接失败(同步失败)");
// }
// }
// };
// thread.run();
ps.close(); ps.close();
} }
conn.close(); conn.close();
@ -442,18 +423,17 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMappe
List<Structure> structureList = structureService.list(new LambdaQueryWrapper<Structure>() {{ List<Structure> structureList = structureService.list(new LambdaQueryWrapper<Structure>() {{
eq(Structure::getTableId, tableInfoScopeReq.getId()); eq(Structure::getTableId, tableInfoScopeReq.getId());
}}); }});
//字段级 //字段级
if (tableInfoScopeReq.getLevel().equals("data-field")) { if (tableInfoScopeReq.getLevel().equals("data-field")) {
return getList(tableInfoScopeReq, structureList, 1); return getList(tableInfoScopeReq, structureList, 0,1);
} }
//行级 //行级
if (tableInfoScopeReq.getLevel().equals("data-record")) { if (tableInfoScopeReq.getLevel().equals("data-record")) {
return getList(tableInfoScopeReq, structureList, 5); return getList(tableInfoScopeReq, structureList, 0,5);
} }
//页级 //页级
if (tableInfoScopeReq.getLevel().equals("data-set")) { if (tableInfoScopeReq.getLevel().equals("data-set")) {
return getList(tableInfoScopeReq, structureList, 10); return getList(tableInfoScopeReq, structureList, 3,10);
} }
return null; return null;
} }
@ -463,21 +443,44 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMappe
* *
* @return * @return
*/ */
public List<HashMap<String, StructureValueResp>> getList(TableInfoScopeReq tableInfoScopeReq, List<Structure> structureList, int num) { public List<DataSetModel> getList(TableInfoScopeReq tableInfoScopeReq, List<Structure> structureList, int last,int num) {
List<HashMap<String, StructureValueResp>> list = null; List<DataSetModel> list = new ArrayList<>();
HashMap<String, StructureValueResp> valueRespHashMap = new HashMap<>();
BasicConfigInfo basicConfigInfo = this.selectBasicConfigInfoById(tableInfoScopeReq.getBasicId()); BasicConfigInfo basicConfigInfo = this.selectBasicConfigInfoById(tableInfoScopeReq.getBasicId());
try { try {
// 获取该接入的连接
Connection conn = this.getConn(basicConfigInfo); Connection conn = this.getConn(basicConfigInfo);
PreparedStatement ps = conn.prepareStatement("select * from " + tableInfoScopeReq.getTableName() + " limit ?"); for (int i = 0; i < last; i++) {
PreparedStatement ps = conn.prepareStatement("select * from " + tableInfoScopeReq.getTableName() + " limit ?,?");
//随机条
ps.setInt(1, i);
ps.setInt(2, num);
ResultSet rs = ps.executeQuery(); ResultSet rs = ps.executeQuery();
List<RecordModel> recordModelList = new ArrayList<>();
while (rs.next()) { while (rs.next()) {
for (int i = 0; i < structureList.size(); i++) { List<DataModel> dataModelList = new ArrayList<>();
StructureValueResp structureValueResp = StructureValueResp.saveBuilder(structureList.get(i), for (int ia = 0; ia < structureList.size(); ia++) {
String.valueOf(rs.getObject(i + 1))); int finalI = ia;
valueRespHashMap.put(structureList.get(i).getColumnName(), structureValueResp); DataModel dataModel = new DataModel(){{
list.add(valueRespHashMap); setKey(structureList.get(finalI).getColumnName());
setValue(String.valueOf(rs.getObject(structureList.get(finalI).getColumnName())));
setProcessClass(String.class);
setSourceType(structureList.get(finalI).getColumnType());
setSourceType(structureList.get(finalI).getJavaType());
}};
log.info("对象{}",dataModel);
dataModelList.add(dataModel);
} }
// 记录模型
RecordModel recordModel = RecordModel.build(dataModelList.toArray(new DataModel[structureList.size()]));
recordModelList.add(recordModel);
log.info("recordModelList数据{}", recordModelList);
}
// 页数据
DataSetModel build = DataSetModel.build(recordModelList.toArray(new RecordModel[num]));
list.add(build);
log.info("list数据{}", list);
} }
} catch (SQLException e) { } catch (SQLException e) {
throw new RuntimeException(e); throw new RuntimeException(e);

View File

@ -4,6 +4,24 @@ server:
# Spring # Spring
spring: spring:
rabbitmq:
host: 43.142.100.73
port: 5672
username: guest
password: guest
virtual-host: /
publisher-confirm-type: correlated #确认消息已发送到交换机(Exchange)
publisher-returns: true #确认消息已发送到队列(Queue)
listener:
simple:
prefetch: 1 # 每次只能获取一条,处理完成才能获取下一条
acknowledge-mode: manual # 设置消费端手动ack确认
retry:
enabled: true # 是否支持重试
template:
# 只要消息抵达Queue就会异步发送优先回调return firm
mandatory: true
application: application:
# 应用名称 # 应用名称
name: muyu-etl name: muyu-etl
@ -26,20 +44,3 @@ spring:
logging: logging:
level: level:
com.muyu.etl.mapper: DEBUG com.muyu.etl.mapper: DEBUG
rabbitmq:
host: 43.142.100.73
port: 5672
username: guest
password: guest
virtual-host: /
publisher-confirm-type: correlated #确认消息已发送到交换机(Exchange)
publisher-returns: true #确认消息已发送到队列(Queue)
listener:
simple:
prefetch: 1 # 每次只能获取一条,处理完成才能获取下一条
acknowledge-mode: manual # 设置消费端手动ack确认
retry:
enabled: true # 是否支持重试
template:
# 只要消息抵达Queue就会异步发送优先回调return firm
mandatory: true

View File

@ -21,7 +21,7 @@ public class FastDfsSysFileServiceImpl implements ISysFileService {
/** /**
* 访 * 访
*/ */
@Value("${fdfs.domain}") @Value("${fdfs.scope}")
public String domain; public String domain;
@Autowired @Autowired

View File

@ -23,7 +23,7 @@ public class LocalSysFileServiceImpl implements ISysFileService {
/** /**
* 访 * 访
*/ */
@Value("${file.domain}") @Value("${file.scope}")
public String domain; public String domain;
/** /**

View File

@ -164,11 +164,11 @@ public class VelocityUtils {
String mybatisPath = MYBATIS_PATH + "/" + moduleName; String mybatisPath = MYBATIS_PATH + "/" + moduleName;
String vuePath = "vue"; String vuePath = "vue";
if (template.contains("domain.java.vm")) { if (template.contains("scope.java.vm")) {
fileName = StringUtils.format("{}/domain/{}.java", javaPath, className); fileName = StringUtils.format("{}/scope/{}.java", javaPath, className);
} }
if (template.contains("sub-domain.java.vm") && StringUtils.equals(GenConstants.TPL_SUB, genTable.getTplCategory())) { if (template.contains("sub-scope.java.vm") && StringUtils.equals(GenConstants.TPL_SUB, genTable.getTplCategory())) {
fileName = StringUtils.format("{}/domain/{}.java", javaPath, genTable.getSubTable().getClassName()); fileName = StringUtils.format("{}/scope/{}.java", javaPath, genTable.getSubTable().getClassName());
} else if (template.contains("mapper.java.vm")) { } else if (template.contains("mapper.java.vm")) {
fileName = StringUtils.format("{}/mapper/{}Mapper.java", javaPath, className); fileName = StringUtils.format("{}/mapper/{}Mapper.java", javaPath, className);
} else if (template.contains("redis.java.vm")) { } else if (template.contains("redis.java.vm")) {

View File

@ -2,8 +2,8 @@
// //
//import com.muyu.common.core.constant.SecurityConstants; //import com.muyu.common.core.constant.SecurityConstants;
//import com.muyu.common.core.constant.ServiceNameConstants; //import com.muyu.common.core.constant.ServiceNameConstants;
//import com.muyu.common.core.domain.Result; //import com.muyu.common.core.scope.Result;
//import com.muyu.common.system.domain.LoginUser; //import com.muyu.common.system.scope.LoginUser;
//import com.muyu.remote.factory.RemoteRuleEngineFallbackFactory; //import com.muyu.remote.factory.RemoteRuleEngineFallbackFactory;
//import org.springframework.cloud.openfeign.FeignClient; //import org.springframework.cloud.openfeign.FeignClient;
//import org.springframework.web.bind.annotation.GetMapping; //import org.springframework.web.bind.annotation.GetMapping;

View File

@ -1,7 +1,7 @@
//package com.muyu.remote.factory; //package com.muyu.remote.factory;
// //
//import com.muyu.common.core.domain.Result; //import com.muyu.common.core.scope.Result;
//import com.muyu.common.system.domain.LoginUser; //import com.muyu.common.system.scope.LoginUser;
//import com.muyu.remote.RemoteRuleEngineService; //import com.muyu.remote.RemoteRuleEngineService;
//import org.slf4j.Logger; //import org.slf4j.Logger;
//import org.slf4j.LoggerFactory; //import org.slf4j.LoggerFactory;

View File

@ -29,6 +29,14 @@
<artifactId>muyu-ruleEngine-common</artifactId> <artifactId>muyu-ruleEngine-common</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-etl-common</artifactId>
</dependency>
<!-- SpringCloud Alibaba Nacos --> <!-- SpringCloud Alibaba Nacos -->
<dependency> <dependency>
<groupId>com.alibaba.cloud</groupId> <groupId>com.alibaba.cloud</groupId>

View File

@ -115,7 +115,7 @@ public class RuleEngineVersionServiceImpl extends ServiceImpl<RuleEngineVersionM
RuleEngineVersion one = this.getOne(new LambdaQueryWrapper<>() {{ RuleEngineVersion one = this.getOne(new LambdaQueryWrapper<>() {{
eq(RuleEngineVersion::getCode, ruleEngineVersion.getCode()); eq(RuleEngineVersion::getCode, ruleEngineVersion.getCode());
}}); }});
if (!"null".equals(one)) throw new ServletException("该版本已存在"); if (one.getStatus()=="2") throw new ServletException("该版本已发布,无法更改");
String codeIng = ruleEngineVersion.getCodeIng(); String codeIng = ruleEngineVersion.getCodeIng();
try { try {
String path = codeIng.substring(codeIng.indexOf("com"), codeIng.indexOf(";")).replaceAll("\\.", "/").trim(); String path = codeIng.substring(codeIng.indexOf("com"), codeIng.indexOf(";")).replaceAll("\\.", "/").trim();
@ -129,9 +129,11 @@ public class RuleEngineVersionServiceImpl extends ServiceImpl<RuleEngineVersionM
fileName = fileName.substring(0, fileName.indexOf("implements")).trim(); fileName = fileName.substring(0, fileName.indexOf("implements")).trim();
} }
//代码编译 //代码编译
File file = new File("D:/ruoyi/FinallyTest/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-redis/src/main/java/" + path + "/" + fileName + ".java"); File file = new File("D:/ruoyi/FinallyTest/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/src/main/java/" + path + "/" + fileName + ".java");
File fileMenu = new File("D:/ruoyi/FinallyTest/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/src/main/java/" + path );
if (!file.exists()) { if (!file.exists()) {
//不存在创建 //不存在创建
fileMenu.mkdirs();
file.createNewFile(); file.createNewFile();
} else { } else {
//存在测重新创建 //存在测重新创建
@ -177,7 +179,7 @@ public class RuleEngineVersionServiceImpl extends ServiceImpl<RuleEngineVersionM
String name = path + "." + fileName; String name = path + "." + fileName;
String javaPackageName = name.replace(".", File.separator) + ".java"; String javaPackageName = name.replace(".", File.separator) + ".java";
String javaAbsolutePath = "D:/ruoyi/FinallyTest/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-redis/src/main/java/" + javaPackageName; String javaAbsolutePath = "D:/ruoyi/FinallyTest/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-redis/src/main/java/" + javaPackageName;
String jarAbsolutePath = "D:/ruoyi/FinallyTest/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-redis/target/classes/com/muyu/engine/domain/test"; String jarAbsolutePath = "D:/ruoyi/FinallyTest/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-redis/target/classes/com/muyu/engine/scope/test";
Process process = Runtime.getRuntime().exec("javac -classpath " + jarAbsolutePath + " " + javaAbsolutePath); Process process = Runtime.getRuntime().exec("javac -classpath " + jarAbsolutePath + " " + javaAbsolutePath);
try { try {
int exitVal = process.waitFor(); int exitVal = process.waitFor();

View File

@ -14,10 +14,10 @@
//import com.muyu.common.log.annotation.Log; //import com.muyu.common.log.annotation.Log;
//import com.muyu.common.log.enums.BusinessType; //import com.muyu.common.log.enums.BusinessType;
//import com.muyu.common.security.annotation.RequiresPermissions; //import com.muyu.common.security.annotation.RequiresPermissions;
//import com.muyu.system.domain.AsNoticeUser; //import com.muyu.system.scope.AsNoticeUser;
//import com.muyu.system.redis.AsNoticeUserService; //import com.muyu.system.redis.AsNoticeUserService;
//import com.muyu.common.core.web.controller.BaseController; //import com.muyu.common.core.web.controller.BaseController;
//import com.muyu.common.core.domain.Result; //import com.muyu.common.core.scope.Result;
//import com.muyu.common.core.utils.poi.ExcelUtil; //import com.muyu.common.core.utils.poi.ExcelUtil;
//import com.muyu.common.core.web.page.TableDataInfo; //import com.muyu.common.core.web.page.TableDataInfo;
// //

View File

@ -39,16 +39,24 @@ public class AddInitConn {
throw new ServletException("队列内容为空"); throw new ServletException("队列内容为空");
} }
BasicConfigInfo basicConfigInfo = JSON.parseObject(basicInfo, BasicConfigInfo.class); BasicConfigInfo basicConfigInfo = JSON.parseObject(basicInfo, BasicConfigInfo.class);
log.info("队列信息{}",basicInfo);
try { try {
DruidPooledConnection init = connectionPoolFactory.init(basicConfigInfo); DruidPooledConnection init = connectionPoolFactory.init(basicConfigInfo);
if (init == null){ if (init == null){
// 消息拒绝,放回队列中重新消费 // 消息拒绝,放回队列中重新消费
channel.basicReject(message.getMessageProperties().getDeliveryTag(), true); channel.basicReject(message.getMessageProperties().getDeliveryTag(), false);
throw new ServletException("初始化连接池失败");
}else { }else {
// 消息消费确认 // 消息消费确认
channel.basicAck(message.getMessageProperties().getDeliveryTag(), true); channel.basicAck(message.getMessageProperties().getDeliveryTag(), true);
} }
} catch (SQLException | IOException e) { } catch (SQLException | IOException e) {
try {
channel.basicReject(message.getMessageProperties().getDeliveryTag(), false);
} catch (IOException ex) {
log.error("消息未执行,接入未生成");
throw new RuntimeException(ex);
}
log.error("初始化连接池失败,消费失败"); log.error("初始化连接池失败,消费失败");
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View File

@ -38,9 +38,9 @@ insert into config_info(id, data_id, group_id, content, md5, gmt_create, gmt_mod
(3,'muyu-auth-dev.yml','DEFAULT_GROUP','spring:\n redis:\n host: localhost\n port: 6379\n password:\n','8bd9dada9a94822feeab40de55efced6','2020-11-20 00:00:00','2022-09-29 02:48:42','nacos','0:0:0:0:0:0:0:1','','','认证中心','null','null','yaml','',''), (3,'muyu-auth-dev.yml','DEFAULT_GROUP','spring:\n redis:\n host: localhost\n port: 6379\n password:\n','8bd9dada9a94822feeab40de55efced6','2020-11-20 00:00:00','2022-09-29 02:48:42','nacos','0:0:0:0:0:0:0:1','','','认证中心','null','null','yaml','',''),
(4,'muyu-monitor-dev.yml','DEFAULT_GROUP','# spring\nspring:\n security:\n user:\n name: muyu\n password: 123456\n boot:\n admin:\n ui:\n title: 若依服务状态监控\n','6f122fd2bfb8d45f858e7d6529a9cd44','2020-11-20 00:00:00','2022-09-29 02:48:54','nacos','0:0:0:0:0:0:0:1','','','监控中心','null','null','yaml','',''), (4,'muyu-monitor-dev.yml','DEFAULT_GROUP','# spring\nspring:\n security:\n user:\n name: muyu\n password: 123456\n boot:\n admin:\n ui:\n title: 若依服务状态监控\n','6f122fd2bfb8d45f858e7d6529a9cd44','2020-11-20 00:00:00','2022-09-29 02:48:54','nacos','0:0:0:0:0:0:0:1','','','监控中心','null','null','yaml','',''),
(5,'muyu-system-dev.yml','DEFAULT_GROUP','# spring配置\nspring:\n redis:\n host: localhost\n port: 6379\n password:\n datasource:\n druid:\n stat-view-servlet:\n enabled: true\n loginUsername: admin\n loginPassword: 123456\n dynamic:\n druid:\n initial-size: 5\n min-idle: 5\n maxActive: 20\n maxWait: 60000\n timeBetweenEvictionRunsMillis: 60000\n minEvictableIdleTimeMillis: 300000\n validationQuery: SELECT 1 FROM DUAL\n testWhileIdle: true\n testOnBorrow: false\n testOnReturn: false\n poolPreparedStatements: true\n maxPoolPreparedStatementPerConnectionSize: 20\n filters: stat,slf4j\n connectionProperties: druid.stat.mergeSql\\=true;druid.stat.slowSqlMillis\\=5000\n datasource:\n # 主库数据源\n master:\n driver-class-name: com.mysql.cj.jdbc.Driver\n url: jdbc:mysql://localhost:3306/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8\n username: root\n password: root\n # 从库数据源\n # slave:\n # username: \n # password: \n # url: \n # driver-class-name: \n\n# mybatis配置\nmybatis:\n # 搜索指定包别名\n typeAliasesPackage: com.muyu.system\n # 配置mapper的扫描找到所有的mapper.xml映射文件\n mapperLocations: classpath:mapper/**/*.xml\n\n# swagger配置\nswagger:\n title: 系统模块接口文档\n license: Powered By muyu\n licenseUrl: https://muyu.vip','48e0ed4a040c402bdc2444213a82c910','2020-11-20 00:00:00','2022-09-29 02:49:09','nacos','0:0:0:0:0:0:0:1','','','系统模块','null','null','yaml','',''), (5,'muyu-system-dev.yml','DEFAULT_GROUP','# spring配置\nspring:\n redis:\n host: localhost\n port: 6379\n password:\n datasource:\n druid:\n stat-view-servlet:\n enabled: true\n loginUsername: admin\n loginPassword: 123456\n dynamic:\n druid:\n initial-size: 5\n min-idle: 5\n maxActive: 20\n maxWait: 60000\n timeBetweenEvictionRunsMillis: 60000\n minEvictableIdleTimeMillis: 300000\n validationQuery: SELECT 1 FROM DUAL\n testWhileIdle: true\n testOnBorrow: false\n testOnReturn: false\n poolPreparedStatements: true\n maxPoolPreparedStatementPerConnectionSize: 20\n filters: stat,slf4j\n connectionProperties: druid.stat.mergeSql\\=true;druid.stat.slowSqlMillis\\=5000\n datasource:\n # 主库数据源\n master:\n driver-class-name: com.mysql.cj.jdbc.Driver\n url: jdbc:mysql://localhost:3306/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8\n username: root\n password: root\n # 从库数据源\n # slave:\n # username: \n # password: \n # url: \n # driver-class-name: \n\n# mybatis配置\nmybatis:\n # 搜索指定包别名\n typeAliasesPackage: com.muyu.system\n # 配置mapper的扫描找到所有的mapper.xml映射文件\n mapperLocations: classpath:mapper/**/*.xml\n\n# swagger配置\nswagger:\n title: 系统模块接口文档\n license: Powered By muyu\n licenseUrl: https://muyu.vip','48e0ed4a040c402bdc2444213a82c910','2020-11-20 00:00:00','2022-09-29 02:49:09','nacos','0:0:0:0:0:0:0:1','','','系统模块','null','null','yaml','',''),
(6,'muyu-gen-dev.yml','DEFAULT_GROUP','# spring配置\nspring:\n redis:\n host: localhost\n port: 6379\n password:\n datasource:\n driver-class-name: com.mysql.cj.jdbc.Driver\n url: jdbc:mysql://localhost:3306/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8\n username: root\n password: root\n\n# mybatis配置\nmybatis:\n # 搜索指定包别名\n typeAliasesPackage: com.muyu.gen.domain\n # 配置mapper的扫描找到所有的mapper.xml映射文件\n mapperLocations: classpath:mapper/**/*.xml\n\n# swagger配置\nswagger:\n title: 代码生成接口文档\n license: Powered By muyu\n licenseUrl: https://muyu.vip\n\n# 代码生成\ngen:\n # 作者\n author: muyu\n # 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool\n packageName: com.muyu.system\n # 自动去除表前缀默认是false\n autoRemovePre: false\n # 表前缀(生成类名不会包含表前缀,多个用逗号分隔)\n tablePrefix: sys_\n','eb592420b3fceae1402881887b8a6a0d','2020-11-20 00:00:00','2022-09-29 02:49:42','nacos','0:0:0:0:0:0:0:1','','','代码生成','null','null','yaml','',''), (6,'muyu-gen-dev.yml','DEFAULT_GROUP','# spring配置\nspring:\n redis:\n host: localhost\n port: 6379\n password:\n datasource:\n driver-class-name: com.mysql.cj.jdbc.Driver\n url: jdbc:mysql://localhost:3306/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8\n username: root\n password: root\n\n# mybatis配置\nmybatis:\n # 搜索指定包别名\n typeAliasesPackage: com.muyu.gen.scope\n # 配置mapper的扫描找到所有的mapper.xml映射文件\n mapperLocations: classpath:mapper/**/*.xml\n\n# swagger配置\nswagger:\n title: 代码生成接口文档\n license: Powered By muyu\n licenseUrl: https://muyu.vip\n\n# 代码生成\ngen:\n # 作者\n author: muyu\n # 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool\n packageName: com.muyu.system\n # 自动去除表前缀默认是false\n autoRemovePre: false\n # 表前缀(生成类名不会包含表前缀,多个用逗号分隔)\n tablePrefix: sys_\n','eb592420b3fceae1402881887b8a6a0d','2020-11-20 00:00:00','2022-09-29 02:49:42','nacos','0:0:0:0:0:0:0:1','','','代码生成','null','null','yaml','',''),
(7,'muyu-job-dev.yml','DEFAULT_GROUP','# spring配置\nspring:\n redis:\n host: localhost\n port: 6379\n password: \n datasource:\n driver-class-name: com.mysql.cj.jdbc.Driver\n url: jdbc:mysql://localhost:3306/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8\n username: root\n password: root\n\n# mybatis配置\nmybatis:\n # 搜索指定包别名\n typeAliasesPackage: com.muyu.job.domain\n # 配置mapper的扫描找到所有的mapper.xml映射文件\n mapperLocations: classpath:mapper/**/*.xml\n\n# swagger配置\nswagger:\n title: 定时任务接口文档\n license: Powered By muyu\n licenseUrl: https://muyu.vip\n','edcf0e3fe13fea07b4ec08b1088f30b3','2020-11-20 00:00:00','2022-09-29 02:50:50','nacos','0:0:0:0:0:0:0:1','','','定时任务','null','null','yaml','',''), (7,'muyu-job-dev.yml','DEFAULT_GROUP','# spring配置\nspring:\n redis:\n host: localhost\n port: 6379\n password: \n datasource:\n driver-class-name: com.mysql.cj.jdbc.Driver\n url: jdbc:mysql://localhost:3306/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8\n username: root\n password: root\n\n# mybatis配置\nmybatis:\n # 搜索指定包别名\n typeAliasesPackage: com.muyu.job.scope\n # 配置mapper的扫描找到所有的mapper.xml映射文件\n mapperLocations: classpath:mapper/**/*.xml\n\n# swagger配置\nswagger:\n title: 定时任务接口文档\n license: Powered By muyu\n licenseUrl: https://muyu.vip\n','edcf0e3fe13fea07b4ec08b1088f30b3','2020-11-20 00:00:00','2022-09-29 02:50:50','nacos','0:0:0:0:0:0:0:1','','','定时任务','null','null','yaml','',''),
(8,'muyu-file-dev.yml','DEFAULT_GROUP','# 本地文件上传 \r\nfile:\r\n domain: http://43.142.100.73:9300\r\n path: D:/muyu/uploadPath\r\n prefix: /statics\r\n\r\n# FastDFS配置\r\nfdfs:\r\n domain: http://8.129.231.12\r\n soTimeout: 3000\r\n connectTimeout: 2000\r\n trackerList: 8.129.231.12:22122\r\n\r\n# Minio配置\r\nminio:\r\n url: http://8.129.231.12:9000\r\n accessKey: minioadmin\r\n secretKey: minioadmin\r\n bucketName: test','5382b93f3d8059d6068c0501fdd41195','2020-11-20 00:00:00','2020-12-21 21:01:59',NULL,'0:0:0:0:0:0:0:1','','','文件服务','null','null','yaml',NULL,''), (8,'muyu-file-dev.yml','DEFAULT_GROUP','# 本地文件上传 \r\nfile:\r\n scope: http://43.142.100.73:9300\r\n path: D:/muyu/uploadPath\r\n prefix: /statics\r\n\r\n# FastDFS配置\r\nfdfs:\r\n scope: http://8.129.231.12\r\n soTimeout: 3000\r\n connectTimeout: 2000\r\n trackerList: 8.129.231.12:22122\r\n\r\n# Minio配置\r\nminio:\r\n url: http://8.129.231.12:9000\r\n accessKey: minioadmin\r\n secretKey: minioadmin\r\n bucketName: test','5382b93f3d8059d6068c0501fdd41195','2020-11-20 00:00:00','2020-12-21 21:01:59',NULL,'0:0:0:0:0:0:0:1','','','文件服务','null','null','yaml',NULL,''),
(9,'sentinel-muyu-gateway','DEFAULT_GROUP','[\r\n {\r\n \"resource\": \"muyu-auth\",\r\n \"count\": 500,\r\n \"grade\": 1,\r\n \"limitApp\": \"default\",\r\n \"strategy\": 0,\r\n \"controlBehavior\": 0\r\n },\r\n {\r\n \"resource\": \"muyu-system\",\r\n \"count\": 1000,\r\n \"grade\": 1,\r\n \"limitApp\": \"default\",\r\n \"strategy\": 0,\r\n \"controlBehavior\": 0\r\n },\r\n {\r\n \"resource\": \"muyu-gen\",\r\n \"count\": 200,\r\n \"grade\": 1,\r\n \"limitApp\": \"default\",\r\n \"strategy\": 0,\r\n \"controlBehavior\": 0\r\n },\r\n {\r\n \"resource\": \"muyu-job\",\r\n \"count\": 300,\r\n \"grade\": 1,\r\n \"limitApp\": \"default\",\r\n \"strategy\": 0,\r\n \"controlBehavior\": 0\r\n }\r\n]','9f3a3069261598f74220bc47958ec252','2020-11-20 00:00:00','2020-11-20 00:00:00',NULL,'0:0:0:0:0:0:0:1','','','限流策略','null','null','json',NULL,''); (9,'sentinel-muyu-gateway','DEFAULT_GROUP','[\r\n {\r\n \"resource\": \"muyu-auth\",\r\n \"count\": 500,\r\n \"grade\": 1,\r\n \"limitApp\": \"default\",\r\n \"strategy\": 0,\r\n \"controlBehavior\": 0\r\n },\r\n {\r\n \"resource\": \"muyu-system\",\r\n \"count\": 1000,\r\n \"grade\": 1,\r\n \"limitApp\": \"default\",\r\n \"strategy\": 0,\r\n \"controlBehavior\": 0\r\n },\r\n {\r\n \"resource\": \"muyu-gen\",\r\n \"count\": 200,\r\n \"grade\": 1,\r\n \"limitApp\": \"default\",\r\n \"strategy\": 0,\r\n \"controlBehavior\": 0\r\n },\r\n {\r\n \"resource\": \"muyu-job\",\r\n \"count\": 300,\r\n \"grade\": 1,\r\n \"limitApp\": \"default\",\r\n \"strategy\": 0,\r\n \"controlBehavior\": 0\r\n }\r\n]','9f3a3069261598f74220bc47958ec252','2020-11-20 00:00:00','2020-11-20 00:00:00',NULL,'0:0:0:0:0:0:0:1','','','限流策略','null','null','json',NULL,'');