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

result保存调整

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