Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdst
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdst
提交
d880dd45
提交
d880dd45
编写于
9月 02, 2021
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
同步表数据代码优化
上级
59ad8c9e
变更
3
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
45 行增加
和
22 行删除
+45
-22
TableSyncExService.java
...n/ibizlab/core/extensions/service/TableSyncExService.java
+32
-14
DbEntityService.java
...ibizlab/core/lite/extensions/service/DbEntityService.java
+3
-2
LiteDataService.java
...ibizlab/core/lite/extensions/service/LiteDataService.java
+10
-6
未找到文件。
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/service/TableSyncExService.java
浏览文件 @
d880dd45
...
...
@@ -138,20 +138,38 @@ public class TableSyncExService extends TableSyncServiceImpl {
@Override
public
boolean
processData
(
List
<
EntityObj
>
datas
)
{
liteDataService
.
saveBatch
(
entityModel
,
dsName
,
datas
);
String
updateSql
=
"UPDATE ibztablesync SET lastwrite=(CASE WHEN lastwrite is null then 0 else lastwrite end+#{et.count}),"
+
"lastendtime=CASE WHEN lastread <= lastwrite THEN #{et.lastendtime} ELSE lastendtime END,"
+
"etltimestamp=CASE WHEN lastread <= lastwrite THEN #{et.etltimestamp} ELSE etltimestamp END,"
+
"lastrunresult=CASE WHEN lastread <= lastwrite THEN 'FINISH' ELSE lastrunresult END WHERE syncid = #{et.syncid}"
;
HashMap
<
String
,
Object
>
param
=
new
HashMap
<>();
param
.
put
(
"count"
,
datas
.
size
());
param
.
put
(
"lastendtime"
,
new
Timestamp
(
System
.
currentTimeMillis
()));
param
.
put
(
"etltimestamp"
,
runTimestamp
);
param
.
put
(
"syncid"
,
sync
.
getId
());
updateBySQL
(
updateSql
,
param
);
return
true
;
boolean
rt
=
liteDataService
.
saveBatch
(
entityModel
,
dsName
,
datas
);
if
(
rt
)
{
String
updateSql
=
"UPDATE ibztablesync SET lastwrite=(CASE WHEN lastwrite is null then 0 else lastwrite end+#{et.count}),"
+
"lastendtime=CASE WHEN lastread <= lastwrite THEN #{et.lastendtime} ELSE lastendtime END,"
+
"etltimestamp=CASE WHEN lastread <= lastwrite THEN #{et.etltimestamp} ELSE etltimestamp END,"
+
"lastrunresult=CASE WHEN lastread <= lastwrite THEN 'FINISH' ELSE lastrunresult END WHERE syncid = #{et.syncid}"
;
HashMap
<
String
,
Object
>
param
=
new
HashMap
<>();
param
.
put
(
"count"
,
datas
.
size
());
param
.
put
(
"lastendtime"
,
new
Timestamp
(
System
.
currentTimeMillis
()));
param
.
put
(
"etltimestamp"
,
runTimestamp
);
param
.
put
(
"syncid"
,
sync
.
getId
());
updateBySQL
(
updateSql
,
param
);
}
else
{
String
updateSql
=
"UPDATE ibztablesync SET lastwrite=CASE WHEN lastwrite is null then 0 else lastwrite end,"
+
"lastruntime=#{et.lastruntime},"
+
"lastendtime=#{et.lastendtime},"
+
//"etltimestamp=#{et.etltimestamp}," +
"lastrunresult='ERROR' WHERE syncid = #{et.syncid}"
;
HashMap
<
String
,
Object
>
param
=
new
HashMap
<>();
param
.
put
(
"lastendtime"
,
new
Timestamp
(
System
.
currentTimeMillis
()));
param
.
put
(
"lastruntime"
,
runTimestamp
);
//param.put("etltimestamp", runTimestamp);
param
.
put
(
"syncid"
,
sync
.
getId
());
updateBySQL
(
updateSql
,
param
);
}
return
rt
;
}
});
}
...
...
ibzdst-core/src/main/java/cn/ibizlab/core/lite/extensions/service/DbEntityService.java
浏览文件 @
d880dd45
...
...
@@ -187,7 +187,7 @@ public class DbEntityService extends ServiceImpl<DbEntityMapper, EntityObj> impl
EntityObj
rowdata
;
while
((
rowdata
=
(
EntityObj
)
myMyBatisCursorItemReader
.
read
())
!=
null
)
{
datas
.
add
(
rowdata
);
if
(
datas
.
size
()
>=
5
){
if
(
datas
.
size
()
>=
processSize
){
boolean
rt
=
callback
.
processData
(
datas
);
datas
.
clear
();
if
(!
rt
)
...
...
@@ -226,7 +226,8 @@ public class DbEntityService extends ServiceImpl<DbEntityMapper, EntityObj> impl
});
});
return
baseMapper
.
saveBatch
(
entityModel
,
list
);
baseMapper
.
saveBatch
(
entityModel
,
list
);
return
true
;
}
catch
(
Exception
ex
)
{
log
.
error
(
"详细错误信息:"
+
ex
.
getMessage
()
+
", 执行sql:"
+
entityModel
.
getTableName
());
...
...
ibzdst-core/src/main/java/cn/ibizlab/core/lite/extensions/service/LiteDataService.java
浏览文件 @
d880dd45
...
...
@@ -58,18 +58,22 @@ public class LiteDataService {
public
boolean
saveBatch
(
EntityModel
entityModel
,
String
dsName
,
List
<
EntityObj
>
list
)
{
List
<
List
<
EntityObj
>>
splist
=
splitList
(
list
,
500
);
splist
.
forEach
(
objs
->{
getEntityService
(
StringUtils
.
isEmpty
(
dsName
)?
entityModel
.
getDsName
():
dsName
).
saveBatch
(
dsName
,
entityModel
,
objs
);
});
for
(
List
<
EntityObj
>
objs:
splist
)
{
if
(!
getEntityService
(
StringUtils
.
isEmpty
(
dsName
)?
entityModel
.
getDsName
():
dsName
).
saveBatch
(
dsName
,
entityModel
,
objs
))
return
false
;
}
return
true
;
}
public
boolean
saveBatch
(
String
systemId
,
String
entityName
,
String
dsName
,
List
<
EntityObj
>
list
)
{
EntityModel
entityModel
=
liteModelService
.
getEntityModel
(
systemId
,
entityName
);
List
<
List
<
EntityObj
>>
splist
=
splitList
(
list
,
500
);
splist
.
forEach
(
objs
->{
getEntityService
(
StringUtils
.
isEmpty
(
dsName
)?
entityModel
.
getDsName
():
dsName
).
saveBatch
(
dsName
,
entityModel
,
objs
);
});
for
(
List
<
EntityObj
>
objs:
splist
)
{
if
(!
getEntityService
(
StringUtils
.
isEmpty
(
dsName
)?
entityModel
.
getDsName
():
dsName
).
saveBatch
(
dsName
,
entityModel
,
objs
))
return
false
;
}
return
true
;
}
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录