提交 355fc9e1 编写于 作者: hebao@lab.ibiz5.com's avatar hebao@lab.ibiz5.com

result保存调整

上级 64569b5c
......@@ -106,13 +106,17 @@ public class BaseEntityServiceImpl implements BaseEntityService
result.setExt1Field(EXT1FIELD.toString());
if(EXT2FIELD!=null)
result.setExt2Field(EXT2FIELD.toString());
result.set(Tag_EngineId,param.get(Tag_EngineId));
Object resultDataSource = ExecResultExService.Default_ResultDataSource;
Object resultTableName = ExecResultExService.Default_ResultTableName;
if(param.containsKey(RuleEngineExService.Setting_ResultDataSource)){
result.set(RuleEngineExService.Setting_ResultDataSource, param.get(RuleEngineExService.Setting_ResultDataSource));
resultDataSource = param.get(RuleEngineExService.Setting_ResultDataSource);
}
if(param.containsKey(RuleEngineExService.Setting_ResultTableName)){
result.set(RuleEngineExService.Setting_ResultTableName, param.get(RuleEngineExService.Setting_ResultTableName));
resultTableName = param.get(RuleEngineExService.Setting_ResultTableName);
}
result.set(Tag_EngineId,param.get(Tag_EngineId));
result.set(RuleEngineExService.Setting_ResultDataSource, resultDataSource);
result.set(RuleEngineExService.Setting_ResultTableName, resultTableName);
if(DIMFIELD == null){
return;
......
......@@ -27,6 +27,8 @@ import java.util.*;
@Service("ExecResultExService")
public class ExecResultExService extends ExecResultServiceImpl {
public static final String Default_ResultDataSource = "default";
public static final String Default_ResultTableName = "IBZRULERESULT";
@Autowired
@Lazy
......@@ -177,8 +179,6 @@ public class ExecResultExService extends ExecResultServiceImpl {
}
}
public static final String Default_ResultTableName = "IBZRULERESULT";
@Autowired
private DstDataSourceExService dstDataSourceService;
......@@ -194,13 +194,9 @@ public class ExecResultExService extends ExecResultServiceImpl {
public int saveResultBatch(List<ExecResult> execResults, String dsName ,String tableName) {
int result = 0;
try {
if(!ObjectUtils.isEmpty(dsName) && !dsName.equalsIgnoreCase("null")){
if(!Default_ResultDataSource.equalsIgnoreCase(dsName)) {
dstDataSourceService.initDataSource(dsName);
DynamicDataSourceContextHolder.push(dsName);
}
if(StringUtils.isEmpty(tableName) || tableName.equalsIgnoreCase("null")){
tableName = Default_ResultTableName;
}
Map<String, DataSource> dynamicDSMap = dynamicRoutingDataSource.getCurrentDataSources();
if (!ObjectUtils.isEmpty(dynamicDSMap) && dynamicDSMap.containsKey(dsName)) {
DataSource ds = dynamicDSMap.get(dsName);
......@@ -211,26 +207,33 @@ public class ExecResultExService extends ExecResultServiceImpl {
}
}
}
}
result = execResultExMapper.replaceBatch(execResults, tableName);
} catch (Exception ex) {
log.error("存储规则结果发生异常,详细错误信息:" + ex.getMessage());
} finally {
if(!Default_ResultDataSource.equalsIgnoreCase(dsName)) {
DynamicDataSourceContextHolder.poll();
}
}
return result;
}
public int clearResultBatch(List<ExecResult> execResults, String dsName ,String tableName) {
int result = 0;
try {
if(!Default_ResultDataSource.equalsIgnoreCase(dsName)){
dstDataSourceService.initDataSource(dsName);
DynamicDataSourceContextHolder.push(dsName);
result = execResultExMapper.clearBatch(execResults, tableName);
}
//result = execResultExMapper.clearBatch(execResults, tableName);
} catch (Exception ex) {
log.error("存储规则结果发生异常,详细错误信息:" + ex.getMessage());
} finally {
if(!Default_ResultDataSource.equalsIgnoreCase(dsName)) {
DynamicDataSourceContextHolder.poll();
}
}
return result;
}
......
......@@ -35,7 +35,7 @@ public class MQConsumeMsgListenerProcessor implements MessageListenerOrderly {
log.info("MQ接收消息为空,直接返回成功");
return ConsumeOrderlyStatus.SUCCESS;
}
System.out.println(System.currentTimeMillis());
//System.out.println(System.currentTimeMillis());
MessageExt messageExt = list.get(0);
log.info("MQ接收到的消息为:" + messageExt.toString());
try {
......@@ -60,7 +60,9 @@ public class MQConsumeMsgListenerProcessor implements MessageListenerOrderly {
try {
String body = new String(messageExt.getBody(), "utf-8");
// Thread.sleep(10000);
// System.out.println("start sleep");
// Thread.sleep(80000);
// System.out.println("end sleep");
EngineMQMsg engineMQMsg = JSON.parseObject(body, new TypeReference<EngineMQMsg>() {});
ruleEngineExService.processData(engineMQMsg);
} catch (Exception e) {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册