Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdst
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdst
提交
14ca8aa9
提交
14ca8aa9
编写于
12月 22, 2020
作者:
zhouweidong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
规则执行结果动态存储
上级
329091a8
变更
2
展开全部
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
145 行增加
和
178 行删除
+145
-178
ExecResultExService.java
.../ibizlab/core/extensions/service/ExecResultExService.java
+6
-61
DbEntityService.java
...ibizlab/core/lite/extensions/service/DbEntityService.java
+139
-117
未找到文件。
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/service/ExecResultExService.java
浏览文件 @
14ca8aa9
...
@@ -3,19 +3,12 @@ package cn.ibizlab.core.extensions.service;
...
@@ -3,19 +3,12 @@ package cn.ibizlab.core.extensions.service;
import
cn.ibizlab.core.lite.extensions.service.DbEntityService
;
import
cn.ibizlab.core.lite.extensions.service.DbEntityService
;
import
cn.ibizlab.core.rule.domain.ExecResult
;
import
cn.ibizlab.core.rule.domain.ExecResult
;
import
cn.ibizlab.core.rule.service.impl.ExecResultServiceImpl
;
import
cn.ibizlab.core.rule.service.impl.ExecResultServiceImpl
;
import
com.alibaba.druid.pool.DruidDataSource
;
import
com.baomidou.dynamic.datasource.DynamicRoutingDataSource
;
import
com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
javax.sql.DataSource
;
import
java.util.*
;
import
java.util.*
;
/**
/**
...
@@ -26,16 +19,9 @@ import java.util.*;
...
@@ -26,16 +19,9 @@ import java.util.*;
@Service
(
"ExecResultExService"
)
@Service
(
"ExecResultExService"
)
public
class
ExecResultExService
extends
ExecResultServiceImpl
{
public
class
ExecResultExService
extends
ExecResultServiceImpl
{
@Autowired
private
DstDataSourceExService
dstDataSourceService
;
@Autowired
@Autowired
private
DbEntityService
dbEntityService
;
private
DbEntityService
dbEntityService
;
@Autowired
@Lazy
private
DynamicRoutingDataSource
dynamicRoutingDataSource
;
private
Map
<
String
,
List
<
ExecResult
>>
resultsSaveAsync
=
new
HashMap
<>();
private
Map
<
String
,
List
<
ExecResult
>>
resultsSaveAsync
=
new
HashMap
<>();
private
Object
objResultSaveAsyncLock
=
new
Object
();
private
Object
objResultSaveAsyncLock
=
new
Object
();
private
Timer
timerSaveAsync
=
null
;
private
Timer
timerSaveAsync
=
null
;
...
@@ -66,7 +52,6 @@ public class ExecResultExService extends ExecResultServiceImpl {
...
@@ -66,7 +52,6 @@ public class ExecResultExService extends ExecResultServiceImpl {
timerSaveAsync
=
new
Timer
();
timerSaveAsync
=
new
Timer
();
//schedule方法是执行时间定时任务的方法
//schedule方法是执行时间定时任务的方法
timerSaveAsync
.
schedule
(
new
TimerTask
()
{
timerSaveAsync
.
schedule
(
new
TimerTask
()
{
//run方法就是具体需要定时执行的任务
//run方法就是具体需要定时执行的任务
@Override
@Override
public
void
run
()
{
public
void
run
()
{
...
@@ -74,25 +59,20 @@ public class ExecResultExService extends ExecResultServiceImpl {
...
@@ -74,25 +59,20 @@ public class ExecResultExService extends ExecResultServiceImpl {
synchronized
(
objResultSaveAsyncLock
)
{
synchronized
(
objResultSaveAsyncLock
)
{
if
(
resultsSaveAsync
.
size
()
>
0
)
{
if
(
resultsSaveAsync
.
size
()
>
0
)
{
for
(
Map
.
Entry
<
String
,
List
<
ExecResult
>>
entry
:
resultsSaveAsync
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
List
<
ExecResult
>>
entry
:
resultsSaveAsync
.
entrySet
())
{
String
tabName
=
""
;
String
dsName
=
entry
.
getKey
();
String
dsName
=
entry
.
getKey
();
List
<
ExecResult
>
execResults
=
entry
.
getValue
();
List
<
ExecResult
>
execResults
=
entry
.
getValue
();
List
<
ExecResult
>
tempExecResults
=
new
ArrayList
<>();
List
<
ExecResult
>
tempExecResults
=
new
ArrayList
<>();
if
(
execResults
.
size
()
>
0
)
{
if
(
execResults
.
size
()
>
0
)
{
dstDataSourceService
.
initDataSource
(
dsName
);
DynamicDataSourceContextHolder
.
push
(
dsName
);
for
(
ExecResult
execResult
:
execResults
)
{
for
(
ExecResult
execResult
:
execResults
)
{
tempExecResults
.
add
(
execResult
);
tempExecResults
.
add
(
execResult
);
Object
objTabName
=
execResult
.
get
(
RuleEngineExService
.
Setting_ResultTableName
);
if
(
StringUtils
.
isEmpty
(
tabName
)
&&
!
ObjectUtils
.
isEmpty
(
objTabName
))
{
tabName
=
String
.
valueOf
(
objTabName
);
}
if
(
tempExecResults
.
size
()
>=
500
)
{
if
(
tempExecResults
.
size
()
>=
500
)
{
saveResultBatch
(
tempExecResults
,
dsName
,
tabName
);
dbEntityService
.
saveResultBatch
(
tempExecResults
,
dsName
);
tempExecResults
.
clear
();
}
}
}
}
if
(
tempExecResults
.
size
()
>
0
)
{
if
(
tempExecResults
.
size
()
>
0
)
{
saveResultBatch
(
tempExecResults
,
dsName
,
tabName
);
dbEntityService
.
saveResultBatch
(
tempExecResults
,
dsName
);
tempExecResults
.
clear
();
}
}
resultsSaveAsync
.
remove
(
dsName
);
resultsSaveAsync
.
remove
(
dsName
);
}
}
...
@@ -101,10 +81,7 @@ public class ExecResultExService extends ExecResultServiceImpl {
...
@@ -101,10 +81,7 @@ public class ExecResultExService extends ExecResultServiceImpl {
}
}
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
log
.
error
(
ex
.
getMessage
());
log
.
error
(
ex
.
getMessage
());
}
finally
{
DynamicDataSourceContextHolder
.
poll
();
}
}
}
}
},
1000
,
10000
);
},
1000
,
10000
);
}
}
...
@@ -135,25 +112,18 @@ public class ExecResultExService extends ExecResultServiceImpl {
...
@@ -135,25 +112,18 @@ public class ExecResultExService extends ExecResultServiceImpl {
synchronized
(
objResultDeleteAsyncLock
)
{
synchronized
(
objResultDeleteAsyncLock
)
{
if
(
resultsDeleteAsync
.
size
()
>
0
)
{
if
(
resultsDeleteAsync
.
size
()
>
0
)
{
for
(
Map
.
Entry
<
String
,
List
<
ExecResult
>>
entry
:
resultsDeleteAsync
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
List
<
ExecResult
>>
entry
:
resultsDeleteAsync
.
entrySet
())
{
String
tabName
=
""
;
String
dsName
=
entry
.
getKey
();
String
dsName
=
entry
.
getKey
();
List
<
ExecResult
>
execResults
=
entry
.
getValue
();
List
<
ExecResult
>
execResults
=
entry
.
getValue
();
List
<
ExecResult
>
tempExecResults
=
new
ArrayList
<>();
List
<
ExecResult
>
tempExecResults
=
new
ArrayList
<>();
if
(
execResults
.
size
()
>
0
)
{
if
(
execResults
.
size
()
>
0
)
{
dstDataSourceService
.
initDataSource
(
dsName
);
DynamicDataSourceContextHolder
.
push
(
dsName
);
for
(
ExecResult
execResult
:
execResults
)
{
for
(
ExecResult
execResult
:
execResults
)
{
tempExecResults
.
add
(
execResult
);
tempExecResults
.
add
(
execResult
);
Object
objTabName
=
execResult
.
get
(
RuleEngineExService
.
Setting_ResultTableName
);
if
(
StringUtils
.
isEmpty
(
tabName
)
&&
!
ObjectUtils
.
isEmpty
(
objTabName
))
{
tabName
=
String
.
valueOf
(
objTabName
);
}
if
(
tempExecResults
.
size
()
>=
500
)
{
if
(
tempExecResults
.
size
()
>=
500
)
{
dbEntityService
.
clearResultBatch
(
tempExecResults
,
tab
Name
);
dbEntityService
.
clearResultBatch
(
tempExecResults
,
ds
Name
);
}
}
}
}
if
(
tempExecResults
.
size
()
>
0
)
{
if
(
tempExecResults
.
size
()
>
0
)
{
dbEntityService
.
clearResultBatch
(
tempExecResults
,
tab
Name
);
dbEntityService
.
clearResultBatch
(
tempExecResults
,
ds
Name
);
}
}
resultsDeleteAsync
.
remove
(
dsName
);
resultsDeleteAsync
.
remove
(
dsName
);
}
}
...
@@ -162,10 +132,7 @@ public class ExecResultExService extends ExecResultServiceImpl {
...
@@ -162,10 +132,7 @@ public class ExecResultExService extends ExecResultServiceImpl {
}
}
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
log
.
error
(
ex
.
getMessage
());
log
.
error
(
ex
.
getMessage
());
}
finally
{
DynamicDataSourceContextHolder
.
poll
();
}
}
}
}
},
1000
,
10000
);
},
1000
,
10000
);
}
}
...
@@ -195,27 +162,5 @@ public class ExecResultExService extends ExecResultServiceImpl {
...
@@ -195,27 +162,5 @@ public class ExecResultExService extends ExecResultServiceImpl {
}});
}});
}
}
}
}
/**
* 根据数据源类型保存结果
* @param args
* @param
*/
private
void
saveResultBatch
(
List
<
ExecResult
>
args
,
String
dsName
,
String
tabName
)
{
Map
<
String
,
DataSource
>
dynamicDSMap
=
dynamicRoutingDataSource
.
getCurrentDataSources
();
if
(!
ObjectUtils
.
isEmpty
(
dynamicDSMap
)
&&
dynamicDSMap
.
containsKey
(
dsName
))
{
DataSource
ds
=
dynamicDSMap
.
get
(
dsName
);
if
(
ds
instanceof
DruidDataSource
)
{
DruidDataSource
druidDataSource
=
(
DruidDataSource
)
dynamicDSMap
.
get
(
dsName
);
if
(
"oracle"
.
equals
(
druidDataSource
.
getDbType
()))
{
dbEntityService
.
saveResultBatchByOracle
(
args
,
tabName
);
args
.
clear
();
return
;
}
}
}
dbEntityService
.
saveResultBatch
(
args
,
tabName
);
args
.
clear
();
}
}
}
ibzdst-core/src/main/java/cn/ibizlab/core/lite/extensions/service/DbEntityService.java
浏览文件 @
14ca8aa9
此差异已折叠。
点击以展开。
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录